knip 2.33.3 → 2.34.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 +27 -7
- package/dist/ConfigurationChief.d.ts +1 -0
- package/dist/ConfigurationChief.js +13 -1
- package/dist/ConfigurationValidator.d.ts +56 -0
- package/dist/ConfigurationValidator.js +1 -0
- package/dist/WorkspaceWorker.d.ts +1 -1
- package/dist/WorkspaceWorker.js +12 -17
- package/dist/binaries/bash-parser.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +17 -16
- package/dist/plugins/_template/index.js +14 -3
- package/dist/plugins/_template/types.d.ts +1 -0
- package/dist/plugins/angular/index.js +11 -11
- package/dist/plugins/astro/index.d.ts +7 -0
- package/dist/plugins/astro/index.js +10 -0
- package/dist/plugins/ava/index.js +13 -12
- package/dist/plugins/babel/index.js +8 -5
- package/dist/plugins/capacitor/index.js +4 -2
- package/dist/plugins/changesets/index.js +7 -5
- package/dist/plugins/commitizen/index.js +4 -3
- package/dist/plugins/commitizen/types.d.ts +1 -1
- package/dist/plugins/commitlint/index.js +4 -2
- package/dist/plugins/cspell/index.js +4 -2
- package/dist/plugins/cspell/types.d.ts +1 -1
- package/dist/plugins/cypress/index.js +7 -4
- package/dist/plugins/drizzle/index.js +4 -4
- package/dist/plugins/eslint/fallback.js +6 -1
- package/dist/plugins/eslint/helpers.d.ts +2 -2
- package/dist/plugins/eslint/helpers.js +7 -7
- package/dist/plugins/eslint/index.d.ts +0 -1
- package/dist/plugins/eslint/index.js +3 -4
- package/dist/plugins/gatsby/index.js +5 -8
- package/dist/plugins/github-actions/index.d.ts +1 -1
- package/dist/plugins/github-actions/index.js +5 -4
- package/dist/plugins/husky/index.js +4 -2
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/jest/index.js +8 -8
- package/dist/plugins/jest/types.d.ts +3 -0
- package/dist/plugins/jest/types.js +1 -0
- package/dist/plugins/lefthook/index.js +5 -4
- package/dist/plugins/lint-staged/index.js +7 -7
- package/dist/plugins/markdownlint/index.js +5 -4
- package/dist/plugins/mocha/index.js +8 -7
- package/dist/plugins/mocha/types.d.ts +4 -0
- package/dist/plugins/mocha/types.js +1 -0
- package/dist/plugins/npm-package-json-lint/index.js +4 -3
- package/dist/plugins/nx/index.js +6 -5
- package/dist/plugins/nyc/index.js +4 -3
- package/dist/plugins/nyc/types.d.ts +3 -0
- package/dist/plugins/nyc/types.js +1 -0
- package/dist/plugins/playwright/index.d.ts +1 -1
- package/dist/plugins/playwright/index.js +7 -6
- package/dist/plugins/playwright-ct/index.js +11 -6
- package/dist/plugins/postcss/index.js +6 -5
- package/dist/plugins/prettier/index.js +3 -3
- package/dist/plugins/prettier/types.d.ts +8 -0
- package/dist/plugins/prettier/types.js +1 -0
- package/dist/plugins/release-it/index.js +10 -9
- package/dist/plugins/remark/index.js +6 -5
- package/dist/plugins/remix/index.js +1 -5
- package/dist/plugins/rollup/index.js +1 -1
- package/dist/plugins/semantic-release/index.js +5 -4
- package/dist/plugins/semantic-release/types.d.ts +1 -1
- package/dist/plugins/storybook/index.js +13 -11
- package/dist/plugins/stryker/index.js +9 -6
- package/dist/plugins/stylelint/index.js +6 -5
- package/dist/plugins/typedoc/index.js +4 -3
- package/dist/plugins/typedoc/types.d.ts +1 -1
- package/dist/plugins/typescript/index.js +13 -10
- package/dist/plugins/vite/index.js +4 -2
- package/dist/plugins/vitest/index.d.ts +1 -1
- package/dist/plugins/vitest/index.js +8 -8
- package/dist/plugins/webpack/index.js +25 -15
- package/dist/plugins/webpack/types.d.ts +2 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/plugins.d.ts +1 -1
- package/dist/typescript/SourceFileManager.js +3 -3
- package/dist/typescript/ast-helpers.d.ts +2 -1
- package/dist/typescript/ast-helpers.js +3 -0
- package/dist/typescript/visitors/exports/exportKeyword.js +5 -2
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +2 -0
- package/dist/util/compilers.d.ts +10 -0
- package/dist/util/debug.d.ts +3 -3
- package/dist/util/debug.js +10 -8
- package/dist/util/glob.js +1 -1
- package/dist/util/modules.js +1 -1
- package/dist/util/path.js +4 -2
- package/dist/util/plugin.js +7 -1
- package/dist/util/require.js +1 -1
- package/dist/util/unwrapFunction.d.ts +1 -0
- package/dist/util/unwrapFunction.js +13 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +4 -0
|
@@ -23,10 +23,13 @@ export const getDependenciesFromConfig = (config) => {
|
|
|
23
23
|
const findBabelDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
24
24
|
if (isProduction)
|
|
25
25
|
return [];
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
let localConfig = configFilePath.endsWith('package.json')
|
|
27
|
+
? manifest.babel
|
|
28
|
+
: await load(configFilePath);
|
|
29
|
+
if (typeof localConfig === 'function')
|
|
30
|
+
localConfig = localConfig(api);
|
|
31
|
+
if (!localConfig)
|
|
32
|
+
return [];
|
|
33
|
+
return getDependenciesFromConfig(localConfig);
|
|
31
34
|
};
|
|
32
35
|
export const findDependencies = timerify(findBabelDependencies);
|
|
@@ -7,7 +7,9 @@ export const CONFIG_FILE_PATTERNS = ['capacitor.config.ts'];
|
|
|
7
7
|
const findCapacitorDependencies = async (configFilePath, { isProduction }) => {
|
|
8
8
|
if (isProduction)
|
|
9
9
|
return [];
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const localConfig = await load(configFilePath);
|
|
11
|
+
if (!localConfig)
|
|
12
|
+
return [];
|
|
13
|
+
return localConfig.includePlugins ?? [];
|
|
12
14
|
};
|
|
13
15
|
export const findDependencies = timerify(findCapacitorDependencies);
|
|
@@ -7,11 +7,13 @@ export const CONFIG_FILE_PATTERNS = ['.changeset/config.json'];
|
|
|
7
7
|
const findChangesetsDependencies = async (configFilePath, { isProduction }) => {
|
|
8
8
|
if (isProduction)
|
|
9
9
|
return [];
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const localConfig = await load(configFilePath);
|
|
11
|
+
if (!localConfig)
|
|
12
|
+
return [];
|
|
13
|
+
return Array.isArray(localConfig.changelog)
|
|
14
|
+
? [localConfig.changelog[0]]
|
|
15
|
+
: typeof localConfig.changelog === 'string'
|
|
16
|
+
? [localConfig.changelog]
|
|
15
17
|
: [];
|
|
16
18
|
};
|
|
17
19
|
export const findDependencies = timerify(findChangesetsDependencies);
|
|
@@ -8,10 +8,11 @@ export const CONFIG_FILE_PATTERNS = ['.czrc', '.cz.json', 'package.json'];
|
|
|
8
8
|
const findPluginDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
9
9
|
if (isProduction)
|
|
10
10
|
return [];
|
|
11
|
-
const
|
|
11
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
12
12
|
? manifest.config?.commitizen
|
|
13
13
|
: await load(configFilePath);
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if (!localConfig)
|
|
15
|
+
return [];
|
|
16
|
+
return localConfig.path ? [localConfig.path] : [];
|
|
16
17
|
};
|
|
17
18
|
export const findDependencies = timerify(findPluginDependencies);
|
|
@@ -12,9 +12,11 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
12
12
|
const findCommitLintDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
13
13
|
if (isProduction)
|
|
14
14
|
return [];
|
|
15
|
-
const
|
|
15
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
16
16
|
? manifest.commitlint
|
|
17
17
|
: await load(configFilePath);
|
|
18
|
-
|
|
18
|
+
if (!localConfig)
|
|
19
|
+
return [];
|
|
20
|
+
return localConfig.extends ? [localConfig.extends].flat() : [];
|
|
19
21
|
};
|
|
20
22
|
export const findDependencies = timerify(findCommitLintDependencies);
|
|
@@ -12,8 +12,10 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
12
12
|
const findCspellDependencies = async (configFilePath, { isProduction }) => {
|
|
13
13
|
if (isProduction)
|
|
14
14
|
return [];
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const localConfig = await load(configFilePath);
|
|
16
|
+
if (!localConfig)
|
|
17
|
+
return [];
|
|
18
|
+
const imports = localConfig.import ?? [];
|
|
17
19
|
return imports;
|
|
18
20
|
};
|
|
19
21
|
export const findDependencies = timerify(findCspellDependencies);
|
|
@@ -10,11 +10,14 @@ const SUPPORT_FILE_PATTERNS = [
|
|
|
10
10
|
'cypress/plugins/index.js',
|
|
11
11
|
];
|
|
12
12
|
export const ENTRY_FILE_PATTERNS = [...TEST_FILE_PATTERNS, ...SUPPORT_FILE_PATTERNS];
|
|
13
|
-
export const findDependencies = async (configFilePath) => {
|
|
14
|
-
const config =
|
|
15
|
-
|
|
13
|
+
export const findDependencies = async (configFilePath, options) => {
|
|
14
|
+
const { config } = options;
|
|
15
|
+
const localConfig = await load(configFilePath);
|
|
16
|
+
if (!localConfig)
|
|
16
17
|
return [];
|
|
17
|
-
|
|
18
|
+
if (config.entry)
|
|
19
|
+
return config.entry.map(toEntryPattern);
|
|
20
|
+
const patterns = [localConfig.e2e?.specPattern ?? [], localConfig.component?.specPattern ?? []].flat();
|
|
18
21
|
const entryPatterns = (patterns.length > 0 ? patterns : TEST_FILE_PATTERNS).map(toEntryPattern);
|
|
19
22
|
return [...entryPatterns, ...SUPPORT_FILE_PATTERNS.map(toEntryPattern)];
|
|
20
23
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { timerify } from '../../util/Performance.js';
|
|
2
2
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toProductionEntryPattern } 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
8
|
const findDrizzleDependencies = async (configFilePath) => {
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
9
|
+
const localConfig = await load(configFilePath);
|
|
10
|
+
if (!localConfig?.schema)
|
|
11
11
|
return [];
|
|
12
|
-
return [
|
|
12
|
+
return [localConfig.schema].flat().map(toProductionEntryPattern);
|
|
13
13
|
};
|
|
14
14
|
export const findDependencies = timerify(findDrizzleDependencies);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import createJITI from 'jiti';
|
|
2
2
|
import transform from 'jiti/dist/babel.js';
|
|
3
|
+
import { FAKE_PATH } from '../../util/loader.js';
|
|
3
4
|
import { timerify } from '../../util/Performance.js';
|
|
4
5
|
const rushstackMatch = /require\(("|')@rushstack\/(eslint-config\/patch|eslint-patch)\/modern-module-resolution("|')\)/;
|
|
5
6
|
const jiti = createJITI(process.cwd(), {
|
|
@@ -9,5 +10,9 @@ const jiti = createJITI(process.cwd(), {
|
|
|
9
10
|
return transform(opts);
|
|
10
11
|
},
|
|
11
12
|
});
|
|
12
|
-
const load = (configFilePath) =>
|
|
13
|
+
const load = (configFilePath) => {
|
|
14
|
+
if (configFilePath === FAKE_PATH)
|
|
15
|
+
return;
|
|
16
|
+
return jiti(configFilePath);
|
|
17
|
+
};
|
|
13
18
|
export const fallback = timerify(load);
|
|
@@ -4,10 +4,10 @@ import type { PackageJson } from '@npmcli/package-json';
|
|
|
4
4
|
type Manifest = PackageJson & {
|
|
5
5
|
eslintConfig?: ESLintConfig;
|
|
6
6
|
};
|
|
7
|
-
type GetDependenciesDeep = (configFilePath: string,
|
|
7
|
+
type GetDependenciesDeep = (configFilePath: string, options: {
|
|
8
8
|
cwd: string;
|
|
9
9
|
manifest: Manifest;
|
|
10
|
-
}) => Promise<Set<string>>;
|
|
10
|
+
}, dependencies?: Set<string>) => Promise<Set<string>>;
|
|
11
11
|
export declare const getDependenciesDeep: GetDependenciesDeep;
|
|
12
12
|
export declare const resolvePluginSpecifier: (specifier: string) => string;
|
|
13
13
|
export declare const resolveExtendSpecifier: (specifier: string) => string | undefined;
|
|
@@ -24,25 +24,25 @@ const getDependencies = (config) => {
|
|
|
24
24
|
...overrides,
|
|
25
25
|
]);
|
|
26
26
|
};
|
|
27
|
-
export const getDependenciesDeep = async (configFilePath, dependencies = new Set()
|
|
27
|
+
export const getDependenciesDeep = async (configFilePath, options, dependencies = new Set()) => {
|
|
28
28
|
const addAll = (deps) => deps.forEach(dependency => dependencies.add(dependency));
|
|
29
|
-
const
|
|
29
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
30
30
|
? options.manifest[PACKAGE_JSON_PATH]
|
|
31
31
|
: /(\.(jsonc?|ya?ml)|rc)$/.test(configFilePath)
|
|
32
32
|
? await load(configFilePath)
|
|
33
33
|
: await fallback(configFilePath);
|
|
34
|
-
if (
|
|
35
|
-
if (
|
|
36
|
-
for (const extend of [
|
|
34
|
+
if (localConfig) {
|
|
35
|
+
if (localConfig.extends) {
|
|
36
|
+
for (const extend of [localConfig.extends].flat()) {
|
|
37
37
|
if (isInternal(extend)) {
|
|
38
38
|
const filePath = toAbsolute(extend, dirname(configFilePath));
|
|
39
39
|
const extendConfigFilePath = _resolve(filePath);
|
|
40
40
|
dependencies.add(extendConfigFilePath);
|
|
41
|
-
addAll(await getDependenciesDeep(extendConfigFilePath,
|
|
41
|
+
addAll(await getDependenciesDeep(extendConfigFilePath, options, dependencies));
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
addAll(getDependencies(
|
|
45
|
+
addAll(getDependencies(localConfig));
|
|
46
46
|
}
|
|
47
47
|
return dependencies;
|
|
48
48
|
};
|
|
@@ -4,5 +4,4 @@ export declare const ENABLERS: string[];
|
|
|
4
4
|
export declare const PACKAGE_JSON_PATH = "eslintConfig";
|
|
5
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
6
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
7
|
-
export declare const ENTRY_FILE_PATTERNS: never[];
|
|
8
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -14,13 +14,12 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
14
14
|
'.eslintrc.{yml,yaml}',
|
|
15
15
|
'package.json',
|
|
16
16
|
];
|
|
17
|
-
export const ENTRY_FILE_PATTERNS = [];
|
|
18
17
|
const findESLintDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
19
|
-
if (configFilePath.endsWith('eslint.config.js'))
|
|
20
|
-
return [];
|
|
21
18
|
if (isProduction)
|
|
22
19
|
return [];
|
|
23
|
-
|
|
20
|
+
if (configFilePath.endsWith('eslint.config.js'))
|
|
21
|
+
return [];
|
|
22
|
+
const dependencies = await getDependenciesDeep(configFilePath, { cwd, manifest });
|
|
24
23
|
return Array.from(dependencies);
|
|
25
24
|
};
|
|
26
25
|
export const findDependencies = timerify(findESLintDependencies);
|
|
@@ -4,10 +4,7 @@ import { toProductionEntryPattern } from '../../util/protocols.js';
|
|
|
4
4
|
export const NAME = 'Gatsby';
|
|
5
5
|
export const ENABLERS = ['gatsby', 'gatsby-cli'];
|
|
6
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
|
-
export const CONFIG_FILE_PATTERNS = [
|
|
8
|
-
'gatsby-{config,node}.{js,jsx,ts,tsx}',
|
|
9
|
-
'plugins/**/gatsby-node.{js,jsx,ts,tsx}',
|
|
10
|
-
];
|
|
7
|
+
export const CONFIG_FILE_PATTERNS = ['gatsby-{config,node}.{js,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,jsx,ts,tsx}'];
|
|
11
8
|
export const PRODUCTION_ENTRY_FILE_PATTERNS = [
|
|
12
9
|
'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
|
|
13
10
|
'src/api/**/*.{js,ts}',
|
|
@@ -17,17 +14,17 @@ export const PRODUCTION_ENTRY_FILE_PATTERNS = [
|
|
|
17
14
|
'plugins/**/gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
|
|
18
15
|
];
|
|
19
16
|
const findGatsbyDependencies = async (configFilePath, { isProduction }) => {
|
|
20
|
-
const
|
|
17
|
+
const localConfig = await load(configFilePath);
|
|
21
18
|
const entryPatterns = PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern);
|
|
22
|
-
if (isProduction)
|
|
19
|
+
if (isProduction || !localConfig)
|
|
23
20
|
return entryPatterns;
|
|
24
21
|
if (/gatsby-config/.test(configFilePath)) {
|
|
25
|
-
return
|
|
22
|
+
return localConfig.plugins.map(plugin => (typeof plugin === 'string' ? plugin : plugin.resolve));
|
|
26
23
|
}
|
|
27
24
|
if (/gatsby-node/.test(configFilePath)) {
|
|
28
25
|
const plugins = new Set();
|
|
29
26
|
const actions = { setBabelPlugin: plugin => plugins.add(plugin.name) };
|
|
30
|
-
const _config =
|
|
27
|
+
const _config = localConfig;
|
|
31
28
|
if (typeof _config.onCreateBabelConfig === 'function') {
|
|
32
29
|
_config.onCreateBabelConfig({ actions });
|
|
33
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "GitHub Actions";
|
|
3
|
-
export declare const ENABLERS = "This plugin is enabled when a `.yml` file is found in the `.github/workflows` folder.";
|
|
3
|
+
export declare const ENABLERS = "This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.";
|
|
4
4
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
5
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
6
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -4,10 +4,11 @@ import { getValuesByKeyDeep } from '../../util/object.js';
|
|
|
4
4
|
import { timerify } from '../../util/Performance.js';
|
|
5
5
|
import { load } from '../../util/plugin.js';
|
|
6
6
|
export const NAME = 'GitHub Actions';
|
|
7
|
-
export const ENABLERS = 'This plugin is enabled when a `.yml` file is found in the `.github/workflows` folder.';
|
|
8
|
-
export const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.yml'] }));
|
|
9
|
-
export const CONFIG_FILE_PATTERNS = ['.github/workflows/*.yml', '.github/**/action.{yml,yaml}'];
|
|
10
|
-
const findGithubActionsDependencies = async (configFilePath,
|
|
7
|
+
export const ENABLERS = 'This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.';
|
|
8
|
+
export const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.{yml,yaml}'] }));
|
|
9
|
+
export const CONFIG_FILE_PATTERNS = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
|
|
10
|
+
const findGithubActionsDependencies = async (configFilePath, options) => {
|
|
11
|
+
const { cwd, manifest, isProduction } = options;
|
|
11
12
|
if (isProduction)
|
|
12
13
|
return [];
|
|
13
14
|
const config = await load(configFilePath);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'fs';
|
|
2
2
|
import { _getDependenciesFromScripts } from '../../binaries/index.js';
|
|
3
3
|
import { getGitHookPaths } from '../../util/git.js';
|
|
4
|
+
import { FAKE_PATH } from '../../util/loader.js';
|
|
4
5
|
import { timerify } from '../../util/Performance.js';
|
|
5
6
|
import { hasDependency } from '../../util/plugin.js';
|
|
6
7
|
export const NAME = 'husky';
|
|
@@ -8,8 +9,9 @@ export const ENABLERS = ['husky'];
|
|
|
8
9
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
9
10
|
const gitHookPaths = getGitHookPaths('.husky');
|
|
10
11
|
export const CONFIG_FILE_PATTERNS = [...gitHookPaths];
|
|
11
|
-
const findHuskyDependencies = async (configFilePath,
|
|
12
|
-
|
|
12
|
+
const findHuskyDependencies = async (configFilePath, options) => {
|
|
13
|
+
const { cwd, manifest, isProduction } = options;
|
|
14
|
+
if (isProduction || configFilePath === FAKE_PATH)
|
|
13
15
|
return [];
|
|
14
16
|
const script = readFileSync(configFilePath);
|
|
15
17
|
return _getDependenciesFromScripts(String(script), {
|
package/dist/plugins/index.d.ts
CHANGED
package/dist/plugins/index.js
CHANGED
|
@@ -21,7 +21,7 @@ const resolveExtensibleConfig = async (configFilePath) => {
|
|
|
21
21
|
};
|
|
22
22
|
const resolveDependencies = (config, options) => {
|
|
23
23
|
const { isProduction } = options;
|
|
24
|
-
const entryPatterns = (config.testMatch ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
24
|
+
const entryPatterns = (options.config?.entry ?? config.testMatch ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
25
25
|
if (isProduction)
|
|
26
26
|
return entryPatterns;
|
|
27
27
|
const presets = (config.preset ? [config.preset] : []).map(preset => isInternal(preset) ? preset : join(preset, 'jest-preset'));
|
|
@@ -64,16 +64,16 @@ const resolveDependencies = (config, options) => {
|
|
|
64
64
|
};
|
|
65
65
|
const findJestDependencies = async (configFilePath, options) => {
|
|
66
66
|
const { manifest, cwd } = options;
|
|
67
|
-
let
|
|
67
|
+
let localConfig = configFilePath.endsWith('package.json')
|
|
68
68
|
? manifest.jest
|
|
69
69
|
: await resolveExtensibleConfig(configFilePath);
|
|
70
|
-
if (typeof
|
|
71
|
-
|
|
72
|
-
if (!
|
|
73
|
-
|
|
74
|
-
const rootDir =
|
|
70
|
+
if (typeof localConfig === 'function')
|
|
71
|
+
localConfig = await localConfig();
|
|
72
|
+
if (!localConfig)
|
|
73
|
+
localConfig = {};
|
|
74
|
+
const rootDir = localConfig.rootDir ? join(dirname(configFilePath), localConfig.rootDir) : dirname(configFilePath);
|
|
75
75
|
const replaceRootDir = (name) => (name.includes('<rootDir>') ? name.replace(/<rootDir>/, rootDir) : name);
|
|
76
|
-
const dependencies = resolveDependencies(
|
|
76
|
+
const dependencies = resolveDependencies(localConfig, options);
|
|
77
77
|
const matchCwd = new RegExp('^' + toEntryPattern(cwd) + '/');
|
|
78
78
|
return dependencies.map(replaceRootDir).map(dependency => dependency.replace(matchCwd, toEntryPattern('')));
|
|
79
79
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,15 +10,16 @@ export const ENABLERS = ['lefthook', '@arkweid/lefthook', '@evilmartians/lefthoo
|
|
|
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,
|
|
13
|
+
const findLefthookDependencies = async (configFilePath, options) => {
|
|
14
|
+
const { cwd, manifest, isProduction } = options;
|
|
14
15
|
if (isProduction)
|
|
15
16
|
return [];
|
|
16
17
|
const dependencies = manifest.devDependencies ? Object.keys(manifest.devDependencies) : [];
|
|
17
18
|
if (configFilePath.endsWith('.yml')) {
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
19
|
+
const localConfig = await load(configFilePath);
|
|
20
|
+
if (!localConfig)
|
|
20
21
|
return [];
|
|
21
|
-
const scripts = getValuesByKeyDeep(
|
|
22
|
+
const scripts = getValuesByKeyDeep(localConfig, 'run').filter((run) => typeof run === 'string');
|
|
22
23
|
const lefthook = process.env.CI ? ENABLERS.filter(dependency => dependencies.includes(dependency)) : [];
|
|
23
24
|
return [...lefthook, ..._getDependenciesFromScripts(scripts, { cwd, manifest, knownGlobalsOnly: true })];
|
|
24
25
|
}
|
|
@@ -13,19 +13,19 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
13
13
|
'lint-staged.config.{js,mjs,cjs}',
|
|
14
14
|
'package.json',
|
|
15
15
|
];
|
|
16
|
-
const findLintStagedDependencies = async (configFilePath,
|
|
16
|
+
const findLintStagedDependencies = async (configFilePath, options) => {
|
|
17
|
+
const { cwd, manifest, isProduction } = options;
|
|
17
18
|
if (isProduction)
|
|
18
19
|
return [];
|
|
19
|
-
let
|
|
20
|
+
let localConfig = configFilePath.endsWith('package.json')
|
|
20
21
|
? manifest['lint-staged']
|
|
21
22
|
: await load(configFilePath);
|
|
22
|
-
if (
|
|
23
|
+
if (typeof localConfig === 'function')
|
|
24
|
+
localConfig = localConfig();
|
|
25
|
+
if (!localConfig)
|
|
23
26
|
return [];
|
|
24
|
-
if (typeof config === 'function') {
|
|
25
|
-
config = config();
|
|
26
|
-
}
|
|
27
27
|
const dependencies = new Set();
|
|
28
|
-
for (const entry of Object.values(
|
|
28
|
+
for (const entry of Object.values(localConfig).flat()) {
|
|
29
29
|
const scripts = [typeof entry === 'function' ? await entry([]) : entry].flat();
|
|
30
30
|
const options = { cwd, manifest };
|
|
31
31
|
_getDependenciesFromScripts(scripts, options).forEach(identifier => dependencies.add(identifier));
|
|
@@ -5,12 +5,13 @@ 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,
|
|
8
|
+
const findMarkdownlintConfigDependencies = async (configFilePath, options) => {
|
|
9
|
+
const { manifest, isProduction } = options;
|
|
9
10
|
if (isProduction)
|
|
10
11
|
return [];
|
|
11
|
-
const
|
|
12
|
-
const extend =
|
|
13
|
-
const scripts = manifest
|
|
12
|
+
const localConfig = await load(configFilePath);
|
|
13
|
+
const extend = localConfig?.extends ? [localConfig.extends] : [];
|
|
14
|
+
const scripts = manifest?.scripts
|
|
14
15
|
? Object.values(manifest.scripts).filter((script) => typeof script === 'string')
|
|
15
16
|
: [];
|
|
16
17
|
const uses = scripts
|
|
@@ -6,14 +6,15 @@ export const ENABLERS = ['mocha'];
|
|
|
6
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
7
|
export const CONFIG_FILE_PATTERNS = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
|
|
8
8
|
export const ENTRY_FILE_PATTERNS = ['**/test/*.{js,cjs,mjs}'];
|
|
9
|
-
const findMochaDependencies = async (configFilePath,
|
|
10
|
-
const
|
|
11
|
-
|
|
9
|
+
const findMochaDependencies = async (configFilePath, options) => {
|
|
10
|
+
const { config, manifest, isProduction } = options;
|
|
11
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
12
|
+
? manifest.mocha
|
|
13
|
+
: await load(configFilePath);
|
|
14
|
+
const entryPatterns = (config.entry ?? (localConfig?.spec ? [localConfig.spec].flat() : ENTRY_FILE_PATTERNS)).map(toEntryPattern);
|
|
15
|
+
if (isProduction || !localConfig)
|
|
12
16
|
return entryPatterns;
|
|
13
|
-
const
|
|
14
|
-
if (!config)
|
|
15
|
-
return [];
|
|
16
|
-
const require = config.require ? [config.require].flat() : [];
|
|
17
|
+
const require = localConfig.require ? [localConfig.require].flat() : [];
|
|
17
18
|
return [...require, ...entryPatterns];
|
|
18
19
|
};
|
|
19
20
|
export const findDependencies = timerify(findMochaDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,12 +5,13 @@ export const ENABLERS = ['npm-package-json-lint'];
|
|
|
5
5
|
export const PACKAGE_JSON_PATH = 'npmpackagejsonlint';
|
|
6
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
7
|
export const CONFIG_FILE_PATTERNS = ['.npmpackagejsonlintrc.json', 'npmpackagejsonlint.config.js', 'package.json'];
|
|
8
|
-
const findNpmPkgJsonLintConfigDependencies = async (configFilePath,
|
|
8
|
+
const findNpmPkgJsonLintConfigDependencies = async (configFilePath, options) => {
|
|
9
|
+
const { manifest, isProduction } = options;
|
|
9
10
|
if (isProduction)
|
|
10
11
|
return [];
|
|
11
|
-
const
|
|
12
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
12
13
|
? manifest[PACKAGE_JSON_PATH]
|
|
13
14
|
: await load(configFilePath);
|
|
14
|
-
return
|
|
15
|
+
return localConfig?.extends ? [localConfig.extends] : [];
|
|
15
16
|
};
|
|
16
17
|
export const findDependencies = timerify(findNpmPkgJsonLintConfigDependencies);
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -3,16 +3,17 @@ import { compact } from '../../util/array.js';
|
|
|
3
3
|
import { timerify } from '../../util/Performance.js';
|
|
4
4
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
5
5
|
export const NAME = 'Nx';
|
|
6
|
-
export const ENABLERS = ['nx', /^@nrwl\//];
|
|
6
|
+
export const ENABLERS = ['nx', /^@nrwl\//, /^@nx\//];
|
|
7
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
8
|
export const CONFIG_FILE_PATTERNS = ['project.json', '{apps,libs}/**/project.json'];
|
|
9
|
-
const findNxDependencies = async (configFilePath,
|
|
9
|
+
const findNxDependencies = async (configFilePath, options) => {
|
|
10
|
+
const { cwd, manifest, isProduction } = options;
|
|
10
11
|
if (isProduction)
|
|
11
12
|
return [];
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
13
|
+
const localConfig = await load(configFilePath);
|
|
14
|
+
if (!localConfig)
|
|
14
15
|
return [];
|
|
15
|
-
const targets =
|
|
16
|
+
const targets = localConfig.targets ? Object.values(localConfig.targets) : [];
|
|
16
17
|
const executors = compact(targets
|
|
17
18
|
.map(target => target?.executor)
|
|
18
19
|
.filter(executor => executor && !executor.startsWith('.'))
|
|
@@ -4,10 +4,11 @@ export const NAME = 'nyc';
|
|
|
4
4
|
export const ENABLERS = ['nyc'];
|
|
5
5
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
6
6
|
export const CONFIG_FILE_PATTERNS = ['.nycrc', '.nycrc.json', '.nycrc.{yml,yaml}', 'nyc.config.js'];
|
|
7
|
-
const findNycDependencies = async (configFilePath,
|
|
7
|
+
const findNycDependencies = async (configFilePath, options) => {
|
|
8
|
+
const { isProduction } = options;
|
|
8
9
|
if (isProduction)
|
|
9
10
|
return [];
|
|
10
|
-
const
|
|
11
|
-
return
|
|
11
|
+
const localConfig = await load(configFilePath);
|
|
12
|
+
return localConfig?.extends ? [localConfig.extends].flat() : [];
|
|
12
13
|
};
|
|
13
14
|
export const findDependencies = timerify(findNycDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import type { PlaywrightTestConfig } from 'playwright/test';
|
|
|
3
3
|
export declare const NAME = "Playwright";
|
|
4
4
|
export declare const ENABLERS: string[];
|
|
5
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
6
|
-
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
7
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
7
|
+
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
8
8
|
export declare const toEntryPatterns: (testMatch: string | RegExp | Array<string | RegExp> | undefined, cwd: string, configFilePath: string, config: PlaywrightTestConfig) => string[];
|
|
9
9
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -5,8 +5,8 @@ import { toEntryPattern } from '../../util/protocols.js';
|
|
|
5
5
|
export const NAME = 'Playwright';
|
|
6
6
|
export const ENABLERS = ['@playwright/test'];
|
|
7
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
|
-
export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
|
|
9
8
|
export const CONFIG_FILE_PATTERNS = ['playwright.config.{js,ts}'];
|
|
9
|
+
export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
|
|
10
10
|
export const toEntryPatterns = (testMatch, cwd, configFilePath, config) => {
|
|
11
11
|
if (!testMatch)
|
|
12
12
|
return [];
|
|
@@ -14,14 +14,15 @@ export const toEntryPatterns = (testMatch, cwd, configFilePath, config) => {
|
|
|
14
14
|
const patterns = [testMatch].flat().filter((p) => typeof p === 'string');
|
|
15
15
|
return patterns.map(pattern => toEntryPattern(join(dir, pattern)));
|
|
16
16
|
};
|
|
17
|
-
const findPlaywrightDependencies = async (configFilePath,
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const findPlaywrightDependencies = async (configFilePath, options) => {
|
|
18
|
+
const { cwd, config } = options;
|
|
19
|
+
const localConfig = await load(configFilePath);
|
|
20
|
+
if (localConfig) {
|
|
21
|
+
const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
|
|
21
22
|
const patterns = projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFilePath, config));
|
|
22
23
|
if (patterns.length > 0)
|
|
23
24
|
return patterns;
|
|
24
25
|
}
|
|
25
|
-
return
|
|
26
|
+
return (config?.entry ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
26
27
|
};
|
|
27
28
|
export const findDependencies = timerify(findPlaywrightDependencies);
|
|
@@ -1,16 +1,21 @@
|
|
|
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
|
import { toEntryPatterns } from '../playwright/index.js';
|
|
4
5
|
export const NAME = 'Playwright for components';
|
|
5
6
|
export const ENABLERS = [/^@playwright\/experimental-ct-/];
|
|
6
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
8
|
export const CONFIG_FILE_PATTERNS = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}'];
|
|
8
9
|
export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
|
|
9
|
-
const findPlaywrightCTDependencies = async (configFilePath,
|
|
10
|
-
const config =
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const findPlaywrightCTDependencies = async (configFilePath, options) => {
|
|
11
|
+
const { cwd, config } = options;
|
|
12
|
+
const localConfig = await load(configFilePath);
|
|
13
|
+
if (localConfig) {
|
|
14
|
+
const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
|
|
15
|
+
const patterns = projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFilePath, config));
|
|
16
|
+
if (patterns.length > 0)
|
|
17
|
+
return patterns;
|
|
18
|
+
}
|
|
19
|
+
return (config?.entry ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
15
20
|
};
|
|
16
21
|
export const findDependencies = timerify(findPlaywrightCTDependencies);
|