knip 2.31.0 → 2.32.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/README.md +15 -24
- package/dist/ConfigurationValidator.d.ts +56 -0
- package/dist/ConfigurationValidator.js +1 -0
- package/dist/WorkspaceWorker.d.ts +8 -6
- package/dist/WorkspaceWorker.js +33 -59
- package/dist/binaries/index.js +1 -1
- package/dist/binaries/resolvers/c8.js +2 -1
- package/dist/binaries/resolvers/dotenv.js +2 -1
- package/dist/binaries/resolvers/fallback.js +2 -1
- package/dist/binaries/resolvers/nodemon.js +2 -1
- package/dist/binaries/resolvers/npx.js +2 -1
- package/dist/binaries/resolvers/nx.js +1 -1
- package/dist/binaries/resolvers/pnpm.js +1 -1
- package/dist/binaries/resolvers/rollup.js +2 -1
- package/dist/binaries/resolvers/yarn.js +1 -1
- package/dist/binaries/util.d.ts +0 -3
- package/dist/binaries/util.js +1 -3
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -4
- package/dist/index.js +19 -18
- package/dist/plugins/ava/index.d.ts +1 -1
- package/dist/plugins/ava/index.js +23 -5
- package/dist/plugins/ava/types.d.ts +1 -0
- package/dist/plugins/babel/index.js +3 -1
- package/dist/plugins/capacitor/index.js +3 -1
- package/dist/plugins/changesets/index.js +3 -1
- package/dist/plugins/commitizen/index.d.ts +1 -0
- package/dist/plugins/commitizen/index.js +4 -1
- package/dist/plugins/commitlint/index.js +3 -1
- package/dist/plugins/cspell/index.js +3 -1
- package/dist/plugins/cypress/index.d.ts +3 -1
- package/dist/plugins/cypress/index.js +14 -4
- package/dist/plugins/drizzle/index.js +3 -5
- package/dist/plugins/eslint/helpers.js +2 -1
- package/dist/plugins/eslint/index.d.ts +1 -0
- package/dist/plugins/eslint/index.js +4 -1
- package/dist/plugins/gatsby/index.js +10 -2
- package/dist/plugins/github-actions/index.js +3 -1
- package/dist/plugins/husky/index.js +3 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/jest/index.d.ts +1 -1
- package/dist/plugins/jest/index.js +16 -7
- package/dist/plugins/lefthook/index.js +4 -2
- package/dist/plugins/lint-staged/index.d.ts +1 -0
- package/dist/plugins/lint-staged/index.js +4 -1
- package/dist/plugins/markdownlint/index.js +3 -1
- package/dist/plugins/mocha/index.d.ts +1 -0
- package/dist/plugins/mocha/index.js +10 -6
- package/dist/plugins/next/index.d.ts +2 -1
- package/dist/plugins/next/index.js +4 -0
- package/dist/plugins/node-test-runner/index.d.ts +6 -0
- package/dist/plugins/node-test-runner/index.js +17 -0
- package/dist/plugins/npm-package-json-lint/index.d.ts +1 -0
- package/dist/plugins/npm-package-json-lint/index.js +5 -2
- package/dist/plugins/nx/index.js +3 -1
- package/dist/plugins/nyc/index.js +3 -1
- package/dist/plugins/playwright/index.d.ts +3 -1
- package/dist/plugins/playwright/index.js +22 -2
- package/dist/plugins/playwright-ct/index.d.ts +3 -1
- package/dist/plugins/playwright-ct/index.js +13 -2
- package/dist/plugins/postcss/index.js +8 -6
- package/dist/plugins/prettier/index.js +3 -1
- package/dist/plugins/release-it/index.d.ts +1 -0
- package/dist/plugins/release-it/index.js +5 -2
- package/dist/plugins/remark/index.d.ts +1 -0
- package/dist/plugins/remark/index.js +10 -3
- package/dist/plugins/remix/index.d.ts +2 -1
- package/dist/plugins/remix/index.js +10 -0
- package/dist/plugins/rollup/index.d.ts +2 -1
- package/dist/plugins/rollup/index.js +7 -0
- package/dist/plugins/semantic-release/index.d.ts +1 -0
- package/dist/plugins/semantic-release/index.js +7 -2
- package/dist/plugins/sentry/index.d.ts +2 -1
- package/dist/plugins/sentry/index.js +7 -0
- package/dist/plugins/storybook/index.js +6 -2
- package/dist/plugins/stryker/index.js +9 -8
- package/dist/plugins/stylelint/index.js +3 -1
- package/dist/plugins/svelte/index.d.ts +2 -1
- package/dist/plugins/svelte/index.js +6 -0
- package/dist/plugins/typedoc/index.d.ts +1 -0
- package/dist/plugins/typedoc/index.js +5 -2
- package/dist/plugins/typescript/index.js +3 -1
- package/dist/plugins/vite/index.js +2 -2
- package/dist/plugins/vitest/index.d.ts +3 -3
- package/dist/plugins/vitest/index.js +16 -23
- package/dist/plugins/vitest/types.d.ts +1 -0
- package/dist/plugins/webpack/index.js +3 -1
- package/dist/types/config.d.ts +3 -2
- package/dist/types/plugins.d.ts +3 -3
- package/dist/util/compilers.d.ts +10 -0
- package/dist/util/object.d.ts +1 -0
- package/dist/util/object.js +1 -0
- package/dist/util/plugin.d.ts +1 -1
- package/dist/util/protocols.d.ts +9 -0
- package/dist/util/protocols.js +9 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/schema.json +4 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import micromatch from 'micromatch';
|
|
2
2
|
import { _getDependenciesFromScripts } from './binaries/index.js';
|
|
3
|
-
import { fromBinary, isBinary } from './binaries/util.js';
|
|
4
3
|
import { ConfigurationChief } from './ConfigurationChief.js';
|
|
5
4
|
import { ConsoleStreamer } from './ConsoleStreamer.js';
|
|
6
5
|
import { ROOT_WORKSPACE_NAME } from './constants.js';
|
|
@@ -12,9 +11,10 @@ import { compact } from './util/array.js';
|
|
|
12
11
|
import { debugLogObject, debugLogArray, debugLog } from './util/debug.js';
|
|
13
12
|
import { LoaderError } from './util/errors.js';
|
|
14
13
|
import { findFile } from './util/fs.js';
|
|
15
|
-
import { _glob } from './util/glob.js';
|
|
14
|
+
import { _glob, negate } from './util/glob.js';
|
|
16
15
|
import { getEntryPathFromManifest, getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, } from './util/modules.js';
|
|
17
16
|
import { dirname, isInNodeModules, join, isInternal, toAbsolute } from './util/path.js';
|
|
17
|
+
import { fromBinary, isBinary } from './util/protocols.js';
|
|
18
18
|
import { _resolveSpecifier, _tryResolve } from './util/require.js';
|
|
19
19
|
import { _require } from './util/require.js';
|
|
20
20
|
import { loadTSConfig } from './util/tsconfig-loader.js';
|
|
@@ -113,21 +113,30 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
113
113
|
const entryPathsFromManifest = await getEntryPathFromManifest(cwd, dir, manifest);
|
|
114
114
|
debugLogArray(`Found entry paths in package.json (${name})`, entryPathsFromManifest);
|
|
115
115
|
principal.addEntryPaths(entryPathsFromManifest);
|
|
116
|
+
const dependencies = await worker.findAllDependencies();
|
|
117
|
+
const { referencedDependencies, hostDependencies, installedBinaries, hasTypesIncluded, enabledPlugins, entryFilePatterns, productionEntryFilePatterns, } = dependencies;
|
|
118
|
+
deputy.addHostDependencies(name, hostDependencies);
|
|
119
|
+
deputy.setInstalledBinaries(name, installedBinaries);
|
|
120
|
+
deputy.setHasTypesIncluded(name, hasTypesIncluded);
|
|
121
|
+
enabledPluginsStore.set(name, enabledPlugins);
|
|
122
|
+
referencedDependencies.forEach(([containingFilePath, specifier]) => {
|
|
123
|
+
handleReferencedDependency({ specifier, containingFilePath, principal, workspace });
|
|
124
|
+
});
|
|
116
125
|
if (isProduction) {
|
|
126
|
+
const negatedEntryPatterns = entryFilePatterns.map(negate);
|
|
117
127
|
{
|
|
118
|
-
const patterns = worker.getProductionEntryFilePatterns();
|
|
128
|
+
const patterns = worker.getProductionEntryFilePatterns(negatedEntryPatterns);
|
|
119
129
|
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
120
130
|
debugLogArray(`Found entry paths (${name})`, workspaceEntryPaths);
|
|
121
131
|
principal.addEntryPaths(workspaceEntryPaths);
|
|
122
132
|
}
|
|
123
133
|
{
|
|
124
|
-
const
|
|
125
|
-
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
134
|
+
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns: productionEntryFilePatterns });
|
|
126
135
|
debugLogArray(`Found production plugin entry paths (${name})`, pluginWorkspaceEntryPaths);
|
|
127
136
|
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
|
|
128
137
|
}
|
|
129
138
|
{
|
|
130
|
-
const patterns = worker.getProductionProjectFilePatterns();
|
|
139
|
+
const patterns = worker.getProductionProjectFilePatterns(negatedEntryPatterns);
|
|
131
140
|
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
132
141
|
debugLogArray(`Found project paths (${name})`, workspaceProjectPaths);
|
|
133
142
|
workspaceProjectPaths.forEach(projectPath => principal.addProjectPath(projectPath));
|
|
@@ -141,13 +150,13 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
141
150
|
principal.addEntryPaths(workspaceEntryPaths);
|
|
142
151
|
}
|
|
143
152
|
{
|
|
144
|
-
const patterns = worker.getProjectFilePatterns();
|
|
153
|
+
const patterns = worker.getProjectFilePatterns([...productionEntryFilePatterns]);
|
|
145
154
|
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
146
155
|
debugLogArray(`Found project paths (${name})`, workspaceProjectPaths);
|
|
147
156
|
workspaceProjectPaths.forEach(projectPath => principal.addProjectPath(projectPath));
|
|
148
157
|
}
|
|
149
158
|
{
|
|
150
|
-
const patterns =
|
|
159
|
+
const patterns = [...entryFilePatterns, ...productionEntryFilePatterns];
|
|
151
160
|
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
152
161
|
debugLogArray(`Found plugin entry paths (${name})`, pluginWorkspaceEntryPaths);
|
|
153
162
|
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
|
|
@@ -165,17 +174,9 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
165
174
|
principal.addEntryPaths(configurationEntryPaths, { skipExportsAnalysis: true });
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
|
-
if (chief.resolvedConfigFilePath)
|
|
177
|
+
if (chief.resolvedConfigFilePath) {
|
|
169
178
|
principal.addEntryPath(chief.resolvedConfigFilePath, { skipExportsAnalysis: true });
|
|
170
|
-
|
|
171
|
-
const { referencedDependencies, hostDependencies, installedBinaries, enabledPlugins, hasTypesIncluded } = dependencies;
|
|
172
|
-
deputy.addHostDependencies(name, hostDependencies);
|
|
173
|
-
deputy.setInstalledBinaries(name, installedBinaries);
|
|
174
|
-
deputy.setHasTypesIncluded(name, hasTypesIncluded);
|
|
175
|
-
enabledPluginsStore.set(name, enabledPlugins);
|
|
176
|
-
referencedDependencies.forEach(([containingFilePath, specifier]) => {
|
|
177
|
-
handleReferencedDependency({ specifier, containingFilePath, principal, workspace });
|
|
178
|
-
});
|
|
179
|
+
}
|
|
179
180
|
}
|
|
180
181
|
const principals = factory.getPrincipals();
|
|
181
182
|
debugLog(`Installed ${principals.length} principals for ${workspaces.length} workspaces`);
|
|
@@ -3,5 +3,5 @@ export declare const NAME = "Ava";
|
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
5
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
-
export declare const ENTRY_FILE_PATTERNS:
|
|
6
|
+
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
7
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
import { _getDependenciesFromScripts } from '../../binaries/index.js';
|
|
2
2
|
import { timerify } from '../../util/Performance.js';
|
|
3
3
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
4
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
4
5
|
export const NAME = 'Ava';
|
|
5
6
|
export const ENABLERS = ['ava'];
|
|
6
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
8
|
export const CONFIG_FILE_PATTERNS = ['ava.config.{js,cjs,mjs}', 'package.json'];
|
|
8
|
-
export const ENTRY_FILE_PATTERNS = [
|
|
9
|
-
|
|
9
|
+
export const ENTRY_FILE_PATTERNS = [
|
|
10
|
+
`test.{js,cjs,mjs}`,
|
|
11
|
+
`{src,source}/test.{js,cjs,mjs}`,
|
|
12
|
+
`**/__tests__/**/*.{js,cjs,mjs}`,
|
|
13
|
+
`**/*.spec.{js,cjs,mjs}`,
|
|
14
|
+
`**/*.test.{js,cjs,mjs}`,
|
|
15
|
+
`**/test-*.{js,cjs,mjs}`,
|
|
16
|
+
`**/test/**/*.{js,cjs,mjs}`,
|
|
17
|
+
`**/tests/**/*.{js,cjs,mjs}`,
|
|
18
|
+
'!**/__tests__/**/__{helper,fixture}?(s)__/**/*',
|
|
19
|
+
'!**/test?(s)/**/{helper,fixture}?(s)/**/*',
|
|
20
|
+
];
|
|
21
|
+
const findAvaDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
10
22
|
const config = configFilePath.endsWith('package.json') ? manifest.ava : await load(configFilePath);
|
|
11
|
-
const
|
|
12
|
-
|
|
23
|
+
const entryPatterns = (config?.files ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
24
|
+
if (isProduction)
|
|
25
|
+
return entryPatterns;
|
|
26
|
+
if (!config)
|
|
27
|
+
return [];
|
|
28
|
+
const requireArgs = (config.require ?? []).map(require => `--require ${require}`);
|
|
29
|
+
const otherArgs = config.nodeArguments ?? [];
|
|
13
30
|
const cmd = `node ${otherArgs.join(' ')} ${requireArgs.join(' ')}`;
|
|
14
|
-
|
|
31
|
+
const dependencies = _getDependenciesFromScripts([cmd], {
|
|
15
32
|
cwd,
|
|
16
33
|
manifest,
|
|
17
34
|
knownGlobalsOnly: true,
|
|
18
35
|
});
|
|
36
|
+
return [...entryPatterns, ...dependencies];
|
|
19
37
|
};
|
|
20
38
|
export const findDependencies = timerify(findAvaDependencies);
|
|
@@ -20,7 +20,9 @@ export const getDependenciesFromConfig = (config) => {
|
|
|
20
20
|
const nested = config.env ? Object.values(config.env).flatMap(getDependenciesFromConfig) : [];
|
|
21
21
|
return compact([...presets, ...plugins, ...nested]);
|
|
22
22
|
};
|
|
23
|
-
const findBabelDependencies = async (configFilePath, { manifest }) => {
|
|
23
|
+
const findBabelDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
24
|
+
if (isProduction)
|
|
25
|
+
return [];
|
|
24
26
|
let config = configFilePath.endsWith('package.json') ? manifest.babel : await load(configFilePath);
|
|
25
27
|
if (typeof config === 'function') {
|
|
26
28
|
config = config(api);
|
|
@@ -4,7 +4,9 @@ export const NAME = 'Capacitor';
|
|
|
4
4
|
export const ENABLERS = [/^@capacitor\//];
|
|
5
5
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
6
6
|
export const CONFIG_FILE_PATTERNS = ['capacitor.config.ts'];
|
|
7
|
-
const findCapacitorDependencies = async (configFilePath) => {
|
|
7
|
+
const findCapacitorDependencies = async (configFilePath, { isProduction }) => {
|
|
8
|
+
if (isProduction)
|
|
9
|
+
return [];
|
|
8
10
|
const config = await load(configFilePath);
|
|
9
11
|
return config.includePlugins ?? [];
|
|
10
12
|
};
|
|
@@ -4,7 +4,9 @@ export const NAME = 'Changesets';
|
|
|
4
4
|
export const ENABLERS = ['@changesets/cli'];
|
|
5
5
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
6
6
|
export const CONFIG_FILE_PATTERNS = ['.changeset/config.json'];
|
|
7
|
-
const findChangesetsDependencies = async (configFilePath) => {
|
|
7
|
+
const findChangesetsDependencies = async (configFilePath, { isProduction }) => {
|
|
8
|
+
if (isProduction)
|
|
9
|
+
return [];
|
|
8
10
|
const config = await load(configFilePath);
|
|
9
11
|
return Array.isArray(config.changelog)
|
|
10
12
|
? [config.changelog[0]]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "Commitizen";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const PACKAGE_JSON_PATH = "config.commitizen";
|
|
4
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -2,9 +2,12 @@ import { timerify } from '../../util/Performance.js';
|
|
|
2
2
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
3
|
export const NAME = 'Commitizen';
|
|
4
4
|
export const ENABLERS = ['commitizen'];
|
|
5
|
+
export const PACKAGE_JSON_PATH = 'config.commitizen';
|
|
5
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
6
7
|
export const CONFIG_FILE_PATTERNS = ['.czrc', '.cz.json', 'package.json'];
|
|
7
|
-
const findPluginDependencies = async (configFilePath, { manifest }) => {
|
|
8
|
+
const findPluginDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
9
|
+
if (isProduction)
|
|
10
|
+
return [];
|
|
8
11
|
const config = configFilePath.endsWith('package.json')
|
|
9
12
|
? manifest.config?.commitizen
|
|
10
13
|
: await load(configFilePath);
|
|
@@ -9,7 +9,9 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
9
9
|
'commitlint.config.{js,cjs,ts,cts}',
|
|
10
10
|
'package.json',
|
|
11
11
|
];
|
|
12
|
-
const findCommitLintDependencies = async (configFilePath, { manifest }) => {
|
|
12
|
+
const findCommitLintDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
13
|
+
if (isProduction)
|
|
14
|
+
return [];
|
|
13
15
|
const config = configFilePath.endsWith('package.json')
|
|
14
16
|
? manifest.commitlint
|
|
15
17
|
: await load(configFilePath);
|
|
@@ -9,7 +9,9 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
9
9
|
'.c{s,S}pell.json',
|
|
10
10
|
'cSpell.json',
|
|
11
11
|
];
|
|
12
|
-
const findCspellDependencies = async (configFilePath) => {
|
|
12
|
+
const findCspellDependencies = async (configFilePath, { isProduction }) => {
|
|
13
|
+
if (isProduction)
|
|
14
|
+
return [];
|
|
13
15
|
const config = await load(configFilePath);
|
|
14
16
|
const imports = config?.import ?? [];
|
|
15
17
|
return imports;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
1
|
+
import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "Cypress";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
|
+
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
5
6
|
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
7
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import { hasDependency } from '../../util/plugin.js';
|
|
1
|
+
import { load, hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
2
3
|
export const NAME = 'Cypress';
|
|
3
4
|
export const ENABLERS = ['cypress'];
|
|
4
5
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
5
|
-
export const
|
|
6
|
-
|
|
6
|
+
export const CONFIG_FILE_PATTERNS = ['cypress.config.{js,ts,mjs,cjs}'];
|
|
7
|
+
const TEST_FILE_PATTERNS = ['cypress/e2e/**/*.cy.{js,jsx,ts,tsx}'];
|
|
8
|
+
const SUPPORT_FILE_PATTERNS = [
|
|
7
9
|
'cypress/support/e2e.{js,jsx,ts,tsx}',
|
|
8
|
-
'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
|
|
9
10
|
'cypress/plugins/index.js',
|
|
10
11
|
];
|
|
12
|
+
export const ENTRY_FILE_PATTERNS = [...TEST_FILE_PATTERNS, ...SUPPORT_FILE_PATTERNS];
|
|
13
|
+
export const findDependencies = async (configFilePath) => {
|
|
14
|
+
const config = await load(configFilePath);
|
|
15
|
+
if (!config)
|
|
16
|
+
return [];
|
|
17
|
+
const patterns = [config.e2e?.specPattern ?? [], config.component?.specPattern ?? []].flat();
|
|
18
|
+
const entryPatterns = (patterns.length > 0 ? patterns : TEST_FILE_PATTERNS).map(toEntryPattern);
|
|
19
|
+
return [...entryPatterns, ...SUPPORT_FILE_PATTERNS.map(toEntryPattern)];
|
|
20
|
+
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { _glob } from '../../util/glob.js';
|
|
2
1
|
import { timerify } from '../../util/Performance.js';
|
|
3
2
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
4
4
|
export const NAME = 'Drizzle';
|
|
5
5
|
export const ENABLERS = ['drizzle-kit'];
|
|
6
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
7
|
export const CONFIG_FILE_PATTERNS = ['drizzle.config.{ts,js,json}'];
|
|
8
|
-
const findDrizzleDependencies = async (configFilePath
|
|
8
|
+
const findDrizzleDependencies = async (configFilePath) => {
|
|
9
9
|
const config = await load(configFilePath);
|
|
10
10
|
if (!config || !config.schema)
|
|
11
11
|
return [];
|
|
12
|
-
|
|
13
|
-
const paths = await _glob({ cwd, patterns });
|
|
14
|
-
return paths;
|
|
12
|
+
return [config.schema].flat().map(toEntryPattern);
|
|
15
13
|
};
|
|
16
14
|
export const findDependencies = timerify(findDrizzleDependencies);
|
|
@@ -3,6 +3,7 @@ import { isInternal, dirname, toAbsolute } from '../../util/path.js';
|
|
|
3
3
|
import { load } from '../../util/plugin.js';
|
|
4
4
|
import { _resolve } from '../../util/require.js';
|
|
5
5
|
import { fallback } from './fallback.js';
|
|
6
|
+
import { PACKAGE_JSON_PATH } from './index.js';
|
|
6
7
|
const getDependencies = (config) => {
|
|
7
8
|
const extendsSpecifiers = config.extends ? [config.extends].flat().map(resolveExtendSpecifier) : [];
|
|
8
9
|
if (extendsSpecifiers.some(specifier => specifier?.startsWith('eslint-plugin-prettier')))
|
|
@@ -26,7 +27,7 @@ const getDependencies = (config) => {
|
|
|
26
27
|
export const getDependenciesDeep = async (configFilePath, dependencies = new Set(), options) => {
|
|
27
28
|
const addAll = (deps) => deps.forEach(dependency => dependencies.add(dependency));
|
|
28
29
|
const config = configFilePath.endsWith('package.json')
|
|
29
|
-
? options.manifest
|
|
30
|
+
? options.manifest[PACKAGE_JSON_PATH]
|
|
30
31
|
: /(\.(jsonc?|ya?ml)|rc)$/.test(configFilePath)
|
|
31
32
|
? await load(configFilePath)
|
|
32
33
|
: await fallback(configFilePath);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "ESLint";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const PACKAGE_JSON_PATH = "eslintConfig";
|
|
4
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
7
|
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
@@ -3,12 +3,15 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
import { getDependenciesDeep } from './helpers.js';
|
|
4
4
|
export const NAME = 'ESLint';
|
|
5
5
|
export const ENABLERS = ['eslint'];
|
|
6
|
+
export const PACKAGE_JSON_PATH = 'eslintConfig';
|
|
6
7
|
export const isEnabled = ({ dependencies, manifest, config }) => hasDependency(dependencies, ENABLERS) ||
|
|
7
8
|
'eslint' in config ||
|
|
8
9
|
Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));
|
|
9
10
|
export const CONFIG_FILE_PATTERNS = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.eslintrc.{yml,yaml}', 'package.json'];
|
|
10
11
|
export const ENTRY_FILE_PATTERNS = ['eslint.config.js'];
|
|
11
|
-
const findESLintDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
12
|
+
const findESLintDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
13
|
+
if (isProduction)
|
|
14
|
+
return [];
|
|
12
15
|
const dependencies = await getDependenciesDeep(configFilePath, new Set(), { cwd, manifest });
|
|
13
16
|
return Array.from(dependencies);
|
|
14
17
|
};
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { timerify } from '../../util/Performance.js';
|
|
2
2
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
|
+
import { toProductionEntryPattern } from '../../util/protocols.js';
|
|
3
4
|
export const NAME = 'Gatsby';
|
|
4
5
|
export const ENABLERS = ['gatsby', 'gatsby-cli'];
|
|
5
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
6
|
-
export const CONFIG_FILE_PATTERNS = [
|
|
7
|
+
export const CONFIG_FILE_PATTERNS = [
|
|
8
|
+
'gatsby-{config,node}.{js,jsx,ts,tsx}',
|
|
9
|
+
'plugins/**/gatsby-node.{js,jsx,ts,tsx}',
|
|
10
|
+
];
|
|
7
11
|
export const PRODUCTION_ENTRY_FILE_PATTERNS = [
|
|
8
12
|
'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
|
|
9
13
|
'src/api/**/*.{js,ts}',
|
|
10
14
|
'src/pages/**/*.{js,jsx,ts,tsx}',
|
|
11
15
|
'src/templates/**/*.{js,jsx,ts,tsx}',
|
|
12
16
|
'src/html.{js,jsx,ts,tsx}',
|
|
17
|
+
'plugins/**/gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
|
|
13
18
|
];
|
|
14
|
-
const findGatsbyDependencies = async (configFilePath) => {
|
|
19
|
+
const findGatsbyDependencies = async (configFilePath, { isProduction }) => {
|
|
15
20
|
const config = await load(configFilePath);
|
|
21
|
+
const entryPatterns = PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern);
|
|
22
|
+
if (isProduction)
|
|
23
|
+
return entryPatterns;
|
|
16
24
|
if (/gatsby-config/.test(configFilePath)) {
|
|
17
25
|
return config.plugins.map(plugin => (typeof plugin === 'string' ? plugin : plugin.resolve));
|
|
18
26
|
}
|
|
@@ -7,7 +7,9 @@ export const NAME = 'GitHub Actions';
|
|
|
7
7
|
export const ENABLERS = 'This plugin is enabled when a `.yml` file is found in the `.github/workflows` folder.';
|
|
8
8
|
export const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.yml'] }));
|
|
9
9
|
export const CONFIG_FILE_PATTERNS = ['.github/workflows/*.yml', '.github/**/action.{yml,yaml}'];
|
|
10
|
-
const findGithubActionsDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
10
|
+
const findGithubActionsDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
11
|
+
if (isProduction)
|
|
12
|
+
return [];
|
|
11
13
|
const config = await load(configFilePath);
|
|
12
14
|
if (!config)
|
|
13
15
|
return [];
|
|
@@ -8,7 +8,9 @@ export const ENABLERS = ['husky'];
|
|
|
8
8
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
9
9
|
const gitHookPaths = getGitHookPaths('.husky');
|
|
10
10
|
export const CONFIG_FILE_PATTERNS = [...gitHookPaths];
|
|
11
|
-
const findHuskyDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
11
|
+
const findHuskyDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
12
|
+
if (isProduction)
|
|
13
|
+
return [];
|
|
12
14
|
const script = readFileSync(configFilePath);
|
|
13
15
|
return _getDependenciesFromScripts(String(script), {
|
|
14
16
|
cwd,
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * as lintStaged from './lint-staged/index.js';
|
|
|
18
18
|
export * as markdownlint from './markdownlint/index.js';
|
|
19
19
|
export * as mocha from './mocha/index.js';
|
|
20
20
|
export * as next from './next/index.js';
|
|
21
|
+
export * as nodeTestRunner from './node-test-runner/index.js';
|
|
21
22
|
export * as npmPackageJsonLint from './npm-package-json-lint/index.js';
|
|
22
23
|
export * as nx from './nx/index.js';
|
|
23
24
|
export * as nyc from './nyc/index.js';
|
package/dist/plugins/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * as lintStaged from './lint-staged/index.js';
|
|
|
18
18
|
export * as markdownlint from './markdownlint/index.js';
|
|
19
19
|
export * as mocha from './mocha/index.js';
|
|
20
20
|
export * as next from './next/index.js';
|
|
21
|
+
export * as nodeTestRunner from './node-test-runner/index.js';
|
|
21
22
|
export * as npmPackageJsonLint from './npm-package-json-lint/index.js';
|
|
22
23
|
export * as nx from './nx/index.js';
|
|
23
24
|
export * as nyc from './nyc/index.js';
|
|
@@ -3,5 +3,5 @@ export declare const NAME = "Jest";
|
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
5
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
-
export declare const ENTRY_FILE_PATTERNS:
|
|
6
|
+
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
7
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { join, isInternal, toAbsolute, dirname } from '../../util/path.js';
|
|
2
2
|
import { timerify } from '../../util/Performance.js';
|
|
3
3
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
4
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
4
5
|
export const NAME = 'Jest';
|
|
5
6
|
export const ENABLERS = ['jest'];
|
|
6
7
|
export const isEnabled = ({ dependencies, manifest }) => hasDependency(dependencies, ENABLERS) || Boolean(manifest.name?.startsWith('jest-presets'));
|
|
7
8
|
export const CONFIG_FILE_PATTERNS = ['jest.config.{js,ts,mjs,cjs,json}', 'package.json'];
|
|
8
|
-
export const ENTRY_FILE_PATTERNS = [];
|
|
9
|
+
export const ENTRY_FILE_PATTERNS = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
|
|
9
10
|
const resolveExtensibleConfig = async (configFilePath) => {
|
|
10
11
|
const config = await load(configFilePath);
|
|
11
12
|
if (config?.preset) {
|
|
@@ -18,10 +19,14 @@ const resolveExtensibleConfig = async (configFilePath) => {
|
|
|
18
19
|
}
|
|
19
20
|
return config;
|
|
20
21
|
};
|
|
21
|
-
const resolveDependencies = (config) => {
|
|
22
|
+
const resolveDependencies = (config, options) => {
|
|
23
|
+
const { isProduction } = options;
|
|
24
|
+
const entryPatterns = (config.testMatch ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
25
|
+
if (isProduction)
|
|
26
|
+
return entryPatterns;
|
|
22
27
|
const presets = (config.preset ? [config.preset] : []).map(preset => isInternal(preset) ? preset : join(preset, 'jest-preset'));
|
|
23
28
|
const projects = Array.isArray(config.projects)
|
|
24
|
-
? config.projects.map(config => (typeof config === 'string' ? config : resolveDependencies(config))).flat()
|
|
29
|
+
? config.projects.map(config => (typeof config === 'string' ? config : resolveDependencies(config, options))).flat()
|
|
25
30
|
: [];
|
|
26
31
|
const runner = config.runner ? [config.runner] : [];
|
|
27
32
|
const environments = config.testEnvironment === 'jsdom' ? ['jest-environment-jsdom'] : [];
|
|
@@ -42,6 +47,7 @@ const resolveDependencies = (config) => {
|
|
|
42
47
|
: []).filter(value => !/\$[0-9]/.test(value));
|
|
43
48
|
const testResultsProcessor = config.testResultsProcessor ? [config.testResultsProcessor] : [];
|
|
44
49
|
return [
|
|
50
|
+
...entryPatterns,
|
|
45
51
|
...presets,
|
|
46
52
|
...projects,
|
|
47
53
|
...runner,
|
|
@@ -56,7 +62,8 @@ const resolveDependencies = (config) => {
|
|
|
56
62
|
...testResultsProcessor,
|
|
57
63
|
];
|
|
58
64
|
};
|
|
59
|
-
const findJestDependencies = async (configFilePath,
|
|
65
|
+
const findJestDependencies = async (configFilePath, options) => {
|
|
66
|
+
const { manifest, cwd } = options;
|
|
60
67
|
let config = configFilePath.endsWith('package.json')
|
|
61
68
|
? manifest.jest
|
|
62
69
|
: await resolveExtensibleConfig(configFilePath);
|
|
@@ -64,8 +71,10 @@ const findJestDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
|
64
71
|
config = await config();
|
|
65
72
|
if (!config)
|
|
66
73
|
return [];
|
|
67
|
-
const rootDir = config.rootDir
|
|
68
|
-
const replaceRootDir = (name) => name.includes('<rootDir>') ?
|
|
69
|
-
|
|
74
|
+
const rootDir = config.rootDir ? join(dirname(configFilePath), config.rootDir) : dirname(configFilePath);
|
|
75
|
+
const replaceRootDir = (name) => (name.includes('<rootDir>') ? name.replace(/<rootDir>/, rootDir) : name);
|
|
76
|
+
const dependencies = resolveDependencies(config, options);
|
|
77
|
+
const matchCwd = new RegExp('^' + toEntryPattern(cwd) + '/');
|
|
78
|
+
return dependencies.map(replaceRootDir).map(dependency => dependency.replace(matchCwd, toEntryPattern('')));
|
|
70
79
|
};
|
|
71
80
|
export const findDependencies = timerify(findJestDependencies);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { readFileSync } from 'fs';
|
|
2
2
|
import { _getDependenciesFromScripts } from '../../binaries/index.js';
|
|
3
|
-
import { fromBinary } from '../../binaries/util.js';
|
|
4
3
|
import { getGitHookPaths } from '../../util/git.js';
|
|
5
4
|
import { getValuesByKeyDeep } from '../../util/object.js';
|
|
6
5
|
import { timerify } from '../../util/Performance.js';
|
|
7
6
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
7
|
+
import { fromBinary } from '../../util/protocols.js';
|
|
8
8
|
export const NAME = 'Lefthook';
|
|
9
9
|
export const ENABLERS = ['lefthook', '@arkweid/lefthook', '@evilmartians/lefthook'];
|
|
10
10
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
11
11
|
const gitHookPaths = getGitHookPaths();
|
|
12
12
|
export const CONFIG_FILE_PATTERNS = ['lefthook.yml', ...gitHookPaths];
|
|
13
|
-
const findLefthookDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
13
|
+
const findLefthookDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
14
|
+
if (isProduction)
|
|
15
|
+
return [];
|
|
14
16
|
const dependencies = manifest.devDependencies ? Object.keys(manifest.devDependencies) : [];
|
|
15
17
|
if (configFilePath.endsWith('.yml')) {
|
|
16
18
|
const config = await load(configFilePath);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "lint-staged";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const PACKAGE_JSON_PATH = "lint-staged";
|
|
4
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -3,6 +3,7 @@ import { timerify } from '../../util/Performance.js';
|
|
|
3
3
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
4
4
|
export const NAME = 'lint-staged';
|
|
5
5
|
export const ENABLERS = ['lint-staged'];
|
|
6
|
+
export const PACKAGE_JSON_PATH = 'lint-staged';
|
|
6
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
8
|
export const CONFIG_FILE_PATTERNS = [
|
|
8
9
|
'.lintstagedrc',
|
|
@@ -12,7 +13,9 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
12
13
|
'lint-staged.config.{js,mjs,cjs}',
|
|
13
14
|
'package.json',
|
|
14
15
|
];
|
|
15
|
-
const findLintStagedDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
16
|
+
const findLintStagedDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
17
|
+
if (isProduction)
|
|
18
|
+
return [];
|
|
16
19
|
let config = configFilePath.endsWith('package.json')
|
|
17
20
|
? manifest['lint-staged']
|
|
18
21
|
: await load(configFilePath);
|
|
@@ -5,7 +5,9 @@ export const NAME = 'markdownlint';
|
|
|
5
5
|
export const ENABLERS = ['markdownlint-cli'];
|
|
6
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
7
|
export const CONFIG_FILE_PATTERNS = ['.markdownlint.{json,jsonc}', '.markdownlint.{yml,yaml}'];
|
|
8
|
-
const findMarkdownlintConfigDependencies = async (configFilePath, { manifest }) => {
|
|
8
|
+
const findMarkdownlintConfigDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
9
|
+
if (isProduction)
|
|
10
|
+
return [];
|
|
9
11
|
const config = await load(configFilePath);
|
|
10
12
|
const extend = config?.extends ? [config.extends] : [];
|
|
11
13
|
const scripts = manifest.scripts
|
|
@@ -3,4 +3,5 @@ export declare const NAME = "Mocha";
|
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
5
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
6
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { timerify } from '../../util/Performance.js';
|
|
2
2
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
3
4
|
export const NAME = 'Mocha';
|
|
4
5
|
export const ENABLERS = ['mocha'];
|
|
5
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
6
7
|
export const CONFIG_FILE_PATTERNS = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
|
|
7
|
-
const
|
|
8
|
+
export const ENTRY_FILE_PATTERNS = ['**/test/*.{js,cjs,mjs}'];
|
|
9
|
+
const findMochaDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
10
|
+
const entryPatterns = ENTRY_FILE_PATTERNS.map(toEntryPattern);
|
|
11
|
+
if (isProduction)
|
|
12
|
+
return entryPatterns;
|
|
8
13
|
const config = configFilePath.endsWith('package.json') ? manifest.mocha : await load(configFilePath);
|
|
9
|
-
if (config)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return [];
|
|
14
|
+
if (!config)
|
|
15
|
+
return [];
|
|
16
|
+
const require = config.require ? [config.require].flat() : [];
|
|
17
|
+
return [...require, ...entryPatterns];
|
|
14
18
|
};
|
|
15
19
|
export const findDependencies = timerify(findMochaDependencies);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
1
|
+
import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "Next.js";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
5
|
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
6
6
|
export declare const PRODUCTION_ENTRY_FILE_PATTERNS: string[];
|
|
7
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import { toEntryPattern, toProductionEntryPattern } from '../../util/protocols.js';
|
|
2
3
|
export const NAME = 'Next.js';
|
|
3
4
|
export const ENABLERS = ['next'];
|
|
4
5
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
@@ -17,3 +18,6 @@ export const PRODUCTION_ENTRY_FILE_PATTERNS = [
|
|
|
17
18
|
...productionEntryFilePatternsWithoutSrc,
|
|
18
19
|
...productionEntryFilePatternsWithoutSrc.map(pattern => `src/${pattern}`),
|
|
19
20
|
];
|
|
21
|
+
export const findDependencies = async () => {
|
|
22
|
+
return [...ENTRY_FILE_PATTERNS.map(toEntryPattern), ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern)];
|
|
23
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
|
+
export declare const NAME = "Node.js Test Runner";
|
|
3
|
+
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
|
+
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { timerify } from '../../util/Performance.js';
|
|
2
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
3
|
+
export const NAME = 'Node.js Test Runner';
|
|
4
|
+
export const ENABLERS = [''];
|
|
5
|
+
export const isEnabled = ({ manifest }) => {
|
|
6
|
+
return Boolean(manifest.scripts?.test && /node.+--test/.test(manifest.scripts?.test));
|
|
7
|
+
};
|
|
8
|
+
export const ENTRY_FILE_PATTERNS = [
|
|
9
|
+
'**/test.{js,cjs,mjs}',
|
|
10
|
+
'**/test-*.{js,cjs,mjs}',
|
|
11
|
+
'**/*{.,-,_}test.{js,cjs,mjs}',
|
|
12
|
+
'**/test/**/*.{js,cjs,mjs}',
|
|
13
|
+
];
|
|
14
|
+
const findNodeTestRunnerDependencies = async (configFilePath, options) => {
|
|
15
|
+
return (options.config?.entry ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
16
|
+
};
|
|
17
|
+
export const findDependencies = timerify(findNodeTestRunnerDependencies);
|