knip 5.26.0 → 5.27.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/dist/CacheConsultant.d.ts +8 -2
- package/dist/CacheConsultant.js +9 -16
- package/dist/ConfigurationChief.d.ts +11 -4
- package/dist/ConfigurationChief.js +22 -21
- package/dist/ConfigurationValidator.d.ts +224 -0
- package/dist/ConfigurationValidator.js +4 -0
- package/dist/DependencyDeputy.d.ts +3 -2
- package/dist/DependencyDeputy.js +4 -4
- package/dist/PrincipalFactory.d.ts +4 -0
- package/dist/ProjectPrincipal.d.ts +5 -4
- package/dist/ProjectPrincipal.js +8 -6
- package/dist/WorkspaceWorker.d.ts +5 -3
- package/dist/WorkspaceWorker.js +2 -2
- package/dist/binaries/resolvers/bun.js +1 -1
- package/dist/cli.js +23 -12
- package/dist/compilers/index.d.ts +40 -0
- package/dist/index.js +55 -134
- package/dist/plugins/babel/index.js +2 -1
- package/dist/plugins/babel/types.d.ts +1 -0
- package/dist/plugins/cypress/helpers.d.ts +3 -0
- package/dist/plugins/cypress/helpers.js +23 -0
- package/dist/plugins/cypress/index.d.ts +3 -1
- package/dist/plugins/cypress/index.js +5 -0
- package/dist/plugins/cypress/types.d.ts +6 -0
- package/dist/plugins/cypress/types.js +1 -0
- package/dist/plugins/husky/index.d.ts +1 -1
- package/dist/plugins/husky/index.js +9 -2
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/ladle/index.d.ts +13 -0
- package/dist/plugins/ladle/index.js +36 -0
- package/dist/plugins/ladle/types.d.ts +4 -0
- package/dist/plugins/ladle/types.js +1 -0
- package/dist/plugins/react-cosmos/index.d.ts +12 -0
- package/dist/plugins/react-cosmos/index.js +33 -0
- package/dist/plugins/react-cosmos/types.d.ts +5 -0
- package/dist/plugins/react-cosmos/types.js +1 -0
- package/dist/plugins/rsbuild/index.d.ts +10 -0
- package/dist/plugins/rsbuild/index.js +15 -0
- package/dist/plugins/rsbuild/types.d.ts +3 -0
- package/dist/plugins/rsbuild/types.js +1 -0
- package/dist/plugins/rspack/index.d.ts +10 -0
- package/dist/plugins/rspack/index.js +22 -0
- package/dist/plugins/vitest/index.js +1 -1
- package/dist/types/cli.d.ts +16 -9
- package/dist/typescript/{createHosts.js → create-hosts.js} +1 -1
- package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/importCall.js +13 -15
- package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/exports/index.d.ts +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/index.d.ts +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
- package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
- package/dist/typescript/visitors/scripts/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
- package/dist/util/create-workspace-graph.d.ts +8 -0
- package/dist/util/{pkgs-graph.js → create-workspace-graph.js} +3 -3
- package/dist/util/dependency-graph.d.ts +3 -4
- package/dist/util/dependency-graph.js +35 -3
- package/dist/util/get-included-issue-types.d.ts +6 -6
- package/dist/util/get-included-issue-types.js +5 -5
- package/dist/util/globby.js +2 -2
- package/dist/util/handle-dependency.d.ts +1 -1
- package/dist/util/handle-dependency.js +1 -1
- package/dist/util/reporter.d.ts +2 -2
- package/dist/util/reporter.js +12 -10
- package/dist/util/to-source-path.d.ts +2 -2
- package/dist/util/watch.d.ts +25 -0
- package/dist/util/watch.js +85 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +16 -0
- package/dist/util/pkgs-graph.d.ts +0 -8
- /package/dist/typescript/{createHosts.d.ts → create-hosts.d.ts} +0 -0
- /package/dist/typescript/{getImportsAndExports.d.ts → get-imports-and-exports.d.ts} +0 -0
- /package/dist/typescript/{getImportsAndExports.js → get-imports-and-exports.js} +0 -0
- /package/dist/typescript/{resolveModuleNames.d.ts → resolve-module-names.d.ts} +0 -0
- /package/dist/typescript/{resolveModuleNames.js → resolve-module-names.js} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { hasDependency } from '#p/util/plugin.js';
|
|
2
|
+
import { compact } from '../../util/array.js';
|
|
3
|
+
import { findWebpackDependenciesFromConfig } from '../webpack/index.js';
|
|
4
|
+
const title = 'Rspack';
|
|
5
|
+
const enablers = ['@rspack/core'];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = ['rspack.config*.{js,ts,mjs,cjs}'];
|
|
8
|
+
const resolveConfig = async (localConfig, options) => {
|
|
9
|
+
const { cwd, isProduction } = options;
|
|
10
|
+
const { entryPatterns, dependencies } = await findWebpackDependenciesFromConfig({ config: localConfig, cwd });
|
|
11
|
+
const deps = Array.from(dependencies).filter(dependency => !dependency.startsWith('builtin:'));
|
|
12
|
+
if (isProduction)
|
|
13
|
+
return [...entryPatterns];
|
|
14
|
+
return compact([...entryPatterns, ...deps]);
|
|
15
|
+
};
|
|
16
|
+
export default {
|
|
17
|
+
title,
|
|
18
|
+
enablers,
|
|
19
|
+
isEnabled,
|
|
20
|
+
config,
|
|
21
|
+
resolveConfig,
|
|
22
|
+
};
|
|
@@ -47,7 +47,7 @@ const getConfigs = async (localConfig) => {
|
|
|
47
47
|
return configs;
|
|
48
48
|
};
|
|
49
49
|
export const resolveEntryPaths = async (localConfig, options) => {
|
|
50
|
-
const dependencies = new Set();
|
|
50
|
+
const dependencies = new Set(['src/vite-env.d.ts']);
|
|
51
51
|
const configs = await getConfigs(localConfig);
|
|
52
52
|
for (const cfg of configs) {
|
|
53
53
|
const rootDir = cfg.test?.root ?? '.';
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
export interface CommandLineOptions {
|
|
2
|
+
cacheLocation: string;
|
|
2
3
|
cwd: string;
|
|
3
|
-
|
|
4
|
+
excludedIssueTypes: string[];
|
|
5
|
+
fixTypes: string[];
|
|
4
6
|
gitignore: boolean;
|
|
7
|
+
includedIssueTypes: string[];
|
|
8
|
+
isCache: boolean;
|
|
5
9
|
isDebug: boolean;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
isDependenciesShorthand: boolean;
|
|
11
|
+
isExportsShorthand: boolean;
|
|
12
|
+
isFilesShorthand: boolean;
|
|
13
|
+
isFix: boolean;
|
|
14
|
+
isHideConfigHints: boolean;
|
|
9
15
|
isIncludeEntryExports: boolean;
|
|
10
16
|
isIncludeLibs: boolean;
|
|
11
17
|
isIsolateWorkspaces: boolean;
|
|
18
|
+
isProduction: boolean;
|
|
19
|
+
isRemoveFiles: boolean;
|
|
20
|
+
isShowProgress: boolean;
|
|
21
|
+
isStrict: boolean;
|
|
12
22
|
isWatch: boolean;
|
|
13
|
-
isCache?: boolean;
|
|
14
|
-
cacheLocation?: string;
|
|
15
23
|
tags: Tags;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
isRemoveFiles: boolean;
|
|
24
|
+
tsConfigFile: string | undefined;
|
|
25
|
+
workspace: string | undefined;
|
|
19
26
|
}
|
|
20
27
|
export type Tags = [string[], string[]];
|
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import ts from 'typescript';
|
|
4
4
|
import { getCompilerExtensions } from '../compilers/index.js';
|
|
5
5
|
import { SourceFileManager } from './SourceFileManager.js';
|
|
6
|
-
import { createCustomModuleResolver } from './
|
|
6
|
+
import { createCustomModuleResolver } from './resolve-module-names.js';
|
|
7
7
|
const libLocation = path.dirname(ts.getDefaultLibFilePath({}));
|
|
8
8
|
export const createHosts = ({ cwd, compilerOptions, entryPaths, compilers, isSkipLibs, toSourceFilePath, useResolverCache, }) => {
|
|
9
9
|
const fileManager = new SourceFileManager({ compilers, isSkipLibs });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -98,22 +98,20 @@ export default visit(() => true, node => {
|
|
|
98
98
|
ts.isArrayBindingPattern(variableDeclarationParent.name)) {
|
|
99
99
|
const index = arrayLiteralExpression.elements.indexOf(node);
|
|
100
100
|
const element = variableDeclarationParent.name.elements[index];
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
if (element) {
|
|
102
|
+
const isTLA = isTopLevel(variableDeclarationParent.parent);
|
|
103
|
+
if (ts.isBindingElement(element) && ts.isObjectBindingPattern(element.name) && element.name.elements) {
|
|
104
|
+
return element.name.elements.map(element => {
|
|
105
|
+
const identifier = (element.propertyName ?? element.name).getText();
|
|
106
|
+
const alias = element.propertyName ? element.name.getText() : undefined;
|
|
107
|
+
const symbol = isTLA ? element.symbol : undefined;
|
|
108
|
+
return { identifier, alias, symbol, specifier, pos: element.pos };
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const alias = element.name.escapedText;
|
|
112
|
+
const symbol = isTLA ? element.symbol : undefined;
|
|
113
|
+
return { identifier: 'default', symbol, alias, specifier, pos: element.pos };
|
|
108
114
|
}
|
|
109
|
-
const alias = element.name.escapedText;
|
|
110
|
-
return {
|
|
111
|
-
identifier: 'default',
|
|
112
|
-
symbol: isTLA ? element.symbol : undefined,
|
|
113
|
-
alias,
|
|
114
|
-
specifier,
|
|
115
|
-
pos: element.pos,
|
|
116
|
-
};
|
|
117
115
|
}
|
|
118
116
|
return { identifier: 'default', specifier, pos: node.arguments[0].pos };
|
|
119
117
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[])[];
|
|
3
3
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { ImportNode } from '../../../types/imports.js';
|
|
3
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
3
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | ImportNode | ImportNode[];
|
|
4
4
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[])[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[])[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[];
|
|
3
3
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
2
|
import type { ExportNode } from '../../types/exports.js';
|
|
3
3
|
import type { ImportNode } from '../../types/imports.js';
|
|
4
|
-
import type { GetImportsAndExportsOptions } from '../
|
|
4
|
+
import type { GetImportsAndExportsOptions } from '../get-imports-and-exports.js';
|
|
5
5
|
type FileCondition = (sourceFile: ts.SourceFile) => boolean;
|
|
6
6
|
type VisitorFactory<T> = (fileCondition: FileCondition, fn: Visitor<T>) => VisitorCondition<T>;
|
|
7
7
|
type VisitorCondition<T> = (sourceFile: ts.SourceFile) => Visitor<T>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | string | string[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | string | string[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | string | string[])[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => undefined | string | string[];
|
|
3
3
|
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PackageJson } from '../types/package-json.js';
|
|
2
|
+
interface Package {
|
|
3
|
+
manifest: PackageJson;
|
|
4
|
+
dir: string;
|
|
5
|
+
}
|
|
6
|
+
export type WorkspaceGraph = Record<string, Set<string>>;
|
|
7
|
+
export declare function createWorkspaceGraph(cwd: string, wsNames: string[], wsPkgNames: Set<string>, byPkgName: Map<string, Package>, byName: Map<string, Package>): WorkspaceGraph;
|
|
8
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { join } from './path.js';
|
|
2
2
|
const types = ['peerDependencies', 'devDependencies', 'optionalDependencies', 'dependencies'];
|
|
3
|
-
export function
|
|
3
|
+
export function createWorkspaceGraph(cwd, wsNames, wsPkgNames, byPkgName, byName) {
|
|
4
4
|
const graph = {};
|
|
5
|
-
const
|
|
5
|
+
const getWorkspaceDirs = (pkg) => {
|
|
6
6
|
const dirs = new Set();
|
|
7
7
|
for (const type of types) {
|
|
8
8
|
if (pkg.manifest[type]) {
|
|
@@ -20,7 +20,7 @@ export function createPkgGraph(cwd, wsNames, wsPkgNames, byPkgName, byName) {
|
|
|
20
20
|
for (const name of wsNames) {
|
|
21
21
|
const pkg = byName.get(name);
|
|
22
22
|
if (pkg)
|
|
23
|
-
graph[join(cwd, name)] =
|
|
23
|
+
graph[join(cwd, name)] = getWorkspaceDirs(pkg);
|
|
24
24
|
}
|
|
25
25
|
return graph;
|
|
26
26
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { FileNode, IdToFileMap, IdToNsToFileMap, ImportDetails } from '../types/dependency-graph.js';
|
|
2
|
-
export declare const
|
|
1
|
+
import type { DependencyGraph, FileNode, IdToFileMap, IdToNsToFileMap, ImportDetails, ImportMap } from '../types/dependency-graph.js';
|
|
2
|
+
export declare const getOrCreateFileNode: (graph: DependencyGraph, filePath: string) => FileNode;
|
|
3
|
+
export declare const updateImportMap: (file: FileNode, importMap: ImportMap, graph: DependencyGraph) => void;
|
|
3
4
|
export declare const createImports: () => ImportDetails;
|
|
4
5
|
export declare const addValue: (map: IdToFileMap, id: string, value: string) => void;
|
|
5
6
|
export declare const addNsValue: (map: IdToNsToFileMap, id: string, ns: string, value: string) => void;
|
|
6
|
-
export declare const addValues: (map: IdToFileMap, id: string, values: Set<string>) => void;
|
|
7
|
-
export declare const addNsValues: (map: IdToNsToFileMap, id: string, value: IdToFileMap) => void;
|
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const getOrCreateFileNode = (graph, filePath) => graph.get(filePath) ?? createFileNode();
|
|
2
|
+
const updateImportDetails = (importedModule, importItems) => {
|
|
3
|
+
for (const id of importItems.refs)
|
|
4
|
+
importedModule.refs.add(id);
|
|
5
|
+
for (const [id, v] of importItems.imported.entries())
|
|
6
|
+
addValues(importedModule.imported, id, v);
|
|
7
|
+
for (const [id, v] of importItems.importedAs.entries())
|
|
8
|
+
addNsValues(importedModule.importedAs, id, v);
|
|
9
|
+
for (const [id, v] of importItems.importedNs.entries())
|
|
10
|
+
addValues(importedModule.importedNs, id, v);
|
|
11
|
+
for (const [id, v] of importItems.reExported.entries())
|
|
12
|
+
addValues(importedModule.reExported, id, v);
|
|
13
|
+
for (const [id, v] of importItems.reExportedAs.entries())
|
|
14
|
+
addNsValues(importedModule.reExportedAs, id, v);
|
|
15
|
+
for (const [id, v] of importItems.reExportedNs.entries())
|
|
16
|
+
addValues(importedModule.reExportedNs, id, v);
|
|
17
|
+
};
|
|
18
|
+
export const updateImportMap = (file, importMap, graph) => {
|
|
19
|
+
for (const [importedFilePath, importDetails] of importMap.entries()) {
|
|
20
|
+
const importedFileImports = file.imports.internal.get(importedFilePath);
|
|
21
|
+
if (!importedFileImports)
|
|
22
|
+
file.imports.internal.set(importedFilePath, importDetails);
|
|
23
|
+
else
|
|
24
|
+
updateImportDetails(importedFileImports, importDetails);
|
|
25
|
+
const importedFile = getOrCreateFileNode(graph, importedFilePath);
|
|
26
|
+
if (!importedFile.imported)
|
|
27
|
+
importedFile.imported = importDetails;
|
|
28
|
+
else
|
|
29
|
+
updateImportDetails(importedFile.imported, importDetails);
|
|
30
|
+
graph.set(importedFilePath, importedFile);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const createFileNode = () => ({
|
|
2
34
|
imports: {
|
|
3
35
|
internal: new Map(),
|
|
4
36
|
external: new Set(),
|
|
@@ -37,14 +69,14 @@ export const addNsValue = (map, id, ns, value) => {
|
|
|
37
69
|
map.set(id, new Map([[ns, new Set([value])]]));
|
|
38
70
|
}
|
|
39
71
|
};
|
|
40
|
-
|
|
72
|
+
const addValues = (map, id, values) => {
|
|
41
73
|
if (map.has(id))
|
|
42
74
|
for (const v of values)
|
|
43
75
|
map.get(id)?.add(v);
|
|
44
76
|
else
|
|
45
77
|
map.set(id, values);
|
|
46
78
|
};
|
|
47
|
-
|
|
79
|
+
const addNsValues = (map, id, value) => {
|
|
48
80
|
if (map.has(id))
|
|
49
81
|
for (const [ns, v] of value)
|
|
50
82
|
addValues(map.get(id), ns, v);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Report } from '../types/issues.js';
|
|
2
|
-
type CLIArguments = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
export type CLIArguments = {
|
|
3
|
+
includedIssueTypes: string[];
|
|
4
|
+
excludedIssueTypes: string[];
|
|
5
|
+
isDependenciesShorthand: boolean;
|
|
6
|
+
isExportsShorthand: boolean;
|
|
7
|
+
isFilesShorthand: boolean;
|
|
8
8
|
};
|
|
9
9
|
type Options = {
|
|
10
10
|
isProduction?: boolean;
|
|
@@ -4,21 +4,21 @@ export const defaultExcludedIssueTypes = ['classMembers', 'nsExports', 'nsTypes'
|
|
|
4
4
|
const defaultIssueTypes = ISSUE_TYPES.filter(type => !defaultExcludedIssueTypes.includes(type));
|
|
5
5
|
const normalize = (values) => values.flatMap(value => value.split(','));
|
|
6
6
|
export const getIncludedIssueTypes = (cliArgs, { include = [], exclude = [], isProduction = false } = {}) => {
|
|
7
|
-
let incl = normalize(cliArgs.
|
|
8
|
-
const excl = normalize(cliArgs.
|
|
7
|
+
let incl = normalize(cliArgs.includedIssueTypes);
|
|
8
|
+
const excl = normalize(cliArgs.excludedIssueTypes);
|
|
9
9
|
for (const type of [...incl, ...excl, ...include, ...exclude]) {
|
|
10
10
|
if (!ISSUE_TYPES.includes(type))
|
|
11
11
|
throw new ConfigurationError(`Invalid issue type: ${type}`);
|
|
12
12
|
}
|
|
13
13
|
const excludes = exclude.filter(exclude => !incl.includes(exclude));
|
|
14
14
|
const includes = include.filter(include => !excl.includes(include));
|
|
15
|
-
if (cliArgs.
|
|
15
|
+
if (cliArgs.isDependenciesShorthand) {
|
|
16
16
|
incl = [...incl, 'dependencies', 'optionalPeerDependencies', 'unlisted', 'binaries', 'unresolved'];
|
|
17
17
|
}
|
|
18
|
-
if (cliArgs.
|
|
18
|
+
if (cliArgs.isExportsShorthand) {
|
|
19
19
|
incl = [...incl, 'exports', 'types', 'enumMembers', 'duplicates'];
|
|
20
20
|
}
|
|
21
|
-
if (cliArgs.
|
|
21
|
+
if (cliArgs.isFilesShorthand) {
|
|
22
22
|
incl = [...incl, 'files'];
|
|
23
23
|
}
|
|
24
24
|
const _include = [...incl, ...includes];
|
package/dist/util/globby.js
CHANGED
|
@@ -7,7 +7,7 @@ import { GLOBAL_IGNORE_PATTERNS, ROOT_WORKSPACE_NAME } from '../constants.js';
|
|
|
7
7
|
import { timerify } from './Performance.js';
|
|
8
8
|
import { debugLogObject } from './debug.js';
|
|
9
9
|
import { isFile } from './fs.js';
|
|
10
|
-
import { dirname, join, relative, toPosix } from './path.js';
|
|
10
|
+
import { dirname, join, relative, toPosix, toRelative } from './path.js';
|
|
11
11
|
const walk = promisify(_walk);
|
|
12
12
|
const _picomatch = timerify(picomatch);
|
|
13
13
|
const cachedIgnores = new Map();
|
|
@@ -53,7 +53,7 @@ async function parseFindGitignores(options) {
|
|
|
53
53
|
return false;
|
|
54
54
|
};
|
|
55
55
|
const addFile = (filePath) => {
|
|
56
|
-
gitignoreFiles.push(filePath);
|
|
56
|
+
gitignoreFiles.push(toRelative(filePath));
|
|
57
57
|
const dir = dirname(toPosix(filePath));
|
|
58
58
|
const base = relative(options.cwd, dir);
|
|
59
59
|
const dirIgnores = base === '' ? ['.git', ...GLOBAL_IGNORE_PATTERNS] : [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.js';
|
|
2
2
|
import type { DependencyDeputy } from '../DependencyDeputy.js';
|
|
3
3
|
import type { IssueCollector } from '../IssueCollector.js';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const getReferencedDependencyHandler: (collector: IssueCollector, deputy: DependencyDeputy, chief: ConfigurationChief) => (specifier: string, containingFilePath: string, workspace: Workspace) => string | undefined;
|
|
@@ -3,7 +3,7 @@ import { isInNodeModules, isInternal } from './path.js';
|
|
|
3
3
|
import { fromBinary, isBinary } from './protocols.js';
|
|
4
4
|
import { _resolveSpecifier } from './require.js';
|
|
5
5
|
import { resolveSync } from './resolve.js';
|
|
6
|
-
export const
|
|
6
|
+
export const getReferencedDependencyHandler = (collector, deputy, chief) => (specifier, containingFilePath, workspace) => {
|
|
7
7
|
if (isBinary(specifier)) {
|
|
8
8
|
const binaryName = fromBinary(specifier);
|
|
9
9
|
const isHandled = deputy.maybeAddReferencedBinary(workspace, binaryName);
|
package/dist/util/reporter.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ReporterOptions } from '../types/issues.js';
|
|
2
|
-
export declare const runPreprocessors: (
|
|
3
|
-
export declare const runReporters: (options: ReporterOptions) => Promise<void>;
|
|
2
|
+
export declare const runPreprocessors: (processors: string[], data: ReporterOptions) => Promise<ReporterOptions>;
|
|
3
|
+
export declare const runReporters: (reporter: string[], options: ReporterOptions) => Promise<void>;
|
package/dist/util/reporter.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import internalReporters from '../reporters/index.js';
|
|
2
|
-
import parsedArgValues from '../util/cli-arguments.js';
|
|
3
2
|
import { _load } from './loader.js';
|
|
4
3
|
import { isInternal, resolve } from './path.js';
|
|
5
|
-
const
|
|
6
|
-
const preprocessors = await Promise.all(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
export const runPreprocessors = async (processors, data) => {
|
|
5
|
+
const preprocessors = await Promise.all(processors.map(proc => _load(isInternal(proc) ? resolve(proc) : proc)));
|
|
6
|
+
return preprocessors.length === 0
|
|
7
|
+
? Promise.resolve(data)
|
|
8
|
+
: runPreprocessors(preprocessors.slice(1), preprocessors[0](data));
|
|
9
|
+
};
|
|
10
|
+
export const runReporters = async (reporter, options) => {
|
|
11
|
+
const reporters = await Promise.all(reporter.map(async (reporter) => {
|
|
12
|
+
return reporter in internalReporters
|
|
13
|
+
? internalReporters[reporter]
|
|
14
|
+
: await _load(isInternal(reporter) ? resolve(reporter) : reporter);
|
|
15
|
+
}));
|
|
14
16
|
for (const reporter of reporters)
|
|
15
17
|
await reporter(options);
|
|
16
18
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CompilerOptions } from 'typescript';
|
|
2
2
|
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.js';
|
|
3
|
-
export type ToSourceFilePath = (filePath: string) => undefined | string;
|
|
4
3
|
export declare const augmentWorkspace: (workspace: Workspace, dir: string, compilerOptions: CompilerOptions) => void;
|
|
5
|
-
export declare const getToSourcePathHandler: (chief: ConfigurationChief) =>
|
|
4
|
+
export declare const getToSourcePathHandler: (chief: ConfigurationChief) => (filePath: string) => string | undefined;
|
|
5
|
+
export type ToSourceFilePath = ReturnType<typeof getToSourcePathHandler>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WatchListener } from 'node:fs';
|
|
2
|
+
import type { ConfigurationChief } from '../ConfigurationChief.js';
|
|
3
|
+
import type { ConsoleStreamer } from '../ConsoleStreamer.js';
|
|
4
|
+
import type { IssueCollector } from '../IssueCollector.js';
|
|
5
|
+
import type { PrincipalFactory } from '../PrincipalFactory.js';
|
|
6
|
+
import type { ProjectPrincipal } from '../ProjectPrincipal.js';
|
|
7
|
+
import type { DependencyGraph } from '../types/dependency-graph.js';
|
|
8
|
+
import type { Report } from '../types/issues.js';
|
|
9
|
+
type Watch = {
|
|
10
|
+
analyzedFiles: Set<string>;
|
|
11
|
+
analyzeSourceFile: (filePath: string, principal: ProjectPrincipal) => void;
|
|
12
|
+
chief: ConfigurationChief;
|
|
13
|
+
collector: IssueCollector;
|
|
14
|
+
collectUnusedExports: () => Promise<void>;
|
|
15
|
+
cwd: string;
|
|
16
|
+
factory: PrincipalFactory;
|
|
17
|
+
graph: DependencyGraph;
|
|
18
|
+
isDebug: boolean;
|
|
19
|
+
isIgnored: (path: string) => boolean;
|
|
20
|
+
report: Report;
|
|
21
|
+
streamer: ConsoleStreamer;
|
|
22
|
+
unreferencedFiles: Set<string>;
|
|
23
|
+
};
|
|
24
|
+
export declare const getWatchHandler: ({ analyzedFiles, analyzeSourceFile, chief, collector, collectUnusedExports, cwd, factory, graph, isDebug, isIgnored, report, streamer, unreferencedFiles, }: Watch) => Promise<WatchListener<string | Buffer>>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import watchReporter from '../reporters/watch.js';
|
|
2
|
+
import { debugLog } from './debug.js';
|
|
3
|
+
import { updateImportMap } from './dependency-graph.js';
|
|
4
|
+
import { isFile } from './fs.js';
|
|
5
|
+
import { join, toPosix } from './path.js';
|
|
6
|
+
export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief, collector, collectUnusedExports, cwd, factory, graph, isDebug, isIgnored, report, streamer, unreferencedFiles, }) => {
|
|
7
|
+
const reportIssues = async (startTime) => {
|
|
8
|
+
const { issues } = collector.getIssues();
|
|
9
|
+
watchReporter({ report, issues, streamer, startTime, size: analyzedFiles.size, isDebug });
|
|
10
|
+
};
|
|
11
|
+
const listener = async (eventType, filename) => {
|
|
12
|
+
debugLog('*', `(raw) ${eventType} ${filename}`);
|
|
13
|
+
if (typeof filename === 'string') {
|
|
14
|
+
const startTime = performance.now();
|
|
15
|
+
const filePath = join(cwd, toPosix(filename));
|
|
16
|
+
if (isIgnored(filePath)) {
|
|
17
|
+
debugLog('*', `ignoring ${eventType} ${filename}`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
21
|
+
if (workspace) {
|
|
22
|
+
const principal = factory.getPrincipalByPackageName(workspace.pkgName);
|
|
23
|
+
if (principal) {
|
|
24
|
+
const event = eventType === 'rename' ? (isFile(filePath) ? 'added' : 'deleted') : 'modified';
|
|
25
|
+
principal.invalidateFile(filePath);
|
|
26
|
+
unreferencedFiles.clear();
|
|
27
|
+
const cachedUnusedFiles = collector.purge();
|
|
28
|
+
switch (event) {
|
|
29
|
+
case 'added':
|
|
30
|
+
principal.addProjectPath(filePath);
|
|
31
|
+
principal.deletedFiles.delete(filePath);
|
|
32
|
+
cachedUnusedFiles.add(filePath);
|
|
33
|
+
debugLog(workspace.name, `Watcher: + ${filename}`);
|
|
34
|
+
break;
|
|
35
|
+
case 'deleted':
|
|
36
|
+
analyzedFiles.delete(filePath);
|
|
37
|
+
principal.removeProjectPath(filePath);
|
|
38
|
+
cachedUnusedFiles.delete(filePath);
|
|
39
|
+
debugLog(workspace.name, `Watcher: - ${filename}`);
|
|
40
|
+
break;
|
|
41
|
+
case 'modified':
|
|
42
|
+
debugLog(workspace.name, `Watcher: ± ${filename}`);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
const filePaths = principal.getUsedResolvedFiles();
|
|
46
|
+
if (event === 'added' || event === 'deleted') {
|
|
47
|
+
graph.clear();
|
|
48
|
+
for (const filePath of filePaths)
|
|
49
|
+
analyzeSourceFile(filePath, principal);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
for (const [filePath, file] of graph) {
|
|
53
|
+
if (filePaths.includes(filePath)) {
|
|
54
|
+
file.imported = undefined;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
graph.delete(filePath);
|
|
58
|
+
analyzedFiles.delete(filePath);
|
|
59
|
+
cachedUnusedFiles.add(filePath);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const filePath of filePaths)
|
|
63
|
+
if (!graph.has(filePath))
|
|
64
|
+
analyzeSourceFile(filePath, principal);
|
|
65
|
+
if (!cachedUnusedFiles.has(filePath))
|
|
66
|
+
analyzeSourceFile(filePath, principal);
|
|
67
|
+
for (const filePath of filePaths) {
|
|
68
|
+
const file = graph.get(filePath);
|
|
69
|
+
if (file?.internalImportCache)
|
|
70
|
+
updateImportMap(file, file.internalImportCache, graph);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
await collectUnusedExports();
|
|
74
|
+
const unusedFiles = [...cachedUnusedFiles].filter(filePath => !analyzedFiles.has(filePath));
|
|
75
|
+
collector.addFilesIssues(unusedFiles);
|
|
76
|
+
collector.addFileCounts({ processed: analyzedFiles.size, unused: unusedFiles.length });
|
|
77
|
+
await reportIssues(startTime);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
await collectUnusedExports();
|
|
83
|
+
await reportIssues();
|
|
84
|
+
return listener;
|
|
85
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.27.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.27.0';
|