knip 6.24.0 → 6.26.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 (203) hide show
  1. package/dist/ConfigurationChief.d.ts +115 -1
  2. package/dist/ConfigurationChief.js +3 -0
  3. package/dist/ProjectPrincipal.d.ts +2 -0
  4. package/dist/ProjectPrincipal.js +4 -1
  5. package/dist/binaries/bash-parser.js +55 -83
  6. package/dist/binaries/index.js +3 -0
  7. package/dist/compilers/index.d.ts +199 -5
  8. package/dist/constants.d.ts +5 -1
  9. package/dist/constants.js +18 -0
  10. package/dist/graph/analyze.js +37 -2
  11. package/dist/graph/build.js +17 -3
  12. package/dist/graph-explorer/explorer.d.ts +1 -0
  13. package/dist/graph-explorer/explorer.js +2 -0
  14. package/dist/graph-explorer/operations/find-all-cycles.d.ts +3 -0
  15. package/dist/graph-explorer/operations/find-all-cycles.js +43 -0
  16. package/dist/graph-explorer/operations/find-cycles.js +3 -9
  17. package/dist/graph-explorer/utils.d.ts +10 -1
  18. package/dist/graph-explorer/utils.js +53 -0
  19. package/dist/plugins/_vue/auto-import.d.ts +12 -0
  20. package/dist/plugins/_vue/auto-import.js +272 -0
  21. package/dist/plugins/_vue/types.d.ts +38 -0
  22. package/dist/plugins/_vue/types.js +1 -0
  23. package/dist/plugins/astro/index.js +2 -37
  24. package/dist/plugins/astro/resolveFromAST.d.ts +4 -4
  25. package/dist/plugins/astro/resolveFromAST.js +34 -7
  26. package/dist/plugins/bun/index.js +28 -14
  27. package/dist/plugins/electron-vite/index.d.ts +3 -0
  28. package/dist/plugins/electron-vite/index.js +51 -0
  29. package/dist/plugins/electron-vite/types.d.ts +23 -0
  30. package/dist/plugins/electron-vite/types.js +1 -0
  31. package/dist/plugins/esbuild/index.d.ts +3 -0
  32. package/dist/plugins/esbuild/index.js +17 -0
  33. package/dist/plugins/eslint/resolveFromAST.js +18 -21
  34. package/dist/plugins/eve/index.d.ts +3 -0
  35. package/dist/plugins/eve/index.js +22 -0
  36. package/dist/plugins/execa/visitors/execa.js +10 -18
  37. package/dist/plugins/fumadocs/index.d.ts +3 -0
  38. package/dist/plugins/fumadocs/index.js +18 -0
  39. package/dist/plugins/graphql-codegen/index.js +9 -7
  40. package/dist/plugins/index.d.ts +19 -0
  41. package/dist/plugins/index.js +38 -0
  42. package/dist/plugins/jest/index.js +13 -3
  43. package/dist/plugins/laravel-vite-plugin/index.d.ts +3 -0
  44. package/dist/plugins/laravel-vite-plugin/index.js +14 -0
  45. package/dist/plugins/laravel-vite-plugin/resolveFromAST.d.ts +2 -0
  46. package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +27 -0
  47. package/dist/plugins/next/index.js +25 -12
  48. package/dist/plugins/next-mdx/index.js +2 -8
  49. package/dist/plugins/next-mdx/resolveFromAST.d.ts +3 -2
  50. package/dist/plugins/next-mdx/resolveFromAST.js +17 -21
  51. package/dist/plugins/node/index.js +4 -1
  52. package/dist/plugins/nuxt/index.js +5 -68
  53. package/dist/plugins/nuxt/types.d.ts +0 -34
  54. package/dist/plugins/nuxtjs-i18n/index.d.ts +3 -0
  55. package/dist/plugins/nuxtjs-i18n/index.js +12 -0
  56. package/dist/plugins/oclif/index.js +10 -5
  57. package/dist/plugins/orval/index.js +1 -3
  58. package/dist/plugins/orval/resolveFromAST.d.ts +2 -2
  59. package/dist/plugins/orval/resolveFromAST.js +4 -7
  60. package/dist/plugins/oxlint/index.js +23 -2
  61. package/dist/plugins/pnpm/index.js +22 -1
  62. package/dist/plugins/pnpm/types.d.ts +4 -0
  63. package/dist/plugins/pnpm/types.js +1 -0
  64. package/dist/plugins/prettier/index.js +19 -3
  65. package/dist/plugins/prettier/types.d.ts +6 -1
  66. package/dist/plugins/quasar/index.d.ts +3 -0
  67. package/dist/plugins/quasar/index.js +15 -0
  68. package/dist/plugins/quasar/resolveFromAST.d.ts +3 -0
  69. package/dist/plugins/quasar/resolveFromAST.js +63 -0
  70. package/dist/plugins/qwik/index.js +1 -25
  71. package/dist/plugins/qwik/resolveFromAST.d.ts +5 -3
  72. package/dist/plugins/qwik/resolveFromAST.js +28 -9
  73. package/dist/plugins/rolldown/index.js +2 -5
  74. package/dist/plugins/rollup/index.js +2 -5
  75. package/dist/plugins/rslib/index.js +2 -5
  76. package/dist/plugins/rspack/index.js +5 -0
  77. package/dist/plugins/serverless-framework/index.js +12 -1
  78. package/dist/plugins/serverless-framework/types.d.ts +5 -2
  79. package/dist/plugins/sst/index.js +1 -5
  80. package/dist/plugins/sst/resolveFromAST.d.ts +1 -1
  81. package/dist/plugins/sst/resolveFromAST.js +1 -1
  82. package/dist/plugins/starlight/index.js +1 -19
  83. package/dist/plugins/starlight/resolveFromAST.d.ts +2 -2
  84. package/dist/plugins/starlight/resolveFromAST.js +12 -8
  85. package/dist/plugins/stencil/index.js +2 -37
  86. package/dist/plugins/stencil/resolveFromAST.d.ts +3 -0
  87. package/dist/plugins/stencil/resolveFromAST.js +36 -0
  88. package/dist/plugins/storybook/index.js +10 -0
  89. package/dist/plugins/sveltekit/index.js +1 -48
  90. package/dist/plugins/sveltekit/resolveFromAST.d.ts +2 -0
  91. package/dist/plugins/sveltekit/resolveFromAST.js +45 -0
  92. package/dist/plugins/tauri/index.d.ts +3 -0
  93. package/dist/plugins/tauri/index.js +42 -0
  94. package/dist/plugins/tauri/types.d.ts +16 -0
  95. package/dist/plugins/tauri/types.js +1 -0
  96. package/dist/plugins/tsdown/index.js +2 -5
  97. package/dist/plugins/tsup/index.js +2 -5
  98. package/dist/plugins/typedoc/index.js +9 -3
  99. package/dist/plugins/typedoc/types.d.ts +2 -0
  100. package/dist/plugins/unplugin-auto-import/index.d.ts +3 -0
  101. package/dist/plugins/unplugin-auto-import/index.js +18 -0
  102. package/dist/plugins/unplugin-icons/index.d.ts +3 -0
  103. package/dist/plugins/unplugin-icons/index.js +17 -0
  104. package/dist/plugins/unplugin-vue-components/index.d.ts +3 -0
  105. package/dist/plugins/unplugin-vue-components/index.js +16 -0
  106. package/dist/plugins/unplugin-vue-i18n/index.d.ts +3 -0
  107. package/dist/plugins/unplugin-vue-i18n/index.js +10 -0
  108. package/dist/plugins/unplugin-vue-markdown/index.d.ts +3 -0
  109. package/dist/plugins/unplugin-vue-markdown/index.js +16 -0
  110. package/dist/plugins/unplugin-vue-router/index.d.ts +3 -0
  111. package/dist/plugins/unplugin-vue-router/index.js +14 -0
  112. package/dist/plugins/vite/helpers.d.ts +2 -0
  113. package/dist/plugins/vite/helpers.js +46 -31
  114. package/dist/plugins/vite/index.js +1 -1
  115. package/dist/plugins/vite/visitors/importMetaGlob.js +1 -8
  116. package/dist/plugins/vite-plugin-pages/index.d.ts +3 -0
  117. package/dist/plugins/vite-plugin-pages/index.js +26 -0
  118. package/dist/plugins/vite-plugin-pwa/index.d.ts +3 -0
  119. package/dist/plugins/vite-plugin-pwa/index.js +17 -0
  120. package/dist/plugins/vite-plugin-pwa/resolveFromAST.d.ts +4 -0
  121. package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +37 -0
  122. package/dist/plugins/vite-plugin-vue-layouts-next/index.d.ts +3 -0
  123. package/dist/plugins/vite-plugin-vue-layouts-next/index.js +23 -0
  124. package/dist/plugins/vite-plus/index.d.ts +3 -0
  125. package/dist/plugins/vite-plus/index.js +14 -0
  126. package/dist/plugins/vite-plus/resolveFromAST.d.ts +2 -0
  127. package/dist/plugins/vite-plus/resolveFromAST.js +37 -0
  128. package/dist/plugins/vite-pwa-assets-generator/index.d.ts +3 -0
  129. package/dist/plugins/vite-pwa-assets-generator/index.js +12 -0
  130. package/dist/plugins/vitepress/index.js +5 -1
  131. package/dist/plugins/vitest/index.js +4 -0
  132. package/dist/plugins/vitest/types.d.ts +3 -0
  133. package/dist/plugins/vue/index.js +5 -3
  134. package/dist/plugins/webpack/visitors/requireContext.js +2 -13
  135. package/dist/plugins/yarn/index.js +14 -4
  136. package/dist/plugins/yarn/types.d.ts +8 -0
  137. package/dist/plugins/yarn/types.js +1 -0
  138. package/dist/plugins/zx/visitors/zx.js +4 -4
  139. package/dist/reporters/cycles.d.ts +3 -0
  140. package/dist/reporters/cycles.js +79 -0
  141. package/dist/reporters/index.d.ts +1 -0
  142. package/dist/reporters/index.js +2 -0
  143. package/dist/reporters/json.d.ts +3 -0
  144. package/dist/reporters/json.js +2 -1
  145. package/dist/reporters/util/util.d.ts +3 -1
  146. package/dist/reporters/util/util.js +5 -1
  147. package/dist/schema/configuration.d.ts +295 -6
  148. package/dist/schema/configuration.js +6 -0
  149. package/dist/schema/plugins.d.ts +95 -0
  150. package/dist/schema/plugins.js +19 -0
  151. package/dist/types/PluginNames.d.ts +2 -2
  152. package/dist/types/PluginNames.js +19 -0
  153. package/dist/types/config.d.ts +9 -0
  154. package/dist/types/issues.d.ts +3 -0
  155. package/dist/types/module-graph.d.ts +7 -0
  156. package/dist/types/package-json.d.ts +8 -1
  157. package/dist/typescript/ast-helpers.d.ts +7 -2
  158. package/dist/typescript/ast-helpers.js +36 -8
  159. package/dist/typescript/ast-nodes.d.ts +4 -1
  160. package/dist/typescript/ast-nodes.js +17 -1
  161. package/dist/typescript/get-imports-and-exports.js +10 -0
  162. package/dist/typescript/glob-imports.d.ts +3 -0
  163. package/dist/typescript/glob-imports.js +49 -0
  164. package/dist/typescript/resolve-module-names.d.ts +2 -0
  165. package/dist/typescript/resolve-module-names.js +35 -1
  166. package/dist/typescript/visitors/calls.js +4 -6
  167. package/dist/typescript/visitors/imports.js +8 -8
  168. package/dist/typescript/visitors/script-visitors.js +4 -4
  169. package/dist/typescript/visitors/walk.js +2 -3
  170. package/dist/util/cli-arguments.d.ts +2 -1
  171. package/dist/util/cli-arguments.js +5 -3
  172. package/dist/util/create-options.d.ts +202 -5
  173. package/dist/util/create-options.js +4 -1
  174. package/dist/util/get-included-issue-types.d.ts +1 -0
  175. package/dist/util/get-included-issue-types.js +4 -2
  176. package/dist/util/issue-initializers.js +1 -1
  177. package/dist/util/load-tsconfig.js +17 -4
  178. package/dist/util/module-graph.js +1 -0
  179. package/dist/util/modules.js +25 -4
  180. package/dist/util/resolve.js +4 -1
  181. package/dist/util/scripts.d.ts +7 -0
  182. package/dist/util/scripts.js +75 -0
  183. package/dist/util/to-source-path.js +1 -1
  184. package/dist/version.d.ts +1 -1
  185. package/dist/version.js +1 -1
  186. package/package.json +1 -1
  187. package/schema.json +108 -1
  188. package/dist/plugins/next/resolveFromAST.d.ts +0 -2
  189. package/dist/plugins/next/resolveFromAST.js +0 -2
  190. package/dist/plugins/nuxt/helpers.d.ts +0 -15
  191. package/dist/plugins/nuxt/helpers.js +0 -133
  192. package/dist/plugins/rolldown/resolveFromAST.d.ts +0 -2
  193. package/dist/plugins/rolldown/resolveFromAST.js +0 -4
  194. package/dist/plugins/rollup/resolveFromAST.d.ts +0 -2
  195. package/dist/plugins/rollup/resolveFromAST.js +0 -4
  196. package/dist/plugins/rslib/resolveFromAST.d.ts +0 -2
  197. package/dist/plugins/rslib/resolveFromAST.js +0 -4
  198. package/dist/plugins/tsdown/resolveFromAST.d.ts +0 -2
  199. package/dist/plugins/tsdown/resolveFromAST.js +0 -4
  200. package/dist/plugins/tsup/resolveFromAST.d.ts +0 -2
  201. package/dist/plugins/tsup/resolveFromAST.js +0 -4
  202. package/dist/plugins/vue/compiler.d.ts +0 -3
  203. package/dist/plugins/vue/compiler.js +0 -10
