knip 6.46.1 → 6.47.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 (59) hide show
  1. package/dist/ConfigurationChief.d.ts +2 -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/compilers/mdx.js +7 -1
  6. package/dist/plugins/angular/helpers.d.ts +7 -0
  7. package/dist/plugins/angular/helpers.js +58 -0
  8. package/dist/plugins/angular/index.js +5 -50
  9. package/dist/plugins/angular/types.d.ts +2 -2
  10. package/dist/plugins/astro/index.js +6 -1
  11. package/dist/plugins/cucumber/index.js +19 -7
  12. package/dist/plugins/cucumber/types.d.ts +1 -0
  13. package/dist/plugins/cypress/index.js +5 -0
  14. package/dist/plugins/drizzle/index.js +5 -0
  15. package/dist/plugins/github-action/index.js +13 -3
  16. package/dist/plugins/github-actions/index.d.ts +2 -1
  17. package/dist/plugins/github-actions/index.js +4 -2
  18. package/dist/plugins/github-actions/types.d.ts +5 -0
  19. package/dist/plugins/index.d.ts +2 -0
  20. package/dist/plugins/index.js +4 -0
  21. package/dist/plugins/mocha/index.js +6 -0
  22. package/dist/plugins/mocha/types.d.ts +3 -0
  23. package/dist/plugins/node/index.d.ts +2 -2
  24. package/dist/plugins/node/index.js +14 -3
  25. package/dist/plugins/nx/index.js +14 -1
  26. package/dist/plugins/plop/index.js +4 -0
  27. package/dist/plugins/prisma/index.js +2 -0
  28. package/dist/plugins/rollup/index.js +1 -1
  29. package/dist/plugins/sst/resolveFromAST.js +24 -15
  30. package/dist/plugins/start-server-and-test/index.d.ts +3 -0
  31. package/dist/plugins/start-server-and-test/index.js +10 -0
  32. package/dist/plugins/trigger-dev/index.d.ts +3 -0
  33. package/dist/plugins/trigger-dev/index.js +28 -0
  34. package/dist/plugins/tsx/index.js +1 -1
  35. package/dist/plugins/typedoc/index.js +5 -2
  36. package/dist/plugins/typescript/index.d.ts +12 -1
  37. package/dist/plugins/typescript/index.js +6 -3
  38. package/dist/plugins/vite-plus/index.d.ts +4 -1
  39. package/dist/plugins/vite-plus/index.js +19 -4
  40. package/dist/plugins/vite-plus/types.d.ts +12 -0
  41. package/dist/plugins/vite-plus/types.js +1 -0
  42. package/dist/plugins/vitepress/index.js +14 -0
  43. package/dist/plugins/vitest/index.js +5 -0
  44. package/dist/plugins/vitest/types.d.ts +2 -1
  45. package/dist/plugins/web-test-runner/index.js +8 -2
  46. package/dist/plugins/wrangler/index.js +4 -0
  47. package/dist/session/index.d.ts +1 -0
  48. package/dist/session/index.js +1 -0
  49. package/dist/types/PluginNames.d.ts +2 -2
  50. package/dist/types/PluginNames.js +2 -0
  51. package/dist/util/create-input-handler.js +3 -1
  52. package/dist/util/remove-export.d.ts +1 -0
  53. package/dist/util/remove-export.js +2 -0
  54. package/dist/version.d.ts +1 -1
  55. package/dist/version.js +1 -1
  56. package/package.json +1 -1
  57. package/schema.json +8 -0
  58. package/dist/plugins/vite-plus/resolveFromAST.d.ts +0 -2
  59. package/dist/plugins/vite-plus/resolveFromAST.js +0 -37
