knip 6.42.0 → 6.43.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 +18 -0
- package/dist/IssueFixer.js +10 -5
- package/dist/WorkspaceWorker.js +15 -10
- package/dist/binaries/resolvers/bun.js +1 -0
- package/dist/binaries/resolvers/npm.js +12 -2
- package/dist/binaries/resolvers/pnpm.js +5 -3
- package/dist/compilers/compilers.js +2 -2
- package/dist/compilers/scss.js +2 -22
- package/dist/compilers/shared.d.ts +1 -1
- package/dist/compilers/shared.js +24 -1
- package/dist/constants.js +2 -0
- package/dist/plugins/_vue/auto-import.js +31 -1
- package/dist/plugins/buf/index.d.ts +3 -0
- package/dist/plugins/buf/index.js +33 -0
- package/dist/plugins/buf/types.d.ts +8 -0
- package/dist/plugins/buf/types.js +1 -0
- package/dist/plugins/bun/index.js +13 -0
- package/dist/plugins/electron-forge/index.d.ts +3 -0
- package/dist/plugins/electron-forge/index.js +94 -0
- package/dist/plugins/eslint/helpers.d.ts +1 -0
- package/dist/plugins/eslint/helpers.js +1 -1
- package/dist/plugins/eslint/resolveFromAST.js +35 -10
- package/dist/plugins/expo/helpers.d.ts +1 -1
- package/dist/plugins/expo/helpers.js +15 -8
- package/dist/plugins/expo/types.d.ts +2 -1
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/jest/index.js +11 -7
- package/dist/plugins/mcp/index.d.ts +3 -0
- package/dist/plugins/mcp/index.js +33 -0
- package/dist/plugins/mcp/types.d.ts +11 -0
- package/dist/plugins/mcp/types.js +1 -0
- package/dist/plugins/next/index.d.ts +3 -0
- package/dist/plugins/next/index.js +57 -9
- package/dist/plugins/next/types.d.ts +11 -0
- package/dist/plugins/next/types.js +1 -0
- package/dist/plugins/semantic-release/index.js +32 -3
- package/dist/plugins/semantic-release/types.d.ts +1 -0
- package/dist/plugins/tailwind/compiler.js +14 -2
- package/dist/plugins/travis/index.js +2 -2
- package/dist/plugins/typescript/index.js +2 -4
- package/dist/plugins/vitest/helpers.d.ts +1 -1
- package/dist/plugins/vitest/helpers.js +13 -3
- package/dist/plugins/vitest/index.js +54 -46
- package/dist/plugins/vitest/types.d.ts +11 -7
- package/dist/run.js +1 -1
- package/dist/schema/configuration.d.ts +45 -0
- package/dist/schema/plugins.d.ts +15 -0
- package/dist/schema/plugins.js +3 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +3 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/typescript/ast-nodes.js +3 -3
- package/dist/typescript/visitors/exports.js +5 -4
- package/dist/typescript/visitors/walk.js +13 -1
- package/dist/util/create-options.d.ts +30 -0
- package/dist/util/modules.js +2 -1
- package/dist/util/remove-export.js +3 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/schema.json +12 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toDependency, toProductionDependency } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolveEntry, toDependency, toProductionDependency } from '../../util/input.js';
|
|
2
2
|
import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
3
|
-
import { join } from '../../util/path.js';
|
|
3
|
+
import { isInternal, join } from '../../util/path.js';
|
|
4
4
|
const getDummyConfigContext = (options) => ({
|
|
5
5
|
projectRoot: options.cwd,
|
|
6
6
|
staticConfigPath: null,
|
|
@@ -17,13 +17,20 @@ export const getDependencies = async (localConfig, options) => {
|
|
|
17
17
|
const { manifest } = options;
|
|
18
18
|
const config = getConfig(localConfig, options);
|
|
19
19
|
const platforms = config.platforms ?? ['ios', 'android'];
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const inputs = new Set();
|
|
21
|
+
for (const plugin of config.plugins ?? []) {
|
|
22
22
|
const pluginName = Array.isArray(plugin) ? plugin[0] : plugin;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (typeof pluginName !== 'string')
|
|
24
|
+
continue;
|
|
25
|
+
if (isInternal(pluginName)) {
|
|
26
|
+
inputs.add(toDeferResolveEntry(pluginName));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const packageName = getPackageNameFromModuleSpecifier(pluginName);
|
|
30
|
+
if (packageName)
|
|
31
|
+
inputs.add(toDependency(packageName));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
27
34
|
const allowedPackages = ['expo-atlas', 'expo-dev-client'];
|
|
28
35
|
const allowedProductionPackages = ['expo-insights'];
|
|
29
36
|
const manifestDependencies = Object.keys(manifest.dependencies ?? {});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type ConfigPlugin = (config: unknown) => unknown;
|
|
1
2
|
type BaseConfig = {
|
|
2
3
|
platforms?: ('ios' | 'android' | 'web')[];
|
|
3
4
|
notification?: Record<string, unknown>;
|
|
@@ -13,7 +14,7 @@ type BaseConfig = {
|
|
|
13
14
|
userInterfaceStyle?: 'automatic' | 'light' | 'dark';
|
|
14
15
|
};
|
|
15
16
|
androidNavigationBar?: Record<string, unknown>;
|
|
16
|
-
plugins?: (string | [string, Record<string, unknown>])[];
|
|
17
|
+
plugins?: (string | ConfigPlugin | [string | ConfigPlugin, Record<string, unknown>])[];
|
|
17
18
|
};
|
|
18
19
|
type ConfigContext = {
|
|
19
20
|
projectRoot: string;
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const Plugins: {
|
|
|
8
8
|
babel: import("../types/config.ts").Plugin;
|
|
9
9
|
biome: import("../types/config.ts").Plugin;
|
|
10
10
|
borp: import("../types/config.ts").Plugin;
|
|
11
|
+
buf: import("../types/config.ts").Plugin;
|
|
11
12
|
bumpp: import("../types/config.ts").Plugin;
|
|
12
13
|
bun: import("../types/config.ts").Plugin;
|
|
13
14
|
c8: import("../types/config.ts").Plugin;
|
|
@@ -28,6 +29,7 @@ export declare const Plugins: {
|
|
|
28
29
|
docusaurus: import("../types/config.ts").Plugin;
|
|
29
30
|
dotenv: import("../types/config.ts").Plugin;
|
|
30
31
|
drizzle: import("../types/config.ts").Plugin;
|
|
32
|
+
'electron-forge': import("../types/config.ts").Plugin;
|
|
31
33
|
'electron-vite': import("../types/config.ts").Plugin;
|
|
32
34
|
eleventy: import("../types/config.ts").Plugin;
|
|
33
35
|
esbuild: import("../types/config.ts").Plugin;
|
|
@@ -69,6 +71,7 @@ export declare const Plugins: {
|
|
|
69
71
|
lunaria: import("../types/config.ts").Plugin;
|
|
70
72
|
markdownlint: import("../types/config.ts").Plugin;
|
|
71
73
|
marko: import("../types/config.ts").Plugin;
|
|
74
|
+
mcp: import("../types/config.ts").Plugin;
|
|
72
75
|
mdx: import("../types/config.ts").Plugin;
|
|
73
76
|
mdxlint: import("../types/config.ts").Plugin;
|
|
74
77
|
metro: import("../types/config.ts").Plugin;
|
package/dist/plugins/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { default as ava } from './ava/index.js';
|
|
|
7
7
|
import { default as babel } from './babel/index.js';
|
|
8
8
|
import { default as biome } from './biome/index.js';
|
|
9
9
|
import { default as borp } from './borp/index.js';
|
|
10
|
+
import { default as buf } from './buf/index.js';
|
|
10
11
|
import { default as bumpp } from './bumpp/index.js';
|
|
11
12
|
import { default as bun } from './bun/index.js';
|
|
12
13
|
import { default as c8 } from './c8/index.js';
|
|
@@ -27,6 +28,7 @@ import { default as dependencyCruiser } from './dependency-cruiser/index.js';
|
|
|
27
28
|
import { default as docusaurus } from './docusaurus/index.js';
|
|
28
29
|
import { default as dotenv } from './dotenv/index.js';
|
|
29
30
|
import { default as drizzle } from './drizzle/index.js';
|
|
31
|
+
import { default as electronForge } from './electron-forge/index.js';
|
|
30
32
|
import { default as electronVite } from './electron-vite/index.js';
|
|
31
33
|
import { default as eleventy } from './eleventy/index.js';
|
|
32
34
|
import { default as esbuild } from './esbuild/index.js';
|
|
@@ -63,6 +65,7 @@ import { default as lostPixel } from './lost-pixel/index.js';
|
|
|
63
65
|
import { default as lunaria } from './lunaria/index.js';
|
|
64
66
|
import { default as markdownlint } from './markdownlint/index.js';
|
|
65
67
|
import { default as marko } from './marko/index.js';
|
|
68
|
+
import { default as mcp } from './mcp/index.js';
|
|
66
69
|
import { default as mdx } from './mdx/index.js';
|
|
67
70
|
import { default as mdxlint } from './mdxlint/index.js';
|
|
68
71
|
import { default as metro } from './metro/index.js';
|
|
@@ -203,6 +206,7 @@ export const Plugins = {
|
|
|
203
206
|
babel,
|
|
204
207
|
biome,
|
|
205
208
|
borp,
|
|
209
|
+
buf,
|
|
206
210
|
bumpp,
|
|
207
211
|
bun,
|
|
208
212
|
c8,
|
|
@@ -223,6 +227,7 @@ export const Plugins = {
|
|
|
223
227
|
docusaurus,
|
|
224
228
|
dotenv,
|
|
225
229
|
drizzle,
|
|
230
|
+
'electron-forge': electronForge,
|
|
226
231
|
'electron-vite': electronVite,
|
|
227
232
|
eleventy,
|
|
228
233
|
esbuild,
|
|
@@ -259,6 +264,7 @@ export const Plugins = {
|
|
|
259
264
|
lunaria,
|
|
260
265
|
markdownlint,
|
|
261
266
|
marko,
|
|
267
|
+
mcp,
|
|
262
268
|
mdx,
|
|
263
269
|
mdxlint,
|
|
264
270
|
metro,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { arrayify } from '../../util/array.js';
|
|
2
|
-
import { _glob
|
|
2
|
+
import { _glob } from '../../util/glob.js';
|
|
3
3
|
import { toConfig, toDeferResolve, toDependency, toEntry } from '../../util/input.js';
|
|
4
|
-
import { isInternal, join, normalize, toAbsolute } from '../../util/path.js';
|
|
4
|
+
import { extname, isInternal, join, normalize, toAbsolute } from '../../util/path.js';
|
|
5
5
|
import { hasDependency } from '../../util/plugin.js';
|
|
6
6
|
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
7
7
|
import { getReportersDependencies, resolveExtensibleConfig, resolveWithPrefix } from './helpers.js';
|
|
@@ -9,7 +9,9 @@ import { createJestMockVisitor } from './visitors/mock.js';
|
|
|
9
9
|
const title = 'Jest';
|
|
10
10
|
const enablers = ['jest'];
|
|
11
11
|
const isEnabled = ({ dependencies, manifest }) => hasDependency(dependencies, enablers) || Boolean(manifest.name?.startsWith('jest-presets'));
|
|
12
|
-
const
|
|
12
|
+
const configExtensions = ['js', 'ts', 'mjs', 'mts', 'cjs', 'cts', 'json'];
|
|
13
|
+
const configPattern = `jest.config.{${configExtensions.join(',')}}`;
|
|
14
|
+
const config = [configPattern, 'package.json'];
|
|
13
15
|
const mocks = ['**/__mocks__/**/*.[jt]s?(x)'];
|
|
14
16
|
const entry = ['**/__tests__/**/*.?(c|m)[jt]s?(x)', '**/?(*.)+(spec|test).?(c|m)[jt]s?(x)', ...mocks];
|
|
15
17
|
const rootDirRe = /<rootDir>/;
|
|
@@ -28,10 +30,12 @@ const resolveDependencies = async (config, rootDir, options) => {
|
|
|
28
30
|
const projects = [];
|
|
29
31
|
for (const project of config.projects ?? []) {
|
|
30
32
|
if (typeof project === 'string') {
|
|
31
|
-
const
|
|
32
|
-
const files = await _glob({ patterns, cwd: options.cwd });
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
const pattern = project.replace(rootDirRe, rootDir);
|
|
34
|
+
const files = await _glob({ patterns: [pattern, join(pattern, configPattern)], cwd: options.cwd });
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
if (configExtensions.includes(extname(file).slice(1)))
|
|
37
|
+
projects.push(toConfig('jest', file));
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
else {
|
|
37
41
|
const dependencies = await resolveDependencies(project, rootDir, options);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isFile } from '../../util/fs.js';
|
|
2
|
+
import { toAbsolute } from '../../util/path.js';
|
|
3
|
+
const title = 'MCP';
|
|
4
|
+
const enablers = 'This plugin is enabled when `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json` or `.codex/config.toml` is found.';
|
|
5
|
+
const isRootOnly = true;
|
|
6
|
+
const config = ['.mcp.json', '.cursor/mcp.json', '.vscode/mcp.json', '.codex/config.toml'];
|
|
7
|
+
const isEnabled = ({ cwd }) => config.some(file => isFile(cwd, file));
|
|
8
|
+
const PROJECT_DIR_VAR = /\$\{(?:workspaceFolder|CLAUDE_PROJECT_DIR(?::-[^}]*)?)\}/g;
|
|
9
|
+
const resolveConfig = async (localConfig, options) => {
|
|
10
|
+
const { cwd, getInputsFromScripts } = options;
|
|
11
|
+
const servers = { ...localConfig.mcpServers, ...localConfig.servers, ...localConfig.mcp_servers };
|
|
12
|
+
const inputs = [];
|
|
13
|
+
for (const server of Object.values(servers)) {
|
|
14
|
+
if (typeof server?.command !== 'string')
|
|
15
|
+
continue;
|
|
16
|
+
const script = [server.command, ...(server.args ?? [])].join(' ').replace(PROJECT_DIR_VAR, '.');
|
|
17
|
+
const dir = server.cwd ? toAbsolute(server.cwd.replace(PROJECT_DIR_VAR, '.'), cwd) : cwd;
|
|
18
|
+
for (const input of getInputsFromScripts(script, { optionalBinaries: true })) {
|
|
19
|
+
input.dir = dir;
|
|
20
|
+
inputs.push(input);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return inputs;
|
|
24
|
+
};
|
|
25
|
+
const plugin = {
|
|
26
|
+
title,
|
|
27
|
+
enablers,
|
|
28
|
+
isEnabled,
|
|
29
|
+
isRootOnly,
|
|
30
|
+
config,
|
|
31
|
+
resolveConfig,
|
|
32
|
+
};
|
|
33
|
+
export default plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import { findProperty, getPropertyValues } from '../../typescript/ast-helpers.js
|
|
|
3
3
|
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
4
4
|
import { isDirectory } from '../../util/fs.js';
|
|
5
5
|
import { toConfig, toDeferResolve, toProductionEntry } from '../../util/input.js';
|
|
6
|
-
import { join } from '../../util/path.js';
|
|
6
|
+
import { isInNodeModules, join } from '../../util/path.js';
|
|
7
7
|
import { hasDependency } from '../../util/plugin.js';
|
|
8
8
|
const title = 'Next.js';
|
|
9
9
|
const enablers = ['next'];
|
|
@@ -39,6 +39,56 @@ const getEntryFilePatterns = (pageExtensions = defaultPageExtensions, cwd) => {
|
|
|
39
39
|
];
|
|
40
40
|
};
|
|
41
41
|
const production = getEntryFilePatterns();
|
|
42
|
+
const getInputs = (pageExtensions, loaders, aliasTargets, configFileDir) => {
|
|
43
|
+
const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
|
|
44
|
+
const patterns = [...getEntryFilePatterns(extensions, configFileDir), 'next-env.d.ts'];
|
|
45
|
+
const inputs = patterns.map(id => toProductionEntry(join(configFileDir, id)));
|
|
46
|
+
for (const loader of loaders)
|
|
47
|
+
inputs.push(toDeferResolve(loader));
|
|
48
|
+
for (const target of aliasTargets)
|
|
49
|
+
inputs.push({ ...toDeferResolve(target, { dir: configFileDir }), production: true });
|
|
50
|
+
return inputs;
|
|
51
|
+
};
|
|
52
|
+
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
53
|
+
const addSpecifier = (specifiers, value) => {
|
|
54
|
+
if (typeof value === 'string' && !isInNodeModules(value))
|
|
55
|
+
specifiers.add(value);
|
|
56
|
+
};
|
|
57
|
+
const collectLoaderValues = (value, loaders) => {
|
|
58
|
+
if (Array.isArray(value))
|
|
59
|
+
for (const item of value)
|
|
60
|
+
collectLoaderValues(item, loaders);
|
|
61
|
+
else if (isObject(value)) {
|
|
62
|
+
addSpecifier(loaders, value.loader);
|
|
63
|
+
collectLoaderValues(value.loaders, loaders);
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
addSpecifier(loaders, value);
|
|
67
|
+
};
|
|
68
|
+
const collectAliasTargetValues = (value, targets) => {
|
|
69
|
+
if (Array.isArray(value))
|
|
70
|
+
for (const item of value)
|
|
71
|
+
collectAliasTargetValues(item, targets);
|
|
72
|
+
else if (isObject(value))
|
|
73
|
+
collectAliasTargetValues(value.browser, targets);
|
|
74
|
+
else
|
|
75
|
+
addSpecifier(targets, value);
|
|
76
|
+
};
|
|
77
|
+
const resolveConfig = async (localConfig, { configFileDir }) => {
|
|
78
|
+
const config = typeof localConfig === 'function'
|
|
79
|
+
? await localConfig('phase-production-build', { defaultConfig: {} })
|
|
80
|
+
: localConfig;
|
|
81
|
+
const pageExtensions = Array.isArray(config?.pageExtensions)
|
|
82
|
+
? config.pageExtensions.filter(extension => typeof extension === 'string')
|
|
83
|
+
: [];
|
|
84
|
+
const loaders = new Set();
|
|
85
|
+
for (const rule of Object.values(config?.turbopack?.rules ?? {}))
|
|
86
|
+
collectLoaderValues(rule, loaders);
|
|
87
|
+
const aliasTargets = new Set();
|
|
88
|
+
for (const target of Object.values(config?.turbopack?.resolveAlias ?? {}))
|
|
89
|
+
collectAliasTargetValues(target, aliasTargets);
|
|
90
|
+
return getInputs(pageExtensions, loaders, aliasTargets, configFileDir);
|
|
91
|
+
};
|
|
42
92
|
const resolveFromAST = (program, { configFileDir }) => {
|
|
43
93
|
const pageExtensions = new Set();
|
|
44
94
|
const loaders = new Set();
|
|
@@ -100,14 +150,7 @@ const resolveFromAST = (program, { configFileDir }) => {
|
|
|
100
150
|
},
|
|
101
151
|
});
|
|
102
152
|
visitor.visit(program);
|
|
103
|
-
|
|
104
|
-
const patterns = [...getEntryFilePatterns(extensions, configFileDir), 'next-env.d.ts'];
|
|
105
|
-
const inputs = patterns.map(id => toProductionEntry(join(configFileDir, id)));
|
|
106
|
-
for (const loader of loaders)
|
|
107
|
-
inputs.push(toDeferResolve(loader));
|
|
108
|
-
for (const target of aliasTargets)
|
|
109
|
-
inputs.push({ ...toDeferResolve(target, { dir: configFileDir }), production: true });
|
|
110
|
-
return inputs;
|
|
153
|
+
return getInputs([...pageExtensions], loaders, aliasTargets, configFileDir);
|
|
111
154
|
};
|
|
112
155
|
const commands = new Set(['dev', 'build', 'start']);
|
|
113
156
|
const args = {
|
|
@@ -119,12 +162,17 @@ const args = {
|
|
|
119
162
|
return [toConfig('next', join(dir, 'next.config'))];
|
|
120
163
|
},
|
|
121
164
|
};
|
|
165
|
+
const note = `Knip loads \`next.config.*\` to read Turbopack loaders and alias targets from the composed configuration,
|
|
166
|
+
including values a shared configuration factory adds. A configuration file that fails to load is analyzed statically.`;
|
|
167
|
+
export const docs = { note };
|
|
122
168
|
const plugin = {
|
|
123
169
|
title,
|
|
124
170
|
enablers,
|
|
125
171
|
isEnabled,
|
|
126
172
|
config,
|
|
127
173
|
production,
|
|
174
|
+
isLoadConfigOptional: true,
|
|
175
|
+
resolveConfig,
|
|
128
176
|
resolveFromAST,
|
|
129
177
|
args,
|
|
130
178
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type NextConfig = {
|
|
2
|
+
pageExtensions?: string[];
|
|
3
|
+
turbopack?: {
|
|
4
|
+
rules?: Record<string, unknown>;
|
|
5
|
+
resolveAlias?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type NextConfigModule = NextConfig | ((phase: string, context: {
|
|
9
|
+
defaultConfig: NextConfig;
|
|
10
|
+
}) => NextConfig | Promise<NextConfig>);
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { toDeferResolve } from '../../util/input.js';
|
|
1
|
+
import { toConfig, toDeferResolve } from '../../util/input.js';
|
|
2
|
+
import { isInternal } from '../../util/path.js';
|
|
2
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
4
|
import { toCosmiconfig } from '../../util/plugin-config.js';
|
|
4
5
|
const title = 'Semantic Release';
|
|
@@ -13,9 +14,36 @@ const excludePackages = [
|
|
|
13
14
|
'@semantic-release/npm',
|
|
14
15
|
'@semantic-release/release-notes-generator',
|
|
15
16
|
];
|
|
16
|
-
const resolveConfig = config => {
|
|
17
|
+
const resolveConfig = (config, options) => {
|
|
18
|
+
const inputs = [];
|
|
19
|
+
for (const id of [config?.extends ?? []].flat()) {
|
|
20
|
+
if (isInternal(id))
|
|
21
|
+
inputs.push(toConfig('semantic-release', id, { containingFilePath: options.configFilePath }));
|
|
22
|
+
else
|
|
23
|
+
inputs.push(toDeferResolve(id));
|
|
24
|
+
}
|
|
17
25
|
const plugins = (config?.plugins ?? []).map(plugin => (Array.isArray(plugin) ? plugin[0] : plugin));
|
|
18
|
-
|
|
26
|
+
for (const id of plugins.filter(plugin => !excludePackages.includes(plugin)))
|
|
27
|
+
inputs.push(toDeferResolve(id));
|
|
28
|
+
return inputs;
|
|
29
|
+
};
|
|
30
|
+
const args = {
|
|
31
|
+
alias: { extends: ['e'] },
|
|
32
|
+
resolveInputs: (parsed, { cwd }) => {
|
|
33
|
+
if (parsed.extends === 'false')
|
|
34
|
+
return [];
|
|
35
|
+
const inputs = [];
|
|
36
|
+
for (const value of [parsed.extends ?? []].flat()) {
|
|
37
|
+
for (const part of String(value).split(',')) {
|
|
38
|
+
const id = part.trim();
|
|
39
|
+
if (isInternal(id))
|
|
40
|
+
inputs.push(toConfig('semantic-release', id, { dir: cwd }));
|
|
41
|
+
else
|
|
42
|
+
inputs.push(toDeferResolve(id));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return inputs;
|
|
46
|
+
},
|
|
19
47
|
};
|
|
20
48
|
const plugin = {
|
|
21
49
|
title,
|
|
@@ -25,5 +53,6 @@ const plugin = {
|
|
|
25
53
|
packageJsonPath,
|
|
26
54
|
config,
|
|
27
55
|
resolveConfig,
|
|
56
|
+
args,
|
|
28
57
|
};
|
|
29
58
|
export default plugin;
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
import { getUrlSpecifier } from '../../compilers/shared.js';
|
|
1
2
|
import { hasUrlScheme } from '../../util/url.js';
|
|
2
|
-
const directiveMatcher = /"(?:\\(?:\r\n|[\s\S]|$)|[^"\\\r\n\f])*(?:"|[\r\n\f]|$)|'(?:\\(?:\r\n|[\s\S]|$)|[^'\\\r\n\f])*(?:'|[\r\n\f]|$)|\/\*[\s\S]*?(?:\*\/|$)|@(?:(?:import|config|plugin)\s+['"]([^'"]+)['"]|import\s+url\(\s*(?:['"]([^'"]+)['"]|([^'")\s]+))\s*\))[^;]
|
|
3
|
+
const directiveMatcher = /"(?:\\(?:\r\n|[\s\S]|$)|[^"\\\r\n\f])*(?:"|[\r\n\f]|$)|'(?:\\(?:\r\n|[\s\S]|$)|[^'\\\r\n\f])*(?:'|[\r\n\f]|$)|\/\*[\s\S]*?(?:\*\/|$)|@(?:(?:import|config|plugin|reference)\s+['"]([^'"]+)['"]|import\s+url\(\s*(?:['"]([^'"]+)['"]|([^'")\s]+))\s*\))(?:\s*\{|[^;]*;)|url\(\s*(?:["']([^"'\r\n]*)["']|([^'")\s]+))\s*\)/g;
|
|
3
4
|
const compiler = (text) => {
|
|
4
|
-
if (!text.includes('@import') &&
|
|
5
|
+
if (!text.includes('@import') &&
|
|
6
|
+
!text.includes('@config') &&
|
|
7
|
+
!text.includes('@plugin') &&
|
|
8
|
+
!text.includes('@reference') &&
|
|
9
|
+
!text.includes('url('))
|
|
5
10
|
return '';
|
|
6
11
|
const imports = [];
|
|
7
12
|
let match;
|
|
8
13
|
let index = 0;
|
|
9
14
|
directiveMatcher.lastIndex = 0;
|
|
10
15
|
while ((match = directiveMatcher.exec(text))) {
|
|
16
|
+
const asset = match[4] ?? match[5];
|
|
17
|
+
if (asset !== undefined) {
|
|
18
|
+
const specifier = getUrlSpecifier(asset);
|
|
19
|
+
if (specifier)
|
|
20
|
+
imports.push(`import _$${index++} from '${specifier}';`);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
11
23
|
const url = match[2] ?? match[3];
|
|
12
24
|
const specifier = match[1] ?? url;
|
|
13
25
|
if (!specifier || (url && (url.startsWith('//') || hasUrlScheme(url))))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isFile } from '../../util/fs.js';
|
|
2
2
|
const title = 'Travis CI';
|
|
3
3
|
const enablers = 'This plugin is enabled when a `.travis.yml` file is found in the root folder.';
|
|
4
|
-
const isEnabled =
|
|
4
|
+
const isEnabled = ({ cwd }) => isFile(cwd, '.travis.yml');
|
|
5
5
|
const isRootOnly = true;
|
|
6
6
|
const config = ['.travis.yml'];
|
|
7
7
|
const resolveConfig = async (config, options) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
2
|
import { toConfig, toDeferResolve, toDependency, toProductionDependency } from '../../util/input.js';
|
|
3
|
-
import { join } from '../../util/path.js';
|
|
3
|
+
import { join, toAbsolute } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
5
|
import { contentMapperResolvers } from './content-mappers.js';
|
|
6
6
|
const title = 'TypeScript';
|
|
@@ -22,9 +22,7 @@ export const resolveConfig = (localConfig, options) => {
|
|
|
22
22
|
const extend = localConfig.extends
|
|
23
23
|
? [localConfig.extends].flat().map(specifier => toConfig(options.pluginName, specifier))
|
|
24
24
|
: [];
|
|
25
|
-
const references = localConfig.references
|
|
26
|
-
?.filter(reference => reference.path.endsWith('.json'))
|
|
27
|
-
.map(reference => toConfig(options.pluginName, reference.path)) ?? [];
|
|
25
|
+
const references = localConfig.references?.map(({ path }) => toConfig(options.pluginName, path.endsWith('.json') ? path : toAbsolute(join(path, 'tsconfig.json'), options.configFileDir))) ?? [];
|
|
28
26
|
const contentMappers = resolveContentMappers(localConfig);
|
|
29
27
|
if (!(compilerOptions && localConfig))
|
|
30
28
|
return compact([...contentMappers, ...extend, ...references]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Input } from '../../util/input.ts';
|
|
2
2
|
import type { AliasOptions, ViteConfig } from './types.ts';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const toEnvDependency: (env: string) => Input;
|
|
4
4
|
export declare const getAliasInputs: (aliasOptions: AliasOptions, cwd: string) => Input[];
|
|
5
5
|
export declare const getExternalReporters: (reporters?: ViteConfig['test']['reporters']) => string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toAlias } from '../../util/input.js';
|
|
1
|
+
import { toAlias, toDependency } from '../../util/input.js';
|
|
2
2
|
import { join, toPosix } from '../../util/path.js';
|
|
3
3
|
const environments = {
|
|
4
4
|
node: null,
|
|
@@ -11,11 +11,12 @@ const envPackageNames = {
|
|
|
11
11
|
'happy-dom': 'happy-dom',
|
|
12
12
|
'edge-runtime': '@edge-runtime/vm',
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const getEnvSpecifier = (env) => {
|
|
15
15
|
if (env in envPackageNames)
|
|
16
16
|
return envPackageNames[env];
|
|
17
17
|
return `vitest-environment-${env}`;
|
|
18
18
|
};
|
|
19
|
+
export const toEnvDependency = (env) => toDependency(getEnvSpecifier(env), env === 'nuxt' ? { optional: true } : undefined);
|
|
19
20
|
const builtInReporters = [
|
|
20
21
|
'agent',
|
|
21
22
|
'basic',
|
|
@@ -34,9 +35,18 @@ const builtInReporters = [
|
|
|
34
35
|
'verbose',
|
|
35
36
|
];
|
|
36
37
|
const addStar = (value) => (value.endsWith('*') ? value : join(value, '*').replace(/\/\*\*$/, '/*'));
|
|
38
|
+
const getAliasEntries = (aliasOptions) => {
|
|
39
|
+
if (!Array.isArray(aliasOptions))
|
|
40
|
+
return Object.entries(aliasOptions);
|
|
41
|
+
const entries = [];
|
|
42
|
+
for (const { find, replacement } of aliasOptions)
|
|
43
|
+
if (typeof find === 'string')
|
|
44
|
+
entries.push([find, replacement]);
|
|
45
|
+
return entries;
|
|
46
|
+
};
|
|
37
47
|
export const getAliasInputs = (aliasOptions, cwd) => {
|
|
38
48
|
const inputs = [];
|
|
39
|
-
for (const [alias, value] of
|
|
49
|
+
for (const [alias, value] of getAliasEntries(aliasOptions)) {
|
|
40
50
|
if (!value)
|
|
41
51
|
continue;
|
|
42
52
|
const prefixes = [value]
|