knip 5.36.7 → 5.37.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/binaries/package-manager/yarn.js +1 -0
- package/dist/plugins/jest/helpers.d.ts +4 -0
- package/dist/plugins/jest/helpers.js +39 -0
- package/dist/plugins/jest/index.js +11 -22
- package/dist/util/debug.js +2 -1
- package/dist/util/watch.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PluginOptions } from '../../types/config.js';
|
|
2
|
+
import type { JestInitialOptions } from './types.js';
|
|
3
|
+
export declare const resolveExtensibleConfig: (configFilePath: string) => Promise<any>;
|
|
4
|
+
export declare const getReportersDependencies: (config: JestInitialOptions, options: PluginOptions) => string[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { dirname, isInternal, join, toAbsolute } from '../../util/path.js';
|
|
2
|
+
import { load } from '../../util/plugin.js';
|
|
3
|
+
export const resolveExtensibleConfig = async (configFilePath) => {
|
|
4
|
+
let config = await load(configFilePath);
|
|
5
|
+
if (config?.preset) {
|
|
6
|
+
const { preset } = config;
|
|
7
|
+
if (isInternal(preset)) {
|
|
8
|
+
const presetConfigPath = toAbsolute(preset, dirname(configFilePath));
|
|
9
|
+
const presetConfig = await resolveExtensibleConfig(presetConfigPath);
|
|
10
|
+
config = Object.assign({}, presetConfig, config);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return config;
|
|
14
|
+
};
|
|
15
|
+
const getStringPropOrFallback = (prop, fallback) => {
|
|
16
|
+
return typeof prop === 'string' ? prop : fallback;
|
|
17
|
+
};
|
|
18
|
+
export const getReportersDependencies = (config, options) => {
|
|
19
|
+
const jUnitReporterDeps = [];
|
|
20
|
+
for (const reporter of config.reporters ?? []) {
|
|
21
|
+
if (typeof reporter !== 'string' && reporter[0] === 'jest-junit') {
|
|
22
|
+
const { testCasePropertiesFile, testCasePropertiesDirectory, testSuitePropertiesFile, testSuitePropertiesDirectory, } = reporter[1];
|
|
23
|
+
const testCaseFileName = getStringPropOrFallback(testCasePropertiesFile, 'junitProperties.js');
|
|
24
|
+
const testCaseDirectory = getStringPropOrFallback(testCasePropertiesDirectory, options.rootCwd);
|
|
25
|
+
const testCaseFilePath = join(testCaseDirectory, testCaseFileName);
|
|
26
|
+
const testSuiteFileName = getStringPropOrFallback(testSuitePropertiesFile, 'junitTestCaseProperties.js');
|
|
27
|
+
const testSuiteDirectory = getStringPropOrFallback(testSuitePropertiesDirectory, options.rootCwd);
|
|
28
|
+
const testSuiteFilePath = join(testSuiteDirectory, testSuiteFileName);
|
|
29
|
+
jUnitReporterDeps.push(testCaseFilePath);
|
|
30
|
+
jUnitReporterDeps.push(testSuiteFilePath);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const reporters = config.reporters
|
|
34
|
+
? config.reporters
|
|
35
|
+
.map(reporter => (typeof reporter === 'string' ? reporter : reporter[0]))
|
|
36
|
+
.filter(reporter => !['default', 'github-actions', 'summary'].includes(reporter))
|
|
37
|
+
: [];
|
|
38
|
+
return [...reporters, ...jUnitReporterDeps];
|
|
39
|
+
};
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import { toDeferResolve, toEntry } from '../../util/input.js';
|
|
2
|
-
import {
|
|
3
|
-
import { hasDependency
|
|
2
|
+
import { isInternal, join, toAbsolute } from '../../util/path.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
import { getReportersDependencies, resolveExtensibleConfig } from './helpers.js';
|
|
4
5
|
const title = 'Jest';
|
|
5
6
|
const enablers = ['jest'];
|
|
6
7
|
const isEnabled = ({ dependencies, manifest }) => hasDependency(dependencies, enablers) || Boolean(manifest.name?.startsWith('jest-presets'));
|
|
7
8
|
const config = ['jest.config.{js,ts,mjs,cjs,json}', 'package.json'];
|
|
8
9
|
const entry = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
|
|
9
|
-
const resolveExtensibleConfig = async (configFilePath) => {
|
|
10
|
-
let config = await load(configFilePath);
|
|
11
|
-
if (config?.preset) {
|
|
12
|
-
const { preset } = config;
|
|
13
|
-
if (isInternal(preset)) {
|
|
14
|
-
const presetConfigPath = toAbsolute(preset, dirname(configFilePath));
|
|
15
|
-
const presetConfig = await resolveExtensibleConfig(presetConfigPath);
|
|
16
|
-
config = Object.assign({}, presetConfig, config);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return config;
|
|
20
|
-
};
|
|
21
10
|
const resolveDependencies = async (config, options) => {
|
|
22
11
|
const { configFileDir } = options;
|
|
23
12
|
if (config?.preset) {
|
|
@@ -42,13 +31,13 @@ const resolveDependencies = async (config, options) => {
|
|
|
42
31
|
}
|
|
43
32
|
const runner = config.runner ? [config.runner] : [];
|
|
44
33
|
const runtime = config.runtime && config.runtime !== 'jest-circus' ? [config.runtime] : [];
|
|
45
|
-
const environments = config.testEnvironment === 'jsdom'
|
|
34
|
+
const environments = config.testEnvironment === 'jsdom'
|
|
35
|
+
? ['jest-environment-jsdom']
|
|
36
|
+
: config.testEnvironment
|
|
37
|
+
? [config.testEnvironment]
|
|
38
|
+
: [];
|
|
46
39
|
const resolvers = config.resolver ? [config.resolver] : [];
|
|
47
|
-
const reporters = config
|
|
48
|
-
? config.reporters
|
|
49
|
-
.map(reporter => (typeof reporter === 'string' ? reporter : reporter[0]))
|
|
50
|
-
.filter(reporter => !['default', 'github-actions', 'summary'].includes(reporter))
|
|
51
|
-
: [];
|
|
40
|
+
const reporters = getReportersDependencies(config, options);
|
|
52
41
|
const watchPlugins = config.watchPlugins?.map(watchPlugin => (typeof watchPlugin === 'string' ? watchPlugin : watchPlugin[0])) ?? [];
|
|
53
42
|
const transform = config.transform
|
|
54
43
|
? Object.values(config.transform).map(transform => (typeof transform === 'string' ? transform : transform[0]))
|
|
@@ -89,7 +78,7 @@ const resolveEntryPaths = async (localConfig, options) => {
|
|
|
89
78
|
const { configFileDir } = options;
|
|
90
79
|
if (typeof localConfig === 'function')
|
|
91
80
|
localConfig = await localConfig();
|
|
92
|
-
const rootDir = localConfig.rootDir
|
|
81
|
+
const rootDir = localConfig.rootDir ?? configFileDir;
|
|
93
82
|
const replaceRootDir = (name) => name.replace(/<rootDir>/, rootDir);
|
|
94
83
|
return (localConfig.testMatch ?? []).map(replaceRootDir).map(toEntry);
|
|
95
84
|
};
|
|
@@ -97,7 +86,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
97
86
|
const { configFileDir } = options;
|
|
98
87
|
if (typeof localConfig === 'function')
|
|
99
88
|
localConfig = await localConfig();
|
|
100
|
-
const rootDir = localConfig.rootDir
|
|
89
|
+
const rootDir = localConfig.rootDir ?? configFileDir;
|
|
101
90
|
const replaceRootDir = (name) => name.replace(/<rootDir>/, rootDir);
|
|
102
91
|
const inputs = await resolveDependencies(localConfig, options);
|
|
103
92
|
const result = inputs.map(dependency => {
|
package/dist/util/debug.js
CHANGED
|
@@ -3,8 +3,9 @@ import picocolors from 'picocolors';
|
|
|
3
3
|
import parsedArgValues from './cli-arguments.js';
|
|
4
4
|
const { debug } = parsedArgValues;
|
|
5
5
|
const IS_DEBUG_ENABLED = debug ?? false;
|
|
6
|
+
const IS_COLORS = !process.env.NO_COLOR;
|
|
6
7
|
const noop = () => { };
|
|
7
|
-
const inspectOptions = { maxArrayLength: null, depth: null, colors:
|
|
8
|
+
const inspectOptions = { maxArrayLength: null, depth: null, colors: IS_COLORS };
|
|
8
9
|
export const inspect = (obj) => console.log(util.inspect(obj, inspectOptions));
|
|
9
10
|
const ctx = (text) => typeof text === 'string'
|
|
10
11
|
? picocolors.yellow(`[${text}]`)
|
package/dist/util/watch.js
CHANGED
|
@@ -56,7 +56,8 @@ export const getWatchHandler = async ({ analyzedFiles, analyzeSourceFile, chief,
|
|
|
56
56
|
else {
|
|
57
57
|
graph.delete(filePath);
|
|
58
58
|
analyzedFiles.delete(filePath);
|
|
59
|
-
|
|
59
|
+
if (filePath.startsWith(cwd))
|
|
60
|
+
cachedUnusedFiles.add(filePath);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
for (const filePath of filePaths)
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.37.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.37.0';
|