knip 6.46.1 → 6.48.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.
Files changed (101) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -0
  2. package/dist/IssueFixer.js +2 -6
  3. package/dist/WorkspaceWorker.d.ts +1 -0
  4. package/dist/WorkspaceWorker.js +10 -6
  5. package/dist/binaries/create-script-parser-context.js +2 -1
  6. package/dist/binaries/fallback.js +2 -3
  7. package/dist/binaries/plugins.js +1 -5
  8. package/dist/binaries/resolvers/npx.js +6 -8
  9. package/dist/binaries/resolvers/pnpx.js +3 -7
  10. package/dist/binaries/util.d.ts +4 -0
  11. package/dist/binaries/util.js +12 -2
  12. package/dist/compilers/mdx.js +7 -1
  13. package/dist/plugins/angular/helpers.d.ts +7 -0
  14. package/dist/plugins/angular/helpers.js +58 -0
  15. package/dist/plugins/angular/index.js +5 -50
  16. package/dist/plugins/angular/types.d.ts +2 -2
  17. package/dist/plugins/astro/index.js +6 -1
  18. package/dist/plugins/cucumber/index.js +19 -7
  19. package/dist/plugins/cucumber/types.d.ts +1 -0
  20. package/dist/plugins/cypress/index.js +5 -0
  21. package/dist/plugins/docusaurus/helpers.js +19 -5
  22. package/dist/plugins/drizzle/index.js +5 -0
  23. package/dist/plugins/ember/index.js +4 -8
  24. package/dist/plugins/env/index.d.ts +3 -0
  25. package/dist/plugins/env/index.js +27 -0
  26. package/dist/plugins/esbuild/index.js +5 -0
  27. package/dist/plugins/firebase/index.d.ts +3 -0
  28. package/dist/plugins/firebase/index.js +12 -0
  29. package/dist/plugins/github-action/index.js +13 -3
  30. package/dist/plugins/github-actions/index.d.ts +2 -1
  31. package/dist/plugins/github-actions/index.js +4 -2
  32. package/dist/plugins/github-actions/types.d.ts +5 -0
  33. package/dist/plugins/graphql-codegen/index.js +2 -0
  34. package/dist/plugins/index.d.ts +6 -0
  35. package/dist/plugins/index.js +12 -0
  36. package/dist/plugins/mocha/index.js +6 -0
  37. package/dist/plugins/mocha/types.d.ts +3 -0
  38. package/dist/plugins/netlify/index.js +12 -2
  39. package/dist/plugins/netlify/types.d.ts +3 -0
  40. package/dist/plugins/node/index.d.ts +2 -2
  41. package/dist/plugins/node/index.js +14 -3
  42. package/dist/plugins/nodemon/index.js +19 -0
  43. package/dist/plugins/nx/index.js +14 -1
  44. package/dist/plugins/plop/index.js +4 -0
  45. package/dist/plugins/prisma/index.js +2 -0
  46. package/dist/plugins/remark/helpers.js +1 -8
  47. package/dist/plugins/rollup/index.js +1 -1
  48. package/dist/plugins/serverless-framework/index.js +14 -5
  49. package/dist/plugins/serverless-framework/types.d.ts +4 -1
  50. package/dist/plugins/sst/index.js +13 -0
  51. package/dist/plugins/sst/resolveFromAST.js +35 -16
  52. package/dist/plugins/start-server-and-test/index.d.ts +3 -0
  53. package/dist/plugins/start-server-and-test/index.js +10 -0
  54. package/dist/plugins/storybook/index.js +3 -3
  55. package/dist/plugins/storybook/types.d.ts +5 -3
  56. package/dist/plugins/textlint/helpers.js +1 -5
  57. package/dist/plugins/trigger-dev/index.d.ts +3 -0
  58. package/dist/plugins/trigger-dev/index.js +28 -0
  59. package/dist/plugins/ts-node/index.d.ts +6 -0
  60. package/dist/plugins/ts-node/index.js +19 -0
  61. package/dist/plugins/ts-node-dev/index.d.ts +3 -0
  62. package/dist/plugins/ts-node-dev/index.js +46 -0
  63. package/dist/plugins/tsup/index.js +2 -0
  64. package/dist/plugins/tsx/index.js +1 -1
  65. package/dist/plugins/typedoc/index.js +5 -2
  66. package/dist/plugins/typescript/index.d.ts +12 -1
  67. package/dist/plugins/typescript/index.js +12 -4
  68. package/dist/plugins/vite/helpers.js +1 -4
  69. package/dist/plugins/vite-node/index.d.ts +3 -0
  70. package/dist/plugins/vite-node/index.js +11 -0
  71. package/dist/plugins/vite-plus/index.d.ts +4 -1
  72. package/dist/plugins/vite-plus/index.js +19 -4
  73. package/dist/plugins/vite-plus/types.d.ts +12 -0
  74. package/dist/plugins/vite-plus/types.js +1 -0
  75. package/dist/plugins/vitepress/index.js +14 -0
  76. package/dist/plugins/vitest/index.js +5 -0
  77. package/dist/plugins/vitest/types.d.ts +2 -1
  78. package/dist/plugins/web-test-runner/index.js +8 -2
  79. package/dist/plugins/webdriver-io/index.js +6 -2
  80. package/dist/plugins/wrangler/index.js +4 -0
  81. package/dist/session/index.d.ts +1 -0
  82. package/dist/session/index.js +1 -0
  83. package/dist/types/PluginNames.d.ts +2 -2
  84. package/dist/types/PluginNames.js +6 -0
  85. package/dist/types/tsconfig-json.d.ts +5 -0
  86. package/dist/typescript/ast-helpers.d.ts +3 -1
  87. package/dist/typescript/ast-helpers.js +14 -4
  88. package/dist/typescript/visitors/exports.js +11 -8
  89. package/dist/typescript/visitors/imports.js +10 -8
  90. package/dist/typescript/visitors/members.js +10 -8
  91. package/dist/util/create-input-handler.js +5 -3
  92. package/dist/util/package-json.d.ts +1 -0
  93. package/dist/util/package-json.js +21 -9
  94. package/dist/util/remove-export.d.ts +1 -0
  95. package/dist/util/remove-export.js +2 -0
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +1 -1
  98. package/package.json +1 -1
  99. package/schema.json +24 -0
  100. package/dist/plugins/vite-plus/resolveFromAST.d.ts +0 -2
  101. package/dist/plugins/vite-plus/resolveFromAST.js +0 -37
