knip 5.41.1 → 5.42.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 (104) hide show
  1. package/README.md +1 -1
  2. package/dist/ConfigurationChief.d.ts +2 -0
  3. package/dist/ConfigurationValidator.d.ts +112 -0
  4. package/dist/IssueCollector.js +6 -4
  5. package/dist/ProjectPrincipal.js +2 -14
  6. package/dist/WorkspaceWorker.js +2 -3
  7. package/dist/binaries/package-manager/bun.js +8 -2
  8. package/dist/binaries/package-manager/bunx.d.ts +3 -0
  9. package/dist/binaries/package-manager/bunx.js +18 -0
  10. package/dist/binaries/package-manager/index.d.ts +2 -0
  11. package/dist/binaries/package-manager/index.js +4 -0
  12. package/dist/binaries/package-manager/npm.js +1 -2
  13. package/dist/binaries/package-manager/npx.js +7 -2
  14. package/dist/binaries/package-manager/pnpm.js +7 -1
  15. package/dist/binaries/package-manager/pnpx.d.ts +3 -0
  16. package/dist/binaries/package-manager/pnpx.js +18 -0
  17. package/dist/binaries/package-manager/yarn.js +4 -3
  18. package/dist/binaries/plugins.js +7 -2
  19. package/dist/compilers/index.d.ts +20 -0
  20. package/dist/constants.js +2 -0
  21. package/dist/index.js +27 -17
  22. package/dist/plugins/_template/index.js +1 -1
  23. package/dist/plugins/angular/index.js +59 -27
  24. package/dist/plugins/angular/types.d.ts +2 -2
  25. package/dist/plugins/capacitor/index.js +1 -1
  26. package/dist/plugins/changesets/index.js +1 -1
  27. package/dist/plugins/commitlint/index.js +1 -1
  28. package/dist/plugins/dependency-cruiser/index.d.ts +12 -0
  29. package/dist/plugins/dependency-cruiser/index.js +16 -0
  30. package/dist/plugins/expo/helpers.js +1 -1
  31. package/dist/plugins/expo/index.d.ts +3 -0
  32. package/dist/plugins/expo/index.js +6 -4
  33. package/dist/plugins/gatsby/index.js +1 -1
  34. package/dist/plugins/graphql-codegen/index.js +1 -1
  35. package/dist/plugins/index.d.ts +29 -11
  36. package/dist/plugins/index.js +4 -0
  37. package/dist/plugins/jest/index.d.ts +3 -0
  38. package/dist/plugins/jest/index.js +4 -0
  39. package/dist/plugins/karma/helpers.d.ts +7 -0
  40. package/dist/plugins/karma/helpers.js +32 -0
  41. package/dist/plugins/karma/index.d.ts +1 -2
  42. package/dist/plugins/karma/index.js +10 -36
  43. package/dist/plugins/lefthook/index.js +2 -2
  44. package/dist/plugins/linthtml/index.d.ts +2 -2
  45. package/dist/plugins/linthtml/types.d.ts +1 -1
  46. package/dist/plugins/markdownlint/index.js +1 -1
  47. package/dist/plugins/metro/index.d.ts +15 -0
  48. package/dist/plugins/metro/index.js +47 -0
  49. package/dist/plugins/metro/types.d.ts +13 -0
  50. package/dist/plugins/metro/types.js +1 -0
  51. package/dist/plugins/nest/index.js +1 -1
  52. package/dist/plugins/netlify/index.js +2 -2
  53. package/dist/plugins/npm-package-json-lint/index.js +1 -1
  54. package/dist/plugins/nuxt/index.d.ts +3 -1
  55. package/dist/plugins/nuxt/index.js +3 -3
  56. package/dist/plugins/nx/index.js +11 -3
  57. package/dist/plugins/nx/types.d.ts +1 -0
  58. package/dist/plugins/oclif/index.js +1 -1
  59. package/dist/plugins/prettier/index.js +1 -1
  60. package/dist/plugins/release-it/index.d.ts +0 -1
  61. package/dist/plugins/release-it/index.js +1 -3
  62. package/dist/plugins/semantic-release/index.js +7 -1
  63. package/dist/plugins/simple-git-hooks/index.d.ts +2 -3
  64. package/dist/plugins/simple-git-hooks/index.js +1 -9
  65. package/dist/plugins/simple-git-hooks/types.d.ts +1 -1
  66. package/dist/plugins/storybook/index.js +5 -1
  67. package/dist/plugins/typescript/index.d.ts +3 -1
  68. package/dist/plugins/typescript/index.js +2 -2
  69. package/dist/plugins/vite/index.d.ts +0 -1
  70. package/dist/plugins/vite/index.js +0 -2
  71. package/dist/plugins/vitest/index.js +1 -1
  72. package/dist/plugins/webdriver-io/index.js +1 -1
  73. package/dist/plugins/webpack/index.d.ts +4 -1
  74. package/dist/plugins/webpack/index.js +5 -2
  75. package/dist/plugins/wireit/index.d.ts +0 -1
  76. package/dist/plugins/wireit/index.js +0 -2
  77. package/dist/reporters/symbols.js +12 -3
  78. package/dist/schema/plugins.d.ts +46 -0
  79. package/dist/schema/plugins.js +2 -0
  80. package/dist/types/PluginNames.d.ts +2 -2
  81. package/dist/types/PluginNames.js +2 -0
  82. package/dist/types/config.d.ts +1 -2
  83. package/dist/types/dependency-graph.d.ts +2 -4
  84. package/dist/typescript/ast-helpers.d.ts +1 -0
  85. package/dist/typescript/ast-helpers.js +1 -0
  86. package/dist/typescript/get-imports-and-exports.d.ts +2 -4
  87. package/dist/typescript/get-imports-and-exports.js +18 -23
  88. package/dist/typescript/visitors/exports/exportAssignment.js +2 -1
  89. package/dist/typescript/visitors/exports/exportDeclaration.js +2 -1
  90. package/dist/typescript/visitors/exports/exportKeyword.js +3 -4
  91. package/dist/typescript/visitors/helpers.d.ts +2 -1
  92. package/dist/typescript/visitors/helpers.js +3 -2
  93. package/dist/typescript/visitors/scripts/bun.js +1 -1
  94. package/dist/typescript/visitors/scripts/execa.js +24 -1
  95. package/dist/util/dependency-graph.js +2 -4
  96. package/dist/util/file-entry-cache.js +2 -6
  97. package/dist/util/get-referenced-inputs.js +4 -2
  98. package/dist/util/input.d.ts +3 -1
  99. package/dist/util/input.js +5 -1
  100. package/dist/util/modules.js +1 -1
  101. package/dist/version.d.ts +1 -1
  102. package/dist/version.js +1 -1
  103. package/package.json +13 -12
  104. package/schema.json +8 -0
