knip 2.40.0 → 2.40.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/dist/ConfigurationChief.d.ts +3 -1
- package/dist/ConfigurationChief.js +7 -2
- package/dist/ProjectPrincipal.js +5 -2
- package/dist/index.js +1 -1
- package/dist/plugins/node-test-runner/index.d.ts +1 -1
- package/dist/plugins/node-test-runner/index.js +1 -1
- package/dist/util/modules.js +5 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import type { PackageJson } from '@npmcli/package-json';
|
|
|
6
6
|
type ConfigurationManagerOptions = {
|
|
7
7
|
cwd: string;
|
|
8
8
|
isProduction: boolean;
|
|
9
|
+
isStrict: boolean;
|
|
9
10
|
};
|
|
10
11
|
export type Workspace = {
|
|
11
12
|
name: string;
|
|
@@ -19,6 +20,7 @@ export type Workspace = {
|
|
|
19
20
|
export declare class ConfigurationChief {
|
|
20
21
|
cwd: string;
|
|
21
22
|
isProduction: boolean;
|
|
23
|
+
isStrict: boolean;
|
|
22
24
|
config: Configuration;
|
|
23
25
|
manifestPath?: string;
|
|
24
26
|
manifest?: PackageJson;
|
|
@@ -36,7 +38,7 @@ export declare class ConfigurationChief {
|
|
|
36
38
|
enabledWorkspaces: Workspace[];
|
|
37
39
|
resolvedConfigFilePath?: string;
|
|
38
40
|
rawConfig?: any;
|
|
39
|
-
constructor({ cwd, isProduction }: ConfigurationManagerOptions);
|
|
41
|
+
constructor({ cwd, isProduction, isStrict }: ConfigurationManagerOptions);
|
|
40
42
|
init(): Promise<void>;
|
|
41
43
|
private loadResolvedConfigurationFile;
|
|
42
44
|
getCompilers(): [SyncCompilers, AsyncCompilers];
|
|
@@ -51,6 +51,7 @@ const PLUGIN_NAMES = Object.keys(plugins);
|
|
|
51
51
|
export class ConfigurationChief {
|
|
52
52
|
cwd;
|
|
53
53
|
isProduction = false;
|
|
54
|
+
isStrict = false;
|
|
54
55
|
config;
|
|
55
56
|
manifestPath;
|
|
56
57
|
manifest;
|
|
@@ -65,9 +66,10 @@ export class ConfigurationChief {
|
|
|
65
66
|
enabledWorkspaces = [];
|
|
66
67
|
resolvedConfigFilePath;
|
|
67
68
|
rawConfig;
|
|
68
|
-
constructor({ cwd, isProduction }) {
|
|
69
|
+
constructor({ cwd, isProduction, isStrict }) {
|
|
69
70
|
this.cwd = cwd;
|
|
70
71
|
this.isProduction = isProduction;
|
|
72
|
+
this.isStrict = isStrict;
|
|
71
73
|
this.config = defaultConfig;
|
|
72
74
|
}
|
|
73
75
|
async init() {
|
|
@@ -233,7 +235,10 @@ export class ConfigurationChief {
|
|
|
233
235
|
: this.availableWorkspaceNames;
|
|
234
236
|
const graph = this.workspacesGraph?.graph;
|
|
235
237
|
const ws = new Set();
|
|
236
|
-
if (
|
|
238
|
+
if (workspaceArg && this.isStrict) {
|
|
239
|
+
ws.add(workspaceArg);
|
|
240
|
+
}
|
|
241
|
+
else if (graph && workspaceArg) {
|
|
237
242
|
const seen = new Set();
|
|
238
243
|
const initialWorkspaces = new Set(workspaceNames.map(name => join(this.cwd, name)));
|
|
239
244
|
const workspaceDirsWithDependants = new Set(initialWorkspaces);
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -122,10 +122,13 @@ export class ProjectPrincipal {
|
|
|
122
122
|
const resolvedModule = this.resolveModule(specifier, filePath);
|
|
123
123
|
if (resolvedModule) {
|
|
124
124
|
if (resolvedModule.isExternalLibraryImport) {
|
|
125
|
-
|
|
125
|
+
const sanitizedSpecifier = sanitizeSpecifier(specifier);
|
|
126
|
+
external.add(sanitizedSpecifier);
|
|
126
127
|
}
|
|
127
128
|
else {
|
|
128
|
-
this.
|
|
129
|
+
const isIgnored = this.isGitIgnored(resolvedModule.resolvedFileName);
|
|
130
|
+
if (!isIgnored)
|
|
131
|
+
this.addEntryPath(resolvedModule.resolvedFileName, { skipExportsAnalysis: true });
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
else {
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { WorkspaceWorker } from './WorkspaceWorker.js';
|
|
|
17
17
|
export const main = async (unresolvedConfiguration) => {
|
|
18
18
|
const { cwd, tsConfigFile, gitignore, isStrict, isProduction, isIgnoreInternal, isShowProgress, isIncludeEntryExports, } = unresolvedConfiguration;
|
|
19
19
|
debugLogObject('*', 'Unresolved configuration (from CLI arguments)', unresolvedConfiguration);
|
|
20
|
-
const chief = new ConfigurationChief({ cwd, isProduction });
|
|
20
|
+
const chief = new ConfigurationChief({ cwd, isProduction, isStrict });
|
|
21
21
|
const deputy = new DependencyDeputy({ isStrict });
|
|
22
22
|
const factory = new PrincipalFactory();
|
|
23
23
|
const streamer = new ConsoleStreamer({ isEnabled: isShowProgress });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "Node.js Test Runner";
|
|
3
|
-
export declare const ENABLERS
|
|
3
|
+
export declare const ENABLERS = "This plugin is enabled when any script in `package.json` includes `node --test`";
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
5
|
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
6
6
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { timerify } from '../../util/Performance.js';
|
|
2
2
|
import { toEntryPattern } from '../../util/protocols.js';
|
|
3
3
|
export const NAME = 'Node.js Test Runner';
|
|
4
|
-
export const ENABLERS =
|
|
4
|
+
export const ENABLERS = 'This plugin is enabled when any script in `package.json` includes `node --test`';
|
|
5
5
|
export const isEnabled = ({ manifest }) => {
|
|
6
6
|
return Object.keys(manifest.scripts ?? {})
|
|
7
7
|
.filter(s => /test/.test(s))
|
package/dist/util/modules.js
CHANGED
|
@@ -51,4 +51,8 @@ export const getEntryPathFromManifest = (cwd, dir, manifest) => {
|
|
|
51
51
|
}
|
|
52
52
|
return _glob({ cwd, workingDir: dir, patterns: Array.from(entryPaths) });
|
|
53
53
|
};
|
|
54
|
-
export const sanitizeSpecifier = (specifier) =>
|
|
54
|
+
export const sanitizeSpecifier = (specifier) => {
|
|
55
|
+
if (specifier.startsWith('node:'))
|
|
56
|
+
return specifier;
|
|
57
|
+
return specifier.replace(/^([?!|-]+)?([^!?:]+).*/, '$2');
|
|
58
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.40.
|
|
1
|
+
export declare const version = "2.40.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.40.
|
|
1
|
+
export const version = '2.40.1';
|
package/package.json
CHANGED