@@ -9,6 +9,7 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
9
9
  config: string | undefined;
10
10
  configFilePath: string | undefined;
11
11
  cwd: string;
12
+ cycles: boolean;
12
13
  dependencies: boolean;
13
14
  exports: boolean;
14
15
  files: boolean;
@@ -30,6 +31,7 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
30
31
  isProduction: boolean;
31
32
  isReportDependencies: boolean;
32
33
  isReportExports: boolean;
34
+ isReportCycles: boolean;
33
35
  isReportFiles: boolean;
34
36
  isReportTypes: boolean;
35
37
  isReportValues: boolean;
@@ -183,16 +185,31 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
183
185
  entry?: string | string[] | undefined;
184
186
  project?: string | string[] | undefined;
185
187
  } | undefined;
188
+ 'electron-vite'?: string | boolean | string[] | {
189
+ config?: string | string[] | undefined;
190
+ entry?: string | string[] | undefined;
191
+ project?: string | string[] | undefined;
192
+ } | undefined;
186
193
  eleventy?: string | boolean | string[] | {
187
194
  config?: string | string[] | undefined;
188
195
  entry?: string | string[] | undefined;
189
196
  project?: string | string[] | undefined;
190
197
  } | undefined;
198
+ esbuild?: string | boolean | string[] | {
199
+ config?: string | string[] | undefined;
200
+ entry?: string | string[] | undefined;
201
+ project?: string | string[] | undefined;
202
+ } | undefined;
191
203
  eslint?: string | boolean | string[] | {
192
204
  config?: string | string[] | undefined;
193
205
  entry?: string | string[] | undefined;
194
206
  project?: string | string[] | undefined;
195
207
  } | undefined;
