knip 6.40.0 → 6.41.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 +12 -0
- package/dist/DependencyDeputy.d.ts +1 -0
- package/dist/DependencyDeputy.js +28 -2
- package/dist/IssueCollector.js +13 -15
- package/dist/IssueFixer.js +1 -1
- package/dist/WorkspaceWorker.js +14 -8
- package/dist/binaries/bash-parser.js +10 -4
- package/dist/binaries/command.d.ts +1 -1
- package/dist/binaries/command.js +14 -8
- package/dist/graph/build.js +18 -9
- package/dist/manifest/index.d.ts +1 -0
- package/dist/manifest/index.js +5 -0
- package/dist/plugins/expo/helpers.js +1 -1
- package/dist/plugins/expo/index.js +4 -24
- package/dist/plugins/expo-router/index.d.ts +3 -0
- package/dist/plugins/expo-router/index.js +32 -0
- package/dist/plugins/flue/index.d.ts +3 -0
- package/dist/plugins/flue/index.js +42 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/mise/scripts.js +32 -10
- package/dist/plugins/moonrepo/index.js +2 -1
- package/dist/plugins/nx/index.js +6 -2
- package/dist/plugins/react-native/index.js +1 -1
- package/dist/plugins/rsbuild/index.js +20 -6
- package/dist/plugins/rsbuild/types.d.ts +6 -0
- package/dist/plugins/rstest/types.d.ts +1 -5
- package/dist/plugins/sveltejs-package/helpers.js +7 -44
- package/dist/run.js +2 -0
- package/dist/schema/configuration.d.ts +30 -0
- package/dist/schema/plugins.d.ts +10 -0
- package/dist/schema/plugins.js +2 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +2 -0
- package/dist/types/workspace.d.ts +1 -0
- package/dist/util/create-options.d.ts +20 -0
- package/dist/util/glob-cache.d.ts +2 -2
- package/dist/util/glob-core.js +70 -47
- package/dist/util/glob.js +15 -10
- package/dist/util/load-tsconfig.d.ts +1 -1
- package/dist/util/load-tsconfig.js +21 -11
- package/dist/util/module-graph.js +9 -4
- package/dist/util/scripts.d.ts +3 -2
- package/dist/util/scripts.js +9 -3
- package/dist/util/to-source-path.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -10
- package/schema.json +8 -0
package/dist/util/glob-core.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import {
|
|
4
|
-
import { fdir } from 'fdir';
|
|
5
|
-
import { glob as tinyGlob } from 'tinyglobby';
|
|
2
|
+
import { readdir, readFileSync } from 'node:fs';
|
|
3
|
+
import { escapePath, glob as tinyGlob } from 'tinyglobby';
|
|
6
4
|
import picomatch from 'picomatch';
|
|
7
5
|
import { GLOBAL_IGNORE_PATTERNS } from '../constants.js';
|
|
8
6
|
import { compact, partition } from './array.js';
|
|
@@ -14,6 +12,15 @@ import { expandIgnorePatterns, parseAndConvertGitignorePatterns } from './parse-
|
|
|
14
12
|
import { dirname, isAbsolute, join, relative, toAbsolute, toPosix } from './path.js';
|
|
15
13
|
const cachedGitIgnores = new Map();
|
|
16
14
|
const cachedGlobIgnores = new Map();
|
|
15
|
+
let gitignoreWorkspaceDirs;
|
|
16
|
+
const isInNestedWorkspace = (gitignoreDir, dir) => {
|
|
17
|
+
if (!gitignoreWorkspaceDirs)
|
|
18
|
+
return false;
|
|
19
|
+
for (let d = gitignoreDir; d.length > dir.length; d = dirname(d))
|
|
20
|
+
if (gitignoreWorkspaceDirs.has(d))
|
|
21
|
+
return true;
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
17
24
|
let gitignoreReconciler;
|
|
18
25
|
let gitignoreMatcher = (_filePath) => false;
|
|
19
26
|
export const isGitIgnored = (filePath) => gitignoreMatcher(filePath);
|
|
@@ -76,22 +83,20 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
76
83
|
const ignores = new Set(GLOBAL_IGNORE_PATTERNS);
|
|
77
84
|
const unignores = new Set();
|
|
78
85
|
const gitignoreFiles = [];
|
|
79
|
-
let
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
return deepFilterMatcher;
|
|
86
|
+
let isIgnored = (_path) => false;
|
|
87
|
+
let isUnignored = (_path) => false;
|
|
88
|
+
const pendingIgnores = Array.from(ignores);
|
|
89
|
+
const pendingUnignores = [];
|
|
90
|
+
const extend = (matcher, pending) => {
|
|
91
|
+
if (pending.length === 0)
|
|
92
|
+
return matcher;
|
|
93
|
+
const incr = picomatch(pending.splice(0));
|
|
94
|
+
return (path) => matcher(path) || incr(path);
|
|
95
|
+
};
|
|
96
|
+
const isExcluded = (path) => {
|
|
97
|
+
isIgnored = extend(isIgnored, pendingIgnores);
|
|
98
|
+
isUnignored = extend(isUnignored, pendingUnignores);
|
|
99
|
+
return isIgnored(path) && !isUnignored(path);
|
|
95
100
|
};
|
|
96
101
|
const seenGitignoreFiles = new Set();
|
|
97
102
|
const addFile = (filePath, baseDir) => {
|
|
@@ -108,6 +113,7 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
108
113
|
const prevIgnoreSize = ignores.size;
|
|
109
114
|
const patterns = readFileSync(filePath, 'utf8');
|
|
110
115
|
const isRoot = base === '' || base.startsWith('..');
|
|
116
|
+
const escapedBase = escapePath(base);
|
|
111
117
|
for (const { negated, pattern } of parseAndConvertGitignorePatterns(patterns, ancestor)) {
|
|
112
118
|
if (negated) {
|
|
113
119
|
if (isRoot) {
|
|
@@ -117,7 +123,7 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
125
|
else if (!unignores.has(pattern)) {
|
|
120
|
-
const unignore = join(
|
|
126
|
+
const unignore = join(escapedBase, pattern);
|
|
121
127
|
unignores.add(unignore);
|
|
122
128
|
unignoresForDir.add(unignore);
|
|
123
129
|
}
|
|
@@ -127,7 +133,7 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
127
133
|
ignoresForDir.add(pattern);
|
|
128
134
|
}
|
|
129
135
|
else if (!unignores.has(pattern)) {
|
|
130
|
-
const ignore = join(
|
|
136
|
+
const ignore = join(escapedBase, pattern);
|
|
131
137
|
ignores.add(ignore);
|
|
132
138
|
ignoresForDir.add(ignore);
|
|
133
139
|
}
|
|
@@ -143,11 +149,9 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
143
149
|
else {
|
|
144
150
|
cachedGitIgnores.set(cacheDir, { ignores: ignoresForDir, unignores: unignoresForDir });
|
|
145
151
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
else if (ignores.size !== prevIgnoreSize) {
|
|
152
|
+
for (const p of unignoresForDir)
|
|
153
|
+
pendingUnignores.push(p);
|
|
154
|
+
if (ignores.size !== prevIgnoreSize) {
|
|
151
155
|
for (const p of ignoresForDir)
|
|
152
156
|
if (!GLOBAL_IGNORE_PATTERNS.includes(p))
|
|
153
157
|
pendingIgnores.push(p);
|
|
@@ -168,15 +172,16 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
168
172
|
const rootGitignorePath = join(cwd, '.gitignore');
|
|
169
173
|
if (isFile(rootGitignorePath))
|
|
170
174
|
addFile(rootGitignorePath);
|
|
175
|
+
const root = cwd.length > 1 && cwd.endsWith('/') ? cwd.slice(0, -1) : cwd;
|
|
171
176
|
let isRelevantDir;
|
|
172
177
|
if (workspaceDirs && workspaceDirs.size > 0) {
|
|
173
178
|
const relevantAncestors = new Set();
|
|
174
179
|
const nonRootDirs = new Set();
|
|
175
180
|
for (const wsDir of workspaceDirs) {
|
|
176
|
-
if (wsDir !==
|
|
181
|
+
if (wsDir !== root)
|
|
177
182
|
nonRootDirs.add(wsDir);
|
|
178
183
|
let dir = wsDir;
|
|
179
|
-
while (dir.length >=
|
|
184
|
+
while (dir.length >= root.length) {
|
|
180
185
|
relevantAncestors.add(dir);
|
|
181
186
|
const parent = dirname(dir);
|
|
182
187
|
if (parent === dir)
|
|
@@ -195,24 +200,32 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
|
|
|
195
200
|
};
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
203
|
+
const rootPrefixLen = root.length + 1;
|
|
204
|
+
await new Promise(resolve => {
|
|
205
|
+
let pending = 0;
|
|
206
|
+
const walk = (dir) => {
|
|
207
|
+
pending++;
|
|
208
|
+
readdir(dir, { withFileTypes: true }, (error, entries) => {
|
|
209
|
+
if (!error) {
|
|
210
|
+
for (const entry of entries) {
|
|
211
|
+
if (entry.name === '.gitignore' && (entry.isFile() || entry.isSymbolicLink()))
|
|
212
|
+
addFile(`${dir}/.gitignore`);
|
|
213
|
+
}
|
|
214
|
+
for (const entry of entries) {
|
|
215
|
+
if (!entry.isDirectory())
|
|
216
|
+
continue;
|
|
217
|
+
const absPath = `${dir}/${entry.name}`;
|
|
218
|
+
if ((isRelevantDir && !isRelevantDir(absPath)) || isExcluded(absPath.slice(rootPrefixLen)))
|
|
219
|
+
continue;
|
|
220
|
+
walk(absPath);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (--pending === 0)
|
|
224
|
+
resolve();
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
walk(root);
|
|
228
|
+
});
|
|
216
229
|
if (unignores.size > 0) {
|
|
217
230
|
const unignorePaths = new Set();
|
|
218
231
|
for (const u of unignores) {
|
|
@@ -269,6 +282,14 @@ export async function glob(_patterns, options) {
|
|
|
269
282
|
if (prev === dir || dir === '.')
|
|
270
283
|
break;
|
|
271
284
|
}
|
|
285
|
+
if (!gitignoreReconciler) {
|
|
286
|
+
const prefix = `${options.dir}/`;
|
|
287
|
+
for (const [gitignoreDir, cacheForDir] of cachedGitIgnores) {
|
|
288
|
+
if (gitignoreDir.startsWith(prefix) && !isInNestedWorkspace(gitignoreDir, options.dir)) {
|
|
289
|
+
_ignore.push(...cacheForDir.ignores);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
272
293
|
cachedGlobIgnores.set(options.dir, compact(_ignore));
|
|
273
294
|
}
|
|
274
295
|
const ignorePatterns = (cachedIgnores ?? _ignore).concat(negatedPatterns.map(pattern => pattern.slice(1)));
|
|
@@ -301,6 +322,8 @@ export function reconcileGitignoredPaths(paths, cwd) {
|
|
|
301
322
|
}
|
|
302
323
|
export async function getGitIgnoredHandler(options, workspaceDirs) {
|
|
303
324
|
cachedGitIgnores.clear();
|
|
325
|
+
cachedGlobIgnores.clear();
|
|
326
|
+
gitignoreWorkspaceDirs = workspaceDirs;
|
|
304
327
|
gitignoreReconciler = undefined;
|
|
305
328
|
gitignoreMatcher = () => false;
|
|
306
329
|
gitignoreFingerprint = '';
|
package/dist/util/glob.js
CHANGED
|
@@ -4,8 +4,18 @@ import { computeGlobCacheKey, createDirTracker, getCachedGlob, isGlobCacheEnable
|
|
|
4
4
|
import { getGitignoreFingerprint, glob, reconcileGitignoredPaths } from './glob-core.js';
|
|
5
5
|
import { timerify } from './Performance.js';
|
|
6
6
|
import { isAbsolute, join, relative } from './path.js';
|
|
7
|
-
const prepend = (pattern, relativePath) =>
|
|
8
|
-
const
|
|
7
|
+
const prepend = (pattern, cwd, relativePath) => {
|
|
8
|
+
const isNegated = pattern.startsWith('!');
|
|
9
|
+
const id = isNegated ? pattern.slice(1) : pattern;
|
|
10
|
+
if (id && !isAbsolute(id) && !relativePath)
|
|
11
|
+
return pattern;
|
|
12
|
+
const globPattern = isAbsolute(id) ? relative(cwd, id) : join(relativePath, id);
|
|
13
|
+
return isNegated ? `!${globPattern}` : globPattern;
|
|
14
|
+
};
|
|
15
|
+
const prependDirToPatterns = (cwd, dir, patterns) => {
|
|
16
|
+
const relativePath = dir === cwd ? '' : relative(cwd, dir);
|
|
17
|
+
return compact(patterns.map(p => removeProductionSuffix(prepend(p, cwd, relativePath)))).sort(negatedLast);
|
|
18
|
+
};
|
|
9
19
|
export const removeProductionSuffix = (pattern) => pattern.replace(/!$/, '');
|
|
10
20
|
const negatedLast = (pattern) => (pattern.startsWith('!') ? 1 : -1);
|
|
11
21
|
export const prependDirToPattern = (dir, pattern) => {
|
|
@@ -48,7 +58,7 @@ const defaultGlob = async ({ cwd, dir = cwd, patterns, gitignore = true, label }
|
|
|
48
58
|
};
|
|
49
59
|
const syncGlob = ({ cwd, patterns }) => {
|
|
50
60
|
const cacheEnabled = isGlobCacheEnabled();
|
|
51
|
-
const patternList =
|
|
61
|
+
const patternList = [patterns].flat().map(pattern => prepend(pattern, cwd, ''));
|
|
52
62
|
const cacheKey = cacheEnabled
|
|
53
63
|
? computeGlobCacheKey({ patterns: patternList, cwd, dir: cwd, gitignore: false, gitignoreFingerprint: '' })
|
|
54
64
|
: '';
|
|
@@ -58,7 +68,7 @@ const syncGlob = ({ cwd, patterns }) => {
|
|
|
58
68
|
return cached;
|
|
59
69
|
}
|
|
60
70
|
const tracker = cacheEnabled ? createDirTracker() : undefined;
|
|
61
|
-
const paths = globSync(
|
|
71
|
+
const paths = globSync(patternList, {
|
|
62
72
|
cwd,
|
|
63
73
|
absolute: true,
|
|
64
74
|
followSymbolicLinks: false,
|
|
@@ -69,12 +79,7 @@ const syncGlob = ({ cwd, patterns }) => {
|
|
|
69
79
|
setCachedGlob(cacheKey, paths, cwd, tracker?.dirs);
|
|
70
80
|
return paths;
|
|
71
81
|
};
|
|
72
|
-
const dirGlob = async ({ cwd, patterns, gitignore = true }) => glob(patterns, {
|
|
73
|
-
cwd,
|
|
74
|
-
dir: cwd,
|
|
75
|
-
onlyDirectories: true,
|
|
76
|
-
gitignore,
|
|
77
|
-
});
|
|
82
|
+
const dirGlob = async ({ cwd, patterns, gitignore = true }) => glob(patterns.map(pattern => prepend(pattern, cwd, '')), { cwd, dir: cwd, onlyDirectories: true, gitignore });
|
|
78
83
|
export const _glob = timerify(defaultGlob);
|
|
79
84
|
export const _syncGlob = timerify(syncGlob);
|
|
80
85
|
export const _dirGlob = timerify(dirGlob);
|
|
@@ -9,5 +9,5 @@ interface TSConfigInfo {
|
|
|
9
9
|
sourceMapPairs: SourceMap[];
|
|
10
10
|
paths: Record<string, string[]> | undefined;
|
|
11
11
|
}
|
|
12
|
-
export declare const loadTSConfig: (tsConfigFilePath: string) => Promise<TSConfigInfo>;
|
|
12
|
+
export declare const loadTSConfig: (tsConfigFilePath: string, isUseTscFiles?: boolean, visited?: Set<string>) => Promise<TSConfigInfo>;
|
|
13
13
|
export {};
|
|
@@ -2,19 +2,19 @@ import { parseTsconfig } from 'get-tsconfig';
|
|
|
2
2
|
import { compact } from './array.js';
|
|
3
3
|
import { isFile } from './fs.js';
|
|
4
4
|
import { _syncGlob } from './glob.js';
|
|
5
|
-
import { dirname, isAbsolute, join, toAbsolute, toPosix } from './path.js';
|
|
5
|
+
import { dirname, isAbsolute, join, relative, toAbsolute, toPosix } from './path.js';
|
|
6
6
|
const hasGlobChar = (p) => p.includes('*') || p.includes('?');
|
|
7
7
|
const hasExtension = (p) => {
|
|
8
8
|
const last = p.lastIndexOf('/');
|
|
9
9
|
const base = last >= 0 ? p.slice(last + 1) : p;
|
|
10
10
|
return base !== '.' && base !== '..' && base.includes('.');
|
|
11
11
|
};
|
|
12
|
-
const
|
|
12
|
+
const toRelativePatterns = (patterns, dir) => {
|
|
13
13
|
if (!patterns)
|
|
14
14
|
return undefined;
|
|
15
15
|
return patterns.map(p => {
|
|
16
|
-
const
|
|
17
|
-
return
|
|
16
|
+
const pattern = isAbsolute(p) ? relative(dir, p) : p;
|
|
17
|
+
return hasGlobChar(p) || hasExtension(p) ? pattern : join(pattern, '**/*');
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
const getImplicitBaseUrl = (compilerOptions) => {
|
|
@@ -54,11 +54,11 @@ const expandFileNames = (dir, compilerOptions, include, exclude, files) => {
|
|
|
54
54
|
for (const file of files)
|
|
55
55
|
result.push(file);
|
|
56
56
|
}
|
|
57
|
-
const effectiveExclude = [...(exclude ?? []),
|
|
57
|
+
const effectiveExclude = [...(exclude ?? []), 'node_modules/**'];
|
|
58
58
|
if (compilerOptions.outDir) {
|
|
59
|
-
effectiveExclude.push(join(compilerOptions.outDir, '**'));
|
|
59
|
+
effectiveExclude.push(join(relative(dir, compilerOptions.outDir), '**'));
|
|
60
60
|
}
|
|
61
|
-
const effectiveInclude = include ?? (files ? undefined : DEFAULT_INCLUDE
|
|
61
|
+
const effectiveInclude = include ?? (files ? undefined : DEFAULT_INCLUDE);
|
|
62
62
|
if (effectiveInclude) {
|
|
63
63
|
const negated = effectiveExclude.map(p => `!${p}`);
|
|
64
64
|
const globbed = _syncGlob({ patterns: [...effectiveInclude, ...negated], cwd: dir });
|
|
@@ -108,7 +108,7 @@ const EMPTY = {
|
|
|
108
108
|
sourceMapPairs: [],
|
|
109
109
|
paths: undefined,
|
|
110
110
|
};
|
|
111
|
-
export const loadTSConfig = async (tsConfigFilePath) => {
|
|
111
|
+
export const loadTSConfig = async (tsConfigFilePath, isUseTscFiles = false, visited = new Set([tsConfigFilePath])) => {
|
|
112
112
|
if (!isFile(tsConfigFilePath))
|
|
113
113
|
return { isFile: false, ...EMPTY };
|
|
114
114
|
try {
|
|
@@ -127,10 +127,20 @@ export const loadTSConfig = async (tsConfigFilePath) => {
|
|
|
127
127
|
if (config.references?.length) {
|
|
128
128
|
walkReferences(compilerOptions, config.references, dir, new Set([tsConfigFilePath]), sourceMapPairs, tsconfigPaths);
|
|
129
129
|
}
|
|
130
|
-
const include =
|
|
131
|
-
const exclude =
|
|
132
|
-
const files =
|
|
130
|
+
const include = toRelativePatterns(config.include, dir);
|
|
131
|
+
const exclude = toRelativePatterns(config.exclude, dir);
|
|
132
|
+
const files = config.files?.map(p => toAbsolute(p, dir));
|
|
133
133
|
const fileNames = expandFileNames(dir, compilerOptions, include, exclude, files);
|
|
134
|
+
if (isUseTscFiles && config.references) {
|
|
135
|
+
for (const ref of config.references) {
|
|
136
|
+
const refPath = resolveReference(ref.path, dir);
|
|
137
|
+
if (!refPath?.startsWith(`${dir}/`) || visited.has(refPath))
|
|
138
|
+
continue;
|
|
139
|
+
visited.add(refPath);
|
|
140
|
+
for (const filePath of (await loadTSConfig(refPath, true, visited)).fileNames)
|
|
141
|
+
fileNames.push(filePath);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
134
144
|
const paths = Object.keys(tsconfigPaths).length > 0 ? tsconfigPaths : undefined;
|
|
135
145
|
return { isFile: true, compilerOptions, fileNames, include, exclude, sourceMapPairs, paths };
|
|
136
146
|
}
|
|
@@ -87,13 +87,18 @@ const addValues = (map, id, values) => {
|
|
|
87
87
|
for (const v of values)
|
|
88
88
|
existing.add(v);
|
|
89
89
|
else
|
|
90
|
-
map.set(id, values);
|
|
90
|
+
map.set(id, new Set(values));
|
|
91
91
|
};
|
|
92
92
|
const addNsValues = (map, id, value) => {
|
|
93
93
|
const existing = map.get(id);
|
|
94
|
-
if (existing)
|
|
94
|
+
if (existing) {
|
|
95
95
|
for (const [ns, v] of value)
|
|
96
96
|
addValues(existing, ns, v);
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const copy = new Map();
|
|
100
|
+
for (const [ns, v] of value)
|
|
101
|
+
copy.set(ns, new Set(v));
|
|
102
|
+
map.set(id, copy);
|
|
103
|
+
}
|
|
99
104
|
};
|
package/dist/util/scripts.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type Command, type
|
|
1
|
+
import { type Command, type SyntaxNode, type Word } from 'unbash';
|
|
2
2
|
export interface ScriptCommand {
|
|
3
3
|
binary: string;
|
|
4
4
|
args: string[];
|
|
5
5
|
}
|
|
6
6
|
export declare const toShellCommand: (argv: string[]) => string;
|
|
7
|
-
export declare
|
|
7
|
+
export declare const getCommandWords: (node: Pick<Command, 'args'>) => Word[];
|
|
8
|
+
export declare function walkCommands(node: SyntaxNode): Generator<Command>;
|
|
8
9
|
export declare const getScriptCommands: (script: string) => ScriptCommand[];
|
package/dist/util/scripts.js
CHANGED
|
@@ -2,6 +2,7 @@ import { parse } from 'unbash';
|
|
|
2
2
|
import { extractBinary } from './modules.js';
|
|
3
3
|
const spawningBinaries = new Set(['c8', 'cross-env', 'retry-cli']);
|
|
4
4
|
export const toShellCommand = (argv) => argv.map(arg => `'${arg.replaceAll("'", `'\\''`)}'`).join(' ');
|
|
5
|
+
export const getCommandWords = (node) => node.args.filter((arg) => arg.type === 'Word');
|
|
5
6
|
export function* walkCommands(node) {
|
|
6
7
|
switch (node.type) {
|
|
7
8
|
case 'Command':
|
|
@@ -42,7 +43,11 @@ export function* walkCommands(node) {
|
|
|
42
43
|
yield* walkCommands(node.body);
|
|
43
44
|
break;
|
|
44
45
|
case 'Statement':
|
|
45
|
-
|
|
46
|
+
case 'Redirected':
|
|
47
|
+
case 'Time':
|
|
48
|
+
case 'Negation':
|
|
49
|
+
if (node.command)
|
|
50
|
+
yield* walkCommands(node.command);
|
|
46
51
|
break;
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -65,15 +70,16 @@ export const getScriptCommands = (script) => {
|
|
|
65
70
|
if (!text)
|
|
66
71
|
continue;
|
|
67
72
|
const binary = extractBinary(text);
|
|
73
|
+
const words = getCommandWords(node);
|
|
68
74
|
if (spawningBinaries.has(binary)) {
|
|
69
|
-
const rest =
|
|
75
|
+
const rest = words
|
|
70
76
|
.filter(word => word.text !== '--')
|
|
71
77
|
.map(word => word.text)
|
|
72
78
|
.join(' ');
|
|
73
79
|
out.push(...getScriptCommands(rest));
|
|
74
80
|
}
|
|
75
81
|
else
|
|
76
|
-
out.push({ binary, args:
|
|
82
|
+
out.push({ binary, args: words.map(word => word.value) });
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
return out;
|
|
@@ -104,7 +104,7 @@ export const getToSourcePathsHandler = (chief) => {
|
|
|
104
104
|
const absSpecifier = isAbsolute(id) ? id : prependDirToPattern(dir, id);
|
|
105
105
|
const ws = chief.findWorkspaceByFilePath(absSpecifier);
|
|
106
106
|
const mapped = ws?.sourceMaps && rewritePattern(ws.sourceMaps, absSpecifier, extensions);
|
|
107
|
-
patterns.add(negation + (mapped ??
|
|
107
|
+
patterns.add(negation + (mapped ?? id));
|
|
108
108
|
}
|
|
109
109
|
const filePaths = await _glob({ patterns: Array.from(patterns), cwd: chief.cwd, dir, label });
|
|
110
110
|
debugLogArray(toRelative(dir, chief.cwd), 'Source mapping (package.json)', filePaths);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.41.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.41.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.41.0",
|
|
4
4
|
"description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analysis",
|
|
@@ -81,29 +81,28 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"
|
|
85
|
-
"formatly": "^0.7.0",
|
|
84
|
+
"formatly": "^0.11.4",
|
|
86
85
|
"get-tsconfig": "4.14.3",
|
|
87
86
|
"jiti": "^2.7.0",
|
|
88
|
-
"oxc-parser": "^0.
|
|
87
|
+
"oxc-parser": "^0.153.0",
|
|
89
88
|
"oxc-resolver": "11.24.2",
|
|
90
89
|
"picomatch": "^4.0.7",
|
|
91
|
-
"smol-toml": "^1.
|
|
90
|
+
"smol-toml": "^1.9.0",
|
|
92
91
|
"strip-json-comments": "5.0.3",
|
|
93
92
|
"tinyglobby": "^0.2.17",
|
|
94
|
-
"unbash": "^
|
|
93
|
+
"unbash": "^5.0.0",
|
|
95
94
|
"yaml": "^2.9.1",
|
|
96
|
-
"zod": "^4.
|
|
95
|
+
"zod": "^4.6.5"
|
|
97
96
|
},
|
|
98
97
|
"devDependencies": {
|
|
99
98
|
"@jest/types": "^30.5.1",
|
|
100
99
|
"@types/bun": "^1.4.2",
|
|
101
100
|
"@types/picomatch": "^4.0.3",
|
|
102
101
|
"codeclimate-types": "^0.3.1",
|
|
103
|
-
"prettier": "^3.9.
|
|
104
|
-
"tsx": "^4.23.
|
|
102
|
+
"prettier": "^3.9.9",
|
|
103
|
+
"tsx": "^4.23.15",
|
|
105
104
|
"typescript": "7.0.2",
|
|
106
|
-
"webpack": "^5.111.
|
|
105
|
+
"webpack": "^5.111.1"
|
|
107
106
|
},
|
|
108
107
|
"engines": {
|
|
109
108
|
"node": "^20.19.0 || >=22.12.0"
|
package/schema.json
CHANGED
|
@@ -562,6 +562,10 @@
|
|
|
562
562
|
"title": "Expo plugin configuration (https://knip.dev/reference/plugins/expo)",
|
|
563
563
|
"$ref": "#/definitions/plugin"
|
|
564
564
|
},
|
|
565
|
+
"expo-router": {
|
|
566
|
+
"title": "Expo Router plugin configuration (https://knip.dev/reference/plugins/expo-router)",
|
|
567
|
+
"$ref": "#/definitions/plugin"
|
|
568
|
+
},
|
|
565
569
|
"expressive-code": {
|
|
566
570
|
"title": "expressive-code plugin configuration (https://knip.dev/reference/plugins/expressive-code)",
|
|
567
571
|
"$ref": "#/definitions/plugin"
|
|
@@ -570,6 +574,10 @@
|
|
|
570
574
|
"title": "fast plugin configuration (https://knip.dev/reference/plugins/fast)",
|
|
571
575
|
"$ref": "#/definitions/plugin"
|
|
572
576
|
},
|
|
577
|
+
"flue": {
|
|
578
|
+
"title": "flue plugin configuration (https://knip.dev/reference/plugins/flue)",
|
|
579
|
+
"$ref": "#/definitions/plugin"
|
|
580
|
+
},
|
|
573
581
|
"fumadocs": {
|
|
574
582
|
"title": "fumadocs plugin configuration (https://knip.dev/reference/plugins/fumadocs)",
|
|
575
583
|
"$ref": "#/definitions/plugin"
|