package/README.md CHANGED
@@ -28,7 +28,7 @@ less maintenance and easier refactorings.
28
28
 
29
29
  ## Contributors
30
30
 
31
- Special thanks to [the wonderful people who have contributed Knip][8]!
31
+ Special thanks to [the wonderful people who have contributed to Knip][8]!
32
32
 
33
33
  ## Knip
34
34
 
@@ -83,6 +83,7 @@ export declare class ConfigurationChief {
83
83
  cspell?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
84
84
  cucumber?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
85
85
  cypress?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
86
+ "dependency-cruiser"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
86
87
  dotenv?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
87
88
  drizzle?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
88
89
  eleventy?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -102,6 +103,7 @@ export declare class ConfigurationChief {
102
103
  "lockfile-lint"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
103
104
  "lost-pixel"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
104
105
  markdownlint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
106
+ metro?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
105
107
  mocha?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
106
108
  moonrepo?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
107
109
  msw?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -184,6 +184,19 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
184
184
  entry?: string | string[] | undefined;
185
185
  project?: string | string[] | undefined;
186
186
  }>]>>;
187
+ 'dependency-cruiser': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
188
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
189
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
190
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
191
+ }, "strip", z.ZodTypeAny, {
192
+ config?: string | string[] | undefined;
193
+ entry?: string | string[] | undefined;
194
+ project?: string | string[] | undefined;
195
+ }, {
196
+ config?: string | string[] | undefined;
197
+ entry?: string | string[] | undefined;
198
+ project?: string | string[] | undefined;
199
+ }>]>>;
187
200
  dotenv: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
188
201
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
189
202
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -431,6 +444,19 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
431
444
  entry?: string | string[] | undefined;
432
445
  project?: string | string[] | undefined;
433
446
  }>]>>;
