@xylabs/ts-scripts-yarn3 7.4.27 → 7.5.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 (408) hide show
  1. package/dist/actions/deploy-major.mjs +1 -90
  2. package/dist/actions/deploy-major.mjs.map +1 -1
  3. package/dist/actions/deploy-minor.mjs +1 -90
  4. package/dist/actions/deploy-minor.mjs.map +1 -1
  5. package/dist/actions/deploy-next.mjs +1 -90
  6. package/dist/actions/deploy-next.mjs.map +1 -1
  7. package/dist/actions/deploy.mjs +1 -90
  8. package/dist/actions/deploy.mjs.map +1 -1
  9. package/dist/actions/index.mjs +50 -3534
  10. package/dist/actions/index.mjs.map +1 -1
  11. package/dist/actions/publish.mjs +1 -90
  12. package/dist/actions/publish.mjs.map +1 -1
  13. package/dist/actions/reinstall.mjs +1 -90
  14. package/dist/actions/reinstall.mjs.map +1 -1
  15. package/dist/actions/up.mjs +1 -90
  16. package/dist/actions/up.mjs.map +1 -1
  17. package/dist/actions/updo.mjs +1 -90
  18. package/dist/actions/updo.mjs.map +1 -1
  19. package/dist/actions/upplug.mjs +1 -90
  20. package/dist/actions/upplug.mjs.map +1 -1
  21. package/dist/actions/upyarn.mjs +1 -90
  22. package/dist/actions/upyarn.mjs.map +1 -1
  23. package/dist/actions/yarn3only.mjs +2 -32
  24. package/dist/actions/yarn3only.mjs.map +1 -1
  25. package/dist/bin/xy.mjs +221 -3436
  26. package/dist/bin/xy.mjs.map +1 -1
  27. package/dist/index.d.ts +24 -496
  28. package/dist/index.mjs +226 -4413
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/lib/index.mjs +0 -804
  31. package/dist/lib/index.mjs.map +1 -1
  32. package/dist/lib/yarn/index.mjs +0 -7
  33. package/dist/lib/yarn/index.mjs.map +1 -1
  34. package/dist/pm/index.mjs +82 -0
  35. package/dist/pm/index.mjs.map +1 -0
  36. package/dist/pm/yarnPackageManager.mjs +82 -0
  37. package/dist/pm/yarnPackageManager.mjs.map +1 -0
  38. package/dist/xy/common/index.mjs +7 -1459
  39. package/dist/xy/common/index.mjs.map +1 -1
  40. package/dist/xy/common/upplugCommand.mjs +1 -90
  41. package/dist/xy/common/upplugCommand.mjs.map +1 -1
  42. package/dist/xy/common/upyarnCommand.mjs +1 -90
  43. package/dist/xy/common/upyarnCommand.mjs.map +1 -1
  44. package/dist/xy/common/yarn3OnlyCommand.mjs +1 -33
  45. package/dist/xy/common/yarn3OnlyCommand.mjs.map +1 -1
  46. package/dist/xy/deploy/deployCommand.mjs +3 -90
  47. package/dist/xy/deploy/deployCommand.mjs.map +1 -1
  48. package/dist/xy/deploy/deployMajorCommand.mjs +1 -90
  49. package/dist/xy/deploy/deployMajorCommand.mjs.map +1 -1
  50. package/dist/xy/deploy/deployMinorCommand.mjs +1 -90
  51. package/dist/xy/deploy/deployMinorCommand.mjs.map +1 -1
  52. package/dist/xy/deploy/deployNextCommand.mjs +1 -90
  53. package/dist/xy/deploy/deployNextCommand.mjs.map +1 -1
  54. package/dist/xy/deploy/index.mjs +11 -94
  55. package/dist/xy/deploy/index.mjs.map +1 -1
  56. package/dist/xy/deploy/publishCommand.mjs +1 -90
  57. package/dist/xy/deploy/publishCommand.mjs.map +1 -1
  58. package/dist/xy/index.mjs +190 -3477
  59. package/dist/xy/index.mjs.map +1 -1
  60. package/dist/xy/install/cleanCommand.mjs +6 -118
  61. package/dist/xy/install/cleanCommand.mjs.map +1 -1
  62. package/dist/xy/install/dupdepsCommand.mjs +6 -178
  63. package/dist/xy/install/dupdepsCommand.mjs.map +1 -1
  64. package/dist/xy/install/index.mjs +12 -305
  65. package/dist/xy/install/index.mjs.map +1 -1
  66. package/dist/xy/install/reinstallCommand.mjs +1 -90
  67. package/dist/xy/install/reinstallCommand.mjs.map +1 -1
  68. package/dist/xy/install/staticsCommand.mjs +6 -177
  69. package/dist/xy/install/staticsCommand.mjs.map +1 -1
  70. package/dist/xy/install/upCommand.mjs +1 -90
  71. package/dist/xy/install/upCommand.mjs.map +1 -1
  72. package/dist/xy/install/updoCommand.mjs +1 -90
  73. package/dist/xy/install/updoCommand.mjs.map +1 -1
  74. package/dist/xy/xy.mjs +190 -3474
  75. package/dist/xy/xy.mjs.map +1 -1
  76. package/dist/xy/yarnCommands.mjs +80 -0
  77. package/dist/xy/yarnCommands.mjs.map +1 -0
  78. package/package.json +5 -47
  79. package/dist/actions/build.mjs +0 -140
  80. package/dist/actions/build.mjs.map +0 -1
  81. package/dist/actions/claude-clean.mjs +0 -71
  82. package/dist/actions/claude-clean.mjs.map +0 -1
  83. package/dist/actions/claude-commands.mjs +0 -112
  84. package/dist/actions/claude-commands.mjs.map +0 -1
  85. package/dist/actions/claude-rules.mjs +0 -137
  86. package/dist/actions/claude-rules.mjs.map +0 -1
  87. package/dist/actions/claude-settings.mjs +0 -85
  88. package/dist/actions/claude-settings.mjs.map +0 -1
  89. package/dist/actions/claude-skills.mjs +0 -120
  90. package/dist/actions/claude-skills.mjs.map +0 -1
  91. package/dist/actions/clean-docs.mjs +0 -37
  92. package/dist/actions/clean-docs.mjs.map +0 -1
  93. package/dist/actions/clean-eslint.mjs +0 -26
  94. package/dist/actions/clean-eslint.mjs.map +0 -1
  95. package/dist/actions/clean.mjs +0 -124
  96. package/dist/actions/clean.mjs.map +0 -1
  97. package/dist/actions/compile.mjs +0 -157
  98. package/dist/actions/compile.mjs.map +0 -1
  99. package/dist/actions/copy-assets.mjs +0 -73
  100. package/dist/actions/copy-assets.mjs.map +0 -1
  101. package/dist/actions/cycle.mjs +0 -144
  102. package/dist/actions/cycle.mjs.map +0 -1
  103. package/dist/actions/dead.mjs +0 -98
  104. package/dist/actions/dead.mjs.map +0 -1
  105. package/dist/actions/deplint/checkPackage/checkPackage.mjs +0 -672
  106. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +0 -1
  107. package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs +0 -1
  108. package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs.map +0 -1
  109. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +0 -48
  110. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +0 -1
  111. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +0 -33
  112. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +0 -1
  113. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +0 -30
  114. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +0 -1
  115. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +0 -309
  116. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +0 -1
  117. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +0 -26
  118. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +0 -1
  119. package/dist/actions/deplint/checkPackage/index.mjs +0 -672
  120. package/dist/actions/deplint/checkPackage/index.mjs.map +0 -1
  121. package/dist/actions/deplint/deplint.mjs +0 -764
  122. package/dist/actions/deplint/deplint.mjs.map +0 -1
  123. package/dist/actions/deplint/findFiles.mjs +0 -39
  124. package/dist/actions/deplint/findFiles.mjs.map +0 -1
  125. package/dist/actions/deplint/findFilesByGlob.mjs +0 -14
  126. package/dist/actions/deplint/findFilesByGlob.mjs.map +0 -1
  127. package/dist/actions/deplint/getBasePackageName.mjs +0 -13
  128. package/dist/actions/deplint/getBasePackageName.mjs.map +0 -1
  129. package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs +0 -140
  130. package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs.map +0 -1
  131. package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +0 -20
  132. package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +0 -1
  133. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +0 -44
  134. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +0 -1
  135. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +0 -122
  136. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +0 -1
  137. package/dist/actions/deplint/getImportsFromFile.mjs +0 -85
  138. package/dist/actions/deplint/getImportsFromFile.mjs.map +0 -1
  139. package/dist/actions/deplint/getRequiredPeerDependencies.mjs +0 -36
  140. package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +0 -1
  141. package/dist/actions/deplint/getScriptReferencedPackages.mjs +0 -83
  142. package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +0 -1
  143. package/dist/actions/deplint/implicitDevDependencies.mjs +0 -80
  144. package/dist/actions/deplint/implicitDevDependencies.mjs.map +0 -1
  145. package/dist/actions/deplint/index.mjs +0 -764
  146. package/dist/actions/deplint/index.mjs.map +0 -1
  147. package/dist/actions/dupdeps.mjs +0 -184
  148. package/dist/actions/dupdeps.mjs.map +0 -1
  149. package/dist/actions/fix.mjs +0 -147
  150. package/dist/actions/fix.mjs.map +0 -1
  151. package/dist/actions/gen-docs.mjs +0 -109
  152. package/dist/actions/gen-docs.mjs.map +0 -1
  153. package/dist/actions/gitignore.mjs +0 -152
  154. package/dist/actions/gitignore.mjs.map +0 -1
  155. package/dist/actions/gitlint-fix.mjs +0 -27
  156. package/dist/actions/gitlint-fix.mjs.map +0 -1
  157. package/dist/actions/gitlint.mjs +0 -48
  158. package/dist/actions/gitlint.mjs.map +0 -1
  159. package/dist/actions/knip.mjs +0 -98
  160. package/dist/actions/knip.mjs.map +0 -1
  161. package/dist/actions/license.mjs +0 -84
  162. package/dist/actions/license.mjs.map +0 -1
  163. package/dist/actions/lint.mjs +0 -144
  164. package/dist/actions/lint.mjs.map +0 -1
  165. package/dist/actions/npmignore-gen.mjs +0 -88
  166. package/dist/actions/npmignore-gen.mjs.map +0 -1
  167. package/dist/actions/package/clean-outputs.mjs +0 -29
  168. package/dist/actions/package/clean-outputs.mjs.map +0 -1
  169. package/dist/actions/package/clean-typescript.mjs +0 -29
  170. package/dist/actions/package/clean-typescript.mjs.map +0 -1
  171. package/dist/actions/package/clean.mjs +0 -48
  172. package/dist/actions/package/clean.mjs.map +0 -1
  173. package/dist/actions/package/compile/XyConfig.mjs +0 -1
  174. package/dist/actions/package/compile/XyConfig.mjs.map +0 -1
  175. package/dist/actions/package/compile/buildEntries.mjs +0 -53
  176. package/dist/actions/package/compile/buildEntries.mjs.map +0 -1
  177. package/dist/actions/package/compile/compile.mjs +0 -433
  178. package/dist/actions/package/compile/compile.mjs.map +0 -1
  179. package/dist/actions/package/compile/copyTypeFiles.mjs +0 -34
  180. package/dist/actions/package/compile/copyTypeFiles.mjs.map +0 -1
  181. package/dist/actions/package/compile/deepMerge.mjs +0 -26
  182. package/dist/actions/package/compile/deepMerge.mjs.map +0 -1
  183. package/dist/actions/package/compile/getCompilerOptions.mjs +0 -12
  184. package/dist/actions/package/compile/getCompilerOptions.mjs.map +0 -1
  185. package/dist/actions/package/compile/index.mjs +0 -436
  186. package/dist/actions/package/compile/index.mjs.map +0 -1
  187. package/dist/actions/package/compile/inputs.mjs +0 -22
  188. package/dist/actions/package/compile/inputs.mjs.map +0 -1
  189. package/dist/actions/package/compile/packageCompileTsc.mjs +0 -94
  190. package/dist/actions/package/compile/packageCompileTsc.mjs.map +0 -1
  191. package/dist/actions/package/compile/packageCompileTscTypes.mjs +0 -92
  192. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +0 -1
  193. package/dist/actions/package/compile/packageCompileTsup.mjs +0 -402
  194. package/dist/actions/package/compile/packageCompileTsup.mjs.map +0 -1
  195. package/dist/actions/package/copy-assets.mjs +0 -46
  196. package/dist/actions/package/copy-assets.mjs.map +0 -1
  197. package/dist/actions/package/cycle.mjs +0 -39
  198. package/dist/actions/package/cycle.mjs.map +0 -1
  199. package/dist/actions/package/gen-docs.mjs +0 -114
  200. package/dist/actions/package/gen-docs.mjs.map +0 -1
  201. package/dist/actions/package/index.mjs +0 -825
  202. package/dist/actions/package/index.mjs.map +0 -1
  203. package/dist/actions/package/lint.mjs +0 -80
  204. package/dist/actions/package/lint.mjs.map +0 -1
  205. package/dist/actions/package/publint.mjs +0 -66
  206. package/dist/actions/package/publint.mjs.map +0 -1
  207. package/dist/actions/package/recompile.mjs +0 -483
  208. package/dist/actions/package/recompile.mjs.map +0 -1
  209. package/dist/actions/package-lint.mjs +0 -178
  210. package/dist/actions/package-lint.mjs.map +0 -1
  211. package/dist/actions/publint.mjs +0 -166
  212. package/dist/actions/publint.mjs.map +0 -1
  213. package/dist/actions/readme-gen.mjs +0 -289
  214. package/dist/actions/readme-gen.mjs.map +0 -1
  215. package/dist/actions/readme-init.mjs +0 -83
  216. package/dist/actions/readme-init.mjs.map +0 -1
  217. package/dist/actions/rebuild.mjs +0 -101
  218. package/dist/actions/rebuild.mjs.map +0 -1
  219. package/dist/actions/recompile.mjs +0 -187
  220. package/dist/actions/recompile.mjs.map +0 -1
  221. package/dist/actions/relint.mjs +0 -144
  222. package/dist/actions/relint.mjs.map +0 -1
  223. package/dist/actions/retest.mjs +0 -123
  224. package/dist/actions/retest.mjs.map +0 -1
  225. package/dist/actions/sonar.mjs +0 -98
  226. package/dist/actions/sonar.mjs.map +0 -1
  227. package/dist/actions/statics.mjs +0 -183
  228. package/dist/actions/statics.mjs.map +0 -1
  229. package/dist/actions/test.mjs +0 -117
  230. package/dist/actions/test.mjs.map +0 -1
  231. package/dist/bin/package/build-only.mjs +0 -445
  232. package/dist/bin/package/build-only.mjs.map +0 -1
  233. package/dist/bin/package/build.mjs +0 -445
  234. package/dist/bin/package/build.mjs.map +0 -1
  235. package/dist/bin/package/clean-outputs.mjs +0 -29
  236. package/dist/bin/package/clean-outputs.mjs.map +0 -1
  237. package/dist/bin/package/clean-typescript.mjs +0 -29
  238. package/dist/bin/package/clean-typescript.mjs.map +0 -1
  239. package/dist/bin/package/clean.mjs +0 -53
  240. package/dist/bin/package/clean.mjs.map +0 -1
  241. package/dist/bin/package/compile-only.mjs +0 -441
  242. package/dist/bin/package/compile-only.mjs.map +0 -1
  243. package/dist/bin/package/compile-tsup.mjs +0 -409
  244. package/dist/bin/package/compile-tsup.mjs.map +0 -1
  245. package/dist/bin/package/compile.mjs +0 -445
  246. package/dist/bin/package/compile.mjs.map +0 -1
  247. package/dist/bin/package/copy-assets-cjs.mjs +0 -54
  248. package/dist/bin/package/copy-assets-cjs.mjs.map +0 -1
  249. package/dist/bin/package/copy-assets-esm.mjs +0 -54
  250. package/dist/bin/package/copy-assets-esm.mjs.map +0 -1
  251. package/dist/bin/package/cycle.mjs +0 -51
  252. package/dist/bin/package/cycle.mjs.map +0 -1
  253. package/dist/bin/package/fix.mjs +0 -92
  254. package/dist/bin/package/fix.mjs.map +0 -1
  255. package/dist/bin/package/gen-docs.mjs +0 -121
  256. package/dist/bin/package/gen-docs.mjs.map +0 -1
  257. package/dist/bin/package/lint-verbose.mjs +0 -92
  258. package/dist/bin/package/lint-verbose.mjs.map +0 -1
  259. package/dist/bin/package/lint.mjs +0 -92
  260. package/dist/bin/package/lint.mjs.map +0 -1
  261. package/dist/bin/package/publint.mjs +0 -75
  262. package/dist/bin/package/publint.mjs.map +0 -1
  263. package/dist/bin/package/recompile.mjs +0 -489
  264. package/dist/bin/package/recompile.mjs.map +0 -1
  265. package/dist/bin/package/relint.mjs +0 -92
  266. package/dist/bin/package/relint.mjs.map +0 -1
  267. package/dist/lib/checkResult.mjs +0 -16
  268. package/dist/lib/checkResult.mjs.map +0 -1
  269. package/dist/lib/claudeMdTemplate.mjs +0 -65
  270. package/dist/lib/claudeMdTemplate.mjs.map +0 -1
  271. package/dist/lib/createBuildConfig.mjs +0 -55
  272. package/dist/lib/createBuildConfig.mjs.map +0 -1
  273. package/dist/lib/defaultBuildConfig.mjs +0 -23
  274. package/dist/lib/defaultBuildConfig.mjs.map +0 -1
  275. package/dist/lib/deleteGlob.mjs +0 -13
  276. package/dist/lib/deleteGlob.mjs.map +0 -1
  277. package/dist/lib/dependencies/DuplicateDetector.mjs +0 -81
  278. package/dist/lib/dependencies/DuplicateDetector.mjs.map +0 -1
  279. package/dist/lib/dependencies/detectDuplicateDependencies.mjs +0 -164
  280. package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +0 -1
  281. package/dist/lib/dependencies/index.mjs +0 -165
  282. package/dist/lib/dependencies/index.mjs.map +0 -1
  283. package/dist/lib/file/ReadFileSyncOptions.mjs +0 -6
  284. package/dist/lib/file/ReadFileSyncOptions.mjs.map +0 -1
  285. package/dist/lib/file/constants.mjs +0 -8
  286. package/dist/lib/file/constants.mjs.map +0 -1
  287. package/dist/lib/file/fileLines.mjs +0 -32
  288. package/dist/lib/file/fileLines.mjs.map +0 -1
  289. package/dist/lib/file/index.mjs +0 -42
  290. package/dist/lib/file/index.mjs.map +0 -1
  291. package/dist/lib/file/tryReadFileSync.mjs +0 -14
  292. package/dist/lib/file/tryReadFileSync.mjs.map +0 -1
  293. package/dist/lib/generateIgnoreFiles.mjs +0 -84
  294. package/dist/lib/generateIgnoreFiles.mjs.map +0 -1
  295. package/dist/lib/generateReadmeFiles.mjs +0 -257
  296. package/dist/lib/generateReadmeFiles.mjs.map +0 -1
  297. package/dist/lib/gitignoreTemplate.mjs +0 -12
  298. package/dist/lib/gitignoreTemplate.mjs.map +0 -1
  299. package/dist/lib/jsonFormatters.mjs +0 -11
  300. package/dist/lib/jsonFormatters.mjs.map +0 -1
  301. package/dist/lib/loadConfig.mjs +0 -24
  302. package/dist/lib/loadConfig.mjs.map +0 -1
  303. package/dist/lib/parsedPackageJSON.mjs +0 -11
  304. package/dist/lib/parsedPackageJSON.mjs.map +0 -1
  305. package/dist/lib/processEx.mjs +0 -36
  306. package/dist/lib/processEx.mjs.map +0 -1
  307. package/dist/lib/runSteps.mjs +0 -95
  308. package/dist/lib/runSteps.mjs.map +0 -1
  309. package/dist/lib/runStepsAsync.mjs +0 -113
  310. package/dist/lib/runStepsAsync.mjs.map +0 -1
  311. package/dist/lib/runXy.mjs +0 -103
  312. package/dist/lib/runXy.mjs.map +0 -1
  313. package/dist/lib/runXyWithWarning.mjs +0 -13
  314. package/dist/lib/runXyWithWarning.mjs.map +0 -1
  315. package/dist/lib/safeExit.mjs +0 -61
  316. package/dist/lib/safeExit.mjs.map +0 -1
  317. package/dist/lib/string/empty.mjs +0 -8
  318. package/dist/lib/string/empty.mjs.map +0 -1
  319. package/dist/lib/string/index.mjs +0 -12
  320. package/dist/lib/string/index.mjs.map +0 -1
  321. package/dist/lib/string/union.mjs +0 -6
  322. package/dist/lib/string/union.mjs.map +0 -1
  323. package/dist/lib/tryRunLocalScript.mjs +0 -33
  324. package/dist/lib/tryRunLocalScript.mjs.map +0 -1
  325. package/dist/lib/withErrnoException.mjs +0 -13
  326. package/dist/lib/withErrnoException.mjs.map +0 -1
  327. package/dist/lib/withError.mjs +0 -8
  328. package/dist/lib/withError.mjs.map +0 -1
  329. package/dist/loadPackageConfig.mjs +0 -11
  330. package/dist/loadPackageConfig.mjs.map +0 -1
  331. package/dist/types.d.mjs +0 -1
  332. package/dist/types.d.mjs.map +0 -1
  333. package/dist/xy/build/buildCommand.mjs +0 -161
  334. package/dist/xy/build/buildCommand.mjs.map +0 -1
  335. package/dist/xy/build/compileCommand.mjs +0 -174
  336. package/dist/xy/build/compileCommand.mjs.map +0 -1
  337. package/dist/xy/build/compileOnlyCommand.mjs +0 -175
  338. package/dist/xy/build/compileOnlyCommand.mjs.map +0 -1
  339. package/dist/xy/build/copyAssetsCommand.mjs +0 -84
  340. package/dist/xy/build/copyAssetsCommand.mjs.map +0 -1
  341. package/dist/xy/build/index.mjs +0 -507
  342. package/dist/xy/build/index.mjs.map +0 -1
  343. package/dist/xy/build/rebuildCommand.mjs +0 -114
  344. package/dist/xy/build/rebuildCommand.mjs.map +0 -1
  345. package/dist/xy/build/recompileCommand.mjs +0 -204
  346. package/dist/xy/build/recompileCommand.mjs.map +0 -1
  347. package/dist/xy/common/claude/cleanCommand.mjs +0 -79
  348. package/dist/xy/common/claude/cleanCommand.mjs.map +0 -1
  349. package/dist/xy/common/claude/commandsCommand.mjs +0 -120
  350. package/dist/xy/common/claude/commandsCommand.mjs.map +0 -1
  351. package/dist/xy/common/claude/index.mjs +0 -546
  352. package/dist/xy/common/claude/index.mjs.map +0 -1
  353. package/dist/xy/common/claude/initCommand.mjs +0 -319
  354. package/dist/xy/common/claude/initCommand.mjs.map +0 -1
  355. package/dist/xy/common/claude/rulesCommand.mjs +0 -153
  356. package/dist/xy/common/claude/rulesCommand.mjs.map +0 -1
  357. package/dist/xy/common/claude/settingsCommand.mjs +0 -93
  358. package/dist/xy/common/claude/settingsCommand.mjs.map +0 -1
  359. package/dist/xy/common/claude/skillsCommand.mjs +0 -129
  360. package/dist/xy/common/claude/skillsCommand.mjs.map +0 -1
  361. package/dist/xy/common/cleanDocsCommand.mjs +0 -45
  362. package/dist/xy/common/cleanDocsCommand.mjs.map +0 -1
  363. package/dist/xy/common/deadCommand.mjs +0 -116
  364. package/dist/xy/common/deadCommand.mjs.map +0 -1
  365. package/dist/xy/common/genDocsCommand.mjs +0 -125
  366. package/dist/xy/common/genDocsCommand.mjs.map +0 -1
  367. package/dist/xy/common/gitignoreCommand.mjs +0 -158
  368. package/dist/xy/common/gitignoreCommand.mjs.map +0 -1
  369. package/dist/xy/common/gitlintCommand.mjs +0 -82
  370. package/dist/xy/common/gitlintCommand.mjs.map +0 -1
  371. package/dist/xy/common/licenseCommand.mjs +0 -100
  372. package/dist/xy/common/licenseCommand.mjs.map +0 -1
  373. package/dist/xy/common/npmignoreGenCommand.mjs +0 -98
  374. package/dist/xy/common/npmignoreGenCommand.mjs.map +0 -1
  375. package/dist/xy/common/readme/genCommand.mjs +0 -321
  376. package/dist/xy/common/readme/genCommand.mjs.map +0 -1
  377. package/dist/xy/common/readme/index.mjs +0 -361
  378. package/dist/xy/common/readme/index.mjs.map +0 -1
  379. package/dist/xy/common/readme/initCommand.mjs +0 -103
  380. package/dist/xy/common/readme/initCommand.mjs.map +0 -1
  381. package/dist/xy/common/retestCommand.mjs +0 -136
  382. package/dist/xy/common/retestCommand.mjs.map +0 -1
  383. package/dist/xy/common/testCommand.mjs +0 -130
  384. package/dist/xy/common/testCommand.mjs.map +0 -1
  385. package/dist/xy/lint/cycleCommand.mjs +0 -163
  386. package/dist/xy/lint/cycleCommand.mjs.map +0 -1
  387. package/dist/xy/lint/deplintCommand.mjs +0 -814
  388. package/dist/xy/lint/deplintCommand.mjs.map +0 -1
  389. package/dist/xy/lint/fixCommand.mjs +0 -168
  390. package/dist/xy/lint/fixCommand.mjs.map +0 -1
  391. package/dist/xy/lint/index.mjs +0 -1444
  392. package/dist/xy/lint/index.mjs.map +0 -1
  393. package/dist/xy/lint/knipCommand.mjs +0 -121
  394. package/dist/xy/lint/knipCommand.mjs.map +0 -1
  395. package/dist/xy/lint/lintCommand.mjs +0 -186
  396. package/dist/xy/lint/lintCommand.mjs.map +0 -1
  397. package/dist/xy/lint/packageLintCommand.mjs +0 -193
  398. package/dist/xy/lint/packageLintCommand.mjs.map +0 -1
  399. package/dist/xy/lint/publintCommand.mjs +0 -187
  400. package/dist/xy/lint/publintCommand.mjs.map +0 -1
  401. package/dist/xy/lint/relintCommand.mjs +0 -163
  402. package/dist/xy/lint/relintCommand.mjs.map +0 -1
  403. package/dist/xy/lint/sonarCommand.mjs +0 -121
  404. package/dist/xy/lint/sonarCommand.mjs.map +0 -1
  405. package/dist/xy/param.mjs +0 -8
  406. package/dist/xy/param.mjs.map +0 -1
  407. package/dist/xy/xyParseOptions.mjs +0 -70
  408. package/dist/xy/xyParseOptions.mjs.map +0 -1
