knip 6.44.0 → 6.44.2
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 +2 -4
- package/dist/DependencyDeputy.js +2 -2
- package/dist/ProjectPrincipal.d.ts +2 -1
- package/dist/ProjectPrincipal.js +3 -3
- package/dist/binaries/resolvers/bun.js +9 -4
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +2 -0
- package/dist/binaries/resolvers/npx.js +42 -7
- package/dist/binaries/resolvers/nub.js +2 -2
- package/dist/binaries/resolvers/vp.d.ts +2 -0
- package/dist/binaries/resolvers/vp.js +52 -0
- package/dist/compilers/scss.js +2 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +36 -0
- package/dist/plugins/babel/index.js +13 -3
- package/dist/plugins/babel/types.d.ts +1 -0
- package/dist/plugins/cspell/index.js +9 -2
- package/dist/plugins/eleventy/index.js +2 -2
- package/dist/plugins/gatsby/index.js +1 -1
- package/dist/plugins/mocha/index.js +1 -1
- package/dist/plugins/npm-package-json-lint/index.js +1 -1
- package/dist/plugins/npm-package-json-lint/types.d.ts +1 -1
- package/dist/plugins/react-router/index.js +10 -13
- package/dist/plugins/relay/index.js +1 -1
- package/dist/plugins/release-it/index.js +1 -1
- package/dist/plugins/rsbuild/index.js +29 -1
- package/dist/plugins/rsbuild/types.d.ts +8 -0
- package/dist/plugins/storybook/index.js +9 -3
- package/dist/plugins/stylelint/index.js +2 -2
- package/dist/plugins/svgr/index.js +2 -1
- package/dist/plugins/swc/index.js +8 -3
- package/dist/plugins/unocss/index.js +3 -0
- package/dist/plugins/vitest/index.js +14 -4
- package/dist/plugins/vitest/types.d.ts +1 -0
- package/dist/plugins/webpack/index.d.ts +2 -0
- package/dist/plugins/webpack/index.js +7 -4
- package/dist/session/configuration.d.ts +3 -0
- package/dist/session/configuration.js +19 -0
- package/dist/session/session.js +4 -3
- package/dist/typescript/visitors/imports.d.ts +2 -1
- package/dist/typescript/visitors/imports.js +57 -39
- package/dist/typescript/visitors/walk.js +2 -1
- package/dist/util/cli-arguments.d.ts +1 -1
- package/dist/util/cli-arguments.js +1 -1
- package/dist/util/create-options.d.ts +1 -1
- package/dist/util/create-options.js +4 -2
- package/dist/util/jiti.js +1 -0
- package/dist/util/loader.js +10 -18
- package/dist/util/modules.js +2 -1
- package/dist/util/watch.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -50,8 +50,7 @@ following projects:
|
|
|
50
50
|
[2]: https://img.shields.io/npm/v/knip?color=f56e0f
|
|
51
51
|
[3]: https://img.shields.io/badge/dynamic/json?url=https://npm-gapless.webpro.nl/downloads/range/last-month/knip&query=$.totalCompact&label=downloads&suffix=/month&color=f56e0f
|
|
52
52
|
[4]: https://github.com/webpro-nl/knip
|
|
53
|
-
[5]:
|
|
54
|
-
https://img.shields.io/github/stars/webpro-nl/knip?style=flat&color=f56e0f
|
|
53
|
+
[5]: https://img.shields.io/github/stars/webpro-nl/knip?style=flat&color=f56e0f
|
|
55
54
|
[6]: https://knip.dev
|
|
56
55
|
[7]: https://www.npmx.dev/package/@knip/create-config
|
|
57
56
|
[8]: https://www.npmx.dev/package/@knip/language-server
|
|
@@ -69,7 +68,6 @@ following projects:
|
|
|
69
68
|
[20]: https://github.com/pnpm/pnpm/tree/main/deps/graph-sequencer
|
|
70
69
|
[21]: https://github.com/pnpm/pnpm/blob/main/LICENSE
|
|
71
70
|
[22]: https://github.com/jaredwray/cacheable/tree/main/packages/file-entry-cache
|
|
72
|
-
[23]:
|
|
73
|
-
https://github.com/jaredwray/cacheable/blob/main/packages/file-entry-cache/LICENSE
|
|
71
|
+
[23]: https://github.com/jaredwray/cacheable/blob/main/packages/file-entry-cache/LICENSE
|
|
74
72
|
[24]: https://github.com/npm/json-parse-even-better-errors
|
|
75
73
|
[25]: https://github.com/npm/json-parse-even-better-errors/blob/main/LICENSE.md
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isBuiltin } from 'node:module';
|
|
2
|
-
import { DT_SCOPE, IGNORE_DEFINITELY_TYPED, IGNORED_DEPENDENCIES, IGNORED_RUNTIME_DEPENDENCIES, ROOT_WORKSPACE_NAME, } from './constants.js';
|
|
2
|
+
import { DT_SCOPE, IGNORE_DEFINITELY_TYPED, IGNORED_DEPENDENCIES, IGNORED_RUNTIME_DEPENDENCIES, PROTOCOL_CLOUDFLARE, ROOT_WORKSPACE_NAME, } from './constants.js';
|
|
3
3
|
import { getDependencyMetaData } from './manifest/index.js';
|
|
4
4
|
import { PackagePeeker } from './PackagePeeker.js';
|
|
5
5
|
import { getDefinitelyTypedFor, getPackageFromDefinitelyTyped, getPackageNameFromModuleSpecifier, isDefinitelyTyped, } from './util/modules.js';
|
|
@@ -127,7 +127,7 @@ export class DependencyDeputy {
|
|
|
127
127
|
maybeAddReferencedExternalDependency(workspace, packageName, { specifier, isDevOnly, isTypeOnly, isResolved, isPublishedType, isCaught }) {
|
|
128
128
|
if (!this.isReportDependencies)
|
|
129
129
|
return true;
|
|
130
|
-
if (specifier.startsWith('node:') || isBuiltin(specifier))
|
|
130
|
+
if (specifier.startsWith('node:') || specifier.startsWith(PROTOCOL_CLOUDFLARE) || isBuiltin(specifier))
|
|
131
131
|
return true;
|
|
132
132
|
if (IGNORED_RUNTIME_DEPENDENCIES.has(packageName))
|
|
133
133
|
return true;
|
|
@@ -2,6 +2,7 @@ import type { ParseResult } from 'oxc-parser';
|
|
|
2
2
|
import { CacheConsultant } from './CacheConsultant.ts';
|
|
3
3
|
import type { Compilers } from './compilers/types.ts';
|
|
4
4
|
import type { GetImportsAndExportsOptions, IgnoreExportsUsedInFile, PluginVisitorContext, PluginVisitorObject } from './types/config.ts';
|
|
5
|
+
import type { ConfigurationFiles } from './session/configuration.ts';
|
|
5
6
|
import type { FileNode } from './types/module-graph.ts';
|
|
6
7
|
import type { Paths } from './types/project.ts';
|
|
7
8
|
import type { ResolveGlobPattern } from './typescript/resolve-module-names.ts';
|
|
@@ -39,7 +40,7 @@ export declare class ProjectPrincipal {
|
|
|
39
40
|
addCompilers(workspaceName: string, compilers: Compilers): void;
|
|
40
41
|
addPaths(paths: Paths, basePath: string, scope: string): void;
|
|
41
42
|
addRootDirs(rootDirs: string[] | undefined, scope: string): void;
|
|
42
|
-
collectConfigurationImports(
|
|
43
|
+
collectConfigurationImports(configurationFiles: ConfigurationFiles): void;
|
|
43
44
|
init(): void;
|
|
44
45
|
private hasAcceptedExtension;
|
|
45
46
|
addEntryPath(filePath: string, options?: {
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -100,8 +100,8 @@ export class ProjectPrincipal {
|
|
|
100
100
|
const scoped = this.rootDirs.get(scope) ?? [];
|
|
101
101
|
this.rootDirs.set(scope, compact([...scoped, ...rootDirs]));
|
|
102
102
|
}
|
|
103
|
-
collectConfigurationImports(
|
|
104
|
-
for (const filePath of paths) {
|
|
103
|
+
collectConfigurationImports(configurationFiles) {
|
|
104
|
+
for (const filePath of configurationFiles.paths) {
|
|
105
105
|
if (!DEFAULT_EXTENSIONS.has(extname(filePath)))
|
|
106
106
|
continue;
|
|
107
107
|
const source = this.fileManager.readRawFile(filePath);
|
|
@@ -111,7 +111,7 @@ export class ProjectPrincipal {
|
|
|
111
111
|
for (const specifier of extractSpecifiers(_parseFile(filePath, source), source, filePath)) {
|
|
112
112
|
const resolved = this.resolveSpecifier(specifier, filePath);
|
|
113
113
|
if (resolved && !isInNodeModules(resolved))
|
|
114
|
-
|
|
114
|
+
configurationFiles.addImport(filePath, resolved);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
catch { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import parseArgs from '../../util/parse-args.js';
|
|
2
|
-
import { toBinary,
|
|
2
|
+
import { toBinary, toDeferResolveEntry } from '../../util/input.js';
|
|
3
3
|
import { isAbsolute, join } from '../../util/path.js';
|
|
4
4
|
import { _resolveSync } from '../../util/resolve.js';
|
|
5
5
|
import { argsAfter, expandScript, toCommandBinary } from '../util.js';
|
|
@@ -56,7 +56,12 @@ const commands = new Set([
|
|
|
56
56
|
]);
|
|
57
57
|
export const resolve = (_binary, words, options) => {
|
|
58
58
|
const binary = toCommandBinary(_binary, options);
|
|
59
|
-
const parsed = parseArgs(words, {
|
|
59
|
+
const parsed = parseArgs(words, {
|
|
60
|
+
string: ['cwd'],
|
|
61
|
+
boolean: ['bun', 'hot', 'if-present', 'silent', 'smol', 'watch'],
|
|
62
|
+
alias: { bun: 'b' },
|
|
63
|
+
isStorePositions: true,
|
|
64
|
+
});
|
|
60
65
|
const [command, script] = parsed._;
|
|
61
66
|
if (command === 'x') {
|
|
62
67
|
const wordsForX = words.filter(word => word.value !== 'x');
|
|
@@ -77,11 +82,11 @@ export const resolve = (_binary, words, options) => {
|
|
|
77
82
|
const _cwd = parsed.cwd ? join(cwd, parsed.cwd) : cwd;
|
|
78
83
|
const resolved = _resolveSync(isAbsolute(filePath) ? filePath : join(_cwd, filePath), _cwd);
|
|
79
84
|
if (resolved)
|
|
80
|
-
return [binary,
|
|
85
|
+
return [binary, toDeferResolveEntry(resolved, { optional: true })];
|
|
81
86
|
const dir = parsed.cwd ? join(cwd, parsed.cwd) : undefined;
|
|
82
87
|
const opts = dir ? { cwd: dir } : {};
|
|
83
88
|
if (command !== 'run')
|
|
84
|
-
return [binary, ...fromArgs(words, opts)];
|
|
89
|
+
return [binary, ...fromArgs(dir ? words : words.slice(parsed.positionalIndices[0]), opts)];
|
|
85
90
|
const input = toBinary(filePath, { optional: true });
|
|
86
91
|
if (dir)
|
|
87
92
|
input.dir = dir;
|
|
@@ -10,6 +10,7 @@ declare const _default: {
|
|
|
10
10
|
pn: import("../../types/config.ts").BinaryResolver;
|
|
11
11
|
pnpx: import("../../types/config.ts").BinaryResolver;
|
|
12
12
|
pnx: import("../../types/config.ts").BinaryResolver;
|
|
13
|
+
vp: import("../../types/config.ts").BinaryResolver;
|
|
13
14
|
yarn: import("../../types/config.ts").BinaryResolver;
|
|
14
15
|
find: import("../../types/config.ts").BinaryResolver;
|
|
15
16
|
};
|
|
@@ -6,6 +6,7 @@ import * as npx from './npx.js';
|
|
|
6
6
|
import * as nub from './nub.js';
|
|
7
7
|
import * as pnpm from './pnpm.js';
|
|
8
8
|
import * as pnpx from './pnpx.js';
|
|
9
|
+
import * as vp from './vp.js';
|
|
9
10
|
import * as yarn from './yarn.js';
|
|
10
11
|
const packageManagerResolvers = {
|
|
11
12
|
bun: bun.resolve,
|
|
@@ -18,6 +19,7 @@ const packageManagerResolvers = {
|
|
|
18
19
|
pn: pnpm.resolve,
|
|
19
20
|
pnpx: pnpx.resolve,
|
|
20
21
|
pnx: pnpx.resolve,
|
|
22
|
+
vp: vp.resolve,
|
|
21
23
|
yarn: yarn.resolve,
|
|
22
24
|
};
|
|
23
25
|
export const isPackageManager = (binary) => binary in packageManagerResolvers;
|
|
@@ -6,17 +6,52 @@ import { argsFrom } from '../util.js';
|
|
|
6
6
|
const noInstallFlags = new Set(['--no', '--no-install', '--yes=false', '--no-yes']);
|
|
7
7
|
export const resolve = (_binary, words, options) => {
|
|
8
8
|
const { fromArgs } = options;
|
|
9
|
-
const
|
|
9
|
+
const args = {
|
|
10
10
|
isStorePositions: true,
|
|
11
|
-
boolean: [
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
boolean: [
|
|
12
|
+
'color',
|
|
13
|
+
'd',
|
|
14
|
+
'dangerously-allow-all-scripts',
|
|
15
|
+
'dd',
|
|
16
|
+
'ddd',
|
|
17
|
+
'force',
|
|
18
|
+
'global',
|
|
19
|
+
'ignore-scripts',
|
|
20
|
+
'include-workspace-root',
|
|
21
|
+
'legacy-peer-deps',
|
|
22
|
+
'no',
|
|
23
|
+
'offline',
|
|
24
|
+
'prefer-offline',
|
|
25
|
+
'prefer-online',
|
|
26
|
+
'progress',
|
|
27
|
+
'quiet',
|
|
28
|
+
'silent',
|
|
29
|
+
'strict-allow-scripts',
|
|
30
|
+
'timing',
|
|
31
|
+
'verbose',
|
|
32
|
+
'workspaces',
|
|
33
|
+
'yes',
|
|
34
|
+
],
|
|
35
|
+
alias: {
|
|
36
|
+
force: 'f',
|
|
37
|
+
global: 'g',
|
|
38
|
+
'include-workspace-root': 'iwr',
|
|
39
|
+
quiet: 'q',
|
|
40
|
+
silent: 's',
|
|
41
|
+
workspaces: 'ws',
|
|
42
|
+
yes: 'y',
|
|
43
|
+
package: 'p',
|
|
44
|
+
call: 'c',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const parsed = parseArgs(words, args);
|
|
48
|
+
const commandIndex = parsed.positionalIndices[0] ?? words.length;
|
|
49
|
+
const flags = parseArgs(words.slice(0, commandIndex), args);
|
|
14
50
|
const packageSpecifier = parsed._[0];
|
|
15
51
|
const specifier = packageSpecifier ? stripVersionFromSpecifier(packageSpecifier) : '';
|
|
16
|
-
const packages =
|
|
17
|
-
const command =
|
|
52
|
+
const packages = flags.package ? [flags.package].flat().map(stripVersionFromSpecifier) : [];
|
|
53
|
+
const command = flags.call ? fromArgs([flags.call]) : [];
|
|
18
54
|
const isBinary = specifier && !packageSpecifier.includes('@') && !isInternal(specifier);
|
|
19
|
-
const commandIndex = parsed.positionalIndices[0] ?? words.length;
|
|
20
55
|
const noInstall = words.slice(0, commandIndex).some(word => noInstallFlags.has(word.value));
|
|
21
56
|
const opts = noInstall ? undefined : { optional: true };
|
|
22
57
|
const dependency = isBinary ? toBinary(specifier, opts) : toDependency(specifier, opts);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import parseArgs from '../../util/parse-args.js';
|
|
2
|
-
import {
|
|
2
|
+
import { toDeferResolveEntry } from '../../util/input.js';
|
|
3
3
|
import { isAbsolute, join } from '../../util/path.js';
|
|
4
4
|
import { _resolveSync } from '../../util/resolve.js';
|
|
5
5
|
import { toCommandBinary } from '../util.js';
|
|
@@ -39,7 +39,7 @@ export const resolve = (_binary, words, options) => {
|
|
|
39
39
|
if (!script || manifest.scriptNames.has(script))
|
|
40
40
|
return [binary];
|
|
41
41
|
const resolved = _resolveSync(isAbsolute(script) ? script : join(cwd, script), cwd);
|
|
42
|
-
return resolved ? [binary,
|
|
42
|
+
return resolved ? [binary, toDeferResolveEntry(resolved, { optional: true })] : [binary];
|
|
43
43
|
}
|
|
44
44
|
if (command && (commands.has(command) || manifest.scriptNames.has(command)))
|
|
45
45
|
return [binary];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import parseArgs from '../../util/parse-args.js';
|
|
2
|
+
import { toAbsolute } from '../../util/path.js';
|
|
3
|
+
import { toCommandBinary } from '../util.js';
|
|
4
|
+
const parseOptions = {
|
|
5
|
+
isStorePositions: true,
|
|
6
|
+
string: ['filter', 'resume-from'],
|
|
7
|
+
boolean: [
|
|
8
|
+
'fail-if-no-match',
|
|
9
|
+
'parallel',
|
|
10
|
+
'recursive',
|
|
11
|
+
'report-summary',
|
|
12
|
+
'reverse',
|
|
13
|
+
'shell-mode',
|
|
14
|
+
'transitive',
|
|
15
|
+
'workspace-root',
|
|
16
|
+
],
|
|
17
|
+
alias: { filter: 'F', recursive: 'r', 'shell-mode': 'c', transitive: 't', 'workspace-root': 'w' },
|
|
18
|
+
};
|
|
19
|
+
const parseLeadingChdir = (words) => {
|
|
20
|
+
const first = words[0]?.value;
|
|
21
|
+
if (first === '-C')
|
|
22
|
+
return [words[1]?.value, 2];
|
|
23
|
+
if (first?.startsWith('-C')) {
|
|
24
|
+
const dir = first[2] === '=' ? first.slice(3) : first.slice(2);
|
|
25
|
+
if (dir)
|
|
26
|
+
return [dir, 1];
|
|
27
|
+
}
|
|
28
|
+
return [undefined, 0];
|
|
29
|
+
};
|
|
30
|
+
export const resolve = (_binary, _words, options) => {
|
|
31
|
+
const binary = toCommandBinary(_binary, options);
|
|
32
|
+
const [C, consumed] = parseLeadingChdir(_words);
|
|
33
|
+
const words = _words.slice(consumed);
|
|
34
|
+
const parsed = parseArgs(words, parseOptions);
|
|
35
|
+
const [command] = parsed._;
|
|
36
|
+
if (command !== 'exec')
|
|
37
|
+
return [binary];
|
|
38
|
+
const [execIndex, commandIndex] = parsed.positionalIndices;
|
|
39
|
+
if (commandIndex === undefined)
|
|
40
|
+
return [binary];
|
|
41
|
+
const execOptions = parseArgs(words.slice(execIndex + 1, commandIndex), parseOptions);
|
|
42
|
+
if (execOptions.filter)
|
|
43
|
+
return [binary];
|
|
44
|
+
const dir = execOptions['workspace-root'] ? options.rootCwd : C ? toAbsolute(C, options.cwd) : undefined;
|
|
45
|
+
const rest = words.slice(commandIndex);
|
|
46
|
+
const script = rest.map(word => (execOptions['shell-mode'] ? word.value : word.text)).join(' ');
|
|
47
|
+
const inputs = options.fromArgs([script], dir ? { cwd: dir } : {});
|
|
48
|
+
if (dir)
|
|
49
|
+
for (const input of inputs)
|
|
50
|
+
input.dir ??= dir;
|
|
51
|
+
return [binary, ...inputs];
|
|
52
|
+
};
|
package/dist/compilers/scss.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getUrlSpecifier, isScopedPackage, isTildePackage, splitSpec } from './shared.js';
|
|
2
|
+
import { hasUrlScheme } from '../util/url.js';
|
|
2
3
|
const dependencies = ['sass', 'sass-embedded', 'node-sass'];
|
|
3
4
|
const dependencyMatcher = /"(?:\\(?:\r\n|[\s\S]|$)|[^"\\\r\n\f])*(?:"|[\r\n\f]|$)|'(?:\\(?:\r\n|[\s\S]|$)|[^'\\\r\n\f])*(?:'|[\r\n\f]|$)|\/\*[\s\S]*?(?:\*\/|$)|\/\/[^\r\n]*(?:[\r\n]|$)|@(?:use|import|forward)\s+['"](pkg:)?([^'"]+)['"]|url\(\s*(?:["']([^"'\r\n]*)["']|([^'")\s]+))\s*\)/g;
|
|
4
5
|
const candidates = (specifier) => {
|
|
@@ -29,7 +30,7 @@ export const compiler = text => {
|
|
|
29
30
|
continue;
|
|
30
31
|
}
|
|
31
32
|
let spec = match[2];
|
|
32
|
-
if (!spec || spec.startsWith('
|
|
33
|
+
if (!spec || spec.startsWith('//') || hasUrlScheme(spec))
|
|
33
34
|
continue;
|
|
34
35
|
let isBare = Boolean(match[1]) || isScopedPackage(spec);
|
|
35
36
|
if (isTildePackage(spec)) {
|
package/dist/constants.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const BETA_TAG = "@beta";
|
|
|
11
11
|
export declare const ALIAS_TAG = "@alias";
|
|
12
12
|
export declare const DT_SCOPE = "@types";
|
|
13
13
|
export declare const PROTOCOL_VIRTUAL = "virtual:";
|
|
14
|
+
export declare const PROTOCOL_CLOUDFLARE = "cloudflare:";
|
|
14
15
|
export declare const IGNORED_GLOBAL_BINARIES: Set<string>;
|
|
15
16
|
export declare const IGNORED_DEPENDENCIES: Set<string>;
|
|
16
17
|
export declare const IGNORED_RUNTIME_DEPENDENCIES: Set<string>;
|
package/dist/constants.js
CHANGED
|
@@ -20,19 +20,26 @@ export const BETA_TAG = '@beta';
|
|
|
20
20
|
export const ALIAS_TAG = '@alias';
|
|
21
21
|
export const DT_SCOPE = '@types';
|
|
22
22
|
export const PROTOCOL_VIRTUAL = 'virtual:';
|
|
23
|
+
export const PROTOCOL_CLOUDFLARE = 'cloudflare:';
|
|
23
24
|
export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
25
|
+
'alias',
|
|
24
26
|
'amplify',
|
|
25
27
|
'aws',
|
|
26
28
|
'az',
|
|
27
29
|
'base64',
|
|
28
30
|
'basename',
|
|
29
31
|
'bash',
|
|
32
|
+
'bg',
|
|
33
|
+
'bind',
|
|
34
|
+
'break',
|
|
35
|
+
'builtin',
|
|
30
36
|
'bun',
|
|
31
37
|
'bundle',
|
|
32
38
|
'bunx',
|
|
33
39
|
'cargo',
|
|
34
40
|
'cat',
|
|
35
41
|
'cd',
|
|
42
|
+
'chgrp',
|
|
36
43
|
'chmod',
|
|
37
44
|
'chown',
|
|
38
45
|
'cksum',
|
|
@@ -40,16 +47,20 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
40
47
|
'clear',
|
|
41
48
|
'cmd',
|
|
42
49
|
'cmd.exe',
|
|
50
|
+
'cmp',
|
|
43
51
|
'code',
|
|
44
52
|
'code-insiders',
|
|
45
53
|
'codesign',
|
|
46
54
|
'comm',
|
|
47
55
|
'command',
|
|
56
|
+
'continue',
|
|
48
57
|
'corepack',
|
|
49
58
|
'cp',
|
|
50
59
|
'curl',
|
|
51
60
|
'cut',
|
|
52
61
|
'date',
|
|
62
|
+
'dd',
|
|
63
|
+
'declare',
|
|
53
64
|
'defaults',
|
|
54
65
|
'deno',
|
|
55
66
|
'devtunnel',
|
|
@@ -58,8 +69,10 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
58
69
|
'dirname',
|
|
59
70
|
'docker',
|
|
60
71
|
'dotnet',
|
|
72
|
+
'du',
|
|
61
73
|
'echo',
|
|
62
74
|
'env',
|
|
75
|
+
'eval',
|
|
63
76
|
'exec',
|
|
64
77
|
'exit',
|
|
65
78
|
'expand',
|
|
@@ -67,28 +80,37 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
67
80
|
'expr',
|
|
68
81
|
'factor',
|
|
69
82
|
'false',
|
|
83
|
+
'fg',
|
|
70
84
|
'find',
|
|
71
85
|
'fuser',
|
|
72
86
|
'gem',
|
|
73
87
|
'getconf',
|
|
88
|
+
'getopts',
|
|
74
89
|
'gh',
|
|
75
90
|
'git',
|
|
76
91
|
'grep',
|
|
77
92
|
'groups',
|
|
93
|
+
'gunzip',
|
|
78
94
|
'gzip',
|
|
95
|
+
'hash',
|
|
79
96
|
'head',
|
|
80
97
|
'hg',
|
|
98
|
+
'hostname',
|
|
81
99
|
'id',
|
|
100
|
+
'jobs',
|
|
82
101
|
'join',
|
|
83
102
|
'kill',
|
|
103
|
+
'killall',
|
|
84
104
|
'launchctl',
|
|
85
105
|
'ln',
|
|
106
|
+
'local',
|
|
86
107
|
'logname',
|
|
87
108
|
'ls',
|
|
88
109
|
'lsof',
|
|
89
110
|
'md5sum',
|
|
90
111
|
'mkdir',
|
|
91
112
|
'mknod',
|
|
113
|
+
'mktemp',
|
|
92
114
|
'mv',
|
|
93
115
|
'nc',
|
|
94
116
|
'nice',
|
|
@@ -103,6 +125,8 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
103
125
|
'open',
|
|
104
126
|
'osascript',
|
|
105
127
|
'paste',
|
|
128
|
+
'pgrep',
|
|
129
|
+
'pkill',
|
|
106
130
|
'pnpm',
|
|
107
131
|
'pnpx',
|
|
108
132
|
'powershell',
|
|
@@ -117,6 +141,10 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
117
141
|
'python3',
|
|
118
142
|
'raft',
|
|
119
143
|
'railway',
|
|
144
|
+
'read',
|
|
145
|
+
'readlink',
|
|
146
|
+
'realpath',
|
|
147
|
+
'return',
|
|
120
148
|
'rm',
|
|
121
149
|
'rmdir',
|
|
122
150
|
'rsync',
|
|
@@ -128,6 +156,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
128
156
|
'sh',
|
|
129
157
|
'sha1sum',
|
|
130
158
|
'sha512sum',
|
|
159
|
+
'shift',
|
|
131
160
|
'shred',
|
|
132
161
|
'shuf',
|
|
133
162
|
'sleep',
|
|
@@ -142,6 +171,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
142
171
|
'sysctl',
|
|
143
172
|
'systemctl',
|
|
144
173
|
'tac',
|
|
174
|
+
'tail',
|
|
145
175
|
'tar',
|
|
146
176
|
'taskkill',
|
|
147
177
|
'tee',
|
|
@@ -156,10 +186,16 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
156
186
|
'true',
|
|
157
187
|
'tsort',
|
|
158
188
|
'tty',
|
|
189
|
+
'type',
|
|
190
|
+
'ulimit',
|
|
191
|
+
'umask',
|
|
192
|
+
'unalias',
|
|
159
193
|
'uname',
|
|
160
194
|
'unexpand',
|
|
161
195
|
'uniq',
|
|
196
|
+
'unset',
|
|
162
197
|
'unzip',
|
|
198
|
+
'wait',
|
|
163
199
|
'wc',
|
|
164
200
|
'which',
|
|
165
201
|
'who',
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
|
-
import { toDeferResolve } from '../../util/input.js';
|
|
2
|
+
import { toConfig, toDeferResolve } from '../../util/input.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { api, resolveName } from './helpers.js';
|
|
5
5
|
const title = 'Babel';
|
|
6
6
|
const enablers = [/^@babel\//];
|
|
7
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
|
-
const config = [
|
|
8
|
+
const config = [
|
|
9
|
+
'babel.config.{json,js,cjs,mjs,cts,ts,mts}',
|
|
10
|
+
'.babelrc.{json,js,cjs,mjs,cts}',
|
|
11
|
+
'.babelrc',
|
|
12
|
+
'package.json',
|
|
13
|
+
];
|
|
9
14
|
const getName = (value) => [Array.isArray(value) ? value[0] : value].filter(name => typeof name === 'string');
|
|
10
15
|
export const getDependenciesFromConfig = (config) => {
|
|
11
16
|
const presets = config.presets?.flatMap(getName).map(name => resolveName(name, 'preset')) ?? [];
|
|
@@ -22,12 +27,17 @@ export const getDependenciesFromConfig = (config) => {
|
|
|
22
27
|
...overrides,
|
|
23
28
|
]);
|
|
24
29
|
};
|
|
30
|
+
const getExtendedConfigs = (config) => [
|
|
31
|
+
...(config.extends ? [toConfig('babel', config.extends)] : []),
|
|
32
|
+
...Object.values(config.env ?? {}).flatMap(getExtendedConfigs),
|
|
33
|
+
...(config.overrides ?? []).flatMap(getExtendedConfigs),
|
|
34
|
+
];
|
|
25
35
|
const resolveConfig = async (config) => {
|
|
26
36
|
if (typeof config === 'function')
|
|
27
37
|
config = config(api);
|
|
28
38
|
if (!config)
|
|
29
39
|
return [];
|
|
30
|
-
return getDependenciesFromConfig(config);
|
|
40
|
+
return [...getExtendedConfigs(config), ...getDependenciesFromConfig(config)];
|
|
31
41
|
};
|
|
32
42
|
const plugin = {
|
|
33
43
|
title,
|
|
@@ -2,6 +2,7 @@ import type { api } from './helpers.ts';
|
|
|
2
2
|
type BabelConfigFn = (options: typeof api) => BabelConfigObj;
|
|
3
3
|
export type BabelConfigObj = {
|
|
4
4
|
configFile?: string;
|
|
5
|
+
extends?: string;
|
|
5
6
|
plugins?: (string | [string, unknown])[];
|
|
6
7
|
presets?: (string | [string, unknown])[];
|
|
7
8
|
env?: Record<string, BabelConfigObj>;
|
|
@@ -5,10 +5,17 @@ const enablers = ['cspell'];
|
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = [
|
|
7
7
|
'package.json',
|
|
8
|
-
'cspell.config.{js,cjs,mjs,ts,mts,json,yaml,yml}',
|
|
9
|
-
'cspell.{
|
|
8
|
+
'{.,}cspell.config.{js,cjs,mjs,ts,cts,mts,json,jsonc,yaml,yml,toml}',
|
|
9
|
+
'{.,}cspell.{jsonc,yaml,yml}',
|
|
10
10
|
'.c{s,S}pell.json',
|
|
11
11
|
'c{s,S}pell.json',
|
|
12
|
+
'.vscode/c{s,S}pell.json',
|
|
13
|
+
'.vscode/.cspell.json',
|
|
14
|
+
'.config/{.,}cspell.config.{js,cjs,mjs,ts,cts,mts,json,jsonc,yaml,yml,toml}',
|
|
15
|
+
'.config/.c{s,S}pell.json',
|
|
16
|
+
'.config/c{s,S}pell.json',
|
|
17
|
+
'.config/{.,}cspell.jsonc',
|
|
18
|
+
'.config/cspell.{yaml,yml}',
|
|
12
19
|
];
|
|
13
20
|
const resolveConfig = config => {
|
|
14
21
|
return [config?.import ?? []].flat().map(id => toDeferResolve(id));
|
|
@@ -8,7 +8,7 @@ const title = 'Eleventy';
|
|
|
8
8
|
const enablers = ['@11ty/eleventy'];
|
|
9
9
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
10
10
|
const config = ['.eleventy.js', 'eleventy.config.{js,cjs,mjs}'];
|
|
11
|
-
const production = ['posts/**/*.11tydata.js', '_data/**/*.{js,cjs,mjs}'];
|
|
11
|
+
const production = ['posts/**/*.11tydata.{js,cjs,mjs}', '_data/**/*.{js,cjs,mjs}'];
|
|
12
12
|
const resolveConfig = async (localConfig, options) => {
|
|
13
13
|
const { configFileDir } = options;
|
|
14
14
|
const dummyUserConfig = new DummyEleventyConfig();
|
|
@@ -38,7 +38,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
38
38
|
.concat([
|
|
39
39
|
join(inputDir, dataDir, '**/*.{js,cjs,mjs}'),
|
|
40
40
|
join(inputDir, `**/*.{${typeof templateFormats === 'string' ? templateFormats : templateFormats.join(',')}}`),
|
|
41
|
-
join(inputDir, '**/*.11tydata.js'),
|
|
41
|
+
join(inputDir, '**/*.11tydata.{js,cjs,mjs}'),
|
|
42
42
|
...copiedEntries,
|
|
43
43
|
].map(id => toProductionEntry(id)));
|
|
44
44
|
};
|
|
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'Gatsby';
|
|
4
4
|
const enablers = ['gatsby', 'gatsby-cli'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['gatsby-{config,node}.{js,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,jsx,ts,tsx}'];
|
|
6
|
+
const config = ['gatsby-{config,node}.{js,mjs,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,mjs,jsx,ts,tsx}'];
|
|
7
7
|
const production = [
|
|
8
8
|
'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
|
|
9
9
|
'src/api/**/*.{js,ts}',
|
|
@@ -4,7 +4,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
4
4
|
const title = 'Mocha';
|
|
5
5
|
const enablers = ['mocha'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
-
const config = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
|
|
7
|
+
const config = ['.mocharc.{js,cjs,mjs,json,jsonc,yml,yaml}', 'package.json'];
|
|
8
8
|
const entry = ['**/test/*.{js,cjs,mjs}'];
|
|
9
9
|
const defaultExtensions = ['js', 'cjs', 'mjs'];
|
|
10
10
|
const builtInReporters = new Set([
|
|
@@ -7,7 +7,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
7
7
|
const packageJsonPath = 'npmpackagejsonlint';
|
|
8
8
|
const config = ['package.json', ...toCosmiconfig('npmpackagejsonlint')];
|
|
9
9
|
const resolveConfig = localConfig => {
|
|
10
|
-
return localConfig?.extends ? [localConfig.extends].map(id => toDependency(id)) : [];
|
|
10
|
+
return localConfig?.extends ? [localConfig.extends].flat().map(id => toDependency(id)) : [];
|
|
11
11
|
};
|
|
12
12
|
const plugin = {
|
|
13
13
|
title,
|
|
@@ -8,34 +8,31 @@ const title = 'React Router';
|
|
|
8
8
|
const enablers = ['@react-router/dev'];
|
|
9
9
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
10
10
|
const viteConfig = typeof vite.config === 'function' ? [] : (vite.config ?? []);
|
|
11
|
-
const
|
|
11
|
+
const entryExts = ['js', 'jsx', 'ts', 'tsx', 'mjs', 'mts'];
|
|
12
|
+
const entryExtsGlob = `{${entryExts.join(',')}}`;
|
|
13
|
+
const config = [`react-router.config.${entryExtsGlob}`, ...viteConfig];
|
|
12
14
|
const resolveConfig = async (localConfig, options) => {
|
|
13
15
|
const { configFileDir } = options;
|
|
14
16
|
const appDirectory = localConfig.appDirectory ?? 'app';
|
|
15
17
|
const appDir = toAbsolute(appDirectory, configFileDir);
|
|
16
18
|
globalThis.__reactRouterAppDirectory = appDir;
|
|
17
19
|
let routeConfig = [];
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
routeConfig = await load(routesPathTs);
|
|
22
|
-
}
|
|
23
|
-
else if (existsSync(routesPathJs)) {
|
|
24
|
-
routeConfig = await load(routesPathJs);
|
|
25
|
-
}
|
|
20
|
+
const routesPath = entryExts.map(ext => join(appDir, `routes.${ext}`)).find(existsSync);
|
|
21
|
+
if (routesPath)
|
|
22
|
+
routeConfig = await load(routesPath);
|
|
26
23
|
const mapRoute = (route) => {
|
|
27
24
|
return [toAbsolute(route.file, appDir), ...(route.children ? route.children.flatMap(mapRoute) : [])];
|
|
28
25
|
};
|
|
29
26
|
const routes = routeConfig.flatMap(mapRoute);
|
|
30
27
|
const resolved = [
|
|
31
|
-
toEntry(join(appDir,
|
|
32
|
-
toProductionEntry(join(appDir,
|
|
33
|
-
toProductionEntry(join(appDir,
|
|
28
|
+
toEntry(join(appDir, `routes.${entryExtsGlob}`)),
|
|
29
|
+
toProductionEntry(join(appDir, `root.${entryExtsGlob}`)),
|
|
30
|
+
toProductionEntry(join(appDir, `entry.{client,server}.${entryExtsGlob}`)),
|
|
34
31
|
...routes.map(id => toProductionEntry(id)),
|
|
35
32
|
];
|
|
36
33
|
const serverEntries = await _glob({
|
|
37
34
|
cwd: appDir,
|
|
38
|
-
patterns: [
|
|
35
|
+
patterns: [`entry.server.${entryExtsGlob}`],
|
|
39
36
|
});
|
|
40
37
|
if (serverEntries.length === 0) {
|
|
41
38
|
resolved.push(toProductionDependency('@react-router/node'));
|
|
@@ -5,7 +5,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
5
5
|
const title = 'Relay';
|
|
6
6
|
const enablers = ['vite-plugin-relay', '@swc/plugin-relay', 'babel-plugin-relay'];
|
|
7
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
|
-
const config = ['relay.config.json', 'relay.config.js'];
|
|
8
|
+
const config = ['package.json', 'relay.config.json', 'relay.config.js'];
|
|
9
9
|
const resolveConfig = async (config) => {
|
|
10
10
|
const projects = 'projects' in config ? Object.values(config.projects) : [config];
|
|
11
11
|
return projects.map(project => {
|
|
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'Release It!';
|
|
4
4
|
const enablers = ['release-it'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['.release-it.{json,js,cjs,ts,yml,yaml,toml}', 'package.json'];
|
|
6
|
+
const config = ['.release-it.{json,jsonc,json5,js,mjs,cjs,ts,mts,cts,yml,yaml,toml}', 'package.json'];
|
|
7
7
|
const resolveConfig = (config, options) => {
|
|
8
8
|
const plugins = config.plugins ? Object.keys(config.plugins) : [];
|
|
9
9
|
const scripts = config.hooks ? Object.values(config.hooks).flat() : [];
|