knip 6.31.0 → 6.32.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.
Files changed (59) hide show
  1. package/dist/ConfigurationChief.d.ts +18 -0
  2. package/dist/DependencyDeputy.d.ts +2 -1
  3. package/dist/DependencyDeputy.js +2 -2
  4. package/dist/WorkspaceWorker.js +12 -14
  5. package/dist/binaries/bash-parser.js +20 -8
  6. package/dist/binaries/fallback.js +6 -4
  7. package/dist/binaries/plugins.js +8 -4
  8. package/dist/binaries/resolvers/bun.js +7 -7
  9. package/dist/binaries/resolvers/bunx.d.ts +2 -1
  10. package/dist/binaries/resolvers/bunx.js +10 -6
  11. package/dist/binaries/resolvers/find.js +5 -5
  12. package/dist/binaries/resolvers/npm.js +5 -5
  13. package/dist/binaries/resolvers/npx.js +3 -4
  14. package/dist/binaries/resolvers/nub.js +4 -4
  15. package/dist/binaries/resolvers/pnpm.js +12 -9
  16. package/dist/binaries/resolvers/pnpx.d.ts +2 -1
  17. package/dist/binaries/resolvers/pnpx.js +4 -4
  18. package/dist/binaries/resolvers/yarn.js +17 -13
  19. package/dist/binaries/util.d.ts +6 -4
  20. package/dist/binaries/util.js +25 -3
  21. package/dist/compilers/index.d.ts +30 -0
  22. package/dist/graph/analyze.js +1 -0
  23. package/dist/graph/build.js +1 -0
  24. package/dist/plugins/babel/types.d.ts +1 -0
  25. package/dist/plugins/borp/index.d.ts +3 -0
  26. package/dist/plugins/borp/index.js +61 -0
  27. package/dist/plugins/borp/types.d.ts +4 -0
  28. package/dist/plugins/borp/types.js +1 -0
  29. package/dist/plugins/docusaurus/index.js +3 -4
  30. package/dist/plugins/expo/index.js +3 -1
  31. package/dist/plugins/index.d.ts +3 -0
  32. package/dist/plugins/index.js +6 -0
  33. package/dist/plugins/jest/index.js +6 -2
  34. package/dist/plugins/mocha/index.js +59 -0
  35. package/dist/plugins/playwright/index.js +1 -1
  36. package/dist/plugins/pre-commit/index.d.ts +3 -0
  37. package/dist/plugins/pre-commit/index.js +23 -0
  38. package/dist/plugins/rollup/index.js +5 -1
  39. package/dist/plugins/tsd/index.d.ts +3 -0
  40. package/dist/plugins/tsd/index.js +43 -0
  41. package/dist/plugins/tsd/types.d.ts +4 -0
  42. package/dist/plugins/tsd/types.js +1 -0
  43. package/dist/schema/configuration.d.ts +45 -0
  44. package/dist/schema/plugins.d.ts +15 -0
  45. package/dist/schema/plugins.js +3 -0
  46. package/dist/types/PluginNames.d.ts +2 -2
  47. package/dist/types/PluginNames.js +3 -0
  48. package/dist/types/config.d.ts +4 -2
  49. package/dist/util/create-input-handler.js +2 -0
  50. package/dist/util/create-options.d.ts +30 -0
  51. package/dist/util/package-json.d.ts +3 -0
  52. package/dist/util/package-json.js +6 -2
  53. package/dist/util/parse-args.d.ts +2 -1
  54. package/dist/util/parse-args.js +8 -1
  55. package/dist/util/scripts.js +9 -5
  56. package/dist/version.d.ts +1 -1
  57. package/dist/version.js +1 -1
  58. package/package.json +3 -3
  59. package/schema.json +12 -0
@@ -1,8 +1,30 @@
1
1
  import parseArgs from '../util/parse-args.js';
