knip 5.76.2 → 5.77.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/ConfigurationChief.d.ts +6 -0
- package/dist/DependencyDeputy.d.ts +2 -1
- package/dist/DependencyDeputy.js +17 -9
- package/dist/WorkspaceWorker.d.ts +3 -1
- package/dist/WorkspaceWorker.js +5 -2
- package/dist/binaries/package-manager/bunx.js +7 -4
- package/dist/cli.js +1 -1
- package/dist/compilers/index.d.ts +10 -0
- package/dist/graph/analyze.js +5 -2
- package/dist/graph/build.js +28 -19
- package/dist/plugins/bun/index.js +10 -13
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/node/index.js +14 -16
- package/dist/plugins/vitepress/index.d.ts +3 -0
- package/dist/plugins/vitepress/index.js +12 -0
- package/dist/schema/configuration.d.ts +10 -0
- package/dist/schema/plugins.d.ts +5 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/config.d.ts +2 -0
- package/dist/typescript/get-imports-and-exports.d.ts +1 -1
- package/dist/typescript/get-imports-and-exports.js +7 -6
- package/dist/util/create-input-handler.d.ts +1 -1
- package/dist/util/create-input-handler.js +5 -3
- package/dist/util/create-options.d.ts +12 -0
- package/dist/util/create-options.js +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +22 -24
- package/schema.json +4 -0
|
@@ -623,6 +623,11 @@ export declare class ConfigurationChief {
|
|
|
623
623
|
entry?: string | string[] | undefined;
|
|
624
624
|
project?: string | string[] | undefined;
|
|
625
625
|
} | undefined;
|
|
626
|
+
vitepress?: string | boolean | string[] | {
|
|
627
|
+
config?: string | string[] | undefined;
|
|
628
|
+
entry?: string | string[] | undefined;
|
|
629
|
+
project?: string | string[] | undefined;
|
|
630
|
+
} | undefined;
|
|
626
631
|
vitest?: string | boolean | string[] | {
|
|
627
632
|
config?: string | string[] | undefined;
|
|
628
633
|
entry?: string | string[] | undefined;
|
|
@@ -800,6 +805,7 @@ export declare class ConfigurationChief {
|
|
|
800
805
|
"vercel-og"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
801
806
|
vike?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
802
807
|
vite?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
808
|
+
vitepress?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
803
809
|
vitest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
804
810
|
vue?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
805
811
|
"webdriver-io"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -6,13 +6,14 @@ import type { MainOptions } from './util/create-options.js';
|
|
|
6
6
|
export declare class DependencyDeputy {
|
|
7
7
|
isProduction: boolean;
|
|
8
8
|
isStrict: boolean;
|
|
9
|
+
isReportDependencies: boolean;
|
|
9
10
|
_manifests: WorkspaceManifests;
|
|
10
11
|
referencedDependencies: Map<string, Set<string>>;
|
|
11
12
|
referencedBinaries: Map<string, Set<string>>;
|
|
12
13
|
hostDependencies: Map<string, HostDependencies>;
|
|
13
14
|
installedBinaries: Map<string, InstalledBinaries>;
|
|
14
15
|
hasTypesIncluded: Map<string, Set<string>>;
|
|
15
|
-
constructor({ isProduction, isStrict }: MainOptions);
|
|
16
|
+
constructor({ isProduction, isStrict, isReportDependencies }: MainOptions);
|
|
16
17
|
addWorkspace({ name, cwd, dir, manifestPath, manifestStr, manifest, ignoreDependencies: id, ignoreBinaries: ib, ignoreUnresolved: iu, }: {
|
|
17
18
|
name: string;
|
|
18
19
|
cwd: string;
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -8,15 +8,17 @@ const filterIsProduction = (id, isProduction) => typeof id === 'string' ? (isPro
|
|
|
8
8
|
export class DependencyDeputy {
|
|
9
9
|
isProduction;
|
|
10
10
|
isStrict;
|
|
11
|
+
isReportDependencies;
|
|
11
12
|
_manifests = new Map();
|
|
12
13
|
referencedDependencies;
|
|
13
14
|
referencedBinaries;
|
|
14
15
|
hostDependencies;
|
|
15
16
|
installedBinaries;
|
|
16
17
|
hasTypesIncluded;
|
|
17
|
-
constructor({ isProduction, isStrict }) {
|
|
18
|
+
constructor({ isProduction, isStrict, isReportDependencies }) {
|
|
18
19
|
this.isProduction = isProduction;
|
|
19
20
|
this.isStrict = isStrict;
|
|
21
|
+
this.isReportDependencies = isReportDependencies;
|
|
20
22
|
this.referencedDependencies = new Map();
|
|
21
23
|
this.referencedBinaries = new Map();
|
|
22
24
|
this.hostDependencies = new Map();
|
|
@@ -39,14 +41,16 @@ export class DependencyDeputy {
|
|
|
39
41
|
...(this.isStrict ? peerDependencies : []),
|
|
40
42
|
...(this.isProduction ? [] : devDependencies),
|
|
41
43
|
];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
if (this.isReportDependencies) {
|
|
45
|
+
const { hostDependencies, installedBinaries, hasTypesIncluded } = getDependencyMetaData({
|
|
46
|
+
packageNames,
|
|
47
|
+
dir,
|
|
48
|
+
cwd,
|
|
49
|
+
});
|
|
50
|
+
this.setHostDependencies(name, hostDependencies);
|
|
51
|
+
this.setInstalledBinaries(name, installedBinaries);
|
|
52
|
+
this.setHasTypesIncluded(name, hasTypesIncluded);
|
|
53
|
+
}
|
|
50
54
|
const ignoreDependencies = id.flatMap(id => filterIsProduction(id, this.isProduction)).map(toRegexOrString);
|
|
51
55
|
const ignoreBinaries = ib.flatMap(ib => filterIsProduction(ib, this.isProduction)).map(toRegexOrString);
|
|
52
56
|
const ignoreUnresolved = iu.map(toRegexOrString);
|
|
@@ -124,6 +128,8 @@ export class DependencyDeputy {
|
|
|
124
128
|
return manifest.optionalPeerDependencies;
|
|
125
129
|
}
|
|
126
130
|
maybeAddReferencedExternalDependency(workspace, packageName) {
|
|
131
|
+
if (!this.isReportDependencies)
|
|
132
|
+
return true;
|
|
127
133
|
if (isBuiltin(packageName))
|
|
128
134
|
return true;
|
|
129
135
|
if (IGNORED_RUNTIME_DEPENDENCIES.has(packageName))
|
|
@@ -145,6 +151,8 @@ export class DependencyDeputy {
|
|
|
145
151
|
return false;
|
|
146
152
|
}
|
|
147
153
|
maybeAddReferencedBinary(workspace, binaryName) {
|
|
154
|
+
if (!this.isReportDependencies)
|
|
155
|
+
return new Set();
|
|
148
156
|
if (IGNORED_GLOBAL_BINARIES.has(binaryName))
|
|
149
157
|
return new Set();
|
|
150
158
|
this.addReferencedBinary(workspace.name, binaryName);
|
|
@@ -13,6 +13,7 @@ type WorkspaceManagerOptions = {
|
|
|
13
13
|
config: WorkspaceConfiguration;
|
|
14
14
|
manifest: PackageJson;
|
|
15
15
|
dependencies: DependencySet;
|
|
16
|
+
rootManifest: PackageJson | undefined;
|
|
16
17
|
handleInput: HandleInput;
|
|
17
18
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
18
19
|
getSourceFile: GetSourceFile;
|
|
@@ -32,6 +33,7 @@ export declare class WorkspaceWorker {
|
|
|
32
33
|
dir: string;
|
|
33
34
|
config: WorkspaceConfiguration;
|
|
34
35
|
manifest: PackageJson;
|
|
36
|
+
rootManifest: PackageJson | undefined;
|
|
35
37
|
dependencies: DependencySet;
|
|
36
38
|
handleInput: HandleInput;
|
|
37
39
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
@@ -44,7 +46,7 @@ export declare class WorkspaceWorker {
|
|
|
44
46
|
enabledPluginsInAncestors: string[];
|
|
45
47
|
cache: CacheConsultant<CacheItem>;
|
|
46
48
|
configFilesMap: Map<string, Map<PluginName, Set<string>>>;
|
|
47
|
-
constructor({ name, dir, config, manifest, dependencies, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, getSourceFile, configFilesMap, options, }: WorkspaceManagerOptions);
|
|
49
|
+
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, getSourceFile, configFilesMap, options, }: WorkspaceManagerOptions);
|
|
48
50
|
init(): Promise<void>;
|
|
49
51
|
private determineEnabledPlugins;
|
|
50
52
|
private getConfigForPlugin;
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -21,6 +21,7 @@ export class WorkspaceWorker {
|
|
|
21
21
|
dir;
|
|
22
22
|
config;
|
|
23
23
|
manifest;
|
|
24
|
+
rootManifest;
|
|
24
25
|
dependencies;
|
|
25
26
|
handleInput;
|
|
26
27
|
findWorkspaceByFilePath;
|
|
@@ -33,11 +34,12 @@ export class WorkspaceWorker {
|
|
|
33
34
|
enabledPluginsInAncestors;
|
|
34
35
|
cache;
|
|
35
36
|
configFilesMap;
|
|
36
|
-
constructor({ name, dir, config, manifest, dependencies, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, getSourceFile, configFilesMap, options, }) {
|
|
37
|
+
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, getSourceFile, configFilesMap, options, }) {
|
|
37
38
|
this.name = name;
|
|
38
39
|
this.dir = dir;
|
|
39
40
|
this.config = config;
|
|
40
41
|
this.manifest = manifest;
|
|
42
|
+
this.rootManifest = rootManifest;
|
|
41
43
|
this.dependencies = dependencies;
|
|
42
44
|
this.negatedWorkspacePatterns = negatedWorkspacePatterns;
|
|
43
45
|
this.ignoredWorkspacePatterns = ignoredWorkspacePatterns;
|
|
@@ -158,7 +160,8 @@ export class WorkspaceWorker {
|
|
|
158
160
|
const isProduction = this.options.isProduction;
|
|
159
161
|
const knownBinsOnly = false;
|
|
160
162
|
const manifestScriptNames = new Set(Object.keys(manifest.scripts ?? {}));
|
|
161
|
-
const
|
|
163
|
+
const rootManifest = this.rootManifest;
|
|
164
|
+
const baseOptions = { manifestScriptNames, rootManifest, cwd, rootCwd, containingFilePath, knownBinsOnly };
|
|
162
165
|
const baseScriptOptions = { ...baseOptions, manifest, isProduction, enabledPlugins: this.enabledPlugins };
|
|
163
166
|
const [productionScripts, developmentScripts] = getFilteredScripts(manifest.scripts ?? {});
|
|
164
167
|
const inputsFromManifest = _getInputsFromScripts(Object.values(developmentScripts), baseOptions);
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import parseArgs from 'minimist';
|
|
2
|
-
import { toDependency } from '../../util/input.js';
|
|
2
|
+
import { toBinary, toDependency } from '../../util/input.js';
|
|
3
3
|
import { stripVersionFromSpecifier } from '../../util/modules.js';
|
|
4
|
+
import { isInternal } from '../../util/path.js';
|
|
4
5
|
import { argsFrom } from '../util.js';
|
|
5
6
|
export const resolveX = (args, options) => {
|
|
6
7
|
const { fromArgs } = options;
|
|
7
|
-
const parsed = parseArgs(args);
|
|
8
|
+
const parsed = parseArgs(args, { boolean: ['bun'] });
|
|
8
9
|
const packageSpecifier = parsed._[0];
|
|
9
10
|
const specifier = packageSpecifier ? stripVersionFromSpecifier(packageSpecifier) : '';
|
|
10
11
|
const packages = parsed.package && !parsed.yes ? [parsed.package].flat().map(stripVersionFromSpecifier) : [];
|
|
11
12
|
const command = parsed['shell-mode'] ? fromArgs([parsed['shell-mode']]) : [];
|
|
12
13
|
const restArgs = argsFrom(args, packageSpecifier);
|
|
13
|
-
const
|
|
14
|
-
|
|
14
|
+
const isBinary = specifier && !packageSpecifier.includes('@') && !isInternal(specifier);
|
|
15
|
+
const dependency = isBinary ? toBinary(specifier, { optional: true }) : toDependency(specifier, { optional: true });
|
|
16
|
+
const specifiers = specifier ? [dependency] : [];
|
|
17
|
+
return [...specifiers, ...packages.map(id => toDependency(id)), ...command, ...fromArgs(restArgs).slice(1)];
|
|
15
18
|
};
|
|
16
19
|
export const resolve = (_binary, args, options) => {
|
|
17
20
|
return resolveX(args, options);
|
package/dist/cli.js
CHANGED
|
@@ -21,7 +21,6 @@ catch (error) {
|
|
|
21
21
|
}
|
|
22
22
|
const run = async () => {
|
|
23
23
|
try {
|
|
24
|
-
const options = await createOptions({ args });
|
|
25
24
|
if (args.help) {
|
|
26
25
|
console.log(helpText);
|
|
27
26
|
process.exit(0);
|
|
@@ -30,6 +29,7 @@ const run = async () => {
|
|
|
30
29
|
console.log(version);
|
|
31
30
|
process.exit(0);
|
|
32
31
|
}
|
|
32
|
+
const options = await createOptions({ args });
|
|
33
33
|
const { issues, counters, tagHints, configurationHints, includedWorkspaceDirs, enabledPlugins } = await main(options);
|
|
34
34
|
if (options.isWatch || options.isTrace)
|
|
35
35
|
return;
|
|
@@ -574,6 +574,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
574
574
|
entry?: string | string[] | undefined;
|
|
575
575
|
project?: string | string[] | undefined;
|
|
576
576
|
} | undefined;
|
|
577
|
+
vitepress?: string | boolean | string[] | {
|
|
578
|
+
config?: string | string[] | undefined;
|
|
579
|
+
entry?: string | string[] | undefined;
|
|
580
|
+
project?: string | string[] | undefined;
|
|
581
|
+
} | undefined;
|
|
577
582
|
vitest?: string | boolean | string[] | {
|
|
578
583
|
config?: string | string[] | undefined;
|
|
579
584
|
entry?: string | string[] | undefined;
|
|
@@ -1190,6 +1195,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
1190
1195
|
entry?: string | string[] | undefined;
|
|
1191
1196
|
project?: string | string[] | undefined;
|
|
1192
1197
|
} | undefined;
|
|
1198
|
+
vitepress?: string | boolean | string[] | {
|
|
1199
|
+
config?: string | string[] | undefined;
|
|
1200
|
+
entry?: string | string[] | undefined;
|
|
1201
|
+
project?: string | string[] | undefined;
|
|
1202
|
+
} | undefined;
|
|
1193
1203
|
vitest?: string | boolean | string[] | {
|
|
1194
1204
|
config?: string | string[] | undefined;
|
|
1195
1205
|
entry?: string | string[] | undefined;
|
package/dist/graph/analyze.js
CHANGED
|
@@ -199,8 +199,11 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
const unusedFiles =
|
|
203
|
-
|
|
202
|
+
const unusedFiles = options.isReportFiles
|
|
203
|
+
? [...unreferencedFiles].filter(filePath => !analyzedFiles.has(filePath))
|
|
204
|
+
: [];
|
|
205
|
+
if (options.isReportFiles)
|
|
206
|
+
collector.addFilesIssues(unusedFiles);
|
|
204
207
|
collector.addFileCounts({ processed: analyzedFiles.size, unused: unusedFiles.length });
|
|
205
208
|
if (options.isReportDependencies) {
|
|
206
209
|
const { dependencyIssues, devDependencyIssues, optionalPeerDependencyIssues } = deputy.settleDependencyIssues();
|
package/dist/graph/build.js
CHANGED
|
@@ -20,8 +20,9 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
20
20
|
const toModuleSourceFilePath = getModuleSourcePathHandler(chief);
|
|
21
21
|
const toSourceFilePaths = getToSourcePathsHandler(chief);
|
|
22
22
|
const addIssue = (issue) => collector.addIssue(issue) && options.isWatch && collector.retainIssue(issue);
|
|
23
|
-
const externalRefsFromInputs = new Map();
|
|
23
|
+
const externalRefsFromInputs = options.isSession ? new Map() : undefined;
|
|
24
24
|
const handleInput = createInputHandler(deputy, chief, isGitIgnored, addIssue, externalRefsFromInputs, options);
|
|
25
|
+
const rootManifest = chief.getManifestForWorkspace('.');
|
|
25
26
|
for (const workspace of workspaces) {
|
|
26
27
|
const { name, dir, manifestPath, manifestStr } = workspace;
|
|
27
28
|
const manifest = chief.getManifestForWorkspace(name);
|
|
@@ -62,6 +63,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
62
63
|
config,
|
|
63
64
|
manifest,
|
|
64
65
|
dependencies,
|
|
66
|
+
rootManifest,
|
|
65
67
|
handleInput: (input) => handleInput(input, workspace),
|
|
66
68
|
findWorkspaceByFilePath: chief.findWorkspaceByFilePath.bind(chief),
|
|
67
69
|
negatedWorkspacePatterns: chief.getNegatedWorkspacePatterns(name),
|
|
@@ -174,18 +176,15 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
174
176
|
negatedEntryPatterns.push(negate(pattern));
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
principal.addEntryPaths(entryPaths);
|
|
188
|
-
}
|
|
179
|
+
const userEntryPatterns = options.isProduction
|
|
180
|
+
? worker.getProductionEntryFilePatterns(negatedEntryPatterns)
|
|
181
|
+
: worker.getEntryFilePatterns();
|
|
182
|
+
const userEntryPaths = await _glob({
|
|
183
|
+
...sharedGlobOptions,
|
|
184
|
+
patterns: userEntryPatterns,
|
|
185
|
+
gitignore: false,
|
|
186
|
+
label: 'entry paths',
|
|
187
|
+
});
|
|
189
188
|
for (const group of groups) {
|
|
190
189
|
{
|
|
191
190
|
const patterns = worker.getPluginEntryFilePatterns([
|
|
@@ -207,6 +206,12 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
207
206
|
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
|
|
208
207
|
}
|
|
209
208
|
}
|
|
209
|
+
if (!options.isProduction) {
|
|
210
|
+
const hints = worker.getConfigurationHints('entry', userEntryPatterns, userEntryPaths, principal.entryPaths);
|
|
211
|
+
for (const hint of hints)
|
|
212
|
+
collector.addConfigurationHint(hint);
|
|
213
|
+
}
|
|
214
|
+
principal.addEntryPaths(userEntryPaths);
|
|
210
215
|
if (options.isUseTscFiles) {
|
|
211
216
|
const isIgnoredWorkspace = chief.createIgnoredWorkspaceMatcher(name, dir);
|
|
212
217
|
debugLogArray(name, 'Using tsconfig files as project files', tscSourcePaths);
|
|
@@ -255,6 +260,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
255
260
|
isFixExports: options.isFixUnusedExports,
|
|
256
261
|
isFixTypes: options.isFixUnusedTypes,
|
|
257
262
|
isReportClassMembers: options.isReportClassMembers,
|
|
263
|
+
isReportExports: options.isReportExports,
|
|
258
264
|
skipTypeOnly: options.isStrict,
|
|
259
265
|
tags: options.tags,
|
|
260
266
|
};
|
|
@@ -316,6 +322,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
316
322
|
containingFilePath: filePath,
|
|
317
323
|
dependencies,
|
|
318
324
|
manifestScriptNames,
|
|
325
|
+
rootManifest,
|
|
319
326
|
};
|
|
320
327
|
const inputs = _getInputsFromScripts(file.scripts, opts);
|
|
321
328
|
for (const input of inputs) {
|
|
@@ -327,7 +334,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
327
334
|
}
|
|
328
335
|
}
|
|
329
336
|
file.imports.unresolved = unresolvedImports;
|
|
330
|
-
const pluginRefs = externalRefsFromInputs
|
|
337
|
+
const pluginRefs = externalRefsFromInputs?.get(filePath);
|
|
331
338
|
if (pluginRefs)
|
|
332
339
|
for (const ref of pluginRefs)
|
|
333
340
|
file.imports.externalRefs.add(ref);
|
|
@@ -385,11 +392,13 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
385
392
|
}
|
|
386
393
|
principals.length = 0;
|
|
387
394
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
graph.
|
|
391
|
-
|
|
392
|
-
|
|
395
|
+
if (externalRefsFromInputs) {
|
|
396
|
+
for (const [filePath, refs] of externalRefsFromInputs) {
|
|
397
|
+
if (!graph.has(filePath))
|
|
398
|
+
graph.set(filePath, createFileNode());
|
|
399
|
+
for (const ref of refs)
|
|
400
|
+
graph.get(filePath).imports.externalRefs.add(ref);
|
|
401
|
+
}
|
|
393
402
|
}
|
|
394
403
|
return {
|
|
395
404
|
graph,
|
|
@@ -2,17 +2,16 @@ import parseArgs from 'minimist';
|
|
|
2
2
|
import { toEntry } from '../../util/input.js';
|
|
3
3
|
const title = 'Bun';
|
|
4
4
|
const enablers = ['bun'];
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const scripts =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const parsed = parseArgs(scripts[script].split(' '));
|
|
5
|
+
const hasBunTest = (scripts) => scripts && Object.values(scripts).some(script => /(?<=^|\s)bun test/.test(script));
|
|
6
|
+
const isEnabled = ({ manifest }) => !!hasBunTest(manifest.scripts);
|
|
7
|
+
const patterns = ['**/*.{test,spec}.{js,jsx,ts,tsx}', '**/*_{test,spec}.{js,jsx,ts,tsx}'];
|
|
8
|
+
const resolve = (options) => {
|
|
9
|
+
const scripts = { ...options.rootManifest?.scripts, ...options.manifest.scripts };
|
|
10
|
+
for (const script of Object.values(scripts)) {
|
|
11
|
+
if (/(?<=^|\s)bun test/.test(script)) {
|
|
12
|
+
const parsed = parseArgs(script.split(' '));
|
|
14
13
|
if (parsed._.filter(id => id !== 'bun' && id !== 'test').length === 0) {
|
|
15
|
-
return
|
|
14
|
+
return patterns.map(toEntry);
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
}
|
|
@@ -22,8 +21,6 @@ const plugin = {
|
|
|
22
21
|
title,
|
|
23
22
|
enablers,
|
|
24
23
|
isEnabled,
|
|
25
|
-
|
|
26
|
-
packageJsonPath,
|
|
27
|
-
resolveConfig,
|
|
24
|
+
resolve,
|
|
28
25
|
};
|
|
29
26
|
export default plugin;
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -113,6 +113,7 @@ export declare const Plugins: {
|
|
|
113
113
|
'vercel-og': import("../types/config.js").Plugin;
|
|
114
114
|
vike: import("../types/config.js").Plugin;
|
|
115
115
|
vite: import("../types/config.js").Plugin;
|
|
116
|
+
vitepress: import("../types/config.js").Plugin;
|
|
116
117
|
vitest: import("../types/config.js").Plugin;
|
|
117
118
|
vue: import("../types/config.js").Plugin;
|
|
118
119
|
'webdriver-io': import("../types/config.js").Plugin;
|
package/dist/plugins/index.js
CHANGED
|
@@ -112,6 +112,7 @@ import { default as unocss } from './unocss/index.js';
|
|
|
112
112
|
import { default as vercelOg } from './vercel-og/index.js';
|
|
113
113
|
import { default as vike } from './vike/index.js';
|
|
114
114
|
import { default as vite } from './vite/index.js';
|
|
115
|
+
import { default as vitepress } from './vitepress/index.js';
|
|
115
116
|
import { default as vitest } from './vitest/index.js';
|
|
116
117
|
import { default as vue } from './vue/index.js';
|
|
117
118
|
import { default as webdriverIo } from './webdriver-io/index.js';
|
|
@@ -236,6 +237,7 @@ export const Plugins = {
|
|
|
236
237
|
'vercel-og': vercelOg,
|
|
237
238
|
vike,
|
|
238
239
|
vite,
|
|
240
|
+
vitepress,
|
|
239
241
|
vitest,
|
|
240
242
|
vue,
|
|
241
243
|
'webdriver-io': webdriverIo,
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { toEntry, toProductionEntry } from '../../util/input.js';
|
|
2
2
|
const title = 'Node.js';
|
|
3
3
|
const isEnabled = () => true;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
entries.push(...patterns.map(id => toEntry(id)));
|
|
4
|
+
const patterns = [
|
|
5
|
+
'**/*{.,-,_}test.{cjs,mjs,js,cts,mts,ts}',
|
|
6
|
+
'**/test-*.{cjs,mjs,js,cts,mts,ts}',
|
|
7
|
+
'**/test.{cjs,mjs,js,cts,mts,ts}',
|
|
8
|
+
'**/test/**/*.{cjs,mjs,js,cts,mts,ts}',
|
|
9
|
+
];
|
|
10
|
+
const hasNodeTest = (scripts) => scripts && Object.values(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(script));
|
|
11
|
+
const entry = ['server.js'];
|
|
12
|
+
const resolve = (options) => {
|
|
13
|
+
const entries = entry.map(id => toProductionEntry(id));
|
|
14
|
+
if (hasNodeTest(options.manifest.scripts) || hasNodeTest(options.rootManifest?.scripts)) {
|
|
15
|
+
entries.push(...patterns.map(toEntry));
|
|
17
16
|
}
|
|
18
17
|
return entries;
|
|
19
18
|
};
|
|
@@ -39,9 +38,8 @@ const args = {
|
|
|
39
38
|
const plugin = {
|
|
40
39
|
title,
|
|
41
40
|
isEnabled,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
resolveConfig,
|
|
41
|
+
entry,
|
|
42
|
+
resolve,
|
|
45
43
|
args,
|
|
46
44
|
};
|
|
47
45
|
export default plugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
const title = 'vitepress';
|
|
3
|
+
const enablers = ['vitepress'];
|
|
4
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
+
const entry = ['.vitepress/config.{js,ts,mjs,mts}', '.vitepress/theme/index.{js,ts,mjs,mts}'];
|
|
6
|
+
const plugin = {
|
|
7
|
+
title,
|
|
8
|
+
enablers,
|
|
9
|
+
isEnabled,
|
|
10
|
+
entry,
|
|
11
|
+
};
|
|
12
|
+
export default plugin;
|
|
@@ -572,6 +572,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
572
572
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
573
573
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
574
574
|
}, z.core.$strip>]>>;
|
|
575
|
+
vitepress: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
576
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
577
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
578
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
579
|
+
}, z.core.$strip>]>>;
|
|
575
580
|
vitest: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
576
581
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
577
582
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -1188,6 +1193,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
1188
1193
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1189
1194
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1190
1195
|
}, z.core.$strip>]>>;
|
|
1196
|
+
vitepress: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
1197
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1198
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1199
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1200
|
+
}, z.core.$strip>]>>;
|
|
1191
1201
|
vitest: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
1192
1202
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1193
1203
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
package/dist/schema/plugins.d.ts
CHANGED
|
@@ -576,6 +576,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
|
|
|
576
576
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
577
577
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
578
578
|
}, z.core.$strip>]>;
|
|
579
|
+
vitepress: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
580
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
581
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
582
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
583
|
+
}, z.core.$strip>]>;
|
|
579
584
|
vitest: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
580
585
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
581
586
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
package/dist/schema/plugins.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
|
|
2
|
-
export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "svgr", "swc", "syncpack", "tailwind", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
|
|
1
|
+
export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
|
|
2
|
+
export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "svgr", "swc", "syncpack", "tailwind", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
|
package/dist/types/config.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export type GetImportsAndExportsOptions = {
|
|
|
33
33
|
isFixExports: boolean;
|
|
34
34
|
isFixTypes: boolean;
|
|
35
35
|
isReportClassMembers: boolean;
|
|
36
|
+
isReportExports: boolean;
|
|
36
37
|
tags: Tags;
|
|
37
38
|
};
|
|
38
39
|
export interface Configuration {
|
|
@@ -72,6 +73,7 @@ interface BaseOptions {
|
|
|
72
73
|
rootCwd: string;
|
|
73
74
|
cwd: string;
|
|
74
75
|
manifestScriptNames: Set<string>;
|
|
76
|
+
rootManifest: PackageJson | undefined;
|
|
75
77
|
}
|
|
76
78
|
type IsPluginEnabledOptions = {
|
|
77
79
|
cwd: string;
|
|
@@ -2,4 +2,4 @@ import ts from 'typescript';
|
|
|
2
2
|
import type { GetImportsAndExportsOptions, IgnoreExportsUsedInFile } from '../types/config.js';
|
|
3
3
|
import type { FileNode } from '../types/module-graph.js';
|
|
4
4
|
import type { BoundSourceFile } from './SourceFile.js';
|
|
5
|
-
export declare const _getImportsAndExports: (sourceFile: BoundSourceFile, resolveModule: (specifier: string) => ts.ResolvedModuleFull | undefined, typeChecker: ts.TypeChecker, options: GetImportsAndExportsOptions, ignoreExportsUsedInFile: IgnoreExportsUsedInFile,
|
|
5
|
+
export declare const _getImportsAndExports: (sourceFile: BoundSourceFile, resolveModule: (specifier: string) => ts.ResolvedModuleFull | undefined, typeChecker: ts.TypeChecker, options: GetImportsAndExportsOptions, ignoreExportsUsedInFile: IgnoreExportsUsedInFile, skipExportsForFile: boolean) => FileNode;
|
|
@@ -34,7 +34,8 @@ const createMember = (node, member, pos) => {
|
|
|
34
34
|
flags: member.flags,
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, ignoreExportsUsedInFile,
|
|
37
|
+
const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, ignoreExportsUsedInFile, skipExportsForFile) => {
|
|
38
|
+
const skipExports = skipExportsForFile || !options.isReportExports;
|
|
38
39
|
const internal = new Map();
|
|
39
40
|
const external = new Set();
|
|
40
41
|
const unresolved = new Set();
|
|
@@ -197,8 +198,6 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
|
|
|
197
198
|
}
|
|
198
199
|
};
|
|
199
200
|
const addExport = ({ node, symbol, identifier, type, pos, members, fix }) => {
|
|
200
|
-
if (skipExports)
|
|
201
|
-
return;
|
|
202
201
|
let isReExport = Boolean(node.parent?.parent && ts.isExportDeclaration(node.parent.parent) && node.parent.parent.moduleSpecifier);
|
|
203
202
|
if (symbol) {
|
|
204
203
|
const importedSymbolFilePath = importedInternalSymbols.get(symbol);
|
|
@@ -266,9 +265,11 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
|
|
|
266
265
|
const result = visitor(node, options);
|
|
267
266
|
result && (Array.isArray(result) ? result.forEach(addImportWithNode) : addImportWithNode(result));
|
|
268
267
|
}
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
|
|
268
|
+
if (!skipExports) {
|
|
269
|
+
for (const visitor of visitors.export) {
|
|
270
|
+
const result = visitor(node, options);
|
|
271
|
+
result && (Array.isArray(result) ? result.forEach(addExport) : addExport(result));
|
|
272
|
+
}
|
|
272
273
|
}
|
|
273
274
|
if (ts.isImportEqualsDeclaration(node) &&
|
|
274
275
|
ts.isQualifiedName(node.moduleReference) &&
|
|
@@ -5,4 +5,4 @@ import type { ExternalRef } from '../types/module-graph.js';
|
|
|
5
5
|
import type { MainOptions } from './create-options.js';
|
|
6
6
|
import { type Input } from './input.js';
|
|
7
7
|
export type ExternalRefsFromInputs = Map<string, Set<ExternalRef>>;
|
|
8
|
-
export declare const createInputHandler: (deputy: DependencyDeputy, chief: ConfigurationChief, isGitIgnored: (filePath: string) => boolean, addIssue: (issue: Issue) => void, externalRefs: ExternalRefsFromInputs, options: MainOptions) => (input: Input, workspace: Workspace) => string | undefined;
|
|
8
|
+
export declare const createInputHandler: (deputy: DependencyDeputy, chief: ConfigurationChief, isGitIgnored: (filePath: string) => boolean, addIssue: (issue: Issue) => void, externalRefs: ExternalRefsFromInputs | undefined, options: MainOptions) => (input: Input, workspace: Workspace) => string | undefined;
|
|
@@ -21,8 +21,10 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
|
|
|
21
21
|
const inputWorkspace = getWorkspaceFor(input, chief, workspace);
|
|
22
22
|
const dependencies = deputy.maybeAddReferencedBinary(inputWorkspace, binaryName);
|
|
23
23
|
if (dependencies) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
if (externalRefs) {
|
|
25
|
+
for (const dependency of dependencies) {
|
|
26
|
+
addExternalRef(externalRefs, containingFilePath, { specifier: dependency, identifier: binaryName });
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
@@ -44,7 +46,7 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
|
|
|
44
46
|
const inputWorkspace = getWorkspaceFor(input, chief, workspace);
|
|
45
47
|
if (inputWorkspace) {
|
|
46
48
|
const isHandled = deputy.maybeAddReferencedExternalDependency(inputWorkspace, packageName);
|
|
47
|
-
if (!isWorkspace) {
|
|
49
|
+
if (externalRefs && !isWorkspace) {
|
|
48
50
|
addExternalRef(externalRefs, containingFilePath, { specifier: packageName, identifier: undefined });
|
|
49
51
|
}
|
|
50
52
|
if (isWorkspace || isDependency(input)) {
|
|
@@ -31,6 +31,8 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
31
31
|
isProduction: boolean;
|
|
32
32
|
isReportClassMembers: boolean;
|
|
33
33
|
isReportDependencies: boolean;
|
|
34
|
+
isReportExports: boolean;
|
|
35
|
+
isReportFiles: boolean;
|
|
34
36
|
isReportTypes: boolean;
|
|
35
37
|
isReportValues: boolean;
|
|
36
38
|
isSession: boolean;
|
|
@@ -613,6 +615,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
613
615
|
entry?: string | string[] | undefined;
|
|
614
616
|
project?: string | string[] | undefined;
|
|
615
617
|
} | undefined;
|
|
618
|
+
vitepress?: string | boolean | string[] | {
|
|
619
|
+
config?: string | string[] | undefined;
|
|
620
|
+
entry?: string | string[] | undefined;
|
|
621
|
+
project?: string | string[] | undefined;
|
|
622
|
+
} | undefined;
|
|
616
623
|
vitest?: string | boolean | string[] | {
|
|
617
624
|
config?: string | string[] | undefined;
|
|
618
625
|
entry?: string | string[] | undefined;
|
|
@@ -1229,6 +1236,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1229
1236
|
entry?: string | string[] | undefined;
|
|
1230
1237
|
project?: string | string[] | undefined;
|
|
1231
1238
|
} | undefined;
|
|
1239
|
+
vitepress?: string | boolean | string[] | {
|
|
1240
|
+
config?: string | string[] | undefined;
|
|
1241
|
+
entry?: string | string[] | undefined;
|
|
1242
|
+
project?: string | string[] | undefined;
|
|
1243
|
+
} | undefined;
|
|
1232
1244
|
vitest?: string | boolean | string[] | {
|
|
1233
1245
|
config?: string | string[] | undefined;
|
|
1234
1246
|
entry?: string | string[] | undefined;
|
|
@@ -101,6 +101,14 @@ export const createOptions = async (options) => {
|
|
|
101
101
|
includedIssueTypes.unlisted ||
|
|
102
102
|
includedIssueTypes.unresolved ||
|
|
103
103
|
includedIssueTypes.binaries,
|
|
104
|
+
isReportExports: includedIssueTypes.exports ||
|
|
105
|
+
includedIssueTypes.types ||
|
|
106
|
+
includedIssueTypes.nsExports ||
|
|
107
|
+
includedIssueTypes.nsTypes ||
|
|
108
|
+
includedIssueTypes.enumMembers ||
|
|
109
|
+
includedIssueTypes.duplicates ||
|
|
110
|
+
isReportClassMembers,
|
|
111
|
+
isReportFiles: includedIssueTypes.files,
|
|
104
112
|
isReportTypes: includedIssueTypes.types || includedIssueTypes.nsTypes || includedIssueTypes.enumMembers,
|
|
105
113
|
isReportValues: includedIssueTypes.exports || includedIssueTypes.nsExports || isReportClassMembers,
|
|
106
114
|
isSession: options.isSession ?? false,
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.77.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.77.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.77.0",
|
|
4
4
|
"description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -40,25 +40,6 @@
|
|
|
40
40
|
},
|
|
41
41
|
"type": "module",
|
|
42
42
|
"types": "./dist/types.d.ts",
|
|
43
|
-
"scripts": {
|
|
44
|
-
"knip": "node ./dist/cli.js --directory ../..",
|
|
45
|
-
"knip:production": "node ./dist/cli.js --directory ../.. --production --strict",
|
|
46
|
-
"lint": "biome lint",
|
|
47
|
-
"format": "biome format --write",
|
|
48
|
-
"test": "node scripts/run-test.ts",
|
|
49
|
-
"test:node": "tsx --test test/*.test.ts test/**/*.test.ts",
|
|
50
|
-
"test:bun": "bun test test/*.test.ts test/**/*.test.ts",
|
|
51
|
-
"test:smoke": "glob-bin -c \"tsx --test\" \"test/*.test.ts\" && glob-bin -c \"tsx --test\" \"test/{plugins,util}/*.test.ts\"",
|
|
52
|
-
"test:bun:smoke": "bun test test/*.test.ts test/{plugins,util}/*.test.ts",
|
|
53
|
-
"watch": "npm link && tsc --watch",
|
|
54
|
-
"prebuild": "pnpm run generate-plugin-defs && node rmdir.js dist",
|
|
55
|
-
"build": "tsc",
|
|
56
|
-
"qa": "pnpm lint && pnpm build && pnpm knip && pnpm knip:production && pnpm run test",
|
|
57
|
-
"release": "release-it",
|
|
58
|
-
"create-plugin": "tsx ./scripts/create-new-plugin.ts",
|
|
59
|
-
"postcreate-plugin": "pnpm run build && biome format --write schema.json schema-jsonc.json src/schema/plugins.ts",
|
|
60
|
-
"generate-plugin-defs": "node ./scripts/generate-plugin-defs.js && biome check --write src/plugins/index.ts src/types/PluginNames.ts src/schema/plugins.ts"
|
|
61
|
-
},
|
|
62
43
|
"files": [
|
|
63
44
|
"dist",
|
|
64
45
|
"vendor",
|
|
@@ -85,7 +66,6 @@
|
|
|
85
66
|
},
|
|
86
67
|
"devDependencies": {
|
|
87
68
|
"@jest/types": "^29.6.3",
|
|
88
|
-
"@release-it/bumper": "^7.0.5",
|
|
89
69
|
"@types/bun": "^1.3.3",
|
|
90
70
|
"@types/js-yaml": "^4.0.9",
|
|
91
71
|
"@types/minimist": "^1.2.5",
|
|
@@ -94,7 +74,6 @@
|
|
|
94
74
|
"@wdio/types": "^9.20.0",
|
|
95
75
|
"codeclimate-types": "^0.3.1",
|
|
96
76
|
"glob-bin": "^1.0.0",
|
|
97
|
-
"release-it": "^19.1.0",
|
|
98
77
|
"tsx": "^4.20.3",
|
|
99
78
|
"typescript": "^5.5.2"
|
|
100
79
|
},
|
|
@@ -132,5 +111,24 @@
|
|
|
132
111
|
"unresolved",
|
|
133
112
|
"unused",
|
|
134
113
|
"workspace"
|
|
135
|
-
]
|
|
136
|
-
|
|
114
|
+
],
|
|
115
|
+
"scripts": {
|
|
116
|
+
"knip": "node ./dist/cli.js --directory ../..",
|
|
117
|
+
"knip:production": "node ./dist/cli.js --directory ../.. --production --strict",
|
|
118
|
+
"lint": "biome lint",
|
|
119
|
+
"format": "biome format --write",
|
|
120
|
+
"test": "node scripts/run-test.ts",
|
|
121
|
+
"test:node": "tsx --test test/*.test.ts test/**/*.test.ts",
|
|
122
|
+
"test:bun": "bun test test/*.test.ts test/**/*.test.ts",
|
|
123
|
+
"test:smoke": "glob-bin -c \"tsx --test\" \"test/*.test.ts\" && glob-bin -c \"tsx --test\" \"test/{plugins,util}/*.test.ts\"",
|
|
124
|
+
"test:bun:smoke": "bun test test/*.test.ts test/{plugins,util}/*.test.ts",
|
|
125
|
+
"watch": "npm link && tsc --watch",
|
|
126
|
+
"prebuild": "pnpm run generate-plugin-defs && node rmdir.js dist",
|
|
127
|
+
"build": "tsc",
|
|
128
|
+
"qa": "pnpm lint && pnpm build && pnpm knip && pnpm knip:production && pnpm run test",
|
|
129
|
+
"release": "release-it",
|
|
130
|
+
"create-plugin": "tsx ./scripts/create-new-plugin.ts",
|
|
131
|
+
"postcreate-plugin": "pnpm run build && biome format --write schema.json schema-jsonc.json src/schema/plugins.ts",
|
|
132
|
+
"generate-plugin-defs": "node ./scripts/generate-plugin-defs.js && biome check --write src/plugins/index.ts src/types/PluginNames.ts src/schema/plugins.ts"
|
|
133
|
+
}
|
|
134
|
+
}
|
package/schema.json
CHANGED
|
@@ -793,6 +793,10 @@
|
|
|
793
793
|
"title": "vite plugin configuration (https://knip.dev/reference/plugins/vite)",
|
|
794
794
|
"$ref": "#/definitions/plugin"
|
|
795
795
|
},
|
|
796
|
+
"vitepress": {
|
|
797
|
+
"title": "vitepress plugin configuration (https://knip.dev/reference/plugins/vitepress)",
|
|
798
|
+
"$ref": "#/definitions/plugin"
|
|
799
|
+
},
|
|
796
800
|
"vitest": {
|
|
797
801
|
"title": "vitest plugin configuration (https://knip.dev/reference/plugins/vitest)",
|
|
798
802
|
"$ref": "#/definitions/plugin"
|