knip 0.0.0-angular.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 +907 -0
- package/dist/ConfigurationChief.d.ts +53 -0
- package/dist/ConfigurationChief.js +297 -0
- package/dist/ConfigurationValidator.d.ts +2325 -0
- package/dist/ConfigurationValidator.js +119 -0
- package/dist/ConsoleStreamer.d.ts +12 -0
- package/dist/ConsoleStreamer.js +34 -0
- package/dist/DependencyDeputy.d.ts +64 -0
- package/dist/DependencyDeputy.js +254 -0
- package/dist/IssueCollector.d.ts +27 -0
- package/dist/IssueCollector.js +52 -0
- package/dist/PrincipalFactory.d.ts +25 -0
- package/dist/PrincipalFactory.js +56 -0
- package/dist/ProjectPrincipal.d.ts +64 -0
- package/dist/ProjectPrincipal.js +197 -0
- package/dist/WorkspaceWorker.d.ts +56 -0
- package/dist/WorkspaceWorker.js +244 -0
- package/dist/binaries/bash-parser.d.ts +6 -0
- package/dist/binaries/bash-parser.js +58 -0
- package/dist/binaries/index.d.ts +2 -0
- package/dist/binaries/index.js +18 -0
- package/dist/binaries/resolvers/c8.d.ts +2 -0
- package/dist/binaries/resolvers/c8.js +10 -0
- package/dist/binaries/resolvers/dotenv.d.ts +2 -0
- package/dist/binaries/resolvers/dotenv.js +6 -0
- package/dist/binaries/resolvers/fallback.d.ts +2 -0
- package/dist/binaries/resolvers/fallback.js +22 -0
- package/dist/binaries/resolvers/index.d.ts +8 -0
- package/dist/binaries/resolvers/index.js +8 -0
- package/dist/binaries/resolvers/node.d.ts +2 -0
- package/dist/binaries/resolvers/node.js +10 -0
- package/dist/binaries/resolvers/nodemon.d.ts +2 -0
- package/dist/binaries/resolvers/nodemon.js +15 -0
- package/dist/binaries/resolvers/npx.d.ts +2 -0
- package/dist/binaries/resolvers/npx.js +20 -0
- package/dist/binaries/resolvers/pnpm.d.ts +2 -0
- package/dist/binaries/resolvers/pnpm.js +63 -0
- package/dist/binaries/resolvers/rollup.d.ts +2 -0
- package/dist/binaries/resolvers/rollup.js +11 -0
- package/dist/binaries/resolvers/yarn.d.ts +2 -0
- package/dist/binaries/resolvers/yarn.js +48 -0
- package/dist/binaries/types.d.ts +15 -0
- package/dist/binaries/types.js +1 -0
- package/dist/binaries/util.d.ts +8 -0
- package/dist/binaries/util.js +33 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +72 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +90 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +334 -0
- package/dist/issues/initializers.d.ts +4 -0
- package/dist/issues/initializers.js +11 -0
- package/dist/manifest/helpers.d.ts +7 -0
- package/dist/manifest/helpers.js +16 -0
- package/dist/manifest/index.d.ts +16 -0
- package/dist/manifest/index.js +56 -0
- package/dist/plugins/_template/index.d.ts +9 -0
- package/dist/plugins/_template/index.js +14 -0
- package/dist/plugins/_template/types.d.ts +3 -0
- package/dist/plugins/_template/types.js +1 -0
- package/dist/plugins/angular/index.d.ts +6 -0
- package/dist/plugins/angular/index.js +36 -0
- package/dist/plugins/angular/types.d.ts +745 -0
- package/dist/plugins/angular/types.js +1 -0
- package/dist/plugins/ava/index.d.ts +7 -0
- package/dist/plugins/ava/index.js +20 -0
- package/dist/plugins/ava/types.d.ts +4 -0
- package/dist/plugins/ava/types.js +1 -0
- package/dist/plugins/babel/helpers.d.ts +15 -0
- package/dist/plugins/babel/helpers.js +34 -0
- package/dist/plugins/babel/index.d.ts +8 -0
- package/dist/plugins/babel/index.js +30 -0
- package/dist/plugins/babel/types.d.ts +9 -0
- package/dist/plugins/babel/types.js +1 -0
- package/dist/plugins/capacitor/index.d.ts +6 -0
- package/dist/plugins/capacitor/index.js +11 -0
- package/dist/plugins/capacitor/types.d.ts +3 -0
- package/dist/plugins/capacitor/types.js +1 -0
- package/dist/plugins/changesets/index.d.ts +6 -0
- package/dist/plugins/changesets/index.js +15 -0
- package/dist/plugins/commitizen/index.d.ts +6 -0
- package/dist/plugins/commitizen/index.js +14 -0
- package/dist/plugins/commitizen/types.d.ts +3 -0
- package/dist/plugins/commitizen/types.js +1 -0
- package/dist/plugins/commitlint/index.d.ts +6 -0
- package/dist/plugins/commitlint/index.js +18 -0
- package/dist/plugins/cspell/index.d.ts +6 -0
- package/dist/plugins/cspell/index.js +17 -0
- package/dist/plugins/cspell/types.d.ts +3 -0
- package/dist/plugins/cspell/types.js +1 -0
- package/dist/plugins/cypress/index.d.ts +5 -0
- package/dist/plugins/cypress/index.js +10 -0
- package/dist/plugins/eslint/fallback.d.ts +1 -0
- package/dist/plugins/eslint/fallback.js +13 -0
- package/dist/plugins/eslint/helpers.d.ts +14 -0
- package/dist/plugins/eslint/helpers.js +83 -0
- package/dist/plugins/eslint/index.d.ts +7 -0
- package/dist/plugins/eslint/index.js +15 -0
- package/dist/plugins/eslint/types.d.ts +27 -0
- package/dist/plugins/eslint/types.js +1 -0
- package/dist/plugins/gatsby/index.d.ts +7 -0
- package/dist/plugins/gatsby/index.js +30 -0
- package/dist/plugins/gatsby/types.d.ts +15 -0
- package/dist/plugins/gatsby/types.js +1 -0
- package/dist/plugins/github-actions/index.d.ts +6 -0
- package/dist/plugins/github-actions/index.js +21 -0
- package/dist/plugins/husky/index.d.ts +6 -0
- package/dist/plugins/husky/index.js +19 -0
- package/dist/plugins/index.d.ts +41 -0
- package/dist/plugins/index.js +41 -0
- package/dist/plugins/jest/index.d.ts +7 -0
- package/dist/plugins/jest/index.js +68 -0
- package/dist/plugins/lefthook/index.d.ts +6 -0
- package/dist/plugins/lefthook/index.js +28 -0
- package/dist/plugins/lint-staged/index.d.ts +6 -0
- package/dist/plugins/lint-staged/index.js +32 -0
- package/dist/plugins/lint-staged/types.d.ts +5 -0
- package/dist/plugins/lint-staged/types.js +1 -0
- package/dist/plugins/markdownlint/helpers.d.ts +1 -0
- package/dist/plugins/markdownlint/helpers.js +6 -0
- package/dist/plugins/markdownlint/index.d.ts +6 -0
- package/dist/plugins/markdownlint/index.js +19 -0
- package/dist/plugins/markdownlint/types.d.ts +3 -0
- package/dist/plugins/markdownlint/types.js +1 -0
- package/dist/plugins/mocha/index.d.ts +6 -0
- package/dist/plugins/mocha/index.js +15 -0
- package/dist/plugins/next/index.d.ts +6 -0
- package/dist/plugins/next/index.js +11 -0
- package/dist/plugins/npm-package-json-lint/index.d.ts +6 -0
- package/dist/plugins/npm-package-json-lint/index.js +13 -0
- package/dist/plugins/npm-package-json-lint/types.d.ts +3 -0
- package/dist/plugins/npm-package-json-lint/types.js +1 -0
- package/dist/plugins/nx/index.d.ts +6 -0
- package/dist/plugins/nx/index.js +24 -0
- package/dist/plugins/nx/types.d.ts +11 -0
- package/dist/plugins/nx/types.js +1 -0
- package/dist/plugins/nyc/index.d.ts +6 -0
- package/dist/plugins/nyc/index.js +11 -0
- package/dist/plugins/playwright/index.d.ts +5 -0
- package/dist/plugins/playwright/index.js +5 -0
- package/dist/plugins/postcss/index.d.ts +6 -0
- package/dist/plugins/postcss/index.js +23 -0
- package/dist/plugins/postcss/types.d.ts +3 -0
- package/dist/plugins/postcss/types.js +1 -0
- package/dist/plugins/prettier/index.d.ts +6 -0
- package/dist/plugins/prettier/index.js +20 -0
- package/dist/plugins/release-it/index.d.ts +6 -0
- package/dist/plugins/release-it/index.js +30 -0
- package/dist/plugins/release-it/types.d.ts +10 -0
- package/dist/plugins/release-it/types.js +1 -0
- package/dist/plugins/remark/index.d.ts +6 -0
- package/dist/plugins/remark/index.js +18 -0
- package/dist/plugins/remix/index.d.ts +6 -0
- package/dist/plugins/remix/index.js +11 -0
- package/dist/plugins/rollup/index.d.ts +5 -0
- package/dist/plugins/rollup/index.js +5 -0
- package/dist/plugins/semantic-release/index.d.ts +6 -0
- package/dist/plugins/semantic-release/index.js +17 -0
- package/dist/plugins/semantic-release/types.d.ts +3 -0
- package/dist/plugins/semantic-release/types.js +1 -0
- package/dist/plugins/sentry/index.d.ts +5 -0
- package/dist/plugins/sentry/index.js +5 -0
- package/dist/plugins/storybook/index.d.ts +8 -0
- package/dist/plugins/storybook/index.js +19 -0
- package/dist/plugins/storybook/types.d.ts +11 -0
- package/dist/plugins/storybook/types.js +1 -0
- package/dist/plugins/stryker/index.d.ts +6 -0
- package/dist/plugins/stryker/index.js +17 -0
- package/dist/plugins/stryker/types.d.ts +5 -0
- package/dist/plugins/stryker/types.js +1 -0
- package/dist/plugins/stylelint/index.d.ts +6 -0
- package/dist/plugins/stylelint/index.js +22 -0
- package/dist/plugins/stylelint/types.d.ts +4 -0
- package/dist/plugins/stylelint/types.js +1 -0
- package/dist/plugins/svelte/index.d.ts +7 -0
- package/dist/plugins/svelte/index.js +9 -0
- package/dist/plugins/tailwind/index.d.ts +5 -0
- package/dist/plugins/tailwind/index.js +5 -0
- package/dist/plugins/typedoc/index.d.ts +6 -0
- package/dist/plugins/typedoc/index.js +22 -0
- package/dist/plugins/typedoc/types.d.ts +3 -0
- package/dist/plugins/typedoc/types.js +1 -0
- package/dist/plugins/typescript/index.d.ts +7 -0
- package/dist/plugins/typescript/index.js +42 -0
- package/dist/plugins/vite/index.d.ts +6 -0
- package/dist/plugins/vite/index.js +12 -0
- package/dist/plugins/vite/types.d.ts +4 -0
- package/dist/plugins/vite/types.js +1 -0
- package/dist/plugins/vitest/helpers.d.ts +6 -0
- package/dist/plugins/vitest/helpers.js +22 -0
- package/dist/plugins/vitest/index.d.ts +9 -0
- package/dist/plugins/vitest/index.js +25 -0
- package/dist/plugins/vitest/types.d.ts +11 -0
- package/dist/plugins/vitest/types.js +1 -0
- package/dist/plugins/webpack/index.d.ts +6 -0
- package/dist/plugins/webpack/index.js +82 -0
- package/dist/plugins/webpack/types.d.ts +10 -0
- package/dist/plugins/webpack/types.js +1 -0
- package/dist/reporters/codeowners.d.ts +3 -0
- package/dist/reporters/codeowners.js +62 -0
- package/dist/reporters/compact.d.ts +3 -0
- package/dist/reporters/compact.js +36 -0
- package/dist/reporters/index.d.ts +7 -0
- package/dist/reporters/index.js +10 -0
- package/dist/reporters/json.d.ts +3 -0
- package/dist/reporters/json.js +67 -0
- package/dist/reporters/symbols.d.ts +3 -0
- package/dist/reporters/symbols.js +54 -0
- package/dist/reporters/util.d.ts +15 -0
- package/dist/reporters/util.js +17 -0
- package/dist/types/cli.d.ts +10 -0
- package/dist/types/cli.js +1 -0
- package/dist/types/compilers.d.ts +6 -0
- package/dist/types/compilers.js +1 -0
- package/dist/types/config.d.ts +39 -0
- package/dist/types/config.js +3 -0
- package/dist/types/exports.d.ts +20 -0
- package/dist/types/exports.js +1 -0
- package/dist/types/imports.d.ts +13 -0
- package/dist/types/imports.js +1 -0
- package/dist/types/issues.d.ts +62 -0
- package/dist/types/issues.js +10 -0
- package/dist/types/plugins.d.ts +19 -0
- package/dist/types/plugins.js +1 -0
- package/dist/types/workspace.d.ts +17 -0
- package/dist/types/workspace.js +1 -0
- package/dist/typescript/SourceFile.d.ts +18 -0
- package/dist/typescript/SourceFile.js +1 -0
- package/dist/typescript/SourceFileManager.d.ts +13 -0
- package/dist/typescript/SourceFileManager.js +57 -0
- package/dist/typescript/ast-helpers.d.ts +27 -0
- package/dist/typescript/ast-helpers.js +101 -0
- package/dist/typescript/createHosts.d.ts +15 -0
- package/dist/typescript/createHosts.js +39 -0
- package/dist/typescript/getImportsAndExports.d.ts +29 -0
- package/dist/typescript/getImportsAndExports.js +159 -0
- package/dist/typescript/resolveModuleNames.d.ts +2 -0
- package/dist/typescript/resolveModuleNames.js +27 -0
- package/dist/typescript/sys.d.ts +35 -0
- package/dist/typescript/sys.js +16 -0
- package/dist/typescript/utils.d.ts +2 -0
- package/dist/typescript/utils.js +9 -0
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +3 -0
- package/dist/typescript/visitors/exports/exportAssignment.js +9 -0
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +3 -0
- package/dist/typescript/visitors/exports/exportDeclaration.js +13 -0
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +3 -0
- package/dist/typescript/visitors/exports/exportKeyword.js +77 -0
- package/dist/typescript/visitors/exports/index.d.ts +3 -0
- package/dist/typescript/visitors/exports/index.js +7 -0
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +3 -0
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +31 -0
- package/dist/typescript/visitors/helpers.d.ts +4 -0
- package/dist/typescript/visitors/helpers.js +10 -0
- package/dist/typescript/visitors/imports/importCall.d.ts +3 -0
- package/dist/typescript/visitors/imports/importCall.js +11 -0
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +3 -0
- package/dist/typescript/visitors/imports/importDeclaration.js +32 -0
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +3 -0
- package/dist/typescript/visitors/imports/importEqualsDeclaration.js +11 -0
- package/dist/typescript/visitors/imports/index.d.ts +3 -0
- package/dist/typescript/visitors/imports/index.js +18 -0
- package/dist/typescript/visitors/imports/jsDocType.d.ts +3 -0
- package/dist/typescript/visitors/imports/jsDocType.js +11 -0
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +3 -0
- package/dist/typescript/visitors/imports/reExportDeclaration.js +21 -0
- package/dist/typescript/visitors/imports/requireCall.d.ts +3 -0
- package/dist/typescript/visitors/imports/requireCall.js +45 -0
- package/dist/typescript/visitors/imports/requireResolveCall.d.ts +3 -0
- package/dist/typescript/visitors/imports/requireResolveCall.js +12 -0
- package/dist/typescript/visitors/index.d.ts +10 -0
- package/dist/typescript/visitors/index.js +16 -0
- package/dist/typescript/visitors/scripts/execa.d.ts +3 -0
- package/dist/typescript/visitors/scripts/execa.js +18 -0
- package/dist/typescript/visitors/scripts/index.d.ts +3 -0
- package/dist/typescript/visitors/scripts/index.js +5 -0
- package/dist/typescript/visitors/scripts/zx.d.ts +3 -0
- package/dist/typescript/visitors/scripts/zx.js +8 -0
- package/dist/util/Performance.d.ts +23 -0
- package/dist/util/Performance.js +80 -0
- package/dist/util/array.d.ts +2 -0
- package/dist/util/array.js +2 -0
- package/dist/util/cli-arguments.d.ts +28 -0
- package/dist/util/cli-arguments.js +83 -0
- package/dist/util/compilers.d.ts +426 -0
- package/dist/util/compilers.js +20 -0
- package/dist/util/debug.d.ts +3 -0
- package/dist/util/debug.js +34 -0
- package/dist/util/errors.d.ts +12 -0
- package/dist/util/errors.js +14 -0
- package/dist/util/fs.d.ts +7 -0
- package/dist/util/fs.js +42 -0
- package/dist/util/get-included-issue-types.d.ts +16 -0
- package/dist/util/get-included-issue-types.js +37 -0
- package/dist/util/git.d.ts +1 -0
- package/dist/util/git.js +20 -0
- package/dist/util/glob.d.ts +19 -0
- package/dist/util/glob.js +59 -0
- package/dist/util/loader.d.ts +1 -0
- package/dist/util/loader.js +31 -0
- package/dist/util/map.d.ts +1 -0
- package/dist/util/map.js +6 -0
- package/dist/util/modules.d.ts +8 -0
- package/dist/util/modules.js +52 -0
- package/dist/util/object.d.ts +3 -0
- package/dist/util/object.js +37 -0
- package/dist/util/path.d.ts +11 -0
- package/dist/util/path.js +13 -0
- package/dist/util/plugin.d.ts +3 -0
- package/dist/util/plugin.js +14 -0
- package/dist/util/register.d.ts +1 -0
- package/dist/util/register.js +14 -0
- package/dist/util/reporter.d.ts +3 -0
- package/dist/util/reporter.js +16 -0
- package/dist/util/require.d.ts +5 -0
- package/dist/util/require.js +34 -0
- package/dist/util/tsconfig-loader.d.ts +2 -0
- package/dist/util/tsconfig-loader.js +11 -0
- package/dist/util/workspace.d.ts +1 -0
- package/dist/util/workspace.js +11 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/license +12 -0
- package/package.json +150 -0
- package/schema.json +403 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const globSchema = z.union([z.string(), z.array(z.string())]);
|
|
3
|
+
const pathsSchema = z.record(z.string(), z.array(z.string()));
|
|
4
|
+
const syncCompilerSchema = z.function().args(z.string()).returns(z.string());
|
|
5
|
+
const asyncCompilerSchema = z.function().args(z.string()).returns(z.promise(z.string()));
|
|
6
|
+
const compilerSchema = z.union([syncCompilerSchema, asyncCompilerSchema]);
|
|
7
|
+
const compilersSchema = z.record(z.string(), compilerSchema);
|
|
8
|
+
const issueTypeSchema = z.union([
|
|
9
|
+
z.literal('files'),
|
|
10
|
+
z.literal('dependencies'),
|
|
11
|
+
z.literal('devDependencies'),
|
|
12
|
+
z.literal('unlisted'),
|
|
13
|
+
z.literal('binaries'),
|
|
14
|
+
z.literal('unresolved'),
|
|
15
|
+
z.literal('exports'),
|
|
16
|
+
z.literal('types'),
|
|
17
|
+
z.literal('nsExports'),
|
|
18
|
+
z.literal('nsTypes'),
|
|
19
|
+
z.literal('duplicates'),
|
|
20
|
+
z.literal('enumMembers'),
|
|
21
|
+
z.literal('classMembers'),
|
|
22
|
+
]);
|
|
23
|
+
const rulesSchema = z.record(issueTypeSchema, z.enum(['error', 'warn', 'off']));
|
|
24
|
+
const ignoreExportsUsedInFileSchema = z.union([
|
|
25
|
+
z.boolean(),
|
|
26
|
+
z.record(z.union([
|
|
27
|
+
z.literal('class'),
|
|
28
|
+
z.literal('enum'),
|
|
29
|
+
z.literal('function'),
|
|
30
|
+
z.literal('interface'),
|
|
31
|
+
z.literal('member'),
|
|
32
|
+
z.literal('type'),
|
|
33
|
+
]), z.boolean()),
|
|
34
|
+
]);
|
|
35
|
+
const rootConfigurationSchema = z.object({
|
|
36
|
+
rules: rulesSchema.optional(),
|
|
37
|
+
entry: globSchema.optional(),
|
|
38
|
+
project: globSchema.optional(),
|
|
39
|
+
paths: pathsSchema.optional(),
|
|
40
|
+
ignore: globSchema.optional(),
|
|
41
|
+
ignoreBinaries: z.array(z.string()).optional(),
|
|
42
|
+
ignoreExportsUsedInFile: ignoreExportsUsedInFileSchema.optional(),
|
|
43
|
+
ignoreDependencies: z.array(z.string()).optional(),
|
|
44
|
+
ignoreWorkspaces: z.array(z.string()).optional(),
|
|
45
|
+
compilers: compilersSchema.optional(),
|
|
46
|
+
syncCompilers: z.record(z.string(), syncCompilerSchema).optional(),
|
|
47
|
+
asyncCompilers: z.record(z.string(), asyncCompilerSchema).optional(),
|
|
48
|
+
});
|
|
49
|
+
const reportConfigSchema = z.object({
|
|
50
|
+
include: z.array(z.string()).optional(),
|
|
51
|
+
exclude: z.array(z.string()).optional(),
|
|
52
|
+
});
|
|
53
|
+
const pluginSchema = z.union([
|
|
54
|
+
z.literal(false),
|
|
55
|
+
globSchema,
|
|
56
|
+
z.object({
|
|
57
|
+
config: globSchema.optional(),
|
|
58
|
+
entry: globSchema.optional(),
|
|
59
|
+
project: globSchema.optional(),
|
|
60
|
+
}),
|
|
61
|
+
]);
|
|
62
|
+
const pluginsSchema = z.object({
|
|
63
|
+
angular: pluginSchema,
|
|
64
|
+
ava: pluginSchema,
|
|
65
|
+
babel: pluginSchema,
|
|
66
|
+
capacitor: pluginSchema,
|
|
67
|
+
changesets: pluginSchema,
|
|
68
|
+
commitizen: pluginSchema,
|
|
69
|
+
commitlint: pluginSchema,
|
|
70
|
+
cspell: pluginSchema,
|
|
71
|
+
cypress: pluginSchema,
|
|
72
|
+
eslint: pluginSchema,
|
|
73
|
+
gatsby: pluginSchema,
|
|
74
|
+
'github-actions': pluginSchema,
|
|
75
|
+
husky: pluginSchema,
|
|
76
|
+
jest: pluginSchema,
|
|
77
|
+
lefthook: pluginSchema,
|
|
78
|
+
'lint-staged': pluginSchema,
|
|
79
|
+
markdownlint: pluginSchema,
|
|
80
|
+
mocha: pluginSchema,
|
|
81
|
+
next: pluginSchema,
|
|
82
|
+
'npm-package-json-lint': pluginSchema,
|
|
83
|
+
nx: pluginSchema,
|
|
84
|
+
nyc: pluginSchema,
|
|
85
|
+
playwright: pluginSchema,
|
|
86
|
+
postcss: pluginSchema,
|
|
87
|
+
prettier: pluginSchema,
|
|
88
|
+
'release-it': pluginSchema,
|
|
89
|
+
remark: pluginSchema,
|
|
90
|
+
remix: pluginSchema,
|
|
91
|
+
rollup: pluginSchema,
|
|
92
|
+
'semantic-release': pluginSchema,
|
|
93
|
+
sentry: pluginSchema,
|
|
94
|
+
storybook: pluginSchema,
|
|
95
|
+
stryker: pluginSchema,
|
|
96
|
+
stylelint: pluginSchema,
|
|
97
|
+
tailwind: pluginSchema,
|
|
98
|
+
typedoc: pluginSchema,
|
|
99
|
+
typescript: pluginSchema,
|
|
100
|
+
vite: pluginSchema,
|
|
101
|
+
vitest: pluginSchema,
|
|
102
|
+
webpack: pluginSchema,
|
|
103
|
+
});
|
|
104
|
+
const baseWorkspaceConfigurationSchema = z.object({
|
|
105
|
+
entry: globSchema.optional(),
|
|
106
|
+
project: globSchema.optional(),
|
|
107
|
+
paths: pathsSchema.optional(),
|
|
108
|
+
ignore: globSchema.optional(),
|
|
109
|
+
ignoreBinaries: z.array(z.string()).optional(),
|
|
110
|
+
ignoreDependencies: z.array(z.string()).optional(),
|
|
111
|
+
});
|
|
112
|
+
const workspaceConfigurationSchema = baseWorkspaceConfigurationSchema.merge(pluginsSchema.partial());
|
|
113
|
+
const workspacesConfigurationSchema = z.object({
|
|
114
|
+
workspaces: z.record(z.string(), workspaceConfigurationSchema).optional(),
|
|
115
|
+
});
|
|
116
|
+
export const ConfigurationValidator = rootConfigurationSchema
|
|
117
|
+
.merge(reportConfigSchema)
|
|
118
|
+
.merge(workspacesConfigurationSchema)
|
|
119
|
+
.merge(pluginsSchema.partial());
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class ConsoleStreamer {
|
|
2
|
+
isEnabled: boolean;
|
|
3
|
+
private lines;
|
|
4
|
+
constructor({ isEnabled }: {
|
|
5
|
+
isEnabled?: boolean | undefined;
|
|
6
|
+
});
|
|
7
|
+
private clearLines;
|
|
8
|
+
private resetLines;
|
|
9
|
+
private update;
|
|
10
|
+
cast(message: string): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export class ConsoleStreamer {
|
|
2
|
+
isEnabled = false;
|
|
3
|
+
lines = 0;
|
|
4
|
+
constructor({ isEnabled = false }) {
|
|
5
|
+
this.isEnabled = isEnabled;
|
|
6
|
+
}
|
|
7
|
+
clearLines(count) {
|
|
8
|
+
if (count > 0) {
|
|
9
|
+
for (let i = 0; i < count; i++) {
|
|
10
|
+
process.stdout.moveCursor(0, -1);
|
|
11
|
+
process.stdout.clearLine(1);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
process.stdout.cursorTo(0);
|
|
15
|
+
}
|
|
16
|
+
resetLines() {
|
|
17
|
+
this.clearLines(this.lines);
|
|
18
|
+
}
|
|
19
|
+
update(messages) {
|
|
20
|
+
this.resetLines();
|
|
21
|
+
process.stdout.write(messages.join('\n') + '\n');
|
|
22
|
+
this.lines = messages.length;
|
|
23
|
+
}
|
|
24
|
+
cast(message) {
|
|
25
|
+
if (!this.isEnabled)
|
|
26
|
+
return;
|
|
27
|
+
this.update([message]);
|
|
28
|
+
}
|
|
29
|
+
clear() {
|
|
30
|
+
if (!this.isEnabled)
|
|
31
|
+
return;
|
|
32
|
+
this.resetLines();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="npmcli__package-json" />
|
|
2
|
+
import type { Workspace } from './ConfigurationChief.js';
|
|
3
|
+
import type { ConfigurationHints, Issue } from './types/issues.js';
|
|
4
|
+
import type { WorkspaceManifests } from './types/workspace.js';
|
|
5
|
+
import type { PeerDependencies, InstalledBinaries } from './types/workspace.js';
|
|
6
|
+
import type { PackageJson } from '@npmcli/package-json';
|
|
7
|
+
type Options = {
|
|
8
|
+
isStrict: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare class DependencyDeputy {
|
|
11
|
+
isStrict: boolean;
|
|
12
|
+
_manifests: WorkspaceManifests;
|
|
13
|
+
referencedDependencies: Map<string, Set<string>>;
|
|
14
|
+
referencedBinaries: Map<string, Set<string>>;
|
|
15
|
+
peerDependencies: Map<string, PeerDependencies>;
|
|
16
|
+
installedBinaries: Map<string, InstalledBinaries>;
|
|
17
|
+
ignoreBinaries: string[];
|
|
18
|
+
ignoreDependencies: string[];
|
|
19
|
+
constructor({ isStrict }: Options);
|
|
20
|
+
addWorkspace({ name, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries, }: {
|
|
21
|
+
name: string;
|
|
22
|
+
dir: string;
|
|
23
|
+
manifestPath: string;
|
|
24
|
+
manifest: PackageJson;
|
|
25
|
+
ignoreDependencies: string[];
|
|
26
|
+
ignoreBinaries: string[];
|
|
27
|
+
}): void;
|
|
28
|
+
addIgnored(ignoreBinaries: string[], ignoreDependencies: string[]): void;
|
|
29
|
+
getWorkspaceManifest(workspaceName: string): {
|
|
30
|
+
workspaceDir: string;
|
|
31
|
+
manifestPath: string;
|
|
32
|
+
scripts: string[];
|
|
33
|
+
dependencies: string[];
|
|
34
|
+
peerDependencies: string[];
|
|
35
|
+
optionalPeerDependencies: string[];
|
|
36
|
+
optionalDependencies: string[];
|
|
37
|
+
devDependencies: string[];
|
|
38
|
+
allDependencies: string[];
|
|
39
|
+
ignoreDependencies: string[];
|
|
40
|
+
ignoreBinaries: string[];
|
|
41
|
+
} | undefined;
|
|
42
|
+
getProductionDependencies(workspaceName: string): string[];
|
|
43
|
+
getDevDependencies(workspaceName: string): string[];
|
|
44
|
+
setInstalledBinaries(workspaceName: string, installedBinaries: Map<string, Set<string>>): void;
|
|
45
|
+
getInstalledBinaries(workspaceName: string): InstalledBinaries | undefined;
|
|
46
|
+
addReferencedDependency(workspaceName: string, packageName: string): void;
|
|
47
|
+
addReferencedBinary(workspaceName: string, binaryName: string): void;
|
|
48
|
+
addPeerDependencies(workspaceName: string, peerDependencies: Map<string, Set<string>>): void;
|
|
49
|
+
getPeerDependenciesOf(workspaceName: string, dependency: string): string[];
|
|
50
|
+
getPeerDependencies(workspaceName: string): string[];
|
|
51
|
+
getOptionalPeerDependencies(workspaceName: string): string[];
|
|
52
|
+
maybeAddReferencedExternalDependency(workspace: Workspace, packageName: string): boolean;
|
|
53
|
+
maybeAddReferencedBinary(workspace: Workspace, binaryName: string): boolean;
|
|
54
|
+
private isInDependencies;
|
|
55
|
+
settleDependencyIssues(): {
|
|
56
|
+
dependencyIssues: Issue[];
|
|
57
|
+
devDependencyIssues: Issue[];
|
|
58
|
+
optionalPeerDependencyIssues: Issue[];
|
|
59
|
+
};
|
|
60
|
+
getConfigurationHints(): {
|
|
61
|
+
configurationHints: ConfigurationHints;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { isBuiltin } from 'node:module';
|
|
2
|
+
import { IGNORE_DEFINITELY_TYPED, IGNORED_DEPENDENCIES, IGNORED_GLOBAL_BINARIES, ROOT_WORKSPACE_NAME, } from './constants.js';
|
|
3
|
+
import { isDefinitelyTyped, getDefinitelyTypedFor, getPackageFromDefinitelyTyped } from './util/modules.js';
|
|
4
|
+
export class DependencyDeputy {
|
|
5
|
+
isStrict;
|
|
6
|
+
_manifests = new Map();
|
|
7
|
+
referencedDependencies;
|
|
8
|
+
referencedBinaries;
|
|
9
|
+
peerDependencies;
|
|
10
|
+
installedBinaries;
|
|
11
|
+
ignoreBinaries = [];
|
|
12
|
+
ignoreDependencies = [];
|
|
13
|
+
constructor({ isStrict }) {
|
|
14
|
+
this.isStrict = isStrict;
|
|
15
|
+
this.referencedDependencies = new Map();
|
|
16
|
+
this.referencedBinaries = new Map();
|
|
17
|
+
this.peerDependencies = new Map();
|
|
18
|
+
this.installedBinaries = new Map();
|
|
19
|
+
}
|
|
20
|
+
addWorkspace({ name, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries, }) {
|
|
21
|
+
const scripts = Object.values(manifest.scripts ?? {});
|
|
22
|
+
const dependencies = Object.keys(manifest.dependencies ?? {});
|
|
23
|
+
const peerDependencies = Object.keys(manifest.peerDependencies ?? {});
|
|
24
|
+
const optionalDependencies = Object.keys(manifest.optionalDependencies ?? {});
|
|
25
|
+
const optionalPeerDependencies = manifest.peerDependenciesMeta
|
|
26
|
+
? peerDependencies.filter(peerDependency => manifest.peerDependenciesMeta &&
|
|
27
|
+
peerDependency in manifest.peerDependenciesMeta &&
|
|
28
|
+
manifest.peerDependenciesMeta[peerDependency].optional)
|
|
29
|
+
: [];
|
|
30
|
+
const devDependencies = Object.keys(manifest.devDependencies ?? {});
|
|
31
|
+
const allDependencies = [...dependencies, ...devDependencies, ...peerDependencies, ...optionalDependencies];
|
|
32
|
+
this._manifests.set(name, {
|
|
33
|
+
workspaceDir: dir,
|
|
34
|
+
manifestPath,
|
|
35
|
+
ignoreDependencies,
|
|
36
|
+
ignoreBinaries,
|
|
37
|
+
scripts,
|
|
38
|
+
dependencies,
|
|
39
|
+
peerDependencies,
|
|
40
|
+
optionalPeerDependencies,
|
|
41
|
+
optionalDependencies,
|
|
42
|
+
devDependencies,
|
|
43
|
+
allDependencies,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
addIgnored(ignoreBinaries, ignoreDependencies) {
|
|
47
|
+
this.ignoreBinaries = ignoreBinaries;
|
|
48
|
+
this.ignoreDependencies = ignoreDependencies;
|
|
49
|
+
}
|
|
50
|
+
getWorkspaceManifest(workspaceName) {
|
|
51
|
+
return this._manifests.get(workspaceName);
|
|
52
|
+
}
|
|
53
|
+
getProductionDependencies(workspaceName) {
|
|
54
|
+
const manifest = this._manifests.get(workspaceName);
|
|
55
|
+
if (!manifest)
|
|
56
|
+
return [];
|
|
57
|
+
if (this.isStrict)
|
|
58
|
+
return [...manifest.dependencies, ...manifest.peerDependencies];
|
|
59
|
+
return manifest.dependencies;
|
|
60
|
+
}
|
|
61
|
+
getDevDependencies(workspaceName) {
|
|
62
|
+
return this._manifests.get(workspaceName)?.devDependencies ?? [];
|
|
63
|
+
}
|
|
64
|
+
setInstalledBinaries(workspaceName, installedBinaries) {
|
|
65
|
+
this.installedBinaries.set(workspaceName, installedBinaries);
|
|
66
|
+
}
|
|
67
|
+
getInstalledBinaries(workspaceName) {
|
|
68
|
+
return this.installedBinaries.get(workspaceName);
|
|
69
|
+
}
|
|
70
|
+
addReferencedDependency(workspaceName, packageName) {
|
|
71
|
+
if (!this.referencedDependencies.has(workspaceName)) {
|
|
72
|
+
this.referencedDependencies.set(workspaceName, new Set());
|
|
73
|
+
}
|
|
74
|
+
this.referencedDependencies.get(workspaceName)?.add(packageName);
|
|
75
|
+
}
|
|
76
|
+
addReferencedBinary(workspaceName, binaryName) {
|
|
77
|
+
if (!this.referencedBinaries.has(workspaceName)) {
|
|
78
|
+
this.referencedBinaries.set(workspaceName, new Set());
|
|
79
|
+
}
|
|
80
|
+
this.referencedBinaries.get(workspaceName)?.add(binaryName);
|
|
81
|
+
}
|
|
82
|
+
addPeerDependencies(workspaceName, peerDependencies) {
|
|
83
|
+
this.peerDependencies.set(workspaceName, peerDependencies);
|
|
84
|
+
}
|
|
85
|
+
getPeerDependenciesOf(workspaceName, dependency) {
|
|
86
|
+
return Array.from(this.peerDependencies.get(workspaceName)?.get(dependency) ?? []);
|
|
87
|
+
}
|
|
88
|
+
getPeerDependencies(workspaceName) {
|
|
89
|
+
const manifest = this._manifests.get(workspaceName);
|
|
90
|
+
if (!manifest)
|
|
91
|
+
return [];
|
|
92
|
+
return manifest.peerDependencies;
|
|
93
|
+
}
|
|
94
|
+
getOptionalPeerDependencies(workspaceName) {
|
|
95
|
+
const manifest = this._manifests.get(workspaceName);
|
|
96
|
+
if (!manifest)
|
|
97
|
+
return [];
|
|
98
|
+
return manifest.optionalPeerDependencies;
|
|
99
|
+
}
|
|
100
|
+
maybeAddReferencedExternalDependency(workspace, packageName) {
|
|
101
|
+
if (isBuiltin(packageName))
|
|
102
|
+
return true;
|
|
103
|
+
if (packageName === workspace.pkgName)
|
|
104
|
+
return true;
|
|
105
|
+
const workspaceNames = this.isStrict ? [workspace.name] : [workspace.name, ...[...workspace.ancestors].reverse()];
|
|
106
|
+
const closestWorkspaceName = workspaceNames.find(name => this.isInDependencies(name, packageName));
|
|
107
|
+
const typesPackageName = !isDefinitelyTyped(packageName) && getDefinitelyTypedFor(packageName);
|
|
108
|
+
const closestWorkspaceNameForTypes = typesPackageName && workspaceNames.find(name => this.isInDependencies(name, typesPackageName));
|
|
109
|
+
if (closestWorkspaceName || closestWorkspaceNameForTypes) {
|
|
110
|
+
closestWorkspaceName && this.addReferencedDependency(closestWorkspaceName, packageName);
|
|
111
|
+
closestWorkspaceNameForTypes && this.addReferencedDependency(closestWorkspaceNameForTypes, typesPackageName);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
this.addReferencedDependency(workspace.name, packageName);
|
|
116
|
+
}
|
|
117
|
+
if (this.getWorkspaceManifest(workspace.name)?.ignoreDependencies.includes(packageName))
|
|
118
|
+
return true;
|
|
119
|
+
if (this.ignoreDependencies.includes(packageName))
|
|
120
|
+
return true;
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
maybeAddReferencedBinary(workspace, binaryName) {
|
|
124
|
+
if (IGNORED_GLOBAL_BINARIES.includes(binaryName))
|
|
125
|
+
return true;
|
|
126
|
+
this.addReferencedBinary(workspace.name, binaryName);
|
|
127
|
+
const workspaceNames = this.isStrict ? [workspace.name] : [workspace.name, ...[...workspace.ancestors].reverse()];
|
|
128
|
+
for (const name of workspaceNames) {
|
|
129
|
+
const binaries = this.getInstalledBinaries(name);
|
|
130
|
+
if (binaries?.has(binaryName)) {
|
|
131
|
+
const dependencies = binaries.get(binaryName);
|
|
132
|
+
if (dependencies?.size) {
|
|
133
|
+
dependencies.forEach(dependency => this.addReferencedDependency(name, dependency));
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (this.getWorkspaceManifest(workspace.name)?.ignoreBinaries.includes(binaryName))
|
|
139
|
+
return true;
|
|
140
|
+
if (this.ignoreBinaries.includes(binaryName))
|
|
141
|
+
return true;
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
isInDependencies(workspaceName, packageName) {
|
|
145
|
+
const manifest = this._manifests.get(workspaceName);
|
|
146
|
+
if (!manifest)
|
|
147
|
+
return false;
|
|
148
|
+
const dependencies = this.isStrict ? this.getProductionDependencies(workspaceName) : manifest.allDependencies;
|
|
149
|
+
return dependencies.includes(packageName);
|
|
150
|
+
}
|
|
151
|
+
settleDependencyIssues() {
|
|
152
|
+
const dependencyIssues = [];
|
|
153
|
+
const devDependencyIssues = [];
|
|
154
|
+
const optionalPeerDependencyIssues = [];
|
|
155
|
+
for (const [workspaceName, { manifestPath, ignoreDependencies, ignoreBinaries }] of this._manifests.entries()) {
|
|
156
|
+
const referencedDependencies = this.referencedDependencies.get(workspaceName);
|
|
157
|
+
const installedBinaries = this.getInstalledBinaries(workspaceName);
|
|
158
|
+
const ignoreBins = [...IGNORED_GLOBAL_BINARIES, ...this.ignoreBinaries, ...ignoreBinaries];
|
|
159
|
+
const ignoreDeps = [...IGNORED_DEPENDENCIES, ...this.ignoreDependencies, ...ignoreDependencies];
|
|
160
|
+
const isNotIgnoredDependency = (packageName) => !ignoreDeps.includes(packageName);
|
|
161
|
+
const isNotIgnoredBinary = (packageName) => {
|
|
162
|
+
if (installedBinaries?.has(packageName)) {
|
|
163
|
+
const binaryNames = installedBinaries.get(packageName);
|
|
164
|
+
if (binaryNames) {
|
|
165
|
+
if (ignoreBins.some(ignoredBinary => binaryNames.has(ignoredBinary)))
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
};
|
|
171
|
+
const peerDepRecs = {};
|
|
172
|
+
const isReferencedDependency = (dependency, isPeerDep) => {
|
|
173
|
+
if (referencedDependencies?.has(dependency))
|
|
174
|
+
return true;
|
|
175
|
+
if (isPeerDep && peerDepRecs[dependency])
|
|
176
|
+
return false;
|
|
177
|
+
const [scope, typedDependency] = dependency.split('/');
|
|
178
|
+
if (scope === '@types') {
|
|
179
|
+
const typedPackageName = getPackageFromDefinitelyTyped(typedDependency);
|
|
180
|
+
if (IGNORE_DEFINITELY_TYPED.includes(typedPackageName))
|
|
181
|
+
return true;
|
|
182
|
+
const peerDependencies = this.getPeerDependenciesOf(workspaceName, typedPackageName);
|
|
183
|
+
if (peerDependencies.length) {
|
|
184
|
+
return !!peerDependencies.find(peerDependency => isReferencedDependency(peerDependency, true));
|
|
185
|
+
}
|
|
186
|
+
if (!referencedDependencies)
|
|
187
|
+
return false;
|
|
188
|
+
return referencedDependencies.has(typedPackageName);
|
|
189
|
+
}
|
|
190
|
+
const peerDependenciesOf = this.getPeerDependenciesOf(workspaceName, dependency);
|
|
191
|
+
peerDependenciesOf.forEach(dep => (!peerDepRecs[dep] ? (peerDepRecs[dep] = 1) : peerDepRecs[dep]++));
|
|
192
|
+
return peerDependenciesOf.some(peerDependency => isReferencedDependency(peerDependency, true));
|
|
193
|
+
};
|
|
194
|
+
const isNotReferencedDependency = (dependency) => !isReferencedDependency(dependency);
|
|
195
|
+
const pd = this.getProductionDependencies(workspaceName);
|
|
196
|
+
const dd = this.getDevDependencies(workspaceName);
|
|
197
|
+
const od = this.getOptionalPeerDependencies(workspaceName);
|
|
198
|
+
pd.filter(isNotIgnoredDependency)
|
|
199
|
+
.filter(isNotIgnoredBinary)
|
|
200
|
+
.filter(isNotReferencedDependency)
|
|
201
|
+
.forEach(symbol => dependencyIssues.push({ type: 'dependencies', filePath: manifestPath, symbol }));
|
|
202
|
+
dd.filter(isNotIgnoredDependency)
|
|
203
|
+
.filter(isNotIgnoredBinary)
|
|
204
|
+
.filter(isNotReferencedDependency)
|
|
205
|
+
.forEach(symbol => devDependencyIssues.push({ type: 'devDependencies', filePath: manifestPath, symbol }));
|
|
206
|
+
od.filter(isNotIgnoredDependency)
|
|
207
|
+
.filter(isNotIgnoredBinary)
|
|
208
|
+
.filter(p => isReferencedDependency(p))
|
|
209
|
+
.forEach(symbol => optionalPeerDependencyIssues.push({ type: 'optionalPeerDependencies', filePath: manifestPath, symbol }));
|
|
210
|
+
}
|
|
211
|
+
return { dependencyIssues, devDependencyIssues, optionalPeerDependencyIssues };
|
|
212
|
+
}
|
|
213
|
+
getConfigurationHints() {
|
|
214
|
+
const configurationHints = new Set();
|
|
215
|
+
const rootIgnoreBinaries = Object.fromEntries(this.ignoreBinaries.map(key => [key, 0]));
|
|
216
|
+
const rootIgnoreDependencies = Object.fromEntries(this.ignoreDependencies.map(key => [key, 0]));
|
|
217
|
+
for (const [workspaceName, { ignoreDependencies, ignoreBinaries }] of this._manifests.entries()) {
|
|
218
|
+
const referencedDependencies = this.referencedDependencies.get(workspaceName);
|
|
219
|
+
const referencedBinaries = this.referencedBinaries.get(workspaceName);
|
|
220
|
+
const installedBinaries = this.getInstalledBinaries(workspaceName);
|
|
221
|
+
referencedDependencies?.forEach(pkg => pkg in rootIgnoreDependencies && rootIgnoreDependencies[pkg]++);
|
|
222
|
+
referencedBinaries?.forEach(binaryName => binaryName in rootIgnoreBinaries && rootIgnoreBinaries[binaryName]++);
|
|
223
|
+
const dependencies = this.isStrict
|
|
224
|
+
? this.getProductionDependencies(workspaceName)
|
|
225
|
+
: [...this.getProductionDependencies(workspaceName), ...this.getDevDependencies(workspaceName)];
|
|
226
|
+
const peerDependencies = this.getPeerDependencies(workspaceName);
|
|
227
|
+
const isReferencedDep = (name) => referencedDependencies?.has(name) && dependencies.includes(name);
|
|
228
|
+
const isReferencedBin = (name) => referencedBinaries?.has(name) && installedBinaries?.has(name);
|
|
229
|
+
ignoreDependencies
|
|
230
|
+
.filter(packageName => IGNORED_DEPENDENCIES.includes(packageName) ||
|
|
231
|
+
(workspaceName !== ROOT_WORKSPACE_NAME && this.ignoreDependencies.includes(packageName)) ||
|
|
232
|
+
(!peerDependencies.includes(packageName) && isReferencedDep(packageName)))
|
|
233
|
+
.forEach(identifier => configurationHints.add({ workspaceName, identifier, type: 'ignoreDependencies' }));
|
|
234
|
+
ignoreBinaries
|
|
235
|
+
.filter(binaryName => IGNORED_GLOBAL_BINARIES.includes(binaryName) ||
|
|
236
|
+
(workspaceName !== ROOT_WORKSPACE_NAME && this.ignoreBinaries.includes(binaryName)) ||
|
|
237
|
+
isReferencedBin(binaryName))
|
|
238
|
+
.forEach(identifier => configurationHints.add({ workspaceName, identifier, type: 'ignoreBinaries' }));
|
|
239
|
+
}
|
|
240
|
+
const installedBinaries = this.getInstalledBinaries(ROOT_WORKSPACE_NAME);
|
|
241
|
+
const dependencies = this.isStrict
|
|
242
|
+
? this.getProductionDependencies(ROOT_WORKSPACE_NAME)
|
|
243
|
+
: [...this.getProductionDependencies(ROOT_WORKSPACE_NAME), ...this.getDevDependencies(ROOT_WORKSPACE_NAME)];
|
|
244
|
+
const peerDependencies = this.getPeerDependencies(ROOT_WORKSPACE_NAME);
|
|
245
|
+
Object.keys(rootIgnoreBinaries)
|
|
246
|
+
.filter(key => IGNORED_GLOBAL_BINARIES.includes(key) || (rootIgnoreBinaries[key] !== 0 && installedBinaries?.has(key)))
|
|
247
|
+
.forEach(identifier => configurationHints.add({ workspaceName: ROOT_WORKSPACE_NAME, identifier, type: 'ignoreBinaries' }));
|
|
248
|
+
Object.keys(rootIgnoreDependencies)
|
|
249
|
+
.filter(key => IGNORED_DEPENDENCIES.includes(key) ||
|
|
250
|
+
(rootIgnoreDependencies[key] !== 0 && !peerDependencies.includes(key) && dependencies.includes(key)))
|
|
251
|
+
.forEach(identifier => configurationHints.add({ workspaceName: ROOT_WORKSPACE_NAME, identifier, type: 'ignoreDependencies' }));
|
|
252
|
+
return { configurationHints };
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ConfigurationHint, Issue, Rules } from './types/issues.js';
|
|
2
|
+
type IssueCollectorOptions = {
|
|
3
|
+
cwd: string;
|
|
4
|
+
rules: Rules;
|
|
5
|
+
};
|
|
6
|
+
export declare class IssueCollector {
|
|
7
|
+
private cwd;
|
|
8
|
+
private rules;
|
|
9
|
+
private issues;
|
|
10
|
+
private counters;
|
|
11
|
+
private referencedFiles;
|
|
12
|
+
private configurationHints;
|
|
13
|
+
constructor({ cwd, rules }: IssueCollectorOptions);
|
|
14
|
+
addFileCounts({ processed, unused }: {
|
|
15
|
+
processed: number;
|
|
16
|
+
unused: number;
|
|
17
|
+
}): void;
|
|
18
|
+
addFilesIssues(filePaths: string[]): void;
|
|
19
|
+
addIssue(issue: Issue): void;
|
|
20
|
+
addConfigurationHint(issue: ConfigurationHint): void;
|
|
21
|
+
getIssues(): {
|
|
22
|
+
issues: import("./types/issues.js").Issues;
|
|
23
|
+
counters: import("./types/issues.js").Counters;
|
|
24
|
+
configurationHints: Set<ConfigurationHint>;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { initIssues, initCounters } from './issues/initializers.js';
|
|
2
|
+
import { relative } from './util/path.js';
|
|
3
|
+
function objectInSet(set, obj) {
|
|
4
|
+
const objJSON = JSON.stringify(obj);
|
|
5
|
+
return Array.from(set).some(item => JSON.stringify(item) === objJSON);
|
|
6
|
+
}
|
|
7
|
+
export class IssueCollector {
|
|
8
|
+
cwd;
|
|
9
|
+
rules;
|
|
10
|
+
issues = initIssues();
|
|
11
|
+
counters = initCounters();
|
|
12
|
+
referencedFiles = new Set();
|
|
13
|
+
configurationHints = new Set();
|
|
14
|
+
constructor({ cwd, rules }) {
|
|
15
|
+
this.cwd = cwd;
|
|
16
|
+
this.rules = rules;
|
|
17
|
+
}
|
|
18
|
+
addFileCounts({ processed, unused }) {
|
|
19
|
+
this.counters.processed += processed;
|
|
20
|
+
this.counters.total += processed + unused;
|
|
21
|
+
}
|
|
22
|
+
addFilesIssues(filePaths) {
|
|
23
|
+
filePaths.forEach(filePath => {
|
|
24
|
+
if (!this.referencedFiles.has(filePath)) {
|
|
25
|
+
this.issues.files.add(filePath);
|
|
26
|
+
this.counters.files++;
|
|
27
|
+
this.counters.processed++;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
addIssue(issue) {
|
|
32
|
+
const key = relative(this.cwd, issue.filePath);
|
|
33
|
+
issue.severity = this.rules[issue.type];
|
|
34
|
+
this.issues[issue.type][key] = this.issues[issue.type][key] ?? {};
|
|
35
|
+
if (!this.issues[issue.type][key][issue.symbol]) {
|
|
36
|
+
this.issues[issue.type][key][issue.symbol] = issue;
|
|
37
|
+
this.counters[issue.type]++;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
addConfigurationHint(issue) {
|
|
41
|
+
if (!objectInSet(this.configurationHints, issue)) {
|
|
42
|
+
this.configurationHints.add(issue);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
getIssues() {
|
|
46
|
+
return {
|
|
47
|
+
issues: this.issues,
|
|
48
|
+
counters: this.counters,
|
|
49
|
+
configurationHints: this.configurationHints,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { ProjectPrincipal } from './ProjectPrincipal.js';
|
|
3
|
+
import type { SyncCompilers, AsyncCompilers } from './types/compilers.js';
|
|
4
|
+
type Paths = ts.CompilerOptions['paths'];
|
|
5
|
+
type Principal = {
|
|
6
|
+
principal: ProjectPrincipal;
|
|
7
|
+
cwds: Set<string>;
|
|
8
|
+
pathKeys: Set<string>;
|
|
9
|
+
};
|
|
10
|
+
type Principals = Set<Principal>;
|
|
11
|
+
type Options = {
|
|
12
|
+
cwd: string;
|
|
13
|
+
compilerOptions: ts.CompilerOptions;
|
|
14
|
+
paths: Paths;
|
|
15
|
+
compilers: [SyncCompilers, AsyncCompilers];
|
|
16
|
+
};
|
|
17
|
+
export declare class PrincipalFactory {
|
|
18
|
+
principals: Principals;
|
|
19
|
+
getPrincipal(options: Options): ProjectPrincipal;
|
|
20
|
+
private findReusablePrincipal;
|
|
21
|
+
private linkPrincipal;
|
|
22
|
+
private addNewPrincipal;
|
|
23
|
+
getPrincipals(): ProjectPrincipal[];
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { ProjectPrincipal } from './ProjectPrincipal.js';
|
|
3
|
+
import { toAbsolute } from './util/path.js';
|
|
4
|
+
const mergePaths = (cwd, compilerOptions, paths = {}) => {
|
|
5
|
+
const overridePaths = Object.keys(paths).reduce((overridePaths, key) => {
|
|
6
|
+
overridePaths[key] = paths[key].map(entry => toAbsolute(entry, cwd));
|
|
7
|
+
return overridePaths;
|
|
8
|
+
}, {});
|
|
9
|
+
compilerOptions.paths = { ...compilerOptions.paths, ...overridePaths };
|
|
10
|
+
return compilerOptions;
|
|
11
|
+
};
|
|
12
|
+
export class PrincipalFactory {
|
|
13
|
+
principals = new Set();
|
|
14
|
+
getPrincipal(options) {
|
|
15
|
+
const { cwd, compilerOptions, paths } = options;
|
|
16
|
+
options.compilerOptions = mergePaths(cwd, compilerOptions, paths);
|
|
17
|
+
const principal = this.findReusablePrincipal(compilerOptions);
|
|
18
|
+
if (principal) {
|
|
19
|
+
this.linkPrincipal(principal, cwd, compilerOptions);
|
|
20
|
+
return principal.principal;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return this.addNewPrincipal(options);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
findReusablePrincipal(compilerOptions) {
|
|
27
|
+
const workspacePaths = compilerOptions?.paths ? Object.keys(compilerOptions.paths) : [];
|
|
28
|
+
const principal = Array.from(this.principals).find(principal => {
|
|
29
|
+
if (compilerOptions.pathsBasePath && principal.principal.compilerOptions.pathsBasePath)
|
|
30
|
+
return false;
|
|
31
|
+
if (compilerOptions.baseUrl === principal.principal.compilerOptions.baseUrl) {
|
|
32
|
+
return workspacePaths.every(p => !principal.pathKeys.has(p));
|
|
33
|
+
}
|
|
34
|
+
return !compilerOptions.baseUrl;
|
|
35
|
+
});
|
|
36
|
+
return principal;
|
|
37
|
+
}
|
|
38
|
+
linkPrincipal(principal, cwd, compilerOptions) {
|
|
39
|
+
const { pathsBasePath, paths } = compilerOptions;
|
|
40
|
+
if (pathsBasePath)
|
|
41
|
+
principal.principal.compilerOptions.pathsBasePath = pathsBasePath;
|
|
42
|
+
Object.keys(paths ?? {}).forEach(p => principal.pathKeys.add(p));
|
|
43
|
+
principal.principal.compilerOptions.paths = { ...principal.principal.compilerOptions.paths, ...paths };
|
|
44
|
+
principal.cwds.add(cwd);
|
|
45
|
+
}
|
|
46
|
+
addNewPrincipal(options) {
|
|
47
|
+
const { cwd, compilerOptions } = options;
|
|
48
|
+
const pathKeys = new Set(Object.keys(compilerOptions?.paths ?? {}));
|
|
49
|
+
const principal = new ProjectPrincipal(options);
|
|
50
|
+
this.principals.add({ principal, cwds: new Set([cwd]), pathKeys });
|
|
51
|
+
return principal;
|
|
52
|
+
}
|
|
53
|
+
getPrincipals() {
|
|
54
|
+
return Array.from(this.principals).map(p => p.principal);
|
|
55
|
+
}
|
|
56
|
+
}
|