208
+ eve?: string | boolean | string[] | {
209
+ config?: string | string[] | undefined;
210
+ entry?: string | string[] | undefined;
211
+ project?: string | string[] | undefined;
212
+ } | undefined;
196
213
  execa?: string | boolean | string[] | {
197
214
  config?: string | string[] | undefined;
198
215
  entry?: string | string[] | undefined;
@@ -213,6 +230,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
213
230
  entry?: string | string[] | undefined;
214
231
  project?: string | string[] | undefined;
215
232
  } | undefined;
233
+ fumadocs?: string | boolean | string[] | {
234
+ config?: string | string[] | undefined;
235
+ entry?: string | string[] | undefined;
236
+ project?: string | string[] | undefined;
237
+ } | undefined;
216
238
  gatsby?: string | boolean | string[] | {
217
239
  config?: string | string[] | undefined;
218
240
  entry?: string | string[] | undefined;
@@ -273,6 +295,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
273
295
  entry?: string | string[] | undefined;
274
296
  project?: string | string[] | undefined;
275
297
  } | undefined;
298
+ 'laravel-vite-plugin'?: string | boolean | string[] | {
299
+ config?: string | string[] | undefined;
300
+ entry?: string | string[] | undefined;
301
+ project?: string | string[] | undefined;
302
+ } | undefined;
276
303
  lefthook?: string | boolean | string[] | {
277
304
  config?: string | string[] | undefined;
278
305
  entry?: string | string[] | undefined;
@@ -408,6 +435,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
408
435
  entry?: string | string[] | undefined;
409
436
  project?: string | string[] | undefined;
410
437
  } | undefined;
438
+ 'nuxtjs-i18n'?: string | boolean | string[] | {
439
+ config?: string | string[] | undefined;
440
+ entry?: string | string[] | undefined;
441
+ project?: string | string[] | undefined;
442
+ } | undefined;
411
443
  nx?: string | boolean | string[] | {
412
444
  config?: string | string[] | undefined;
413
445
  entry?: string | string[] | undefined;
@@ -513,6 +545,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
513
545
  entry?: string | string[] | undefined;
514
546
  project?: string | string[] | undefined;
515
547
  } | undefined;
