knip 6.34.0 → 6.35.1
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/CatalogCounselor.d.ts +2 -0
- package/dist/CatalogCounselor.js +30 -7
- package/dist/ConfigurationChief.d.ts +6 -0
- package/dist/ConfigurationChief.js +3 -5
- package/dist/IssueCollector.d.ts +3 -0
- package/dist/IssueCollector.js +5 -0
- package/dist/ProjectPrincipal.d.ts +9 -10
- package/dist/ProjectPrincipal.js +45 -52
- package/dist/WorkspaceWorker.d.ts +5 -3
- package/dist/WorkspaceWorker.js +9 -6
- package/dist/YamlCatalogPeeker.d.ts +4 -0
- package/dist/YamlCatalogPeeker.js +17 -0
- package/dist/binaries/bash-parser.d.ts +1 -1
- package/dist/binaries/bash-parser.js +12 -58
- package/dist/binaries/command.d.ts +5 -0
- package/dist/binaries/command.js +47 -0
- package/dist/binaries/fallback.d.ts +2 -0
- package/dist/binaries/fallback.js +2 -0
- package/dist/binaries/plugins.d.ts +1 -0
- package/dist/binaries/plugins.js +2 -1
- package/dist/binaries/resolvers/pnpm.js +1 -0
- package/dist/binaries/util.d.ts +1 -0
- package/dist/binaries/util.js +12 -0
- package/dist/cli.js +12 -26
- package/dist/compilers/index.d.ts +3 -1866
- package/dist/compilers/index.js +17 -27
- package/dist/compilers/types.d.ts +4 -5
- package/dist/graph/analyze.js +71 -53
- package/dist/graph/build.d.ts +3 -3
- package/dist/graph/build.js +64 -31
- package/dist/index.d.ts +1 -0
- package/dist/plugins/_vue/auto-import.js +28 -4
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/mise/index.d.ts +3 -0
- package/dist/plugins/mise/index.js +82 -0
- package/dist/plugins/mise/scripts.d.ts +7 -0
- package/dist/plugins/mise/scripts.js +108 -0
- package/dist/plugins/mise/types.d.ts +26 -0
- package/dist/plugins/mise/types.js +1 -0
- package/dist/plugins/rstest/index.js +3 -2
- package/dist/plugins/rstest/types.d.ts +3 -1
- package/dist/plugins/vite/helpers.d.ts +2 -2
- package/dist/plugins/vite/helpers.js +18 -11
- package/dist/plugins/vite/visitors/importMetaGlob.js +12 -0
- package/dist/plugins/vitest/index.js +5 -2
- package/dist/plugins/vitest/types.d.ts +1 -0
- package/dist/reporters/util/configuration-hints.d.ts +1 -1
- package/dist/reporters/util/configuration-hints.js +11 -2
- package/dist/run.d.ts +2 -0
- package/dist/run.js +2 -1
- package/dist/schema/configuration.d.ts +20 -4
- package/dist/schema/configuration.js +5 -6
- package/dist/schema/plugins.d.ts +5 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +1 -1
- package/dist/session/session.js +22 -4
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/config.d.ts +4 -4
- package/dist/types/issues.d.ts +1 -0
- package/dist/types/module-graph.d.ts +2 -0
- package/dist/types.d.ts +1 -0
- package/dist/typescript/SourceFileManager.d.ts +13 -9
- package/dist/typescript/SourceFileManager.js +58 -22
- package/dist/typescript/get-imports-and-exports.js +2 -1
- package/dist/typescript/resolve-module-names.js +7 -27
- package/dist/typescript/visitors/exports.js +8 -4
- package/dist/util/catalog.d.ts +5 -0
- package/dist/util/catalog.js +37 -17
- package/dist/util/create-options.d.ts +17 -3
- package/dist/util/create-options.js +14 -3
- package/dist/util/errors.d.ts +3 -1
- package/dist/util/errors.js +6 -1
- package/dist/util/file-entry-cache.js +2 -2
- package/dist/util/module-graph.js +1 -0
- package/dist/util/package-json.d.ts +1 -0
- package/dist/util/preprocessor.d.ts +6 -0
- package/dist/util/preprocessor.js +24 -0
- package/dist/util/reporter.d.ts +0 -1
- package/dist/util/reporter.js +0 -7
- package/dist/util/watch.d.ts +2 -1
- package/dist/util/watch.js +33 -15
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -7
- package/schema.json +12 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isFile } from '../../util/fs.js';
|
|
2
|
+
import { isEntry } from '../../util/input.js';
|
|
3
|
+
import { basename, dirname, join, toAbsolute } from '../../util/path.js';
|
|
4
|
+
const title = 'mise';
|
|
5
|
+
const enablers = 'This plugin is enabled when `mise.toml` or `.mise.toml` is found.';
|
|
6
|
+
const config = [
|
|
7
|
+
'{mise,.mise}{,.*}.toml',
|
|
8
|
+
'{mise,.mise}/config{,.*}.toml',
|
|
9
|
+
'.config/mise{,.*}.toml',
|
|
10
|
+
'.config/mise/config{,.*}.toml',
|
|
11
|
+
'.config/mise/mise{,.local}.toml',
|
|
12
|
+
'{mise,.mise}/conf.d/[!.]*.toml',
|
|
13
|
+
'.config/mise/conf.d/[!.]*.toml',
|
|
14
|
+
];
|
|
15
|
+
const isEnabled = ({ cwd }) => isFile(cwd, 'mise.toml') || isFile(cwd, '.mise.toml');
|
|
16
|
+
const getConfigRoot = (configFileDir, configFileName) => {
|
|
17
|
+
const isFragment = basename(configFileDir) === 'conf.d';
|
|
18
|
+
const groupedDir = isFragment ? dirname(configFileDir) : configFileDir;
|
|
19
|
+
const name = basename(groupedDir);
|
|
20
|
+
const root = (isFragment || configFileName.startsWith('config.')) && (name === 'mise' || name === '.mise')
|
|
21
|
+
? dirname(groupedDir)
|
|
22
|
+
: configFileDir;
|
|
23
|
+
return basename(root) === '.config' ? dirname(root) : root;
|
|
24
|
+
};
|
|
25
|
+
const hasTemplate = (value) => value.includes('{{') || value.includes('{%');
|
|
26
|
+
const resolvePath = (value, root) => {
|
|
27
|
+
const expanded = value.replace(/\{\{\s*config_root\s*\}\}/g, () => root);
|
|
28
|
+
if (hasTemplate(expanded) || expanded.startsWith('~') || expanded.includes('$'))
|
|
29
|
+
return;
|
|
30
|
+
return join(toAbsolute(expanded, root), '.');
|
|
31
|
+
};
|
|
32
|
+
const resolveConfig = async (localConfig, options) => {
|
|
33
|
+
const { getInputsFromMiseScript } = await import('./scripts.js');
|
|
34
|
+
const { configFileDir, configFileName, getManifest, isProduction } = options;
|
|
35
|
+
const configRoot = getConfigRoot(configFileDir, configFileName);
|
|
36
|
+
const inputs = [];
|
|
37
|
+
for (const task of Object.values(localConfig.tasks ?? {})) {
|
|
38
|
+
const taskConfig = typeof task === 'string' || Array.isArray(task) ? { run: task } : task;
|
|
39
|
+
const dir = resolvePath(taskConfig.dir ?? localConfig.task_config?.dir ?? '.', configRoot);
|
|
40
|
+
if (!dir)
|
|
41
|
+
continue;
|
|
42
|
+
let hasLocalBinPath = false;
|
|
43
|
+
for (const env of [localConfig.env ?? [], taskConfig.env ?? []].flat()) {
|
|
44
|
+
if (Object.hasOwn(env, 'PATH'))
|
|
45
|
+
hasLocalBinPath = false;
|
|
46
|
+
const paths = env._?.path;
|
|
47
|
+
for (const path of typeof paths === 'string' ? [paths] : Array.isArray(paths) ? paths : []) {
|
|
48
|
+
if (typeof path === 'string' && resolvePath(path, configRoot) === join(dir, 'node_modules/.bin')) {
|
|
49
|
+
hasLocalBinPath = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const manifest = getManifest(dir) ?? options.manifest;
|
|
54
|
+
const scriptOptions = {
|
|
55
|
+
...options,
|
|
56
|
+
cwd: dir,
|
|
57
|
+
manifest,
|
|
58
|
+
containingFilePath: options.configFilePath,
|
|
59
|
+
};
|
|
60
|
+
for (const script of [taskConfig.run ?? [], taskConfig.run_windows ?? []].flat()) {
|
|
61
|
+
if (typeof script !== 'string' || hasTemplate(script))
|
|
62
|
+
continue;
|
|
63
|
+
for (const input of getInputsFromMiseScript(script, scriptOptions, hasLocalBinPath)) {
|
|
64
|
+
if (isProduction)
|
|
65
|
+
input.optional = true;
|
|
66
|
+
input.dir ??= dir;
|
|
67
|
+
if (isEntry(input))
|
|
68
|
+
input.specifier = toAbsolute(input.specifier, input.dir);
|
|
69
|
+
inputs.push(input);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return inputs;
|
|
74
|
+
};
|
|
75
|
+
const plugin = {
|
|
76
|
+
title,
|
|
77
|
+
enablers,
|
|
78
|
+
isEnabled,
|
|
79
|
+
config,
|
|
80
|
+
resolveConfig,
|
|
81
|
+
};
|
|
82
|
+
export default plugin;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GetInputsFromScriptsOptions, GetInputsFromScriptsPartial } from '../../types/config.ts';
|
|
2
|
+
import { type Input } from '../../util/input.ts';
|
|
3
|
+
type Options = GetInputsFromScriptsOptions & {
|
|
4
|
+
getInputsFromScripts: GetInputsFromScriptsPartial;
|
|
5
|
+
};
|
|
6
|
+
export declare const getInputsFromMiseScript: (script: string, options: Options, hasLocalBinPath: boolean) => Input[];
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { parse } from 'unbash';
|
|
2
|
+
import { getDependenciesFromCommand, getInputsFromNodeOptions } from '../../binaries/command.js';
|
|
3
|
+
import { spawningBinaries } from '../../binaries/fallback.js';
|
|
4
|
+
import { isWrapper } from '../../binaries/plugins.js';
|
|
5
|
+
import KnownResolvers from '../../binaries/resolvers/index.js';
|
|
6
|
+
import { toScript } from '../../binaries/util.js';
|
|
7
|
+
import { SCRIPT_INTERPOLATION } from '../../constants.js';
|
|
8
|
+
import { isBinary } from '../../util/input.js';
|
|
9
|
+
import { extractBinary } from '../../util/modules.js';
|
|
10
|
+
import { walkCommands } from '../../util/scripts.js';
|
|
11
|
+
export const getInputsFromMiseScript = (script, options, hasLocalBinPath) => {
|
|
12
|
+
const inputs = [];
|
|
13
|
+
const definedFunctions = new Set();
|
|
14
|
+
const readParts = (parts) => {
|
|
15
|
+
let text = '';
|
|
16
|
+
let value = '';
|
|
17
|
+
let hasExpansion = false;
|
|
18
|
+
for (const part of parts) {
|
|
19
|
+
if (part.type === 'CommandExpansion' || part.type === 'ProcessSubstitution') {
|
|
20
|
+
if (part.script)
|
|
21
|
+
readScript(part.script);
|
|
22
|
+
text += SCRIPT_INTERPOLATION;
|
|
23
|
+
value += SCRIPT_INTERPOLATION;
|
|
24
|
+
hasExpansion = true;
|
|
25
|
+
}
|
|
26
|
+
else if (part.type === 'DoubleQuoted' || part.type === 'LocaleString') {
|
|
27
|
+
const inner = readParts(part.parts);
|
|
28
|
+
text += `${part.type === 'LocaleString' ? '$"' : '"'}${inner.text}"`;
|
|
29
|
+
value += inner.value;
|
|
30
|
+
if (inner.hasExpansion)
|
|
31
|
+
hasExpansion = true;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
text += part.text;
|
|
35
|
+
value += 'value' in part ? part.value : part.text;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { text, value, hasExpansion };
|
|
39
|
+
};
|
|
40
|
+
const readWord = (word) => {
|
|
41
|
+
if (!word.parts)
|
|
42
|
+
return word;
|
|
43
|
+
const { text, value, hasExpansion } = readParts(word.parts);
|
|
44
|
+
return hasExpansion ? { ...word, text, value } : word;
|
|
45
|
+
};
|
|
46
|
+
const readScript = (parsed) => {
|
|
47
|
+
for (const statement of parsed.commands) {
|
|
48
|
+
if (statement.command.type === 'Function')
|
|
49
|
+
definedFunctions.add(statement.command.name.value);
|
|
50
|
+
}
|
|
51
|
+
for (const statement of parsed.commands) {
|
|
52
|
+
for (const command of walkCommands(statement.command)) {
|
|
53
|
+
const name = command.name?.value;
|
|
54
|
+
const word = command.name && readWord(command.name);
|
|
55
|
+
const prefix = command.prefix.map(assignment => {
|
|
56
|
+
const value = assignment.value && readWord(assignment.value);
|
|
57
|
+
return value && value !== assignment.value
|
|
58
|
+
? { ...assignment, value, text: `${assignment.name}=${value.text}` }
|
|
59
|
+
: assignment;
|
|
60
|
+
});
|
|
61
|
+
const words = command.suffix.map(readWord);
|
|
62
|
+
if (!name || !word || definedFunctions.has(name))
|
|
63
|
+
continue;
|
|
64
|
+
const binary = extractBinary(name);
|
|
65
|
+
const isPackageManager = binary in KnownResolvers && binary !== 'find';
|
|
66
|
+
const isExplicit = isPackageManager || name.startsWith('./') || /^(?:\.\.?\/)*node_modules\/\.bin\//.test(name);
|
|
67
|
+
const isLocal = hasLocalBinPath && !command.prefix.some(assignment => assignment.name === 'PATH');
|
|
68
|
+
const isWrapperCommand = !isPackageManager && isWrapper(binary);
|
|
69
|
+
if (!isExplicit && !isLocal && !isWrapperCommand && binary !== 'node' && binary !== 'find')
|
|
70
|
+
continue;
|
|
71
|
+
let commandInputs;
|
|
72
|
+
if (isWrapperCommand || binary === 'find') {
|
|
73
|
+
const fromScript = (script) => {
|
|
74
|
+
inputs.push(...getInputsFromMiseScript(script, options, isLocal));
|
|
75
|
+
return [];
|
|
76
|
+
};
|
|
77
|
+
const fromArgs = args => fromScript(toScript(args));
|
|
78
|
+
commandInputs = getDependenciesFromCommand({ ...command, name: word, prefix, suffix: words }, { ...options, fromArgs });
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
commandInputs = options.getInputsFromScripts([...prefix.map(assignment => assignment.text), word.text, ...words.map(word => word.text)].join(' '), { cwd: options.cwd, manifest: options.manifest });
|
|
82
|
+
}
|
|
83
|
+
if (!isExplicit && !isLocal && binary !== 'node' && binary !== 'find')
|
|
84
|
+
continue;
|
|
85
|
+
if (isWrapperCommand && spawningBinaries.includes(binary)) {
|
|
86
|
+
commandInputs.push(...getInputsFromNodeOptions(prefix));
|
|
87
|
+
}
|
|
88
|
+
const binaryInput = commandInputs.find(input => isBinary(input) && input.specifier === binary);
|
|
89
|
+
if (!isExplicit && isLocal && binaryInput)
|
|
90
|
+
binaryInput.optional = true;
|
|
91
|
+
for (const input of commandInputs) {
|
|
92
|
+
if (!input.specifier || input.specifier.includes(SCRIPT_INTERPOLATION))
|
|
93
|
+
continue;
|
|
94
|
+
if (!isExplicit && !isLocal && input === binaryInput)
|
|
95
|
+
continue;
|
|
96
|
+
inputs.push(input);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
readScript(parse(script));
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
return inputs;
|
|
108
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type MiseEnvironment = {
|
|
2
|
+
PATH?: unknown;
|
|
3
|
+
_?: {
|
|
4
|
+
path?: string | string[];
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
type TaskReference = {
|
|
8
|
+
task: string;
|
|
9
|
+
} | {
|
|
10
|
+
tasks: string[];
|
|
11
|
+
};
|
|
12
|
+
type Run = string | (string | TaskReference)[];
|
|
13
|
+
type MiseTask = {
|
|
14
|
+
run?: Run;
|
|
15
|
+
run_windows?: Run;
|
|
16
|
+
dir?: string;
|
|
17
|
+
env?: MiseEnvironment;
|
|
18
|
+
};
|
|
19
|
+
export type MiseConfig = {
|
|
20
|
+
tasks?: Record<string, string | string[] | MiseTask>;
|
|
21
|
+
env?: MiseEnvironment | MiseEnvironment[];
|
|
22
|
+
task_config?: {
|
|
23
|
+
dir?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,9 +7,10 @@ const config = ['rstest.config.{js,cjs,mjs,ts,cts,mts}'];
|
|
|
7
7
|
const mocks = ['**/__mocks__/**/*.?(c|m)[jt]s?(x)'];
|
|
8
8
|
const entry = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
|
|
9
9
|
function testEnvironment(config) {
|
|
10
|
-
|
|
10
|
+
const environment = typeof config.testEnvironment === 'string' ? config.testEnvironment : config.testEnvironment?.name;
|
|
11
|
+
if (!environment || environment === 'node')
|
|
11
12
|
return [];
|
|
12
|
-
return [
|
|
13
|
+
return [environment];
|
|
13
14
|
}
|
|
14
15
|
const resolveConfig = async (config) => {
|
|
15
16
|
const entries = (config.include ?? entry)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Program } from 'oxc-parser';
|
|
2
2
|
import { type Input } from '../../util/input.ts';
|
|
3
3
|
export declare const getBabelInputs: (program: Program) => Input[];
|
|
4
|
-
export declare const getHtmlScriptEntries: (htmlPath: string) => Promise<Input[]>;
|
|
5
|
-
export declare const getIndexHtmlEntries: (rootDir: string) => Promise<Input[]>;
|
|
4
|
+
export declare const getHtmlScriptEntries: (htmlPath: string, publicDir?: string) => Promise<Input[]>;
|
|
5
|
+
export declare const getIndexHtmlEntries: (rootDir: string, publicDir?: string) => Promise<Input[]>;
|
|
6
6
|
export declare const getVitePluginDirs: (program: Program, specifiers: string[], key: string) => string[] | undefined;
|
|
@@ -3,7 +3,7 @@ import { findImportedCalls, findProperty, getStringValues } from '../../typescri
|
|
|
3
3
|
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
4
4
|
import { isFile, loadFile } from '../../util/fs.js';
|
|
5
5
|
import { toProductionEntry } from '../../util/input.js';
|
|
6
|
-
import { dirname, join } from '../../util/path.js';
|
|
6
|
+
import { dirname, join, toAbsolute } from '../../util/path.js';
|
|
7
7
|
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
8
8
|
const babelPluginSources = ['@rolldown/plugin-babel', '@vitejs/plugin-react', 'vite-plugin-babel'];
|
|
9
9
|
const isBabelWrappingPlugin = (path) => babelPluginSources.some(source => path === source || path.startsWith(`${source}/`));
|
|
@@ -26,19 +26,26 @@ const srcAttrPattern = /\bsrc\s*=\s*["']([^"']+)["']/i;
|
|
|
26
26
|
const importSpecPattern = /\bimport\b(?:\s*\(\s*|(?:[\w$*,{}\s]*\bfrom\b)?\s*)(['"])([^'"]+)\1/g;
|
|
27
27
|
const isFilePath = (specifier) => specifier.startsWith('/') || specifier.startsWith('./') || specifier.startsWith('../');
|
|
28
28
|
const normalizeModuleScriptSrc = (value) => value.trim().replace(/^\//, '');
|
|
29
|
-
const
|
|
29
|
+
const getScriptSources = (html, publicDir) => {
|
|
30
30
|
const sources = [];
|
|
31
31
|
for (const [, attrs, body] of html.matchAll(scriptExtractor)) {
|
|
32
|
-
if (!moduleTypePattern.test(attrs))
|
|
33
|
-
continue;
|
|
34
32
|
const srcMatch = attrs.match(srcAttrPattern);
|
|
35
33
|
if (srcMatch) {
|
|
36
|
-
const src =
|
|
37
|
-
if (src)
|
|
38
|
-
|
|
34
|
+
const src = srcMatch[1].trim();
|
|
35
|
+
if (!src || /^(?:[\w+.-]+:|\/\/)/.test(src))
|
|
36
|
+
continue;
|
|
37
|
+
if (publicDir && src.startsWith('/')) {
|
|
38
|
+
const publicPath = join(publicDir, src.split(/[?#]/, 1)[0]);
|
|
39
|
+
if (publicPath.startsWith(join(publicDir, '/')) && isFile(publicPath)) {
|
|
40
|
+
sources.push(publicPath);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (moduleTypePattern.test(attrs))
|
|
45
|
+
sources.push(normalizeModuleScriptSrc(src));
|
|
39
46
|
continue;
|
|
40
47
|
}
|
|
41
|
-
if (body) {
|
|
48
|
+
if (moduleTypePattern.test(attrs) && body) {
|
|
42
49
|
const code = body.replace(blockCommentMatcher, '').replace(lineCommentMatcher, '');
|
|
43
50
|
for (const importMatch of code.matchAll(importSpecPattern)) {
|
|
44
51
|
const specifier = importMatch[2];
|
|
@@ -49,14 +56,14 @@ const getModuleScriptSources = (html) => {
|
|
|
49
56
|
}
|
|
50
57
|
return sources;
|
|
51
58
|
};
|
|
52
|
-
export const getHtmlScriptEntries = async (htmlPath) => {
|
|
59
|
+
export const getHtmlScriptEntries = async (htmlPath, publicDir) => {
|
|
53
60
|
if (!isFile(htmlPath))
|
|
54
61
|
return [];
|
|
55
62
|
const html = await loadFile(htmlPath);
|
|
56
63
|
const dir = dirname(htmlPath);
|
|
57
|
-
return
|
|
64
|
+
return getScriptSources(html, publicDir).map(src => toProductionEntry(toAbsolute(src, dir)));
|
|
58
65
|
};
|
|
59
|
-
export const getIndexHtmlEntries = (rootDir) => getHtmlScriptEntries(join(rootDir, 'index.html'));
|
|
66
|
+
export const getIndexHtmlEntries = (rootDir, publicDir) => getHtmlScriptEntries(join(rootDir, 'index.html'), publicDir);
|
|
60
67
|
export const getVitePluginDirs = (program, specifiers, key) => {
|
|
61
68
|
let dirs;
|
|
62
69
|
for (const call of findImportedCalls(program, specifiers)) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { findProperty } from '../../../typescript/ast-helpers.js';
|
|
1
2
|
import { getStringValue, isStringLiteral } from '../../../typescript/ast-nodes.js';
|
|
3
|
+
const RAW_QUERY_RE = /(\?|&)raw(?:&|$)/;
|
|
2
4
|
export function createImportMetaGlobVisitor(ctx) {
|
|
3
5
|
return {
|
|
4
6
|
CallExpression(node) {
|
|
@@ -22,6 +24,16 @@ export function createImportMetaGlobVisitor(ctx) {
|
|
|
22
24
|
}
|
|
23
25
|
if (!patterns?.length)
|
|
24
26
|
return;
|
|
27
|
+
const options = node.arguments[1];
|
|
28
|
+
if (options?.type === 'ObjectExpression') {
|
|
29
|
+
const queryNode = findProperty(options, 'query');
|
|
30
|
+
const query = getStringValue(queryNode);
|
|
31
|
+
const isRaw = getStringValue(findProperty(options, 'as')) === 'raw' ||
|
|
32
|
+
(query !== undefined && RAW_QUERY_RE.test(query.startsWith('?') ? query : `?${query}`)) ||
|
|
33
|
+
getStringValue(findProperty(queryNode, 'raw')) === '';
|
|
34
|
+
if (isRaw)
|
|
35
|
+
return ctx.addImportGlob(patterns, { analyzeExports: true });
|
|
36
|
+
}
|
|
25
37
|
ctx.addImportGlob(patterns);
|
|
26
38
|
},
|
|
27
39
|
};
|
|
@@ -2,7 +2,7 @@ import { DEFAULT_EXTENSIONS } from '../../constants.js';
|
|
|
2
2
|
import { _glob } from '../../util/glob.js';
|
|
3
3
|
import { toConfig, toDeferResolve, toDependency, toEntry } from '../../util/input.js';
|
|
4
4
|
import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
5
|
-
import { isAbsolute, isInternal, join, toAbsolute } from '../../util/path.js';
|
|
5
|
+
import { isAbsolute, isInternal, join, toAbsolute, toPosix } from '../../util/path.js';
|
|
6
6
|
import { hasDependency } from '../../util/plugin.js';
|
|
7
7
|
import { getIndexHtmlEntries } from '../vite/helpers.js';
|
|
8
8
|
import { getAliasInputs, getEnvSpecifier, getExternalReporters } from './helpers.js';
|
|
@@ -137,7 +137,10 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
137
137
|
const viteRoot = toAbsolute(cfg.root ?? '.', options.cwd);
|
|
138
138
|
if (!seenRoots.has(viteRoot)) {
|
|
139
139
|
seenRoots.add(viteRoot);
|
|
140
|
-
|
|
140
|
+
const publicDir = cfg.publicDir === false || cfg.publicDir === ''
|
|
141
|
+
? undefined
|
|
142
|
+
: toAbsolute(toPosix(cfg.publicDir ?? 'public'), viteRoot);
|
|
143
|
+
for (const entry of await getIndexHtmlEntries(viteRoot, publicDir))
|
|
141
144
|
inputs.add(entry);
|
|
142
145
|
}
|
|
143
146
|
const vitestRoot = toAbsolute(cfg.test?.root ?? '.', options.cwd);
|
|
@@ -18,6 +18,6 @@ export declare const finalizeConfigurationHints: (results: Results, options: {
|
|
|
18
18
|
cwd: string;
|
|
19
19
|
configFilePath?: string;
|
|
20
20
|
}) => ProcessedHint[];
|
|
21
|
-
export declare const printConfigurationHints: ({ cwd, counters, issues, tagHints, configurationHints, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }: ReporterOptions) => void;
|
|
21
|
+
export declare const printConfigurationHints: ({ cwd, counters, issues, tagHints, configurationHints, hasConfigLoadErrors, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }: ReporterOptions) => void;
|
|
22
22
|
export declare const printTagHints: ({ cwd, tagHints, isTreatTagHintsAsErrors }: ReporterOptions) => void;
|
|
23
23
|
export {};
|
|
@@ -128,8 +128,17 @@ export const finalizeConfigurationHints = (results, options) => {
|
|
|
128
128
|
return row;
|
|
129
129
|
}));
|
|
130
130
|
};
|
|
131
|
-
export const printConfigurationHints = ({ cwd, counters, issues, tagHints, configurationHints, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }) => {
|
|
132
|
-
const rows = finalizeConfigurationHints({
|
|
131
|
+
export const printConfigurationHints = ({ cwd, counters, issues, tagHints, configurationHints, hasConfigLoadErrors, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }) => {
|
|
132
|
+
const rows = finalizeConfigurationHints({
|
|
133
|
+
issues,
|
|
134
|
+
counters,
|
|
135
|
+
configurationHints,
|
|
136
|
+
hasConfigLoadErrors,
|
|
137
|
+
tagHints,
|
|
138
|
+
includedWorkspaceDirs,
|
|
139
|
+
selectedWorkspaces,
|
|
140
|
+
enabledPlugins,
|
|
141
|
+
}, { cwd, configFilePath });
|
|
133
142
|
if (rows.length > 0) {
|
|
134
143
|
const getTitle = isTreatConfigHintsAsErrors ? getColoredTitle : getDimmedTitle;
|
|
135
144
|
console.warn(getTitle('Configuration hints', configurationHints.length));
|
package/dist/run.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const run: (options: MainOptions) => Promise<{
|
|
|
7
7
|
counters: import("./types/issues.ts").Counters;
|
|
8
8
|
tagHints: Set<import("./types/issues.ts").TagHint>;
|
|
9
9
|
configurationHints: import("./types/issues.ts").ConfigurationHint[];
|
|
10
|
+
hasConfigLoadErrors: boolean;
|
|
10
11
|
selectedWorkspaces: string[] | undefined;
|
|
11
12
|
includedWorkspaceDirs: string[];
|
|
12
13
|
enabledPlugins: {
|
|
@@ -26,6 +27,7 @@ export declare const run: (options: MainOptions) => Promise<{
|
|
|
26
27
|
counters: import("./types/issues.ts").Counters;
|
|
27
28
|
tagHints: Set<import("./types/issues.ts").TagHint>;
|
|
28
29
|
configurationHints: import("./types/issues.ts").ConfigurationHint[];
|
|
30
|
+
hasConfigLoadErrors: boolean;
|
|
29
31
|
};
|
|
30
32
|
} | undefined;
|
|
31
33
|
streamer: ConsoleStreamer;
|
package/dist/run.js
CHANGED
|
@@ -114,7 +114,7 @@ export const run = async (options) => {
|
|
|
114
114
|
if (options.isWatch)
|
|
115
115
|
watch('.', { recursive: true }, session.listener);
|
|
116
116
|
}
|
|
117
|
-
const { issues, counters, tagHints, configurationHints } = collector.getIssues();
|
|
117
|
+
const { issues, counters, tagHints, configurationHints, hasConfigLoadErrors } = collector.getIssues();
|
|
118
118
|
if (!options.isWatch)
|
|
119
119
|
streamer.clear();
|
|
120
120
|
if (options.isCache) {
|
|
@@ -127,6 +127,7 @@ export const run = async (options) => {
|
|
|
127
127
|
counters,
|
|
128
128
|
tagHints,
|
|
129
129
|
configurationHints,
|
|
130
|
+
hasConfigLoadErrors,
|
|
130
131
|
selectedWorkspaces: chief.selectedWorkspaces ? Array.from(chief.selectedWorkspaces) : undefined,
|
|
131
132
|
includedWorkspaceDirs: Array.from(chief.workspacesByDir.keys()),
|
|
132
133
|
enabledPlugins: Object.fromEntries(enabledPluginsStore),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod/mini';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Compiler } from '../compilers/types.ts';
|
|
3
3
|
export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
|
|
4
4
|
angular: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
5
5
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -321,6 +321,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
|
|
|
321
321
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
322
322
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
323
323
|
}, z.core.$strip>]>>;
|
|
324
|
+
mise: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
325
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
326
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
327
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
328
|
+
}, z.core.$strip>]>>;
|
|
324
329
|
mocha: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
325
330
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
326
331
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -1247,6 +1252,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
1247
1252
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1248
1253
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1249
1254
|
}, z.core.$strip>]>>;
|
|
1255
|
+
mise: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
1256
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1257
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1258
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1259
|
+
}, z.core.$strip>]>>;
|
|
1250
1260
|
mocha: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
1251
1261
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1252
1262
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -1862,12 +1872,13 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
1862
1872
|
}, z.core.$strict>>;
|
|
1863
1873
|
ignoreWorkspaces: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
1864
1874
|
includeEntryExports: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1865
|
-
compilers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.
|
|
1866
|
-
|
|
1867
|
-
asyncCompilers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniCustom<CompilerAsync, CompilerAsync>>>;
|
|
1875
|
+
compilers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniLiteral<true>, z.ZodMiniCustom<Compiler, Compiler>]>>>;
|
|
1876
|
+
asyncCompilers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniCustom<Compiler, Compiler>>>;
|
|
1868
1877
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
1869
1878
|
treatConfigHintsAsErrors: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1870
1879
|
treatTagHintsAsErrors: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1880
|
+
preprocessor: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1881
|
+
preprocessorOptions: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
1871
1882
|
include: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"namespaceMembers">, z.ZodMiniLiteral<"catalog">, z.ZodMiniLiteral<"catalogReferences">, z.ZodMiniLiteral<"cycles">]>>>;
|
|
1872
1883
|
exclude: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"namespaceMembers">, z.ZodMiniLiteral<"catalog">, z.ZodMiniLiteral<"catalogReferences">, z.ZodMiniLiteral<"cycles">]>>>;
|
|
1873
1884
|
workspaces: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
@@ -2191,6 +2202,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
2191
2202
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2192
2203
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2193
2204
|
}, z.core.$strip>]>>;
|
|
2205
|
+
mise: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
2206
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2207
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2208
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2209
|
+
}, z.core.$strip>]>>;
|
|
2194
2210
|
mocha: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
2195
2211
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2196
2212
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -2,10 +2,8 @@ import { z } from 'zod/mini';
|
|
|
2
2
|
import { SYMBOL_TYPE } from '../constants.js';
|
|
3
3
|
import { globSchema, pluginsSchema } from './plugins.js';
|
|
4
4
|
const pathsSchema = z.record(z.string(), z.array(z.string()));
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const compilerSchema = z.union([syncCompilerSchema, asyncCompilerSchema]);
|
|
8
|
-
const compilersSchema = z.record(z.string(), compilerSchema);
|
|
5
|
+
const compilerSchema = z.custom();
|
|
6
|
+
const compilersSchema = z.record(z.string(), z.union([z.literal(true), compilerSchema]));
|
|
9
7
|
const stringOrRegexSchema = z.array(z.union([z.string(), z.instanceof(RegExp)]));
|
|
10
8
|
const issueTypeSchema = z.union([
|
|
11
9
|
z.literal('files'),
|
|
@@ -53,11 +51,12 @@ const rootConfigurationSchema = z.object({
|
|
|
53
51
|
ignoreWorkspaces: z.optional(z.array(z.string())),
|
|
54
52
|
includeEntryExports: z.optional(z.boolean()),
|
|
55
53
|
compilers: z.optional(compilersSchema),
|
|
56
|
-
|
|
57
|
-
asyncCompilers: z.optional(z.record(z.string(), asyncCompilerSchema)),
|
|
54
|
+
asyncCompilers: z.optional(z.record(z.string(), compilerSchema)),
|
|
58
55
|
tags: z.optional(z.array(z.string())),
|
|
59
56
|
treatConfigHintsAsErrors: z.optional(z.boolean()),
|
|
60
57
|
treatTagHintsAsErrors: z.optional(z.boolean()),
|
|
58
|
+
preprocessor: z.optional(z.union([z.string(), z.array(z.string())])),
|
|
59
|
+
preprocessorOptions: z.optional(z.record(z.string(), z.unknown())),
|
|
61
60
|
});
|
|
62
61
|
const reportConfigSchema = z.object({
|
|
63
62
|
include: z.optional(z.array(issueTypeSchema)),
|
package/dist/schema/plugins.d.ts
CHANGED
|
@@ -326,6 +326,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
|
|
|
326
326
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
327
327
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
328
328
|
}, z.core.$strip>]>;
|
|
329
|
+
mise: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
330
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
331
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
332
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
333
|
+
}, z.core.$strip>]>;
|
|
329
334
|
mocha: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
330
335
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
331
336
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
package/dist/schema/plugins.js
CHANGED
package/dist/session/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { IMPORT_STAR, KNIP_CONFIG_LOCATIONS, SIDE_EFFECTS } from '../constants.ts';
|
|
1
|
+
export { IMPORT_STAR, ISSUE_TYPES, KNIP_CONFIG_LOCATIONS, SIDE_EFFECTS } from '../constants.ts';
|
|
2
2
|
export type { DependencyNode, DependencyNodes } from '../graph-explorer/operations/get-dependency-usage.ts';
|
|
3
3
|
export { finalizeConfigurationHints } from '../reporters/util/configuration-hints.ts';
|
|
4
4
|
export { getIssuePrefix } from '../reporters/util/util.ts';
|
package/dist/session/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { IMPORT_STAR, KNIP_CONFIG_LOCATIONS, SIDE_EFFECTS } from '../constants.js';
|
|
1
|
+
export { IMPORT_STAR, ISSUE_TYPES, KNIP_CONFIG_LOCATIONS, SIDE_EFFECTS } from '../constants.js';
|
|
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';
|
package/dist/session/session.js
CHANGED
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import { run } from '../run.js';
|
|
2
|
+
import { createPreprocessor, toReporterOptions } from '../util/preprocessor.js';
|
|
2
3
|
import { buildFileDescriptor } from './file-descriptor.js';
|
|
3
4
|
import { buildPackageJsonDescriptor } from './package-json-descriptor.js';
|
|
4
5
|
export const createSession = async (options) => {
|
|
5
6
|
const { session, results } = await run(options);
|
|
6
7
|
if (!session)
|
|
7
8
|
throw new Error('Unable to initialize watch session');
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
const createSessionAdapter = (session, results, options) => {
|
|
11
|
-
return {
|
|
9
|
+
const adapter = {
|
|
12
10
|
handleFileChanges: session.handleFileChanges,
|
|
13
11
|
getIssues: session.getIssues,
|
|
14
12
|
getResults: () => results,
|
|
15
13
|
describeFile: (filePath, opts) => buildFileDescriptor(filePath, options.cwd, session.getGraph(), session.getEntryPaths(), opts),
|
|
16
14
|
describePackageJson: () => buildPackageJsonDescriptor(session.getGraph(), session.getEntryPaths()),
|
|
17
15
|
};
|
|
16
|
+
if (options.preprocessor.length === 0)
|
|
17
|
+
return adapter;
|
|
18
|
+
const input = toReporterOptions(options, results);
|
|
19
|
+
const preprocess = await createPreprocessor(options.preprocessor);
|
|
20
|
+
const updateResults = async () => {
|
|
21
|
+
const data = await preprocess({ ...input, ...structuredClone(session.getIssues()) });
|
|
22
|
+
results.issues = data.issues;
|
|
23
|
+
results.counters = data.counters;
|
|
24
|
+
results.tagHints = data.tagHints;
|
|
25
|
+
results.configurationHints = data.configurationHints;
|
|
26
|
+
};
|
|
27
|
+
await updateResults();
|
|
28
|
+
adapter.handleFileChanges = async (changes) => {
|
|
29
|
+
const update = await session.handleFileChanges(changes);
|
|
30
|
+
if (update)
|
|
31
|
+
await updateResults();
|
|
32
|
+
return update;
|
|
33
|
+
};
|
|
34
|
+
adapter.getIssues = () => results;
|
|
35
|
+
return adapter;
|
|
18
36
|
};
|