447
+ metro: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
448
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
449
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
450
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
451
+ }, "strip", z.ZodTypeAny, {
452
+ config?: string | string[] | undefined;
453
+ entry?: string | string[] | undefined;
454
+ project?: string | string[] | undefined;
455
+ }, {
456
+ config?: string | string[] | undefined;
457
+ entry?: string | string[] | undefined;
458
+ project?: string | string[] | undefined;
459
+ }>]>>;
434
460
  mocha: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
435
461
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
436
462
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -1253,6 +1279,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
1253
1279
  entry?: string | string[] | undefined;
1254
1280
  project?: string | string[] | undefined;
1255
1281
  } | undefined;
1282
+ 'dependency-cruiser'?: string | boolean | string[] | {
1283
+ config?: string | string[] | undefined;
1284
+ entry?: string | string[] | undefined;
1285
+ project?: string | string[] | undefined;
1286
+ } | undefined;
1256
1287
  dotenv?: string | boolean | string[] | {
1257
1288
  config?: string | string[] | undefined;
1258
1289
  entry?: string | string[] | undefined;
@@ -1348,6 +1379,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
1348
1379
  entry?: string | string[] | undefined;
1349
1380
  project?: string | string[] | undefined;
1350
1381
  } | undefined;
1382
+ metro?: string | boolean | string[] | {
1383
+ config?: string | string[] | undefined;
1384
+ entry?: string | string[] | undefined;
1385
+ project?: string | string[] | undefined;
1386
+ } | undefined;
1351
1387
  mocha?: string | boolean | string[] | {
1352
1388
  config?: string | string[] | undefined;
1353
1389
  entry?: string | string[] | undefined;
@@ -1707,6 +1743,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
1707
1743
  entry?: string | string[] | undefined;
1708
1744
  project?: string | string[] | undefined;
1709
1745
  } | undefined;
1746
+ 'dependency-cruiser'?: string | boolean | string[] | {
1747
+ config?: string | string[] | undefined;
1748
+ entry?: string | string[] | undefined;
1749
+ project?: string | string[] | undefined;
1750
+ } | undefined;
1710
1751
  dotenv?: string | boolean | string[] | {
1711
1752
  config?: string | string[] | undefined;
1712
1753
  entry?: string | string[] | undefined;
@@ -1802,6 +1843,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
1802
1843
  entry?: string | string[] | undefined;
1803
1844
  project?: string | string[] | undefined;
1804
1845
  } | undefined;
1846
+ metro?: string | boolean | string[] | {
1847
+ config?: string | string[] | undefined;
1848
+ entry?: string | string[] | undefined;
1849
+ project?: string | string[] | undefined;
1850
+ } | undefined;
1805
1851
  mocha?: string | boolean | string[] | {
1806
1852
  config?: string | string[] | undefined;
1807
1853
  entry?: string | string[] | undefined;
@@ -2251,6 +2297,19 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
2251
2297
  entry?: string | string[] | undefined;
2252
2298
  project?: string | string[] | undefined;
2253
2299
  }>]>>;
2300
+ 'dependency-cruiser': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
2301
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2302
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2303
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2304
+ }, "strip", z.ZodTypeAny, {
2305
+ config?: string | string[] | undefined;
2306
+ entry?: string | string[] | undefined;
2307
+ project?: string | string[] | undefined;
2308
+ }, {
2309
+ config?: string | string[] | undefined;
2310
+ entry?: string | string[] | undefined;
2311
+ project?: string | string[] | undefined;
2312
+ }>]>>;
2254
2313
  dotenv: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
2255
2314
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2256
2315
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -2498,6 +2557,19 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
2498
2557
  entry?: string | string[] | undefined;
2499
2558
  project?: string | string[] | undefined;
2500
2559
  }>]>>;
2560
+ metro: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
2561
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2562
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2563
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2564
+ }, "strip", z.ZodTypeAny, {
2565
+ config?: string | string[] | undefined;
2566
+ entry?: string | string[] | undefined;
2567
+ project?: string | string[] | undefined;
2568
+ }, {
2569
+ config?: string | string[] | undefined;
2570
+ entry?: string | string[] | undefined;
2571
+ project?: string | string[] | undefined;
2572
+ }>]>>;
2501
2573
  mocha: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
2502
2574
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2503
2575
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -3322,6 +3394,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
3322
3394
  entry?: string | string[] | undefined;
3323
3395
  project?: string | string[] | undefined;
3324
3396
  } | undefined;
