knip 2.37.0 → 2.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/ConfigurationValidator.d.ts +56 -0
- package/dist/ConfigurationValidator.js +1 -0
- package/dist/WorkspaceWorker.d.ts +1 -1
- package/dist/plugins/graphql-codegen/index.d.ts +7 -0
- package/dist/plugins/graphql-codegen/index.js +35 -0
- package/dist/plugins/graphql-codegen/types.d.ts +25 -0
- package/dist/plugins/graphql-codegen/types.js +3 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/util/compilers.d.ts +10 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +4 -0
package/README.md
CHANGED
|
@@ -277,6 +277,7 @@ Knip contains a growing list of plugins:
|
|
|
277
277
|
- [ESLint][plugin-eslint]
|
|
278
278
|
- [Gatsby][plugin-gatsby]
|
|
279
279
|
- [GitHub Actions][plugin-github-actions]
|
|
280
|
+
- [Graphql Codegen][plugin-graphql-codegen]
|
|
280
281
|
- [husky][plugin-husky]
|
|
281
282
|
- [Jest][plugin-jest]
|
|
282
283
|
- [Lefthook][plugin-lefthook]
|
|
@@ -928,6 +929,7 @@ Special thanks to the wonderful people who have contributed to this project:
|
|
|
928
929
|
[plugin-eslint]: ./src/plugins/eslint
|
|
929
930
|
[plugin-gatsby]: ./src/plugins/gatsby
|
|
930
931
|
[plugin-github-actions]: ./src/plugins/github-actions
|
|
932
|
+
[plugin-graphql-codegen]: ./src/plugins/graphql-codegen
|
|
931
933
|
[plugin-husky]: ./src/plugins/husky
|
|
932
934
|
[plugin-jest]: ./src/plugins/jest
|
|
933
935
|
[plugin-lefthook]: ./src/plugins/lefthook
|
|
@@ -34,6 +34,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
34
34
|
ignore: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
35
35
|
ignoreBinaries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
36
36
|
ignoreDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
37
|
+
'graphql-codegen': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
38
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
39
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
40
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
config?: string | string[] | undefined;
|
|
43
|
+
entry?: string | string[] | undefined;
|
|
44
|
+
project?: string | string[] | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
config?: string | string[] | undefined;
|
|
47
|
+
entry?: string | string[] | undefined;
|
|
48
|
+
project?: string | string[] | undefined;
|
|
49
|
+
}>]>>;
|
|
37
50
|
astro: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
38
51
|
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
39
52
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -587,6 +600,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
587
600
|
ignore?: string | string[] | undefined;
|
|
588
601
|
ignoreBinaries?: string[] | undefined;
|
|
589
602
|
ignoreDependencies?: string[] | undefined;
|
|
603
|
+
'graphql-codegen'?: string | boolean | string[] | {
|
|
604
|
+
config?: string | string[] | undefined;
|
|
605
|
+
entry?: string | string[] | undefined;
|
|
606
|
+
project?: string | string[] | undefined;
|
|
607
|
+
} | undefined;
|
|
590
608
|
astro?: string | boolean | string[] | {
|
|
591
609
|
config?: string | string[] | undefined;
|
|
592
610
|
entry?: string | string[] | undefined;
|
|
@@ -804,6 +822,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
804
822
|
ignore?: string | string[] | undefined;
|
|
805
823
|
ignoreBinaries?: string[] | undefined;
|
|
806
824
|
ignoreDependencies?: string[] | undefined;
|
|
825
|
+
'graphql-codegen'?: string | boolean | string[] | {
|
|
826
|
+
config?: string | string[] | undefined;
|
|
827
|
+
entry?: string | string[] | undefined;
|
|
828
|
+
project?: string | string[] | undefined;
|
|
829
|
+
} | undefined;
|
|
807
830
|
astro?: string | boolean | string[] | {
|
|
808
831
|
config?: string | string[] | undefined;
|
|
809
832
|
entry?: string | string[] | undefined;
|
|
@@ -1015,6 +1038,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1015
1038
|
project?: string | string[] | undefined;
|
|
1016
1039
|
} | undefined;
|
|
1017
1040
|
}>>>;
|
|
1041
|
+
'graphql-codegen': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
1042
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1043
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1044
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1045
|
+
}, "strip", z.ZodTypeAny, {
|
|
1046
|
+
config?: string | string[] | undefined;
|
|
1047
|
+
entry?: string | string[] | undefined;
|
|
1048
|
+
project?: string | string[] | undefined;
|
|
1049
|
+
}, {
|
|
1050
|
+
config?: string | string[] | undefined;
|
|
1051
|
+
entry?: string | string[] | undefined;
|
|
1052
|
+
project?: string | string[] | undefined;
|
|
1053
|
+
}>]>>;
|
|
1018
1054
|
astro: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
1019
1055
|
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1020
1056
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -1583,6 +1619,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1583
1619
|
ignore?: string | string[] | undefined;
|
|
1584
1620
|
ignoreBinaries?: string[] | undefined;
|
|
1585
1621
|
ignoreDependencies?: string[] | undefined;
|
|
1622
|
+
'graphql-codegen'?: string | boolean | string[] | {
|
|
1623
|
+
config?: string | string[] | undefined;
|
|
1624
|
+
entry?: string | string[] | undefined;
|
|
1625
|
+
project?: string | string[] | undefined;
|
|
1626
|
+
} | undefined;
|
|
1586
1627
|
astro?: string | boolean | string[] | {
|
|
1587
1628
|
config?: string | string[] | undefined;
|
|
1588
1629
|
entry?: string | string[] | undefined;
|
|
@@ -1794,6 +1835,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1794
1835
|
project?: string | string[] | undefined;
|
|
1795
1836
|
} | undefined;
|
|
1796
1837
|
}> | undefined;
|
|
1838
|
+
'graphql-codegen'?: string | boolean | string[] | {
|
|
1839
|
+
config?: string | string[] | undefined;
|
|
1840
|
+
entry?: string | string[] | undefined;
|
|
1841
|
+
project?: string | string[] | undefined;
|
|
1842
|
+
} | undefined;
|
|
1797
1843
|
astro?: string | boolean | string[] | {
|
|
1798
1844
|
config?: string | string[] | undefined;
|
|
1799
1845
|
entry?: string | string[] | undefined;
|
|
@@ -2026,6 +2072,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2026
2072
|
ignore?: string | string[] | undefined;
|
|
2027
2073
|
ignoreBinaries?: string[] | undefined;
|
|
2028
2074
|
ignoreDependencies?: string[] | undefined;
|
|
2075
|
+
'graphql-codegen'?: string | boolean | string[] | {
|
|
2076
|
+
config?: string | string[] | undefined;
|
|
2077
|
+
entry?: string | string[] | undefined;
|
|
2078
|
+
project?: string | string[] | undefined;
|
|
2079
|
+
} | undefined;
|
|
2029
2080
|
astro?: string | boolean | string[] | {
|
|
2030
2081
|
config?: string | string[] | undefined;
|
|
2031
2082
|
entry?: string | string[] | undefined;
|
|
@@ -2237,6 +2288,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2237
2288
|
project?: string | string[] | undefined;
|
|
2238
2289
|
} | undefined;
|
|
2239
2290
|
}> | undefined;
|
|
2291
|
+
'graphql-codegen'?: string | boolean | string[] | {
|
|
2292
|
+
config?: string | string[] | undefined;
|
|
2293
|
+
entry?: string | string[] | undefined;
|
|
2294
|
+
project?: string | string[] | undefined;
|
|
2295
|
+
} | undefined;
|
|
2240
2296
|
astro?: string | boolean | string[] | {
|
|
2241
2297
|
config?: string | string[] | undefined;
|
|
2242
2298
|
entry?: string | string[] | undefined;
|
|
@@ -52,7 +52,7 @@ export declare class WorkspaceWorker {
|
|
|
52
52
|
installedBinaries: InstalledBinaries;
|
|
53
53
|
referencedDependencies: ReferencedDependencies;
|
|
54
54
|
hasTypesIncluded: Set<string>;
|
|
55
|
-
enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "svelte")[];
|
|
55
|
+
enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "svelte" | "graphqlCodegen")[];
|
|
56
56
|
entryFilePatterns: string[];
|
|
57
57
|
productionEntryFilePatterns: string[];
|
|
58
58
|
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
|
+
export declare const NAME = "Graphql Codegen";
|
|
3
|
+
export declare const ENABLERS: RegExp[];
|
|
4
|
+
export declare const PACKAGE_JSON_PATH = "codegen";
|
|
5
|
+
export declare const isEnabled: IsPluginEnabledCallback;
|
|
6
|
+
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
7
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { timerify } from '../../util/Performance.js';
|
|
2
|
+
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
|
+
import { isConfigurationOutput } from './types.js';
|
|
4
|
+
export const NAME = 'Graphql Codegen';
|
|
5
|
+
export const ENABLERS = [/^@graphql-codegen\//];
|
|
6
|
+
export const PACKAGE_JSON_PATH = 'codegen';
|
|
7
|
+
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
|
+
export const CONFIG_FILE_PATTERNS = ['codegen.{ts,js,json,yml,mjs,cts}', 'package.json'];
|
|
9
|
+
const findPluginDependencies = async (configFilePath, options) => {
|
|
10
|
+
const { manifest, isProduction } = options;
|
|
11
|
+
if (isProduction)
|
|
12
|
+
return [];
|
|
13
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
14
|
+
? manifest[PACKAGE_JSON_PATH]
|
|
15
|
+
: await load(configFilePath);
|
|
16
|
+
if (!localConfig)
|
|
17
|
+
return [];
|
|
18
|
+
const generateSet = Object.values(localConfig.generates);
|
|
19
|
+
const configurationOutput = generateSet.filter(isConfigurationOutput);
|
|
20
|
+
const presets = configurationOutput
|
|
21
|
+
.map(configOutput => (configOutput.preset ? configOutput.preset : undefined))
|
|
22
|
+
.filter((preset) => typeof preset === 'string')
|
|
23
|
+
.map(presetName => `@graphql-codegen/${presetName}${presetName.endsWith('-preset') ? '' : '-preset'}`);
|
|
24
|
+
const flatPlugins = generateSet
|
|
25
|
+
.filter((config) => !isConfigurationOutput(config))
|
|
26
|
+
.map(item => Object.keys(item))
|
|
27
|
+
.flat()
|
|
28
|
+
.map(plugin => `@graphql-codegen/${plugin}`);
|
|
29
|
+
const nestedPlugins = configurationOutput
|
|
30
|
+
.map(configOutput => (configOutput.plugins ? configOutput.plugins : []))
|
|
31
|
+
.flat()
|
|
32
|
+
.map(plugin => `@graphql-codegen/${plugin}`);
|
|
33
|
+
return [...presets, ...flatPlugins, ...nestedPlugins];
|
|
34
|
+
};
|
|
35
|
+
export const findDependencies = timerify(findPluginDependencies);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type PluginConfig<T = unknown> = {
|
|
2
|
+
[key: string]: T;
|
|
3
|
+
};
|
|
4
|
+
export interface ConfiguredPlugin {
|
|
5
|
+
[name: string]: PluginConfig;
|
|
6
|
+
}
|
|
7
|
+
type NamedPlugin = string;
|
|
8
|
+
type OutputConfig = NamedPlugin | ConfiguredPlugin;
|
|
9
|
+
type PresetNamesBase = 'client' | 'near-operation-file' | 'gql-tag-operations' | 'graphql-modules' | 'import-types';
|
|
10
|
+
export type PresetNames = `${PresetNamesBase}-preset` | PresetNamesBase;
|
|
11
|
+
type OutputPreset = {
|
|
12
|
+
buildGeneratesSection: (options: unknown) => Promise<unknown>;
|
|
13
|
+
prepareDocuments?: (outputFilePath: string, outputSpecificDocuments: unknown) => Promise<unknown>;
|
|
14
|
+
};
|
|
15
|
+
export declare function isConfigurationOutput(config: ConfiguredOutput | ConfiguredPlugin[]): config is ConfiguredOutput;
|
|
16
|
+
interface ConfiguredOutput {
|
|
17
|
+
plugins?: OutputConfig[];
|
|
18
|
+
preset?: PresetNames | OutputPreset;
|
|
19
|
+
}
|
|
20
|
+
export interface GraphqlCodegenTypes {
|
|
21
|
+
generates: {
|
|
22
|
+
[outputPath: string]: ConfiguredOutput | ConfiguredPlugin[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/dist/plugins/index.d.ts
CHANGED
package/dist/plugins/index.js
CHANGED
package/dist/util/compilers.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
22
22
|
ignore?: string | string[] | undefined;
|
|
23
23
|
ignoreBinaries?: string[] | undefined;
|
|
24
24
|
ignoreDependencies?: string[] | undefined;
|
|
25
|
+
'graphql-codegen'?: string | boolean | string[] | {
|
|
26
|
+
config?: string | string[] | undefined;
|
|
27
|
+
entry?: string | string[] | undefined;
|
|
28
|
+
project?: string | string[] | undefined;
|
|
29
|
+
} | undefined;
|
|
25
30
|
astro?: string | boolean | string[] | {
|
|
26
31
|
config?: string | string[] | undefined;
|
|
27
32
|
entry?: string | string[] | undefined;
|
|
@@ -233,6 +238,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
233
238
|
project?: string | string[] | undefined;
|
|
234
239
|
} | undefined;
|
|
235
240
|
}> | undefined;
|
|
241
|
+
'graphql-codegen'?: string | boolean | string[] | {
|
|
242
|
+
config?: string | string[] | undefined;
|
|
243
|
+
entry?: string | string[] | undefined;
|
|
244
|
+
project?: string | string[] | undefined;
|
|
245
|
+
} | undefined;
|
|
236
246
|
astro?: string | boolean | string[] | {
|
|
237
247
|
config?: string | string[] | undefined;
|
|
238
248
|
entry?: string | string[] | undefined;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.38.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.38.0';
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -276,6 +276,10 @@
|
|
|
276
276
|
"title": "github-actions plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/github-actions/README.md)",
|
|
277
277
|
"$ref": "#/definitions/plugin"
|
|
278
278
|
},
|
|
279
|
+
"graphql-codegen": {
|
|
280
|
+
"title": "graphql-codegen plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/graphql-codegen/README.md)",
|
|
281
|
+
"$ref": "#/definitions/plugin"
|
|
282
|
+
},
|
|
279
283
|
"husky": {
|
|
280
284
|
"title": "husky plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/husky/README.md)",
|
|
281
285
|
"$ref": "#/definitions/plugin"
|