knip 0.0.0-graph.3 → 0.0.0-node-types.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 +7 -915
- package/bin/knip.js +2 -0
- package/dist/ConfigurationChief.d.ts +14 -6
- package/dist/ConfigurationChief.js +104 -70
- package/dist/ConfigurationValidator.d.ts +553 -321
- package/dist/ConfigurationValidator.js +7 -1
- package/dist/DependencyDeputy.d.ts +4 -1
- package/dist/DependencyDeputy.js +13 -11
- package/dist/PrincipalFactory.d.ts +5 -2
- package/dist/PrincipalFactory.js +11 -7
- package/dist/ProjectPrincipal.d.ts +18 -15
- package/dist/ProjectPrincipal.js +43 -25
- package/dist/WorkspaceWorker.d.ts +9 -7
- package/dist/WorkspaceWorker.js +45 -63
- package/dist/binaries/bash-parser.js +1 -1
- package/dist/binaries/index.js +12 -3
- package/dist/binaries/resolvers/c8.js +2 -1
- package/dist/binaries/resolvers/dotenv.js +2 -1
- package/dist/binaries/resolvers/fallback.js +4 -2
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +1 -0
- package/dist/binaries/resolvers/node.js +1 -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/tsx.d.ts +2 -0
- package/dist/binaries/resolvers/tsx.js +6 -0
- 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/cli.d.ts +0 -1
- package/dist/cli.js +10 -9
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +5 -4
- package/dist/index.js +101 -65
- package/dist/manifest/index.js +8 -4
- package/dist/plugins/_template/index.js +15 -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 +19 -0
- package/dist/plugins/ava/index.d.ts +1 -1
- package/dist/plugins/ava/index.js +28 -7
- package/dist/plugins/ava/types.d.ts +5 -1
- package/dist/plugins/babel/helpers.d.ts +1 -2
- package/dist/plugins/babel/helpers.js +28 -20
- package/dist/plugins/babel/index.js +17 -14
- package/dist/plugins/capacitor/index.js +7 -3
- package/dist/plugins/changesets/index.js +10 -6
- package/dist/plugins/commitizen/index.d.ts +1 -0
- package/dist/plugins/commitizen/index.js +8 -4
- package/dist/plugins/commitizen/types.d.ts +1 -1
- package/dist/plugins/commitlint/index.js +7 -3
- package/dist/plugins/cspell/index.js +7 -3
- package/dist/plugins/cspell/types.d.ts +1 -1
- package/dist/plugins/cypress/index.d.ts +3 -1
- package/dist/plugins/cypress/index.js +17 -4
- package/dist/plugins/drizzle/index.js +5 -7
- package/dist/plugins/eslint/fallback.js +6 -1
- package/dist/plugins/eslint/helpers.d.ts +4 -11
- package/dist/plugins/eslint/helpers.js +24 -26
- package/dist/plugins/eslint/index.d.ts +1 -1
- package/dist/plugins/eslint/index.js +14 -4
- package/dist/plugins/gatsby/index.js +11 -5
- package/dist/plugins/github-actions/index.d.ts +1 -1
- package/dist/plugins/github-actions/index.js +7 -4
- package/dist/plugins/graphql-codegen/index.d.ts +7 -0
- package/dist/plugins/graphql-codegen/index.js +46 -0
- package/dist/plugins/graphql-codegen/types.d.ts +25 -0
- package/dist/plugins/graphql-codegen/types.js +3 -0
- package/dist/plugins/husky/index.js +9 -4
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/jest/index.d.ts +1 -1
- package/dist/plugins/jest/index.js +21 -12
- package/dist/plugins/jest/types.d.ts +3 -0
- package/dist/plugins/lefthook/index.js +12 -8
- package/dist/plugins/lint-staged/index.d.ts +1 -0
- package/dist/plugins/lint-staged/index.js +10 -7
- package/dist/plugins/markdownlint/index.js +7 -4
- package/dist/plugins/mocha/index.d.ts +1 -0
- package/dist/plugins/mocha/index.js +12 -7
- package/dist/plugins/mocha/types.d.ts +4 -0
- package/dist/plugins/mocha/types.js +1 -0
- package/dist/plugins/next/index.d.ts +2 -1
- package/dist/plugins/next/index.js +7 -0
- package/dist/plugins/node-test-runner/index.d.ts +6 -0
- package/dist/plugins/node-test-runner/index.js +19 -0
- package/dist/plugins/npm-package-json-lint/index.d.ts +1 -0
- package/dist/plugins/npm-package-json-lint/index.js +8 -4
- package/dist/plugins/nx/index.js +13 -10
- package/dist/plugins/nyc/index.js +6 -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 +5 -1
- package/dist/plugins/playwright/index.js +25 -2
- package/dist/plugins/playwright-ct/index.d.ts +3 -1
- package/dist/plugins/playwright-ct/index.js +18 -2
- package/dist/plugins/postcss/index.js +12 -9
- package/dist/plugins/prettier/index.js +11 -6
- package/dist/plugins/prettier/types.d.ts +8 -0
- package/dist/plugins/prettier/types.js +1 -0
- package/dist/plugins/release-it/index.d.ts +1 -0
- package/dist/plugins/release-it/index.js +14 -10
- package/dist/plugins/remark/index.d.ts +1 -0
- package/dist/plugins/remark/index.js +20 -4
- package/dist/plugins/remark/types.d.ts +3 -0
- package/dist/plugins/remark/types.js +1 -0
- package/dist/plugins/remix/index.d.ts +2 -1
- package/dist/plugins/remix/index.js +9 -0
- package/dist/plugins/rollup/index.d.ts +2 -1
- package/dist/plugins/rollup/index.js +8 -1
- package/dist/plugins/semantic-release/index.d.ts +1 -0
- package/dist/plugins/semantic-release/index.js +10 -4
- package/dist/plugins/semantic-release/types.d.ts +1 -1
- package/dist/plugins/sentry/index.d.ts +2 -1
- package/dist/plugins/sentry/index.js +7 -0
- package/dist/plugins/storybook/index.js +28 -10
- package/dist/plugins/storybook/types.d.ts +7 -0
- package/dist/plugins/stryker/index.js +13 -9
- package/dist/plugins/stylelint/index.js +8 -5
- package/dist/plugins/svelte/index.d.ts +2 -1
- package/dist/plugins/svelte/index.js +6 -0
- package/dist/plugins/tsup/index.d.ts +6 -0
- package/dist/plugins/tsup/index.js +23 -0
- package/dist/plugins/tsup/types.d.ts +7 -0
- package/dist/plugins/tsup/types.js +1 -0
- package/dist/plugins/typedoc/index.d.ts +1 -0
- package/dist/plugins/typedoc/index.js +8 -4
- package/dist/plugins/typedoc/types.d.ts +1 -1
- package/dist/plugins/typescript/index.js +16 -11
- package/dist/plugins/vite/index.js +7 -5
- package/dist/plugins/vitest/helpers.d.ts +2 -2
- package/dist/plugins/vitest/index.d.ts +4 -4
- package/dist/plugins/vitest/index.js +55 -26
- package/dist/plugins/vitest/types.d.ts +23 -2
- package/dist/plugins/webpack/index.js +31 -19
- package/dist/plugins/webpack/types.d.ts +2 -1
- package/dist/reporters/codeowners.js +2 -2
- package/dist/reporters/json.js +14 -9
- package/dist/reporters/symbols.js +3 -2
- package/dist/reporters/util.d.ts +8 -2
- package/dist/reporters/util.js +7 -1
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/config.d.ts +9 -4
- package/dist/types/exports.d.ts +1 -0
- package/dist/types/imports.d.ts +6 -0
- package/dist/types/issues.d.ts +11 -1
- package/dist/types/package-json.d.ts +41 -0
- package/dist/types/package-json.js +1 -0
- package/dist/types/plugins.d.ts +5 -7
- package/dist/types/util.d.ts +16 -0
- package/dist/types/util.js +1 -0
- package/dist/types/workspace.d.ts +4 -1
- package/dist/typescript/SourceFile.d.ts +5 -0
- package/dist/typescript/SourceFileManager.js +3 -3
- package/dist/typescript/ast-helpers.d.ts +7 -14
- package/dist/typescript/ast-helpers.js +11 -9
- package/dist/typescript/createHosts.d.ts +1 -0
- package/dist/typescript/createHosts.js +1 -1
- package/dist/typescript/getImportsAndExports.d.ts +7 -5
- package/dist/typescript/getImportsAndExports.js +35 -18
- package/dist/typescript/resolveModuleNames.d.ts +1 -1
- package/dist/typescript/resolveModuleNames.js +38 -12
- package/dist/typescript/visitors/exports/exportDeclaration.js +14 -1
- package/dist/typescript/visitors/exports/exportKeyword.js +5 -2
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +29 -21
- package/dist/typescript/visitors/imports/importCall.js +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.js +3 -3
- package/dist/typescript/visitors/imports/importEqualsDeclaration.js +1 -1
- package/dist/typescript/visitors/imports/jsDocType.js +37 -5
- package/dist/typescript/visitors/imports/propertyAccessCall.js +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.js +8 -3
- package/dist/typescript/visitors/imports/requireCall.js +5 -5
- package/dist/util/array.d.ts +3 -1
- package/dist/util/cli-arguments.d.ts +3 -2
- package/dist/util/cli-arguments.js +6 -6
- package/dist/util/compilers.d.ts +122 -80
- package/dist/util/debug.d.ts +3 -3
- package/dist/util/debug.js +12 -18
- package/dist/util/fs.d.ts +2 -0
- package/dist/util/fs.js +22 -3
- package/dist/util/get-included-issue-types.js +14 -18
- package/dist/util/git.js +1 -1
- package/dist/util/glob.js +1 -1
- package/dist/util/loader.d.ts +2 -0
- package/dist/util/loader.js +23 -3
- package/dist/util/modules.d.ts +7 -1
- package/dist/util/modules.js +20 -10
- package/dist/util/object.d.ts +1 -0
- package/dist/util/object.js +3 -0
- package/dist/util/parse-args.d.ts +3 -0
- package/dist/util/parse-args.js +8 -0
- package/dist/util/path.d.ts +1 -0
- package/dist/util/path.js +5 -3
- package/dist/util/plugin.d.ts +4 -3
- package/dist/util/plugin.js +11 -4
- package/dist/util/protocols.d.ts +9 -0
- package/dist/util/protocols.js +9 -0
- package/dist/util/register.d.ts +2 -1
- package/dist/util/register.js +9 -13
- package/dist/util/require.js +7 -5
- package/dist/util/tsconfig-loader.js +2 -1
- package/dist/util/unwrap-function.d.ts +1 -0
- package/dist/util/unwrap-function.js +13 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +86 -85
- package/schema-jsonc.json +11 -0
- package/schema.json +27 -3
- package/dist/plugins/vite/types.d.ts +0 -4
- /package/dist/plugins/{vite → jest}/types.js +0 -0
package/dist/plugins/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * as angular from './angular/index.js';
|
|
2
|
+
export * as astro from './astro/index.js';
|
|
2
3
|
export * as ava from './ava/index.js';
|
|
3
4
|
export * as babel from './babel/index.js';
|
|
4
5
|
export * as capacitor from './capacitor/index.js';
|
|
@@ -11,6 +12,7 @@ export * as drizzle from './drizzle/index.js';
|
|
|
11
12
|
export * as eslint from './eslint/index.js';
|
|
12
13
|
export * as gatsby from './gatsby/index.js';
|
|
13
14
|
export * as githubActions from './github-actions/index.js';
|
|
15
|
+
export * as graphqlCodegen from './graphql-codegen/index.js';
|
|
14
16
|
export * as husky from './husky/index.js';
|
|
15
17
|
export * as jest from './jest/index.js';
|
|
16
18
|
export * as lefthook from './lefthook/index.js';
|
|
@@ -18,6 +20,7 @@ export * as lintStaged from './lint-staged/index.js';
|
|
|
18
20
|
export * as markdownlint from './markdownlint/index.js';
|
|
19
21
|
export * as mocha from './mocha/index.js';
|
|
20
22
|
export * as next from './next/index.js';
|
|
23
|
+
export * as nodeTestRunner from './node-test-runner/index.js';
|
|
21
24
|
export * as npmPackageJsonLint from './npm-package-json-lint/index.js';
|
|
22
25
|
export * as nx from './nx/index.js';
|
|
23
26
|
export * as nyc from './nyc/index.js';
|
|
@@ -36,6 +39,7 @@ export * as stryker from './stryker/index.js';
|
|
|
36
39
|
export * as stylelint from './stylelint/index.js';
|
|
37
40
|
export * as svelte from './svelte/index.js';
|
|
38
41
|
export * as tailwind from './tailwind/index.js';
|
|
42
|
+
export * as tsup from './tsup/index.js';
|
|
39
43
|
export * as typedoc from './typedoc/index.js';
|
|
40
44
|
export * as typescript from './typescript/index.js';
|
|
41
45
|
export * as vite from './vite/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 = (options.config?.entry ?? 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,16 +62,19 @@ const resolveDependencies = (config) => {
|
|
|
56
62
|
...testResultsProcessor,
|
|
57
63
|
];
|
|
58
64
|
};
|
|
59
|
-
const findJestDependencies = async (configFilePath,
|
|
60
|
-
|
|
65
|
+
const findJestDependencies = async (configFilePath, options) => {
|
|
66
|
+
const { manifest, cwd } = options;
|
|
67
|
+
let localConfig = configFilePath.endsWith('package.json')
|
|
61
68
|
? manifest.jest
|
|
62
69
|
: await resolveExtensibleConfig(configFilePath);
|
|
63
|
-
if (typeof
|
|
64
|
-
|
|
65
|
-
if (!
|
|
66
|
-
|
|
67
|
-
const rootDir =
|
|
68
|
-
const replaceRootDir = (name) => name.includes('<rootDir>') ?
|
|
69
|
-
|
|
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
|
+
const replaceRootDir = (name) => (name.includes('<rootDir>') ? name.replace(/<rootDir>/, rootDir) : name);
|
|
76
|
+
const dependencies = resolveDependencies(localConfig, 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,26 +1,30 @@
|
|
|
1
|
-
import { readFileSync } from 'fs';
|
|
2
1
|
import { _getDependenciesFromScripts } from '../../binaries/index.js';
|
|
3
|
-
import { fromBinary } from '../../binaries/util.js';
|
|
4
2
|
import { getGitHookPaths } from '../../util/git.js';
|
|
5
3
|
import { getValuesByKeyDeep } from '../../util/object.js';
|
|
6
4
|
import { timerify } from '../../util/Performance.js';
|
|
7
|
-
import { hasDependency, load } from '../../util/plugin.js';
|
|
5
|
+
import { hasDependency, load, loadFile } from '../../util/plugin.js';
|
|
6
|
+
import { fromBinary } from '../../util/protocols.js';
|
|
8
7
|
export const NAME = 'Lefthook';
|
|
9
8
|
export const ENABLERS = ['lefthook', '@arkweid/lefthook', '@evilmartians/lefthook'];
|
|
10
9
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
11
10
|
const gitHookPaths = getGitHookPaths();
|
|
12
11
|
export const CONFIG_FILE_PATTERNS = ['lefthook.yml', ...gitHookPaths];
|
|
13
|
-
const findLefthookDependencies = async (configFilePath,
|
|
12
|
+
const findLefthookDependencies = async (configFilePath, options) => {
|
|
13
|
+
const { cwd, manifest, isProduction } = options;
|
|
14
|
+
if (isProduction)
|
|
15
|
+
return [];
|
|
14
16
|
const dependencies = manifest.devDependencies ? Object.keys(manifest.devDependencies) : [];
|
|
15
17
|
if (configFilePath.endsWith('.yml')) {
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
+
const localConfig = await load(configFilePath);
|
|
19
|
+
if (!localConfig)
|
|
18
20
|
return [];
|
|
19
|
-
const scripts = getValuesByKeyDeep(
|
|
21
|
+
const scripts = getValuesByKeyDeep(localConfig, 'run').filter((run) => typeof run === 'string');
|
|
20
22
|
const lefthook = process.env.CI ? ENABLERS.filter(dependency => dependencies.includes(dependency)) : [];
|
|
21
23
|
return [...lefthook, ..._getDependenciesFromScripts(scripts, { cwd, manifest, knownGlobalsOnly: true })];
|
|
22
24
|
}
|
|
23
|
-
const script =
|
|
25
|
+
const script = await loadFile(configFilePath);
|
|
26
|
+
if (!script)
|
|
27
|
+
return [];
|
|
24
28
|
const scriptDependencies = _getDependenciesFromScripts([script], { cwd, manifest, knownGlobalsOnly: false });
|
|
25
29
|
const matches = scriptDependencies.find(dep => dependencies.includes(fromBinary(dep)));
|
|
26
30
|
return matches ? [matches] : [];
|
|
@@ -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,17 +13,19 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
12
13
|
'lint-staged.config.{js,mjs,cjs}',
|
|
13
14
|
'package.json',
|
|
14
15
|
];
|
|
15
|
-
const findLintStagedDependencies = async (configFilePath,
|
|
16
|
-
|
|
16
|
+
const findLintStagedDependencies = async (configFilePath, options) => {
|
|
17
|
+
const { cwd, manifest, isProduction } = options;
|
|
18
|
+
if (isProduction)
|
|
19
|
+
return [];
|
|
20
|
+
let localConfig = configFilePath.endsWith('package.json')
|
|
17
21
|
? manifest['lint-staged']
|
|
18
22
|
: await load(configFilePath);
|
|
19
|
-
if (
|
|
23
|
+
if (typeof localConfig === 'function')
|
|
24
|
+
localConfig = localConfig();
|
|
25
|
+
if (!localConfig)
|
|
20
26
|
return [];
|
|
21
|
-
if (typeof config === 'function') {
|
|
22
|
-
config = config();
|
|
23
|
-
}
|
|
24
27
|
const dependencies = new Set();
|
|
25
|
-
for (const entry of Object.values(
|
|
28
|
+
for (const entry of Object.values(localConfig).flat()) {
|
|
26
29
|
const scripts = [typeof entry === 'function' ? await entry([]) : entry].flat();
|
|
27
30
|
const options = { cwd, manifest };
|
|
28
31
|
_getDependenciesFromScripts(scripts, options).forEach(identifier => dependencies.add(identifier));
|
|
@@ -5,10 +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,
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const findMarkdownlintConfigDependencies = async (configFilePath, options) => {
|
|
9
|
+
const { manifest, isProduction } = options;
|
|
10
|
+
if (isProduction)
|
|
11
|
+
return [];
|
|
12
|
+
const localConfig = await load(configFilePath);
|
|
13
|
+
const extend = localConfig?.extends ? [localConfig.extends] : [];
|
|
14
|
+
const scripts = manifest?.scripts
|
|
12
15
|
? Object.values(manifest.scripts).filter((script) => typeof script === 'string')
|
|
13
16
|
: [];
|
|
14
17
|
const uses = 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,20 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export const ENTRY_FILE_PATTERNS = ['**/test/*.{js,cjs,mjs}'];
|
|
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)
|
|
16
|
+
return entryPatterns;
|
|
17
|
+
const require = localConfig.require ? [localConfig.require].flat() : [];
|
|
18
|
+
return [...require, ...entryPatterns];
|
|
14
19
|
};
|
|
15
20
|
export const findDependencies = timerify(findMochaDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,9 @@ export const PRODUCTION_ENTRY_FILE_PATTERNS = [
|
|
|
17
18
|
...productionEntryFilePatternsWithoutSrc,
|
|
18
19
|
...productionEntryFilePatternsWithoutSrc.map(pattern => `src/${pattern}`),
|
|
19
20
|
];
|
|
21
|
+
export const findDependencies = async (configFilePath, options) => {
|
|
22
|
+
const { config } = options;
|
|
23
|
+
return config.entry
|
|
24
|
+
? config.entry.map(toProductionEntryPattern)
|
|
25
|
+
: [...ENTRY_FILE_PATTERNS.map(toEntryPattern), ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern)];
|
|
26
|
+
};
|
|
@@ -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 = "This plugin is enabled when any script in `package.json` includes `node --test`";
|
|
4
|
+
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
|
+
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
6
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 = 'This plugin is enabled when any script in `package.json` includes `node --test`';
|
|
5
|
+
export const isEnabled = ({ manifest }) => {
|
|
6
|
+
return Object.keys(manifest.scripts ?? {})
|
|
7
|
+
.filter(s => /test/.test(s))
|
|
8
|
+
.some(s => manifest.scripts && /node (.*)--test/.test(manifest.scripts[s]));
|
|
9
|
+
};
|
|
10
|
+
export const ENTRY_FILE_PATTERNS = [
|
|
11
|
+
'**/*{.,-,_}test.?(c|m)js',
|
|
12
|
+
'**/test-*.?(c|m)js',
|
|
13
|
+
'**/test.?(c|m)js',
|
|
14
|
+
'**/test/**/*.?(c|m)js',
|
|
15
|
+
];
|
|
16
|
+
const findNodeTestRunnerDependencies = async (configFilePath, options) => {
|
|
17
|
+
return (options.config?.entry ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
18
|
+
};
|
|
19
|
+
export const findDependencies = timerify(findNodeTestRunnerDependencies);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "npm-package-json-lint";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const PACKAGE_JSON_PATH = "npmpackagejsonlint";
|
|
4
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
7
|
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -2,12 +2,16 @@ import { timerify } from '../../util/Performance.js';
|
|
|
2
2
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
3
|
export const NAME = 'npm-package-json-lint';
|
|
4
4
|
export const ENABLERS = ['npm-package-json-lint'];
|
|
5
|
+
export const PACKAGE_JSON_PATH = 'npmpackagejsonlint';
|
|
5
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
6
7
|
export const CONFIG_FILE_PATTERNS = ['.npmpackagejsonlintrc.json', 'npmpackagejsonlint.config.js', 'package.json'];
|
|
7
|
-
const findNpmPkgJsonLintConfigDependencies = async (configFilePath,
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const findNpmPkgJsonLintConfigDependencies = async (configFilePath, options) => {
|
|
9
|
+
const { manifest, isProduction } = options;
|
|
10
|
+
if (isProduction)
|
|
11
|
+
return [];
|
|
12
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
13
|
+
? manifest[PACKAGE_JSON_PATH]
|
|
10
14
|
: await load(configFilePath);
|
|
11
|
-
return
|
|
15
|
+
return localConfig?.extends ? [localConfig.extends] : [];
|
|
12
16
|
};
|
|
13
17
|
export const findDependencies = timerify(findNpmPkgJsonLintConfigDependencies);
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -3,22 +3,25 @@ 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,
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
9
|
+
const findNxDependencies = async (configFilePath, options) => {
|
|
10
|
+
const { cwd, manifest, isProduction } = options;
|
|
11
|
+
if (isProduction)
|
|
12
12
|
return [];
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const localConfig = await load(configFilePath);
|
|
14
|
+
if (!localConfig)
|
|
15
|
+
return [];
|
|
16
|
+
const targets = localConfig.targets ? Object.values(localConfig.targets) : [];
|
|
17
|
+
const executors = targets
|
|
15
18
|
.map(target => target?.executor)
|
|
16
19
|
.filter(executor => executor && !executor.startsWith('.'))
|
|
17
|
-
.map(executor => executor?.split(':')[0])
|
|
18
|
-
const scripts =
|
|
20
|
+
.map(executor => executor?.split(':')[0]);
|
|
21
|
+
const scripts = targets
|
|
19
22
|
.filter(target => target.executor === 'nx:run-commands')
|
|
20
|
-
.flatMap(target => target.options?.commands ?? (target.options?.command ? [target.options.command] : []))
|
|
23
|
+
.flatMap(target => target.options?.commands ?? (target.options?.command ? [target.options.command] : []));
|
|
21
24
|
const dependencies = _getDependenciesFromScripts(scripts, { cwd, manifest });
|
|
22
|
-
return [...executors, ...dependencies];
|
|
25
|
+
return compact([...executors, ...dependencies]);
|
|
23
26
|
};
|
|
24
27
|
export const findDependencies = timerify(findNxDependencies);
|
|
@@ -4,8 +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) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
const findNycDependencies = async (configFilePath, options) => {
|
|
8
|
+
const { isProduction } = options;
|
|
9
|
+
if (isProduction)
|
|
10
|
+
return [];
|
|
11
|
+
const localConfig = await load(configFilePath);
|
|
12
|
+
return localConfig?.extends ? [localConfig.extends].flat() : [];
|
|
10
13
|
};
|
|
11
14
|
export const findDependencies = timerify(findNycDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
1
|
+
import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
|
|
2
|
+
import type { PlaywrightTestConfig } from 'playwright/test';
|
|
2
3
|
export declare const NAME = "Playwright";
|
|
3
4
|
export declare const ENABLERS: string[];
|
|
4
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
6
|
+
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
5
7
|
export declare const ENTRY_FILE_PATTERNS: string[];
|
|
8
|
+
export declare const toEntryPatterns: (testMatch: string | RegExp | Array<string | RegExp> | undefined, cwd: string, configFilePath: string, config: PlaywrightTestConfig) => string[];
|
|
9
|
+
export declare const findDependencies: GenericPluginCallback;
|
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dirname, join, relative } from '../../util/path.js';
|
|
2
|
+
import { timerify } from '../../util/Performance.js';
|
|
3
|
+
import { hasDependency, load } from '../../util/plugin.js';
|
|
4
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
2
5
|
export const NAME = 'Playwright';
|
|
3
6
|
export const ENABLERS = ['@playwright/test'];
|
|
4
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
5
|
-
export const
|
|
8
|
+
export const CONFIG_FILE_PATTERNS = ['playwright.config.{js,ts}'];
|
|
9
|
+
export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
|
|
10
|
+
export const toEntryPatterns = (testMatch, cwd, configFilePath, config) => {
|
|
11
|
+
if (!testMatch)
|
|
12
|
+
return [];
|
|
13
|
+
const dir = relative(cwd, config.testDir ? join(dirname(configFilePath), config.testDir) : dirname(configFilePath));
|
|
14
|
+
const patterns = [testMatch].flat().filter((p) => typeof p === 'string');
|
|
15
|
+
return patterns.map(pattern => toEntryPattern(join(dir, pattern)));
|
|
16
|
+
};
|
|
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];
|
|
22
|
+
const patterns = projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFilePath, config));
|
|
23
|
+
if (patterns.length > 0)
|
|
24
|
+
return patterns;
|
|
25
|
+
}
|
|
26
|
+
return (config?.entry ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
27
|
+
};
|
|
28
|
+
export const findDependencies = timerify(findPlaywrightDependencies);
|
|
@@ -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 = "Playwright for components";
|
|
3
3
|
export declare const ENABLERS: RegExp[];
|
|
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,5 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { timerify } from '../../util/Performance.js';
|
|
2
|
+
import { hasDependency, load } from '../../util/plugin.js';
|
|
3
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
4
|
+
import { toEntryPatterns } from '../playwright/index.js';
|
|
2
5
|
export const NAME = 'Playwright for components';
|
|
3
6
|
export const ENABLERS = [/^@playwright\/experimental-ct-/];
|
|
4
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
5
|
-
export const
|
|
8
|
+
export const CONFIG_FILE_PATTERNS = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}'];
|
|
9
|
+
export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
|
|
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);
|
|
20
|
+
};
|
|
21
|
+
export const findDependencies = timerify(findPlaywrightCTDependencies);
|
|
@@ -3,19 +3,22 @@ import { hasDependency, load } from '../../util/plugin.js';
|
|
|
3
3
|
export const NAME = 'PostCSS';
|
|
4
4
|
export const ENABLERS = ['postcss', 'next'];
|
|
5
5
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
6
|
-
export const CONFIG_FILE_PATTERNS = ['postcss.config.js', 'postcss.config.json', 'package.json'];
|
|
7
|
-
const findPostCSSDependencies = async (configFilePath,
|
|
8
|
-
const
|
|
6
|
+
export const CONFIG_FILE_PATTERNS = ['postcss.config.{cjs,js}', 'postcss.config.json', 'package.json'];
|
|
7
|
+
const findPostCSSDependencies = async (configFilePath, options) => {
|
|
8
|
+
const { manifest, isProduction } = options;
|
|
9
|
+
if (isProduction)
|
|
10
|
+
return [];
|
|
11
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
9
12
|
? manifest?.postcss
|
|
10
13
|
: await load(configFilePath);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
if (!localConfig)
|
|
15
|
+
return [];
|
|
16
|
+
return localConfig.plugins
|
|
17
|
+
? (Array.isArray(localConfig.plugins) ? localConfig.plugins : Object.keys(localConfig.plugins)).flatMap(plugin => {
|
|
18
|
+
if (typeof plugin === 'string')
|
|
14
19
|
return plugin;
|
|
15
|
-
|
|
16
|
-
if (Array.isArray(plugin) && typeof plugin[0] === 'string') {
|
|
20
|
+
if (Array.isArray(plugin) && typeof plugin[0] === 'string')
|
|
17
21
|
return plugin[0];
|
|
18
|
-
}
|
|
19
22
|
return [];
|
|
20
23
|
})
|
|
21
24
|
: [];
|
|
@@ -5,16 +5,21 @@ export const ENABLERS = ['prettier'];
|
|
|
5
5
|
export const isEnabled = ({ dependencies, config }) => hasDependency(dependencies, ENABLERS) || 'prettier' in config;
|
|
6
6
|
export const CONFIG_FILE_PATTERNS = [
|
|
7
7
|
'.prettierrc',
|
|
8
|
-
'.prettierrc.{json,js,cjs,yml,yaml}',
|
|
9
|
-
'prettier.config.{js,cjs}',
|
|
8
|
+
'.prettierrc.{json,js,cjs,mjs,yml,yaml}',
|
|
9
|
+
'prettier.config.{js,cjs,mjs}',
|
|
10
10
|
'package.json',
|
|
11
11
|
];
|
|
12
|
-
const findPrettierDependencies = async (configFilePath, { manifest }) => {
|
|
13
|
-
|
|
12
|
+
const findPrettierDependencies = async (configFilePath, { manifest, isProduction }) => {
|
|
13
|
+
if (isProduction)
|
|
14
|
+
return [];
|
|
15
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
14
16
|
? manifest.prettier
|
|
15
17
|
: await load(configFilePath);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
if (typeof localConfig === 'string') {
|
|
19
|
+
return [localConfig];
|
|
20
|
+
}
|
|
21
|
+
return localConfig && Array.isArray(localConfig.plugins)
|
|
22
|
+
? localConfig.plugins.filter((plugin) => typeof plugin === 'string')
|
|
18
23
|
: [];
|
|
19
24
|
};
|
|
20
25
|
export const findDependencies = timerify(findPrettierDependencies);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "Release It";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const PACKAGE_JSON_PATH = "release-it";
|
|
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 = 'Release It';
|
|
5
5
|
export const ENABLERS = ['release-it'];
|
|
6
|
+
export const PACKAGE_JSON_PATH = 'release-it';
|
|
6
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
8
|
export const CONFIG_FILE_PATTERNS = [
|
|
8
9
|
'.release-it.json',
|
|
@@ -10,19 +11,22 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
10
11
|
'.release-it.{yml,yaml}',
|
|
11
12
|
'package.json',
|
|
12
13
|
];
|
|
13
|
-
const findReleaseItDependencies = async (configFilePath,
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const findReleaseItDependencies = async (configFilePath, options) => {
|
|
15
|
+
const { cwd, manifest, isProduction } = options;
|
|
16
|
+
if (isProduction)
|
|
17
|
+
return [];
|
|
18
|
+
const localConfig = configFilePath.endsWith('package.json')
|
|
19
|
+
? manifest[PACKAGE_JSON_PATH]
|
|
16
20
|
: await load(configFilePath);
|
|
17
|
-
if (!
|
|
21
|
+
if (!localConfig)
|
|
18
22
|
return [];
|
|
19
|
-
const plugins =
|
|
20
|
-
const scripts =
|
|
21
|
-
if (typeof
|
|
22
|
-
scripts.push(
|
|
23
|
+
const plugins = localConfig.plugins ? Object.keys(localConfig.plugins) : [];
|
|
24
|
+
const scripts = localConfig.hooks ? Object.values(localConfig.hooks).flat() : [];
|
|
25
|
+
if (typeof localConfig.github?.releaseNotes === 'string') {
|
|
26
|
+
scripts.push(localConfig.github.releaseNotes);
|
|
23
27
|
}
|
|
24
|
-
if (typeof
|
|
25
|
-
scripts.push(
|
|
28
|
+
if (typeof localConfig.gitlab?.releaseNotes === 'string') {
|
|
29
|
+
scripts.push(localConfig.gitlab.releaseNotes);
|
|
26
30
|
}
|
|
27
31
|
const dependencies = _getDependenciesFromScripts(scripts, { cwd, manifest });
|
|
28
32
|
return [...plugins, ...dependencies];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
|
|
2
2
|
export declare const NAME = "Remark";
|
|
3
3
|
export declare const ENABLERS: string[];
|
|
4
|
+
export declare const PACKAGE_JSON_PATH = "remarkConfig";
|
|
4
5
|
export declare const isEnabled: IsPluginEnabledCallback;
|
|
5
6
|
export declare const CONFIG_FILE_PATTERNS: string[];
|
|
6
7
|
export declare const findDependencies: GenericPluginCallback;
|