knip 6.40.0 → 6.42.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/README.md +1 -1
- package/dist/ConfigurationChief.d.ts +30 -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 +15 -8
- package/dist/binaries/bash-parser.js +16 -33
- package/dist/binaries/command.d.ts +1 -1
- package/dist/binaries/command.js +14 -8
- package/dist/binaries/resolvers/bun.js +1 -0
- package/dist/graph/build.js +18 -9
- package/dist/graph-explorer/operations/is-referenced.js +8 -2
- package/dist/manifest/index.d.ts +1 -0
- package/dist/manifest/index.js +7 -3
- package/dist/plugins/_component-style-urls/component-style-urls-visitor.d.ts +2 -0
- package/dist/plugins/_component-style-urls/component-style-urls-visitor.js +40 -0
- package/dist/plugins/angular/index.js +7 -1
- package/dist/plugins/biome/index.js +2 -2
- package/dist/plugins/commitlint/index.js +2 -2
- package/dist/plugins/eslint/helpers.js +1 -1
- 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/filesystem-routing/index.d.ts +3 -0
- package/dist/plugins/filesystem-routing/index.js +57 -0
- package/dist/plugins/flue/index.d.ts +3 -0
- package/dist/plugins/flue/index.js +42 -0
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/jest/index.js +5 -0
- package/dist/plugins/jest/visitors/mock.d.ts +2 -0
- package/dist/plugins/jest/visitors/mock.js +91 -0
- package/dist/plugins/mise/scripts.js +56 -76
- package/dist/plugins/moonrepo/index.js +2 -1
- package/dist/plugins/next/index.js +33 -1
- package/dist/plugins/nx/index.js +50 -8
- package/dist/plugins/nx/types.d.ts +8 -0
- package/dist/plugins/oxlint/index.js +1 -1
- package/dist/plugins/react-native/index.js +1 -1
- package/dist/plugins/react-router/index.d.ts +3 -0
- package/dist/plugins/react-router/index.js +3 -0
- package/dist/plugins/rsbuild/index.js +20 -6
- package/dist/plugins/rsbuild/types.d.ts +6 -0
- package/dist/plugins/rstest/index.js +1 -1
- package/dist/plugins/rstest/types.d.ts +1 -5
- package/dist/plugins/solidjs-vite-plugin/index.d.ts +6 -0
- package/dist/plugins/solidjs-vite-plugin/index.js +17 -0
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.d.ts +3 -0
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +76 -0
- package/dist/plugins/sst/resolveFromAST.js +1 -1
- package/dist/plugins/stencil/index.js +2 -39
- package/dist/plugins/storybook/index.js +2 -4
- package/dist/plugins/sveltejs-package/helpers.js +7 -44
- package/dist/plugins/taskfile/index.js +3 -6
- package/dist/plugins/tsrs/index.d.ts +3 -0
- package/dist/plugins/tsrs/index.js +15 -0
- package/dist/plugins/typescript/index.d.ts +12 -1
- package/dist/plugins/typescript/index.js +5 -7
- package/dist/plugins/vite/helpers.d.ts +1 -0
- package/dist/plugins/vite/helpers.js +15 -1
- package/dist/plugins/vitest/index.js +2 -2
- package/dist/run.js +2 -0
- package/dist/schema/configuration.d.ts +75 -0
- package/dist/schema/plugins.d.ts +25 -0
- package/dist/schema/plugins.js +5 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +5 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/workspace.d.ts +1 -0
- package/dist/typescript/visitors/imports.js +11 -0
- package/dist/typescript/visitors/jsdoc.js +27 -22
- package/dist/util/create-options.d.ts +50 -0
- package/dist/util/create-options.js +2 -3
- 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/path.d.ts +1 -0
- package/dist/util/path.js +1 -0
- package/dist/util/scripts.d.ts +4 -2
- package/dist/util/scripts.js +33 -67
- 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 +10 -11
- package/schema.json +20 -0
|
@@ -226,6 +226,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
226
226
|
entry?: string | string[] | undefined;
|
|
227
227
|
project?: string | string[] | undefined;
|
|
228
228
|
} | undefined;
|
|
229
|
+
'expo-router'?: string | boolean | string[] | {
|
|
230
|
+
config?: string | string[] | undefined;
|
|
231
|
+
entry?: string | string[] | undefined;
|
|
232
|
+
project?: string | string[] | undefined;
|
|
233
|
+
} | undefined;
|
|
229
234
|
'expressive-code'?: string | boolean | string[] | {
|
|
230
235
|
config?: string | string[] | undefined;
|
|
231
236
|
entry?: string | string[] | undefined;
|
|
@@ -236,6 +241,16 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
236
241
|
entry?: string | string[] | undefined;
|
|
237
242
|
project?: string | string[] | undefined;
|
|
238
243
|
} | undefined;
|
|
244
|
+
'filesystem-routing'?: string | boolean | string[] | {
|
|
245
|
+
config?: string | string[] | undefined;
|
|
246
|
+
entry?: string | string[] | undefined;
|
|
247
|
+
project?: string | string[] | undefined;
|
|
248
|
+
} | undefined;
|
|
249
|
+
flue?: string | boolean | string[] | {
|
|
250
|
+
config?: string | string[] | undefined;
|
|
251
|
+
entry?: string | string[] | undefined;
|
|
252
|
+
project?: string | string[] | undefined;
|
|
253
|
+
} | undefined;
|
|
239
254
|
fumadocs?: string | boolean | string[] | {
|
|
240
255
|
config?: string | string[] | undefined;
|
|
241
256
|
entry?: string | string[] | undefined;
|
|
@@ -701,6 +716,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
701
716
|
entry?: string | string[] | undefined;
|
|
702
717
|
project?: string | string[] | undefined;
|
|
703
718
|
} | undefined;
|
|
719
|
+
'solidjs-vite-plugin'?: string | boolean | string[] | {
|
|
720
|
+
config?: string | string[] | undefined;
|
|
721
|
+
entry?: string | string[] | undefined;
|
|
722
|
+
project?: string | string[] | undefined;
|
|
723
|
+
} | undefined;
|
|
704
724
|
sst?: string | boolean | string[] | {
|
|
705
725
|
config?: string | string[] | undefined;
|
|
706
726
|
entry?: string | string[] | undefined;
|
|
@@ -816,6 +836,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
816
836
|
entry?: string | string[] | undefined;
|
|
817
837
|
project?: string | string[] | undefined;
|
|
818
838
|
} | undefined;
|
|
839
|
+
tsrs?: string | boolean | string[] | {
|
|
840
|
+
config?: string | string[] | undefined;
|
|
841
|
+
entry?: string | string[] | undefined;
|
|
842
|
+
project?: string | string[] | undefined;
|
|
843
|
+
} | undefined;
|
|
819
844
|
tsup?: string | boolean | string[] | {
|
|
820
845
|
config?: string | string[] | undefined;
|
|
821
846
|
entry?: string | string[] | undefined;
|
|
@@ -1208,6 +1233,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1208
1233
|
entry?: string | string[] | undefined;
|
|
1209
1234
|
project?: string | string[] | undefined;
|
|
1210
1235
|
} | undefined;
|
|
1236
|
+
'expo-router'?: string | boolean | string[] | {
|
|
1237
|
+
config?: string | string[] | undefined;
|
|
1238
|
+
entry?: string | string[] | undefined;
|
|
1239
|
+
project?: string | string[] | undefined;
|
|
1240
|
+
} | undefined;
|
|
1211
1241
|
'expressive-code'?: string | boolean | string[] | {
|
|
1212
1242
|
config?: string | string[] | undefined;
|
|
1213
1243
|
entry?: string | string[] | undefined;
|
|
@@ -1218,6 +1248,16 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1218
1248
|
entry?: string | string[] | undefined;
|
|
1219
1249
|
project?: string | string[] | undefined;
|
|
1220
1250
|
} | undefined;
|
|
1251
|
+
'filesystem-routing'?: string | boolean | string[] | {
|
|
1252
|
+
config?: string | string[] | undefined;
|
|
1253
|
+
entry?: string | string[] | undefined;
|
|
1254
|
+
project?: string | string[] | undefined;
|
|
1255
|
+
} | undefined;
|
|
1256
|
+
flue?: string | boolean | string[] | {
|
|
1257
|
+
config?: string | string[] | undefined;
|
|
1258
|
+
entry?: string | string[] | undefined;
|
|
1259
|
+
project?: string | string[] | undefined;
|
|
1260
|
+
} | undefined;
|
|
1221
1261
|
fumadocs?: string | boolean | string[] | {
|
|
1222
1262
|
config?: string | string[] | undefined;
|
|
1223
1263
|
entry?: string | string[] | undefined;
|
|
@@ -1683,6 +1723,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1683
1723
|
entry?: string | string[] | undefined;
|
|
1684
1724
|
project?: string | string[] | undefined;
|
|
1685
1725
|
} | undefined;
|
|
1726
|
+
'solidjs-vite-plugin'?: string | boolean | string[] | {
|
|
1727
|
+
config?: string | string[] | undefined;
|
|
1728
|
+
entry?: string | string[] | undefined;
|
|
1729
|
+
project?: string | string[] | undefined;
|
|
1730
|
+
} | undefined;
|
|
1686
1731
|
sst?: string | boolean | string[] | {
|
|
1687
1732
|
config?: string | string[] | undefined;
|
|
1688
1733
|
entry?: string | string[] | undefined;
|
|
@@ -1798,6 +1843,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1798
1843
|
entry?: string | string[] | undefined;
|
|
1799
1844
|
project?: string | string[] | undefined;
|
|
1800
1845
|
} | undefined;
|
|
1846
|
+
tsrs?: string | boolean | string[] | {
|
|
1847
|
+
config?: string | string[] | undefined;
|
|
1848
|
+
entry?: string | string[] | undefined;
|
|
1849
|
+
project?: string | string[] | undefined;
|
|
1850
|
+
} | undefined;
|
|
1801
1851
|
tsup?: string | boolean | string[] | {
|
|
1802
1852
|
config?: string | string[] | undefined;
|
|
1803
1853
|
entry?: string | string[] | undefined;
|
|
@@ -11,12 +11,11 @@ import { loadResolvedConfigFile } from './load-config.js';
|
|
|
11
11
|
import { _load } from './loader.js';
|
|
12
12
|
import { logWarning } from './log.js';
|
|
13
13
|
import { getKeysByValue } from './object.js';
|
|
14
|
-
import { isAbsolute, isInternal, join,
|
|
14
|
+
import { isAbsolute, isInternal, join, resolveCwd, toAbsolute } from './path.js';
|
|
15
15
|
import { splitTags } from './tag.js';
|
|
16
16
|
export const createOptions = async (options) => {
|
|
17
17
|
const { args = {} } = options;
|
|
18
|
-
const
|
|
19
|
-
const cwd = normalize(toAbsolute(toPosix(options.cwd ?? args.directory ?? pcwd), pcwd));
|
|
18
|
+
const cwd = resolveCwd(options.cwd ?? args.directory ?? '.');
|
|
20
19
|
const manifestPath = findFile(cwd, 'package.json');
|
|
21
20
|
const manifest = manifestPath && (await loadJSON(manifestPath));
|
|
22
21
|
if (!(manifestPath && manifest)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FileSystemAdapter } from 'tinyglobby';
|
|
2
2
|
export declare const initGlobCache: (cacheLocation: string) => void;
|
|
3
3
|
export declare const isGlobCacheEnabled: () => boolean;
|
|
4
4
|
export declare const flushGlobCache: () => void;
|
|
@@ -13,6 +13,6 @@ export declare const computeGlobCacheKey: (input: {
|
|
|
13
13
|
export declare const getCachedGlob: (key: string) => string[] | undefined;
|
|
14
14
|
export declare const createDirTracker: () => {
|
|
15
15
|
dirs: Set<string>;
|
|
16
|
-
fs:
|
|
16
|
+
fs: FileSystemAdapter;
|
|
17
17
|
};
|
|
18
18
|
export declare const setCachedGlob: (key: string, paths: string[], baseDir: string, dirs?: Iterable<string>) => void;
|
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/path.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const basename: typeof path.basename;
|
|
|
6
6
|
export declare const join: typeof path.join;
|
|
7
7
|
export declare const toPosix: (value: string) => string;
|
|
8
8
|
export declare const resolve: typeof path.resolve;
|
|
9
|
+
export declare const resolveCwd: (dir: string) => string;
|
|
9
10
|
export declare const relative: (from: string, to: string) => string;
|
|
10
11
|
export declare const isInNodeModules: (filePath: string) => boolean;
|
|
11
12
|
export declare const toAbsolute: (id: string, base: string) => string;
|
package/dist/util/path.js
CHANGED
|
@@ -7,6 +7,7 @@ export const basename = path.posix.basename;
|
|
|
7
7
|
export const join = path.posix.join;
|
|
8
8
|
export const toPosix = isWin ? (value) => value.split(path.sep).join(path.posix.sep) : (value) => value;
|
|
9
9
|
export const resolve = path.posix.resolve;
|
|
10
|
+
export const resolveCwd = (dir) => toPosix(path.resolve(dir));
|
|
10
11
|
export const relative = (from, to) => {
|
|
11
12
|
if (to.startsWith(from)) {
|
|
12
13
|
const next = to[from.length];
|
package/dist/util/scripts.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { type Command, type
|
|
1
|
+
import { type ArithmeticCommandExpansion, type Command, type CommandExpansionPart, type ProcessSubstitutionPart, 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 const collectCommands: (root: SyntaxNode) => Command[];
|
|
9
|
+
export declare const isScriptExpansion: (node: SyntaxNode) => node is CommandExpansionPart | ProcessSubstitutionPart | ArithmeticCommandExpansion;
|
|
8
10
|
export declare const getScriptCommands: (script: string) => ScriptCommand[];
|
package/dist/util/scripts.js
CHANGED
|
@@ -1,80 +1,46 @@
|
|
|
1
|
-
import { parse } from 'unbash';
|
|
1
|
+
import { forEachChild, 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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
for (const statement of node.then.commands)
|
|
19
|
-
yield* walkCommands(statement.command);
|
|
20
|
-
if (node.else)
|
|
21
|
-
yield* walkCommands(node.else);
|
|
22
|
-
break;
|
|
23
|
-
case 'While':
|
|
24
|
-
for (const statement of node.clause.commands)
|
|
25
|
-
yield* walkCommands(statement.command);
|
|
26
|
-
for (const statement of node.body.commands)
|
|
27
|
-
yield* walkCommands(statement.command);
|
|
28
|
-
break;
|
|
29
|
-
case 'For':
|
|
30
|
-
case 'Select':
|
|
31
|
-
case 'Subshell':
|
|
32
|
-
case 'BraceGroup':
|
|
33
|
-
for (const statement of node.body.commands)
|
|
34
|
-
yield* walkCommands(statement.command);
|
|
35
|
-
break;
|
|
36
|
-
case 'CompoundList':
|
|
37
|
-
for (const statement of node.commands)
|
|
38
|
-
yield* walkCommands(statement.command);
|
|
39
|
-
break;
|
|
40
|
-
case 'Function':
|
|
41
|
-
case 'Coproc':
|
|
42
|
-
yield* walkCommands(node.body);
|
|
43
|
-
break;
|
|
44
|
-
case 'Statement':
|
|
45
|
-
yield* walkCommands(node.command);
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
5
|
+
export const getCommandWords = (node) => node.args.filter((arg) => arg.type === 'Word');
|
|
6
|
+
export const collectCommands = (root) => {
|
|
7
|
+
const commands = [];
|
|
8
|
+
const visit = (node) => {
|
|
9
|
+
if (node.type === 'Command')
|
|
10
|
+
commands.push(node);
|
|
11
|
+
if (!isScriptExpansion(node))
|
|
12
|
+
forEachChild(node, visit);
|
|
13
|
+
};
|
|
14
|
+
visit(root);
|
|
15
|
+
return commands;
|
|
16
|
+
};
|
|
17
|
+
export const isScriptExpansion = (node) => node.type === 'CommandExpansion' || node.type === 'ProcessSubstitution' || node.type === 'ArithmeticCommandExpansion';
|
|
49
18
|
export const getScriptCommands = (script) => {
|
|
50
19
|
if (!script)
|
|
51
20
|
return [];
|
|
52
|
-
|
|
21
|
+
const out = [];
|
|
53
22
|
try {
|
|
54
|
-
|
|
23
|
+
for (const statement of parse(script).commands) {
|
|
24
|
+
for (const node of collectCommands(statement.command)) {
|
|
25
|
+
const text = node.name?.value;
|
|
26
|
+
if (!text)
|
|
27
|
+
continue;
|
|
28
|
+
const binary = extractBinary(text);
|
|
29
|
+
const words = getCommandWords(node);
|
|
30
|
+
if (spawningBinaries.has(binary)) {
|
|
31
|
+
const rest = words
|
|
32
|
+
.filter(word => word.text !== '--')
|
|
33
|
+
.map(word => word.text)
|
|
34
|
+
.join(' ');
|
|
35
|
+
out.push(...getScriptCommands(rest));
|
|
36
|
+
}
|
|
37
|
+
else
|
|
38
|
+
out.push({ binary, args: words.map(word => word.value) });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
55
41
|
}
|
|
56
42
|
catch {
|
|
57
43
|
return [];
|
|
58
44
|
}
|
|
59
|
-
if (!parsed.commands)
|
|
60
|
-
return [];
|
|
61
|
-
const out = [];
|
|
62
|
-
for (const statement of parsed.commands) {
|
|
63
|
-
for (const node of walkCommands(statement.command)) {
|
|
64
|
-
const text = node.name?.value;
|
|
65
|
-
if (!text)
|
|
66
|
-
continue;
|
|
67
|
-
const binary = extractBinary(text);
|
|
68
|
-
if (spawningBinaries.has(binary)) {
|
|
69
|
-
const rest = node.suffix
|
|
70
|
-
.filter(word => word.text !== '--')
|
|
71
|
-
.map(word => word.text)
|
|
72
|
-
.join(' ');
|
|
73
|
-
out.push(...getScriptCommands(rest));
|
|
74
|
-
}
|
|
75
|
-
else
|
|
76
|
-
out.push({ binary, args: node.suffix.map(word => word.value) });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
45
|
return out;
|
|
80
46
|
};
|
|
@@ -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.42.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.42.0';
|