3397
+ 'dependency-cruiser'?: string | boolean | string[] | {
3398
+ config?: string | string[] | undefined;
3399
+ entry?: string | string[] | undefined;
3400
+ project?: string | string[] | undefined;
3401
+ } | undefined;
3325
3402
  dotenv?: string | boolean | string[] | {
3326
3403
  config?: string | string[] | undefined;
3327
3404
  entry?: string | string[] | undefined;
@@ -3417,6 +3494,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
3417
3494
  entry?: string | string[] | undefined;
3418
3495
  project?: string | string[] | undefined;
3419
3496
  } | undefined;
3497
+ metro?: string | boolean | string[] | {
3498
+ config?: string | string[] | undefined;
3499
+ entry?: string | string[] | undefined;
3500
+ project?: string | string[] | undefined;
3501
+ } | undefined;
3420
3502
  mocha?: string | boolean | string[] | {
3421
3503
  config?: string | string[] | undefined;
3422
3504
  entry?: string | string[] | undefined;
@@ -3782,6 +3864,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
3782
3864
  entry?: string | string[] | undefined;
3783
3865
  project?: string | string[] | undefined;
3784
3866
  } | undefined;
3867
+ 'dependency-cruiser'?: string | boolean | string[] | {
3868
+ config?: string | string[] | undefined;
3869
+ entry?: string | string[] | undefined;
3870
+ project?: string | string[] | undefined;
3871
+ } | undefined;
3785
3872
  dotenv?: string | boolean | string[] | {
3786
3873
  config?: string | string[] | undefined;
3787
3874
  entry?: string | string[] | undefined;
@@ -3877,6 +3964,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
3877
3964
  entry?: string | string[] | undefined;
3878
3965
  project?: string | string[] | undefined;
3879
3966
  } | undefined;
3967
+ metro?: string | boolean | string[] | {
3968
+ config?: string | string[] | undefined;
3969
+ entry?: string | string[] | undefined;
3970
+ project?: string | string[] | undefined;
3971
+ } | undefined;
3880
3972
  mocha?: string | boolean | string[] | {
3881
3973
  config?: string | string[] | undefined;
3882
3974
  entry?: string | string[] | undefined;
@@ -4239,6 +4331,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4239
4331
  entry?: string | string[] | undefined;
4240
4332
  project?: string | string[] | undefined;
4241
4333
  } | undefined;
4334
+ 'dependency-cruiser'?: string | boolean | string[] | {
4335
+ config?: string | string[] | undefined;
4336
+ entry?: string | string[] | undefined;
4337
+ project?: string | string[] | undefined;
4338
+ } | undefined;
4242
4339
  dotenv?: string | boolean | string[] | {
4243
4340
  config?: string | string[] | undefined;
4244
4341
  entry?: string | string[] | undefined;
@@ -4334,6 +4431,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4334
4431
  entry?: string | string[] | undefined;
4335
4432
  project?: string | string[] | undefined;
4336
4433
  } | undefined;
4434
+ metro?: string | boolean | string[] | {
4435
+ config?: string | string[] | undefined;
4436
+ entry?: string | string[] | undefined;
4437
+ project?: string | string[] | undefined;
4438
+ } | undefined;
4337
4439
  mocha?: string | boolean | string[] | {
4338
4440
  config?: string | string[] | undefined;
4339
4441
  entry?: string | string[] | undefined;
@@ -4699,6 +4801,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4699
4801
  entry?: string | string[] | undefined;
4700
4802
  project?: string | string[] | undefined;
4701
4803
  } | undefined;
4804
+ 'dependency-cruiser'?: string | boolean | string[] | {
4805
+ config?: string | string[] | undefined;
4806
+ entry?: string | string[] | undefined;
4807
+ project?: string | string[] | undefined;
4808
+ } | undefined;
4702
4809
  dotenv?: string | boolean | string[] | {
4703
4810
  config?: string | string[] | undefined;
4704
4811
  entry?: string | string[] | undefined;
@@ -4794,6 +4901,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4794
4901
  entry?: string | string[] | undefined;
4795
4902
  project?: string | string[] | undefined;
4796
4903
  } | undefined;