548
+ quasar?: string | boolean | string[] | {
549
+ config?: string | string[] | undefined;
550
+ entry?: string | string[] | undefined;
551
+ project?: string | string[] | undefined;
552
+ } | undefined;
516
553
  qwik?: string | boolean | string[] | {
517
554
  config?: string | string[] | undefined;
518
555
  entry?: string | string[] | undefined;
@@ -703,6 +740,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
703
740
  entry?: string | string[] | undefined;
704
741
  project?: string | string[] | undefined;
705
742
  } | undefined;
743
+ tauri?: string | boolean | string[] | {
744
+ config?: string | string[] | undefined;
745
+ entry?: string | string[] | undefined;
746
+ project?: string | string[] | undefined;
747
+ } | undefined;
706
748
  travis?: string | boolean | string[] | {
707
749
  config?: string | string[] | undefined;
708
750
  entry?: string | string[] | undefined;
@@ -748,6 +790,36 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
748
790
  entry?: string | string[] | undefined;
749
791
  project?: string | string[] | undefined;
750
792
  } | undefined;
793
+ 'unplugin-auto-import'?: string | boolean | string[] | {
794
+ config?: string | string[] | undefined;
795
+ entry?: string | string[] | undefined;
796
+ project?: string | string[] | undefined;
797
+ } | undefined;
798
+ 'unplugin-icons'?: string | boolean | string[] | {
799
+ config?: string | string[] | undefined;
800
+ entry?: string | string[] | undefined;
801
+ project?: string | string[] | undefined;
802
+ } | undefined;
803
+ 'unplugin-vue-components'?: string | boolean | string[] | {
804
+ config?: string | string[] | undefined;
805
+ entry?: string | string[] | undefined;
806
+ project?: string | string[] | undefined;
807
+ } | undefined;
808
+ 'unplugin-vue-i18n'?: string | boolean | string[] | {
809
+ config?: string | string[] | undefined;
810
+ entry?: string | string[] | undefined;
811
+ project?: string | string[] | undefined;
812
+ } | undefined;
813
+ 'unplugin-vue-markdown'?: string | boolean | string[] | {
814
+ config?: string | string[] | undefined;
815
+ entry?: string | string[] | undefined;
816
+ project?: string | string[] | undefined;
817
+ } | undefined;
818
+ 'unplugin-vue-router'?: string | boolean | string[] | {
819
+ config?: string | string[] | undefined;
820
+ entry?: string | string[] | undefined;
821
+ project?: string | string[] | undefined;
822
+ } | undefined;
751
823
  vercel?: string | boolean | string[] | {
752
824
  config?: string | string[] | undefined;
753
825
  entry?: string | string[] | undefined;
@@ -768,6 +840,31 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
768
840
  entry?: string | string[] | undefined;
769
841
  project?: string | string[] | undefined;
770
842
  } | undefined;
843
+ 'vite-plugin-pages'?: string | boolean | string[] | {
844
+ config?: string | string[] | undefined;
845
+ entry?: string | string[] | undefined;
846
+ project?: string | string[] | undefined;
847
+ } | undefined;
848
+ 'vite-plugin-pwa'?: string | boolean | string[] | {
849
+ config?: string | string[] | undefined;
850
+ entry?: string | string[] | undefined;
851
+ project?: string | string[] | undefined;
852
+ } | undefined;
853
+ 'vite-plugin-vue-layouts-next'?: string | boolean | string[] | {
854
+ config?: string | string[] | undefined;
855
+ entry?: string | string[] | undefined;
856
+ project?: string | string[] | undefined;
857
+ } | undefined;
858
+ 'vite-plus'?: string | boolean | string[] | {
859
+ config?: string | string[] | undefined;
860
+ entry?: string | string[] | undefined;
861
+ project?: string | string[] | undefined;
862
+ } | undefined;
863
+ 'vite-pwa-assets-generator'?: string | boolean | string[] | {
864
+ config?: string | string[] | undefined;
865
+ entry?: string | string[] | undefined;
866
+ project?: string | string[] | undefined;
867
+ } | undefined;
771
868
  vitepress?: string | boolean | string[] | {
772
869
  config?: string | string[] | undefined;
773
870
  entry?: string | string[] | undefined;
@@ -829,7 +926,7 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
829
926
  project?: string | string[] | undefined;
830
927
  } | undefined;
831
928
  $schema?: string | undefined;
832
- rules?: Partial<Record<"binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved", "error" | "off" | "warn">> | undefined;
929
+ rules?: Partial<Record<"binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved", "error" | "off" | "warn">> | undefined;
833
930
  entry?: string | string[] | undefined;
834
931
  project?: string | string[] | undefined;
835
932
  paths?: Record<string, string[]> | undefined;
@@ -840,7 +937,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
840
937
  ignoreMembers?: (string | RegExp)[] | undefined;
841
938
  ignoreUnresolved?: (string | RegExp)[] | undefined;
842
939
  ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
843
- ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
940
+ ignoreIssues?: Record<string, ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
941
+ cycles?: {
942
+ allow?: string[][] | undefined;
943
+ dynamicImports?: boolean | undefined;
944
+ } | undefined;
844
945
  ignoreWorkspaces?: string[] | undefined;
845
946
  includeEntryExports?: boolean | undefined;
846
947
  compilers?: Record<string, true | import("../compilers/types.ts").CompilerAsync | import("../compilers/types.ts").CompilerSync> | undefined;
@@ -849,8 +950,8 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
849
950
  tags?: string[] | undefined;
850
951
  treatConfigHintsAsErrors?: boolean | undefined;
851
952
  treatTagHintsAsErrors?: boolean | undefined;
