knip 6.46.0 → 6.47.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 +2 -0
- package/dist/IssueFixer.js +2 -6
- package/dist/WorkspaceWorker.d.ts +1 -0
- package/dist/WorkspaceWorker.js +10 -6
- package/dist/compilers/mdx.js +7 -1
- package/dist/plugins/angular/helpers.d.ts +7 -0
- package/dist/plugins/angular/helpers.js +58 -0
- package/dist/plugins/angular/index.js +5 -50
- package/dist/plugins/angular/types.d.ts +2 -2
- package/dist/plugins/astro/index.js +6 -1
- package/dist/plugins/astro-og-canvas/index.js +1 -1
- package/dist/plugins/capacitor/index.js +1 -1
- package/dist/plugins/cucumber/index.js +19 -7
- package/dist/plugins/cucumber/types.d.ts +1 -0
- package/dist/plugins/cypress/index.js +5 -0
- package/dist/plugins/docusaurus/helpers.js +2 -2
- package/dist/plugins/drizzle/index.js +5 -0
- package/dist/plugins/github-action/index.js +13 -3
- package/dist/plugins/github-actions/index.d.ts +2 -1
- package/dist/plugins/github-actions/index.js +4 -2
- package/dist/plugins/github-actions/types.d.ts +5 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/mocha/index.js +6 -0
- package/dist/plugins/mocha/types.d.ts +3 -0
- package/dist/plugins/netlify/index.js +1 -1
- package/dist/plugins/node/index.d.ts +2 -2
- package/dist/plugins/node/index.js +14 -3
- package/dist/plugins/nx/index.js +14 -1
- package/dist/plugins/oclif/index.js +3 -1
- package/dist/plugins/plop/index.js +4 -0
- package/dist/plugins/prisma/index.js +2 -0
- package/dist/plugins/quasar/resolveFromAST.js +2 -2
- package/dist/plugins/react-native/index.js +1 -1
- package/dist/plugins/rollup/index.js +1 -1
- package/dist/plugins/sst/resolveFromAST.js +24 -15
- package/dist/plugins/start-server-and-test/index.d.ts +3 -0
- package/dist/plugins/start-server-and-test/index.js +10 -0
- package/dist/plugins/swc/index.js +7 -4
- package/dist/plugins/trigger-dev/index.d.ts +3 -0
- package/dist/plugins/trigger-dev/index.js +28 -0
- package/dist/plugins/tsx/index.js +1 -1
- package/dist/plugins/typedoc/index.js +5 -2
- package/dist/plugins/typescript/index.d.ts +12 -1
- package/dist/plugins/typescript/index.js +6 -3
- package/dist/plugins/vite-plus/index.d.ts +4 -1
- package/dist/plugins/vite-plus/index.js +19 -4
- package/dist/plugins/vite-plus/types.d.ts +12 -0
- package/dist/plugins/vite-plus/types.js +1 -0
- package/dist/plugins/vitepress/index.js +14 -0
- package/dist/plugins/vitest/index.js +5 -0
- package/dist/plugins/vitest/types.d.ts +2 -1
- package/dist/plugins/web-test-runner/index.js +8 -2
- package/dist/plugins/webpack/index.js +5 -7
- package/dist/plugins/wrangler/index.js +4 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +2 -0
- package/dist/util/create-input-handler.js +3 -1
- package/dist/util/remove-export.d.ts +1 -0
- package/dist/util/remove-export.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +8 -0
- package/dist/plugins/vite-plus/resolveFromAST.d.ts +0 -2
- package/dist/plugins/vite-plus/resolveFromAST.js +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toEntry } from '../../util/input.js';
|
|
1
|
+
import { toEntry, toModule } from '../../util/input.js';
|
|
2
2
|
import { createFsPromisesGlobVisitor } from './visitors/fsPromisesGlob.js';
|
|
3
3
|
const title = 'Node.js';
|
|
4
4
|
const isEnabled = () => true;
|
|
@@ -21,6 +21,7 @@ const hasNodeTest = (scripts, cwd, getScriptCommands) => {
|
|
|
21
21
|
return result;
|
|
22
22
|
};
|
|
23
23
|
const entry = ['server.js'];
|
|
24
|
+
const builtInReporters = new Set(['spec', 'tap', 'dot', 'junit', 'lcov']);
|
|
24
25
|
const registerVisitors = ({ ctx, registerVisitor }) => {
|
|
25
26
|
registerVisitor(createFsPromisesGlobVisitor(ctx));
|
|
26
27
|
};
|
|
@@ -41,7 +42,6 @@ const toScripts = (parsed) => {
|
|
|
41
42
|
export const args = {
|
|
42
43
|
positional: toScripts,
|
|
43
44
|
nodeImportArgs: true,
|
|
44
|
-
resolve: ['test-reporter'],
|
|
45
45
|
string: [
|
|
46
46
|
'allow-fs-read',
|
|
47
47
|
'allow-fs-write',
|
|
@@ -101,6 +101,7 @@ export const args = {
|
|
|
101
101
|
'test-isolation',
|
|
102
102
|
'test-name-pattern',
|
|
103
103
|
'test-random-seed',
|
|
104
|
+
'test-reporter',
|
|
104
105
|
'test-reporter-destination',
|
|
105
106
|
'test-rerun-failures',
|
|
106
107
|
'test-shard',
|
|
@@ -121,7 +122,17 @@ export const args = {
|
|
|
121
122
|
alias: { conditions: ['C'], eval: ['e'], print: ['p'] },
|
|
122
123
|
boolean: true,
|
|
123
124
|
stopEarly: true,
|
|
124
|
-
|
|
125
|
+
resolveInputs: (parsed) => {
|
|
126
|
+
const reporters = parsed['test-reporter'];
|
|
127
|
+
if (!reporters)
|
|
128
|
+
return [];
|
|
129
|
+
const inputs = [];
|
|
130
|
+
for (const reporter of Array.isArray(reporters) ? reporters : [reporters]) {
|
|
131
|
+
if (typeof reporter === 'string' && reporter && !builtInReporters.has(reporter))
|
|
132
|
+
inputs.push(toModule(reporter));
|
|
133
|
+
}
|
|
134
|
+
return inputs;
|
|
135
|
+
},
|
|
125
136
|
};
|
|
126
137
|
const plugin = {
|
|
127
138
|
title,
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -5,10 +5,17 @@ import { get } from '../../util/object.js';
|
|
|
5
5
|
import { dirname, isInternal, join, relative, toAbsolute } from '../../util/path.js';
|
|
6
6
|
import { hasDependency } from '../../util/plugin.js';
|
|
7
7
|
import { substringBefore } from '../../util/string.js';
|
|
8
|
+
import { getBuilderEntries } from '../angular/helpers.js';
|
|
8
9
|
const title = 'Nx';
|
|
9
10
|
const enablers = ['nx', /^@nrwl\//, /^@nx\//];
|
|
10
11
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
11
12
|
const config = ['nx.json', 'project.json', '{apps,libs}/**/project.json', 'package.json'];
|
|
13
|
+
const angularBuilderPackages = new Set([
|
|
14
|
+
'@angular-devkit/build-angular',
|
|
15
|
+
'@angular/build',
|
|
16
|
+
'@nrwl/angular',
|
|
17
|
+
'@nx/angular',
|
|
18
|
+
]);
|
|
12
19
|
const findNxDependenciesInNxJson = async (localConfig) => {
|
|
13
20
|
const targetsDefault = localConfig.targetDefaults
|
|
14
21
|
? Object.keys(localConfig.targetDefaults)
|
|
@@ -88,7 +95,13 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
88
95
|
}
|
|
89
96
|
return configs;
|
|
90
97
|
});
|
|
91
|
-
|
|
98
|
+
const angularBuilderInputs = [];
|
|
99
|
+
for (const [targetName, target] of Object.entries(config.targets ?? {})) {
|
|
100
|
+
if (target.executor && angularBuilderPackages.has(substringBefore(target.executor, ':'))) {
|
|
101
|
+
angularBuilderInputs.push(...getBuilderEntries(targetName, target, options.rootCwd, expand));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return compact([...executors, ...inputs, ...configInputs, ...angularBuilderInputs]).map(id => typeof id === 'string' ? toDependency(id) : id);
|
|
92
105
|
};
|
|
93
106
|
const collections = [
|
|
94
107
|
['generators', 'schematics'],
|
|
@@ -9,7 +9,9 @@ const resolveConfig = async (config) => {
|
|
|
9
9
|
if (!config)
|
|
10
10
|
return [];
|
|
11
11
|
const inputs = production.map(id => toEntry(id, { production: true }));
|
|
12
|
-
for (const id of
|
|
12
|
+
for (const id of config.plugins ?? [])
|
|
13
|
+
inputs.push(toDependency(id, { production: true }));
|
|
14
|
+
for (const id of config.devPlugins ?? [])
|
|
13
15
|
inputs.push(toDependency(id));
|
|
14
16
|
return inputs;
|
|
15
17
|
};
|
|
@@ -3,10 +3,14 @@ const title = 'Plop';
|
|
|
3
3
|
const enablers = ['plop'];
|
|
4
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
5
|
const entry = ['plopfile.{cjs,mjs,js,ts}'];
|
|
6
|
+
const args = {
|
|
7
|
+
config: ['plopfile'],
|
|
8
|
+
};
|
|
6
9
|
const plugin = {
|
|
7
10
|
title,
|
|
8
11
|
enablers,
|
|
9
12
|
isEnabled,
|
|
10
13
|
entry,
|
|
14
|
+
args,
|
|
11
15
|
};
|
|
12
16
|
export default plugin;
|
|
@@ -26,6 +26,8 @@ const resolveConfig = async (config, options) => {
|
|
|
26
26
|
else if (config.migrations?.seed) {
|
|
27
27
|
inputs.push(...options.getInputsFromScripts(config.migrations.seed));
|
|
28
28
|
}
|
|
29
|
+
for (const input of inputs)
|
|
30
|
+
input.dir ??= options.cwd;
|
|
29
31
|
if (config.schema) {
|
|
30
32
|
inputs.push(resolveSchema(config.schema, options.configFileDir));
|
|
31
33
|
}
|
|
@@ -53,14 +53,14 @@ export const resolveFromAST = (program, options) => {
|
|
|
53
53
|
if (!id)
|
|
54
54
|
continue;
|
|
55
55
|
if (id.startsWith('~'))
|
|
56
|
-
inputs.push(toDependency(id.slice(1)));
|
|
56
|
+
inputs.push(toDependency(id.slice(1), { production: true }));
|
|
57
57
|
else
|
|
58
58
|
inputs.push(toEntryPath(join(configFileDir, 'src/boot', id), { production: true }));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
for (const id of getStringValues(findProperty(config, 'css'))) {
|
|
62
62
|
if (id.startsWith('~'))
|
|
63
|
-
inputs.push(toDependency(id.slice(1)));
|
|
63
|
+
inputs.push(toDependency(id.slice(1), { production: true }));
|
|
64
64
|
else
|
|
65
65
|
inputs.push(toEntryPath(join(configFileDir, 'src/css', id), { production: true }));
|
|
66
66
|
}
|
|
@@ -19,7 +19,7 @@ const resolveConfig = async (config) => {
|
|
|
19
19
|
if (config.platforms) {
|
|
20
20
|
for (const platform of Object.values(config.platforms)) {
|
|
21
21
|
if (platform.npmPackageName)
|
|
22
|
-
inputs.push(toDependency(platform.npmPackageName));
|
|
22
|
+
inputs.push(toDependency(platform.npmPackageName, { production: true }));
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
return inputs;
|
|
@@ -7,7 +7,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
7
7
|
const config = ['rollup.config.{js,cjs,mjs,ts}'];
|
|
8
8
|
const args = {
|
|
9
9
|
alias: { plugin: ['p'] },
|
|
10
|
-
config:
|
|
10
|
+
config: true,
|
|
11
11
|
args: (args) => args.map(arg => (arg.startsWith('--watch.onEnd') ? `--_exec${arg.slice(13)}` : arg)),
|
|
12
12
|
fromArgs: ['_exec'],
|
|
13
13
|
resolve: ['plugin', 'configPlugin'],
|
|
@@ -6,42 +6,51 @@ import { dirname } from '../../util/path.js';
|
|
|
6
6
|
import { _resolveSync } from '../../util/resolve.js';
|
|
7
7
|
export const resolveFromAST = (program, options) => {
|
|
8
8
|
const entries = new Set();
|
|
9
|
+
const addHandler = (specifier) => entries.add(specifier.substring(0, specifier.lastIndexOf('.')));
|
|
9
10
|
const addHandlers = (values) => {
|
|
10
11
|
for (const specifier of values)
|
|
11
|
-
|
|
12
|
+
addHandler(specifier);
|
|
13
|
+
};
|
|
14
|
+
const parseImport = (specifier) => {
|
|
15
|
+
const filePath = _resolveSync(specifier, dirname(options.configFilePath));
|
|
16
|
+
const text = filePath ? options.readFile(filePath) : undefined;
|
|
17
|
+
return filePath && text ? _parseFile(filePath, text).program : undefined;
|
|
12
18
|
};
|
|
13
19
|
try {
|
|
14
20
|
const importMap = getImportMap(program);
|
|
21
|
+
const dynamicImports = [];
|
|
15
22
|
addHandlers(collectPropertyValues(program, 'handler'));
|
|
16
23
|
const visitor = new Visitor({
|
|
24
|
+
ImportExpression(node) {
|
|
25
|
+
const source = node.source;
|
|
26
|
+
if (source.type === 'Literal' && typeof source.value === 'string' && source.value.startsWith('.'))
|
|
27
|
+
dynamicImports.push(source.value);
|
|
28
|
+
},
|
|
17
29
|
CallExpression(node) {
|
|
18
30
|
if (node.callee?.type !== 'MemberExpression')
|
|
19
31
|
return;
|
|
20
32
|
const propName = !node.callee.computed ? node.callee.property?.name : undefined;
|
|
21
33
|
if (propName === 'stack') {
|
|
22
34
|
const arg = node.arguments?.[0];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (resolvedPath) {
|
|
28
|
-
const stackText = options.readFile(resolvedPath);
|
|
29
|
-
if (stackText) {
|
|
30
|
-
const stackResult = _parseFile('stack.ts', stackText);
|
|
31
|
-
addHandlers(collectPropertyValues(stackResult.program, 'handler'));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
35
|
+
const importPath = arg?.type === 'Identifier' ? importMap.get(arg.name) : undefined;
|
|
36
|
+
const stack = importPath ? parseImport(importPath) : undefined;
|
|
37
|
+
if (stack)
|
|
38
|
+
addHandlers(collectPropertyValues(stack, 'handler'));
|
|
36
39
|
}
|
|
37
40
|
if (propName === 'route' && node.arguments?.length >= 2) {
|
|
38
41
|
const handlerArg = node.arguments[1];
|
|
39
42
|
if (handlerArg?.type === 'Literal' && typeof handlerArg.value === 'string')
|
|
40
|
-
|
|
43
|
+
addHandler(handlerArg.value);
|
|
41
44
|
}
|
|
42
45
|
},
|
|
43
46
|
});
|
|
44
47
|
visitor.visit(program);
|
|
48
|
+
for (const infra of dynamicImports.map(parseImport)) {
|
|
49
|
+
if (!infra)
|
|
50
|
+
continue;
|
|
51
|
+
addHandlers(collectPropertyValues(infra, 'handler'));
|
|
52
|
+
visitor.visit(infra);
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
catch { }
|
|
47
56
|
return Array.from(entries).map(specifier => toEntryPath(specifier, { production: true }));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const title = 'start-server-and-test';
|
|
2
|
+
const args = {
|
|
3
|
+
binaries: ['server-test', 'start-server-and-test', 'start-test'],
|
|
4
|
+
fromArgs: parsed => [...parsed._, ...(parsed['--'] ?? [])].filter(arg => typeof arg === 'string' && arg.includes(' ')).join('\n'),
|
|
5
|
+
};
|
|
6
|
+
const plugin = {
|
|
7
|
+
title,
|
|
8
|
+
args,
|
|
9
|
+
};
|
|
10
|
+
export default plugin;
|
|
@@ -7,14 +7,17 @@ const enablers = ['@swc/core'];
|
|
|
7
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
8
|
const config = ['.swcrc'];
|
|
9
9
|
const resolveConfig = async (config, options) => {
|
|
10
|
-
const
|
|
10
|
+
const plugins = [];
|
|
11
|
+
const inputs = [];
|
|
11
12
|
for (const item of [config].flat()) {
|
|
12
13
|
for (const [id] of item?.jsc?.experimental?.plugins ?? [])
|
|
13
|
-
|
|
14
|
+
plugins.push(id);
|
|
14
15
|
if (item?.jsc?.externalHelpers)
|
|
15
|
-
|
|
16
|
+
inputs.push(toDependency('@swc/helpers', { production: true }));
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
for (const id of compact(plugins))
|
|
19
|
+
inputs.push(isInternal(id) ? toModule(id, { dir: options.cwd }) : toDependency(id));
|
|
20
|
+
return inputs;
|
|
18
21
|
};
|
|
19
22
|
const plugin = {
|
|
20
23
|
title,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { collectPropertyValues } from '../../typescript/ast-helpers.js';
|
|
2
|
+
import { toEntry } from '../../util/input.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
const title = 'Trigger.dev';
|
|
5
|
+
const enablers = ['@trigger.dev/sdk'];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = ['trigger.config.{js,cjs,mjs,ts,cts,mts}'];
|
|
8
|
+
const extensions = '{ts,tsx,mts,cts,js,jsx,mjs,cjs}';
|
|
9
|
+
const defaultDir = '**/trigger';
|
|
10
|
+
const getProductionPatterns = (dirs) => [
|
|
11
|
+
...Array.from(dirs, dir => `${dir}/**/*.${extensions}`),
|
|
12
|
+
'!**/*.{test,spec}.{ts,mts,cts,js,mjs,cjs}',
|
|
13
|
+
];
|
|
14
|
+
const production = getProductionPatterns([defaultDir]);
|
|
15
|
+
const resolveFromAST = (program, { configFileDir }) => {
|
|
16
|
+
const dirs = collectPropertyValues(program, 'dirs');
|
|
17
|
+
const patterns = dirs.size > 0 ? getProductionPatterns(dirs) : production;
|
|
18
|
+
return patterns.map(pattern => toEntry(pattern, { dir: configFileDir, production: true }));
|
|
19
|
+
};
|
|
20
|
+
const plugin = {
|
|
21
|
+
title,
|
|
22
|
+
enablers,
|
|
23
|
+
isEnabled,
|
|
24
|
+
config,
|
|
25
|
+
production,
|
|
26
|
+
resolveFromAST,
|
|
27
|
+
};
|
|
28
|
+
export default plugin;
|
|
@@ -23,7 +23,7 @@ const resolveConfig = localConfig => {
|
|
|
23
23
|
const args = {
|
|
24
24
|
...nodeArgs,
|
|
25
25
|
string: [...nodeArgs.string, 'exclude', 'ignore', 'include', 'tsconfig'],
|
|
26
|
-
args: (args) =>
|
|
26
|
+
args: (args) => (args[0] === 'watch' ? args.slice(1) : args),
|
|
27
27
|
};
|
|
28
28
|
const plugin = {
|
|
29
29
|
title,
|
|
@@ -14,10 +14,11 @@ const config = [
|
|
|
14
14
|
'package.json',
|
|
15
15
|
'tsconfig.json',
|
|
16
16
|
];
|
|
17
|
+
const getThemes = (theme) => arrayify(theme).filter(name => name !== 'default');
|
|
17
18
|
const resolveConfig = (config, options) => {
|
|
18
19
|
const cfg = 'typedocOptions' in config ? config.typedocOptions : config;
|
|
19
20
|
const plugins = arrayify(cfg?.plugin);
|
|
20
|
-
const themes =
|
|
21
|
+
const themes = getThemes(cfg?.theme);
|
|
21
22
|
const inputs = [...plugins, ...themes].map(id => toModule(id));
|
|
22
23
|
for (const file of [cfg?.customCss, cfg?.customJs]) {
|
|
23
24
|
if (file)
|
|
@@ -27,7 +28,9 @@ const resolveConfig = (config, options) => {
|
|
|
27
28
|
};
|
|
28
29
|
const args = {
|
|
29
30
|
config: ['options'],
|
|
30
|
-
resolve: ['plugin'
|
|
31
|
+
resolve: ['plugin'],
|
|
32
|
+
string: ['theme'],
|
|
33
|
+
resolveInputs: (parsed) => getThemes(parsed.theme).map(id => toModule(id)),
|
|
31
34
|
};
|
|
32
35
|
const plugin = {
|
|
33
36
|
title,
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import type { Plugin, ResolveConfig } from '../../types/config.ts';
|
|
2
2
|
import type { TsConfigJson } from '../../types/tsconfig-json.ts';
|
|
3
|
+
import type { ParsedArgs } from '../../util/parse-args.ts';
|
|
3
4
|
export declare const config: string[];
|
|
4
5
|
export declare const resolveConfig: ResolveConfig<TsConfigJson>;
|
|
6
|
+
declare const toConfigPath: (p: string) => string;
|
|
5
7
|
export declare const args: {
|
|
6
8
|
binaries: string[];
|
|
7
9
|
string: string[];
|
|
10
|
+
boolean: string[];
|
|
8
11
|
alias: {
|
|
9
12
|
project: string[];
|
|
13
|
+
build: string[];
|
|
14
|
+
verbose: string[];
|
|
15
|
+
dry: string[];
|
|
16
|
+
force: string[];
|
|
17
|
+
watch: string[];
|
|
10
18
|
};
|
|
11
|
-
config: [string,
|
|
19
|
+
config: [string, typeof toConfigPath][];
|
|
20
|
+
resolveInputs: (parsed: ParsedArgs, { cwd }: {
|
|
21
|
+
cwd: string;
|
|
22
|
+
}) => import("../../util/input.ts").ConfigInput[];
|
|
12
23
|
};
|
|
13
24
|
export declare const docs: {
|
|
14
25
|
note: string;
|
|
@@ -27,7 +27,7 @@ export const resolveConfig = (localConfig, options) => {
|
|
|
27
27
|
if (!(compilerOptions && localConfig))
|
|
28
28
|
return compact([...contentMappers, ...extend, ...references]);
|
|
29
29
|
const jsx = (compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : []).map(id => toDependency(id, { production: true, dir: options.cwd, alsoReferenceOwner: true }));
|
|
30
|
-
const types = compilerOptions.types ?? [];
|
|
30
|
+
const types = compilerOptions.types?.filter(id => id !== '*') ?? [];
|
|
31
31
|
const plugins = Array.isArray(compilerOptions?.plugins)
|
|
32
32
|
? compilerOptions.plugins.map(plugin => (typeof plugin === 'object' && 'name' in plugin ? plugin.name : ''))
|
|
33
33
|
: [];
|
|
@@ -42,11 +42,14 @@ export const resolveConfig = (localConfig, options) => {
|
|
|
42
42
|
...jsx,
|
|
43
43
|
]);
|
|
44
44
|
};
|
|
45
|
+
const toConfigPath = (p) => (p.endsWith('.json') ? p : join(p, 'tsconfig.json'));
|
|
45
46
|
export const args = {
|
|
46
47
|
binaries: ['tsc', 'tsgo'],
|
|
47
48
|
string: ['project'],
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
boolean: ['build', 'clean', 'dry', 'force', 'stopBuildOnErrors'],
|
|
50
|
+
alias: { project: ['p'], build: ['b'], verbose: ['v'], dry: ['d'], force: ['f'], watch: ['w'] },
|
|
51
|
+
config: [['project', toConfigPath]],
|
|
52
|
+
resolveInputs: (parsed, { cwd }) => parsed.build ? parsed._.map(String).map(p => toConfig('typescript', toConfigPath(p), { dir: cwd })) : [],
|
|
50
53
|
};
|
|
51
54
|
const note = `[What's up with that configurable tsconfig.json location?](/reference/faq#whats-up-with-that-configurable-tsconfigjson-location)`;
|
|
52
55
|
export const docs = { note };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type { Plugin } from '../../types/config.ts';
|
|
1
|
+
import type { Plugin, PluginOptions } from '../../types/config.ts';
|
|
2
|
+
import type { Input } from '../../util/input.ts';
|
|
3
|
+
import type { VitePlusConfig } from './types.ts';
|
|
4
|
+
export declare const getTaskInputs: (configs: VitePlusConfig[], options: PluginOptions) => Input[];
|
|
2
5
|
declare const plugin: Plugin;
|
|
3
6
|
export default plugin;
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
-
import { resolveFromAST } from './resolveFromAST.js';
|
|
3
2
|
const title = 'vite-plus';
|
|
4
3
|
const enablers = ['vite-plus'];
|
|
5
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const
|
|
5
|
+
const entry = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
6
|
+
export const getTaskInputs = (configs, options) => {
|
|
7
|
+
const commands = new Set();
|
|
8
|
+
const addCommands = (value) => {
|
|
9
|
+
for (const command of [value].flat())
|
|
10
|
+
if (typeof command === 'string')
|
|
11
|
+
commands.add(command);
|
|
12
|
+
};
|
|
13
|
+
for (const { run, staged } of configs) {
|
|
14
|
+
for (const task of Object.values(run?.tasks ?? {})) {
|
|
15
|
+
addCommands(typeof task === 'string' || Array.isArray(task) ? task : task.command);
|
|
16
|
+
}
|
|
17
|
+
if (typeof staged === 'object')
|
|
18
|
+
for (const command of Object.values(staged))
|
|
19
|
+
addCommands(command);
|
|
20
|
+
}
|
|
21
|
+
return options.getInputsFromScripts(commands, { optionalBinaries: true });
|
|
22
|
+
};
|
|
7
23
|
const plugin = {
|
|
8
24
|
title,
|
|
9
25
|
enablers,
|
|
10
26
|
isEnabled,
|
|
11
|
-
|
|
12
|
-
resolveFromAST,
|
|
27
|
+
entry,
|
|
13
28
|
};
|
|
14
29
|
export default plugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LintStagedConfig } from '../lint-staged/types.ts';
|
|
2
|
+
type Command = string | string[];
|
|
3
|
+
type Task = {
|
|
4
|
+
command: Command;
|
|
5
|
+
};
|
|
6
|
+
export type VitePlusConfig = {
|
|
7
|
+
run?: {
|
|
8
|
+
tasks?: Record<string, Task | Command>;
|
|
9
|
+
};
|
|
10
|
+
staged?: LintStagedConfig;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { toEntry } from '../../util/input.js';
|
|
2
|
+
import { join } from '../../util/path.js';
|
|
1
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
4
|
const title = 'VitePress';
|
|
3
5
|
const enablers = ['vitepress'];
|
|
@@ -7,10 +9,22 @@ const entry = [
|
|
|
7
9
|
'.vitepress/config/index.{js,ts,mjs,mts,cjs,cts}',
|
|
8
10
|
'.vitepress/theme/index.{js,ts,mjs,mts}',
|
|
9
11
|
];
|
|
12
|
+
const commands = new Set(['dev', 'build', 'preview', 'serve']);
|
|
13
|
+
const args = {
|
|
14
|
+
resolveInputs: parsed => {
|
|
15
|
+
const [command, root] = parsed._;
|
|
16
|
+
const inputs = [];
|
|
17
|
+
if (root && commands.has(command))
|
|
18
|
+
for (const pattern of entry)
|
|
19
|
+
inputs.push(toEntry(join(root, pattern)));
|
|
20
|
+
return inputs;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
10
23
|
const plugin = {
|
|
11
24
|
title,
|
|
12
25
|
enablers,
|
|
13
26
|
isEnabled,
|
|
14
27
|
entry,
|
|
28
|
+
args,
|
|
15
29
|
};
|
|
16
30
|
export default plugin;
|
|
@@ -7,6 +7,7 @@ import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
|
7
7
|
import { basename, isAbsolute, isInternal, join, toAbsolute, toPosix } from '../../util/path.js';
|
|
8
8
|
import { hasDependency } from '../../util/plugin.js';
|
|
9
9
|
import { resolveExtendedConfig } from '../oxlint/index.js';
|
|
10
|
+
import { getTaskInputs } from '../vite-plus/index.js';
|
|
10
11
|
import { getHtmlScriptEntries, getIndexHtmlEntries } from '../vite/helpers.js';
|
|
11
12
|
import { getAliasInputs, getExternalReporters, toEnvDependency } from './helpers.js';
|
|
12
13
|
import { createVitestMockVisitor } from './visitors/mock.js';
|
|
@@ -112,6 +113,10 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
112
113
|
const lintInputs = [];
|
|
113
114
|
inputs.add(toEntry(join(options.cwd, 'src/vite-env.d.ts')));
|
|
114
115
|
const configs = await getConfigs(localConfig);
|
|
116
|
+
if (options.enabledPlugins.includes('vite-plus')) {
|
|
117
|
+
for (const input of getTaskInputs(configs, options))
|
|
118
|
+
inputs.add(input);
|
|
119
|
+
}
|
|
115
120
|
const patterns = new Set();
|
|
116
121
|
for (const cfg of configs) {
|
|
117
122
|
for (const project of cfg.test?.projects ?? []) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OxlintConfig } from '../oxlint/types.ts';
|
|
2
|
+
import type { VitePlusConfig } from '../vite-plus/types.ts';
|
|
2
3
|
interface Alias {
|
|
3
4
|
find: string | RegExp;
|
|
4
5
|
replacement: string;
|
|
@@ -34,7 +35,7 @@ interface VitestConfig {
|
|
|
34
35
|
alias?: AliasOptions;
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
|
-
export interface ViteConfig extends VitestConfig {
|
|
38
|
+
export interface ViteConfig extends VitestConfig, VitePlusConfig {
|
|
38
39
|
lint?: OxlintConfig;
|
|
39
40
|
extends?: string | true;
|
|
40
41
|
root?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findProperty, getPropertyValues, resolveObjectArg } from '../../typescript/ast-helpers.js';
|
|
2
|
-
import { toEntry } from '../../util/input.js';
|
|
2
|
+
import { toDependency, toEntry } from '../../util/input.js';
|
|
3
3
|
import { toAbsolute } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
5
|
const title = 'Web Test Runner';
|
|
@@ -73,7 +73,13 @@ const args = {
|
|
|
73
73
|
'update-snapshots',
|
|
74
74
|
'watch',
|
|
75
75
|
],
|
|
76
|
-
resolveInputs: (parsed, { cwd }) =>
|
|
76
|
+
resolveInputs: (parsed, { cwd }) => {
|
|
77
|
+
const inputs = toFileEntries([...parsed._, ...(parsed['--'] ?? []), ...[parsed.files ?? []].flat()].map(String), cwd);
|
|
78
|
+
const launcher = parsed.puppeteer ? 'puppeteer' : parsed.playwright ? 'playwright' : undefined;
|
|
79
|
+
if (launcher)
|
|
80
|
+
inputs.push(toDependency(`@web/test-runner-${launcher}`));
|
|
81
|
+
return inputs;
|
|
82
|
+
},
|
|
77
83
|
};
|
|
78
84
|
const plugin = {
|
|
79
85
|
title,
|
|
@@ -41,8 +41,7 @@ const resolveRuleSetDependencies = (rule) => {
|
|
|
41
41
|
if (typeof useItem === 'function')
|
|
42
42
|
useItem = useItem(info);
|
|
43
43
|
if (typeof useItem === 'string' && hasBabelOptions(rule)) {
|
|
44
|
-
|
|
45
|
-
return [useItem, ...d];
|
|
44
|
+
return [useItem, ...getDependenciesFromConfig(rule.options)];
|
|
46
45
|
}
|
|
47
46
|
if (typeof useItem === 'string' && useItem && rule.options && rule.use == null)
|
|
48
47
|
useItem = { loader: useItem, options: rule.options };
|
|
@@ -50,8 +49,7 @@ const resolveRuleSetDependencies = (rule) => {
|
|
|
50
49
|
if (!item)
|
|
51
50
|
return [];
|
|
52
51
|
if (hasBabelOptions(item)) {
|
|
53
|
-
|
|
54
|
-
return [...resolveUseItem(item), ...d];
|
|
52
|
+
return [...resolveUseItem(item), ...getDependenciesFromConfig(item.options)];
|
|
55
53
|
}
|
|
56
54
|
if (typeof item !== 'string' && 'oneOf' in item)
|
|
57
55
|
return item.oneOf?.flatMap(resolveRuleSetDependencies) ?? [];
|
|
@@ -97,7 +95,7 @@ export const findWebpackDependenciesFromConfig = async (config, options) => {
|
|
|
97
95
|
for (const opts of [resolvedConfig].flat()) {
|
|
98
96
|
const entries = [];
|
|
99
97
|
for (const loader of opts.module?.rules?.flatMap(resolveRuleSetDependencies) ?? []) {
|
|
100
|
-
inputs.add(toModule(loader.replace(/\?.*/, '')));
|
|
98
|
+
inputs.add(typeof loader === 'string' ? toModule(loader.replace(/\?.*/, '')) : loader);
|
|
101
99
|
}
|
|
102
100
|
for (const plugin of opts?.plugins ?? []) {
|
|
103
101
|
if (plugin && plugin.constructor.name === 'ProvidePlugin') {
|
|
@@ -105,7 +103,7 @@ export const findWebpackDependenciesFromConfig = async (config, options) => {
|
|
|
105
103
|
if (providePluginInstance.definitions) {
|
|
106
104
|
for (const values of Object.values(providePluginInstance.definitions)) {
|
|
107
105
|
const specifier = typeof values === 'string' ? values : values[0];
|
|
108
|
-
inputs.add(toModule(specifier));
|
|
106
|
+
inputs.add(toModule(specifier, { production: isProduction }));
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
109
|
}
|
|
@@ -135,7 +133,7 @@ export const findWebpackDependenciesFromConfig = async (config, options) => {
|
|
|
135
133
|
inputs.add(toEntryPath(entry, { production: isProduction, dir }));
|
|
136
134
|
}
|
|
137
135
|
else {
|
|
138
|
-
inputs.add(toModule(entry));
|
|
136
|
+
inputs.add(toModule(entry, { production: isProduction }));
|
|
139
137
|
}
|
|
140
138
|
}
|
|
141
139
|
const processAlias = (aliases) => {
|
|
@@ -7,11 +7,15 @@ const config = ['wrangler.{json,jsonc,toml}'];
|
|
|
7
7
|
const resolveConfig = async (config) => {
|
|
8
8
|
return (config.main ? [config.main] : []).map(id => toEntryPath(id, { production: true }));
|
|
9
9
|
};
|
|
10
|
+
const args = {
|
|
11
|
+
config: true,
|
|
12
|
+
};
|
|
10
13
|
const plugin = {
|
|
11
14
|
title,
|
|
12
15
|
enablers,
|
|
13
16
|
isEnabled,
|
|
14
17
|
config,
|
|
15
18
|
resolveConfig,
|
|
19
|
+
args,
|
|
16
20
|
};
|
|
17
21
|
export default plugin;
|
package/dist/session/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type { Results } from '../run.ts';
|
|
|
6
6
|
export type { Issue, Issues, IssueType, Rules } from '../types/issues.ts';
|
|
7
7
|
export type { PackageJson } from '../types/package-json.ts';
|
|
8
8
|
export { createOptions, type MainOptions } from '../util/create-options.ts';
|
|
9
|
+
export { keepModuleMarker, removeExport } from '../util/remove-export.ts';
|
|
9
10
|
export { buildFileDescriptor, type FileDescriptorOptions } from './file-descriptor.ts';
|
|
10
11
|
export { buildPackageJsonDescriptor, type PackageJsonFile } from './package-json-descriptor.ts';
|
|
11
12
|
export { createSession, type Session } from './session.ts';
|
package/dist/session/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { IMPORT_STAR, ISSUE_TYPES, KNIP_CONFIG_LOCATIONS, SIDE_EFFECTS } from '.
|
|
|
2
2
|
export { finalizeConfigurationHints } from '../reporters/util/configuration-hints.js';
|
|
3
3
|
export { getIssuePrefix } from '../reporters/util/util.js';
|
|
4
4
|
export { createOptions } from '../util/create-options.js';
|
|
5
|
+
export { keepModuleMarker, removeExport } from '../util/remove-export.js';
|
|
5
6
|
export { buildFileDescriptor } from './file-descriptor.js';
|
|
6
7
|
export { buildPackageJsonDescriptor } from './package-json-descriptor.js';
|
|
7
8
|
export { createSession } from './session.js';
|