4904
+ metro?: string | boolean | string[] | {
4905
+ config?: string | string[] | undefined;
4906
+ entry?: string | string[] | undefined;
4907
+ project?: string | string[] | undefined;
4908
+ } | undefined;
4797
4909
  mocha?: string | boolean | string[] | {
4798
4910
  config?: string | string[] | undefined;
4799
4911
  entry?: string | string[] | undefined;
@@ -51,11 +51,13 @@ export class IssueCollector {
51
51
  if (this.isMatch(issue.filePath))
52
52
  return;
53
53
  const key = relative(this.cwd, issue.filePath);
54
- issue.severity = this.rules[issue.type];
55
- const issues = this.issues[issue.type];
54
+ const { type } = issue;
55
+ issue.severity = this.rules[type];
56
+ const issues = this.issues[type];
56
57
  issues[key] = issues[key] ?? {};
57
- if (!issues[key][issue.symbol]) {
58
- issues[key][issue.symbol] = issue;
58
+ const symbol = type.endsWith('Members') && issue.parentSymbol ? `${issue.parentSymbol}.${issue.symbol}` : issue.symbol;
59
+ if (!issues[key][symbol]) {
60
+ issues[key][symbol] = issue;
59
61
  this.counters[issue.type]++;
60
62
  }
61
63
  return issue;
@@ -155,10 +155,7 @@ export class ProjectPrincipal {
155
155
  throw new Error(`Unable to find ${filePath}`);
156
156
  const skipExports = this.skipExportsAnalysis.has(filePath);
157
157
  const resolve = (specifier) => this.backend.resolveModuleNames([specifier], sourceFile.fileName)[0];
158
- const { imports, exports, scripts, traceRefs } = _getImportsAndExports(sourceFile, resolve, typeChecker, {
159
- ...options,
160
- skipExports,
161
- });
158
+ const { imports, ...rest } = _getImportsAndExports(sourceFile, resolve, typeChecker, { ...options, skipExports });
162
159
  const { internal, resolved, specifiers, unresolved, external } = imports;
163
160
  const unresolvedImports = new Set();
164
161
  for (const [specifier, specifierFilePath] of specifiers) {
@@ -194,16 +191,7 @@ export class ProjectPrincipal {
194
191
  }
195
192
  }
196
193
  }
197
- return {
198
- imports: {
199
- internal,
200
- unresolved: unresolvedImports,
201
- external,
202
- },
203
- exports,
204
- scripts,
205
- traceRefs,
206
- };
194
+ return { imports: { internal, unresolved: unresolvedImports, external }, ...rest };
207
195
  }
208
196
  invalidateFile(filePath) {
209
197
  this.backend.fileManager.snapshotCache.delete(filePath);
@@ -201,7 +201,6 @@ export class WorkspaceWorker {
201
201
  const plugin = Plugins[pluginName];
202
202
  const hasResolveEntryPaths = typeof plugin.resolveEntryPaths === 'function';
203
203
  const hasResolveConfig = typeof plugin.resolveConfig === 'function';
204
- const shouldRunConfigResolver = hasResolveConfig && (!isProduction || (isProduction && 'production' in plugin));
205
204
  const hasResolve = typeof plugin.resolve === 'function';
206
205
  const config = this.getConfigForPlugin(pluginName);
207
206
  if (!config)
@@ -228,7 +227,7 @@ export class WorkspaceWorker {
228
227
  configFileDir: dirname(configFilePath),
229
228
  configFileName: basename(configFilePath),
230
229
  };
231
- if (hasResolveEntryPaths || shouldRunConfigResolver) {
230
+ if (hasResolveEntryPaths || hasResolveConfig) {
232
231
  const isManifest = basename(configFilePath) === 'package.json';
233
232
  const fd = isManifest ? undefined : this.cache.getFileDescriptor(configFilePath);
234
233
  if (fd?.meta?.data && !fd.changed) {
@@ -249,7 +248,7 @@ export class WorkspaceWorker {
249
248
  configEntryPaths.push(entryPath);
250
249
  data.resolveEntryPaths = entryPaths;
251
250
  }
252
- if (shouldRunConfigResolver) {
251
+ if (hasResolveConfig) {
253
252
  const inputs = (await plugin.resolveConfig?.(config, opts)) ?? [];
254
253
  for (const input of inputs) {
255
254
  if (isConfigPattern(input))
@@ -2,10 +2,16 @@ import parseArgs from 'minimist';
2
2
  import { isFile } from '../../util/fs.js';
3
3
  import { toEntry } from '../../util/input.js';
4
4
  import { isAbsolute, join } from '../../util/path.js';
5
- const commands = ['add', 'create', 'init', 'install', 'link', 'pm', 'remove', 'run', 'test', 'update', 'upgrade'];
6
- export const resolve = (_binary, args, { manifestScriptNames, cwd, fromArgs }) => {
5
+ import { resolveX } from './bunx.js';
6
+ const commands = ['add', 'create', 'init', 'install', 'link', 'pm', 'remove', 'run', 'test', 'update', 'upgrade', 'x'];
7
+ export const resolve = (_binary, args, options) => {
7
8
  const parsed = parseArgs(args);
8
9
  const [command, script] = parsed._;
10
+ if (command === 'x') {
11
+ const argsForX = args.filter(arg => arg !== 'x');
12
+ return resolveX(argsForX, options);
13
+ }
14
+ const { manifestScriptNames, cwd, fromArgs } = options;
9
15
  if (command === 'run' && manifestScriptNames.has(script))
10
16
  return [];
11
17
  if (manifestScriptNames.has(command) || commands.includes(command))
@@ -0,0 +1,3 @@
1
+ import type { BinaryResolver, BinaryResolverOptions } from '../../types/config.js';
2
+ export declare const resolveX: (args: string[], options: BinaryResolverOptions) => import("../../util/input.js").Input[];
3
+ export declare const resolve: BinaryResolver;
@@ -0,0 +1,18 @@
1
+ import parseArgs from 'minimist';
2
+ import { toDependency } from '../../util/input.js';
3
+ import { stripVersionFromSpecifier } from '../../util/modules.js';
4
+ import { argsFrom } from '../util.js';
5
+ export const resolveX = (args, options) => {
6
+ const { fromArgs } = options;
7
+ const parsed = parseArgs(args);
8
+ const packageSpecifier = parsed._[0];
9
+ const specifier = packageSpecifier ? stripVersionFromSpecifier(packageSpecifier) : '';
10
+ const packages = parsed.package && !parsed.yes ? [parsed.package].flat().map(stripVersionFromSpecifier) : [];
11
+ const command = parsed['shell-mode'] ? fromArgs([parsed['shell-mode']]) : [];
12
+ const restArgs = argsFrom(args, packageSpecifier);
13
+ const dependency = specifier ? [toDependency(specifier, { optional: true })] : [];
14
+ return [...dependency, ...packages.map(id => toDependency(id)), ...command, ...fromArgs(restArgs).slice(1)];
15
+ };
16
+ export const resolve = (_binary, args, options) => {
17
+ return resolveX(args, options);
18
+ };
@@ -1,8 +1,10 @@
1
1
  declare const _default: {
2
2
  bun: import("../../types/config.js").BinaryResolver;
3
+ bunx: import("../../types/config.js").BinaryResolver;
3
4
  npm: import("../../types/config.js").BinaryResolver;
4
5
  npx: import("../../types/config.js").BinaryResolver;
5
6
  pnpm: import("../../types/config.js").BinaryResolver;
7
+ pnpx: import("../../types/config.js").BinaryResolver;
6
8
  yarn: import("../../types/config.js").BinaryResolver;
7
9
  };
8
10
  export default _default;
@@ -1,12 +1,16 @@
1
1
  import * as bun from './bun.js';
2
+ import * as bunx from './bunx.js';
2
3
  import * as npm from './npm.js';
3
4
  import * as npx from './npx.js';
4
5
  import * as pnpm from './pnpm.js';
6
+ import * as pnpx from './pnpx.js';
5
7
  import * as yarn from './yarn.js';
6
8
  export default {
7
9
  bun: bun.resolve,
10
+ bunx: bunx.resolve,
8
11
  npm: npm.resolve,
9
12
  npx: npx.resolve,
10
13
  pnpm: pnpm.resolve,
14
+ pnpx: pnpx.resolve,
11
15
  yarn: yarn.resolve,
12
16
  };
@@ -1,8 +1,7 @@
1
1
  import parseArgs from 'minimist';
2
- import { toBinary } from '../../util/input.js';
3
2
  export const resolve = (_binary, args, options) => {
4
3
  const { fromArgs } = options;
5
4
  const parsed = parseArgs(args);
6
5
  const [command] = parsed._;
7
- return [toBinary(_binary), ...(command !== 'exec' ? [] : fromArgs(parsed._.slice(1)))];
6
+ return command !== 'exec' ? [] : fromArgs(parsed._.slice(1));
8
7
  };
@@ -15,7 +15,12 @@ export const resolve = (_binary, args, options) => {
15
15
  const command = parsed.call ? fromArgs([parsed.call]) : [];
16
16
  const restArgs = argsFrom(args, packageSpecifier);
17
17
  const isBinary = specifier && !packageSpecifier.includes('@') && !isInternal(specifier);
18
- const dependency = isBinary ? toBinary(specifier) : toDependency(specifier);
18
+ const dependency = isBinary ? toBinary(specifier) : toDependency(specifier, { optional: !parsed.no });
19
19
  const specifiers = dependency && !parsed.yes ? [dependency] : [];
20
- return [toBinary(_binary), ...specifiers, ...packages.map(toDependency), ...command, ...fromArgs(restArgs).slice(1)];
20
+ return [
21
+ ...specifiers,
22
+ ...packages.map(id => toDependency(id, { optional: true })),
23
+ ...command,
24
+ ...fromArgs(restArgs).slice(1),
25
+ ];
21
26
  };
@@ -1,5 +1,6 @@
1
1
  import parseArgs from 'minimist';
2
2
  import { toBinary } from '../../util/input.js';
3
+ import { resolveDlx } from './pnpx.js';
3
4
  const commands = [
4
5
  'add',
5
6
  'audit',
@@ -51,12 +52,17 @@ const commands = [
51
52
  'upgrade',
52
53
  'why',
53
54
  ];
54
- export const resolve = (_binary, args, { manifestScriptNames, fromArgs }) => {
55
+ export const resolve = (_binary, args, options) => {
55
56
  const parsed = parseArgs(args, {
56
57
  boolean: ['recursive', 'silent', 'shell-mode'],
57
58
  alias: { recursive: 'r', silent: 's', 'shell-mode': 'c' },
58
59
  });
59
60
  const [command, binary] = parsed._;
61
+ if (command === 'dlx') {
62
+ const argsForDlx = args.filter(arg => arg !== 'dlx');
63
+ return resolveDlx(argsForDlx, options);
64
+ }
65
+ const { manifestScriptNames, fromArgs } = options;
60
66
  if (manifestScriptNames.has(command) || commands.includes(command))
61
67
  return [];
62
68
  if (command === 'exec') {
@@ -0,0 +1,3 @@
1
+ import type { BinaryResolver, BinaryResolverOptions } from '../../types/config.js';
2
+ export declare const resolveDlx: (args: string[], options: BinaryResolverOptions) => import("../../util/input.js").Input[];
3
+ export declare const resolve: BinaryResolver;
@@ -0,0 +1,18 @@
1
+ import parseArgs from 'minimist';
2
+ import { toDependency } from '../../util/input.js';
3
+ import { stripVersionFromSpecifier } from '../../util/modules.js';
4
+ export const resolveDlx = (args, options) => {
5
+ const parsed = parseArgs(args, {
6
+ boolean: ['silent'],
7
+ alias: { package: 'p', 'shell-mode': 'c' },
8
+ });
9
+ const packageSpecifier = parsed._[0];
10
+ const specifier = packageSpecifier ? stripVersionFromSpecifier(packageSpecifier) : '';
11
+ const packages = parsed.package && !parsed.yes ? [parsed.package].flat().map(stripVersionFromSpecifier) : [];
12
+ const command = parsed['shell-mode'] ? options.fromArgs([parsed['shell-mode']]) : [];
13
+ const dependency = specifier ? [toDependency(specifier, { optional: true })] : [];
14
+ return [...dependency, ...packages.map(id => toDependency(id, { optional: true })), ...command];
15
+ };
16
+ export const resolve = (_binary, args, options) => {
17
+ return resolveDlx(args, options);
18
+ };
@@ -42,9 +42,10 @@ export const resolve = (_binary, args, { manifestScriptNames, fromArgs, cwd, roo
42
42
  return [];
43
43
  if (!dir && command === 'run' && manifestScriptNames.has(binary))
44
44
  return [];
45
- if (command === 'run' || command === 'exec')
46
- return dir ? [{ ...toBinary(binary), dir }] : [toBinary(binary)];
47
45
  if (command === 'node')
48
46
  return fromArgs(parsed._);
49
- return command ? (dir ? [{ ...toBinary(command), dir }] : [toBinary(command)]) : [];
47
+ const bin = command === 'run' || command === 'exec' ? toBinary(binary) : toBinary(command);
48
+ if (dir)
49
+ Object.assign(bin, { dir });
50
+ return [bin];
50
51
  };
@@ -2,6 +2,7 @@ import parseArgs from 'minimist';
2
2
  import { pluginArgsMap } from '../plugins.js';
3
3
  import { compact } from '../util/array.js';
4
4
  import { toBinary, toConfig, toDeferResolve, toDeferResolveEntry, toEntry } from '../util/input.js';
5
+ import { extractBinary } from '../util/modules.js';
5
6
  import { resolve as fallbackResolve } from './fallback.js';
6
7
  const isGlobLikeMatch = /(^!|[*+\\(|{^$])/;
7
8
  const isGlobLike = (value) => isGlobLikeMatch.test(value);
@@ -31,8 +32,12 @@ export const resolve = (binary, _args, options) => {
31
32
  const id = parsed._[0];
32
33
  if (isGlobLike(id))
33
34
  positionals.push(toEntry(id));
34
- else
35
- positionals.push(toDeferResolveEntry(id));
35
+ else {
36
+ if (id.includes('node_modules/.bin/'))
37
+ positionals.push(toBinary(extractBinary(id)));
38
+ else
39
+ positionals.push(toDeferResolveEntry(id));
40
+ }
36
41
  }
37
42
  const mapToParsedKey = (id) => parsed[id];
38
43
  const resolved = compact(opts.resolve ? opts.resolve.flatMap(mapToParsedKey) : []);
@@ -73,6 +73,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
73
73
  entry?: string | string[] | undefined;
74
74
  project?: string | string[] | undefined;
75
75
  } | undefined;
76
+ 'dependency-cruiser'?: string | boolean | string[] | {
77
+ config?: string | string[] | undefined;
78
+ entry?: string | string[] | undefined;
79
+ project?: string | string[] | undefined;
80
+ } | undefined;
76
81
  dotenv?: string | boolean | string[] | {
77
82
  config?: string | string[] | undefined;
78
83
  entry?: string | string[] | undefined;
@@ -168,6 +173,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
168
173
  entry?: string | string[] | undefined;
169
174
  project?: string | string[] | undefined;
170
175
  } | undefined;
176
+ metro?: string | boolean | string[] | {
177
+ config?: string | string[] | undefined;
178
+ entry?: string | string[] | undefined;
179
+ project?: string | string[] | undefined;
180
+ } | undefined;
171
181
  mocha?: string | boolean | string[] | {
172
182
  config?: string | string[] | undefined;
173
183
  entry?: string | string[] | undefined;
@@ -531,6 +541,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
531
541
  entry?: string | string[] | undefined;
532
542
  project?: string | string[] | undefined;
533
543
  } | undefined;
544
+ 'dependency-cruiser'?: string | boolean | string[] | {
545
+ config?: string | string[] | undefined;
546
+ entry?: string | string[] | undefined;
547
+ project?: string | string[] | undefined;
548
+ } | undefined;
534
549
  dotenv?: string | boolean | string[] | {
535
550
  config?: string | string[] | undefined;
536
551
  entry?: string | string[] | undefined;
@@ -626,6 +641,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
626
641
  entry?: string | string[] | undefined;
627
642
  project?: string | string[] | undefined;
628
643
  } | undefined;
644
+ metro?: string | boolean | string[] | {
645
+ config?: string | string[] | undefined;
646
+ entry?: string | string[] | undefined;
647
+ project?: string | string[] | undefined;
648
+ } | undefined;
629
649
  mocha?: string | boolean | string[] | {
630
650
  config?: string | string[] | undefined;
631
651
  entry?: string | string[] | undefined;
package/dist/constants.js CHANGED
@@ -84,6 +84,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
84
84
  'pwd',
85
85
  'rm',
86
86
  'rmdir',
87
+ 'rsync',
87
88
  'scp',
88
89
  'seq',
89
90
  'set',
@@ -119,6 +120,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
119
120
  'xvfb-run',
120
121
  'yarn',
121
122
  'yes',
123
+ 'zip',
122
124
  ]);
123
125
  export const IGNORED_DEPENDENCIES = new Set(['knip', 'typescript']);
124
126
  export const IGNORED_RUNTIME_DEPENDENCIES = new Set(['node', 'bun', 'deno']);