@@ -237,6 +237,7 @@ export declare class ConfigurationChief {
237
237
  "solidjs-vite-plugin"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
238
238
  sst?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
239
239
  starlight?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
240
+ "start-server-and-test"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
240
241
  stencil?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
241
242
  storybook?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
242
243
  stryker?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -255,6 +256,7 @@ export declare class ConfigurationChief {
255
256
  temporal?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
256
257
  textlint?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
257
258
  travis?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
259
+ "trigger-dev"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
258
260
  "ts-node"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
259
261
  tsd?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
260
262
  tsdown?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -3,8 +3,7 @@ import { DEFAULT_CATALOG } from './util/catalog.js';
3
3
  import { debugLogArray, debugLogObject } from './util/debug.js';
4
4
  import { load, save } from './util/package-json.js';
5
5
  import { extname, join } from './util/path.js';
6
- import { removeExport } from './util/remove-export.js';
7
- const MODULE_MARKER = /^[ \t]*(import|export)\b/m;
6
+ import { keepModuleMarker, removeExport } from './util/remove-export.js';
8
7
  export const fix = async (issues, counters, options) => {
9
8
  const fixer = new IssueFixer(options);
10
9
  const touchedFiles = await fixer.fixIssues(issues);
@@ -80,10 +79,7 @@ class IssueFixer {
80
79
  if (fix[0] >= (disjointFixes.at(-1)?.[1] ?? 0))
81
80
  disjointFixes.push(fix);
82
81
  }
83
- let sourceFileText = disjointFixes.reduceRight((text, [start, end, flags]) => removeExport({ text, start, end, flags }), originalSource);
84
- if (MODULE_MARKER.test(originalSource) && !MODULE_MARKER.test(sourceFileText)) {
85
- sourceFileText = `${sourceFileText.trimEnd()}\n\nexport {};\n`;
86
- }
82
+ const sourceFileText = keepModuleMarker(originalSource, disjointFixes.reduceRight((text, [start, end, flags]) => removeExport({ text, start, end, flags }), originalSource));
87
83
  await writeFile(absFilePath, sourceFileText);
88
84
  touchedFiles.add(absFilePath);
89
85
  for (const type of types) {
@@ -68,6 +68,7 @@ export declare class WorkspaceWorker {
68
68
  private getPluginConfig;
69
69
  getPluginConfigPatterns(): string[];
70
70
  getPluginEntryFilePatterns(patterns: string[], base?: string): string[];
71
+ private getNegatedDevelopmentEntryFiles;
71
72
  getProductionEntryFilePatterns(): string[];
72
73
  getProductionProjectFilePatterns(): string[];
73
74
  private getConfigurationFilePatterns;
@@ -152,23 +152,27 @@ export class WorkspaceWorker {
152
152
  : this.ignoredWorkspacePatterns;
153
153
  return [patterns, negateWorkspaces, ignoredWorkspaces.map(negate)].flat();
154
154
  }
155
+ getNegatedDevelopmentEntryFiles() {
156
+ const { entry } = this.config;
157
+ return entry.filter(pattern => hasNoProductionSuffix(pattern) && !entry.includes(`${pattern}!`)).map(negate);
158
+ }
155
159
  getProductionEntryFilePatterns() {
156
160
  const entry = this.config.entry.filter(hasProductionSuffix);
157
161
  if (entry.length === 0)
158
162
  return [];
159
- const negatedEntryFiles = this.config.entry.filter(hasNoProductionSuffix).map(negate);
163
+ const negatedEntryFiles = this.getNegatedDevelopmentEntryFiles();
160
164
  return [entry, negatedEntryFiles, this.negatedWorkspacePatterns].flat();
161
165
  }
162
166
  getProductionProjectFilePatterns() {
163
167
  const project = this.config.project;
164
168
  if (project.length === 0)
165
169
  return this.getProductionEntryFilePatterns();
166
- const _project = this.config.project.map(pattern => {
167
- if (!(pattern.endsWith('!') || pattern.startsWith('!')))
168
- return negate(pattern);
169
- return pattern;
170
+ const _project = project.flatMap(pattern => {
171
+ if (pattern.endsWith('!') || pattern.startsWith('!'))
172
+ return [pattern];
173
+ return project.includes(`${pattern}!`) ? [] : [negate(pattern)];
170
174
  });
171
- const negatedEntryFiles = this.config.entry.filter(hasNoProductionSuffix).map(negate);
175
+ const negatedEntryFiles = this.getNegatedDevelopmentEntryFiles();
172
176
  const negatedPluginConfigPatterns = this.getPluginConfigPatterns().map(negate);
173
177
  const negatedPluginProjectFilePatterns = this.getPluginProjectFilePatterns().map(negate);
174
178
  return [
@@ -11,8 +11,9 @@ const dependencies = [
11
11
  'remark-mdx',
12
12
  ];
13
13
  const mdxImportMatcher = /^import[^'"]+['"][^'"]+['"]/gm;
14
+ const mdxReExportMatcher = /^export\s*\{([^}]*)\}\s*from\s*(['"][^'"]+['"])/gm;
14
15
  const compiler = (text) => {
15
- if (!text.includes('import'))
16
+ if (!text.includes('import') && !text.includes('export'))
16
17
  return '';
17
18
  const imports = [];
18
19
  const source = text
@@ -23,6 +24,11 @@ const compiler = (text) => {
23
24
  mdxImportMatcher.lastIndex = 0;
24
25
  while ((match = mdxImportMatcher.exec(source)))
25
26
  imports.push(match[0]);
27
+ mdxReExportMatcher.lastIndex = 0;
28
+ while ((match = mdxReExportMatcher.exec(source))) {
29
+ const names = match[1].replace(/\s+as\s+[\w$]+/g, '').replace(/\bdefault\b/, 'default as _');
30
+ imports.push(`import {${names}} from ${match[2]}`);
31
+ }
26
32
  return imports.join('\n');
27
33
  };
28
34
  export default { dependencies, compiler };
@@ -0,0 +1,7 @@
1
+ import { type Input } from '../../util/input.ts';
2
+ interface BuilderTarget {
3
+ options?: unknown;
4
+ configurations?: unknown;
5
+ }
6
+ export declare const getBuilderEntries: (targetName: string, target: BuilderTarget, dir: string, toSpecifier?: (specifier: string) => string) => Input[];
7
+ export {};
@@ -0,0 +1,58 @@
1
+ import { toEntryPath, toModule } from '../../util/input.js';
2
+ import { isObject } from '../../util/validation.js';
3
+ const PRODUCTION_CONFIG_NAME = 'production';
4
+ const BUILD_TARGET_NAME = 'build';
5
+ const isPath = (value) => typeof value === 'string' && value.length > 0;
6
+ const getBundleInput = (value) => (isObject(value) ? value.input : value);
7
+ const getReplacementPath = (value) => (isObject(value) ? (value.with ?? value.replaceWith) : undefined);
8
+ const toPaths = (value, getPath = item => item) => {
9
+ const paths = [];
10
+ for (const item of Array.isArray(value) ? value : [value]) {
11
+ const path = getPath(item);
12
+ if (isPath(path))
13
+ paths.push(path);
14
+ }
15
+ return paths;
16
+ };
17
+ const entriesByOption = (opts) => new Map([
18
+ ['main', toPaths(opts.main)],
19
+ ['scripts', toPaths(opts.scripts, getBundleInput)],
20
+ ['styles', toPaths(opts.styles, getBundleInput)],
21
+ ['polyfills', toPaths(opts.polyfills)],
22
+ ['fileReplacements', toPaths(opts.fileReplacements, getReplacementPath)],
23
+ ['browser', toPaths(opts.browser)],
24
+ ['server', toPaths(opts.server)],
25
+ ['ssrEntry', toPaths(isObject(opts.ssr) ? opts.ssr.entry : undefined)],
26
+ ]);
27
+ export const getBuilderEntries = (targetName, target, dir, toSpecifier = specifier => specifier) => {
28
+ const { options: opts, configurations: configs } = target;
29
+ const defaultEntriesByOption = isObject(opts) ? entriesByOption(opts) : new Map();
30
+ const entriesByOptionByConfig = new Map();
31
+ if (isObject(configs)) {
32
+ for (const [configName, configOpts] of Object.entries(configs)) {
33
+ if (isObject(configOpts))
34
+ entriesByOptionByConfig.set(configName, entriesByOption(configOpts));
35
+ }
36
+ }
37
+ const productionEntriesByOption = entriesByOptionByConfig.get(PRODUCTION_CONFIG_NAME) ?? new Map();
38
+ const isBuildTarget = targetName === BUILD_TARGET_NAME;
39
+ const toInput = (option, entry, isProduction) => {
40
+ const specifier = toSpecifier(entry);
41
+ const opts = { dir, production: isProduction };
42
+ return option === 'polyfills' ? toModule(specifier, opts) : toEntryPath(specifier, opts);
43
+ };
44
+ const inputs = [];
45
+ for (const [configName, entriesByOption] of entriesByOptionByConfig) {
46
+ for (const [option, entries] of entriesByOption) {
47
+ for (const entry of entries) {
48
+ inputs.push(toInput(option, entry, isBuildTarget && configName === PRODUCTION_CONFIG_NAME));
49
+ }
50
+ }
51
+ }
52
+ for (const [option, entries] of defaultEntriesByOption) {
53
+ for (const entry of entries) {
54
+ inputs.push(toInput(option, entry, isBuildTarget && !productionEntriesByOption.get(option)?.length));
55
+ }
56
+ }
57
+ return inputs;
58
+ };
@@ -1,7 +1,8 @@
1
- import { toConfig, toModule, toEntryPath, toDependency, toEntry } from '../../util/input.js';
1
+ import { toConfig, toDependency, toEntry } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  import { createComponentStyleUrlsVisitor } from '../_component-style-urls/component-style-urls-visitor.js';
4
4
  import * as karma from '../karma/helpers.js';
5
+ import { getBuilderEntries } from './helpers.js';
5
6
  const title = 'Angular';
6
7
  const enablers = ['@angular/cli'];
7
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -14,7 +15,7 @@ const resolveConfig = async (config, options) => {
14
15
  if (!project.architect)
15
16
  continue;
16
17
  for (const [targetName, target] of Object.entries(project.architect)) {
17
- const { options: opts, configurations: configs } = target;
18
+ const { options: opts } = target;
18
19
  const [packageName] = typeof target.builder === 'string' ? target.builder.split(':') : [];
19
20
  if (packageName)
20
21
  inputs.add(toDependency(packageName));
@@ -23,26 +24,8 @@ const resolveConfig = async (config, options) => {
23
24
  inputs.add(toConfig('typescript', opts.tsConfig));
24
25
  }
25
26
  }
26
- const defaultEntriesByOption = opts ? entriesByOption(opts) : new Map();
27
- const entriesByOptionByConfig = new Map(configs ? Object.entries(configs).map(([name, opts]) => [name, entriesByOption(opts)]) : []);
28
- const productionEntriesByOption = entriesByOptionByConfig.get(PRODUCTION_CONFIG_NAME) ?? new Map();
29
- const isBuildTarget = targetName === BUILD_TARGET_NAME;
30
- const toInput = (option, specifier, isProduction) => {
31
- const opts = { dir: options.cwd, production: isProduction };
32
- return option === 'polyfills' ? toModule(specifier, opts) : toEntryPath(specifier, opts);
33
- };
34
- for (const [configName, entriesByOption] of entriesByOptionByConfig) {
35
- for (const [option, entries] of entriesByOption) {
36
- for (const entry of entries) {
37
- inputs.add(toInput(option, entry, isBuildTarget && configName === PRODUCTION_CONFIG_NAME));
38
- }
39
- }
40
- }
41
- for (const [option, entries] of defaultEntriesByOption) {
42
- for (const entry of entries) {
43
- inputs.add(toInput(option, entry, isBuildTarget && !productionEntriesByOption.get(option)?.length));
44
- }
45
- }
27
+ for (const input of getBuilderEntries(targetName, target, options.cwd))
28
+ inputs.add(input);
46
29
  if (target.builder && isAngularBuilderRefWithName({ builderRef: target.builder, name: 'karma' }) && opts) {
47
30
  const karmaBuilderOptions = opts;
48
31
  const testFilePatterns = karmaBuilderOptions.include ?? ['**/*.spec.ts'];
@@ -68,38 +51,10 @@ const resolveConfig = async (config, options) => {
68
51
  }
69
52
  return Array.from(inputs);
70
53
  };
71
- const entriesByOption = (opts) => new Map(Object.entries({
72
- main: 'main' in opts && opts.main && typeof opts.main === 'string' ? [opts.main] : [],
73
- scripts: 'scripts' in opts && opts.scripts && Array.isArray(opts.scripts)
74
- ? opts.scripts.map(scriptStringOrObject => typeof scriptStringOrObject === 'string' ? scriptStringOrObject : scriptStringOrObject.input)
75
- : [],
76
- styles: 'styles' in opts && opts.styles && Array.isArray(opts.styles)
77
- ? opts.styles.map(styleStringOrObject => typeof styleStringOrObject === 'string' ? styleStringOrObject : styleStringOrObject.input)
78
- : [],
79
- polyfills: 'polyfills' in opts && opts.polyfills
80
- ? Array.isArray(opts.polyfills)
81
- ? opts.polyfills
82
- : [opts.polyfills]
83
- : [],
84
- fileReplacements: 'fileReplacements' in opts && opts.fileReplacements && Array.isArray(opts.fileReplacements)
85
- ? opts.fileReplacements.map(fileReplacement => 'with' in fileReplacement ? fileReplacement.with : fileReplacement.replaceWith)
86
- : [],
87
- browser: 'browser' in opts && opts.browser && typeof opts.browser === 'string' ? [opts.browser] : [],
88
- server: 'server' in opts && opts.server && typeof opts.server === 'string' ? [opts.server] : [],
89
- ssrEntry: 'ssr' in opts &&
90
- opts.ssr &&
91
- typeof opts.ssr === 'object' &&
92
- 'entry' in opts.ssr &&
93
- typeof opts.ssr.entry === 'string'
94
- ? [opts.ssr.entry]
95
- : [],
96
- }));
97
54
  const isAngularBuilderRefWithName = ({ builderRef, name }) => {
98
55
  const [pkg, builderName] = builderRef.split(':');
99
56
  return (pkg === '@angular-devkit/build-angular' || pkg === '@angular/build') && builderName === name;
100
57
  };
101
- const PRODUCTION_CONFIG_NAME = 'production';
102
- const BUILD_TARGET_NAME = 'build';
103
58
  const isAngularSpecifier = (specifier) => specifier === '@angular/core';
104
59
  const registerVisitors = ({ ctx, registerVisitor }) => {
105
60
  registerVisitor(createComponentStyleUrlsVisitor(ctx, isAngularSpecifier));
@@ -1,5 +1,5 @@
1
1
  type FileVersion = number;
2
- export type Project = Project1 & {
2
+ type Project = Project1 & {
3
3
  cli?: {
4
4
  [k: string]: unknown;
5
5
  };
@@ -620,7 +620,7 @@ interface AppShellTarget {
620
620
  inputIndexPath?: string;
621
621
  outputIndexPath?: string;
622
622
  }
623
- export interface WebpackBrowserSchemaForBuildFacade {
623
+ interface WebpackBrowserSchemaForBuildFacade {
624
624
  assets?: ({
625
625
  followSymlinks?: boolean;
626
626
  glob: string;
@@ -1,4 +1,4 @@
1
- import { toDependency } from '../../util/input.js';
1
+ import { toConfig, toDependency } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  import compiler from './compiler.js';
4
4
  import mdxCompiler from './compiler-mdx.js';
@@ -24,6 +24,10 @@ const resolve = options => {
24
24
  }
25
25
  return inputs;
26
26
  };
27
+ const args = {
28
+ string: ['config', 'root'],
29
+ resolveInputs: (parsed, { cwd }) => parsed.config && !parsed.root ? [toConfig('astro', parsed.config, { dir: cwd })] : [],
30
+ };
27
31
  const plugin = {
28
32
  title,
29
33
  enablers,
@@ -34,5 +38,6 @@ const plugin = {
34
38
  registerCompilers,
35
39
  resolveFromAST,
36
40
  resolve,
41
+ args,
37
42
  };
38
43
  export default plugin;
@@ -1,4 +1,5 @@
1
1
  import { toModule, toEntry } from '../../util/input.js';
2
+ import { isDirectory } from '../../util/fs.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
4
  const title = 'Cucumber';
4
5
  const enablers = ['@cucumber/cucumber'];
@@ -25,23 +26,33 @@ const toFormatterName = (format) => {
25
26
  const [name, quotedName] = format.match(/^"([^"]*)"|^[^:]*/) ?? [format];
26
27
  return quotedName ?? name;
27
28
  };
28
- const resolveProfile = (config) => {
29
- const imports = (config?.import ? config.import : entry).map(id => toEntry(id));
30
- const requires = (config?.require ? config.require : []).map(id => toEntry(id));
29
+ const toSupportEntry = (id, cwd, extension) => toEntry(isDirectory(cwd, id) ? `${id}/**/*${extension}` : id);
30
+ const resolveProfile = (cwd, config) => {
31
+ const imports = (config?.import ? config.import : entry).map(id => toSupportEntry(id, cwd, '.@(js|cjs|mjs)'));
32
+ const requires = (config?.require ? config.require : []).map(id => toSupportEntry(id, cwd, '.js'));
33
+ const modules = (config?.requireModule ? config.requireModule : []).map(id => toModule(id));
31
34
  const formatters = (config?.format ? config.format : [])
32
35
  .map(toFormatterName)
33
36
  .filter(name => !builtinFormatters.has(name))
34
37
  .map(id => toModule(id));
35
- return [...imports, ...requires, ...formatters];
38
+ return [...imports, ...requires, ...modules, ...formatters];
36
39
  };
37
40
  const resolveConfig = (config, options) => {
38
41
  if (typeof config !== 'object' || config === null)
39
- return resolveProfile();
42
+ return resolveProfile(options.cwd);
40
43
  const isProfiles = /\.(json|ya?ml)$/.test(options.configFileName) || 'default' in config;
41
44
  if (!isProfiles)
42
- return resolveProfile(config);
45
+ return resolveProfile(options.cwd, config);
43
46
  const profiles = 'default' in config ? Object.values(config) : [undefined, ...Object.values(config)];
44
- return profiles.flatMap(resolveProfile);
47
+ return profiles.flatMap(profile => resolveProfile(options.cwd, profile));
48
+ };
49
+ const args = {
50
+ binaries: ['cucumber-js'],
51
+ config: true,
52
+ resolve: ['require-module'],
53
+ string: ['require'],
54
+ alias: { require: ['r'] },
55
+ resolveInputs: (parsed, { cwd }) => [parsed.require ?? []].flat().map(id => toSupportEntry(id, cwd, '.js')),
45
56
  };
46
57
  const plugin = {
47
58
  title,
@@ -50,5 +61,6 @@ const plugin = {
50
61
  config,
51
62
  entry,
52
63
  resolveConfig,
64
+ args,
53
65
  };
54
66
  export default plugin;
@@ -2,6 +2,7 @@ export type CucumberConfig = {
2
2
  publishQuiet?: boolean;
3
3
  import?: string[];
4
4
  require?: string[];
5
+ requireModule?: string[];
5
6
  format?: Format[];
6
7
  parallel?: number;
7
8
  };
@@ -25,6 +25,10 @@ const resolveConfig = async (localConfig, options) => {
25
25
  : SUPPORT_FILE_PATTERNS.map(id => toEntry(id))),
26
26
  ];
27
27
  };
28
+ const args = {
29
+ config: ['config-file'],
30
+ alias: { 'config-file': ['C'] },
31
+ };
28
32
  const plugin = {
29
33
  title,
30
34
  enablers,
@@ -32,5 +36,6 @@ const plugin = {
32
36
  config,
33
37
  entry,
34
38
  resolveConfig,
39
+ args,
35
40
  };
36
41
  export default plugin;
@@ -9,11 +9,16 @@ const resolveConfig = config => {
9
9
  return [];
10
10
  return [config.schema].flat().map(id => toEntry(id, { production: true }));
11
11
  };
12
+ const args = {
13
+ binaries: ['drizzle-kit'],
14
+ config: ['config'],
15
+ };
12
16
  const plugin = {
13
17
  title,
14
18
  enablers,
15
19
  isEnabled,
16
20
  config,
17
21
  resolveConfig,
22
+ args,
18
23
  };
19
24
  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;
@@ -158,6 +158,7 @@ export declare const Plugins: {
158
158
  'solidjs-vite-plugin': import("../types/config.ts").Plugin;
159
159
  sst: import("../types/config.ts").Plugin;
160
160
  starlight: import("../types/config.ts").Plugin;
161
+ 'start-server-and-test': import("../types/config.ts").Plugin;
161
162
  stencil: import("../types/config.ts").Plugin;
162
163
  storybook: import("../types/config.ts").Plugin;
163
164
  stryker: import("../types/config.ts").Plugin;
@@ -176,6 +177,7 @@ export declare const Plugins: {
176
177
  temporal: import("../types/config.ts").Plugin;
177
178
  textlint: import("../types/config.ts").Plugin;
178
179
  travis: import("../types/config.ts").Plugin;
180
+ 'trigger-dev': import("../types/config.ts").Plugin;
179
181
  'ts-node': import("../types/config.ts").Plugin;
180
182
  tsd: import("../types/config.ts").Plugin;
181
183
  tsdown: import("../types/config.ts").Plugin;
@@ -152,6 +152,7 @@ import { default as sizeLimit } from './size-limit/index.js';
152
152
  import { default as solidjsVitePlugin } from './solidjs-vite-plugin/index.js';
153
153
  import { default as sst } from './sst/index.js';
154
154
  import { default as starlight } from './starlight/index.js';
155
+ import { default as startServerAndTest } from './start-server-and-test/index.js';
155
156
  import { default as stencil } from './stencil/index.js';
156
157
  import { default as storybook } from './storybook/index.js';
157
158
  import { default as stryker } from './stryker/index.js';
@@ -170,6 +171,7 @@ import { default as tauri } from './tauri/index.js';
170
171
  import { default as temporal } from './temporal/index.js';
171
172
  import { default as textlint } from './textlint/index.js';
172
173
  import { default as travis } from './travis/index.js';
174
+ import { default as triggerDev } from './trigger-dev/index.js';
173
175
  import { default as tsNode } from './ts-node/index.js';
174
176
  import { default as tsd } from './tsd/index.js';
175
177
  import { default as tsdown } from './tsdown/index.js';
@@ -366,6 +368,7 @@ export const Plugins = {
366
368
  'solidjs-vite-plugin': solidjsVitePlugin,
367
369
  sst,
368
370
  starlight,
371
+ 'start-server-and-test': startServerAndTest,
369
372
  stencil,
370
373
  storybook,
371
374
  stryker,
@@ -384,6 +387,7 @@ export const Plugins = {
384
387
  temporal,
385
388
  textlint,
386
389
  travis,
390
+ 'trigger-dev': triggerDev,
387
391
  'ts-node': tsNode,
388
392
  tsd,
389
393
  tsdown,
@@ -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[];
@@ -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,