knip 6.46.1 → 6.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurationChief.d.ts +6 -0
- package/dist/IssueFixer.js +2 -6
- package/dist/WorkspaceWorker.d.ts +1 -0
- package/dist/WorkspaceWorker.js +10 -6
- package/dist/binaries/create-script-parser-context.js +2 -1
- package/dist/binaries/fallback.js +2 -3
- package/dist/binaries/plugins.js +1 -5
- package/dist/binaries/resolvers/npx.js +6 -8
- package/dist/binaries/resolvers/pnpx.js +3 -7
- package/dist/binaries/util.d.ts +4 -0
- package/dist/binaries/util.js +12 -2
- 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/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 +19 -5
- package/dist/plugins/drizzle/index.js +5 -0
- package/dist/plugins/ember/index.js +4 -8
- package/dist/plugins/env/index.d.ts +3 -0
- package/dist/plugins/env/index.js +27 -0
- package/dist/plugins/esbuild/index.js +5 -0
- package/dist/plugins/firebase/index.d.ts +3 -0
- package/dist/plugins/firebase/index.js +12 -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/graphql-codegen/index.js +2 -0
- package/dist/plugins/index.d.ts +6 -0
- package/dist/plugins/index.js +12 -0
- package/dist/plugins/mocha/index.js +6 -0
- package/dist/plugins/mocha/types.d.ts +3 -0
- package/dist/plugins/netlify/index.js +12 -2
- package/dist/plugins/netlify/types.d.ts +3 -0
- package/dist/plugins/node/index.d.ts +2 -2
- package/dist/plugins/node/index.js +14 -3
- package/dist/plugins/nodemon/index.js +19 -0
- package/dist/plugins/nx/index.js +14 -1
- package/dist/plugins/plop/index.js +4 -0
- package/dist/plugins/prisma/index.js +2 -0
- package/dist/plugins/remark/helpers.js +1 -8
- package/dist/plugins/rollup/index.js +1 -1
- package/dist/plugins/serverless-framework/index.js +14 -5
- package/dist/plugins/serverless-framework/types.d.ts +4 -1
- package/dist/plugins/sst/index.js +13 -0
- package/dist/plugins/sst/resolveFromAST.js +35 -16
- 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/storybook/index.js +3 -3
- package/dist/plugins/storybook/types.d.ts +5 -3
- package/dist/plugins/textlint/helpers.js +1 -5
- package/dist/plugins/trigger-dev/index.d.ts +3 -0
- package/dist/plugins/trigger-dev/index.js +28 -0
- package/dist/plugins/ts-node/index.d.ts +6 -0
- package/dist/plugins/ts-node/index.js +19 -0
- package/dist/plugins/ts-node-dev/index.d.ts +3 -0
- package/dist/plugins/ts-node-dev/index.js +46 -0
- package/dist/plugins/tsup/index.js +2 -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 +12 -4
- package/dist/plugins/vite/helpers.js +1 -4
- package/dist/plugins/vite-node/index.d.ts +3 -0
- package/dist/plugins/vite-node/index.js +11 -0
- 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/webdriver-io/index.js +6 -2
- 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 +6 -0
- package/dist/types/tsconfig-json.d.ts +5 -0
- package/dist/typescript/ast-helpers.d.ts +3 -1
- package/dist/typescript/ast-helpers.js +14 -4
- package/dist/typescript/visitors/exports.js +11 -8
- package/dist/typescript/visitors/imports.js +10 -8
- package/dist/typescript/visitors/members.js +10 -8
- package/dist/util/create-input-handler.js +5 -3
- package/dist/util/package-json.d.ts +1 -0
- package/dist/util/package-json.js +21 -9
- 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 +24 -0
- package/dist/plugins/vite-plus/resolveFromAST.d.ts +0 -2
- package/dist/plugins/vite-plus/resolveFromAST.js +0 -37
|
@@ -1,14 +1,27 @@
|
|
|
1
|
+
import { argsFromPositional } from '../../binaries/util.js';
|
|
1
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
3
|
import { resolveFromAST } from './resolveFromAST.js';
|
|
3
4
|
const title = 'SST';
|
|
4
5
|
const enablers = ['sst'];
|
|
5
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
7
|
const config = ['sst.config.ts'];
|
|
8
|
+
const wrappers = new Set(['bind', 'dev', 'env', 'shell']);
|
|
9
|
+
const args = {
|
|
10
|
+
boolean: ['print-logs', 'script'],
|
|
11
|
+
config: ['config'],
|
|
12
|
+
fromArgs: (parsed, args) => {
|
|
13
|
+
if (!wrappers.has(parsed._[0]))
|
|
14
|
+
return [];
|
|
15
|
+
const command = argsFromPositional(parsed, args, 1);
|
|
16
|
+
return parsed._[0] === 'bind' || parsed._[0] === 'env' ? command.join(' ') : command;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
7
19
|
const plugin = {
|
|
8
20
|
title,
|
|
9
21
|
enablers,
|
|
10
22
|
isEnabled,
|
|
11
23
|
config,
|
|
12
24
|
resolveFromAST,
|
|
25
|
+
args,
|
|
13
26
|
};
|
|
14
27
|
export default plugin;
|
|
@@ -1,47 +1,66 @@
|
|
|
1
1
|
import { Visitor } from 'oxc-parser';
|
|
2
|
-
import { collectPropertyValues, getImportMap } from '../../typescript/ast-helpers.js';
|
|
2
|
+
import { collectPropertyValues, findProperty, getImportMap } from '../../typescript/ast-helpers.js';
|
|
3
3
|
import { _parseFile } from '../../typescript/ast-nodes.js';
|
|
4
4
|
import { toEntryPath } from '../../util/input.js';
|
|
5
5
|
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);
|
|
44
|
+
}
|
|
45
|
+
if (propName === 'subscribe') {
|
|
46
|
+
const [first, second] = node.arguments;
|
|
47
|
+
const subscriber = second?.type === 'Literal'
|
|
48
|
+
? second
|
|
49
|
+
: !second || (second.type === 'ObjectExpression' && !findProperty(second, 'handler'))
|
|
50
|
+
? first
|
|
51
|
+
: undefined;
|
|
52
|
+
if (subscriber?.type === 'Literal' && typeof subscriber.value === 'string' && subscriber.value.includes('.'))
|
|
53
|
+
addHandler(subscriber.value);
|
|
41
54
|
}
|
|
42
55
|
},
|
|
43
56
|
});
|
|
44
57
|
visitor.visit(program);
|
|
58
|
+
for (const infra of dynamicImports.map(parseImport)) {
|
|
59
|
+
if (!infra)
|
|
60
|
+
continue;
|
|
61
|
+
addHandlers(collectPropertyValues(infra, 'handler'));
|
|
62
|
+
visitor.visit(infra);
|
|
63
|
+
}
|
|
45
64
|
}
|
|
46
65
|
catch { }
|
|
47
66
|
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;
|
|
@@ -40,9 +40,9 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
40
40
|
const framework = localConfig.framework;
|
|
41
41
|
const frameworkName = typeof framework === 'string' ? framework : framework?.name;
|
|
42
42
|
const frameworks = frameworkName ? [frameworkName] : [];
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const builderOptions = (typeof framework === 'object' && framework?.options?.builder) ||
|
|
44
|
+
(typeof localConfig?.core?.builder === 'object' && localConfig.core.builder.options);
|
|
45
|
+
const viteConfigPath = builderOptions && builderOptions.viteConfigPath;
|
|
46
46
|
const configs = viteConfigPath ? [toConfig('vite', viteConfigPath, { dir: cwd })] : [];
|
|
47
47
|
const hasVitestAddon = addons.some(addon => addon === '@storybook/addon-vitest');
|
|
48
48
|
const coverageDeps = hasVitestAddon
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
type BuilderOptions = {
|
|
2
|
+
viteConfigPath?: string | null;
|
|
3
|
+
};
|
|
1
4
|
type Stories = (string | {
|
|
2
5
|
directory: string;
|
|
3
6
|
files?: string;
|
|
@@ -11,14 +14,13 @@ export type StorybookConfig = {
|
|
|
11
14
|
core?: {
|
|
12
15
|
builder?: string | {
|
|
13
16
|
name?: string;
|
|
17
|
+
options?: BuilderOptions;
|
|
14
18
|
};
|
|
15
19
|
};
|
|
16
20
|
framework?: string | {
|
|
17
21
|
name?: string;
|
|
18
22
|
options?: {
|
|
19
|
-
builder?:
|
|
20
|
-
viteConfigPath?: string;
|
|
21
|
-
};
|
|
23
|
+
builder?: BuilderOptions;
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
26
|
};
|
|
@@ -14,11 +14,7 @@ const createFullPackageName = (prefix, name) => {
|
|
|
14
14
|
return `${prefix}${name}`;
|
|
15
15
|
};
|
|
16
16
|
const hasPrefix = (prefix, name) => (name.charAt(0) === '@' ? name.slice(name.indexOf('/') + 1) : name).startsWith(prefix);
|
|
17
|
-
const
|
|
18
|
-
manifest.devDependencies?.[name] ??
|
|
19
|
-
manifest.optionalDependencies?.[name] ??
|
|
20
|
-
manifest.peerDependencies?.[name]);
|
|
21
|
-
const toPackageDependency = (prefix, name, candidates, manifest) => toDependency(candidates.find(candidate => isDeclared(manifest, candidate)) ??
|
|
17
|
+
const toPackageDependency = (prefix, name, candidates, manifest) => toDependency(candidates.find(candidate => manifest.allDependencies.has(candidate)) ??
|
|
22
18
|
(hasPrefix(prefix, name) ? name : createFullPackageName(prefix, name)));
|
|
23
19
|
const isPresetRuleKey = (key) => key.startsWith('preset-') ||
|
|
24
20
|
key.startsWith(PRESET_PREFIX) ||
|
|
@@ -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;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Plugin } from '../../types/config.ts';
|
|
2
|
+
import type { TsConfigJson } from '../../types/tsconfig-json.ts';
|
|
3
|
+
import { type Input } from '../../util/input.ts';
|
|
4
|
+
export declare const resolveTsNodeConfig: (options: NonNullable<TsConfigJson['ts-node']>) => Input[];
|
|
5
|
+
export declare const docs: {
|
|
6
|
+
note: string;
|
|
7
|
+
};
|
|
2
8
|
declare const plugin: Plugin;
|
|
3
9
|
export default plugin;
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
import { toModule } from '../../util/input.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
1
3
|
const title = 'ts-node';
|
|
4
|
+
const enablers = ['ts-node'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
export const resolveTsNodeConfig = (options) => {
|
|
7
|
+
const inputs = [];
|
|
8
|
+
for (const id of options.require ?? [])
|
|
9
|
+
inputs.push(toModule(id));
|
|
10
|
+
if (options.compiler)
|
|
11
|
+
inputs.push(toModule(options.compiler));
|
|
12
|
+
const transpiler = Array.isArray(options.transpiler) ? options.transpiler[0] : options.transpiler;
|
|
13
|
+
if (transpiler)
|
|
14
|
+
inputs.push(toModule(transpiler));
|
|
15
|
+
return inputs;
|
|
16
|
+
};
|
|
2
17
|
const args = {
|
|
3
18
|
binaries: ['ts-node', 'ts-node-cwd', 'ts-node-esm', 'ts-node-script', 'ts-node-transpile-only'],
|
|
4
19
|
positional: (parsed) => (parsed.eval === undefined ? parsed._.slice(0, 1) : []),
|
|
@@ -27,8 +42,12 @@ const args = {
|
|
|
27
42
|
boolean: true,
|
|
28
43
|
stopEarly: true,
|
|
29
44
|
};
|
|
45
|
+
const note = 'The `"ts-node"` section of `tsconfig.json` is read by the TypeScript plugin.';
|
|
46
|
+
export const docs = { note };
|
|
30
47
|
const plugin = {
|
|
31
48
|
title,
|
|
49
|
+
enablers,
|
|
50
|
+
isEnabled,
|
|
32
51
|
args,
|
|
33
52
|
};
|
|
34
53
|
export default plugin;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const title = 'ts-node-dev';
|
|
2
|
+
const args = {
|
|
3
|
+
binaries: ['ts-node-dev', 'tsnd'],
|
|
4
|
+
positional: true,
|
|
5
|
+
nodeImportArgs: true,
|
|
6
|
+
args: (args) => args.filter((arg, index) => arg !== '--watch' && args[index - 1] !== '--watch'),
|
|
7
|
+
boolean: [
|
|
8
|
+
'all-deps',
|
|
9
|
+
'clear',
|
|
10
|
+
'cls',
|
|
11
|
+
'compiler-host',
|
|
12
|
+
'debug',
|
|
13
|
+
'dedupe',
|
|
14
|
+
'deps',
|
|
15
|
+
'emit',
|
|
16
|
+
'error-recompile',
|
|
17
|
+
'exec-check',
|
|
18
|
+
'exit-child',
|
|
19
|
+
'files',
|
|
20
|
+
'fork',
|
|
21
|
+
'log-error',
|
|
22
|
+
'notify',
|
|
23
|
+
'poll',
|
|
24
|
+
'prefer-ts-exts',
|
|
25
|
+
'pretty',
|
|
26
|
+
'respawn',
|
|
27
|
+
'rs',
|
|
28
|
+
'scope',
|
|
29
|
+
'script-mode',
|
|
30
|
+
'skip-ignore',
|
|
31
|
+
'skip-project',
|
|
32
|
+
'transpile-only',
|
|
33
|
+
'tree-kill',
|
|
34
|
+
],
|
|
35
|
+
alias: {
|
|
36
|
+
'compiler-host': ['H'],
|
|
37
|
+
'prefer-ts-exts': ['prefer-ts'],
|
|
38
|
+
'script-mode': ['s'],
|
|
39
|
+
'transpile-only': ['T'],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
const plugin = {
|
|
43
|
+
title,
|
|
44
|
+
args,
|
|
45
|
+
};
|
|
46
|
+
export default plugin;
|
|
@@ -24,6 +24,8 @@ const resolveConfig = async (config) => {
|
|
|
24
24
|
const resolveFromAST = program => Array.from(collectPropertyValues(program, 'entry'), id => toEntry(id, { production: true, allowIncludeExports: true }));
|
|
25
25
|
const args = {
|
|
26
26
|
config: true,
|
|
27
|
+
boolean: ['clean'],
|
|
28
|
+
resolveInputs: parsed => parsed._.map(id => toEntry(id, { production: true, allowIncludeExports: true })),
|
|
27
29
|
};
|
|
28
30
|
const plugin = {
|
|
29
31
|
title,
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@ import { compact } from '../../util/array.js';
|
|
|
2
2
|
import { toConfig, toModule, toDependency } from '../../util/input.js';
|
|
3
3
|
import { join, toAbsolute } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
|
+
import { resolveTsNodeConfig } from '../ts-node/index.js';
|
|
5
6
|
import { contentMapperResolvers } from './content-mappers.js';
|
|
6
7
|
const title = 'TypeScript';
|
|
7
8
|
const enablers = ['typescript', '@typescript/native', '@typescript/native-preview'];
|
|
@@ -24,16 +25,20 @@ export const resolveConfig = (localConfig, options) => {
|
|
|
24
25
|
: [];
|
|
25
26
|
const references = localConfig.references?.map(({ path }) => toConfig(options.pluginName, path.endsWith('.json') ? path : toAbsolute(join(path, 'tsconfig.json'), options.configFileDir))) ?? [];
|
|
26
27
|
const contentMappers = resolveContentMappers(localConfig, options.configFileDir);
|
|
28
|
+
const tsNode = localConfig['ts-node'] && options.enabledPlugins.includes('ts-node')
|
|
29
|
+
? resolveTsNodeConfig(localConfig['ts-node'])
|
|
30
|
+
: [];
|
|
27
31
|
if (!(compilerOptions && localConfig))
|
|
28
|
-
return compact([...contentMappers, ...extend, ...references]);
|
|
32
|
+
return compact([...contentMappers, ...tsNode, ...extend, ...references]);
|
|
29
33
|
const jsx = (compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : []).map(id => toDependency(id, { production: true, dir: options.cwd, alsoReferenceOwner: true }));
|
|
30
|
-
const types = compilerOptions.types ?? [];
|
|
34
|
+
const types = compilerOptions.types?.filter(id => id !== '*') ?? [];
|
|
31
35
|
const plugins = Array.isArray(compilerOptions?.plugins)
|
|
32
36
|
? compilerOptions.plugins.map(plugin => (typeof plugin === 'object' && 'name' in plugin ? plugin.name : ''))
|
|
33
37
|
: [];
|
|
34
38
|
const importHelpers = compilerOptions?.importHelpers ? ['tslib'] : [];
|
|
35
39
|
return compact([
|
|
36
40
|
...contentMappers,
|
|
41
|
+
...tsNode,
|
|
37
42
|
...extend,
|
|
38
43
|
...references,
|
|
39
44
|
...types.map(id => toModule(id, { isTypeOnly: true, dir: options.cwd, alsoReferenceOwner: true })),
|
|
@@ -42,11 +47,14 @@ export const resolveConfig = (localConfig, options) => {
|
|
|
42
47
|
...jsx,
|
|
43
48
|
]);
|
|
44
49
|
};
|
|
50
|
+
const toConfigPath = (p) => (p.endsWith('.json') ? p : join(p, 'tsconfig.json'));
|
|
45
51
|
export const args = {
|
|
46
52
|
binaries: ['tsc', 'tsgo'],
|
|
47
53
|
string: ['project'],
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
boolean: ['build', 'clean', 'dry', 'force', 'stopBuildOnErrors'],
|
|
55
|
+
alias: { project: ['p'], build: ['b'], verbose: ['v'], dry: ['d'], force: ['f'], watch: ['w'] },
|
|
56
|
+
config: [['project', toConfigPath]],
|
|
57
|
+
resolveInputs: (parsed, { cwd }) => parsed.build ? parsed._.map(String).map(p => toConfig('typescript', toConfigPath(p), { dir: cwd })) : [],
|
|
50
58
|
};
|
|
51
59
|
const note = `[What's up with that configurable tsconfig.json location?](/reference/faq#whats-up-with-that-configurable-tsconfigjson-location)`;
|
|
52
60
|
export const docs = { note };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { blockCommentMatcher, lineCommentMatcher, scriptExtractor } from '../../compilers/compilers.js';
|
|
2
|
-
import { findImportedCalls, findProperty, getStringValues, resolveObjectArg } from '../../typescript/ast-helpers.js';
|
|
2
|
+
import { findImportedCalls, findProperty, getStringValues, resolveObjectArg, unwrapExpression, } from '../../typescript/ast-helpers.js';
|
|
3
3
|
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
4
4
|
import { isFile, loadFile } from '../../util/fs.js';
|
|
5
5
|
import { toEntryPath } from '../../util/input.js';
|
|
@@ -100,9 +100,6 @@ export const getVitePluginDirs = (program, specifiers, key) => {
|
|
|
100
100
|
}
|
|
101
101
|
return dirs;
|
|
102
102
|
};
|
|
103
|
-
const unwrapExpression = (node) => node.type === 'TSSatisfiesExpression' || node.type === 'TSAsExpression' || node.type === 'ParenthesizedExpression'
|
|
104
|
-
? unwrapExpression(node.expression)
|
|
105
|
-
: node;
|
|
106
103
|
export const getViteRoot = (program, cwd) => {
|
|
107
104
|
for (const node of program.body) {
|
|
108
105
|
if (node.type !== 'ExportDefaultDeclaration')
|
|
@@ -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,
|
|
@@ -10,11 +10,15 @@ const getNames = (plugins = []) => plugins.flatMap(plugin => {
|
|
|
10
10
|
const name = Array.isArray(plugin) ? plugin[0] : plugin;
|
|
11
11
|
return typeof name === 'string' && !name.startsWith('file://') && !isAbsolute(name) ? [name] : [];
|
|
12
12
|
});
|
|
13
|
-
const toPluginDependency = (name, type, dir) => {
|
|
13
|
+
const toPluginDependency = (name, type, dir, manifest) => {
|
|
14
14
|
if (name.startsWith('@'))
|
|
15
15
|
return toDependency(name);
|
|
16
16
|
const scoped = `@wdio/${name.toLowerCase()}-${type}`;
|
|
17
17
|
const community = `wdio-${name.toLowerCase()}-${type}`;
|
|
18
|
+
if (manifest.allDependencies.has(scoped))
|
|
19
|
+
return toDependency(scoped);
|
|
20
|
+
if (manifest.allDependencies.has(community))
|
|
21
|
+
return toDependency(community);
|
|
18
22
|
const isCommunity = !resolvePackageManifestPath(scoped, dir) && resolvePackageManifestPath(community, dir);
|
|
19
23
|
return toDependency(isCommunity ? community : scoped);
|
|
20
24
|
};
|
|
@@ -22,7 +26,7 @@ const resolveConfig = async (config, options) => {
|
|
|
22
26
|
const cfg = config?.config;
|
|
23
27
|
if (!cfg)
|
|
24
28
|
return [];
|
|
25
|
-
const toInputs = (plugins, type) => getNames(plugins).map(name => toPluginDependency(name, type, options.configFileDir));
|
|
29
|
+
const toInputs = (plugins, type) => getNames(plugins).map(name => toPluginDependency(name, type, options.configFileDir, options.manifest));
|
|
26
30
|
return [
|
|
27
31
|
...toInputs([cfg.framework], 'framework'),
|
|
28
32
|
...toInputs([cfg.runner ?? 'local'], 'runner'),
|