Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve json-schema file #200

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"repository": "JamieMason/syncpack",
"scripts": {
"build": "pnpm run clean && pnpm run build:source && pnpm run build:json-schema",
"build:json-schema": "typescript-json-schema --esModuleInterop --noExtraProps --ignoreErrors src/index.ts RcFile --out dist/schema.json",
"build:json-schema": "typescript-json-schema --esModuleInterop --noExtraProps --ignoreErrors src/index.ts JsonSchema --out dist/schema.json",
"build:source": "tsc --project tsconfig.build.json",
"clean": "rm -rf ./dist",
"format": "pnpm run format:lint && pnpm run format:source",
Expand Down
24 changes: 17 additions & 7 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,33 @@ export type SemverRange = '' | '*' | '>' | '>=' | '.x' | '<' | '<=' | '^' | '~'

type DefaultDependencyType = keyof typeof CUSTOM_TYPES;

class CustomString extends String { }

type UnknownString = CustomString & string;

export type DependencyType =
| DefaultDependencyType
| `!${DefaultDependencyType}`
// This is done to allow any other `string` while also offering intellisense
// for the internal dependency types above. `(string & {})` is needed to
// for the internal dependency types above. `UnknownString` is needed to
// prevent typescript from ignoring these specific strings and merging them
// all into `string`, where we'd lose any editor autocomplete for the other
// more specific fields, using (string & {}) stops that from happening.
// more specific fields, using UnknownString stops that from happening.
//
// eslint-disable-next-line @typescript-eslint/ban-types
| (string & {});
| UnknownString;

export type SpecifierType =
| Specifier.Any['name']
| `!${Specifier.Any['name']}`
// This is done to allow any other `string` while also offering intellisense
// for the internal dependency types above. `(string & {})` is needed to
// for the internal dependency types above. `UnknownString` is needed to
// prevent typescript from ignoring these specific strings and merging them
// all into `string`, where we'd lose any editor autocomplete for the other
// more specific fields, using (string & {}) stops that from happening.
// more specific fields, using UnknownString stops that from happening.
//
// eslint-disable-next-line @typescript-eslint/ban-types
| (string & {});
| UnknownString;

export interface GroupConfig {
dependencies?: string[];
Expand Down Expand Up @@ -140,7 +144,9 @@ export interface CliConfig {

export interface RcConfig {
/** @see https://jamiemason.github.io/syncpack/config/custom-types */
customTypes: Record<string, CustomTypeConfig.Any>;
customTypes: {
[name: string]: CustomTypeConfig.Any;
};
/** @see https://jamiemason.github.io/syncpack/config/dependency-types */
dependencyTypes: DependencyType[];
/** @see https://jamiemason.github.io/syncpack/config/filter */
Expand Down Expand Up @@ -174,3 +180,7 @@ export interface RcConfig {
/** @see https://jamiemason.github.io/syncpack/config/version-groups */
versionGroups: VersionGroupConfig.Any[];
}

export interface JsonSchema extends RcConfig {
$schema?: string;
}
Loading