@@ -1,1444 +0,0 @@
1
- // src/xy/lint/cycleCommand.ts
2
- import chalk15 from "chalk";
3
-
4
- // src/lib/checkResult.ts
5
- import chalk from "chalk";
6
- var checkResult = (name, result, level = "error", exitOnFail = false) => {
7
- if (result) {
8
- const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
9
- const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
10
- console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
11
- if (exitOnFail) {
12
- process.exit(result);
13
- }
14
- }
15
- };
16
-
17
- // src/lib/processEx.ts
18
- import chalk2 from "chalk";
19
-
20
- // src/lib/withError.ts
21
- var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
22
- return predicate(ex) ? closure(ex) : void 0;
23
- };
24
-
25
- // src/lib/withErrnoException.ts
26
- var withErrnoException = (ex, closure) => {
27
- return withError(ex, closure, (ex2) => ex2.errno !== void 0);
28
- };
29
-
30
- // src/lib/processEx.ts
31
- var processEx = (ex) => {
32
- const error = typeof ex === "string" ? new Error(ex) : ex;
33
- const exitCode = withErrnoException(error, (error2) => {
34
- if (error2.code === "ENOENT") {
35
- console.error(chalk2.red(`'${error2.path}' not found.`));
36
- } else {
37
- console.error(chalk2.red(`Errno: ${error2.code}`));
38
- }
39
- return error2.errno ?? -1;
40
- }) ?? withError(error, (error2) => {
41
- console.error(chalk2.red(`${error2.name}: ${error2.message}`));
42
- return -1;
43
- }) ?? (() => {
44
- console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
45
- return -1;
46
- })();
47
- process.exit(process.exitCode ?? exitCode);
48
- };
49
-
50
- // src/lib/safeExit.ts
51
- var safeExit = (func, exitOnFail = true) => {
52
- try {
53
- const result = func();
54
- if (result && exitOnFail) {
55
- process.exit(result);
56
- }
57
- return result;
58
- } catch (ex) {
59
- return processEx(ex);
60
- }
61
- };
62
- var safeExitAsync = async (func, exitOnFail = true) => {
63
- try {
64
- const result = await func();
65
- if (result && exitOnFail) {
66
- process.exit(result);
67
- }
68
- return result;
69
- } catch (ex) {
70
- return processEx(ex);
71
- }
72
- };
73
-
74
- // src/lib/yarn/workspace/yarnWorkspaces.ts
75
- import { spawnSync } from "child_process";
76
- var yarnWorkspaces = () => {
77
- const result = spawnSync("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
78
- if (result.error) {
79
- throw result.error;
80
- }
81
- return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
82
- return JSON.parse(item);
83
- });
84
- };
85
-
86
- // src/lib/yarn/workspace/yarnWorkspace.ts
87
- var yarnWorkspace = (pkg) => {
88
- const workspace = yarnWorkspaces().find(({ name }) => name === pkg);
89
- if (!workspace) throw new Error(`Workspace ${pkg} not found`);
90
- return workspace;
91
- };
92
-
93
- // src/lib/yarn/yarnInitCwd.ts
94
- var INIT_CWD = () => {
95
- if (!process.env.INIT_CWD) console.error("Missing INIT_CWD");
96
- return process.env.INIT_CWD;
97
- };
98
-
99
- // src/lib/loadConfig.ts
100
- import chalk3 from "chalk";
101
- import { cosmiconfig } from "cosmiconfig";
102
- import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
103
- import deepmerge from "deepmerge";
104
- var config;
105
- var loadConfig = async (params) => {
106
- if (config === void 0) {
107
- const cosmicConfigResult = await cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } }).search();
108
- config = cosmicConfigResult?.config;
109
- const configFilePath = cosmicConfigResult?.filepath;
110
- if (configFilePath !== void 0) {
111
- console.log(chalk3.green(`Loaded config from ${configFilePath}`));
112
- if (config.verbose) {
113
- console.log(chalk3.gray(`${JSON.stringify(config, null, 2)}`));
114
- }
115
- }
116
- }
117
- return deepmerge(config, params ?? {});
118
- };
119
-
120
- // src/lib/runSteps.ts
121
- import { spawnSync as spawnSync2 } from "child_process";
122
- import { existsSync } from "fs";
123
- import chalk4 from "chalk";
124
- var runSteps = (name, steps, exitOnFail = true, messages) => {
125
- return safeExit(() => {
126
- const pkgName = process.env.npm_package_name;
127
- console.log(chalk4.green(`${name} [${pkgName}]`));
128
- let totalStatus = 0;
129
- for (const [i, [command, args, config2]] of steps.entries()) {
130
- if (messages?.[i]) {
131
- console.log(chalk4.gray(messages?.[i]));
132
- }
133
- const argList = Array.isArray(args) ? args : args.split(" ");
134
- if (command === "node" && !existsSync(argList[0])) {
135
- throw new Error(`File not found [${argList[0]}]`);
136
- }
137
- const status = spawnSync2(command, Array.isArray(args) ? args : args.split(" "), {
138
- ...config2,
139
- encoding: "utf8",
140
- env: { FORCE_COLOR: "3", ...process.env },
141
- shell: true,
142
- stdio: "inherit"
143
- }).status ?? 0;
144
- checkResult(name, status, "error", exitOnFail);
145
- totalStatus += status ?? 0;
146
- }
147
- return totalStatus;
148
- }, !!exitOnFail);
149
- };
150
-
151
- // src/lib/runStepsAsync.ts
152
- import { spawn } from "child_process";
153
- import { existsSync as existsSync2 } from "fs";
154
- import chalk5 from "chalk";
155
- var runStepAsync = (name, step, exitOnFail = true, message) => {
156
- return new Promise((resolve) => {
157
- const [command, args, config2] = step;
158
- if (message) {
159
- console.log(chalk5.gray(message));
160
- }
161
- const argList = Array.isArray(args) ? args : args.split(" ");
162
- if (command === "node" && !existsSync2(argList[0])) {
163
- throw new Error(`File not found [${argList[0]}]`);
164
- }
165
- spawn(command, Array.isArray(args) ? args : args.split(" "), {
166
- ...config2,
167
- env: { FORCE_COLOR: "3", ...process.env },
168
- shell: true,
169
- stdio: "inherit"
170
- }).on("close", (code) => {
171
- if (code) {
172
- console.error(
173
- chalk5.red(
174
- `Command Exited With Non-Zero Result [${chalk5.gray(code)}] | ${chalk5.yellow(command)} ${chalk5.white(
175
- Array.isArray(args) ? args.join(" ") : args
176
- )}`
177
- )
178
- );
179
- checkResult(name, code, "error", exitOnFail);
180
- resolve(code);
181
- } else {
182
- resolve(0);
183
- }
184
- });
185
- });
186
- };
187
- var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
188
- return await safeExitAsync(async () => {
189
- const pkgName = process.env.npm_package_name;
190
- console.log(chalk5.green(`${name} [${pkgName}]`));
191
- let result = 0;
192
- for (const [i, step] of steps.entries()) {
193
- result += await runStepAsync(name, step, exitOnFail, messages?.[i]);
194
- }
195
- return result;
196
- });
197
- };
198
-
199
- // src/actions/cycle.ts
200
- import { cruise } from "dependency-cruiser";
201
- var cycle = async ({ verbose, pkg } = {}) => {
202
- return pkg ? cyclePackage({ pkg, verbose }) : await cycleAll({ verbose });
203
- };
204
- var cyclePackage = ({ pkg, verbose }) => {
205
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
206
- return runSteps(
207
- `Cycle [${pkg}]`,
208
- [["yarn", ["workspace", pkg, "run", "package-cycle", ...verboseOptions]]]
209
- );
210
- };
211
- var cycleAll = async ({ verbose = false }) => {
212
- const pkgName = process.env.npm_package_name;
213
- const cruiseOptions = {
214
- ruleSet: {
215
- forbidden: [
216
- {
217
- name: "no-circular",
218
- severity: "error",
219
- comment: "This dependency creates a circular reference",
220
- from: {},
221
- to: { circular: true }
222
- }
223
- ]
224
- },
225
- exclude: "node_modules|packages/.*/packages",
226
- validate: true,
227
- doNotFollow: { path: "node_modules|packages/.*/packages" },
228
- tsPreCompilationDeps: false,
229
- combinedDependencies: true,
230
- outputType: verbose ? "text" : "err"
231
- };
232
- const target = "**/packages/*/src";
233
- console.log(`Checking for circular dependencies in ${target}...`);
234
- const result = await cruise([target], cruiseOptions);
235
- if (result.output) {
236
- console.log(result.output);
237
- }
238
- if (result.exitCode === 0) {
239
- console.log(`${pkgName} \u2705 No dependency violations`);
240
- } else {
241
- console.error(`${pkgName} \u274C Dependency violations found`);
242
- }
243
- return result.exitCode;
244
- };
245
-
246
- // src/actions/deplint/deplint.ts
247
- import chalk11 from "chalk";
248
-
249
- // src/actions/deplint/findFiles.ts
250
- import fs from "fs";
251
-
252
- // src/actions/deplint/findFilesByGlob.ts
253
- import { globSync } from "glob";
254
- function findFilesByGlob(cwd, pattern, ignore) {
255
- return globSync(pattern, {
256
- cwd,
257
- absolute: true,
258
- ignore,
259
- nodir: true
260
- });
261
- }
262
-
263
- // src/actions/deplint/findFiles.ts
264
- var codeExtensions = "*.{ts,tsx,mts,cts,js,mjs,cjs}";
265
- function getWorkspaceIgnores(location) {
266
- try {
267
- const raw = fs.readFileSync(`${location}/package.json`, "utf8");
268
- const pkg = JSON.parse(raw);
269
- return pkg.workspaces ?? [];
270
- } catch {
271
- return [];
272
- }
273
- }
274
- function findFiles(location) {
275
- const workspaceIgnores = getWorkspaceIgnores(location).map((w) => `${w}/**`);
276
- const ignore = ["**/node_modules/**", "dist/**", ...workspaceIgnores];
277
- const allFiles = findFilesByGlob(location, `./**/${codeExtensions}`, ignore);
278
- const distFiles = [
279
- ...findFilesByGlob(location, "./dist/**/*.d.ts"),
280
- ...findFilesByGlob(location, `./dist/**/${codeExtensions}`)
281
- ];
282
- return { allFiles, distFiles };
283
- }
284
-
285
- // src/actions/deplint/getDependenciesFromPackageJson.ts
286
- import fs2 from "fs";
287
- import path from "path";
288
- function getDependenciesFromPackageJson(packageJsonPath) {
289
- const packageJsonFullPath = path.resolve(packageJsonPath);
290
- const rawContent = fs2.readFileSync(packageJsonFullPath, "utf8");
291
- const packageJson = JSON.parse(rawContent);
292
- const dependencies = packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
293
- const devDependencies = packageJson.devDependencies ? Object.keys(packageJson.devDependencies) : [];
294
- const peerDependencies = packageJson.peerDependencies ? Object.keys(packageJson.peerDependencies) : [];
295
- return {
296
- dependencies,
297
- devDependencies,
298
- peerDependencies
299
- };
300
- }
301
-
302
- // src/actions/deplint/getExtendsFromTsconfigs.ts
303
- import fs3 from "fs";
304
- import { globSync as globSync2 } from "glob";
305
-
306
- // src/actions/deplint/getBasePackageName.ts
307
- function getBasePackageName(importName) {
308
- const importNameScrubbed = importName.replaceAll('"', "").trim();
309
- if (importNameScrubbed.startsWith("@")) {
310
- const parts = importNameScrubbed.split("/");
311
- return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : importNameScrubbed;
312
- }
313
- return importNameScrubbed.split("/")[0];
314
- }
315
-
316
- // src/actions/deplint/getExtendsFromTsconfigs.ts
317
- var isExternalReference = (ref) => !ref.startsWith(".") && !ref.startsWith("/");
318
- function parseExtendsField(value) {
319
- if (typeof value === "string") return [value];
320
- if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
321
- return [];
322
- }
323
- function getExtendsFromTsconfigs(location) {
324
- const tsconfigFiles = globSync2("./tsconfig*.json", { cwd: location, absolute: true });
325
- const packages = /* @__PURE__ */ new Set();
326
- for (const file of tsconfigFiles) {
327
- try {
328
- const content = fs3.readFileSync(file, "utf8");
329
- const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
330
- const parsed = JSON.parse(cleaned);
331
- const refs = parseExtendsField(parsed.extends);
332
- for (const ref of refs) {
333
- if (isExternalReference(ref)) {
334
- packages.add(getBasePackageName(ref));
335
- }
336
- }
337
- } catch {
338
- }
339
- }
340
- return [...packages];
341
- }
342
-
343
- // src/actions/deplint/getImportsFromFile.ts
344
- import fs4 from "fs";
345
- import path2 from "path";
346
- import ts from "typescript";
347
- function isTypeOnlyImportClause(clause) {
348
- if (clause === void 0) {
349
- return false;
350
- }
351
- if ("phaseModifier" in clause) {
352
- const mod = clause.phaseModifier;
353
- const kind = typeof mod === "number" ? mod : mod?.kind;
354
- return kind === ts.SyntaxKind.TypeKeyword;
355
- }
356
- return clause.isTypeOnly;
357
- }
358
- function getImportsFromFile(filePath, importPaths, typeImportPaths) {
359
- const sourceCode = fs4.readFileSync(filePath, "utf8");
360
- const isMjsFile = filePath.endsWith(".mjs");
361
- const sourceFile = ts.createSourceFile(
362
- path2.basename(filePath),
363
- sourceCode,
364
- ts.ScriptTarget.Latest,
365
- true,
366
- isMjsFile ? ts.ScriptKind.JS : void 0
367
- );
368
- const imports = [];
369
- const typeImports = [];
370
- const isDeclarationFile2 = filePath.endsWith(".d.ts");
371
- function visit(node) {
372
- if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
373
- const moduleSpecifier = node.moduleSpecifier?.getFullText();
374
- const isTypeImport = ts.isImportDeclaration(node) ? isTypeOnlyImportClause(node.importClause) : false;
375
- if (typeof moduleSpecifier === "string") {
376
- const trimmed = moduleSpecifier.replaceAll("'", "").replaceAll('"', "").trim();
377
- if (isTypeImport || isDeclarationFile2) {
378
- typeImports.push(trimmed);
379
- } else {
380
- imports.push(trimmed);
381
- }
382
- }
383
- } else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
384
- const [arg] = node.arguments;
385
- if (ts.isStringLiteral(arg)) {
386
- imports.push(arg.text);
387
- }
388
- } else if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "require" && node.arguments.length > 0 && ts.isStringLiteral(node.arguments[0])) {
389
- imports.push(node.arguments[0].text);
390
- }
391
- ts.forEachChild(node, visit);
392
- }
393
- visit(sourceFile);
394
- for (const ref of sourceFile.typeReferenceDirectives) {
395
- typeImports.push(ref.fileName);
396
- }
397
- const importsStartsWithExcludes = [".", "#", "node:"];
398
- const isValidImport = (imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc)) && !imp.includes("*") && !imp.includes("!");
399
- const cleanedImports = imports.filter(isValidImport).map(getBasePackageName);
400
- const cleanedTypeImports = typeImports.filter(isValidImport).map(getBasePackageName);
401
- for (const imp of cleanedImports) {
402
- importPaths[imp] = importPaths[imp] ?? [];
403
- importPaths[imp].push(filePath);
404
- }
405
- for (const imp of cleanedTypeImports) {
406
- typeImportPaths[imp] = typeImportPaths[imp] ?? [];
407
- typeImportPaths[imp].push(filePath);
408
- }
409
- return [cleanedImports, cleanedTypeImports];
410
- }
411
-
412
- // src/actions/deplint/getExternalImportsFromFiles.ts
413
- var internalImportPrefixes = [".", "#", "node:"];
414
- var removeInternalImports = (imports) => {
415
- return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
416
- };
417
- var isDeclarationFile = (file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts");
418
- function getExternalImportsFromFiles({
419
- allFiles,
420
- distFiles,
421
- tsconfigExtends = []
422
- }) {
423
- const allImportPaths = {};
424
- const distImportPaths = {};
425
- const distTypeImportPaths = {};
426
- for (const path6 of allFiles) getImportsFromFile(path6, allImportPaths, allImportPaths).flat();
427
- const distTypeFiles = distFiles.filter(isDeclarationFile);
428
- const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
429
- for (const path6 of distCodeFiles) getImportsFromFile(path6, distImportPaths, distImportPaths).flat();
430
- for (const path6 of distTypeFiles) getImportsFromFile(path6, distTypeImportPaths, distTypeImportPaths).flat();
431
- const allImports = Object.keys(allImportPaths);
432
- const distImports = Object.keys(distImportPaths);
433
- const externalAllImports = removeInternalImports(allImports);
434
- const externalDistImports = removeInternalImports(distImports);
435
- const externalDistTypeImports = removeInternalImports(Object.keys(distTypeImportPaths));
436
- for (const ext of tsconfigExtends) {
437
- if (!externalAllImports.includes(ext)) externalAllImports.push(ext);
438
- }
439
- return {
440
- allImportPaths,
441
- allImports,
442
- distImportPaths,
443
- distImports,
444
- externalAllImports,
445
- externalDistImports,
446
- externalDistTypeImports
447
- };
448
- }
449
-
450
- // src/actions/deplint/checkPackage/getUnlistedDependencies.ts
451
- import { builtinModules } from "module";
452
- import chalk6 from "chalk";
453
- function isRuntimeImportListed(imp, name, dependencies, peerDependencies) {
454
- return dependencies.includes(imp) || imp === name || peerDependencies.includes(imp) || builtinModules.includes(imp);
455
- }
456
- function isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies) {
457
- return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || devDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp);
458
- }
459
- function logMissing(name, imp, importPaths) {
460
- console.log(`[${chalk6.blue(name)}] Missing dependency in package.json: ${chalk6.red(imp)}`);
461
- if (importPaths[imp]) {
462
- console.log(` ${importPaths[imp].join("\n ")}`);
463
- }
464
- }
465
- function getUnlistedDependencies({ name, location }, {
466
- dependencies,
467
- devDependencies,
468
- peerDependencies
469
- }, {
470
- externalDistImports,
471
- externalDistTypeImports,
472
- distImportPaths
473
- }) {
474
- let unlistedDependencies = 0;
475
- for (const imp of externalDistImports) {
476
- if (!isRuntimeImportListed(imp, name, dependencies, peerDependencies)) {
477
- unlistedDependencies++;
478
- logMissing(name, imp, distImportPaths);
479
- }
480
- }
481
- for (const imp of externalDistTypeImports) {
482
- if (!isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies)) {
483
- unlistedDependencies++;
484
- logMissing(name, imp, distImportPaths);
485
- }
486
- }
487
- if (unlistedDependencies > 0) {
488
- const packageLocation = `${location}/package.json`;
489
- console.log(` ${chalk6.yellow(packageLocation)}
490
- `);
491
- }
492
- return unlistedDependencies;
493
- }
494
-
495
- // src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
496
- import { builtinModules as builtinModules2 } from "module";
497
- import chalk7 from "chalk";
498
- function getUnlistedDevDependencies({ name, location }, {
499
- devDependencies,
500
- dependencies,
501
- peerDependencies
502
- }, {
503
- allImportPaths,
504
- externalAllImports,
505
- distImports
506
- }) {
507
- let unlistedDevDependencies = 0;
508
- for (const imp of externalAllImports) {
509
- if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
510
- unlistedDevDependencies++;
511
- console.log(`[${chalk7.blue(name)}] Missing devDependency in package.json: ${chalk7.red(imp)}`);
512
- if (allImportPaths[imp]) {
513
- console.log(` ${allImportPaths[imp].join("\n ")}`);
514
- }
515
- }
516
- }
517
- if (unlistedDevDependencies > 0) {
518
- const packageLocation = `${location}/package.json`;
519
- console.log(` ${chalk7.yellow(packageLocation)}
520
- `);
521
- }
522
- return unlistedDevDependencies;
523
- }
524
-
525
- // src/actions/deplint/checkPackage/getUnusedDependencies.ts
526
- import chalk8 from "chalk";
527
- function getUnusedDependencies({ name, location }, { dependencies }, {
528
- externalDistImports,
529
- externalDistTypeImports,
530
- externalAllImports
531
- }, exclude) {
532
- let unusedDependencies = 0;
533
- for (const dep of dependencies) {
534
- if (exclude?.has(dep)) continue;
535
- if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
536
- unusedDependencies++;
537
- if (externalAllImports.includes(dep)) {
538
- console.log(`[${chalk8.blue(name)}] dependency should be devDependency in package.json: ${chalk8.red(dep)}`);
539
- } else {
540
- console.log(`[${chalk8.blue(name)}] Unused dependency in package.json: ${chalk8.red(dep)}`);
541
- }
542
- }
543
- }
544
- if (unusedDependencies > 0) {
545
- const packageLocation = `${location}/package.json`;
546
- console.log(` ${chalk8.yellow(packageLocation)}
547
- `);
548
- }
549
- return unusedDependencies;
550
- }
551
-
552
- // src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
553
- import chalk9 from "chalk";
554
-
555
- // src/actions/deplint/getCliReferencedPackagesFromFiles.ts
556
- import fs7 from "fs";
557
- import path5 from "path";
558
- import ts2 from "typescript";
559
-
560
- // src/actions/deplint/getScriptReferencedPackages.ts
561
- import fs6 from "fs";
562
- import path4 from "path";
563
-
564
- // src/actions/deplint/getRequiredPeerDependencies.ts
565
- import fs5 from "fs";
566
- import path3 from "path";
567
- function findDepPackageJson(location, dep) {
568
- let dir = location;
569
- while (true) {
570
- const candidate = path3.join(dir, "node_modules", dep, "package.json");
571
- if (fs5.existsSync(candidate)) return candidate;
572
- const parent = path3.dirname(dir);
573
- if (parent === dir) return void 0;
574
- dir = parent;
575
- }
576
- }
577
- function getRequiredPeerDependencies(location, allDeps) {
578
- const required = /* @__PURE__ */ new Set();
579
- for (const dep of allDeps) {
580
- const depPkgPath = findDepPackageJson(location, dep);
581
- if (!depPkgPath) continue;
582
- try {
583
- const raw = fs5.readFileSync(depPkgPath, "utf8");
584
- const pkg = JSON.parse(raw);
585
- if (pkg.peerDependencies) {
586
- for (const peer of Object.keys(pkg.peerDependencies)) {
587
- required.add(peer);
588
- }
589
- }
590
- } catch {
591
- }
592
- }
593
- return required;
594
- }
595
-
596
- // src/actions/deplint/getScriptReferencedPackages.ts
597
- function getBinNames(location, dep) {
598
- const depPkgPath = findDepPackageJson(location, dep);
599
- if (!depPkgPath) return [];
600
- try {
601
- const raw = fs6.readFileSync(depPkgPath, "utf8");
602
- const pkg = JSON.parse(raw);
603
- if (!pkg.bin) return [];
604
- if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
605
- return Object.keys(pkg.bin);
606
- } catch {
607
- return [];
608
- }
609
- }
610
- function tokenizeScript(script) {
611
- return script.split(/[&|;$()"`\s]+/).map((t) => t.trim()).filter(Boolean);
612
- }
613
- function getScriptReferencedPackages(location, allDeps) {
614
- const pkgPath = path4.join(location, "package.json");
615
- let scripts = {};
616
- try {
617
- const raw = fs6.readFileSync(pkgPath, "utf8");
618
- const pkg = JSON.parse(raw);
619
- scripts = pkg.scripts ?? {};
620
- } catch {
621
- return /* @__PURE__ */ new Set();
622
- }
623
- const scriptText = Object.values(scripts).join(" ");
624
- const tokens = new Set(tokenizeScript(scriptText));
625
- const binToPackage = /* @__PURE__ */ new Map();
626
- for (const dep of allDeps) {
627
- const bins = getBinNames(location, dep);
628
- for (const bin of bins) {
629
- binToPackage.set(bin, dep);
630
- }
631
- }
632
- const referenced = /* @__PURE__ */ new Set();
633
- for (const token of tokens) {
634
- const baseName = getBasePackageName(token);
635
- if (allDeps.includes(baseName)) {
636
- referenced.add(baseName);
637
- }
638
- const pkg = binToPackage.get(token);
639
- if (pkg) {
640
- referenced.add(pkg);
641
- }
642
- }
643
- return referenced;
644
- }
645
-
646
- // src/actions/deplint/getCliReferencedPackagesFromFiles.ts
647
- var shellCommandFunctions = /* @__PURE__ */ new Set(["execSync", "exec"]);
648
- var directExecFunctions = /* @__PURE__ */ new Set(["spawn", "spawnSync", "execFile", "execFileSync"]);
649
- var allExecFunctions = /* @__PURE__ */ new Set([...shellCommandFunctions, ...directExecFunctions]);
650
- function getCommandTokensFromFile(filePath) {
651
- const tokens = /* @__PURE__ */ new Set();
652
- let sourceCode;
653
- try {
654
- sourceCode = fs7.readFileSync(filePath, "utf8");
655
- } catch {
656
- return tokens;
657
- }
658
- const isMjsFile = filePath.endsWith(".mjs");
659
- const sourceFile = ts2.createSourceFile(
660
- path5.basename(filePath),
661
- sourceCode,
662
- ts2.ScriptTarget.Latest,
663
- true,
664
- isMjsFile ? ts2.ScriptKind.JS : void 0
665
- );
666
- function visit(node) {
667
- if (ts2.isCallExpression(node) && node.arguments.length > 0) {
668
- const fnName = getFunctionName(node.expression);
669
- if (fnName && allExecFunctions.has(fnName)) {
670
- const firstArg = node.arguments[0];
671
- if (ts2.isStringLiteral(firstArg) || ts2.isNoSubstitutionTemplateLiteral(firstArg)) {
672
- const value = firstArg.text;
673
- if (shellCommandFunctions.has(fnName)) {
674
- for (const token of tokenizeScript(value)) {
675
- tokens.add(token);
676
- }
677
- } else {
678
- tokens.add(value);
679
- }
680
- } else if (ts2.isTemplateExpression(firstArg)) {
681
- const head = firstArg.head.text;
682
- if (head) {
683
- for (const token of tokenizeScript(head)) {
684
- tokens.add(token);
685
- }
686
- }
687
- }
688
- }
689
- }
690
- ts2.forEachChild(node, visit);
691
- }
692
- visit(sourceFile);
693
- return tokens;
694
- }
695
- function getFunctionName(expr) {
696
- if (ts2.isIdentifier(expr)) {
697
- return expr.text;
698
- }
699
- if (ts2.isPropertyAccessExpression(expr) && ts2.isIdentifier(expr.name)) {
700
- return expr.name.text;
701
- }
702
- return void 0;
703
- }
704
- function getCliReferencedPackagesFromFiles(allFiles, location, allDeps) {
705
- const allTokens = /* @__PURE__ */ new Set();
706
- for (const file of allFiles) {
707
- for (const token of getCommandTokensFromFile(file)) {
708
- allTokens.add(token);
709
- }
710
- }
711
- if (allTokens.size === 0) return /* @__PURE__ */ new Set();
712
- const binToPackage = /* @__PURE__ */ new Map();
713
- for (const dep of allDeps) {
714
- for (const bin of getBinNames(location, dep)) {
715
- binToPackage.set(bin, dep);
716
- }
717
- }
718
- const referenced = /* @__PURE__ */ new Set();
719
- for (const token of allTokens) {
720
- const baseName = getBasePackageName(token);
721
- if (allDeps.includes(baseName)) {
722
- referenced.add(baseName);
723
- }
724
- const pkg = binToPackage.get(token);
725
- if (pkg) {
726
- referenced.add(pkg);
727
- }
728
- }
729
- return referenced;
730
- }
731
-
732
- // src/actions/deplint/implicitDevDependencies.ts
733
- import fs8 from "fs";
734
- var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
735
- var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
736
- var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
737
- var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
738
- var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
739
- try {
740
- const content = fs8.readFileSync(file, "utf8");
741
- return decoratorPattern.test(content);
742
- } catch {
743
- return false;
744
- }
745
- });
746
- var importPlugins = /* @__PURE__ */ new Set(["eslint-plugin-import-x", "eslint-plugin-import"]);
747
- function hasImportPlugin({ location, allDependencies }) {
748
- if (allDependencies.some((d) => importPlugins.has(d))) return true;
749
- for (const dep of allDependencies) {
750
- const pkgPath = findDepPackageJson(location, dep);
751
- if (!pkgPath) continue;
752
- try {
753
- const pkg = JSON.parse(fs8.readFileSync(pkgPath, "utf8"));
754
- const transitiveDeps = [
755
- ...Object.keys(pkg.dependencies ?? {}),
756
- ...Object.keys(pkg.peerDependencies ?? {})
757
- ];
758
- if (transitiveDeps.some((d) => importPlugins.has(d))) return true;
759
- } catch {
760
- }
761
- }
762
- return false;
763
- }
764
- var hasVitest = ({ allDependencies }) => allDependencies.includes("vitest");
765
- var rules = [
766
- {
767
- package: "typescript",
768
- isNeeded: hasTypescriptFiles
769
- },
770
- {
771
- package: "eslint-import-resolver-typescript",
772
- isNeeded: (context) => hasTypescriptFiles(context) && context.allDependencies.includes("eslint") && hasImportPlugin(context)
773
- },
774
- {
775
- package: "tslib",
776
- isNeeded: hasDecorators
777
- },
778
- {
779
- package: "@vitest/coverage-v8",
780
- isNeeded: hasVitest
781
- }
782
- ];
783
- function getImplicitDevDependencies(context) {
784
- const implicit = /* @__PURE__ */ new Set();
785
- for (const rule of rules) {
786
- if (rule.isNeeded(context)) {
787
- implicit.add(rule.package);
788
- }
789
- }
790
- return implicit;
791
- }
792
-
793
- // src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
794
- var allExternalImports = ({
795
- externalAllImports,
796
- externalDistImports,
797
- externalDistTypeImports
798
- }) => {
799
- return /* @__PURE__ */ new Set([
800
- ...externalAllImports,
801
- ...externalDistImports,
802
- ...externalDistTypeImports
803
- ]);
804
- };
805
- function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs) {
806
- if (implicitDeps.has(dep)) return true;
807
- if (requiredPeers.has(dep)) return true;
808
- if (scriptRefs.has(dep)) return true;
809
- if (cliRefs.has(dep)) return true;
810
- if (dep.startsWith("@types/")) {
811
- const baseName = dep.replace(/^@types\//, "");
812
- return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
813
- }
814
- return allImports.has(dep);
815
- }
816
- function getUnusedDevDependencies({ name, location }, {
817
- devDependencies,
818
- dependencies,
819
- peerDependencies
820
- }, sourceParams, fileContext, exclude) {
821
- const allImports = allExternalImports(sourceParams);
822
- const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
823
- const implicitDeps = getImplicitDevDependencies({
824
- ...fileContext,
825
- allDependencies: allDeps,
826
- location
827
- });
828
- const requiredPeers = getRequiredPeerDependencies(location, allDeps);
829
- const scriptRefs = getScriptReferencedPackages(location, allDeps);
830
- const cliRefs = getCliReferencedPackagesFromFiles(fileContext.allFiles, location, allDeps);
831
- let unusedDevDependencies = 0;
832
- for (const dep of devDependencies) {
833
- if (exclude?.has(dep)) continue;
834
- if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
835
- if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
836
- unusedDevDependencies++;
837
- console.log(`[${chalk9.blue(name)}] Unused devDependency in package.json: ${chalk9.red(dep)}`);
838
- }
839
- }
840
- if (unusedDevDependencies > 0) {
841
- const packageLocation = `${location}/package.json`;
842
- console.log(` ${chalk9.yellow(packageLocation)}
843
- `);
844
- }
845
- return unusedDevDependencies;
846
- }
847
-
848
- // src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
849
- import chalk10 from "chalk";
850
- function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
851
- let unusedDependencies = 0;
852
- for (const dep of peerDependencies) {
853
- if (exclude?.has(dep)) continue;
854
- if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
855
- unusedDependencies++;
856
- if (dependencies.includes(dep)) {
857
- console.log(`[${chalk10.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk10.red(dep)}`);
858
- } else {
859
- console.log(`[${chalk10.blue(name)}] Unused peerDependency in package.json: ${chalk10.red(dep)}`);
860
- }
861
- }
862
- }
863
- if (unusedDependencies > 0) {
864
- const packageLocation = `${location}/package.json`;
865
- console.log(` ${chalk10.yellow(packageLocation)}
866
- `);
867
- }
868
- return unusedDependencies;
869
- }
870
-
871
- // src/actions/deplint/checkPackage/checkPackage.ts
872
- function logVerbose(name, location, allFiles, distFiles, tsconfigExtends) {
873
- console.info(`Checking package: ${name} at ${location}`);
874
- console.info(`All files: ${allFiles.length}, Distribution files: ${distFiles.length}`);
875
- for (const file of allFiles) {
876
- console.info(`File: ${file}`);
877
- }
878
- for (const file of distFiles) {
879
- console.info(`Distribution file: ${file}`);
880
- }
881
- for (const ext of tsconfigExtends) {
882
- console.info(`Tsconfig extends: ${ext}`);
883
- }
884
- }
885
- function checkPackage({
886
- name,
887
- location,
888
- deps = false,
889
- devDeps = false,
890
- exclude,
891
- peerDeps = false,
892
- verbose = false
893
- }) {
894
- const { allFiles, distFiles } = findFiles(location);
895
- const tsconfigExtends = getExtendsFromTsconfigs(location);
896
- if (verbose) {
897
- logVerbose(name, location, allFiles, distFiles, tsconfigExtends);
898
- }
899
- const checkDeps = deps || !(deps || devDeps || peerDeps);
900
- const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
901
- const checkPeerDeps = peerDeps;
902
- const sourceParams = getExternalImportsFromFiles({
903
- allFiles,
904
- distFiles,
905
- tsconfigExtends
906
- });
907
- const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
908
- const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
909
- const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
910
- const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
911
- const fileContext = { allFiles, distFiles };
912
- const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext, exclude) : 0;
913
- const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
914
- const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
915
- return totalErrors;
916
- }
917
-
918
- // src/actions/deplint/deplint.ts
919
- var deplint = async ({
920
- pkg,
921
- deps,
922
- devDeps,
923
- peerDeps,
924
- verbose,
925
- cliExclude
926
- }) => {
927
- const config2 = await loadConfig();
928
- const exclude = /* @__PURE__ */ new Set([
929
- ...config2.deplint?.exclude ?? [],
930
- ...cliExclude ?? []
931
- ]);
932
- let totalErrors = 0;
933
- if (pkg === void 0) {
934
- const workspaces = yarnWorkspaces();
935
- console.info("Deplint Started...");
936
- for (const workspace of workspaces) {
937
- totalErrors += checkPackage({
938
- ...workspace,
939
- deps,
940
- devDeps,
941
- exclude,
942
- peerDeps,
943
- verbose
944
- });
945
- }
946
- } else {
947
- const { location, name } = yarnWorkspace(pkg);
948
- console.info(`Running Deplint for ${name}`);
949
- totalErrors += checkPackage({
950
- name,
951
- location,
952
- devDeps,
953
- deps,
954
- exclude,
955
- peerDeps,
956
- verbose
957
- });
958
- }
959
- if (totalErrors > 0) {
960
- console.warn(`Deplint: Found ${chalk11.red(totalErrors)} dependency problems. ${chalk11.red("\u2716")}`);
961
- } else {
962
- console.info(`Deplint: Found no dependency problems. ${chalk11.green("\u2714")}`);
963
- }
964
- return 0;
965
- };
966
-
967
- // src/actions/lint.ts
968
- import chalk12 from "chalk";
969
- var lintPackage = ({
970
- pkg,
971
- fix: fix2,
972
- verbose
973
- }) => {
974
- console.log(chalk12.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
975
- const start = Date.now();
976
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
977
- ["yarn", [
978
- "workspace",
979
- pkg,
980
- "run",
981
- fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
982
- ]]
983
- ]);
984
- console.log(chalk12.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`));
985
- return result;
986
- };
987
- var lint = ({
988
- pkg,
989
- verbose,
990
- incremental,
991
- fix: fix2
992
- } = {}) => {
993
- return pkg === void 0 ? lintAllPackages({
994
- verbose,
995
- incremental,
996
- fix: fix2
997
- }) : lintPackage({
998
- pkg,
999
- fix: fix2,
1000
- verbose
1001
- });
1002
- };
1003
- var lintAllPackages = ({ fix: fix2 = false } = {}) => {
1004
- console.log(chalk12.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
1005
- const start = Date.now();
1006
- const fixOptions = fix2 ? ["--fix"] : [];
1007
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
1008
- ["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
1009
- ]);
1010
- console.log(chalk12.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`));
1011
- return result;
1012
- };
1013
-
1014
- // src/actions/fix.ts
1015
- var fix = (params) => {
1016
- return lint({ ...params, fix: true });
1017
- };
1018
-
1019
- // src/actions/knip.ts
1020
- var knip = () => {
1021
- return runSteps("Knip", [["yarn", ["knip", "--dependencies", "--no-exit-code"]]]);
1022
- };
1023
-
1024
- // src/actions/package-lint.ts
1025
- import { readFileSync, writeFileSync } from "fs";
1026
- import PATH from "path";
1027
- import chalk13 from "chalk";
1028
- import picomatch from "picomatch";
1029
- function emptyResult() {
1030
- return {
1031
- errors: [],
1032
- fixable: [],
1033
- warnings: []
1034
- };
1035
- }
1036
- function readRootPackageJson(cwd) {
1037
- const raw = readFileSync(PATH.resolve(cwd, "package.json"), "utf8");
1038
- return JSON.parse(raw);
1039
- }
1040
- function writeRootPackageJson(cwd, pkg) {
1041
- const path6 = PATH.resolve(cwd, "package.json");
1042
- writeFileSync(path6, `${JSON.stringify(pkg, null, 2)}
1043
- `, "utf8");
1044
- }
1045
- function isMonorepo(pkg) {
1046
- const workspaces = pkg.workspaces;
1047
- return Array.isArray(workspaces) && workspaces.length > 0;
1048
- }
1049
- function checkPackagesFolder(workspaces) {
1050
- const result = emptyResult();
1051
- for (const { location, name } of workspaces) {
1052
- if (location === ".") continue;
1053
- if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
1054
- result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
1055
- }
1056
- }
1057
- return result;
1058
- }
1059
- function checkRootPrivate(pkg) {
1060
- const result = emptyResult();
1061
- if (!pkg.private) {
1062
- result.fixable.push("Root package.json must be private to prevent accidental publishing");
1063
- }
1064
- return result;
1065
- }
1066
- function fixRootPrivate(cwd, pkg) {
1067
- pkg.private = true;
1068
- writeRootPackageJson(cwd, pkg);
1069
- console.log(chalk13.green(' \u2714 Fixed: set "private": true in root package.json'));
1070
- }
1071
- function checkNoPublishConfigOnPrivate(pkg) {
1072
- const result = emptyResult();
1073
- if (pkg.private && pkg.publishConfig) {
1074
- result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
1075
- }
1076
- return result;
1077
- }
1078
- function fixNoPublishConfigOnPrivate(cwd, pkg) {
1079
- delete pkg.publishConfig;
1080
- writeRootPackageJson(cwd, pkg);
1081
- console.log(chalk13.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
1082
- }
1083
- function checkDiscoverable(pkg, workspaces) {
1084
- const result = emptyResult();
1085
- const globs = pkg.workspaces;
1086
- const matchers = globs.map((glob) => picomatch(glob));
1087
- const isMatch = (location) => matchers.some((m) => m(location));
1088
- for (const { location, name } of workspaces) {
1089
- if (location === ".") continue;
1090
- if (!isMatch(location)) {
1091
- result.errors.push(`${name} (${location}) is not matched by any workspace glob in package.json`);
1092
- }
1093
- }
1094
- return result;
1095
- }
1096
- function logResults(label, result, fix2) {
1097
- let errors = 0;
1098
- let fixed = 0;
1099
- for (const error of result.errors) {
1100
- console.log(chalk13.red(` \u2717 ${error}`));
1101
- errors++;
1102
- }
1103
- for (const fixable of result.fixable) {
1104
- if (fix2) {
1105
- fixed++;
1106
- } else {
1107
- console.log(chalk13.red(` \u2717 ${fixable} (fixable)`));
1108
- errors++;
1109
- }
1110
- }
1111
- for (const warning of result.warnings) {
1112
- console.log(chalk13.yellow(` \u26A0 ${warning}`));
1113
- }
1114
- if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
1115
- console.log(chalk13.green(` \u2713 ${label}`));
1116
- }
1117
- return { errors, fixed };
1118
- }
1119
- function runChecks(entries, cwd, pkg, fix2) {
1120
- let totalErrors = 0;
1121
- let totalFixed = 0;
1122
- for (const entry of entries) {
1123
- const result = entry.check();
1124
- const log = logResults(entry.label, result, fix2);
1125
- if (fix2 && entry.fix && result.fixable.length > 0) {
1126
- entry.fix(cwd, pkg);
1127
- }
1128
- totalErrors += log.errors;
1129
- totalFixed += log.fixed;
1130
- }
1131
- return { errors: totalErrors, fixed: totalFixed };
1132
- }
1133
- function logSummary(errors, fixed) {
1134
- if (fixed > 0) {
1135
- console.log(chalk13.green(`
1136
- Fixed ${fixed} issue(s)`));
1137
- }
1138
- if (errors > 0) {
1139
- console.log(chalk13.red(`
1140
- ${errors} error(s) found`));
1141
- } else if (fixed === 0) {
1142
- console.log(chalk13.green("\n All checks passed"));
1143
- }
1144
- }
1145
- function packageLintMonorepo(fix2 = false) {
1146
- const cwd = INIT_CWD() ?? process.cwd();
1147
- let pkg;
1148
- try {
1149
- pkg = readRootPackageJson(cwd);
1150
- } catch {
1151
- console.error(chalk13.red("Could not read package.json"));
1152
- return 1;
1153
- }
1154
- if (!isMonorepo(pkg)) {
1155
- console.log(chalk13.gray("Not a monorepo \u2014 skipping package-lint checks"));
1156
- return 0;
1157
- }
1158
- console.log(chalk13.green("Package Lint"));
1159
- const workspaces = yarnWorkspaces();
1160
- const checks = [
1161
- {
1162
- check: () => checkRootPrivate(pkg),
1163
- fix: fixRootPrivate,
1164
- label: "Root package is private"
1165
- },
1166
- {
1167
- check: () => checkNoPublishConfigOnPrivate(pkg),
1168
- fix: fixNoPublishConfigOnPrivate,
1169
- label: "No publishConfig on private root"
1170
- },
1171
- { check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
1172
- { check: () => checkDiscoverable(pkg, workspaces), label: "All packages are discoverable from workspace globs" }
1173
- ];
1174
- const { errors, fixed } = runChecks(checks, cwd, pkg, fix2);
1175
- logSummary(errors, fixed);
1176
- return errors > 0 ? 1 : 0;
1177
- }
1178
-
1179
- // src/actions/publint.ts
1180
- var publint = async ({ verbose, pkg }) => {
1181
- return pkg === void 0 ? publintAll({ verbose }) : await publintPackage({ pkg, verbose });
1182
- };
1183
- var publintPackage = ({ pkg }) => {
1184
- return runStepsAsync(`Publint [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-publint"]]]);
1185
- };
1186
- var publintAll = ({ verbose }) => {
1187
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
1188
- return runSteps("Publint", [["yarn", ["workspaces", "foreach", "-pA", ...verboseOptions, "run", "package-publint"]]]);
1189
- };
1190
-
1191
- // src/actions/relint.ts
1192
- import chalk14 from "chalk";
1193
- var relintPackage = ({
1194
- pkg,
1195
- fix: fix2,
1196
- verbose
1197
- }) => {
1198
- console.log(chalk14.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
1199
- const start = Date.now();
1200
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
1201
- ["yarn", [
1202
- "workspace",
1203
- pkg,
1204
- "run",
1205
- fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
1206
- ]]
1207
- ]);
1208
- console.log(chalk14.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk14.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk14.gray("seconds")}`));
1209
- return result;
1210
- };
1211
- var relint = ({
1212
- pkg,
1213
- verbose,
1214
- incremental,
1215
- fix: fix2
1216
- } = {}) => {
1217
- return pkg === void 0 ? relintAllPackages({
1218
- verbose,
1219
- incremental,
1220
- fix: fix2
1221
- }) : relintPackage({
1222
- pkg,
1223
- fix: fix2,
1224
- verbose
1225
- });
1226
- };
1227
- var relintAllPackages = ({ fix: fix2 = false } = {}) => {
1228
- console.log(chalk14.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
1229
- const start = Date.now();
1230
- const fixOptions = fix2 ? ["--fix"] : [];
1231
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
1232
- ["yarn", ["eslint", ...fixOptions]]
1233
- ]);
1234
- console.log(chalk14.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk14.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk14.gray("seconds")}`));
1235
- return result;
1236
- };
1237
-
1238
- // src/actions/sonar.ts
1239
- var sonar = () => {
1240
- return runSteps("Sonar", [["yarn", ["eslint", "-c", "sonar.eslintrc", "."]]]);
1241
- };
1242
-
1243
- // src/xy/param.ts
1244
- var packagePositionalParam = (yargs) => {
1245
- return yargs.positional("package", { describe: "Specific package to target", type: "string" });
1246
- };
1247
-
1248
- // src/xy/lint/cycleCommand.ts
1249
- var cycleCommand = {
1250
- command: "cycle [package]",
1251
- describe: "Cycle - Check for dependency cycles",
1252
- builder: (yargs) => {
1253
- return packagePositionalParam(yargs);
1254
- },
1255
- handler: async (argv) => {
1256
- const start = Date.now();
1257
- if (argv.verbose) console.log("Cycle");
1258
- process.exitCode = await cycle({ pkg: argv.package });
1259
- console.log(chalk15.blue(`Finished in ${Date.now() - start}ms`));
1260
- }
1261
- };
1262
-
1263
- // src/xy/lint/deplintCommand.ts
1264
- import chalk16 from "chalk";
1265
- var deplintCommand = {
1266
- command: "deplint [package]",
1267
- describe: "Deplint - Run Deplint",
1268
- builder: (yargs) => {
1269
- return packagePositionalParam(yargs).option("deps", {
1270
- alias: "d",
1271
- default: false,
1272
- description: "Check dependencies",
1273
- type: "boolean"
1274
- }).option("devDeps", {
1275
- alias: "v",
1276
- default: false,
1277
- description: "Check devDependencies",
1278
- type: "boolean"
1279
- }).option("peerDeps", {
1280
- alias: "p",
1281
- default: false,
1282
- description: "Check peerDependencies",
1283
- type: "boolean"
1284
- }).option("exclude", {
1285
- alias: "e",
1286
- description: "Package names to exclude from unused checks (comma-separated or repeated)",
1287
- type: "array"
1288
- });
1289
- },
1290
- handler: async (argv) => {
1291
- if (argv.verbose) console.log("Deplint");
1292
- const start = Date.now();
1293
- const cliExclude = argv.exclude?.flatMap((v) => String(v).split(",")).map((v) => v.trim()).filter(Boolean);
1294
- process.exitCode = await deplint({
1295
- cliExclude,
1296
- pkg: argv.package,
1297
- deps: !!argv.deps,
1298
- devDeps: !!argv.devDeps,
1299
- peerDeps: !!argv.peerDeps,
1300
- verbose: !!argv.verbose
1301
- });
1302
- console.log(chalk16.blue(`Finished in ${Date.now() - start}ms`));
1303
- }
1304
- };
1305
-
1306
- // src/xy/lint/fixCommand.ts
1307
- import chalk17 from "chalk";
1308
- var fixCommand = {
1309
- command: "fix [package]",
1310
- describe: "Fix - Run Eslint w/fix",
1311
- builder: (yargs) => {
1312
- return packagePositionalParam(yargs);
1313
- },
1314
- handler: (argv) => {
1315
- const start = Date.now();
1316
- if (argv.verbose) console.log("Fix");
1317
- process.exitCode = fix();
1318
- console.log(chalk17.blue(`Finished in ${Date.now() - start}ms`));
1319
- }
1320
- };
1321
-
1322
- // src/xy/lint/knipCommand.ts
1323
- import chalk18 from "chalk";
1324
- var knipCommand = {
1325
- command: "knip",
1326
- describe: "Knip - Run Knip",
1327
- builder: (yargs) => {
1328
- return packagePositionalParam(yargs);
1329
- },
1330
- handler: (argv) => {
1331
- if (argv.verbose) console.log("Knip");
1332
- const start = Date.now();
1333
- process.exitCode = knip();
1334
- console.log(chalk18.blue(`Knip finished in ${Date.now() - start}ms`));
1335
- }
1336
- };
1337
-
1338
- // src/xy/lint/lintCommand.ts
1339
- import chalk19 from "chalk";
1340
- var lintCommand = {
1341
- command: "lint [package]",
1342
- describe: "Lint - Run Eslint",
1343
- builder: (yargs) => {
1344
- return packagePositionalParam(yargs).option("fix", {
1345
- alias: "f",
1346
- default: false,
1347
- description: "Fix fixable issues",
1348
- type: "boolean"
1349
- }).option("cache", {
1350
- alias: "c",
1351
- default: false,
1352
- description: "Use caching for performance",
1353
- type: "boolean"
1354
- });
1355
- },
1356
- handler: (argv) => {
1357
- if (argv.verbose) console.log("Lint");
1358
- const start = Date.now();
1359
- process.exitCode = argv.fix ? fix({
1360
- pkg: argv.package,
1361
- cache: argv.cache,
1362
- verbose: !!argv.verbose
1363
- }) : lint({
1364
- pkg: argv.package,
1365
- cache: argv.cache,
1366
- verbose: !!argv.verbose
1367
- });
1368
- console.log(chalk19.blue(`Finished in ${Date.now() - start}ms`));
1369
- }
1370
- };
1371
-
1372
- // src/xy/lint/packageLintCommand.ts
1373
- var packageLintCommand = {
1374
- builder: (yargs) => {
1375
- return yargs.option("fix", {
1376
- default: false,
1377
- description: "Auto-fix fixable issues",
1378
- type: "boolean"
1379
- });
1380
- },
1381
- command: "package-lint",
1382
- describe: "Package Lint - Check monorepo package structure",
1383
- handler: (argv) => {
1384
- if (argv.verbose) console.log("Package Lint");
1385
- process.exitCode = packageLintMonorepo(!!argv.fix);
1386
- }
1387
- };
1388
-
1389
- // src/xy/lint/publintCommand.ts
1390
- import chalk20 from "chalk";
1391
- var publintCommand = {
1392
- command: "publint [package]",
1393
- describe: "Publint - Run Publint",
1394
- builder: (yargs) => {
1395
- return packagePositionalParam(yargs);
1396
- },
1397
- handler: async (argv) => {
1398
- if (argv.verbose) console.log("Publint");
1399
- const start = Date.now();
1400
- process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
1401
- console.log(chalk20.blue(`Finished in ${Date.now() - start}ms`));
1402
- }
1403
- };
1404
-
1405
- // src/xy/lint/relintCommand.ts
1406
- import chalk21 from "chalk";
1407
- var relintCommand = {
1408
- command: "relint [package]",
1409
- describe: "Relint - Clean & Lint",
1410
- builder: (yargs) => {
1411
- return packagePositionalParam(yargs);
1412
- },
1413
- handler: (argv) => {
1414
- if (argv.verbose) console.log("Relinting");
1415
- const start = Date.now();
1416
- process.exitCode = relint();
1417
- console.log(chalk21.blue(`Finished in ${Date.now() - start}ms`));
1418
- }
1419
- };
1420
-
1421
- // src/xy/lint/sonarCommand.ts
1422
- import chalk22 from "chalk";
1423
- var sonarCommand = {
1424
- command: "sonar",
1425
- describe: "Sonar - Run Sonar Check",
1426
- builder: (yargs) => {
1427
- return packagePositionalParam(yargs);
1428
- },
1429
- handler: (argv) => {
1430
- const start = Date.now();
1431
- if (argv.verbose) console.log("Sonar Check");
1432
- process.exitCode = sonar();
1433
- console.log(chalk22.blue(`Finished in ${Date.now() - start}ms`));
1434
- }
1435
- };
1436
-
1437
- // src/xy/lint/index.ts
1438
- var xyLintCommands = (args) => {
1439
- return args.command(cycleCommand).command(lintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(packageLintCommand).command(sonarCommand);
1440
- };
1441
- export {
1442
- xyLintCommands
1443
- };
1444
- //# sourceMappingURL=index.mjs.map