knip 6.44.2 → 6.45.1
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/npm.js +7 -5
- package/dist/binaries/resolvers/npx.js +8 -40
- package/dist/binaries/util.d.ts +13 -1
- package/dist/binaries/util.js +35 -1
- package/dist/cli.js +10 -84
- 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 +2 -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 +19 -5
- 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/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/panda-css/index.js +5 -0
- 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 +2 -2
- 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/stryker/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/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 +14 -16
- 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/webdriver-io/index.js +22 -17
- package/dist/plugins/webdriver-io/types.d.ts +3 -2
- 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/index.d.ts +1 -0
- package/dist/session/index.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/ast-nodes.js +47 -1
- 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 +4 -2
- 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/get-included-issue-types.js +1 -0
- 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 +10 -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/regex.js +10 -1
- 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 +6 -7
- 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,25 +1,28 @@
|
|
|
1
|
-
import { toDeferResolve } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolve, toDependency } from '../../util/input.js';
|
|
2
2
|
import { isInternal } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
const title = 'mdxlint';
|
|
5
5
|
const enablers = ['mdxlint'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
7
|
const config = ['.mdxlintrc', '.mdxlintrc.{json,js,cjs,mjs,yml,yaml}', 'package.json'];
|
|
8
|
+
const isPrefixed = (name) => name.startsWith('remark-') || name.startsWith('mdxlint-');
|
|
9
|
+
const toPluginName = (plugin) => {
|
|
10
|
+
const slash = plugin.startsWith('@') ? plugin.indexOf('/') + 1 : 0;
|
|
11
|
+
const name = plugin.slice(slash);
|
|
12
|
+
return isPrefixed(name) ? plugin : `${plugin.slice(0, slash)}remark-${name}`;
|
|
13
|
+
};
|
|
8
14
|
const resolveConfig = config => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
? plugin
|
|
21
|
-
: `remark-${plugin}`) ?? [];
|
|
22
|
-
return plugins.map(id => toDeferResolve(id));
|
|
15
|
+
const inputs = [];
|
|
16
|
+
for (const plugin of config.plugins ?? []) {
|
|
17
|
+
const id = typeof plugin === 'string' ? plugin : Array.isArray(plugin) ? plugin[0] : undefined;
|
|
18
|
+
if (typeof id !== 'string')
|
|
19
|
+
continue;
|
|
20
|
+
if (isInternal(id))
|
|
21
|
+
inputs.push(toDeferResolve(id));
|
|
22
|
+
else
|
|
23
|
+
inputs.push(toDependency(toPluginName(id)));
|
|
24
|
+
}
|
|
25
|
+
return inputs;
|
|
23
26
|
};
|
|
24
27
|
const plugin = {
|
|
25
28
|
title,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { toConfig, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { join, toAbsolute } from '../../util/path.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
const title = 'MikroORM';
|
|
5
|
+
const enablers = [/^@mikro-orm\//];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = [
|
|
8
|
+
'src/mikro-orm.config.{ts,js}',
|
|
9
|
+
'mikro-orm.config.{ts,js}',
|
|
10
|
+
'dist/mikro-orm.config.js',
|
|
11
|
+
'build/mikro-orm.config.js',
|
|
12
|
+
'package.json',
|
|
13
|
+
];
|
|
14
|
+
const DEFAULT_MIGRATIONS_GLOB = '!(*.d).{js,ts,cjs}';
|
|
15
|
+
const DEFAULT_SEEDER_GLOB = '!(*.d).{js,ts}';
|
|
16
|
+
const ENTITY_EXTENSIONS = 'js,cjs,mjs,ts,cts,mts';
|
|
17
|
+
const toStrings = (value) => (Array.isArray(value) ? value : [value]).filter((item) => typeof item === 'string');
|
|
18
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
|
+
const isMikroOrmOptions = (value) => isRecord(value);
|
|
20
|
+
const isMikroOrmPackageJson = (value) => isRecord(value) &&
|
|
21
|
+
'configPaths' in value &&
|
|
22
|
+
(typeof value.configPaths === 'string' || Array.isArray(value.configPaths));
|
|
23
|
+
const isMikroOrmConfigFactory = (value) => typeof value === 'function';
|
|
24
|
+
const isMikroOrmConfigItem = (value) => isMikroOrmOptions(value) || isMikroOrmConfigFactory(value);
|
|
25
|
+
const entitySpecialRegex = /[*?{}[]/u;
|
|
26
|
+
const entityFileExtensionRegex = /\.(?:[cm]?[jt]s)$/u;
|
|
27
|
+
const toEntityEntry = (specifier, extensions, baseDir) => {
|
|
28
|
+
const hasPattern = entitySpecialRegex.test(specifier);
|
|
29
|
+
const hasExtension = entityFileExtensionRegex.test(specifier);
|
|
30
|
+
const pattern = hasPattern || hasExtension ? specifier : join(specifier, `**/*.{${extensions}}`);
|
|
31
|
+
return toProductionEntry(toAbsolute(pattern, baseDir));
|
|
32
|
+
};
|
|
33
|
+
const toFolderEntries = (paths, glob, baseDir) => paths.map(path => toProductionEntry(toAbsolute(join(path, glob), baseDir)));
|
|
34
|
+
const resolveConfig = async (config, options) => {
|
|
35
|
+
if (options.configFileName === 'package.json') {
|
|
36
|
+
if (!isMikroOrmPackageJson(config))
|
|
37
|
+
return [];
|
|
38
|
+
const configPaths = toStrings(config.configPaths);
|
|
39
|
+
return configPaths.map(path => toConfig('mikro-orm', path, { dir: options.cwd }));
|
|
40
|
+
}
|
|
41
|
+
const configItems = (Array.isArray(config) ? config : [config]).filter(isMikroOrmConfigItem);
|
|
42
|
+
const resolvedConfigs = await Promise.all(configItems.map(async (configItem) => isMikroOrmConfigFactory(configItem) ? await configItem('default') : configItem));
|
|
43
|
+
const configs = resolvedConfigs
|
|
44
|
+
.flatMap(config => (Array.isArray(config) ? config : [config]))
|
|
45
|
+
.filter(isMikroOrmOptions);
|
|
46
|
+
return configs.flatMap(config => {
|
|
47
|
+
const baseDir = typeof config.baseDir === 'string' ? toAbsolute(config.baseDir, options.cwd) : options.cwd;
|
|
48
|
+
const inputs = [];
|
|
49
|
+
const entities = [...toStrings(config.entities), ...toStrings(config.entitiesTs)];
|
|
50
|
+
inputs.push(...entities.map(path => toEntityEntry(path, ENTITY_EXTENSIONS, baseDir)));
|
|
51
|
+
if (config.migrations?.migrationsList === undefined) {
|
|
52
|
+
const migrationsTs = toStrings(config.migrations?.pathTs);
|
|
53
|
+
const migrations = migrationsTs.length > 0 ? migrationsTs : toStrings(config.migrations?.path);
|
|
54
|
+
const paths = migrations.length > 0 ? migrations : ['./migrations'];
|
|
55
|
+
inputs.push(...toFolderEntries(paths, config.migrations?.glob ?? DEFAULT_MIGRATIONS_GLOB, baseDir));
|
|
56
|
+
}
|
|
57
|
+
const seedersTs = toStrings(config.seeder?.pathTs);
|
|
58
|
+
const seeders = seedersTs.length > 0 ? seedersTs : toStrings(config.seeder?.path);
|
|
59
|
+
const seederPaths = seeders.length > 0 ? seeders : ['./seeders'];
|
|
60
|
+
inputs.push(...toFolderEntries(seederPaths, config.seeder?.glob ?? DEFAULT_SEEDER_GLOB, baseDir));
|
|
61
|
+
return inputs;
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const args = {
|
|
65
|
+
binaries: ['mikro-orm'],
|
|
66
|
+
config: true,
|
|
67
|
+
string: ['contextName'],
|
|
68
|
+
};
|
|
69
|
+
const plugin = {
|
|
70
|
+
title,
|
|
71
|
+
enablers,
|
|
72
|
+
isEnabled,
|
|
73
|
+
config,
|
|
74
|
+
args,
|
|
75
|
+
resolveConfig,
|
|
76
|
+
};
|
|
77
|
+
export default plugin;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type MikroOrmDirectoryConfig = {
|
|
2
|
+
path?: string;
|
|
3
|
+
pathTs?: string;
|
|
4
|
+
glob?: string;
|
|
5
|
+
};
|
|
6
|
+
export type MikroOrmOptions = {
|
|
7
|
+
baseDir?: string;
|
|
8
|
+
entities?: unknown;
|
|
9
|
+
entitiesTs?: unknown;
|
|
10
|
+
migrations?: MikroOrmDirectoryConfig & {
|
|
11
|
+
migrationsList?: unknown;
|
|
12
|
+
};
|
|
13
|
+
seeder?: MikroOrmDirectoryConfig;
|
|
14
|
+
};
|
|
15
|
+
export type MikroOrmPackageJson = {
|
|
16
|
+
configPaths?: string | string[];
|
|
17
|
+
};
|
|
18
|
+
export type MikroOrmConfigFactory = (contextName: string) => MikroOrmOptions | MikroOrmOptions[] | Promise<MikroOrmOptions | MikroOrmOptions[]>;
|
|
19
|
+
export type MikroOrmConfigItem = MikroOrmOptions | MikroOrmConfigFactory;
|
|
20
|
+
export type MikroOrmConfig = MikroOrmConfigItem | MikroOrmConfigItem[] | MikroOrmPackageJson;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,9 +7,12 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
7
7
|
const config = ['package.json'];
|
|
8
8
|
const entry = ['mockServiceWorker.js'];
|
|
9
9
|
const resolveConfig = async (localConfig) => {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
const dirs = localConfig?.workerDirectory ? [localConfig.workerDirectory].flat() : ['.'];
|
|
11
|
+
const inputs = [];
|
|
12
|
+
for (const dir of dirs)
|
|
13
|
+
for (const pattern of entry)
|
|
14
|
+
inputs.push(toEntry(join(dir, pattern)));
|
|
15
|
+
return inputs;
|
|
13
16
|
};
|
|
14
17
|
const plugin = {
|
|
15
18
|
title,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
2
|
-
import { join } from '../../util/path.js';
|
|
1
|
+
import { toDeferResolve, toDependency, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { isInternal, join } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { extractFunctionsConfigProperty } from './helpers.js';
|
|
5
5
|
const title = 'Netlify';
|
|
@@ -9,6 +9,10 @@ const config = ['netlify.toml'];
|
|
|
9
9
|
const NETLIFY_FUNCTIONS_DIR = 'netlify/functions';
|
|
10
10
|
const NETLIFY_FUNCTIONS_EXTS = 'js,mjs,cjs,ts,mts,cts';
|
|
11
11
|
const production = [`${NETLIFY_FUNCTIONS_DIR}/**/*.{${NETLIFY_FUNCTIONS_EXTS}}`];
|
|
12
|
+
const toPluginInput = (id) => {
|
|
13
|
+
const specifier = id.startsWith('/') ? `.${id}` : id;
|
|
14
|
+
return isInternal(specifier) ? toDeferResolve(specifier) : toDependency(id);
|
|
15
|
+
};
|
|
12
16
|
const resolveConfig = async (localConfig) => {
|
|
13
17
|
return [
|
|
14
18
|
...extractFunctionsConfigProperty(localConfig.functions || {}, 'included_files'),
|
|
@@ -17,7 +21,7 @@ const resolveConfig = async (localConfig) => {
|
|
|
17
21
|
.filter(file => !file.startsWith('!'))
|
|
18
22
|
.map(id => toProductionEntry(id))
|
|
19
23
|
.concat([
|
|
20
|
-
...(localConfig?.plugins?.map(plugin => plugin.package) ?? []).map(
|
|
24
|
+
...(localConfig?.plugins?.map(plugin => plugin.package) ?? []).map(toPluginInput),
|
|
21
25
|
...extractFunctionsConfigProperty(localConfig.functions || {}, 'external_node_modules').map(id => toDependency(id)),
|
|
22
26
|
]);
|
|
23
27
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Visitor } from 'oxc-parser';
|
|
2
|
-
import { findProperty, getPropertyValues } from '../../typescript/ast-helpers.js';
|
|
1
|
+
import { Visitor, } from 'oxc-parser';
|
|
2
|
+
import { findProperty, getPropertyValues, resolveObjectArg } from '../../typescript/ast-helpers.js';
|
|
3
3
|
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
4
4
|
import { isDirectory } from '../../util/fs.js';
|
|
5
|
-
import { toConfig, toDeferResolve, toProductionEntry } from '../../util/input.js';
|
|
6
|
-
import { isInNodeModules, join } from '../../util/path.js';
|
|
5
|
+
import { toConfig, toDeferResolve, toDeferResolveProductionEntry, toProductionEntry } from '../../util/input.js';
|
|
6
|
+
import { isInNodeModules, join, toAbsolute } from '../../util/path.js';
|
|
7
7
|
import { hasDependency } from '../../util/plugin.js';
|
|
8
8
|
const title = 'Next.js';
|
|
9
9
|
const enablers = ['next'];
|
|
@@ -39,14 +39,16 @@ const getEntryFilePatterns = (pageExtensions = defaultPageExtensions, cwd) => {
|
|
|
39
39
|
];
|
|
40
40
|
};
|
|
41
41
|
const production = getEntryFilePatterns();
|
|
42
|
-
const getInputs = (pageExtensions, loaders, aliasTargets, configFileDir) => {
|
|
42
|
+
const getInputs = (pageExtensions, loaders, aliasTargets, files, configFileDir) => {
|
|
43
43
|
const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
|
|
44
44
|
const patterns = [...getEntryFilePatterns(extensions, configFileDir), 'next-env.d.ts'];
|
|
45
45
|
const inputs = patterns.map(id => toProductionEntry(join(configFileDir, id)));
|
|
46
46
|
for (const loader of loaders)
|
|
47
47
|
inputs.push(toDeferResolve(loader));
|
|
48
48
|
for (const target of aliasTargets)
|
|
49
|
-
inputs.push(
|
|
49
|
+
inputs.push(toDeferResolve(target, { dir: configFileDir, production: true }));
|
|
50
|
+
for (const file of files)
|
|
51
|
+
inputs.push(toDeferResolveProductionEntry(toAbsolute(file, configFileDir)));
|
|
50
52
|
return inputs;
|
|
51
53
|
};
|
|
52
54
|
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
@@ -87,12 +89,63 @@ const resolveConfig = async (localConfig, { configFileDir }) => {
|
|
|
87
89
|
const aliasTargets = new Set();
|
|
88
90
|
for (const target of Object.values(config?.turbopack?.resolveAlias ?? {}))
|
|
89
91
|
collectAliasTargetValues(target, aliasTargets);
|
|
90
|
-
|
|
92
|
+
const files = new Set();
|
|
93
|
+
addSpecifier(files, config?.images?.loaderFile);
|
|
94
|
+
addSpecifier(files, config?.cacheHandler);
|
|
95
|
+
for (const handler of Object.values(config?.cacheHandlers ?? {}))
|
|
96
|
+
addSpecifier(files, handler);
|
|
97
|
+
return getInputs(pageExtensions, loaders, aliasTargets, files, configFileDir);
|
|
98
|
+
};
|
|
99
|
+
const isModuleExports = (node) => node.type === 'MemberExpression' &&
|
|
100
|
+
node.object.type === 'Identifier' &&
|
|
101
|
+
node.object.name === 'module' &&
|
|
102
|
+
node.property.type === 'Identifier' &&
|
|
103
|
+
node.property.name === 'exports';
|
|
104
|
+
const getConfigObject = (program) => {
|
|
105
|
+
const declarations = new Map();
|
|
106
|
+
let node;
|
|
107
|
+
for (const statement of program.body) {
|
|
108
|
+
if (statement.type === 'VariableDeclaration') {
|
|
109
|
+
for (const declaration of statement.declarations) {
|
|
110
|
+
if (declaration.id.type === 'Identifier' && declaration.init)
|
|
111
|
+
declarations.set(declaration.id.name, declaration.init);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (statement.type === 'ExportDefaultDeclaration') {
|
|
115
|
+
node = statement.declaration;
|
|
116
|
+
}
|
|
117
|
+
else if (statement.type === 'ExpressionStatement' &&
|
|
118
|
+
statement.expression.type === 'AssignmentExpression' &&
|
|
119
|
+
isModuleExports(statement.expression.left)) {
|
|
120
|
+
node = statement.expression.right;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
while (node) {
|
|
124
|
+
if (node.type === 'TSSatisfiesExpression' ||
|
|
125
|
+
node.type === 'TSAsExpression' ||
|
|
126
|
+
node.type === 'ParenthesizedExpression')
|
|
127
|
+
node = node.expression;
|
|
128
|
+
else if (node.type === 'CallExpression')
|
|
129
|
+
node = node.arguments[0];
|
|
130
|
+
else if (node.type === 'Identifier') {
|
|
131
|
+
const init = declarations.get(node.name);
|
|
132
|
+
declarations.delete(node.name);
|
|
133
|
+
node = init;
|
|
134
|
+
}
|
|
135
|
+
else
|
|
136
|
+
return resolveObjectArg(node);
|
|
137
|
+
}
|
|
91
138
|
};
|
|
92
139
|
const resolveFromAST = (program, { configFileDir }) => {
|
|
93
140
|
const pageExtensions = new Set();
|
|
94
141
|
const loaders = new Set();
|
|
95
142
|
const aliasTargets = new Set();
|
|
143
|
+
const files = new Set();
|
|
144
|
+
const config = getConfigObject(program);
|
|
145
|
+
addSpecifier(files, getStringValue(findProperty(findProperty(config, 'images'), 'loaderFile')));
|
|
146
|
+
addSpecifier(files, getStringValue(findProperty(config, 'cacheHandler')));
|
|
147
|
+
for (const handler of getPropertyValues(config, 'cacheHandlers'))
|
|
148
|
+
addSpecifier(files, handler);
|
|
96
149
|
const collectAliasTargets = (node) => {
|
|
97
150
|
const target = getStringValue(node);
|
|
98
151
|
if (target)
|
|
@@ -150,7 +203,7 @@ const resolveFromAST = (program, { configFileDir }) => {
|
|
|
150
203
|
},
|
|
151
204
|
});
|
|
152
205
|
visitor.visit(program);
|
|
153
|
-
return getInputs([...pageExtensions], loaders, aliasTargets, configFileDir);
|
|
206
|
+
return getInputs([...pageExtensions], loaders, aliasTargets, files, configFileDir);
|
|
154
207
|
};
|
|
155
208
|
const commands = new Set(['dev', 'build', 'start']);
|
|
156
209
|
const args = {
|
|
@@ -162,7 +215,8 @@ const args = {
|
|
|
162
215
|
return [toConfig('next', join(dir, 'next.config'))];
|
|
163
216
|
},
|
|
164
217
|
};
|
|
165
|
-
const note = `Knip loads \`next.config.*\` to read Turbopack loaders and alias targets
|
|
218
|
+
const note = `Knip loads \`next.config.*\` to read Turbopack loaders and alias targets, the custom image loader
|
|
219
|
+
(\`images.loaderFile\`) and cache handlers (\`cacheHandler\`, \`cacheHandlers\`) from the composed configuration,
|
|
166
220
|
including values a shared configuration factory adds. A configuration file that fails to load is analyzed statically.`;
|
|
167
221
|
export const docs = { note };
|
|
168
222
|
const plugin = {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
type NextConfig = {
|
|
2
2
|
pageExtensions?: string[];
|
|
3
|
+
images?: {
|
|
4
|
+
loaderFile?: string;
|
|
5
|
+
};
|
|
6
|
+
cacheHandler?: string;
|
|
7
|
+
cacheHandlers?: Record<string, string | undefined>;
|
|
3
8
|
turbopack?: {
|
|
4
9
|
rules?: Record<string, unknown>;
|
|
5
10
|
resolveAlias?: Record<string, unknown>;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { findImportedCalls, findProperty, getStringValues } from '../../typescript/ast-helpers.js';
|
|
2
|
+
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
2
3
|
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
4
|
+
import { isInternal } from '../../util/path.js';
|
|
5
|
+
import { toProviderInput } from '../mdx/index.js';
|
|
3
6
|
export const production = ['{src/,}mdx-components.{js,jsx,ts,tsx}'];
|
|
4
|
-
const
|
|
7
|
+
export const resolveFromAST = (program, options) => {
|
|
8
|
+
const inputs = production.map(id => toProductionEntry(id));
|
|
5
9
|
const plugins = new Set();
|
|
6
10
|
for (const call of findImportedCalls(program, '@next/mdx')) {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
11
|
+
const mdxOptions = findProperty(call.arguments?.[0], 'options');
|
|
12
|
+
if (mdxOptions?.type !== 'ObjectExpression')
|
|
9
13
|
continue;
|
|
10
14
|
for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
|
|
11
|
-
for (const
|
|
12
|
-
plugins.add(
|
|
15
|
+
for (const id of getStringValues(findProperty(mdxOptions, pluginType)))
|
|
16
|
+
plugins.add(id);
|
|
13
17
|
}
|
|
18
|
+
const provider = getStringValue(findProperty(mdxOptions, 'providerImportSource'));
|
|
19
|
+
if (provider && !isInternal(provider))
|
|
20
|
+
inputs.push(toProviderInput(provider, options.configFileDir));
|
|
14
21
|
}
|
|
15
|
-
|
|
22
|
+
for (const id of plugins)
|
|
23
|
+
inputs.push(toDependency(id));
|
|
24
|
+
return inputs;
|
|
16
25
|
};
|
|
17
|
-
export const resolveFromAST = program => [
|
|
18
|
-
...production.map(id => toProductionEntry(id)),
|
|
19
|
-
...Array.from(getMdxPlugins(program)).map(id => toDependency(id)),
|
|
20
|
-
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toDependency, toIgnore, toProductionEntry } from '../../util/input.js';
|
|
2
|
-
import { join } from '../../util/path.js';
|
|
1
|
+
import { toDeferResolve, toDependency, toIgnore, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { isInternal, join } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
const title = 'Nitro';
|
|
5
5
|
const enablers = ['nitropack', 'nitro'];
|
|
@@ -35,11 +35,10 @@ const resolveConfig = async (localConfig) => {
|
|
|
35
35
|
'plugins/**/*.ts',
|
|
36
36
|
].map(pattern => toProductionEntry(join(srcDir, pattern))),
|
|
37
37
|
];
|
|
38
|
-
const deps = localConfig.modules?.reduce((acc,
|
|
39
|
-
|
|
40
|
-
acc.push(toDependency(id[0]));
|
|
38
|
+
const deps = localConfig.modules?.reduce((acc, mod) => {
|
|
39
|
+
const id = Array.isArray(mod) ? mod[0] : mod;
|
|
41
40
|
if (typeof id === 'string')
|
|
42
|
-
acc.push(toDependency(id));
|
|
41
|
+
acc.push(isInternal(id) ? toDeferResolve(id) : toDependency(id));
|
|
43
42
|
return acc;
|
|
44
43
|
}, []) ?? [];
|
|
45
44
|
return [...deps, ...patterns];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { toEntry, toProductionEntry } from '../../util/input.js';
|
|
2
|
-
import { getScriptCommands } from '../../util/scripts.js';
|
|
3
2
|
import { createFsPromisesGlobVisitor } from './visitors/fsPromisesGlob.js';
|
|
4
3
|
const title = 'Node.js';
|
|
5
4
|
const isEnabled = () => true;
|
|
@@ -10,14 +9,14 @@ const patterns = [
|
|
|
10
9
|
'**/test/**/*.{cjs,mjs,js,cts,mts,ts}',
|
|
11
10
|
];
|
|
12
11
|
const hasNodeTestCache = new WeakMap();
|
|
13
|
-
const hasNodeTest = (scripts) => {
|
|
12
|
+
const hasNodeTest = (scripts, cwd, getScriptCommands) => {
|
|
14
13
|
if (!scripts)
|
|
15
14
|
return false;
|
|
16
15
|
const cached = hasNodeTestCache.get(scripts);
|
|
17
16
|
if (cached !== undefined)
|
|
18
17
|
return cached;
|
|
19
18
|
const result = Object.values(scripts).some(script => typeof script === 'string' &&
|
|
20
|
-
getScriptCommands(script).some(({ binary, args }) => (binary === 'node' || binary === 'nub') && args.includes('--test')));
|
|
19
|
+
getScriptCommands(script, cwd).some(({ binary, args }) => (binary === 'node' || binary === 'nub') && args.includes('--test')));
|
|
21
20
|
hasNodeTestCache.set(scripts, result);
|
|
22
21
|
return result;
|
|
23
22
|
};
|
|
@@ -27,7 +26,8 @@ const registerVisitors = ({ ctx, registerVisitor }) => {
|
|
|
27
26
|
};
|
|
28
27
|
const resolve = options => {
|
|
29
28
|
const entries = entry.map(id => toProductionEntry(id));
|
|
30
|
-
if (hasNodeTest(options.manifest.scripts
|
|
29
|
+
if (hasNodeTest(options.manifest.scripts, options.cwd, options.getScriptCommands) ||
|
|
30
|
+
hasNodeTest(options.rootManifest?.scripts, options.rootCwd, options.getScriptCommands)) {
|
|
31
31
|
entries.push(...patterns.map(toEntry));
|
|
32
32
|
}
|
|
33
33
|
return entries;
|
|
@@ -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
|
import { toCosmiconfig } from '../../util/plugin-config.js';
|
|
4
5
|
const title = 'npm-package-json-lint';
|
|
@@ -6,8 +7,14 @@ const enablers = ['npm-package-json-lint'];
|
|
|
6
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
8
|
const packageJsonPath = 'npmpackagejsonlint';
|
|
8
9
|
const config = ['package.json', ...toCosmiconfig('npmpackagejsonlint')];
|
|
9
|
-
const resolveConfig = localConfig => {
|
|
10
|
-
|
|
10
|
+
const resolveConfig = (localConfig, options) => {
|
|
11
|
+
if (!localConfig?.extends)
|
|
12
|
+
return [];
|
|
13
|
+
return [localConfig.extends].flat().map(id => {
|
|
14
|
+
if (!isInternal(id))
|
|
15
|
+
return toDependency(id);
|
|
16
|
+
return id.startsWith('./') ? toDeferResolve(id, { dir: options.cwd }) : toDeferResolve(id);
|
|
17
|
+
});
|
|
11
18
|
};
|
|
12
19
|
const plugin = {
|
|
13
20
|
title,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isDirectory } from '../../util/fs.js';
|
|
2
2
|
import { _syncGlob } from '../../util/glob.js';
|
|
3
|
-
import { toAlias, toConfig, toDeferResolveProductionEntry, toDependency, toEntry, toIgnore, toProductionDependency, toProductionEntry, } from '../../util/input.js';
|
|
3
|
+
import { toAlias, toConfig, toDeferResolve, toDeferResolveProductionEntry, toDependency, toEntry, toIgnore, toProductionDependency, toProductionEntry, } from '../../util/input.js';
|
|
4
4
|
import { loadTSConfig } from '../../util/load-tsconfig.js';
|
|
5
5
|
import { isInternal, join, toAbsolute } from '../../util/path.js';
|
|
6
6
|
import { hasDependency } from '../../util/plugin.js';
|
|
@@ -9,20 +9,21 @@ const title = 'Nuxt';
|
|
|
9
9
|
const enablers = ['nuxt', 'nuxt-nightly'];
|
|
10
10
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
11
11
|
const config = ['nuxt.config.{js,cjs,mjs,ts,cts,mts}'];
|
|
12
|
-
const
|
|
12
|
+
const scriptExt = '{js,mjs,cjs,jsx,ts,mts,cts,tsx}';
|
|
13
|
+
const entry = [`app.config.${scriptExt}`, '**/*.d.vue.ts'];
|
|
13
14
|
const app = ['app.{vue,jsx,tsx}', 'error.{vue,jsx,tsx}', 'router.options.ts'];
|
|
14
15
|
const layout = (dir = 'layouts') => join(dir, '**/*.{vue,jsx,tsx}');
|
|
15
|
-
const middleware = (dir = 'middleware') => join(dir,
|
|
16
|
+
const middleware = (dir = 'middleware') => [join(dir, `*.${scriptExt}`), join(dir, `*/index.${scriptExt}`)];
|
|
16
17
|
const pages = (dir = 'pages') => join(dir, '**/*.{vue,jsx,tsx}');
|
|
17
|
-
const plugins = (dir = 'plugins') => join(dir,
|
|
18
|
+
const plugins = (dir = 'plugins') => [join(dir, `*.${scriptExt}`), join(dir, `*/index.${scriptExt}`)];
|
|
18
19
|
const modules = 'modules/**/*.{ts,vue}';
|
|
19
20
|
const server = ['api/**/*.ts', 'middleware/**/*.ts', 'plugins/**/*.ts', 'routes/**/*.ts', 'tasks/**/*.ts'];
|
|
20
21
|
const production = [
|
|
21
22
|
...app,
|
|
22
23
|
layout(),
|
|
23
|
-
middleware(),
|
|
24
|
+
...middleware(),
|
|
24
25
|
pages(),
|
|
25
|
-
plugins(),
|
|
26
|
+
...plugins(),
|
|
26
27
|
modules,
|
|
27
28
|
...server.map(id => join('server', id)),
|
|
28
29
|
];
|
|
@@ -75,9 +76,11 @@ const addAppEntries = (inputs, srcDir, serverDir, config, dir) => {
|
|
|
75
76
|
for (const id of app)
|
|
76
77
|
inputs.push(toProductionEntry(join(srcDir, id)));
|
|
77
78
|
inputs.push(toProductionEntry(join(srcDir, layout(config.dir?.layouts))));
|
|
78
|
-
|
|
79
|
+
for (const id of middleware(config.dir?.middleware))
|
|
80
|
+
inputs.push(toProductionEntry(join(srcDir, id)));
|
|
79
81
|
inputs.push(toProductionEntry(join(srcDir, pages(config.dir?.pages))));
|
|
80
|
-
|
|
82
|
+
for (const id of plugins(config.dir?.plugins))
|
|
83
|
+
inputs.push(toProductionEntry(join(srcDir, id)));
|
|
81
84
|
inputs.push(toProductionEntry(join(srcDir, 'components/global/**/*.{vue,jsx,tsx}')));
|
|
82
85
|
for (const id of server)
|
|
83
86
|
inputs.push(toProductionEntry(join(dir, serverDir, id)));
|
|
@@ -120,6 +123,11 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
120
123
|
if (typeof id === 'string')
|
|
121
124
|
addModule(id);
|
|
122
125
|
}
|
|
126
|
+
for (const id of localConfig.plugins ?? []) {
|
|
127
|
+
const src = typeof id === 'string' ? id : id?.src;
|
|
128
|
+
if (typeof src === 'string')
|
|
129
|
+
inputs.push(toDeferResolve(resolveAlias(src, srcDir, cwd), { dir: cwd, production: true }));
|
|
130
|
+
}
|
|
123
131
|
addAppEntries(inputs, srcDir, serverDir, localConfig, cwd);
|
|
124
132
|
const sharedDir = toAbsolute(localConfig.dir?.shared ?? 'shared', cwd);
|
|
125
133
|
inputs.push(toAlias('#shared', sharedDir));
|
|
@@ -144,7 +152,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
144
152
|
for (const cfg of configs)
|
|
145
153
|
inputs.push(toConfig('nuxt', cfg));
|
|
146
154
|
else
|
|
147
|
-
inputs.push(toDependency(source));
|
|
155
|
+
inputs.push(isInternal(target) ? toDependency(source) : toProductionDependency(source));
|
|
148
156
|
}
|
|
149
157
|
for (const layerConfig of findLayerConfigs(cwd)) {
|
|
150
158
|
inputs.push(toConfig('nuxt', layerConfig));
|
|
@@ -154,7 +162,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
154
162
|
for (const file of _syncGlob({ cwd, patterns: ['.nuxt/module/*.d.ts'] })) {
|
|
155
163
|
const result = readAndParseFile(file);
|
|
156
164
|
for (const p of collectLocalImportPaths(file, result))
|
|
157
|
-
inputs.push(
|
|
165
|
+
inputs.push(toDeferResolveProductionEntry(p));
|
|
158
166
|
}
|
|
159
167
|
const dir = join(cwd, '.nuxt');
|
|
160
168
|
const tsConfig = await loadTSConfig(join(dir, 'tsconfig.json'));
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
2
|
import { isFile, loadJSON } from '../../util/fs.js';
|
|
3
|
-
import { toConfig, toDeferResolveEntry, toDependency } from '../../util/input.js';
|
|
3
|
+
import { toConfig, toDeferResolve, toDeferResolveEntry, toDependency } from '../../util/input.js';
|
|
4
4
|
import { get } from '../../util/object.js';
|
|
5
|
-
import { dirname, join, relative, toAbsolute } from '../../util/path.js';
|
|
5
|
+
import { dirname, isInternal, join, relative, toAbsolute } from '../../util/path.js';
|
|
6
6
|
import { hasDependency } from '../../util/plugin.js';
|
|
7
7
|
import { substringBefore } from '../../util/string.js';
|
|
8
8
|
const title = 'Nx';
|
|
@@ -25,7 +25,10 @@ const findNxDependenciesInNxJson = async (localConfig) => {
|
|
|
25
25
|
.filter(value => value !== undefined)
|
|
26
26
|
.map(value => substringBefore(value, ':'))
|
|
27
27
|
: [];
|
|
28
|
-
return
|
|
28
|
+
return [
|
|
29
|
+
...compact([...targetsDefault, ...generators]).map(id => toDependency(id)),
|
|
30
|
+
...compact(plugins).map(id => (isInternal(id) ? toDeferResolve(id) : toDependency(id))),
|
|
31
|
+
];
|
|
29
32
|
};
|
|
30
33
|
const resolveConfig = async (localConfig, options) => {
|
|
31
34
|
const { configFileName } = options;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { collectPropertyValues } from '../../typescript/ast-helpers.js';
|
|
2
2
|
import { _parseFile } from '../../typescript/ast-nodes.js';
|
|
3
|
-
import { toProductionEntry } from '../../util/input.js';
|
|
3
|
+
import { toDeferResolveProductionEntry, toProductionEntry } from '../../util/input.js';
|
|
4
4
|
const title = 'OpenClaw';
|
|
5
5
|
const enablers = 'This plugin is enabled when `package.json#openclaw` is present.';
|
|
6
6
|
const isEnabled = ({ manifest }) => Object.hasOwn(manifest, 'openclaw');
|
|
7
7
|
const config = ['package.json', 'openclaw.plugin.json'];
|
|
8
8
|
const isLoadConfig = ({ configFileName }) => configFileName === 'package.json';
|
|
9
|
-
const toEntries = (value) => (Array.isArray(value) ? value : [value]).flatMap(entry => typeof entry === 'string' ? [
|
|
9
|
+
const toEntries = (value, dir) => (Array.isArray(value) ? value : [value]).flatMap(entry => typeof entry === 'string' ? [toDeferResolveProductionEntry(entry, { dir })] : []);
|
|
10
10
|
const toHookEntries = (value) => (Array.isArray(value) ? value : [value]).flatMap(entry => {
|
|
11
11
|
if (typeof entry !== 'string')
|
|
12
12
|
return [];
|
|
@@ -21,15 +21,15 @@ const resolveConfig = (localConfig, options) => {
|
|
|
21
21
|
.getInputsFromScripts(assetScripts)
|
|
22
22
|
.map(input => input.type === 'entry' || input.type === 'deferResolveEntry' ? { ...input, production: true } : input);
|
|
23
23
|
return [
|
|
24
|
-
...toEntries(localConfig.extensions),
|
|
25
|
-
...toEntries(localConfig.runtimeExtensions),
|
|
26
|
-
...toEntries(localConfig.setupEntry),
|
|
27
|
-
...toEntries(localConfig.runtimeSetupEntry),
|
|
28
|
-
...toEntries(localConfig.providerCatalogEntry),
|
|
29
|
-
...toEntries(localConfig.channel?.configuredState?.specifier),
|
|
30
|
-
...toEntries(localConfig.channel?.persistedAuthState?.specifier),
|
|
24
|
+
...toEntries(localConfig.extensions, options.cwd),
|
|
25
|
+
...toEntries(localConfig.runtimeExtensions, options.cwd),
|
|
26
|
+
...toEntries(localConfig.setupEntry, options.cwd),
|
|
27
|
+
...toEntries(localConfig.runtimeSetupEntry, options.cwd),
|
|
28
|
+
...toEntries(localConfig.providerCatalogEntry, options.cwd),
|
|
29
|
+
...toEntries(localConfig.channel?.configuredState?.specifier, options.cwd),
|
|
30
|
+
...toEntries(localConfig.channel?.persistedAuthState?.specifier, options.cwd),
|
|
31
31
|
...toHookEntries(localConfig.hooks),
|
|
32
|
-
...
|
|
32
|
+
...(localConfig.build?.staticAssets ?? []).flatMap(asset => typeof asset.source === 'string' ? [toProductionEntry(asset.source)] : []),
|
|
33
33
|
...assetScriptInputs,
|
|
34
34
|
];
|
|
35
35
|
};
|
|
@@ -38,7 +38,7 @@ const resolveFromAST = (_, options) => {
|
|
|
38
38
|
return [];
|
|
39
39
|
const sourceText = options.readFile(options.configFilePath).replace(/^\uFEFF/, '');
|
|
40
40
|
const { program } = _parseFile(`${options.configFilePath}.ts`, `(${sourceText}\n)`);
|
|
41
|
-
return Array.from(collectPropertyValues(program, 'providerCatalogEntry'), entry =>
|
|
41
|
+
return Array.from(collectPropertyValues(program, 'providerCatalogEntry'), entry => toDeferResolveProductionEntry(entry, { dir: options.cwd }));
|
|
42
42
|
};
|
|
43
43
|
const plugin = {
|
|
44
44
|
title,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toConfig, toDependency,
|
|
1
|
+
import { toConfig, toDependency, toDeferResolveEntry } from '../../util/input.js';
|
|
2
2
|
import { dirname, isInternal, toAbsolute } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { getInputsFromSettings } from '../eslint/helpers.js';
|
|
@@ -17,7 +17,7 @@ const resolveJsPlugins = (jsPlugins, configFilePath) => {
|
|
|
17
17
|
if (!isInternal(specifier))
|
|
18
18
|
inputs.push(toDependency(specifier));
|
|
19
19
|
else
|
|
20
|
-
inputs.push(
|
|
20
|
+
inputs.push(toDeferResolveEntry(toAbsolute(specifier, dir)));
|
|
21
21
|
}
|
|
22
22
|
return inputs;
|
|
23
23
|
};
|