852
- include?: ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
853
- exclude?: ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
953
+ include?: ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
954
+ exclude?: ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
854
955
  workspaces?: Record<string, {
855
956
  angular?: string | boolean | string[] | {
856
957
  config?: string | string[] | undefined;
@@ -992,16 +1093,31 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
992
1093
  entry?: string | string[] | undefined;
993
1094
  project?: string | string[] | undefined;
994
1095
  } | undefined;
1096
+ 'electron-vite'?: string | boolean | string[] | {
1097
+ config?: string | string[] | undefined;
1098
+ entry?: string | string[] | undefined;
1099
+ project?: string | string[] | undefined;
1100
+ } | undefined;
995
1101
  eleventy?: string | boolean | string[] | {
996
1102
  config?: string | string[] | undefined;
997
1103
  entry?: string | string[] | undefined;
998
1104
  project?: string | string[] | undefined;
999
1105
  } | undefined;
1106
+ esbuild?: string | boolean | string[] | {
1107
+ config?: string | string[] | undefined;
1108
+ entry?: string | string[] | undefined;
1109
+ project?: string | string[] | undefined;
1110
+ } | undefined;
1000
1111
  eslint?: string | boolean | string[] | {
1001
1112
  config?: string | string[] | undefined;
1002
1113
  entry?: string | string[] | undefined;
1003
1114
  project?: string | string[] | undefined;
1004
1115
  } | undefined;
1116
+ eve?: string | boolean | string[] | {
1117
+ config?: string | string[] | undefined;
1118
+ entry?: string | string[] | undefined;
1119
+ project?: string | string[] | undefined;
1120
+ } | undefined;
1005
1121
  execa?: string | boolean | string[] | {
1006
1122
  config?: string | string[] | undefined;
1007
1123
  entry?: string | string[] | undefined;
@@ -1022,6 +1138,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1022
1138
  entry?: string | string[] | undefined;
1023
1139
  project?: string | string[] | undefined;
1024
1140
  } | undefined;
1141
+ fumadocs?: string | boolean | string[] | {
1142
+ config?: string | string[] | undefined;
1143
+ entry?: string | string[] | undefined;
1144
+ project?: string | string[] | undefined;
1145
+ } | undefined;
1025
1146
  gatsby?: string | boolean | string[] | {
1026
1147
  config?: string | string[] | undefined;
1027
1148
  entry?: string | string[] | undefined;
@@ -1082,6 +1203,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1082
1203
  entry?: string | string[] | undefined;
1083
1204
  project?: string | string[] | undefined;
1084
1205
  } | undefined;
1206
+ 'laravel-vite-plugin'?: string | boolean | string[] | {
1207
+ config?: string | string[] | undefined;
1208
+ entry?: string | string[] | undefined;
1209
+ project?: string | string[] | undefined;
1210
+ } | undefined;
1085
1211
  lefthook?: string | boolean | string[] | {
1086
1212
  config?: string | string[] | undefined;
1087
1213
  entry?: string | string[] | undefined;
@@ -1217,6 +1343,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1217
1343
  entry?: string | string[] | undefined;
1218
1344
  project?: string | string[] | undefined;
1219
1345
  } | undefined;
1346
+ 'nuxtjs-i18n'?: string | boolean | string[] | {
1347
+ config?: string | string[] | undefined;
1348
+ entry?: string | string[] | undefined;
1349
+ project?: string | string[] | undefined;
1350
+ } | undefined;
1220
1351
  nx?: string | boolean | string[] | {
1221
1352
  config?: string | string[] | undefined;
1222
1353
  entry?: string | string[] | undefined;
@@ -1322,6 +1453,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1322
1453
  entry?: string | string[] | undefined;
1323
1454
  project?: string | string[] | undefined;
1324
1455
  } | undefined;
1456
+ quasar?: string | boolean | string[] | {
1457
+ config?: string | string[] | undefined;
1458
+ entry?: string | string[] | undefined;
1459
+ project?: string | string[] | undefined;
1460
+ } | undefined;
1325
1461
  qwik?: string | boolean | string[] | {
1326
1462
  config?: string | string[] | undefined;
1327
1463
  entry?: string | string[] | undefined;
@@ -1512,6 +1648,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1512
1648
  entry?: string | string[] | undefined;
1513
1649
  project?: string | string[] | undefined;
1514
1650
  } | undefined;
1651
+ tauri?: string | boolean | string[] | {
1652
+ config?: string | string[] | undefined;
1653
+ entry?: string | string[] | undefined;
1654
+ project?: string | string[] | undefined;
1655
+ } | undefined;
1515
1656
  travis?: string | boolean | string[] | {
1516
1657
  config?: string | string[] | undefined;
1517
1658
  entry?: string | string[] | undefined;
@@ -1557,6 +1698,36 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1557
1698
  entry?: string | string[] | undefined;
1558
1699
  project?: string | string[] | undefined;
1559
1700
  } | undefined;
1701
+ 'unplugin-auto-import'?: string | boolean | string[] | {
1702
+ config?: string | string[] | undefined;
1703
+ entry?: string | string[] | undefined;
1704
+ project?: string | string[] | undefined;
1705
+ } | undefined;
1706
+ 'unplugin-icons'?: string | boolean | string[] | {
1707
+ config?: string | string[] | undefined;
1708
+ entry?: string | string[] | undefined;
1709
+ project?: string | string[] | undefined;
1710
+ } | undefined;
1711
+ 'unplugin-vue-components'?: string | boolean | string[] | {
1712
+ config?: string | string[] | undefined;
1713
+ entry?: string | string[] | undefined;
1714
+ project?: string | string[] | undefined;
1715
+ } | undefined;
1716
+ 'unplugin-vue-i18n'?: string | boolean | string[] | {
1717
+ config?: string | string[] | undefined;
1718
+ entry?: string | string[] | undefined;
1719
+ project?: string | string[] | undefined;
1720
+ } | undefined;
1721
+ 'unplugin-vue-markdown'?: string | boolean | string[] | {
1722
+ config?: string | string[] | undefined;
1723
+ entry?: string | string[] | undefined;
1724
+ project?: string | string[] | undefined;
1725
+ } | undefined;
1726
+ 'unplugin-vue-router'?: string | boolean | string[] | {
1727
+ config?: string | string[] | undefined;
1728
+ entry?: string | string[] | undefined;
1729
+ project?: string | string[] | undefined;
1730
+ } | undefined;
1560
1731
  vercel?: string | boolean | string[] | {
1561
1732
  config?: string | string[] | undefined;
1562
1733
  entry?: string | string[] | undefined;
@@ -1577,6 +1748,31 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1577
1748
  entry?: string | string[] | undefined;
1578
1749
  project?: string | string[] | undefined;
1579
1750
  } | undefined;
1751
+ 'vite-plugin-pages'?: string | boolean | string[] | {
1752
+ config?: string | string[] | undefined;
1753
+ entry?: string | string[] | undefined;
1754
+ project?: string | string[] | undefined;
1755
+ } | undefined;
1756
+ 'vite-plugin-pwa'?: string | boolean | string[] | {
1757
+ config?: string | string[] | undefined;
1758
+ entry?: string | string[] | undefined;
1759
+ project?: string | string[] | undefined;
1760
+ } | undefined;
1761
+ 'vite-plugin-vue-layouts-next'?: string | boolean | string[] | {
1762
+ config?: string | string[] | undefined;
1763
+ entry?: string | string[] | undefined;
1764
+ project?: string | string[] | undefined;
1765
+ } | undefined;
1766
+ 'vite-plus'?: string | boolean | string[] | {
1767
+ config?: string | string[] | undefined;
1768
+ entry?: string | string[] | undefined;
1769
+ project?: string | string[] | undefined;
1770
+ } | undefined;
1771
+ 'vite-pwa-assets-generator'?: string | boolean | string[] | {
1772
+ config?: string | string[] | undefined;
1773
+ entry?: string | string[] | undefined;
1774
+ project?: string | string[] | undefined;
1775
+ } | undefined;
1580
1776
  vitepress?: string | boolean | string[] | {
1581
1777
  config?: string | string[] | undefined;
1582
1778
  entry?: string | string[] | undefined;
@@ -1647,13 +1843,14 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1647
1843
  ignoreMembers?: (string | RegExp)[] | undefined;
1648
1844
  ignoreUnresolved?: (string | RegExp)[] | undefined;
1649
1845
  ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
1650
- ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
1846
+ ignoreIssues?: Record<string, ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
1651
1847
  includeEntryExports?: boolean | undefined;
1652
1848
  }> | undefined;
1653
1849
  };