2
- export const argsFrom = (args, from) => args.slice(args.indexOf(from));
2
+ const valueOf = (arg) => (typeof arg === 'string' ? arg : arg.value);
3
+ export const argsFrom = (args, from) => args.slice(args.findIndex(arg => valueOf(arg) === from));
3
4
  export const argsAfter = (args, token) => {
4
- const index = args.indexOf(token);
5
- return index === -1 ? [] : args.slice(index + 1).filter(arg => arg !== '--');
5
+ const index = args.findIndex(arg => valueOf(arg) === token);
6
+ return index === -1 ? [] : args.slice(index + 1).filter(arg => valueOf(arg) !== '--');
7
+ };
8
+ export const toWordArgs = (values, words) => {
9
+ const args = [];
10
+ let cursor = 0;
11
+ for (const value of values) {
12
+ const str = String(value);
13
+ let match = -1;
14
+ for (let index = cursor; index < words.length; index++) {
15
+ if (words[index].value === str) {
16
+ match = index;
17
+ break;
18
+ }
19
+ }
20
+ if (match === -1)
21
+ args.push(str);
22
+ else {
23
+ args.push(words[match]);
24
+ cursor = match + 1;
25
+ }
26
+ }
27
+ return args;
6
28
  };
7
29
  export const expandScript = (name, forwardedArgs, scripts, options, opts = {}) => {
8
30
  const source = scripts?.[name];
@@ -43,6 +43,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
43
43
  entry?: string | string[] | undefined;
44
44
  project?: string | string[] | undefined;
45
45
  } | undefined;
46
+ borp?: string | boolean | string[] | {
47
+ config?: string | string[] | undefined;
48
+ entry?: string | string[] | undefined;
49
+ project?: string | string[] | undefined;
50
+ } | undefined;
46
51
  bumpp?: string | boolean | string[] | {
47
52
  config?: string | string[] | undefined;
48
53
  entry?: string | string[] | undefined;
@@ -498,6 +503,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
498
503
  entry?: string | string[] | undefined;
499
504
  project?: string | string[] | undefined;
500
505
  } | undefined;
506
+ 'pre-commit'?: string | boolean | string[] | {
507
+ config?: string | string[] | undefined;
508
+ entry?: string | string[] | undefined;
509
+ project?: string | string[] | undefined;
510
+ } | undefined;
501
511
  preconstruct?: string | boolean | string[] | {
502
512
  config?: string | string[] | undefined;
503
513
  entry?: string | string[] | undefined;
@@ -728,6 +738,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
728
738
  entry?: string | string[] | undefined;
729
739
  project?: string | string[] | undefined;
730
740
  } | undefined;
741
+ tsd?: string | boolean | string[] | {
742
+ config?: string | string[] | undefined;
743
+ entry?: string | string[] | undefined;
744
+ project?: string | string[] | undefined;
745
+ } | undefined;
731
746
  tsdown?: string | boolean | string[] | {
732
747
  config?: string | string[] | undefined;
733
748
  entry?: string | string[] | undefined;
@@ -964,6 +979,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
964
979
  entry?: string | string[] | undefined;
965
980
  project?: string | string[] | undefined;
966
981
  } | undefined;
982
+ borp?: string | boolean | string[] | {
983
+ config?: string | string[] | undefined;
984
+ entry?: string | string[] | undefined;
985
+ project?: string | string[] | undefined;
986
+ } | undefined;
967
987
  bumpp?: string | boolean | string[] | {
968
988
  config?: string | string[] | undefined;
969
989
  entry?: string | string[] | undefined;
@@ -1419,6 +1439,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1419
1439
  entry?: string | string[] | undefined;
1420
1440
  project?: string | string[] | undefined;
1421
1441
  } | undefined;
