knip 5.62.0 → 5.63.1
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 +22 -24
- package/dist/CacheConsultant.d.ts +3 -9
- package/dist/CacheConsultant.js +5 -5
- package/dist/ConfigurationChief.d.ts +588 -38
- package/dist/ConfigurationChief.js +43 -124
- package/dist/ConsoleStreamer.d.ts +2 -3
- package/dist/ConsoleStreamer.js +2 -2
- package/dist/DependencyDeputy.d.ts +2 -6
- package/dist/IssueCollector.d.ts +4 -12
- package/dist/IssueCollector.js +10 -10
- package/dist/IssueFixer.d.ts +3 -14
- package/dist/IssueFixer.js +11 -21
- package/dist/PrincipalFactory.d.ts +3 -2
- package/dist/PrincipalFactory.js +11 -11
- package/dist/ProjectPrincipal.d.ts +5 -3
- package/dist/ProjectPrincipal.js +17 -11
- package/dist/WorkspaceWorker.d.ts +4 -9
- package/dist/WorkspaceWorker.js +8 -12
- package/dist/binaries/bash-parser.js +1 -1
- package/dist/binaries/fallback.js +4 -2
- package/dist/binaries/package-manager/pnpm.js +6 -1
- package/dist/cli.js +43 -60
- package/dist/compilers/index.d.ts +34 -4
- package/dist/graph/analyze.d.ts +3 -8
- package/dist/graph/analyze.js +24 -27
- package/dist/graph/build.d.ts +3 -17
- package/dist/graph/build.js +60 -47
- package/dist/index.d.ts +3 -6
- package/dist/index.js +23 -62
- package/dist/plugins/astro/index.d.ts +1 -0
- package/dist/plugins/astro/index.js +4 -0
- package/dist/plugins/index.d.ts +24 -1
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/lefthook/index.js +2 -0
- package/dist/plugins/node-modules-inspector/index.d.ts +12 -0
- package/dist/plugins/node-modules-inspector/index.js +17 -0
- package/dist/plugins/nuxt/index.js +4 -3
- package/dist/plugins/nuxt/types.d.ts +3 -2
- package/dist/plugins/playwright/index.js +8 -1
- package/dist/plugins/playwright/types.d.ts +20 -14
- package/dist/plugins/pnpm/index.d.ts +7 -0
- package/dist/plugins/pnpm/index.js +8 -0
- package/dist/plugins/preconstruct/index.js +2 -1
- package/dist/plugins/react-router/index.js +18 -8
- package/dist/plugins/rsbuild/index.js +28 -2
- package/dist/plugins/rsbuild/types.d.ts +11 -0
- package/dist/plugins/rslib/index.d.ts +10 -0
- package/dist/plugins/rslib/index.js +15 -0
- package/dist/plugins/rslib/types.d.ts +1 -0
- package/dist/plugins/rspack/index.js +1 -1
- package/dist/plugins/typescript/index.d.ts +1 -1
- package/dist/plugins.js +3 -2
- package/dist/reporters/codeclimate.d.ts +1 -1
- package/dist/reporters/codeclimate.js +10 -10
- package/dist/reporters/codeowners.d.ts +1 -1
- package/dist/reporters/codeowners.js +5 -5
- package/dist/reporters/compact.d.ts +1 -1
- package/dist/reporters/compact.js +7 -7
- package/dist/reporters/disclosure.d.ts +1 -1
- package/dist/reporters/disclosure.js +2 -2
- package/dist/reporters/index.d.ts +6 -6
- package/dist/reporters/json.d.ts +1 -1
- package/dist/reporters/json.js +3 -3
- package/dist/reporters/markdown.d.ts +1 -1
- package/dist/reporters/markdown.js +4 -4
- package/dist/reporters/symbols.js +4 -2
- package/dist/reporters/util/configuration-hints.d.ts +1 -1
- package/dist/reporters/util/configuration-hints.js +58 -23
- package/dist/reporters/util/util.d.ts +2 -4
- package/dist/reporters/util/util.js +6 -6
- package/dist/reporters/watch.d.ts +3 -4
- package/dist/reporters/watch.js +5 -5
- package/dist/schema/configuration.d.ts +176 -8
- package/dist/schema/plugins.d.ts +69 -0
- package/dist/schema/plugins.js +3 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +3 -0
- package/dist/types/config.d.ts +4 -10
- package/dist/types/entries.d.ts +3 -0
- package/dist/types/entries.js +1 -0
- package/dist/types/issues.d.ts +4 -3
- package/dist/types/{cli.d.ts → options.d.ts} +2 -2
- package/dist/types/options.js +1 -0
- package/dist/types/package-json.d.ts +5 -0
- package/dist/types/project.d.ts +1 -7
- package/dist/types/tsconfig-json.d.ts +14 -0
- package/dist/types/tsconfig-json.js +1 -0
- package/dist/typescript/ast-helpers.js +1 -1
- package/dist/typescript/get-imports-and-exports.d.ts +2 -2
- package/dist/typescript/get-imports-and-exports.js +9 -10
- package/dist/util/Performance.js +16 -6
- package/dist/util/cli-arguments.d.ts +1 -2
- package/dist/util/cli-arguments.js +3 -13
- package/dist/util/create-options.d.ts +1219 -0
- package/dist/util/create-options.js +112 -0
- package/dist/util/debug.js +3 -4
- package/dist/util/errors.d.ts +1 -1
- package/dist/util/file-entry-cache.js +3 -3
- package/dist/util/fs.d.ts +1 -1
- package/dist/util/get-included-issue-types.d.ts +9 -13
- package/dist/util/get-included-issue-types.js +10 -16
- package/dist/util/get-referenced-inputs.js +1 -1
- package/dist/util/glob-core.d.ts +1 -1
- package/dist/util/glob-core.js +8 -7
- package/dist/util/glob.d.ts +1 -0
- package/dist/util/glob.js +1 -1
- package/dist/util/input.d.ts +1 -1
- package/dist/util/input.js +1 -1
- package/dist/util/is-identifier-referenced.d.ts +1 -1
- package/dist/util/is-identifier-referenced.js +19 -19
- package/dist/util/load-config.d.ts +1 -0
- package/dist/util/load-config.js +24 -0
- package/dist/util/package-json.d.ts +2 -1
- package/dist/util/package-json.js +24 -12
- package/dist/util/parse-and-convert-gitignores.js +2 -0
- package/dist/util/path.d.ts +4 -4
- package/dist/util/path.js +5 -7
- package/dist/util/reporter.js +3 -3
- package/dist/util/require.js +1 -2
- package/dist/util/table.js +1 -3
- package/dist/util/tag.d.ts +1 -1
- package/dist/util/to-source-path.d.ts +1 -1
- package/dist/util/to-source-path.js +5 -5
- package/dist/util/trace.d.ts +6 -6
- package/dist/util/trace.js +18 -22
- package/dist/util/watch.d.ts +2 -5
- package/dist/util/watch.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -15
- package/schema.json +12 -0
- package/dist/util/unwrap-function.d.ts +0 -1
- package/dist/util/unwrap-function.js +0 -13
- /package/dist/{types/cli.js → plugins/rslib/types.js} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { CacheConsultant } from './CacheConsultant.js';
|
|
3
3
|
import type { AsyncCompilers, SyncCompilers } from './compilers/types.js';
|
|
4
|
-
import type { GetImportsAndExportsOptions } from './types/config.js';
|
|
4
|
+
import type { GetImportsAndExportsOptions, IgnoreExportsUsedInFile } from './types/config.js';
|
|
5
5
|
import type { Export, ExportMember, FileNode, ModuleGraph } from './types/module-graph.js';
|
|
6
6
|
import type { Paths, PrincipalOptions } from './types/project.js';
|
|
7
7
|
import { SourceFileManager } from './typescript/SourceFileManager.js';
|
|
8
8
|
import type { ResolveModuleNames } from './typescript/resolve-module-names.js';
|
|
9
|
+
import type { MainOptions } from './util/create-options.js';
|
|
9
10
|
import type { ToSourceFilePath } from './util/to-source-path.js';
|
|
10
11
|
export declare class ProjectPrincipal {
|
|
11
12
|
entryPaths: Set<string>;
|
|
@@ -30,7 +31,8 @@ export declare class ProjectPrincipal {
|
|
|
30
31
|
languageServiceHost: ts.LanguageServiceHost;
|
|
31
32
|
};
|
|
32
33
|
findReferences?: ts.LanguageService['findReferences'];
|
|
33
|
-
|
|
34
|
+
getImplementationAtPosition?: ts.LanguageService['getImplementationAtPosition'];
|
|
35
|
+
constructor(options: MainOptions, { compilerOptions, compilers, pkgName, toSourceFilePath }: PrincipalOptions);
|
|
34
36
|
init(): void;
|
|
35
37
|
addPaths(paths: Paths, basePath: string): void;
|
|
36
38
|
addCompilers(compilers: [SyncCompilers, AsyncCompilers]): void;
|
|
@@ -50,7 +52,7 @@ export declare class ProjectPrincipal {
|
|
|
50
52
|
getUsedResolvedFiles(): string[];
|
|
51
53
|
private getProgramSourceFiles;
|
|
52
54
|
getUnreferencedFiles(): string[];
|
|
53
|
-
analyzeSourceFile(filePath: string, options:
|
|
55
|
+
analyzeSourceFile(filePath: string, options: GetImportsAndExportsOptions, ignoreExportsUsedInFile: IgnoreExportsUsedInFile): FileNode;
|
|
54
56
|
invalidateFile(filePath: string): void;
|
|
55
57
|
findUnusedMembers(filePath: string, members: ExportMember[]): ExportMember[];
|
|
56
58
|
hasExternalReferences(filePath: string, exportedItem: Export): boolean;
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -42,8 +42,8 @@ export class ProjectPrincipal {
|
|
|
42
42
|
toSourceFilePath;
|
|
43
43
|
backend;
|
|
44
44
|
findReferences;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
getImplementationAtPosition;
|
|
46
|
+
constructor(options, { compilerOptions, compilers, pkgName, toSourceFilePath }) {
|
|
47
47
|
this.compilerOptions = {
|
|
48
48
|
...compilerOptions,
|
|
49
49
|
...baseCompilerOptions,
|
|
@@ -54,12 +54,13 @@ export class ProjectPrincipal {
|
|
|
54
54
|
this.extensions = new Set([...DEFAULT_EXTENSIONS, ...getCompilerExtensions(compilers)]);
|
|
55
55
|
this.syncCompilers = syncCompilers;
|
|
56
56
|
this.asyncCompilers = asyncCompilers;
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
57
|
+
this.cwd = options.cwd;
|
|
58
|
+
this.isSkipLibs = options.isSkipLibs;
|
|
59
|
+
this.isWatch = options.isWatch;
|
|
60
|
+
this.cache = new CacheConsultant(pkgName || ANONYMOUS, options);
|
|
60
61
|
this.toSourceFilePath = toSourceFilePath;
|
|
61
62
|
this.backend = {
|
|
62
|
-
fileManager: new SourceFileManager({ compilers, isSkipLibs }),
|
|
63
|
+
fileManager: new SourceFileManager({ compilers, isSkipLibs: options.isSkipLibs }),
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
init() {
|
|
@@ -155,7 +156,7 @@ export class ProjectPrincipal {
|
|
|
155
156
|
const sourceFiles = this.getProgramSourceFiles();
|
|
156
157
|
return Array.from(this.projectPaths).filter(filePath => !sourceFiles.has(filePath));
|
|
157
158
|
}
|
|
158
|
-
analyzeSourceFile(filePath, options) {
|
|
159
|
+
analyzeSourceFile(filePath, options, ignoreExportsUsedInFile) {
|
|
159
160
|
const fd = this.cache.getFileDescriptor(filePath);
|
|
160
161
|
if (!fd.changed && fd.meta?.data)
|
|
161
162
|
return fd.meta.data;
|
|
@@ -167,21 +168,25 @@ export class ProjectPrincipal {
|
|
|
167
168
|
throw new Error(`Unable to find ${filePath}`);
|
|
168
169
|
const skipExports = this.skipExportsAnalysis.has(filePath);
|
|
169
170
|
const resolve = (specifier) => this.backend.resolveModuleNames([specifier], sourceFile.fileName)[0];
|
|
170
|
-
return _getImportsAndExports(sourceFile, resolve, typeChecker,
|
|
171
|
+
return _getImportsAndExports(sourceFile, resolve, typeChecker, options, ignoreExportsUsedInFile, skipExports);
|
|
171
172
|
}
|
|
172
173
|
invalidateFile(filePath) {
|
|
173
174
|
this.backend.fileManager.snapshotCache.delete(filePath);
|
|
174
175
|
this.backend.fileManager.sourceFileCache.delete(filePath);
|
|
175
176
|
}
|
|
176
177
|
findUnusedMembers(filePath, members) {
|
|
177
|
-
if (!this.findReferences) {
|
|
178
|
+
if (!this.findReferences || !this.getImplementationAtPosition) {
|
|
178
179
|
const languageService = ts.createLanguageService(this.backend.languageServiceHost, ts.createDocumentRegistry());
|
|
179
180
|
this.findReferences = timerify(languageService.findReferences);
|
|
181
|
+
this.getImplementationAtPosition = timerify(languageService.getImplementationAtPosition);
|
|
180
182
|
}
|
|
181
183
|
return members.filter(member => {
|
|
182
184
|
if (member.jsDocTags.has(PUBLIC_TAG))
|
|
183
185
|
return false;
|
|
184
|
-
const
|
|
186
|
+
const implementations = this.getImplementationAtPosition?.(filePath, member.pos)?.filter(impl => impl.fileName !== filePath || impl.textSpan.start !== member.pos) ?? [];
|
|
187
|
+
const referencedSymbols = this.findReferences?.(filePath, member.pos)?.filter(sym => !implementations.some(impl => impl.fileName === sym.definition.fileName &&
|
|
188
|
+
impl.textSpan.start === sym.definition.textSpan.start &&
|
|
189
|
+
impl.textSpan.length === sym.definition.textSpan.length)) ?? [];
|
|
185
190
|
const refs = referencedSymbols.flatMap(refs => refs.references).filter(ref => !ref.isDefinition);
|
|
186
191
|
return refs.length === 0;
|
|
187
192
|
});
|
|
@@ -189,9 +194,10 @@ export class ProjectPrincipal {
|
|
|
189
194
|
hasExternalReferences(filePath, exportedItem) {
|
|
190
195
|
if (exportedItem.jsDocTags.has(PUBLIC_TAG))
|
|
191
196
|
return false;
|
|
192
|
-
if (!this.findReferences) {
|
|
197
|
+
if (!this.findReferences || !this.getImplementationAtPosition) {
|
|
193
198
|
const languageService = ts.createLanguageService(this.backend.languageServiceHost, ts.createDocumentRegistry());
|
|
194
199
|
this.findReferences = timerify(languageService.findReferences);
|
|
200
|
+
this.getImplementationAtPosition = timerify(languageService.getImplementationAtPosition);
|
|
195
201
|
}
|
|
196
202
|
const referencedSymbols = this.findReferences(filePath, exportedItem.pos);
|
|
197
203
|
if (!referencedSymbols?.length)
|
|
@@ -5,11 +5,11 @@ import type { Configuration, GetReferencedInternalFilePath, GetSourceFile, Works
|
|
|
5
5
|
import type { ConfigurationHints } from './types/issues.js';
|
|
6
6
|
import type { PackageJson } from './types/package-json.js';
|
|
7
7
|
import type { DependencySet } from './types/workspace.js';
|
|
8
|
+
import type { MainOptions } from './util/create-options.js';
|
|
8
9
|
import { type Input } from './util/input.js';
|
|
9
10
|
type WorkspaceManagerOptions = {
|
|
10
11
|
name: string;
|
|
11
12
|
dir: string;
|
|
12
|
-
cwd: string;
|
|
13
13
|
config: WorkspaceConfiguration;
|
|
14
14
|
manifest: PackageJson;
|
|
15
15
|
dependencies: DependencySet;
|
|
@@ -20,11 +20,8 @@ type WorkspaceManagerOptions = {
|
|
|
20
20
|
negatedWorkspacePatterns: string[];
|
|
21
21
|
ignoredWorkspacePatterns: string[];
|
|
22
22
|
enabledPluginsInAncestors: string[];
|
|
23
|
-
isProduction: boolean;
|
|
24
|
-
isStrict: boolean;
|
|
25
|
-
isCache: boolean;
|
|
26
|
-
cacheLocation: string;
|
|
27
23
|
configFilesMap: Map<string, Map<PluginName, Set<string>>>;
|
|
24
|
+
options: MainOptions;
|
|
28
25
|
};
|
|
29
26
|
type CacheItem = {
|
|
30
27
|
resolveConfig?: Input[];
|
|
@@ -34,24 +31,22 @@ type CacheItem = {
|
|
|
34
31
|
export declare class WorkspaceWorker {
|
|
35
32
|
name: string;
|
|
36
33
|
dir: string;
|
|
37
|
-
cwd: string;
|
|
38
34
|
config: WorkspaceConfiguration;
|
|
39
35
|
manifest: PackageJson;
|
|
40
36
|
dependencies: DependencySet;
|
|
41
37
|
getReferencedInternalFilePath: GetReferencedInternalFilePath;
|
|
42
38
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
43
39
|
getSourceFile: GetSourceFile;
|
|
44
|
-
isProduction: boolean;
|
|
45
|
-
isStrict: boolean;
|
|
46
40
|
rootIgnore: Configuration['ignore'];
|
|
47
41
|
negatedWorkspacePatterns: string[];
|
|
48
42
|
ignoredWorkspacePatterns: string[];
|
|
43
|
+
options: MainOptions;
|
|
49
44
|
enabledPluginsMap: Record<PluginName, boolean>;
|
|
50
45
|
enabledPlugins: PluginName[];
|
|
51
46
|
enabledPluginsInAncestors: string[];
|
|
52
47
|
cache: CacheConsultant<CacheItem>;
|
|
53
48
|
configFilesMap: Map<string, Map<PluginName, Set<string>>>;
|
|
54
|
-
constructor({ name, dir,
|
|
49
|
+
constructor({ name, dir, config, manifest, dependencies, rootIgnore, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, getReferencedInternalFilePath, findWorkspaceByFilePath, getSourceFile, configFilesMap, options, }: WorkspaceManagerOptions);
|
|
55
50
|
init(): Promise<void>;
|
|
56
51
|
private determineEnabledPlugins;
|
|
57
52
|
private getConfigForPlugin;
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -19,32 +19,27 @@ const initEnabledPluginsMap = () => Object.keys(Plugins).reduce((enabled, plugin
|
|
|
19
19
|
export class WorkspaceWorker {
|
|
20
20
|
name;
|
|
21
21
|
dir;
|
|
22
|
-
cwd;
|
|
23
22
|
config;
|
|
24
23
|
manifest;
|
|
25
24
|
dependencies;
|
|
26
25
|
getReferencedInternalFilePath;
|
|
27
26
|
findWorkspaceByFilePath;
|
|
28
27
|
getSourceFile;
|
|
29
|
-
isProduction;
|
|
30
|
-
isStrict;
|
|
31
28
|
rootIgnore;
|
|
32
29
|
negatedWorkspacePatterns = [];
|
|
33
30
|
ignoredWorkspacePatterns = [];
|
|
31
|
+
options;
|
|
34
32
|
enabledPluginsMap = initEnabledPluginsMap();
|
|
35
33
|
enabledPlugins = [];
|
|
36
34
|
enabledPluginsInAncestors;
|
|
37
35
|
cache;
|
|
38
36
|
configFilesMap;
|
|
39
|
-
constructor({ name, dir,
|
|
37
|
+
constructor({ name, dir, config, manifest, dependencies, rootIgnore, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, getReferencedInternalFilePath, findWorkspaceByFilePath, getSourceFile, configFilesMap, options, }) {
|
|
40
38
|
this.name = name;
|
|
41
39
|
this.dir = dir;
|
|
42
|
-
this.cwd = cwd;
|
|
43
40
|
this.config = config;
|
|
44
41
|
this.manifest = manifest;
|
|
45
42
|
this.dependencies = dependencies;
|
|
46
|
-
this.isProduction = isProduction;
|
|
47
|
-
this.isStrict = isStrict;
|
|
48
43
|
this.rootIgnore = rootIgnore;
|
|
49
44
|
this.negatedWorkspacePatterns = negatedWorkspacePatterns;
|
|
50
45
|
this.ignoredWorkspacePatterns = ignoredWorkspacePatterns;
|
|
@@ -53,7 +48,8 @@ export class WorkspaceWorker {
|
|
|
53
48
|
this.getReferencedInternalFilePath = getReferencedInternalFilePath;
|
|
54
49
|
this.findWorkspaceByFilePath = findWorkspaceByFilePath;
|
|
55
50
|
this.getSourceFile = getSourceFile;
|
|
56
|
-
this.
|
|
51
|
+
this.options = options;
|
|
52
|
+
this.cache = new CacheConsultant(`plugins-${name}`, options);
|
|
57
53
|
this.getConfigurationHints = timerify(this.getConfigurationHints.bind(this), 'worker.getConfigurationHints');
|
|
58
54
|
}
|
|
59
55
|
async init() {
|
|
@@ -64,7 +60,7 @@ export class WorkspaceWorker {
|
|
|
64
60
|
for (const [pluginName, plugin] of PluginEntries) {
|
|
65
61
|
if (this.config[pluginName] === false)
|
|
66
62
|
continue;
|
|
67
|
-
if (this.cwd !== this.dir && plugin.isRootOnly)
|
|
63
|
+
if (this.options.cwd !== this.dir && plugin.isRootOnly)
|
|
68
64
|
continue;
|
|
69
65
|
if (this.config[pluginName]) {
|
|
70
66
|
this.enabledPluginsMap[pluginName] = true;
|
|
@@ -169,10 +165,10 @@ export class WorkspaceWorker {
|
|
|
169
165
|
async runPlugins() {
|
|
170
166
|
const wsName = this.name;
|
|
171
167
|
const cwd = this.dir;
|
|
172
|
-
const rootCwd = this.cwd;
|
|
168
|
+
const rootCwd = this.options.cwd;
|
|
173
169
|
const manifest = this.manifest;
|
|
174
170
|
const containingFilePath = join(cwd, 'package.json');
|
|
175
|
-
const isProduction = this.isProduction;
|
|
171
|
+
const isProduction = this.options.isProduction;
|
|
176
172
|
const knownBinsOnly = false;
|
|
177
173
|
const manifestScriptNames = new Set(Object.keys(manifest.scripts ?? {}));
|
|
178
174
|
const baseOptions = { manifestScriptNames, cwd, rootCwd, containingFilePath, knownBinsOnly };
|
|
@@ -344,7 +340,7 @@ export class WorkspaceWorker {
|
|
|
344
340
|
} while (remainingPlugins.size > 0 && configFiles.size > 0);
|
|
345
341
|
}
|
|
346
342
|
}
|
|
347
|
-
debugLogArray(wsName, 'Plugin dependencies', () => compact(inputs.map(toDebugString)));
|
|
343
|
+
debugLogArray(wsName, 'Plugin dependencies', () => compact(inputs.map(input => toDebugString(input, rootCwd))));
|
|
348
344
|
return inputs;
|
|
349
345
|
}
|
|
350
346
|
getConfigurationHints(type, patterns, filePaths, includedPaths) {
|
|
@@ -88,7 +88,7 @@ export const getDependenciesFromScript = (script, options) => {
|
|
|
88
88
|
return parsed?.commands ? getDependenciesFromNodes(parsed.commands) : [];
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
91
|
-
const msg = `Warning: failed to parse and ignoring script in ${relative(options.containingFilePath)} (${truncate(script, 30)})`;
|
|
91
|
+
const msg = `Warning: failed to parse and ignoring script in ${relative(options.cwd, options.containingFilePath)} (${truncate(script, 30)})`;
|
|
92
92
|
debugLogObject('*', msg, error);
|
|
93
93
|
return [];
|
|
94
94
|
}
|
|
@@ -4,11 +4,13 @@ import { toBinary, toDeferResolve, toEntry } from '../util/input.js';
|
|
|
4
4
|
const spawningBinaries = ['cross-env', 'retry-cli'];
|
|
5
5
|
const endOfCommandBinaries = ['dotenvx'];
|
|
6
6
|
const positionals = new Set(['babel-node', 'esbuild', 'execa', 'jiti', 'oxnode', 'vite-node', 'zx']);
|
|
7
|
+
const positionalBinaries = new Set(['concurrently']);
|
|
7
8
|
export const resolve = (binary, args, { fromArgs }) => {
|
|
8
9
|
const parsed = parseArgs(args, { boolean: ['quiet', 'verbose'], '--': endOfCommandBinaries.includes(binary) });
|
|
9
|
-
const bin = binary.startsWith('.') ? toEntry(binary) : toBinary(binary);
|
|
10
|
+
const bin = binary.startsWith('.') ? toEntry(binary) : /[*:]/.test(binary) ? undefined : toBinary(binary);
|
|
10
11
|
const shiftedArgs = spawningBinaries.includes(binary) ? fromArgs(args) : [];
|
|
11
12
|
const pos = positionals.has(binary) ? [toDeferResolve(parsed._[0])] : [];
|
|
12
13
|
const newCommand = parsed['--'] && parsed['--'].length > 0 ? fromArgs(parsed['--']) : [];
|
|
13
|
-
|
|
14
|
+
const commands = positionalBinaries.has(binary) ? parsed._.flatMap(cmd => fromArgs([cmd])) : [];
|
|
15
|
+
return compact([bin, ...shiftedArgs, ...pos, ...newCommand, ...commands]);
|
|
14
16
|
};
|
|
@@ -3,9 +3,12 @@ import { toBinary } from '../../util/input.js';
|
|
|
3
3
|
import { resolveDlx } from './pnpx.js';
|
|
4
4
|
const commands = [
|
|
5
5
|
'add',
|
|
6
|
+
'approve-builds',
|
|
6
7
|
'audit',
|
|
7
8
|
'bin',
|
|
8
9
|
'cache',
|
|
10
|
+
'cat-file',
|
|
11
|
+
'cat-index',
|
|
9
12
|
'config',
|
|
10
13
|
'dedupe',
|
|
11
14
|
'deploy',
|
|
@@ -13,7 +16,9 @@ const commands = [
|
|
|
13
16
|
'doctor',
|
|
14
17
|
'env',
|
|
15
18
|
'fetch',
|
|
19
|
+
'find-hash',
|
|
16
20
|
'i',
|
|
21
|
+
'ignored-builds',
|
|
17
22
|
'import',
|
|
18
23
|
'init',
|
|
19
24
|
'install-test',
|
|
@@ -25,7 +30,6 @@ const commands = [
|
|
|
25
30
|
'ln',
|
|
26
31
|
'ls',
|
|
27
32
|
'outdated',
|
|
28
|
-
'outdated',
|
|
29
33
|
'pack',
|
|
30
34
|
'patch-commit',
|
|
31
35
|
'patch-remove',
|
|
@@ -39,6 +43,7 @@ const commands = [
|
|
|
39
43
|
'rm',
|
|
40
44
|
'root',
|
|
41
45
|
'run',
|
|
46
|
+
'self-update',
|
|
42
47
|
'server',
|
|
43
48
|
'setup',
|
|
44
49
|
'start',
|
package/dist/cli.js
CHANGED
|
@@ -1,102 +1,85 @@
|
|
|
1
1
|
import { main } from './index.js';
|
|
2
2
|
import { perfObserver } from './util/Performance.js';
|
|
3
|
-
import
|
|
3
|
+
import { helpText } from './util/cli-arguments.js';
|
|
4
|
+
import parseArgs from './util/cli-arguments.js';
|
|
5
|
+
import { createOptions } from './util/create-options.js';
|
|
4
6
|
import { getKnownError, isConfigurationError, isDisplayReason, isKnownError } from './util/errors.js';
|
|
5
7
|
import { logError, logWarning } from './util/log.js';
|
|
6
|
-
import { cwd, join, toPosix } from './util/path.js';
|
|
7
8
|
import { runPreprocessors, runReporters } from './util/reporter.js';
|
|
8
9
|
import { prettyMilliseconds } from './util/string.js';
|
|
9
|
-
import { splitTags } from './util/tag.js';
|
|
10
|
-
import { isTrace } from './util/trace.js';
|
|
11
10
|
import { version } from './version.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
console.log(helpText);
|
|
16
|
-
process.exit(0);
|
|
11
|
+
let parsedCLIArgs = {};
|
|
12
|
+
try {
|
|
13
|
+
parsedCLIArgs = parseArgs();
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error instanceof Error) {
|
|
17
|
+
console.error(error.message);
|
|
18
|
+
console.log(`\n${helpText}`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
21
22
|
}
|
|
22
|
-
const isShowProgress = isNoProgress === false && process.stdout.isTTY && typeof process.stdout.cursorTo === 'function';
|
|
23
|
-
const workspace = rawWorkspaceArg ? toPosix(rawWorkspaceArg).replace(/^\.\//, '').replace(/\/$/, '') : undefined;
|
|
24
23
|
const run = async () => {
|
|
25
24
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
isFilesShorthand,
|
|
38
|
-
isFix: isFix || fixTypes.length > 0,
|
|
39
|
-
isFormat,
|
|
40
|
-
isIncludeEntryExports,
|
|
41
|
-
isIncludeLibs,
|
|
42
|
-
isIsolateWorkspaces,
|
|
43
|
-
isProduction: isStrict || isProduction,
|
|
44
|
-
isRemoveFiles,
|
|
45
|
-
isShowProgress,
|
|
46
|
-
isStrict,
|
|
47
|
-
isWatch,
|
|
48
|
-
tags: tags.length > 0 ? splitTags(tags) : splitTags(experimentalTags),
|
|
49
|
-
tsConfigFile: tsConfig,
|
|
50
|
-
workspace,
|
|
51
|
-
});
|
|
52
|
-
const isDisableConfigHints = isNoConfigHints || isProduction || Boolean(workspace);
|
|
53
|
-
if (isWatch || isTrace)
|
|
25
|
+
const options = await createOptions({ parsedCLIArgs });
|
|
26
|
+
if (parsedCLIArgs.help) {
|
|
27
|
+
console.log(helpText);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
if (parsedCLIArgs.version) {
|
|
31
|
+
console.log(version);
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
const { issues, counters, tagHints, configurationHints, includedWorkspaceDirs } = await main(options);
|
|
35
|
+
if (options.isWatch || options.isTrace)
|
|
54
36
|
return;
|
|
55
37
|
const initialData = {
|
|
56
|
-
report,
|
|
38
|
+
report: options.includedIssueTypes,
|
|
57
39
|
issues,
|
|
58
40
|
counters,
|
|
59
41
|
tagHints,
|
|
60
42
|
configurationHints,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
includedWorkspaceDirs,
|
|
44
|
+
cwd: options.cwd,
|
|
45
|
+
configFilePath: options.configFilePath,
|
|
46
|
+
isDisableConfigHints: options.isDisableConfigHints,
|
|
47
|
+
isProduction: options.isProduction,
|
|
48
|
+
isShowProgress: options.isShowProgress,
|
|
49
|
+
isTreatConfigHintsAsErrors: options.isTreatConfigHintsAsErrors,
|
|
50
|
+
options: parsedCLIArgs['reporter-options'] ?? '',
|
|
51
|
+
preprocessorOptions: parsedCLIArgs['preprocessor-options'] ?? '',
|
|
69
52
|
};
|
|
70
|
-
const finalData = await runPreprocessors(preprocessor, initialData);
|
|
71
|
-
await runReporters(reporter, finalData);
|
|
53
|
+
const finalData = await runPreprocessors(parsedCLIArgs.preprocessor ?? [], initialData);
|
|
54
|
+
await runReporters(parsedCLIArgs.reporter ?? ['symbols'], finalData);
|
|
72
55
|
const totalErrorCount = Object.keys(finalData.report)
|
|
73
|
-
.filter(reportGroup => finalData.report[reportGroup] && rules[reportGroup] === 'error')
|
|
56
|
+
.filter(reportGroup => finalData.report[reportGroup] && options.rules[reportGroup] === 'error')
|
|
74
57
|
.reduce((errorCount, reportGroup) => errorCount + finalData.counters[reportGroup], 0);
|
|
75
58
|
if (perfObserver.isEnabled)
|
|
76
59
|
await perfObserver.finalize();
|
|
77
60
|
if (perfObserver.isTimerifyFunctions)
|
|
78
61
|
console.log(`\n${perfObserver.getTimerifiedFunctionsTable()}`);
|
|
79
|
-
if (perfObserver.isMemoryUsageEnabled && !
|
|
62
|
+
if (perfObserver.isMemoryUsageEnabled && !parsedCLIArgs['memory-realtime'])
|
|
80
63
|
console.log(`\n${perfObserver.getMemoryUsageTable()}`);
|
|
81
64
|
if (perfObserver.isEnabled) {
|
|
82
65
|
const duration = perfObserver.getCurrentDurationInMs();
|
|
83
66
|
console.log('\nTotal running time:', prettyMilliseconds(duration));
|
|
84
67
|
perfObserver.reset();
|
|
85
68
|
}
|
|
86
|
-
if (
|
|
69
|
+
if (parsedCLIArgs['experimental-tags'] && parsedCLIArgs['experimental-tags'].length > 0) {
|
|
87
70
|
logWarning('DEPRECATION WARNING', '--experimental-tags is deprecated, please start using --tags instead');
|
|
88
71
|
}
|
|
89
|
-
if (isIsolateWorkspaces &&
|
|
72
|
+
if (options.isIsolateWorkspaces && options.includedIssueTypes.classMembers) {
|
|
90
73
|
logWarning('WARNING', 'Class members are not tracked when using the --isolate-workspaces flag');
|
|
91
74
|
}
|
|
92
|
-
if ((!
|
|
93
|
-
(
|
|
75
|
+
if ((!parsedCLIArgs['no-exit-code'] && totalErrorCount > Number(parsedCLIArgs['max-issues'] ?? 0)) ||
|
|
76
|
+
(options.isTreatConfigHintsAsErrors && configurationHints.size > 0)) {
|
|
94
77
|
process.exit(1);
|
|
95
78
|
}
|
|
96
79
|
}
|
|
97
80
|
catch (error) {
|
|
98
81
|
process.exitCode = 2;
|
|
99
|
-
if (!
|
|
82
|
+
if (!parsedCLIArgs.debug && error instanceof Error && isKnownError(error)) {
|
|
100
83
|
const knownError = getKnownError(error);
|
|
101
84
|
logError('ERROR', knownError.message);
|
|
102
85
|
if (isDisplayReason(knownError))
|
|
@@ -4,9 +4,6 @@ import type { AsyncCompilerFn, AsyncCompilers, RawSyncCompilers, SyncCompilerFn,
|
|
|
4
4
|
export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
5
5
|
syncCompilers: Record<string, SyncCompilerFn>;
|
|
6
6
|
asyncCompilers: Record<string, AsyncCompilerFn>;
|
|
7
|
-
exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
8
|
-
tags?: string[] | undefined;
|
|
9
|
-
include?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
10
7
|
node?: string | boolean | string[] | {
|
|
11
8
|
config?: string | string[] | undefined;
|
|
12
9
|
entry?: string | string[] | undefined;
|
|
@@ -264,6 +261,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
264
261
|
entry?: string | string[] | undefined;
|
|
265
262
|
project?: string | string[] | undefined;
|
|
266
263
|
} | undefined;
|
|
264
|
+
'node-modules-inspector'?: string | boolean | string[] | {
|
|
265
|
+
config?: string | string[] | undefined;
|
|
266
|
+
entry?: string | string[] | undefined;
|
|
267
|
+
project?: string | string[] | undefined;
|
|
268
|
+
} | undefined;
|
|
267
269
|
nodemon?: string | boolean | string[] | {
|
|
268
270
|
config?: string | string[] | undefined;
|
|
269
271
|
entry?: string | string[] | undefined;
|
|
@@ -319,6 +321,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
319
321
|
entry?: string | string[] | undefined;
|
|
320
322
|
project?: string | string[] | undefined;
|
|
321
323
|
} | undefined;
|
|
324
|
+
pnpm?: string | boolean | string[] | {
|
|
325
|
+
config?: string | string[] | undefined;
|
|
326
|
+
entry?: string | string[] | undefined;
|
|
327
|
+
project?: string | string[] | undefined;
|
|
328
|
+
} | undefined;
|
|
322
329
|
postcss?: string | boolean | string[] | {
|
|
323
330
|
config?: string | string[] | undefined;
|
|
324
331
|
entry?: string | string[] | undefined;
|
|
@@ -379,6 +386,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
379
386
|
entry?: string | string[] | undefined;
|
|
380
387
|
project?: string | string[] | undefined;
|
|
381
388
|
} | undefined;
|
|
389
|
+
rslib?: string | boolean | string[] | {
|
|
390
|
+
config?: string | string[] | undefined;
|
|
391
|
+
entry?: string | string[] | undefined;
|
|
392
|
+
project?: string | string[] | undefined;
|
|
393
|
+
} | undefined;
|
|
382
394
|
rspack?: string | boolean | string[] | {
|
|
383
395
|
config?: string | string[] | undefined;
|
|
384
396
|
entry?: string | string[] | undefined;
|
|
@@ -554,8 +566,9 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
554
566
|
entry?: string | string[] | undefined;
|
|
555
567
|
project?: string | string[] | undefined;
|
|
556
568
|
} | undefined;
|
|
569
|
+
exclude?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
557
570
|
$schema?: string | undefined;
|
|
558
|
-
rules?: Partial<Record<"
|
|
571
|
+
rules?: Partial<Record<"files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
|
|
559
572
|
paths?: Record<string, string[]> | undefined;
|
|
560
573
|
ignore?: string | string[] | undefined;
|
|
561
574
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
@@ -566,7 +579,9 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
566
579
|
ignoreWorkspaces?: string[] | undefined;
|
|
567
580
|
includeEntryExports?: boolean | undefined;
|
|
568
581
|
compilers?: Record<string, true | ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
|
|
582
|
+
tags?: string[] | undefined;
|
|
569
583
|
treatConfigHintsAsErrors?: boolean | undefined;
|
|
584
|
+
include?: ("files" | "dependencies" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
|
|
570
585
|
workspaces?: Record<string, {
|
|
571
586
|
node?: string | boolean | string[] | {
|
|
572
587
|
config?: string | string[] | undefined;
|
|
@@ -825,6 +840,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
825
840
|
entry?: string | string[] | undefined;
|
|
826
841
|
project?: string | string[] | undefined;
|
|
827
842
|
} | undefined;
|
|
843
|
+
'node-modules-inspector'?: string | boolean | string[] | {
|
|
844
|
+
config?: string | string[] | undefined;
|
|
845
|
+
entry?: string | string[] | undefined;
|
|
846
|
+
project?: string | string[] | undefined;
|
|
847
|
+
} | undefined;
|
|
828
848
|
nodemon?: string | boolean | string[] | {
|
|
829
849
|
config?: string | string[] | undefined;
|
|
830
850
|
entry?: string | string[] | undefined;
|
|
@@ -880,6 +900,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
880
900
|
entry?: string | string[] | undefined;
|
|
881
901
|
project?: string | string[] | undefined;
|
|
882
902
|
} | undefined;
|
|
903
|
+
pnpm?: string | boolean | string[] | {
|
|
904
|
+
config?: string | string[] | undefined;
|
|
905
|
+
entry?: string | string[] | undefined;
|
|
906
|
+
project?: string | string[] | undefined;
|
|
907
|
+
} | undefined;
|
|
883
908
|
postcss?: string | boolean | string[] | {
|
|
884
909
|
config?: string | string[] | undefined;
|
|
885
910
|
entry?: string | string[] | undefined;
|
|
@@ -940,6 +965,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
940
965
|
entry?: string | string[] | undefined;
|
|
941
966
|
project?: string | string[] | undefined;
|
|
942
967
|
} | undefined;
|
|
968
|
+
rslib?: string | boolean | string[] | {
|
|
969
|
+
config?: string | string[] | undefined;
|
|
970
|
+
entry?: string | string[] | undefined;
|
|
971
|
+
project?: string | string[] | undefined;
|
|
972
|
+
} | undefined;
|
|
943
973
|
rspack?: string | boolean | string[] | {
|
|
944
974
|
config?: string | string[] | undefined;
|
|
945
975
|
entry?: string | string[] | undefined;
|
package/dist/graph/analyze.d.ts
CHANGED
|
@@ -4,9 +4,8 @@ import type { DependencyDeputy } from '../DependencyDeputy.js';
|
|
|
4
4
|
import type { IssueCollector } from '../IssueCollector.js';
|
|
5
5
|
import type { IssueFixer } from '../IssueFixer.js';
|
|
6
6
|
import type { PrincipalFactory } from '../PrincipalFactory.js';
|
|
7
|
-
import type { Tags } from '../types/cli.js';
|
|
8
|
-
import type { Report } from '../types/issues.js';
|
|
9
7
|
import type { ModuleGraph } from '../types/module-graph.js';
|
|
8
|
+
import type { MainOptions } from '../util/create-options.js';
|
|
10
9
|
interface AnalyzeOptions {
|
|
11
10
|
analyzedFiles: Set<string>;
|
|
12
11
|
chief: ConfigurationChief;
|
|
@@ -16,13 +15,9 @@ interface AnalyzeOptions {
|
|
|
16
15
|
factory: PrincipalFactory;
|
|
17
16
|
fixer: IssueFixer;
|
|
18
17
|
graph: ModuleGraph;
|
|
19
|
-
isFix: boolean;
|
|
20
|
-
isIncludeLibs: boolean;
|
|
21
|
-
isProduction: boolean;
|
|
22
|
-
report: Report;
|
|
23
18
|
streamer: ConsoleStreamer;
|
|
24
|
-
tags: Tags;
|
|
25
19
|
unreferencedFiles: Set<string>;
|
|
20
|
+
options: MainOptions;
|
|
26
21
|
}
|
|
27
|
-
export declare const analyze: (options: AnalyzeOptions) => Promise<() => Promise<void>>;
|
|
22
|
+
export declare const analyze: ({ analyzedFiles, chief, collector, deputy, entryPaths, factory, fixer, graph, streamer, unreferencedFiles, options, }: AnalyzeOptions) => Promise<() => Promise<void>>;
|
|
28
23
|
export {};
|