@@ -78,17 +78,13 @@ const resolve = async ({ cwd, manifest }) => {
78
78
  inputs.push(toAlias(`${manifest.name}/tests/*`, './tests/*', { dir: cwd }), toAlias(`${manifest.name}/*`, './app/*', { dir: cwd }));
79
79
  }
80
80
  }
81
- const isDeclared = (name) => Boolean(manifest.dependencies?.[name] ||
82
- manifest.devDependencies?.[name] ||
83
- manifest.peerDependencies?.[name] ||
84
- manifest.optionalDependencies?.[name]);
85
81
  const checked = new Set();
86
82
  const provided = new Set();
87
83
  for (const dependencies of [manifest.dependencies, manifest.devDependencies, manifest.peerDependencies]) {
88
84
  for (const name in dependencies) {
89
85
  if (name === 'ember-auto-import')
90
86
  inputs.push(toDependency('webpack', { production: true, optional: true }));
91
- if (name === 'ember-fetch' && !isDeclared('fetch'))
87
+ if (name === 'ember-fetch' && !manifest.allDependencies.has('fetch'))
92
88
  provided.add('fetch');
93
89
  const path = resolvePackageManifestPath(name, cwd);
94
90
  if (!path)
@@ -102,7 +98,7 @@ const resolve = async ({ cwd, manifest }) => {
102
98
  }
103
99
  const dir = dirname(path);
104
100
  for (const dependency in pkg.dependencies) {
105
- if (checked.has(dependency) || isDeclared(dependency))
101
+ if (checked.has(dependency) || manifest.allDependencies.has(dependency))
106
102
  continue;
107
103
  checked.add(dependency);
108
104
  const nestedPath = resolvePackageManifestPath(dependency, dir);
@@ -115,13 +111,13 @@ const resolve = async ({ cwd, manifest }) => {
115
111
  ...getModuleNames(join(dir, 'dist/packages')),
116
112
  ...getModuleNames(join(dir, 'dist/dependencies')),
117
113
  ]) {
118
- if (!isDeclared(module))
114
+ if (!manifest.allDependencies.has(module))
119
115
  provided.add(module);
120
116
  }
121
117
  }
122
118
  for (const specifier in renamedModules) {
123
119
  const packageName = getPackageNameFromSpecifier(specifier);
124
- if (packageName && !isDeclared(packageName))
120
+ if (packageName && !manifest.allDependencies.has(packageName))
125
121
  provided.add(packageName);
126
122
  }
127
123
  }
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,27 @@
1
+ import { isEnvAssignment, spawningArgs, toShellAssignment } from '../../binaries/util.js';
2
+ const title = 'env';
3
+ const isAssignmentOrSubstitution = (arg) => isEnvAssignment.test(arg) || arg.startsWith('$(');
4
+ const options = {
5
+ boolean: ['debug', 'ignore-environment'],
6
+ string: ['chdir'],
7
+ alias: { chdir: ['C'], debug: ['v'], 'ignore-environment': ['i'] },
8
+ };
9
+ const args = {
10
+ ...options,
11
+ stopEarly: true,
12
+ fromArgs: (parsed, args) => {
13
+ const command = spawningArgs(parsed, args);
14
+ if (parsed.chdir)
15
+ return [];
16
+ const index = command.findIndex(arg => !isAssignmentOrSubstitution(arg));
17
+ if (index === -1)
18
+ return [];
19
+ const assignments = command.slice(0, index).filter(arg => !arg.startsWith('$('));
20
+ return [...assignments.map(toShellAssignment), ...command.slice(index)];
21
+ },
22
+ };
23
+ const plugin = {
24
+ title,
25
+ args,
26
+ };
27
+ export default plugin;
@@ -7,11 +7,16 @@ const enablers = ['esbuild'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['esbuild.config.{js,mjs,cjs,ts,mts,cts}', 'esbuild.{js,mjs,cjs,ts,mts,cts}'];
9
9
  const resolveFromAST = (program, { configFileDir }) => Array.from(collectPropertyValues(program, 'entryPoints'), id => toEntry(join(configFileDir, id), { production: true }));
10
+ const args = {
11
+ boolean: true,
12
+ resolveInputs: parsed => parsed._.map(id => toEntry(id, { production: true })),
13
+ };
10
14
  const plugin = {
11
15
  title,
12
16
  enablers,
13
17
  isEnabled,
14
18
  config,
15
19
  resolveFromAST,
20
+ args,
16
21
  };
17
22
  export default plugin;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,12 @@
1
+ const title = 'Firebase';
2
+ const args = {
3
+ binaries: ['firebase', 'firebase-tools'],
4
+ boolean: ['debug', 'interactive', 'json', 'non-interactive', 'ui'],
5
+ alias: { interactive: ['i'], json: ['j'] },
6
+ fromArgs: parsed => (parsed._[0] === 'emulators:exec' && parsed._[1] ? parsed._[1] : []),
7
+ };
8
+ const plugin = {
9
+ title,
10
+ args,
11
+ };
12
+ export default plugin;
@@ -1,7 +1,7 @@
1
- import { toEntryPath, toProject } from '../../util/input.js';
2
- import { relative } from '../../util/path.js';
1
+ import { isDeferResolveEntry, toEntryPath, toProject } from '../../util/input.js';
2
+ import { join, relative } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
- import { getActionDependencies } from '../github-actions/index.js';
4
+ import { getActionDependencies, resolveConfig as resolveStepsConfig } from '../github-actions/index.js';
5
5
  const title = 'GitHub Action';
6
6
  const enablers = ['@actions/core'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -9,6 +9,16 @@ const config = ['action.{yml,yaml}'];
9
9
  const isAssumeArtifact = (specifier) => /^(dist|build)\//.test(specifier);
10
10
  const resolveConfig = async (config, options) => {
11
11
  const inputs = [];
12
+ if (config?.runs?.using === 'composite') {
13
+ for (const input of await resolveStepsConfig(config, options)) {
14
+ const relativePath = relative(options.cwd, join(input.dir ?? options.cwd, input.specifier));
15
+ if (isDeferResolveEntry(input) && isAssumeArtifact(relativePath))
16
+ inputs.push(toProject(`!${relativePath}`));
17
+ else
18
+ inputs.push(input);
19
+ }
20
+ return inputs;
21
+ }
12
22
  const filePaths = getActionDependencies(config, options);
13
23
  for (const filePath of new Set(filePaths)) {
14
24
  const relativePath = relative(options.cwd, filePath);
@@ -1,4 +1,5 @@
1
- import type { Plugin, PluginOptions } from '../../types/config.ts';
1
+ import type { Plugin, PluginOptions, ResolveConfig } from '../../types/config.ts';
2
2
  export declare const getActionDependencies: (config: any, options: PluginOptions) => string[];
3
+ export declare const resolveConfig: ResolveConfig;
3
4
  declare const plugin: Plugin;
4
5
  export default plugin;
@@ -18,17 +18,19 @@ export const getActionDependencies = (config, options) => {
18
18
  return scripts.map(script => join(configFileDir, script));
19
19
  };
20
20
  const ACTION_PATH_VAR = /\$\{\{\s*github\.action_path\s*\}\}|\$\{GITHUB_ACTION_PATH\}|\$GITHUB_ACTION_PATH/g;
21
- const resolveConfig = async (config, options) => {
21
+ export const resolveConfig = async (config, options) => {
22
22
  const { rootCwd, getInputsFromScripts, isProduction, getManifest, configFileDir } = options;
23
23
  const inputs = new Set();
24
24
  const jobs = findByKeyDeep(config, 'steps');
25
+ const workflowWorkingDir = config?.defaults?.run?.['working-directory'];
25
26
  for (const steps of jobs) {
26
27
  if (!Array.isArray(steps.steps))
27
28
  continue;
28
29
  const action = steps.steps.find(step => step.uses?.startsWith('actions/checkout@') && typeof step.with?.path === 'string' && !step.with.repository);
29
30
  const path = action?.with?.path;
31
+ const jobWorkingDir = steps.defaults?.run?.['working-directory'] ?? workflowWorkingDir;
30
32
  for (const step of steps.steps) {
31
- const workingDir = step['working-directory'];
33
+ const workingDir = step['working-directory'] ?? jobWorkingDir;
32
34
  const dir = join(rootCwd, path && workingDir ? relative(path, workingDir) : workingDir ? workingDir : '.');
33
35
  if (step.run) {
34
36
  const manifest = getManifest(dir) ?? options.manifest;
@@ -10,6 +10,11 @@ type Step = {
10
10
  type Steps = Step[];
11
11
  export type Job = {
12
12
  steps: Steps;
13
+ defaults?: {
14
+ run?: {
15
+ 'working-directory'?: string;
16
+ };
17
+ };
13
18
  };
14
19
  export type Runs = {
15
20
  using: string;
@@ -8,6 +8,8 @@ const enablers = [/^@graphql-codegen\//, 'graphql-config'];
8
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
9
9
  const args = {
10
10
  config: true,
11
+ resolve: ['require'],
12
+ alias: { require: ['r'] },
11
13
  };
12
14
  const packageJsonPath = manifest => get(manifest, 'codegen') ?? get(manifest, 'graphql');
13
15
  const config = [
@@ -36,6 +36,7 @@ export declare const Plugins: {
36
36
  eleventy: import("../types/config.ts").Plugin;
37
37
  ember: import("../types/config.ts").Plugin;
38
38
  'ember-template-lint': import("../types/config.ts").Plugin;
39
+ env: import("../types/config.ts").Plugin;
39
40
  'env-cmd': import("../types/config.ts").Plugin;
40
41
  esbuild: import("../types/config.ts").Plugin;
41
42
  eslint: import("../types/config.ts").Plugin;
@@ -52,6 +53,7 @@ export declare const Plugins: {
52
53
  };
53
54
  fast: import("../types/config.ts").Plugin;
54
55
  'filesystem-routing': import("../types/config.ts").Plugin;
56
+ firebase: import("../types/config.ts").Plugin;
55
57
  flue: import("../types/config.ts").Plugin;
56
58
  fumadocs: import("../types/config.ts").Plugin;
57
59
  gatsby: import("../types/config.ts").Plugin;
@@ -158,6 +160,7 @@ export declare const Plugins: {
158
160
  'solidjs-vite-plugin': import("../types/config.ts").Plugin;
159
161
  sst: import("../types/config.ts").Plugin;
160
162
  starlight: import("../types/config.ts").Plugin;
163
+ 'start-server-and-test': import("../types/config.ts").Plugin;
161
164
  stencil: import("../types/config.ts").Plugin;
162
165
  storybook: import("../types/config.ts").Plugin;
163
166
  stryker: import("../types/config.ts").Plugin;
@@ -176,7 +179,9 @@ export declare const Plugins: {
176
179
  temporal: import("../types/config.ts").Plugin;
177
180
  textlint: import("../types/config.ts").Plugin;
178
181
  travis: import("../types/config.ts").Plugin;
182
+ 'trigger-dev': import("../types/config.ts").Plugin;
179
183
  'ts-node': import("../types/config.ts").Plugin;
184
+ 'ts-node-dev': import("../types/config.ts").Plugin;
180
185
  tsd: import("../types/config.ts").Plugin;
181
186
  tsdown: import("../types/config.ts").Plugin;
182
187
  tsrs: import("../types/config.ts").Plugin;
@@ -199,6 +204,7 @@ export declare const Plugins: {
199
204
  'vercel-og': import("../types/config.ts").Plugin;
200
205
  vike: import("../types/config.ts").Plugin;
201
206
  vite: import("../types/config.ts").Plugin;
207
+ 'vite-node': import("../types/config.ts").Plugin;
202
208
  'vite-plugin-pages': import("../types/config.ts").Plugin;
203
209
  'vite-plugin-pwa': import("../types/config.ts").Plugin;
204
210
  'vite-plugin-vue-layouts-next': import("../types/config.ts").Plugin;
@@ -35,6 +35,7 @@ import { default as electronVite } from './electron-vite/index.js';
35
35
  import { default as eleventy } from './eleventy/index.js';
36
36
  import { default as ember } from './ember/index.js';
37
37
  import { default as emberTemplateLint } from './ember-template-lint/index.js';
38
+ import { default as env } from './env/index.js';
38
39
  import { default as envCmd } from './env-cmd/index.js';
39
40
  import { default as esbuild } from './esbuild/index.js';
40
41
  import { default as eslint } from './eslint/index.js';
@@ -46,6 +47,7 @@ import { default as expoRouter } from './expo-router/index.js';
46
47
  import { default as expressiveCode } from './expressive-code/index.js';
47
48
  import { default as fast } from './fast/index.js';
48
49
  import { default as filesystemRouting } from './filesystem-routing/index.js';
50
+ import { default as firebase } from './firebase/index.js';
49
51
  import { default as flue } from './flue/index.js';
50
52
  import { default as fumadocs } from './fumadocs/index.js';
51
53
  import { default as gatsby } from './gatsby/index.js';
@@ -152,6 +154,7 @@ import { default as sizeLimit } from './size-limit/index.js';
152
154
  import { default as solidjsVitePlugin } from './solidjs-vite-plugin/index.js';
153
155
  import { default as sst } from './sst/index.js';
154
156
  import { default as starlight } from './starlight/index.js';
157
+ import { default as startServerAndTest } from './start-server-and-test/index.js';
155
158
  import { default as stencil } from './stencil/index.js';
156
159
  import { default as storybook } from './storybook/index.js';
157
160
  import { default as stryker } from './stryker/index.js';
@@ -170,7 +173,9 @@ import { default as tauri } from './tauri/index.js';
170
173
  import { default as temporal } from './temporal/index.js';
171
174
  import { default as textlint } from './textlint/index.js';
172
175
  import { default as travis } from './travis/index.js';
176
+ import { default as triggerDev } from './trigger-dev/index.js';
173
177
  import { default as tsNode } from './ts-node/index.js';
178
+ import { default as tsNodeDev } from './ts-node-dev/index.js';
174
179
  import { default as tsd } from './tsd/index.js';
175
180
  import { default as tsdown } from './tsdown/index.js';
176
181
  import { default as tsrs } from './tsrs/index.js';
@@ -193,6 +198,7 @@ import { default as vercel } from './vercel/index.js';
193
198
  import { default as vercelOg } from './vercel-og/index.js';
194
199
  import { default as vike } from './vike/index.js';
195
200
  import { default as vite } from './vite/index.js';
201
+ import { default as viteNode } from './vite-node/index.js';
196
202
  import { default as vitePluginPages } from './vite-plugin-pages/index.js';
197
203
  import { default as vitePluginPwa } from './vite-plugin-pwa/index.js';
198
204
  import { default as vitePluginVueLayoutsNext } from './vite-plugin-vue-layouts-next/index.js';
@@ -249,6 +255,7 @@ export const Plugins = {
249
255
  eleventy,
250
256
  ember,
251
257
  'ember-template-lint': emberTemplateLint,
258
+ env,
252
259
  'env-cmd': envCmd,
253
260
  esbuild,
254
261
  eslint,
@@ -260,6 +267,7 @@ export const Plugins = {
260
267
  'expressive-code': expressiveCode,
261
268
  fast,
262
269
  'filesystem-routing': filesystemRouting,
270
+ firebase,
263
271
  flue,
264
272
  fumadocs,
265
273
  gatsby,
@@ -366,6 +374,7 @@ export const Plugins = {
366
374
  'solidjs-vite-plugin': solidjsVitePlugin,
367
375
  sst,
368
376
  starlight,
377
+ 'start-server-and-test': startServerAndTest,
369
378
  stencil,
370
379
  storybook,
371
380
  stryker,
@@ -384,7 +393,9 @@ export const Plugins = {
384
393
  temporal,
385
394
  textlint,
386
395
  travis,
396
+ 'trigger-dev': triggerDev,
387
397
  'ts-node': tsNode,
398
+ 'ts-node-dev': tsNodeDev,
388
399
  tsd,
389
400
  tsdown,
390
401
  tsrs,
@@ -407,6 +418,7 @@ export const Plugins = {
407
418
  'vercel-og': vercelOg,
408
419
  vike,
409
420
  vite,
421
+ 'vite-node': viteNode,
410
422
  'vite-plugin-pages': vitePluginPages,
411
423
  'vite-plugin-pwa': vitePluginPwa,
412
424
  'vite-plugin-vue-layouts-next': vitePluginVueLayoutsNext,
@@ -41,15 +41,21 @@ const builtInReporters = new Set([
41
41
  'GithubActions',
42
42
  'github-actions',
43
43
  ]);
44
+ const nodeOptionModule = /^(?:import|require|loader|experimental-loader)=(.+)$/;
44
45
  const isExternalReporter = (reporter) => typeof reporter === 'string' && !builtInReporters.has(reporter);
45
46
  const resolveConfig = (localConfig, options) => {
46
47
  const entryPatterns = localConfig.spec ? [localConfig.spec].flat() : entry;
47
48
  const files = localConfig.file ? [localConfig.file].flat() : [];
48
49
  const require = localConfig.require ? [localConfig.require].flat() : [];
50
+ const nodeOptions = localConfig['node-option'] ? [localConfig['node-option']].flat() : undefined;
51
+ const preload = nodeOptions
52
+ ? nodeOptions.flatMap(option => option.match(nodeOptionModule)?.[1] ?? [])
53
+ : [localConfig.import ?? [], localConfig.loader ?? []].flat();
49
54
  const inputs = [];
50
55
  inputs.push(...entryPatterns.map(id => toEntry(id)));
51
56
  inputs.push(...files.map(id => toEntryPath(id, { dir: options.cwd })));
52
57
  inputs.push(...require.map(id => toModule(id, { dir: options.cwd })));
58
+ inputs.push(...preload.map(id => toModule(id, { dir: options.cwd })));
53
59
  if (isExternalReporter(localConfig.reporter))
54
60
  inputs.push(toModule(localConfig.reporter, { dir: options.cwd }));
55
61
  return inputs;
@@ -1,5 +1,8 @@
1
1
  export interface MochaConfig {
2
2
  file?: string | string[];
3
+ import?: string | string[];
4
+ loader?: string | string[];
5
+ 'node-option'?: string | string[];
3
6
  reporter?: string;
4
7
  require?: string | string[];
5
8
  spec?: string | string[];
@@ -3,12 +3,21 @@ 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';
6
- const enablers = [/^@netlify\/plugin-/, 'netlify-cli', '@netlify/functions'];
6
+ const enablers = [/^@netlify\/plugin-/, 'netlify-cli', '@netlify/functions', '@netlify/edge-functions'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  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
- const production = [`${NETLIFY_FUNCTIONS_DIR}/**/*.{${NETLIFY_FUNCTIONS_EXTS}}`];
11
+ const NETLIFY_EDGE_FUNCTIONS_DIR = 'netlify/edge-functions';
12
+ const NETLIFY_EDGE_FUNCTIONS_EXTS = 'js,jsx,mjs,mts,ts,tsx';
13
+ const toEdgeFunctionPatterns = (dir) => [
14
+ join(dir, `*.{${NETLIFY_EDGE_FUNCTIONS_EXTS}}`),
15
+ join(dir, `*/index.{${NETLIFY_EDGE_FUNCTIONS_EXTS}}`),
16
+ ];
17
+ const production = [
18
+ `${NETLIFY_FUNCTIONS_DIR}/**/*.{${NETLIFY_FUNCTIONS_EXTS}}`,
19
+ ...toEdgeFunctionPatterns(NETLIFY_EDGE_FUNCTIONS_DIR),
20
+ ];
12
21
  const toPluginInput = (id) => {
13
22
  const specifier = id.startsWith('/') ? `.${id}` : id;
14
23
  return isInternal(specifier) ? toModule(specifier) : toDependency(id);
@@ -17,6 +26,7 @@ const resolveConfig = async (localConfig) => {
17
26
  return [
18
27
  ...extractFunctionsConfigProperty(localConfig.functions || {}, 'included_files'),
19
28
  join(localConfig.functions?.directory ?? NETLIFY_FUNCTIONS_DIR, `**/*.{${NETLIFY_FUNCTIONS_EXTS}}`),
29
+ ...toEdgeFunctionPatterns(localConfig.build?.edge_functions ?? NETLIFY_EDGE_FUNCTIONS_DIR),
20
30
  ]
21
31
  .filter(file => !file.startsWith('!'))
22
32
  .map(id => toEntry(id, { production: true }))
@@ -1,4 +1,7 @@
1
1
  export type NetlifyConfig = {
2
+ build?: {
3
+ edge_functions?: string;
4
+ };
2
5
  plugins?: {
3
6
  package: string;
4
7
  }[];
@@ -1,10 +1,10 @@
1
1
  import type { Plugin } from '../../types/config.ts';
2
+ import { type Input } from '../../util/input.ts';
2
3
  import type { ParsedArgs } from '../../util/parse-args.ts';
3
4
  declare const toScripts: (parsed: ParsedArgs) => string[];
4
5
  export declare const args: {
5
6
  positional: typeof toScripts;
6
7
  nodeImportArgs: true;
7
- resolve: string[];
8
8
  string: string[];
9
9
  alias: {
10
10
  conditions: string[];
@@ -13,7 +13,7 @@ export declare const args: {
13
13
  };
14
14
  boolean: true;
15
15
  stopEarly: true;
16
- args: (args: string[]) => string[];
16
+ resolveInputs: (parsed: ParsedArgs) => Input[];
17
17
  };
18
18
  declare const plugin: Plugin;
19
19
  export default plugin;
@@ -1,4 +1,4 @@
1
- import { toEntry } from '../../util/input.js';
1
+ import { toEntry, toModule } from '../../util/input.js';
2
2
  import { createFsPromisesGlobVisitor } from './visitors/fsPromisesGlob.js';
3
3
  const title = 'Node.js';
4
4
  const isEnabled = () => true;
@@ -21,6 +21,7 @@ const hasNodeTest = (scripts, cwd, getScriptCommands) => {
21
21
  return result;
22
22
  };
23
23
  const entry = ['server.js'];
24
+ const builtInReporters = new Set(['spec', 'tap', 'dot', 'junit', 'lcov']);
24
25
  const registerVisitors = ({ ctx, registerVisitor }) => {
25
26
  registerVisitor(createFsPromisesGlobVisitor(ctx));
26
27
  };
@@ -41,7 +42,6 @@ const toScripts = (parsed) => {
41
42
  export const args = {
42
43
  positional: toScripts,
43
44
  nodeImportArgs: true,
44
- resolve: ['test-reporter'],
45
45
  string: [
46
46
  'allow-fs-read',
47
47
  'allow-fs-write',
@@ -101,6 +101,7 @@ export const args = {
101
101
  'test-isolation',
102
102
  'test-name-pattern',
103
103
  'test-random-seed',
104
+ 'test-reporter',
104
105
  'test-reporter-destination',
105
106
  'test-rerun-failures',
106
107
  'test-shard',
@@ -121,7 +122,17 @@ export const args = {
121
122
  alias: { conditions: ['C'], eval: ['e'], print: ['p'] },
122
123
  boolean: true,
123
124
  stopEarly: true,
124
- args: (args) => args.filter(arg => !/--test-reporter[= ](spec|tap|dot|junit|lcov)/.test(arg)),
125
+ resolveInputs: (parsed) => {
126
+ const reporters = parsed['test-reporter'];
127
+ if (!reporters)
128
+ return [];
129
+ const inputs = [];
130
+ for (const reporter of Array.isArray(reporters) ? reporters : [reporters]) {
131
+ if (typeof reporter === 'string' && reporter && !builtInReporters.has(reporter))
132
+ inputs.push(toModule(reporter));
133
+ }
134
+ return inputs;
135
+ },
125
136
  };
126
137
  const plugin = {
127
138
  title,
@@ -1,12 +1,31 @@
1
+ import { hasDependency } from '../../util/plugin.js';
1
2
  const title = 'nodemon';
3
+ const enablers = ['nodemon'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const config = ['nodemon.json', 'package.json'];
6
+ const packageJsonPath = 'nodemonConfig';
7
+ const resolveConfig = (config, options) => {
8
+ if (!config.exec)
9
+ return [];
10
+ const inputs = options.getInputsFromScripts(config.exec, { optionalBinaries: true });
11
+ for (const input of inputs)
12
+ input.dir ??= options.cwd;
13
+ return inputs;
14
+ };
2
15
  const args = {
3
16
  positional: false,
4
17
  nodeImportArgs: true,
5
18
  alias: { exec: ['x'] },
6
19
  fromArgs: ['exec'],
20
+ config: ['config'],
7
21
  };
8
22
  const plugin = {
9
23
  title,
24
+ enablers,
25
+ isEnabled,
26
+ config,
27
+ packageJsonPath,
28
+ resolveConfig,
10
29
  args,
11
30
  };
12
31
  export default plugin;
@@ -5,10 +5,17 @@ import { get } from '../../util/object.js';
5
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
+ import { getBuilderEntries } from '../angular/helpers.js';
8
9
  const title = 'Nx';
9
10
  const enablers = ['nx', /^@nrwl\//, /^@nx\//];
10
11
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
11
12
  const config = ['nx.json', 'project.json', '{apps,libs}/**/project.json', 'package.json'];
13
+ const angularBuilderPackages = new Set([
14
+ '@angular-devkit/build-angular',
15
+ '@angular/build',
16
+ '@nrwl/angular',
17
+ '@nx/angular',
18
+ ]);
12
19
  const findNxDependenciesInNxJson = async (localConfig) => {
13
20
  const targetsDefault = localConfig.targetDefaults
14
21
  ? Object.keys(localConfig.targetDefaults)
@@ -88,7 +95,13 @@ const resolveConfig = async (localConfig, options) => {
88
95
  }
89
96
  return configs;
90
97
  });
91
- return compact([...executors, ...inputs, ...configInputs]).map(id => typeof id === 'string' ? toDependency(id) : id);
98
+ const angularBuilderInputs = [];
99
+ for (const [targetName, target] of Object.entries(config.targets ?? {})) {
100
+ if (target.executor && angularBuilderPackages.has(substringBefore(target.executor, ':'))) {
101
+ angularBuilderInputs.push(...getBuilderEntries(targetName, target, options.rootCwd, expand));
102
+ }
103
+ }
104
+ return compact([...executors, ...inputs, ...configInputs, ...angularBuilderInputs]).map(id => typeof id === 'string' ? toDependency(id) : id);
92
105
  };
93
106
  const collections = [
94
107
  ['generators', 'schematics'],
@@ -3,10 +3,14 @@ const title = 'Plop';
3
3
  const enablers = ['plop'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
5
  const entry = ['plopfile.{cjs,mjs,js,ts}'];
6
+ const args = {
7
+ config: ['plopfile'],
8
+ };
6
9
  const plugin = {
7
10
  title,
8
11
  enablers,
9
12
  isEnabled,
10
13
  entry,
14
+ args,
11
15
  };
12
16
  export default plugin;
@@ -26,6 +26,8 @@ const resolveConfig = async (config, options) => {
26
26
  else if (config.migrations?.seed) {
27
27
  inputs.push(...options.getInputsFromScripts(config.migrations.seed));
28
28
  }
29
+ for (const input of inputs)
30
+ input.dir ??= options.cwd;
29
31
  if (config.schema) {
30
32
  inputs.push(resolveSchema(config.schema, options.configFileDir));
31
33
  }
@@ -22,18 +22,11 @@ const getCandidates = (prefix, identifier) => {
22
22
  return [identifier];
23
23
  return [prefix + name, name];
24
24
  };
25
- const getDeclaredDependencies = (manifest) => new Set([
26
- ...Object.keys(manifest.dependencies ?? {}),
27
- ...Object.keys(manifest.devDependencies ?? {}),
28
- ...Object.keys(manifest.optionalDependencies ?? {}),
29
- ...Object.keys(manifest.peerDependencies ?? {}),
30
- ]);
31
25
  const pickCandidate = (prefix, identifier, manifest) => {
32
26
  const candidates = getCandidates(prefix, identifier);
33
27
  if (candidates.length === 1 || isInternal(candidates[0]))
34
28
  return candidates[0];
35
- const dependencies = getDeclaredDependencies(manifest);
36
- return candidates.find(candidate => dependencies.has(candidate)) ?? candidates[0];
29
+ return candidates.find(candidate => manifest.allDependencies.has(candidate)) ?? candidates[0];
37
30
  };
38
31
  export const resolveLoadPluginStylePluginName = (prefix, identifier, manifest) => {
39
32
  prefix = prefix + (prefix.at(-1) === '-' ? '' : '-');
@@ -7,7 +7,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['rollup.config.{js,cjs,mjs,ts}'];
8
8
  const args = {
9
9
  alias: { plugin: ['p'] },
10
- config: ['config'],
10
+ config: true,
11
11
  args: (args) => args.map(arg => (arg.startsWith('--watch.onEnd') ? `--_exec${arg.slice(13)}` : arg)),
12
12
  fromArgs: ['_exec'],
13
13
  resolve: ['plugin', 'configPlugin'],
@@ -27,7 +27,11 @@ const handlerToEntry = (handler, dir) => {
27
27
  const file = handler.slice(0, dot);
28
28
  return toEntryPath(file, { production: true, dir });
29
29
  };
30
- const pluginToInput = (plugin, dir) => isInternal(plugin) ? toEntryPath(toAbsolute(plugin, dir), { production: true }) : toDependency(plugin);
30
+ const pluginToInput = (plugin, dir, localPath) => isInternal(plugin)
31
+ ? toEntryPath(toAbsolute(plugin, dir), { production: true })
32
+ : localPath
33
+ ? toEntryPath(plugin, { production: true, dir: toAbsolute(localPath, dir) })
34
+ : toDependency(plugin);
31
35
  const getFunctionEntries = async (functions, dir, cwd) => {
32
36
  const entries = [];
33
37
  const resolved = await resolveFileVariable(functions, dir);
@@ -49,9 +53,14 @@ const getInjectEntries = (esbuild, dir) => esbuild && typeof esbuild === 'object
49
53
  export const resolveConfig = async (config, options) => {
50
54
  const functions = await getFunctionEntries(config.functions, options.configFileDir, options.cwd);
51
55
  const resolvedPlugins = await resolveFileVariable(config.plugins, options.configFileDir);
52
- const plugins = Array.isArray(resolvedPlugins)
53
- ? resolvedPlugins.filter((plugin) => typeof plugin === 'string')
54
- : [];
56
+ const pluginConfig = isRecord(resolvedPlugins) ? resolvedPlugins : undefined;
57
+ const pluginModules = Array.isArray(resolvedPlugins)
58
+ ? resolvedPlugins
59
+ : pluginConfig && Array.isArray(pluginConfig.modules)
60
+ ? pluginConfig.modules
61
+ : [];
62
+ const localPath = pluginConfig && typeof pluginConfig.localPath === 'string' ? pluginConfig.localPath : undefined;
63
+ const plugins = pluginModules.filter((plugin) => typeof plugin === 'string');
55
64
  const esbuild = config.custom?.esbuild || config.build?.esbuild ? [toDependency('esbuild', { optional: true })] : [];
56
65
  const injectEntries = [
57
66
  ...getInjectEntries(config.custom?.esbuild, options.configFileDir),
@@ -59,7 +68,7 @@ export const resolveConfig = async (config, options) => {
59
68
  ];
60
69
  return [
61
70
  ...functions,
62
- ...plugins.map(plugin => pluginToInput(plugin, options.configFileDir)),
71
+ ...plugins.map(plugin => pluginToInput(plugin, options.configFileDir, localPath)),
63
72
  ...esbuild,
64
73
  ...injectEntries,
65
74
  ];
@@ -6,7 +6,10 @@ export type PluginConfig = {
6
6
  esbuild?: EsbuildConfig;
7
7
  };
8
8
  functions?: Functions | Array<Functions | FileVariable> | FileVariable;
9
- plugins?: unknown[] | FileVariable;
9
+ plugins?: unknown[] | {
10
+ localPath?: string;
11
+ modules?: unknown[];
12
+ } | FileVariable;
10
13
  };
11
14
  type FileVariable = string;
12
15
  type Functions = Record<string, ServerlessFunction | FileVariable>;