1442
+ 'pre-commit'?: string | boolean | string[] | {
1443
+ config?: string | string[] | undefined;
1444
+ entry?: string | string[] | undefined;
1445
+ project?: string | string[] | undefined;
1446
+ } | undefined;
1422
1447
  preconstruct?: string | boolean | string[] | {
1423
1448
  config?: string | string[] | undefined;
1424
1449
  entry?: string | string[] | undefined;
@@ -1649,6 +1674,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1649
1674
  entry?: string | string[] | undefined;
1650
1675
  project?: string | string[] | undefined;
1651
1676
  } | undefined;
1677
+ tsd?: string | boolean | string[] | {
1678
+ config?: string | string[] | undefined;
1679
+ entry?: string | string[] | undefined;
1680
+ project?: string | string[] | undefined;
1681
+ } | undefined;
1652
1682
  tsdown?: string | boolean | string[] | {
1653
1683
  config?: string | string[] | undefined;
1654
1684
  entry?: string | string[] | undefined;
@@ -196,6 +196,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
196
196
  const packageName = getPackageNameFromModuleSpecifier(extImport.specifier);
197
197
  const isHandled = packageName &&
198
198
  deputy.maybeAddReferencedExternalDependency(ws, packageName, {
199
+ specifier: extImport.specifier,
199
200
  isTypeOnly: extImport.isTypeOnly,
200
201
  isResolved: extImport.filePath !== undefined,
201
202
  });
@@ -117,6 +117,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
117
117
  if (getPublishedTypeDependencies && !manifest.private && !manifest.publishConfig?.directory) {
118
118
  for (const dependency of getPublishedTypeDependencies(workspace, manifest)) {
119
119
  const isHandled = deputy.maybeAddReferencedExternalDependency(workspace, dependency.packageName, {
120
+ specifier: dependency.specifier,
120
121
  isTypeOnly: true,
121
122
  isResolved: dependency.isResolved,
122
123
  isPublishedType: true,
@@ -1,6 +1,7 @@
1
1
  import type { api } from './helpers.ts';
2
2
  type BabelConfigFn = (options: typeof api) => BabelConfigObj;
3
3
  export type BabelConfigObj = {
4
+ configFile?: string;
4
5
  plugins?: (string | [string, unknown])[];
5
6
  presets?: (string | [string, unknown])[];
6
7
  env?: Record<string, BabelConfigObj>;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,61 @@
1
+ import { toDeferResolve, toEntry } from '../../util/input.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ const title = 'Borp';
4
+ const enablers = ['borp'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['.borp.yaml', '.borp.yml'];
7
+ const entry = ['**/*.test.{js,mjs,cjs,ts,mts,cts}'];
8
+ const builtinReporters = new Set(['spec', 'tap', 'dot', 'junit', 'lcov', 'gh']);
9
+ const toReporterInput = (reporter) => {
10
+ const separatorIndex = reporter.indexOf(':');
11
+ const name = separatorIndex === -1 ? reporter : reporter.slice(0, separatorIndex);
12
+ if (builtinReporters.has(name))
13
+ return;
14
+ return toDeferResolve(name);
15
+ };
16
+ const resolveConfig = async (localConfig) => {
17
+ const inputs = [];
18
+ for (const reporter of localConfig.reporters ?? []) {
19
+ const input = toReporterInput(reporter);
20
+ if (input)
21
+ inputs.push(input);
22
+ }
23
+ for (const id of localConfig.files ?? entry)
24
+ inputs.push(toEntry(id));
25
+ return inputs;
26
+ };
27
+ const args = {
28
+ boolean: ['coverage', 'watch', 'only', 'no-timeout', 'expose-gc', 'check-coverage', 'coverage-html'],
29
+ alias: {
30
+ coverage: ['C'],
31
+ watch: ['w'],
32
+ only: ['o'],
33
+ reporter: ['r'],
34
+ pattern: ['p'],
35
+ ignore: ['i'],
36
+ timeout: ['t'],
37
+ concurrency: ['c'],
38
+ 'coverage-exclude': ['X'],
39
+ },
40
+ resolveInputs: (parsed) => {
41
+ const inputs = [];
42
+ for (const reporter of [parsed.reporter ?? []].flat()) {
43
+ const input = toReporterInput(String(reporter));
44
+ if (input)
45
+ inputs.push(input);
46
+ }
47
+ for (const id of [...parsed._, parsed.pattern ?? []].flat())
48
+ inputs.push(toEntry(String(id)));
49
+ return inputs;
50
+ },
51
+ };
52
+ const plugin = {
53
+ title,
54
+ enablers,
55
+ isEnabled,
56
+ config,
57
+ entry,
58
+ resolveConfig,
59
+ args,
60
+ };
61
+ export default plugin;
@@ -0,0 +1,4 @@
1
+ export type BorpConfig = {
2
+ files?: string[];
3
+ reporters?: string[];
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { toAlias, toDependency, toEntry, toIgnore, toProductionEntry } from '../../util/input.js';
1
+ import { toAlias, toConfig, toDependency, toIgnore, toProductionEntry } from '../../util/input.js';
2
2
  import { join } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  import { CORE_CLIENT_API, resolveConfigItems } from './helpers.js';
@@ -7,7 +7,7 @@ const enablers = ['@docusaurus/core'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['docusaurus.config.{js,cjs,mjs,ts,cts,mts}'];
9
9
  const production = ['src/pages/**/*.{js,ts,jsx,tsx}', '{blog,docs}/**/*.mdx', 'versioned_docs/**/*.{mdx,jsx,tsx}'];
10
- const entry = ['babel.config.{js,cjs,mjs,cts}'];
10
+ const resolve = () => [toConfig('babel', 'babel.config')];
11
11
  const resolveStaticAssets = (items, cwd) => {
12
12
  const entries = [];
13
13
  for (const item of items ?? []) {
@@ -33,7 +33,6 @@ const resolveConfig = async (config, options) => {
33
33
  toIgnore('@generated/.*', 'dependencies'),
34
34
  ...(config.future?.experimental_faster ? [toDependency('@docusaurus/faster')] : []),
35
35
  ...production.map(id => toProductionEntry(id)),
36
- ...entry.map(id => toEntry(id)),
37
36
  ...themes,
38
37
  ...plugins,
39
38
  ...presets,
@@ -46,8 +45,8 @@ const plugin = {
46
45
  enablers,
47
46
  isEnabled,
48
47
  config,
49
- entry,
50
48
  production,
49
+ resolve,
51
50
  resolveConfig,
52
51
  };
53
52
  export default plugin;
@@ -1,4 +1,4 @@
1
- import { toProductionEntry } from '../../util/input.js';
1
+ import { toConfig, toIgnore, toProductionEntry } from '../../util/input.js';
2
2
  import { join } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  import { getConfig, getDependencies } from './helpers.js';
@@ -7,6 +7,7 @@ const enablers = ['expo'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['app.json', 'app.config.{ts,js}'];
9
9
  const production = ['app/**/*.{js,jsx,ts,tsx}', 'src/app/**/*.{js,jsx,ts,tsx}'];
10
+ const resolve = () => [toConfig('babel', 'babel.config'), toIgnore('babel-preset-expo', 'unresolved')];
10
11
  const resolveConfig = async (localConfig, options) => {
11
12
  const { manifest } = options;
12
13
  const config = getConfig(localConfig, options);
@@ -30,6 +31,7 @@ const plugin = {
30
31
  isEnabled,
31
32
  config,
32
33
  production,
34
+ resolve,
33
35
  resolveConfig,
34
36
  };
35
37
  export default plugin;
@@ -7,6 +7,7 @@ export declare const Plugins: {
7
7
  ava: import("../types/config.ts").Plugin;
8
8
  babel: import("../types/config.ts").Plugin;
9
9
  biome: import("../types/config.ts").Plugin;
10
+ borp: import("../types/config.ts").Plugin;
10
11
  bumpp: import("../types/config.ts").Plugin;
11
12
  bun: import("../types/config.ts").Plugin;
12
13
  c8: import("../types/config.ts").Plugin;
@@ -103,6 +104,7 @@ export declare const Plugins: {
103
104
  pm2: import("../types/config.ts").Plugin;
104
105
  pnpm: import("../types/config.ts").Plugin;
105
106
  postcss: import("../types/config.ts").Plugin;
107
+ 'pre-commit': import("../types/config.ts").Plugin;
106
108
  preconstruct: import("../types/config.ts").Plugin;
107
109
  prettier: import("../types/config.ts").Plugin;
108
110
  prisma: import("../types/config.ts").Plugin;
@@ -149,6 +151,7 @@ export declare const Plugins: {
149
151
  temporal: import("../types/config.ts").Plugin;
150
152
  travis: import("../types/config.ts").Plugin;
151
153
  'ts-node': import("../types/config.ts").Plugin;
154
+ tsd: import("../types/config.ts").Plugin;
152
155
  tsdown: import("../types/config.ts").Plugin;
153
156
  tsup: import("../types/config.ts").Plugin;
154
157
  tsx: import("../types/config.ts").Plugin;
@@ -6,6 +6,7 @@ import { default as astroOgCanvas } from './astro-og-canvas/index.js';
6
6
  import { default as ava } from './ava/index.js';
7
7
  import { default as babel } from './babel/index.js';
8
8
  import { default as biome } from './biome/index.js';
9
+ import { default as borp } from './borp/index.js';
9
10
  import { default as bumpp } from './bumpp/index.js';
10
11
  import { default as bun } from './bun/index.js';
11
12
  import { default as c8 } from './c8/index.js';
@@ -97,6 +98,7 @@ import { default as plop } from './plop/index.js';
97
98
  import { default as pm2 } from './pm2/index.js';
98
99
  import { default as pnpm } from './pnpm/index.js';
99
100
  import { default as postcss } from './postcss/index.js';
101
+ import { default as preCommit } from './pre-commit/index.js';
100
102
  import { default as preconstruct } from './preconstruct/index.js';
101
103
  import { default as prettier } from './prettier/index.js';
102
104
  import { default as prisma } from './prisma/index.js';
@@ -143,6 +145,7 @@ import { default as tauri } from './tauri/index.js';
143
145
  import { default as temporal } from './temporal/index.js';
144
146
  import { default as travis } from './travis/index.js';
145
147
  import { default as tsNode } from './ts-node/index.js';
148
+ import { default as tsd } from './tsd/index.js';
146
149
  import { default as tsdown } from './tsdown/index.js';
147
150
  import { default as tsup } from './tsup/index.js';
148
151
  import { default as tsx } from './tsx/index.js';
@@ -186,6 +189,7 @@ export const Plugins = {
186
189
  ava,
187
190
  babel,
188
191
  biome,
192
+ borp,
189
193
  bumpp,
190
194
  bun,
191
195
  c8,
@@ -277,6 +281,7 @@ export const Plugins = {
277
281
  pm2,
278
282
  pnpm,
279
283
  postcss,
284
+ 'pre-commit': preCommit,
280
285
  preconstruct,
281
286
  prettier,
282
287
  prisma,
@@ -323,6 +328,7 @@ export const Plugins = {
323
328
  temporal,
324
329
  travis,
325
330
  'ts-node': tsNode,
331
+ tsd,
326
332
  tsdown,
327
333
  tsup,
328
334
  tsx,
@@ -1,6 +1,6 @@
1
1
  import { arrayify } from '../../util/array.js';
2
2
  import { _glob, _dirGlob } from '../../util/glob.js';
3
- import { toDeferResolve, toEntry } from '../../util/input.js';
3
+ import { toConfig, toDeferResolve, toEntry } from '../../util/input.js';
4
4
  import { isInternal, join, normalize, toAbsolute } from '../../util/path.js';
5
5
  import { hasDependency } from '../../util/plugin.js';
6
6
  import { getDependenciesFromConfig } from '../babel/index.js';
@@ -55,8 +55,12 @@ const resolveDependencies = async (config, rootDir, options) => {
55
55
  }
56
56
  else {
57
57
  transform.push(transformer[0]);
58
- if (isBabelJest(transformer))
58
+ if (isBabelJest(transformer)) {
59
59
  transform.push(...getDependenciesFromConfig(transformer[1]));
60
+ const { configFile } = transformer[1];
61
+ if (typeof configFile === 'string')
62
+ transform.push(toConfig('babel', rootDirRe.test(configFile) ? configFile : toAbsolute(configFile, options.cwd)));
63
+ }
60
64
  }
61
65
  }
62
66
  const moduleNameMapper = (config.moduleNameMapper
@@ -1,10 +1,12 @@
1
1
  import { toDeferResolve, toEntry } from '../../util/input.js';
2
+ import { isDirectory } from '../../util/fs.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
4
  const title = 'Mocha';
4
5
  const enablers = ['mocha'];
5
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
7
  const config = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
7
8
  const entry = ['**/test/*.{js,cjs,mjs}'];
9
+ const defaultExtensions = ['js', 'cjs', 'mjs'];
8
10
  const resolveConfig = localConfig => {
9
11
  const entryPatterns = localConfig.spec ? [localConfig.spec].flat() : entry;
10
12
  const require = localConfig.require ? [localConfig.require].flat() : [];
@@ -15,6 +17,63 @@ const resolveConfig = localConfig => {
15
17
  };
16
18
  const args = {
17
19
  nodeImportArgs: true,
20
+ boolean: [
21
+ 'allow-uncaught',
22
+ 'async-only',
23
+ 'bail',
24
+ 'check-leaks',
25
+ 'colors',
26
+ 'delay',
27
+ 'diff',
28
+ 'dry-run',
29
+ 'exit',
30
+ 'forbid-only',
31
+ 'forbid-pending',
32
+ 'inline-diffs',
33
+ 'invert',
34
+ 'parallel',
35
+ 'recursive',
36
+ 'sort',
37
+ 'watch',
38
+ ],
39
+ alias: {
40
+ 'async-only': ['A'],
41
+ bail: ['b'],
42
+ colors: ['c'],
43
+ fgrep: ['f'],
44
+ grep: ['g'],
45
+ invert: ['i'],
46
+ jobs: ['j'],
47
+ 'node-option': ['n'],
48
+ parallel: ['p'],
49
+ reporter: ['R'],
50
+ 'reporter-option': ['O'],
51
+ slow: ['s'],
52
+ sort: ['S'],
53
+ timeout: ['t'],
54
+ ui: ['u'],
55
+ watch: ['w'],
56
+ },
57
+ string: ['config', 'extension', 'fgrep', 'file', 'grep', 'ignore', 'package', 'reporter', 'spec', 'ui'],
58
+ config: ['config'],
59
+ resolveInputs: (parsed, { cwd }) => {
60
+ const extensions = [parsed.extension ?? []]
61
+ .flat()
62
+ .flatMap(value => String(value).split(','))
63
+ .map(extension => extension.replace(/^\./, ''));
64
+ const list = extensions.length > 0 ? extensions : defaultExtensions;
65
+ const suffix = list.length === 1 ? `*.${list[0]}` : `*.{${list.join(',')}}`;
66
+ const inputs = [];
67
+ for (const value of [...parsed._, ...[parsed.spec ?? []].flat(), ...[parsed.file ?? []].flat()].map(String)) {
68
+ if (isDirectory(cwd, value))
69
+ inputs.push(toEntry(`${value.replace(/\/$/, '')}/${parsed.recursive ? '**/' : ''}${suffix}`));
70
+ else
71
+ inputs.push(toEntry(value));
72
+ }
73
+ for (const value of [parsed.ignore ?? []].flat())
74
+ inputs.push(toEntry(`!${String(value)}`));
75
+ return inputs;
76
+ },
18
77
  };
19
78
  const plugin = {
20
79
  title,
@@ -5,7 +5,7 @@ import { hasDependency } from '../../util/plugin.js';
5
5
  const title = 'Playwright';
6
6
  const enablers = ['@playwright/test'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
- const config = ['playwright.config.{js,ts,mjs}'];
8
+ const config = ['playwright.config.{js,cjs,mjs,ts,cts,mts}'];
9
9
  export const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
10
10
  const toEntryPatterns = (testMatch, cwd, configDir, localConfig, rootConfig) => {
11
11
  const testDir = localConfig.testDir ?? rootConfig.testDir;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,23 @@
1
+ import { toDependency } from '../../util/input.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ const title = 'pre-commit';
4
+ const packages = ['pre-commit', '@fastify/pre-commit'];
5
+ const enablers = packages;
6
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
+ const isRootOnly = true;
8
+ const resolve = options => {
9
+ const { dependencies, devDependencies } = options.manifest;
10
+ const inputs = [];
11
+ for (const name of packages)
12
+ if (dependencies?.[name] || devDependencies?.[name])
13
+ inputs.push(toDependency(name));
14
+ return inputs;
15
+ };
16
+ const plugin = {
17
+ title,
18
+ enablers,
19
+ isEnabled,
20
+ isRootOnly,
21
+ resolve,
22
+ };
23
+ export default plugin;
@@ -7,7 +7,11 @@ 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
- args: (args) => args.map(arg => (arg.startsWith('--watch.onEnd') ? `--_exec${arg.slice(13)}` : arg)),
10
+ string: ['config'],
11
+ config: ['config'],
12
+ args: (args) => args
13
+ .filter((arg, index) => !(arg === '--config' && (args[index + 1] === undefined || args[index + 1].startsWith('-'))))
14
+ .map(arg => (arg.startsWith('--watch.onEnd') ? `--_exec${arg.slice(13)}` : arg)),
11
15
  fromArgs: ['_exec'],
12
16
  resolve: ['plugin', 'configPlugin'],
13
17
  };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,43 @@
1
+ import { toEntry } from '../../util/input.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ const title = 'tsd';
4
+ const enablers = ['tsd'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['package.json'];
7
+ const entry = ['*.test-d.{ts,tsx}', 'test-d/**/*.test-d.{ts,tsx}'];
8
+ const resolveConfig = async (localConfig) => {
9
+ const inputs = [];
10
+ if (localConfig?.testFiles)
11
+ for (const id of localConfig.testFiles)
12
+ inputs.push(toEntry(id));
13
+ if (localConfig?.directory) {
14
+ inputs.push(toEntry('*.test-d.{ts,tsx}'));
15
+ inputs.push(toEntry(`${localConfig.directory}/**/*.test-d.{ts,tsx}`));
16
+ }
17
+ if (inputs.length === 0)
18
+ for (const id of entry)
19
+ inputs.push(toEntry(id));
20
+ return inputs;
21
+ };
22
+ const args = {
23
+ alias: { files: ['f'], typings: ['t'] },
24
+ string: ['files', 'typings'],
25
+ resolveInputs: (parsed) => {
26
+ const inputs = [];
27
+ for (const id of [parsed.files ?? []].flat())
28
+ inputs.push(toEntry(String(id)));
29
+ if (typeof parsed._[0] === 'string')
30
+ inputs.push(toEntry(`${parsed._[0]}/**/*.test-d.{ts,tsx}`));
31
+ return inputs;
32
+ },
33
+ };
34
+ const plugin = {
35
+ title,
36
+ enablers,
37
+ isEnabled,
38
+ config,
39
+ entry,
40
+ resolveConfig,
41
+ args,
42
+ };
43
+ export default plugin;
@@ -0,0 +1,4 @@
1
+ export type TsdConfig = {
2
+ directory?: string;
3
+ testFiles?: string[];
4
+ };
@@ -0,0 +1 @@
1
+ export {};