1654
1850
  rules: {
1655
1851
  binaries: import("../types/issues.ts").IssueSeverity;
1656
1852
  catalog: import("../types/issues.ts").IssueSeverity;
1853
+ cycles: import("../types/issues.ts").IssueSeverity;
1657
1854
  dependencies: import("../types/issues.ts").IssueSeverity;
1658
1855
  devDependencies: import("../types/issues.ts").IssueSeverity;
1659
1856
  duplicates: import("../types/issues.ts").IssueSeverity;
@@ -4,7 +4,7 @@ import { knipConfigurationSchema } from '../schema/configuration.js';
4
4
  import { getCatalogContainer } from './catalog.js';
5
5
  import { ConfigurationError } from './errors.js';
6
6
  import { findFile, loadJSON } from './fs.js';
7
- import { getIncludedIssueTypes, shorthandDeps, shorthandExports, shorthandFiles } from './get-included-issue-types.js';
7
+ import { getIncludedIssueTypes, shorthandCycles, shorthandDeps, shorthandExports, shorthandFiles, } from './get-included-issue-types.js';
8
8
  import { defaultRules } from './issue-initializers.js';
9
9
  import { loadResolvedConfigFile } from './load-config.js';
10
10
  import { _load } from './loader.js';
@@ -82,6 +82,7 @@ export const createOptions = async (options) => {
82
82
  ...(args.dependencies ? shorthandDeps : []),
83
83
  ...(args.exports ? shorthandExports : []),
84
84
  ...(args.files ? shorthandFiles : []),
85
+ ...(args.cycles ? shorthandCycles : []),
85
86
  ],
86
87
  });
