knip 6.44.1 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurationChief.d.ts +23 -1033
- package/dist/ConfigurationChief.js +71 -15
- package/dist/DependencyDeputy.d.ts +10 -6
- package/dist/DependencyDeputy.js +51 -27
- package/dist/IssueCollector.d.ts +14 -11
- package/dist/IssueCollector.js +25 -20
- package/dist/IssueFixer.js +1 -1
- package/dist/PackagePeeker.d.ts +6 -0
- package/dist/PackagePeeker.js +43 -14
- package/dist/ProjectPrincipal.d.ts +6 -3
- package/dist/ProjectPrincipal.js +83 -32
- package/dist/WorkspaceWorker.d.ts +5 -1
- package/dist/WorkspaceWorker.js +39 -22
- package/dist/binaries/bash-parser.js +1 -7
- package/dist/binaries/command.d.ts +3 -3
- package/dist/binaries/command.js +6 -2
- package/dist/binaries/fallback.js +1 -1
- package/dist/binaries/plugins.d.ts +4 -1
- package/dist/binaries/plugins.js +66 -18
- package/dist/binaries/resolvers/bun.js +2 -2
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +2 -0
- package/dist/binaries/resolvers/npm.js +7 -5
- package/dist/binaries/resolvers/npx.js +15 -12
- package/dist/binaries/resolvers/nub.js +2 -2
- package/dist/binaries/resolvers/vp.d.ts +2 -0
- package/dist/binaries/resolvers/vp.js +52 -0
- package/dist/binaries/util.d.ts +13 -1
- package/dist/binaries/util.js +35 -1
- package/dist/cli.js +10 -84
- package/dist/compilers/scss.js +2 -1
- package/dist/configuration-hints.d.ts +16 -0
- package/dist/configuration-hints.js +64 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +37 -0
- package/dist/graph/SubpathReferences.d.ts +33 -0
- package/dist/graph/SubpathReferences.js +114 -0
- package/dist/graph/analyze.d.ts +4 -1
- package/dist/graph/analyze.js +16 -5
- package/dist/graph/build.d.ts +3 -1
- package/dist/graph/build.js +47 -23
- package/dist/graph-explorer/operations/resolve-export-origins.js +1 -1
- package/dist/plugins/angular/index.js +10 -17
- package/dist/plugins/aws-cdk/index.d.ts +3 -0
- package/dist/plugins/aws-cdk/index.js +32 -0
- package/dist/plugins/aws-cdk/types.d.ts +5 -0
- package/dist/plugins/aws-cdk/types.js +1 -0
- package/dist/plugins/babel/index.d.ts +1 -1
- package/dist/plugins/babel/index.js +25 -6
- package/dist/plugins/babel/types.d.ts +1 -0
- package/dist/plugins/bun/index.js +8 -7
- package/dist/plugins/c8/index.js +17 -4
- package/dist/plugins/changesets/index.js +3 -2
- package/dist/plugins/commitizen/index.js +6 -3
- package/dist/plugins/commitlint/index.js +10 -11
- package/dist/plugins/cypress/index.js +4 -2
- package/dist/plugins/danger/index.js +1 -1
- package/dist/plugins/docusaurus/helpers.js +6 -6
- package/dist/plugins/docusaurus/index.js +2 -2
- package/dist/plugins/electron-forge/index.js +2 -2
- package/dist/plugins/electron-vite/index.js +2 -2
- package/dist/plugins/eleventy/index.js +3 -2
- package/dist/plugins/eslint/helpers.js +4 -3
- package/dist/plugins/eslint/resolveFromAST.js +2 -2
- package/dist/plugins/evalite/index.d.ts +3 -0
- package/dist/plugins/evalite/index.js +26 -0
- package/dist/plugins/flue/index.js +2 -2
- package/dist/plugins/gatsby/index.js +1 -1
- package/dist/plugins/github-action/index.js +2 -2
- package/dist/plugins/github-actions/index.js +2 -2
- package/dist/plugins/graphql-codegen/index.js +13 -9
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/jest/index.js +5 -5
- package/dist/plugins/knex/index.js +2 -2
- package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +2 -2
- package/dist/plugins/lunaria/index.js +5 -2
- package/dist/plugins/markdownlint/index.js +8 -2
- package/dist/plugins/marko/index.js +2 -2
- package/dist/plugins/marko/taglibs.d.ts +1 -1
- package/dist/plugins/marko/taglibs.js +4 -28
- package/dist/plugins/mdx/index.d.ts +2 -1
- package/dist/plugins/mdx/index.js +7 -4
- package/dist/plugins/mdxlint/index.js +18 -15
- package/dist/plugins/mikro-orm/index.d.ts +3 -0
- package/dist/plugins/mikro-orm/index.js +77 -0
- package/dist/plugins/mikro-orm/types.d.ts +21 -0
- package/dist/plugins/mikro-orm/types.js +1 -0
- package/dist/plugins/msw/index.js +6 -3
- package/dist/plugins/msw/types.d.ts +1 -1
- package/dist/plugins/netlify/index.js +7 -3
- package/dist/plugins/next/index.js +63 -9
- package/dist/plugins/next/types.d.ts +5 -0
- package/dist/plugins/next-mdx/resolveFromAST.js +15 -10
- package/dist/plugins/nitro/index.js +5 -6
- package/dist/plugins/node/index.js +4 -4
- package/dist/plugins/npm-package-json-lint/index.js +10 -3
- package/dist/plugins/nuxt/index.js +18 -10
- package/dist/plugins/nuxt/types.d.ts +4 -0
- package/dist/plugins/nx/index.js +6 -3
- package/dist/plugins/openclaw/index.js +11 -11
- package/dist/plugins/oxlint/index.js +2 -2
- package/dist/plugins/payload/index.js +1 -1
- package/dist/plugins/playwright/index.js +3 -3
- package/dist/plugins/pm2/index.js +7 -7
- package/dist/plugins/prettier/index.js +2 -1
- package/dist/plugins/prisma/index.js +2 -2
- package/dist/plugins/quasar/resolveFromAST.js +14 -9
- package/dist/plugins/react-router/index.js +12 -15
- package/dist/plugins/release-it/index.js +6 -2
- package/dist/plugins/remix/index.js +3 -3
- package/dist/plugins/retry-cli/index.d.ts +3 -0
- package/dist/plugins/retry-cli/index.js +14 -0
- package/dist/plugins/rollup/index.js +1 -4
- package/dist/plugins/rstest/index.js +3 -3
- package/dist/plugins/semantic-release/index.js +3 -3
- package/dist/plugins/serverless-framework/index.js +10 -8
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +2 -2
- package/dist/plugins/stencil/resolveFromAST.js +5 -5
- package/dist/plugins/storybook/index.js +9 -3
- package/dist/plugins/stryker/index.js +2 -2
- package/dist/plugins/stylelint/index.js +2 -2
- package/dist/plugins/swc/index.js +4 -3
- package/dist/plugins/tailwind/index.js +2 -2
- package/dist/plugins/tanstack-router/index.js +2 -2
- package/dist/plugins/ts-node/index.js +6 -1
- package/dist/plugins/turbo/index.js +3 -3
- package/dist/plugins/typedoc/index.js +2 -2
- package/dist/plugins/typescript/content-mappers.d.ts +1 -1
- package/dist/plugins/typescript/index.js +6 -9
- package/dist/plugins/unocss/index.js +3 -0
- package/dist/plugins/varlock/scan.js +1 -1
- package/dist/plugins/vite/helpers.d.ts +1 -0
- package/dist/plugins/vite/helpers.js +13 -3
- package/dist/plugins/vite/index.js +5 -2
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
- package/dist/plugins/vitest/index.js +26 -18
- package/dist/plugins/vitest/types.d.ts +1 -0
- package/dist/plugins/vue/index.js +1 -1
- package/dist/plugins/web-test-runner/index.d.ts +3 -0
- package/dist/plugins/web-test-runner/index.js +86 -0
- package/dist/plugins/wrangler/index.js +3 -3
- package/dist/plugins/yarn/index.js +5 -5
- package/dist/plugins.js +2 -5
- package/dist/reporters/github-actions.js +3 -7
- package/dist/reporters/json.d.ts +1 -0
- package/dist/reporters/json.js +1 -0
- package/dist/reporters/util/configuration-hints.d.ts +3 -1
- package/dist/reporters/util/configuration-hints.js +40 -21
- package/dist/reporters/util/util.d.ts +1 -1
- package/dist/run-cli.d.ts +2 -0
- package/dist/run-cli.js +82 -0
- package/dist/run.js +12 -0
- package/dist/session/incremental.d.ts +1 -0
- package/dist/session/incremental.js +1 -0
- package/dist/session/watch.js +2 -1
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +5 -0
- package/dist/types/args.d.ts +3 -1
- package/dist/types/config.d.ts +17 -10
- package/dist/types/configuration.d.ts +45 -0
- package/dist/types/configuration.js +1 -0
- package/dist/types/issues.d.ts +4 -0
- package/dist/types/module-graph.d.ts +1 -0
- package/dist/types/options.d.ts +1 -0
- package/dist/types/package-json.d.ts +3 -8
- package/dist/types/workspace.d.ts +1 -0
- package/dist/typescript/get-imports-and-exports.js +18 -6
- package/dist/typescript/resolve-module-names.js +7 -45
- package/dist/typescript/visitors/calls.d.ts +1 -1
- package/dist/typescript/visitors/calls.js +14 -10
- package/dist/typescript/visitors/exports.js +16 -26
- package/dist/typescript/visitors/imports.d.ts +2 -1
- package/dist/typescript/visitors/imports.js +41 -24
- package/dist/typescript/visitors/members.d.ts +1 -1
- package/dist/typescript/visitors/members.js +38 -24
- package/dist/typescript/visitors/shadow.d.ts +2 -0
- package/dist/typescript/visitors/shadow.js +25 -0
- package/dist/typescript/visitors/walk.d.ts +20 -12
- package/dist/typescript/visitors/walk.js +78 -48
- package/dist/util/Performance.d.ts +25 -3
- package/dist/util/Performance.js +51 -27
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +5 -3
- package/dist/util/create-input-handler.js +138 -119
- package/dist/util/create-options.d.ts +4 -2071
- package/dist/util/create-options.js +6 -4
- package/dist/util/create-workspace-graph.js +2 -1
- package/dist/util/errors.d.ts +5 -2
- package/dist/util/errors.js +11 -18
- package/dist/util/fs.js +4 -2
- package/dist/util/input.d.ts +2 -2
- package/dist/util/input.js +2 -2
- package/dist/util/is-plugin-name.d.ts +2 -0
- package/dist/util/is-plugin-name.js +3 -0
- package/dist/util/jiti.d.ts +2 -1
- package/dist/util/jiti.js +11 -3
- package/dist/util/load-config.d.ts +1 -1
- package/dist/util/load-config.js +3 -2
- package/dist/util/loader.js +3 -2
- package/dist/util/map-workspaces.js +23 -1
- package/dist/util/module-graph.js +1 -0
- package/dist/util/modules.d.ts +2 -0
- package/dist/util/modules.js +78 -0
- package/dist/util/package-json.d.ts +12 -5
- package/dist/util/package-json.js +54 -26
- package/dist/util/parse-and-convert-gitignores.d.ts +2 -2
- package/dist/util/parse-and-convert-gitignores.js +5 -5
- package/dist/util/parse-configuration.d.ts +2 -0
- package/dist/util/parse-configuration.js +66 -0
- package/dist/util/plugin.js +8 -12
- package/dist/util/resolve.d.ts +1 -0
- package/dist/util/resolve.js +3 -2
- package/dist/util/scripts.d.ts +0 -5
- package/dist/util/scripts.js +1 -32
- package/dist/util/to-source-path.d.ts +4 -1
- package/dist/util/to-source-path.js +2 -2
- package/dist/util/unhandled-rejection.d.ts +8 -0
- package/dist/util/unhandled-rejection.js +29 -0
- package/dist/util/validation.d.ts +11 -0
- package/dist/util/validation.js +68 -0
- package/dist/util/watch.d.ts +3 -1
- package/dist/util/watch.js +5 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -10
- package/schema.json +34 -0
- package/dist/schema/configuration.d.ts +0 -3103
- package/dist/schema/configuration.js +0 -94
- package/dist/schema/plugins.d.ts +0 -1019
- package/dist/schema/plugins.js +0 -215
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { toConfig, toDeferResolve, toDependency, toEntry, toProductionEntry } from '../../util/input.js';
|
|
3
|
-
import { isInternal, join } from '../../util/path.js';
|
|
1
|
+
import { toConfig, toDeferResolve, toDeferResolveEntry, toDeferResolveProductionEntry, toDependency, toEntry, } from '../../util/input.js';
|
|
4
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
3
|
import { createComponentStyleUrlsVisitor } from '../_component-style-urls/component-style-urls-visitor.js';
|
|
6
4
|
import * as karma from '../karma/helpers.js';
|
|
@@ -29,30 +27,25 @@ const resolveConfig = async (config, options) => {
|
|
|
29
27
|
const entriesByOptionByConfig = new Map(configs ? Object.entries(configs).map(([name, opts]) => [name, entriesByOption(opts)]) : []);
|
|
30
28
|
const productionEntriesByOption = entriesByOptionByConfig.get(PRODUCTION_CONFIG_NAME) ?? new Map();
|
|
31
29
|
const isBuildTarget = targetName === BUILD_TARGET_NAME;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const toInput = (option, specifier, isProduction) => {
|
|
31
|
+
const opts = { dir: options.cwd };
|
|
32
|
+
if (option === 'polyfills') {
|
|
33
|
+
return isProduction
|
|
34
|
+
? toDeferResolve(specifier, { ...opts, production: true })
|
|
35
|
+
: toDeferResolve(specifier, opts);
|
|
37
36
|
}
|
|
38
|
-
return
|
|
37
|
+
return isProduction ? toDeferResolveProductionEntry(specifier, opts) : toDeferResolveEntry(specifier, opts);
|
|
39
38
|
};
|
|
40
39
|
for (const [configName, entriesByOption] of entriesByOptionByConfig) {
|
|
41
40
|
for (const [option, entries] of entriesByOption) {
|
|
42
41
|
for (const entry of entries) {
|
|
43
|
-
inputs.add(toInput(entry,
|
|
44
|
-
isProduction: isBuildTarget && configName === PRODUCTION_CONFIG_NAME,
|
|
45
|
-
maybeExternal: maybeExternal(option),
|
|
46
|
-
}));
|
|
42
|
+
inputs.add(toInput(option, entry, isBuildTarget && configName === PRODUCTION_CONFIG_NAME));
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
for (const [option, entries] of defaultEntriesByOption) {
|
|
51
47
|
for (const entry of entries) {
|
|
52
|
-
inputs.add(toInput(entry,
|
|
53
|
-
isProduction: isBuildTarget && !productionEntriesByOption.get(option)?.length,
|
|
54
|
-
maybeExternal: maybeExternal(option),
|
|
55
|
-
}));
|
|
48
|
+
inputs.add(toInput(option, entry, isBuildTarget && !productionEntriesByOption.get(option)?.length));
|
|
56
49
|
}
|
|
57
50
|
}
|
|
58
51
|
if (target.builder && isAngularBuilderRefWithName({ builderRef: target.builder, name: 'karma' }) && opts) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isDirectory } from '../../util/fs.js';
|
|
2
|
+
import { toDeferResolve } from '../../util/input.js';
|
|
3
|
+
import { toAbsolute } from '../../util/path.js';
|
|
4
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
5
|
+
const title = 'AWS CDK';
|
|
6
|
+
const enablers = ['aws-cdk', 'aws-cdk-lib'];
|
|
7
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
|
+
const config = ['cdk.json'];
|
|
9
|
+
const resolveConfig = (localConfig, options) => {
|
|
10
|
+
const scripts = [localConfig.build, localConfig.app].filter((script) => typeof script === 'string');
|
|
11
|
+
const inputs = options.getInputsFromScripts(scripts, { optionalBinaries: true, cwd: options.configFileDir });
|
|
12
|
+
for (const id of localConfig.plugin ?? [])
|
|
13
|
+
inputs.push(toDeferResolve(id));
|
|
14
|
+
return inputs;
|
|
15
|
+
};
|
|
16
|
+
const args = {
|
|
17
|
+
binaries: ['cdk'],
|
|
18
|
+
string: ['app'],
|
|
19
|
+
alias: { app: ['a'] },
|
|
20
|
+
fromArgs: (parsed, _, { cwd }) => typeof parsed.app === 'string' && parsed.app.includes(' ') && !isDirectory(toAbsolute(parsed.app, cwd))
|
|
21
|
+
? parsed.app.split(' ')
|
|
22
|
+
: [],
|
|
23
|
+
};
|
|
24
|
+
const plugin = {
|
|
25
|
+
title,
|
|
26
|
+
enablers,
|
|
27
|
+
isEnabled,
|
|
28
|
+
config,
|
|
29
|
+
resolveConfig,
|
|
30
|
+
args,
|
|
31
|
+
};
|
|
32
|
+
export default plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from '../../types/config.ts';
|
|
2
2
|
import { type Input } from '../../util/input.ts';
|
|
3
3
|
import type { BabelConfigObj } from './types.ts';
|
|
4
|
-
export declare const getDependenciesFromConfig: (config: BabelConfigObj) => Input[];
|
|
4
|
+
export declare const getDependenciesFromConfig: (config: BabelConfigObj, isProduction?: boolean) => Input[];
|
|
5
5
|
declare const plugin: Plugin;
|
|
6
6
|
export default plugin;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
|
-
import { toDeferResolve } from '../../util/input.js';
|
|
2
|
+
import { toConfig, toDeferResolve, toDependency } from '../../util/input.js';
|
|
3
|
+
import { getPackageNameFromSpecifier } from '../../util/modules.js';
|
|
3
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
5
|
import { api, resolveName } from './helpers.js';
|
|
5
6
|
const title = 'Babel';
|
|
@@ -12,27 +13,45 @@ const config = [
|
|
|
12
13
|
'package.json',
|
|
13
14
|
];
|
|
14
15
|
const getName = (value) => [Array.isArray(value) ? value[0] : value].filter(name => typeof name === 'string');
|
|
15
|
-
|
|
16
|
+
const DECORATOR_TRANSFORMS = 'decorator-transforms';
|
|
17
|
+
const isRuntimeImportPlugin = (value) => {
|
|
18
|
+
if (!Array.isArray(value) || typeof value[0] !== 'string')
|
|
19
|
+
return false;
|
|
20
|
+
if (getPackageNameFromSpecifier(resolveName(value[0], 'plugin')) !== DECORATOR_TRANSFORMS)
|
|
21
|
+
return false;
|
|
22
|
+
const runtime = value[1]?.runtime;
|
|
23
|
+
return typeof runtime?.import === 'string';
|
|
24
|
+
};
|
|
25
|
+
export const getDependenciesFromConfig = (config, isProduction = true) => {
|
|
16
26
|
const presets = config.presets?.flatMap(getName).map(name => resolveName(name, 'preset')) ?? [];
|
|
17
27
|
const plugins = config.plugins?.flatMap(getName).map(name => resolveName(name, 'plugin')) ?? [];
|
|
18
|
-
const
|
|
19
|
-
const
|
|
28
|
+
const toInputs = (config) => getDependenciesFromConfig(config, isProduction);
|
|
29
|
+
const nested = config.env ? Object.values(config.env).flatMap(toInputs) : [];
|
|
30
|
+
const overrides = config.overrides ? [config.overrides].flat().flatMap(toInputs) : [];
|
|
20
31
|
return compact([
|
|
21
32
|
...presets.map(id => toDeferResolve(id)),
|
|
22
33
|
...plugins.map(id => toDeferResolve(id)),
|
|
23
34
|
...(plugins.includes('@babel/plugin-transform-runtime')
|
|
24
|
-
? [
|
|
35
|
+
? [toDependency('@babel/runtime', { optional: true, production: isProduction })]
|
|
36
|
+
: []),
|
|
37
|
+
...(config.plugins?.some(isRuntimeImportPlugin)
|
|
38
|
+
? [toDependency(DECORATOR_TRANSFORMS, { production: isProduction })]
|
|
25
39
|
: []),
|
|
26
40
|
...nested,
|
|
27
41
|
...overrides,
|
|
28
42
|
]);
|
|
29
43
|
};
|
|
44
|
+
const getExtendedConfigs = (config) => [
|
|
45
|
+
...(config.extends ? [toConfig('babel', config.extends)] : []),
|
|
46
|
+
...Object.values(config.env ?? {}).flatMap(getExtendedConfigs),
|
|
47
|
+
...(config.overrides ?? []).flatMap(getExtendedConfigs),
|
|
48
|
+
];
|
|
30
49
|
const resolveConfig = async (config) => {
|
|
31
50
|
if (typeof config === 'function')
|
|
32
51
|
config = config(api);
|
|
33
52
|
if (!config)
|
|
34
53
|
return [];
|
|
35
|
-
return getDependenciesFromConfig(config);
|
|
54
|
+
return [...getExtendedConfigs(config), ...getDependenciesFromConfig(config)];
|
|
36
55
|
};
|
|
37
56
|
const plugin = {
|
|
38
57
|
title,
|
|
@@ -2,6 +2,7 @@ import type { api } from './helpers.ts';
|
|
|
2
2
|
type BabelConfigFn = (options: typeof api) => BabelConfigObj;
|
|
3
3
|
export type BabelConfigObj = {
|
|
4
4
|
configFile?: string;
|
|
5
|
+
extends?: string;
|
|
5
6
|
plugins?: (string | [string, unknown])[];
|
|
6
7
|
presets?: (string | [string, unknown])[];
|
|
7
8
|
env?: Record<string, BabelConfigObj>;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { isFile } from '../../util/fs.js';
|
|
2
2
|
import { toDeferResolve, toEntry, toIgnore } from '../../util/input.js';
|
|
3
3
|
import parseArgs from '../../util/parse-args.js';
|
|
4
|
-
import { getScriptCommands } from '../../util/scripts.js';
|
|
5
4
|
const title = 'Bun';
|
|
6
5
|
const enablers = 'This plugin is enabled when a `bun.lock` or `bun.lockb` file is found or a `bun test` script is configured.';
|
|
7
6
|
const patterns = ['**/*.{test,spec}.{js,jsx,ts,tsx}', '**/*_{test,spec}.{js,jsx,ts,tsx}'];
|
|
8
|
-
const getBunTest = (script) => {
|
|
9
|
-
for (const { binary, args } of getScriptCommands(script)) {
|
|
7
|
+
const getBunTest = (script, cwd, getScriptCommands) => {
|
|
8
|
+
for (const { binary, args } of getScriptCommands(script, cwd)) {
|
|
10
9
|
if (binary !== 'bun')
|
|
11
10
|
continue;
|
|
12
11
|
const parsed = parseArgs(args, { string: ['timeout', 'rerun-each', 'preload'] });
|
|
@@ -14,8 +13,9 @@ const getBunTest = (script) => {
|
|
|
14
13
|
return parsed;
|
|
15
14
|
}
|
|
16
15
|
};
|
|
17
|
-
const hasBunTest = (scripts
|
|
18
|
-
|
|
16
|
+
const hasBunTest = (scripts, cwd, getScriptCommands) => scripts &&
|
|
17
|
+
Object.values(scripts).some(script => typeof script === 'string' && getBunTest(script, cwd, getScriptCommands));
|
|
18
|
+
const isEnabled = ({ cwd, manifest, getScriptCommands }) => isFile(cwd, 'bun.lock') || isFile(cwd, 'bun.lockb') || !!hasBunTest(manifest.scripts, cwd, getScriptCommands);
|
|
19
19
|
const config = ['bunfig.toml'];
|
|
20
20
|
const resolveConfig = localConfig => {
|
|
21
21
|
const preload = localConfig.test?.preload ?? [];
|
|
@@ -45,10 +45,11 @@ const toPatterns = (arg) => {
|
|
|
45
45
|
const resolve = options => {
|
|
46
46
|
const scripts = { ...options.rootManifest?.scripts, ...options.manifest.scripts };
|
|
47
47
|
const inputs = [toIgnore('bun', 'dependencies')];
|
|
48
|
-
for (const script of Object.
|
|
48
|
+
for (const [name, script] of Object.entries(scripts)) {
|
|
49
49
|
if (typeof script !== 'string')
|
|
50
50
|
continue;
|
|
51
|
-
const
|
|
51
|
+
const cwd = options.manifest.scripts?.[name] !== undefined ? options.cwd : options.rootCwd;
|
|
52
|
+
const parsed = getBunTest(script, cwd, options.getScriptCommands);
|
|
52
53
|
if (!parsed)
|
|
53
54
|
continue;
|
|
54
55
|
const targets = parsed._.slice(1);
|
package/dist/plugins/c8/index.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawningArgs } from '../../binaries/util.js';
|
|
2
2
|
const title = 'c8';
|
|
3
|
+
const commands = new Set(['check-coverage', 'report']);
|
|
3
4
|
const args = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
boolean: [
|
|
6
|
+
'100',
|
|
7
|
+
'all',
|
|
8
|
+
'allowExternal',
|
|
9
|
+
'check-coverage',
|
|
10
|
+
'clean',
|
|
11
|
+
'exclude-after-remap',
|
|
12
|
+
'exclude-node-modules',
|
|
13
|
+
'experimental-monocart',
|
|
14
|
+
'merge-async',
|
|
15
|
+
'omit-relative',
|
|
16
|
+
'per-file',
|
|
17
|
+
'skip-full',
|
|
18
|
+
],
|
|
19
|
+
fromArgs: (parsed, args) => (commands.has(parsed._[0]) ? [] : spawningArgs(parsed, args)),
|
|
7
20
|
};
|
|
8
21
|
const plugin = {
|
|
9
22
|
title,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { toDependency } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolve, toDependency } from '../../util/input.js';
|
|
2
2
|
import { getPackageNameFromFilePath } from '../../util/modules.js';
|
|
3
|
+
import { isInternal } from '../../util/path.js';
|
|
3
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
5
|
const title = 'Changesets';
|
|
5
6
|
const enablers = ['@changesets/cli'];
|
|
@@ -11,7 +12,7 @@ const resolveConfig = config => {
|
|
|
11
12
|
? [config.changelog[0]]
|
|
12
13
|
: typeof config.changelog === 'string'
|
|
13
14
|
? [config.changelog]
|
|
14
|
-
: []).map(id => toDependency(id));
|
|
15
|
+
: []).map(id => (isInternal(id) ? toDeferResolve(id) : toDependency(id)));
|
|
15
16
|
if (config.$schema?.includes('node_modules/')) {
|
|
16
17
|
const packageName = getPackageNameFromFilePath(config.$schema);
|
|
17
18
|
if (packageName)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { toDependency } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolve, toDependency } from '../../util/input.js';
|
|
2
|
+
import { isInternal } from '../../util/path.js';
|
|
2
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
4
|
const title = 'Commitizen';
|
|
4
5
|
const enablers = ['commitizen'];
|
|
@@ -6,8 +7,10 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
6
7
|
const isRootOnly = true;
|
|
7
8
|
const packageJsonPath = 'config.commitizen';
|
|
8
9
|
const config = ['.czrc', '.cz.json', 'package.json'];
|
|
9
|
-
const resolveConfig = config => {
|
|
10
|
-
|
|
10
|
+
const resolveConfig = (config, options) => {
|
|
11
|
+
if (!config.path)
|
|
12
|
+
return [];
|
|
13
|
+
return [isInternal(config.path) ? toDeferResolve(config.path, { dir: options.cwd }) : toDependency(config.path)];
|
|
11
14
|
};
|
|
12
15
|
const plugin = {
|
|
13
16
|
title,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toConfig, toDependency } from '../../util/input.js';
|
|
1
|
+
import { toConfig, toDeferResolve, toDependency } from '../../util/input.js';
|
|
2
2
|
import { isInternal } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { toCosmiconfig } from '../../util/plugin-config.js';
|
|
@@ -39,17 +39,16 @@ const resolveConfig = async (config) => {
|
|
|
39
39
|
if (typeof id === 'string')
|
|
40
40
|
plugins.push(toPluginSpecifier(id));
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
const parserPreset = await config.parserPreset;
|
|
44
|
-
const parserPresetPaths = parserPreset
|
|
45
|
-
? typeof parserPreset === 'string'
|
|
46
|
-
? [parserPreset]
|
|
47
|
-
: parserPreset.path
|
|
48
|
-
? [parserPreset.path ?? parserPreset]
|
|
49
|
-
: []
|
|
50
|
-
: [];
|
|
51
|
-
for (const id of [...extendsConfigs, ...plugins, ...formatter, ...parserPresetPaths])
|
|
42
|
+
for (const id of [...extendsConfigs, ...plugins])
|
|
52
43
|
inputs.push(toDependency(id));
|
|
44
|
+
const parserPreset = await config.parserPreset;
|
|
45
|
+
const modules = config.formatter ? [config.formatter] : [];
|
|
46
|
+
if (typeof parserPreset === 'string')
|
|
47
|
+
modules.push(parserPreset);
|
|
48
|
+
for (const id of modules)
|
|
49
|
+
inputs.push(isInternal(id) ? toDeferResolve(id) : toDependency(id));
|
|
50
|
+
if (typeof parserPreset === 'object' && parserPreset.path)
|
|
51
|
+
inputs.push(toDependency(parserPreset.path));
|
|
53
52
|
return inputs;
|
|
54
53
|
};
|
|
55
54
|
const plugin = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toDeferResolve, toEntry } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolve, toDeferResolveEntry, toEntry } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
3
|
import { resolveDependencies } from './helpers.js';
|
|
4
4
|
const title = 'Cypress';
|
|
@@ -20,7 +20,9 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
20
20
|
return [
|
|
21
21
|
...inputs.map(id => toDeferResolve(id)),
|
|
22
22
|
...(specPatterns.length > 0 ? specPatterns : TEST_FILE_PATTERNS).map(id => toEntry(id)),
|
|
23
|
-
...(supportFiles.length > 0
|
|
23
|
+
...(supportFiles.length > 0
|
|
24
|
+
? supportFiles.map(id => toDeferResolveEntry(id, { dir: options.cwd }))
|
|
25
|
+
: SUPPORT_FILE_PATTERNS.map(id => toEntry(id))),
|
|
24
26
|
];
|
|
25
27
|
};
|
|
26
28
|
const plugin = {
|
|
@@ -2,7 +2,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
2
2
|
const title = 'Danger';
|
|
3
3
|
const enablers = ['danger'];
|
|
4
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
-
const entry = ['dangerfile.{js,cjs,mjs,ts}'];
|
|
5
|
+
const entry = ['dangerfile.{js,cjs,mjs,ts,mts}', 'Dangerfile.{js,mjs,ts,mts}'];
|
|
6
6
|
const plugin = {
|
|
7
7
|
title,
|
|
8
8
|
enablers,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toDependency, toDeferResolveProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { isAbsolute, toAbsolute } from '../../util/path.js';
|
|
3
3
|
import { findWebpackDependenciesFromConfig } from '../webpack/index.js';
|
|
4
4
|
const isLocalPath = (name) => name.startsWith('.') || isAbsolute(name);
|
|
@@ -61,10 +61,10 @@ const resolveArrayConfig = ([name, config], type, cwd) => {
|
|
|
61
61
|
if (typeof name !== 'string')
|
|
62
62
|
return [];
|
|
63
63
|
const sidebarPath = type !== 'theme' ? resolveSidebarPath(config) : undefined;
|
|
64
|
-
const sidebar = sidebarPath ? [
|
|
64
|
+
const sidebar = sidebarPath ? [toDeferResolveProductionEntry(sidebarPath, { dir: cwd })] : [];
|
|
65
65
|
if (isLocalPath(name))
|
|
66
|
-
return [
|
|
67
|
-
return [
|
|
66
|
+
return [toDeferResolveProductionEntry(toAbsolute(name, cwd)), ...sidebar];
|
|
67
|
+
return [toDependency(resolveModuleName(name, type)), ...sidebar];
|
|
68
68
|
};
|
|
69
69
|
export const resolveConfigItems = async (items, type, options) => {
|
|
70
70
|
const inputs = new Set();
|
|
@@ -75,9 +75,9 @@ export const resolveConfigItems = async (items, type, options) => {
|
|
|
75
75
|
continue;
|
|
76
76
|
if (typeof item === 'string') {
|
|
77
77
|
if (isLocalPath(item))
|
|
78
|
-
inputs.add(
|
|
78
|
+
inputs.add(toDeferResolveProductionEntry(toAbsolute(item, options.cwd)));
|
|
79
79
|
else
|
|
80
|
-
inputs.add(
|
|
80
|
+
inputs.add(toDependency(resolveModuleName(item, type)));
|
|
81
81
|
}
|
|
82
82
|
else if (Array.isArray(item)) {
|
|
83
83
|
for (const input of resolveArrayConfig(item, type, options.cwd))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toAlias, toConfig, toDependency, toIgnore, toProductionEntry } from '../../util/input.js';
|
|
1
|
+
import { toAlias, toConfig, toDeferResolveProductionEntry, toDependency, toIgnore, toProductionEntry, } from '../../util/input.js';
|
|
2
2
|
import { join } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { CORE_CLIENT_API, resolveConfigItems } from './helpers.js';
|
|
@@ -13,7 +13,7 @@ const resolveStaticAssets = (items, cwd) => {
|
|
|
13
13
|
for (const item of items ?? []) {
|
|
14
14
|
const value = typeof item === 'string' ? item : (item.src ?? item.href);
|
|
15
15
|
if (typeof value === 'string' && !value.includes('://'))
|
|
16
|
-
entries.push(
|
|
16
|
+
entries.push(toDeferResolveProductionEntry(join(cwd, 'static', value)));
|
|
17
17
|
}
|
|
18
18
|
return entries;
|
|
19
19
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toConfig, toDependency,
|
|
1
|
+
import { toConfig, toDependency, toDeferResolveProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { toAbsolute } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { findWebpackDependenciesFromConfig } from '../webpack/index.js';
|
|
@@ -25,7 +25,7 @@ const getPluginInputs = async (name, opts, options) => {
|
|
|
25
25
|
const inputs = [];
|
|
26
26
|
const addEntry = (value) => {
|
|
27
27
|
for (const id of toStrings(value))
|
|
28
|
-
inputs.push(
|
|
28
|
+
inputs.push(toDeferResolveProductionEntry(toAbsolute(id, cwd)));
|
|
29
29
|
};
|
|
30
30
|
const addConfig = async (pluginName, value) => {
|
|
31
31
|
if (typeof value === 'string') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toProductionEntry } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolveProductionEntry, toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { toAbsolute } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { getHtmlScriptEntries } from '../vite/helpers.js';
|
|
@@ -31,7 +31,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
31
31
|
const patterns = ids.length > 0 ? ids : [defaultEntry[name]];
|
|
32
32
|
for (const id of patterns) {
|
|
33
33
|
const resolved = toAbsolute(id, configFileDir);
|
|
34
|
-
inputs.push(toProductionEntry(resolved));
|
|
34
|
+
inputs.push(ids.length > 0 ? toDeferResolveProductionEntry(resolved) : toProductionEntry(resolved));
|
|
35
35
|
if (name === 'renderer' && resolved.endsWith('.html')) {
|
|
36
36
|
for (const input of await getHtmlScriptEntries(resolved))
|
|
37
37
|
inputs.push(input);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_EXTENSIONS } from '../../constants.js';
|
|
2
2
|
import { isDirectory } from '../../util/fs.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
4
|
+
import { getPackageNameFromFilePath } from '../../util/modules.js';
|
|
4
5
|
import { isInNodeModules, join } from '../../util/path.js';
|
|
5
6
|
import { hasDependency } from '../../util/plugin.js';
|
|
6
7
|
import { DummyEleventyConfig, defaultEleventyConfig } from './helpers.js';
|
|
@@ -34,7 +35,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
34
35
|
copiedPackages.add(path);
|
|
35
36
|
}
|
|
36
37
|
return Array.from(copiedPackages)
|
|
37
|
-
.map(id =>
|
|
38
|
+
.map(id => toDependency(getPackageNameFromFilePath(id)))
|
|
38
39
|
.concat([
|
|
39
40
|
join(inputDir, dataDir, '**/*.{js,cjs,mjs}'),
|
|
40
41
|
join(inputDir, `**/*.{${typeof templateFormats === 'string' ? templateFormats : templateFormats.join(',')}}`),
|
|
@@ -24,13 +24,14 @@ const getInputsDeprecated = (config, options) => {
|
|
|
24
24
|
const plugins = config.plugins ? config.plugins.map(resolvePluginSpecifier) : [];
|
|
25
25
|
const parsers = getParsers(config);
|
|
26
26
|
const babelDependencies = config.parserOptions?.babelOptions
|
|
27
|
-
? getDependenciesFromConfig(config.parserOptions.babelOptions)
|
|
27
|
+
? getDependenciesFromConfig(config.parserOptions.babelOptions, false)
|
|
28
28
|
: [];
|
|
29
29
|
const settings = config.settings ? getDependenciesFromSettings(config.settings) : [];
|
|
30
30
|
const rules = getDependenciesFromRules({});
|
|
31
31
|
const overrides = config.overrides ? [config.overrides].flat().flatMap(d => getInputsDeprecated(d, options)) : [];
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const dependencies = compact([...extendsSpecifiers, ...plugins, ...rules]).map(id => toDependency(id));
|
|
33
|
+
const resolvers = compact(settings).map(id => toDeferResolve(id));
|
|
34
|
+
return [...extendConfigs, ...dependencies, ...resolvers, ...parsers, ...babelDependencies, ...overrides];
|
|
34
35
|
};
|
|
35
36
|
const isParserObject = (value) => typeof value.parseForESLint === 'function' || typeof value.parse === 'function';
|
|
36
37
|
export const toParser = (name) => toDeferResolve(name, name === 'espree' ? { optional: true } : {});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Visitor } from 'oxc-parser';
|
|
2
|
-
import { toDeferResolve } from '../../util/input.js';
|
|
2
|
+
import { toDeferResolve, toDependency } from '../../util/input.js';
|
|
3
3
|
import { findProperty, getPropertyKey } from '../../typescript/ast-helpers.js';
|
|
4
4
|
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
5
5
|
import { isInternal } from '../../util/path.js';
|
|
@@ -74,5 +74,5 @@ const getInputsFromSettingsAST = (program) => {
|
|
|
74
74
|
};
|
|
75
75
|
export const getInputsFromFlatConfigAST = (program) => [
|
|
76
76
|
...getInputsFromSettingsAST(program),
|
|
77
|
-
|
|
77
|
+
toDependency('eslint-import-resolver-typescript', { optional: true }),
|
|
78
78
|
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { collectPropertyValues } from '../../typescript/ast-helpers.js';
|
|
2
|
+
import { toDeferResolve, toEntry } from '../../util/input.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
const title = 'Evalite';
|
|
5
|
+
const enablers = ['evalite'];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = ['evalite.config.{ts,mts,js,mjs}'];
|
|
8
|
+
const entry = ['**/*.eval.?(m)ts'];
|
|
9
|
+
const resolveFromAST = (program, options) => {
|
|
10
|
+
const inputs = [];
|
|
11
|
+
if (!options.config.entry)
|
|
12
|
+
for (const id of entry)
|
|
13
|
+
inputs.push(toEntry(id));
|
|
14
|
+
for (const id of collectPropertyValues(program, 'setupFiles'))
|
|
15
|
+
inputs.push(toDeferResolve(id));
|
|
16
|
+
return inputs;
|
|
17
|
+
};
|
|
18
|
+
const plugin = {
|
|
19
|
+
title,
|
|
20
|
+
enablers,
|
|
21
|
+
isEnabled,
|
|
22
|
+
config,
|
|
23
|
+
entry,
|
|
24
|
+
resolveFromAST,
|
|
25
|
+
};
|
|
26
|
+
export default plugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { collectFirstPropertyValue } from '../../typescript/ast-helpers.js';
|
|
2
2
|
import { isDirectory } from '../../util/fs.js';
|
|
3
|
-
import { toProductionEntry } from '../../util/input.js';
|
|
3
|
+
import { toDeferResolveProductionEntry, toProductionEntry } from '../../util/input.js';
|
|
4
4
|
import { join } from '../../util/path.js';
|
|
5
5
|
import { hasDependency } from '../../util/plugin.js';
|
|
6
6
|
const title = 'Flue';
|
|
@@ -23,7 +23,7 @@ const resolveFromAST = (program, { configFileDir }) => {
|
|
|
23
23
|
for (const name of entryNames) {
|
|
24
24
|
const filePath = collectFirstPropertyValue(program, name);
|
|
25
25
|
if (filePath)
|
|
26
|
-
inputs.push(
|
|
26
|
+
inputs.push(toDeferResolveProductionEntry(join(configFileDir, filePath)));
|
|
27
27
|
else
|
|
28
28
|
inputs.push(toProductionEntry(join(sourceRoot, `${name}.${extensions}`)));
|
|
29
29
|
}
|
|
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'Gatsby';
|
|
4
4
|
const enablers = ['gatsby', 'gatsby-cli'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['gatsby-{config,node}.{js,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,jsx,ts,tsx}'];
|
|
6
|
+
const config = ['gatsby-{config,node}.{js,mjs,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,mjs,jsx,ts,tsx}'];
|
|
7
7
|
const production = [
|
|
8
8
|
'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
|
|
9
9
|
'src/api/**/*.{js,ts}',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toDeferResolveEntry, toProject } from '../../util/input.js';
|
|
2
2
|
import { relative } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { getActionDependencies } from '../github-actions/index.js';
|
|
@@ -15,7 +15,7 @@ const resolveConfig = async (config, options) => {
|
|
|
15
15
|
if (isAssumeArtifact(relativePath))
|
|
16
16
|
inputs.push(toProject(`!${relativePath}`));
|
|
17
17
|
else
|
|
18
|
-
inputs.push(
|
|
18
|
+
inputs.push(toDeferResolveEntry(filePath));
|
|
19
19
|
}
|
|
20
20
|
return inputs;
|
|
21
21
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasFileWithExtension } from '../../util/fs.js';
|
|
2
|
-
import { isDeferResolveEntry,
|
|
2
|
+
import { isDeferResolveEntry, toDeferResolveEntry } from '../../util/input.js';
|
|
3
3
|
import { findByKeyDeep } from '../../util/object.js';
|
|
4
4
|
import { join, relative } from '../../util/path.js';
|
|
5
5
|
const title = 'GitHub Actions';
|
|
@@ -45,7 +45,7 @@ const resolveConfig = async (config, options) => {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
return [...inputs, ...getActionDependencies(config, options).map(id =>
|
|
48
|
+
return [...inputs, ...getActionDependencies(config, options).map(id => toDeferResolveEntry(id))];
|
|
49
49
|
};
|
|
50
50
|
const plugin = {
|
|
51
51
|
title,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toDeferResolve, toDeferResolveEntry, toDeferResolveProductionEntry, toDependency, toProductionEntry, } from '../../util/input.js';
|
|
2
2
|
import { get } from '../../util/object.js';
|
|
3
3
|
import { isInternal, join, normalize } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
@@ -24,16 +24,18 @@ const getPluginPackageName = (name) => {
|
|
|
24
24
|
return name;
|
|
25
25
|
return `@graphql-codegen/${name}`;
|
|
26
26
|
};
|
|
27
|
-
const
|
|
27
|
+
const getOutputInput = (output, outputConfig, dir) => {
|
|
28
28
|
if (isConfigurationOutput(outputConfig) && isNearOperationFilePreset(outputConfig.preset)) {
|
|
29
29
|
const presetConfig = outputConfig.presetConfig ?? {};
|
|
30
30
|
const { folder = '', extension = '.generated.ts', fileName = '*', filePerOperation = false } = presetConfig;
|
|
31
31
|
const subfolder = normalize(folder)
|
|
32
32
|
.split('/')
|
|
33
33
|
.filter(segment => segment !== '' && segment !== '.' && segment !== '..');
|
|
34
|
-
return join(output, '**', ...subfolder, `${filePerOperation ? '*' : fileName}${extension}`);
|
|
34
|
+
return toProductionEntry(join(dir, output, '**', ...subfolder, `${filePerOperation ? '*' : fileName}${extension}`));
|
|
35
35
|
}
|
|
36
|
-
return output.endsWith('/')
|
|
36
|
+
return output.endsWith('/')
|
|
37
|
+
? toProductionEntry(join(dir, `${output}**`))
|
|
38
|
+
: toDeferResolveProductionEntry(output, { dir });
|
|
37
39
|
};
|
|
38
40
|
const resolveConfig = (config, options) => {
|
|
39
41
|
const codegenConfigs = isGraphqlProjectsConfigTypes(config)
|
|
@@ -45,14 +47,16 @@ const resolveConfig = (config, options) => {
|
|
|
45
47
|
const generateSet = generateConfigs.flatMap(config => Object.values(config.generates));
|
|
46
48
|
const outputs = generateConfigs
|
|
47
49
|
.flatMap(config => Object.entries(config.generates))
|
|
48
|
-
.map(([output, outputConfig]) =>
|
|
50
|
+
.map(([output, outputConfig]) => getOutputInput(output, outputConfig, options.configFileDir));
|
|
49
51
|
const configurationOutput = generateSet.filter(isConfigurationOutput);
|
|
50
52
|
const presets = configurationOutput
|
|
51
53
|
.map(configOutput => (configOutput.preset ? configOutput.preset : undefined))
|
|
52
54
|
.filter((preset) => typeof preset === 'string')
|
|
53
|
-
.map(presetName => presetName
|
|
54
|
-
? presetName
|
|
55
|
-
:
|
|
55
|
+
.map(presetName => isInternal(presetName)
|
|
56
|
+
? toDeferResolve(presetName, { dir: options.cwd })
|
|
57
|
+
: presetName.startsWith('@graphql-codegen/')
|
|
58
|
+
? presetName
|
|
59
|
+
: `@graphql-codegen/${presetName}${presetName.endsWith('-preset') ? '' : '-preset'}`);
|
|
56
60
|
const flatPlugins = generateSet
|
|
57
61
|
.filter((config) => !isConfigurationOutput(config))
|
|
58
62
|
.flatMap(item => Object.keys(item))
|
|
@@ -68,7 +72,7 @@ const resolveConfig = (config, options) => {
|
|
|
68
72
|
if (typeof plugin !== 'string')
|
|
69
73
|
return [];
|
|
70
74
|
if (isInternal(plugin))
|
|
71
|
-
return [
|
|
75
|
+
return [toDeferResolveEntry(plugin, { dir: options.cwd })];
|
|
72
76
|
return [toDependency(getPluginPackageName(plugin))];
|
|
73
77
|
});
|
|
74
78
|
return [...presets, ...flatPlugins, ...nestedPlugins, ...outputs].map(id => typeof id === 'string' ? toDependency(id) : id);
|