87
88
  for (const [key, value] of Object.entries(includedIssueTypes)) {
@@ -98,6 +99,7 @@ export const createOptions = async (options) => {
98
99
  config: args.config,
99
100
  configFilePath,
100
101
  cwd,
102
+ cycles: args.cycles ?? false,
101
103
  dependencies: args.dependencies ?? false,
102
104
  exports: args.exports ?? false,
103
105
  files: args.files ?? false,
@@ -128,6 +130,7 @@ export const createOptions = async (options) => {
128
130
  includedIssueTypes.enumMembers ||
129
131
  includedIssueTypes.namespaceMembers ||
130
132
  includedIssueTypes.duplicates,
133
+ isReportCycles: includedIssueTypes.cycles,
131
134
  isReportFiles: includedIssueTypes.files,
132
135
  isReportTypes: includedIssueTypes.types ||
133
136
  includedIssueTypes.nsTypes ||
@@ -10,5 +10,6 @@ export declare const defaultExcludedIssueTypes: string[];
10
10
  export declare const shorthandDeps: string[];
11
11
  export declare const shorthandExports: string[];
12
12
  export declare const shorthandFiles: string[];
13
+ export declare const shorthandCycles: string[];
13
14
  export declare const getIncludedIssueTypes: (options: GetIncludedIssueTypesOptions) => Report;
14
15
  export {};
@@ -1,11 +1,13 @@
1
1
  import { ISSUE_TYPES } from '../constants.js';
2
2
  import { ConfigurationError } from './errors.js';
3
- export const defaultExcludedIssueTypes = ['nsExports', 'nsTypes'];
3
+ export const defaultExcludedIssueTypes = ['nsExports', 'nsTypes', 'cycles'];
4
+ const defaultAddOnIssueTypes = ['nsExports', 'nsTypes'];
4
5
  const defaultIssueTypes = ISSUE_TYPES.filter(type => !defaultExcludedIssueTypes.includes(type));
5
6
  const normalize = (values) => values.flatMap(value => value.split(','));
6
7
  export const shorthandDeps = ['dependencies', 'unlisted', 'binaries', 'unresolved', 'catalog'];
7
8
  export const shorthandExports = ['exports', 'types', 'enumMembers', 'namespaceMembers', 'duplicates'];
8
9
  export const shorthandFiles = ['files'];
10
+ export const shorthandCycles = ['cycles'];
9
11
  export const getIncludedIssueTypes = (options) => {
10
12
  const incl = normalize(options.includeOverrides ?? []);
11
13
  const excl = normalize(options.excludeOverrides ?? []);
@@ -28,7 +30,7 @@ export const getIncludedIssueTypes = (options) => {
28
30
  _exclude.push('devDependencies', 'optionalPeerDependencies');
29
31
  }
30
32
  const included = (_include.length > 0
31
- ? _include.some(type => !defaultExcludedIssueTypes.includes(type))
33
+ ? _include.some(type => !defaultAddOnIssueTypes.includes(type))
32
34
  ? _include
33
35
  : [..._include, ...defaultIssueTypes]
34
36
  : defaultIssueTypes).filter(group => !_exclude.includes(group));
@@ -5,4 +5,4 @@ export const initCounters = () => ({
5
5
  processed: 0,
6
6
  total: 0,
7
7
  });
8
- export const defaultRules = Object.fromEntries(ISSUE_TYPES.map(issueType => [issueType, 'error']));
8
+ export const defaultRules = Object.fromEntries(ISSUE_TYPES.map(issueType => [issueType, issueType === 'cycles' ? 'warn' : 'error']));
@@ -2,7 +2,7 @@ import { parseTsconfig } from 'get-tsconfig';
2
2
  import { compact } from './array.js';
3
3
  import { isFile } from './fs.js';
4
4
  import { _syncGlob } from './glob.js';
5
- import { dirname, isAbsolute, join, toAbsolute } from './path.js';
5
+ import { dirname, isAbsolute, join, toAbsolute, toPosix } from './path.js';
6
6
  const hasGlobChar = (p) => p.includes('*') || p.includes('?');
7
7
  const hasExtension = (p) => {
8
8
  const last = p.lastIndexOf('/');
@@ -17,7 +17,20 @@ const resolvePatterns = (patterns, dir, expandDirs = false) => {
17
17
  return expandDirs && !hasGlobChar(p) && !hasExtension(p) ? join(resolved, '**/*') : resolved;
18
18
  });
19
19
  };
20
- const pathsBaseDir = (baseUrl, dir) => (baseUrl ? toAbsolute(baseUrl, dir) : dir);
20
+ const getImplicitBaseUrl = (compilerOptions) => {
21
+ for (const symbol of Object.getOwnPropertySymbols(compilerOptions)) {
22
+ if (symbol.description === 'implicitBaseUrl') {
23
+ const value = Reflect.get(compilerOptions, symbol);
24
+ if (typeof value === 'string')
25
+ return toPosix(value);
26
+ }
27
+ }
28
+ };
29
+ const pathsBaseDir = (compilerOptions, dir) => {
30
+ if (compilerOptions?.baseUrl)
31
+ return toAbsolute(compilerOptions.baseUrl, dir);
32
+ return (compilerOptions && getImplicitBaseUrl(compilerOptions)) ?? dir;
33
+ };
21
34
  const collectPaths = (acc, paths, baseDir) => {
22
35
  if (!paths)
23
36
  return;
@@ -74,7 +87,7 @@ const walkReferences = (target, references, dir, visited, pairs, paths) => {
74
87
  const refConfig = parseTsconfig(refPath);
75
88
  const refDir = dirname(refPath);
76
89
  const refOpts = refConfig.compilerOptions;
77
- collectPaths(paths, refOpts?.paths, pathsBaseDir(refOpts?.baseUrl, refDir));
90
+ collectPaths(paths, refOpts?.paths, pathsBaseDir(refOpts, refDir));
78
91
  const refOutDir = refOpts?.outDir ? absDir(refOpts.outDir, refDir) : undefined;
79
92
  const refRootDir = refOpts?.rootDir ? absDir(refOpts.rootDir, refDir) : undefined;
80
93
  if (refOutDir && refRootDir && refOutDir !== refRootDir)
@@ -109,7 +122,7 @@ export const loadTSConfig = async (tsConfigFilePath) => {
109
122
  if (compilerOptions.rootDirs)
110
123
  compilerOptions.rootDirs = compilerOptions.rootDirs.map(d => absDir(d, dir));
111
124
  const tsconfigPaths = {};
112
- collectPaths(tsconfigPaths, compilerOptions.paths, pathsBaseDir(compilerOptions.baseUrl, dir));
125
+ collectPaths(tsconfigPaths, compilerOptions.paths, pathsBaseDir(compilerOptions, dir));
113
126
  const sourceMapPairs = [];
114
127
  if (config.references?.length) {
115
128
  walkReferences(compilerOptions, config.references, dir, new Set([tsConfigFilePath]), sourceMapPairs, tsconfigPaths);
@@ -47,6 +47,7 @@ export const createFileNode = () => ({
47
47
  exports: new Map(),
48
48
  duplicates: new Set(),
49
49
  scripts: new Set(),
50
+ importGlobs: [],
50
51
  importedBy: undefined,
51
52
  internalImportCache: undefined,
52
53
  });
@@ -1,5 +1,6 @@
1
+ import { readFileSync } from 'node:fs';
1
2
  import { DT_SCOPE, PROTOCOL_VIRTUAL } from '../constants.js';
2
- import { isAbsolute, isInNodeModules, toPosix } from './path.js';
3
+ import { isAbsolute, isInNodeModules, join, toPosix } from './path.js';
3
4
  export const getPackageNameFromModuleSpecifier = (specifier) => {
4
5
  if (!isStartsLikePackageName(specifier))
5
6
  return;
@@ -18,13 +19,33 @@ export const getPackageNameFromModuleSpecifier = (specifier) => {
18
19
  return specifier;
19
20
  };
20
21
  const lastPackageNameMatch = /(?<=node_modules\/)(@[^/]+\/[^/]+|[^/]+)/g;
22
+ const yarnPnpmStorePackageRoot = /^(.*\/node_modules\/\.store\/[^/]+\/package)(?:\/|$)/;
23
+ const yarnPnpmStoreNameCache = new Map();
24
+ const getPackageNameFromYarnPnpmStore = (posixPath) => {
25
+ const match = posixPath.match(yarnPnpmStorePackageRoot);
26
+ if (!match)
27
+ return;
28
+ const root = match[1];
29
+ if (yarnPnpmStoreNameCache.has(root))
30
+ return yarnPnpmStoreNameCache.get(root);
31
+ let name;
32
+ try {
33
+ name = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).name;
34
+ }
35
+ catch { }
36
+ yarnPnpmStoreNameCache.set(root, name);
37
+ return name;
38
+ };
21
39
  export const getPackageNameFromFilePath = (value) => {
22
40
  const name = value.startsWith('file://') ? value.slice(7) : value;
23
41
  if (name.includes('node_modules/.bin/'))
24
42
  return extractBinary(name);
25
- const match = toPosix(name).match(lastPackageNameMatch);
26
- if (match)
27
- return match[match.length - 1];
43
+ const posixPath = toPosix(name);
44
+ const match = posixPath.match(lastPackageNameMatch);
45
+ if (match) {
46
+ const last = match[match.length - 1];
47
+ return last === '.store' ? (getPackageNameFromYarnPnpmStore(posixPath) ?? last) : last;
48
+ }
28
49
  return name;
29
50
  };
30
51
  export const getPackageNameFromSpecifier = (specifier) => isInNodeModules(specifier) ? getPackageNameFromFilePath(specifier) : getPackageNameFromModuleSpecifier(specifier);
@@ -20,7 +20,10 @@ const createSyncModuleResolver = (extensions, tsConfigFile) => {
20
20
  tsconfig: tsConfigFile ? { configFile: tsConfigFile, references: 'auto' } : 'auto',
21
21
  ...baseOptions,
22
22
  });
23
- const fallbackResolver = new ResolverFactory(baseOptions);
23
+ const fallbackResolver = new ResolverFactory({
24
+ ...baseOptions,
25
+ conditionNames: ['require', 'import', 'browser', 'default'],
26
+ });
24
27
  resolverInstances.push(resolver, fallbackResolver);
25
28
  return function resolveSync(specifier, basePath) {
26
29
  const resolved = resolver.resolveFileSync(basePath, specifier);
@@ -0,0 +1,7 @@
1
+ import { type Command, type Node } from 'unbash';
2
+ export interface ScriptCommand {
3
+ binary: string;
4
+ args: string[];
5
+ }
6
+ export declare function walkCommands(node: Node): Generator<Command>;
7
+ export declare const getScriptCommands: (script: string) => ScriptCommand[];
@@ -0,0 +1,75 @@
1
+ import { parse } from 'unbash';
2
+ import { extractBinary } from './modules.js';
3
+ const spawningBinaries = new Set(['cross-env', 'retry-cli']);
4
+ export function* walkCommands(node) {
5
+ switch (node.type) {
6
+ case 'Command':
7
+ yield node;
8
+ break;
9
+ case 'AndOr':
10
+ case 'Pipeline':
11
+ for (const command of node.commands)
12
+ yield* walkCommands(command);
13
+ break;
14
+ case 'If':
15
+ for (const statement of node.clause.commands)
16
+ yield* walkCommands(statement.command);
17
+ for (const statement of node.then.commands)
18
+ yield* walkCommands(statement.command);
19
+ if (node.else)
20
+ yield* walkCommands(node.else);
21
+ break;
22
+ case 'While':
23
+ for (const statement of node.clause.commands)
24
+ yield* walkCommands(statement.command);
25
+ for (const statement of node.body.commands)
26
+ yield* walkCommands(statement.command);
27
+ break;
28
+ case 'For':
29
+ case 'Select':
30
+ case 'Subshell':
31
+ case 'BraceGroup':
32
+ for (const statement of node.body.commands)
33
+ yield* walkCommands(statement.command);
34
+ break;
35
+ case 'CompoundList':
36
+ for (const statement of node.commands)
37
+ yield* walkCommands(statement.command);
38
+ break;
39
+ case 'Function':
40
+ case 'Coproc':
41
+ yield* walkCommands(node.body);
42
+ break;
43
+ case 'Statement':
44
+ yield* walkCommands(node.command);
45
+ break;
46
+ }
47
+ }
48
+ export const getScriptCommands = (script) => {
49
+ if (!script)
50
+ return [];
51
+ let parsed;
52
+ try {
53
+ parsed = parse(script);
54
+ }
55
+ catch {
56
+ return [];
57
+ }
58
+ if (!parsed.commands)
59
+ return [];
60
+ const out = [];
61
+ for (const statement of parsed.commands) {
62
+ for (const node of walkCommands(statement.command)) {
63
+ const text = node.name?.value;
64
+ if (!text)
65
+ continue;
66
+ const binary = extractBinary(text);
67
+ const args = node.suffix.map(word => word.value);
68
+ if (spawningBinaries.has(binary))
69
+ out.push(...getScriptCommands(args.filter(arg => arg !== '--').join(' ')));
70
+ else
71
+ out.push({ binary, args });
72
+ }
73
+ }
74
+ return out;
75
+ };