@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
package/dist/xy/xy.mjs CHANGED
@@ -1,289 +1,9 @@
1
1
  // src/xy/xy.ts
2
- import chalk43 from "chalk";
2
+ import { xyBase } from "@xylabs/ts-scripts-common";
3
3
 
4
- // src/actions/build.ts
5
- import chalk10 from "chalk";
6
-
7
- // src/lib/checkResult.ts
8
- import chalk from "chalk";
9
- var checkResult = (name, result, level = "error", exitOnFail = false) => {
10
- if (result) {
11
- const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
12
- const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
13
- console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
14
- if (exitOnFail) {
15
- process.exit(result);
16
- }
17
- }
18
- };
19
-
20
- // src/lib/claudeMdTemplate.ts
21
- import {
22
- readdirSync,
23
- readFileSync,
24
- statSync
25
- } from "fs";
26
- import { createRequire } from "module";
27
- import PATH from "path";
28
- var require2 = createRequire(import.meta.url);
29
- var packageRoot = PATH.dirname(require2.resolve("@xylabs/ts-scripts-yarn3/package.json"));
30
- var templatesDir = PATH.resolve(packageRoot, "templates", "claude");
31
- var XYLABS_RULES_PREFIX = "xylabs-";
32
- var XYLABS_COMMANDS_PREFIX = "xy-";
33
- var LEGACY_COMMANDS_PREFIX = "xylabs-";
34
- var XYLABS_SKILLS_PREFIX = "xylabs-";
35
- var claudeMdRuleTemplates = () => {
36
- const rulesDir = PATH.resolve(templatesDir, "rules");
37
- const files = readdirSync(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
38
- const result = {};
39
- for (const file of files) {
40
- result[file] = readFileSync(PATH.resolve(rulesDir, file), "utf8");
41
- }
42
- return result;
43
- };
44
- var claudeCommandTemplates = () => {
45
- const commandsDir = PATH.resolve(templatesDir, "commands");
46
- const files = readdirSync(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
47
- const result = {};
48
- for (const file of files) {
49
- result[file] = readFileSync(PATH.resolve(commandsDir, file), "utf8");
50
- }
51
- return result;
52
- };
53
- var claudeSkillTemplates = () => {
54
- const skillsDir = PATH.resolve(templatesDir, "skills");
55
- const dirs = readdirSync(skillsDir).filter(
56
- (f) => f.startsWith(XYLABS_SKILLS_PREFIX) && statSync(PATH.resolve(skillsDir, f)).isDirectory()
57
- );
58
- const result = {};
59
- for (const dir of dirs) {
60
- const dirPath = PATH.resolve(skillsDir, dir);
61
- const files = readdirSync(dirPath, { recursive: true, encoding: "utf8" });
62
- result[dir] = {};
63
- for (const file of files) {
64
- if (statSync(PATH.resolve(dirPath, file)).isFile()) {
65
- result[dir][file] = readFileSync(PATH.resolve(dirPath, file), "utf8");
66
- }
67
- }
68
- }
69
- return result;
70
- };
71
- var claudeMdLocalTemplate = () => readFileSync(PATH.resolve(templatesDir, "CLAUDE-local.md"), "utf8");
72
-
73
- // src/lib/deleteGlob.ts
74
- import fs from "fs";
75
- import { glob } from "glob";
76
- var deleteGlob = (globPath) => {
77
- const files = glob.sync(globPath);
78
- for (const file of files) {
79
- fs.rmSync(file, { recursive: true, force: true });
80
- }
81
- };
82
-
83
- // src/lib/dependencies/detectDuplicateDependencies.ts
84
- import { execSync } from "child_process";
85
-
86
- // src/lib/processEx.ts
87
- import chalk2 from "chalk";
88
-
89
- // src/lib/withError.ts
90
- var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
91
- return predicate(ex) ? closure(ex) : void 0;
92
- };
93
-
94
- // src/lib/withErrnoException.ts
95
- var withErrnoException = (ex, closure) => {
96
- return withError(ex, closure, (ex2) => ex2.errno !== void 0);
97
- };
98
-
99
- // src/lib/processEx.ts
100
- var processEx = (ex) => {
101
- const error = typeof ex === "string" ? new Error(ex) : ex;
102
- const exitCode = withErrnoException(error, (error2) => {
103
- if (error2.code === "ENOENT") {
104
- console.error(chalk2.red(`'${error2.path}' not found.`));
105
- } else {
106
- console.error(chalk2.red(`Errno: ${error2.code}`));
107
- }
108
- return error2.errno ?? -1;
109
- }) ?? withError(error, (error2) => {
110
- console.error(chalk2.red(`${error2.name}: ${error2.message}`));
111
- return -1;
112
- }) ?? (() => {
113
- console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
114
- return -1;
115
- })();
116
- process.exit(process.exitCode ?? exitCode);
117
- };
118
-
119
- // src/lib/safeExit.ts
120
- var safeExit = (func, exitOnFail = true) => {
121
- try {
122
- const result = func();
123
- if (result && exitOnFail) {
124
- process.exit(result);
125
- }
126
- return result;
127
- } catch (ex) {
128
- return processEx(ex);
129
- }
130
- };
131
- var safeExitAsync = async (func, exitOnFail = true) => {
132
- try {
133
- const result = await func();
134
- if (result && exitOnFail) {
135
- process.exit(result);
136
- }
137
- return result;
138
- } catch (ex) {
139
- return processEx(ex);
140
- }
141
- };
142
-
143
- // src/lib/dependencies/DuplicateDetector.ts
144
- import { EOL } from "os";
145
- import chalk3 from "chalk";
146
-
147
- // src/lib/jsonFormatters.ts
148
- var multiLineToJSONArray = (output) => {
149
- const withCommas = output.replaceAll("\r\n", "").replaceAll("\n", ",");
150
- const cleanCollection = withCommas.slice(0, Math.max(0, withCommas.length - 1));
151
- const collection = `[${cleanCollection}]`;
152
- return JSON.parse(collection);
153
- };
154
-
155
- // src/lib/dependencies/DuplicateDetector.ts
156
- var trimVirtualMeta = (value) => {
157
- const virtualParts = value.split("virtual:");
158
- if (virtualParts.length > 1) {
159
- const hashParts = virtualParts[1].split("#");
160
- return virtualParts[0] + hashParts[1];
161
- } else {
162
- return value;
163
- }
164
- };
165
- var trimObjectDependencyVirtualMeta = (obj) => {
166
- const resultObj = {};
167
- for (const [key, value] of Object.entries(obj)) {
168
- resultObj[trimVirtualMeta(key)] = {
169
- descriptor: trimVirtualMeta(value.descriptor),
170
- locator: trimVirtualMeta(value.locator)
171
- };
172
- }
173
- return resultObj;
174
- };
175
- var trimDependencyVirtualMeta = (dependencies) => {
176
- return dependencies.map((dependency) => {
177
- return { children: trimObjectDependencyVirtualMeta(dependency.children), value: trimVirtualMeta(dependency.value) };
178
- });
179
- };
180
- var DuplicateDetector = class {
181
- dependency;
182
- dependencyEntries;
183
- constructor(output, dependency) {
184
- this.dependency = dependency;
185
- this.dependencyEntries = trimDependencyVirtualMeta(multiLineToJSONArray(output));
186
- }
187
- detect() {
188
- const result = this.dependencyEntries.reduce(this.detectReducer, this.resultsFactory(this.dependency));
189
- if (result.duplicateVersions.length > 0) {
190
- console.log(chalk3.yellow(`${EOL}Duplicates found for: ${this.dependency}`));
191
- const duplicateVersions = result.duplicateVersions.toString().replaceAll(",", `${EOL} `);
192
- console.log(chalk3.grey(` ${duplicateVersions}`, EOL));
193
- return 1;
194
- } else {
195
- console.log(`${this.dependency} - OK`);
196
- return 0;
197
- }
198
- }
199
- detectReducer(acc, entry) {
200
- const version = Object.entries(entry.children).map(([k]) => k)[0];
201
- if (!acc.currentVersion) {
202
- acc.currentVersion = version;
203
- return acc;
204
- }
205
- if (acc.currentVersion && acc.currentVersion !== version && !version.includes("@virtual:")) {
206
- if (acc.duplicateVersions.length === 0) {
207
- acc.duplicateVersions.push(acc.currentVersion);
208
- }
209
- acc.duplicateVersions.push(version);
210
- acc.duplicateVersions = [...new Set(acc.duplicateVersions)];
211
- }
212
- return acc;
213
- }
214
- resultsFactory = (dependency) => ({
215
- currentVersion: void 0,
216
- dependency,
217
- duplicateVersions: []
218
- });
219
- };
220
-
221
- // src/lib/dependencies/detectDuplicateDependencies.ts
222
- var detectDuplicateDependencies = (depsFromPackageJSON, DefaultDependencies2) => {
223
- let exitCode = 0;
224
- const dependencies = depsFromPackageJSON?.length ? depsFromPackageJSON : DefaultDependencies2;
225
- return safeExit(() => {
226
- if (dependencies) {
227
- for (const dependency of dependencies) {
228
- let output;
229
- try {
230
- const cmd = `yarn why ${dependency} --json`;
231
- output = execSync(cmd).toString();
232
- } catch (e) {
233
- console.error(`Error running yarn why: ${e}`);
234
- exitCode = 1;
235
- continue;
236
- }
237
- if (output) {
238
- exitCode = new DuplicateDetector(output, dependency).detect();
239
- } else {
240
- console.log(`${dependency} - N/A`);
241
- if (depsFromPackageJSON) {
242
- exitCode = 1;
243
- console.log(`\u{1F6A8} Library ${dependency} was requested in package.json but not found`);
244
- }
245
- }
246
- }
247
- return exitCode;
248
- } else {
249
- console.log("\u{1F6A8} No dependencies where passed");
250
- return exitCode;
251
- }
252
- });
253
- };
254
-
255
- // src/lib/file/constants.ts
256
- var WINDOWS_NEWLINE_REGEX = /\r\n/g;
257
- var CROSS_PLATFORM_NEWLINE = "\n";
258
-
259
- // src/lib/file/fileLines.ts
260
- import {
261
- existsSync,
262
- readFileSync as readFileSync2,
263
- writeFileSync
264
- } from "fs";
265
-
266
- // src/lib/string/empty.ts
267
- var empty = (value) => value?.trim().length === 0;
268
- var notEmpty = (value) => !empty(value);
269
-
270
- // src/lib/string/union.ts
271
- var union = (a, b) => /* @__PURE__ */ new Set([...new Set(a), ...new Set(b)]);
272
-
273
- // src/lib/file/ReadFileSyncOptions.ts
274
- var defaultReadFileSyncOptions = { encoding: "utf8" };
275
-
276
- // src/lib/file/fileLines.ts
277
- var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync(uri) ? readFileSync2(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : [];
278
- var readNonEmptyLines = (uri, options = defaultReadFileSyncOptions) => readLines(uri, options).filter(notEmpty);
279
- var writeLines = (uri, lines, options = defaultReadFileSyncOptions) => {
280
- const existing = existsSync(uri) ? readFileSync2(uri, options) : void 0;
281
- const desired = lines.join(CROSS_PLATFORM_NEWLINE);
282
- if (existing !== desired) writeFileSync(uri, desired, options);
283
- };
284
-
285
- // src/lib/generateIgnoreFiles.ts
286
- import chalk4 from "chalk";
4
+ // src/actions/deploy.ts
5
+ import { readFileSync } from "fs";
6
+ import { runSteps } from "@xylabs/ts-scripts-common";
287
7
 
288
8
  // src/lib/yarn/isYarnVersionOrGreater.ts
289
9
  import { spawnSync } from "child_process";
@@ -295,3007 +15,202 @@ var isYarnVersionOrGreater = (major, minor, patch) => {
295
15
  const minorDelta = versionNumbers[1] - (minor ?? versionNumbers[1]);
296
16
  const patchDelta = versionNumbers[2] - (patch ?? versionNumbers[2]);
297
17
  const majorOk = majorDelta >= 0;
298
- const minorOk = majorDelta > 0 || minorDelta >= 0;
299
- const patchOk = majorDelta > 0 || minorDelta > 0 || patchDelta >= 0;
300
- return [majorOk && minorOk && patchOk, version];
301
- };
302
-
303
- // src/lib/yarn/workspace/yarnWorkspaces.ts
304
- import { spawnSync as spawnSync2 } from "child_process";
305
- var yarnWorkspaces = () => {
306
- const result = spawnSync2("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
307
- if (result.error) {
308
- throw result.error;
309
- }
310
- return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
311
- return JSON.parse(item);
312
- });
313
- };
314
-
315
- // src/lib/yarn/workspace/yarnWorkspace.ts
316
- var yarnWorkspace = (pkg) => {
317
- const workspace = yarnWorkspaces().find(({ name }) => name === pkg);
318
- if (!workspace) throw new Error(`Workspace ${pkg} not found`);
319
- return workspace;
320
- };
321
-
322
- // src/lib/yarn/yarnInitCwd.ts
323
- var INIT_CWD = () => {
324
- if (!process.env.INIT_CWD) console.error("Missing INIT_CWD");
325
- return process.env.INIT_CWD;
326
- };
327
-
328
- // src/lib/generateIgnoreFiles.ts
329
- var localeCompare = (a, b) => a.localeCompare(b);
330
- var mergeEntries = (a, b) => [...union(a, b)].toSorted(localeCompare);
331
- var generateIgnoreFiles = (filename2, pkg) => {
332
- console.log(chalk4.green(`Generate ${filename2} Files`));
333
- const cwd = INIT_CWD() ?? ".";
334
- const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces();
335
- const readEntries = (location) => readNonEmptyLines(`${location}/${filename2}`);
336
- const writeEntries = (location, entries) => writeLines(`${location}/${filename2}`, entries);
337
- const results = workspaces.map(({ location, name }) => {
338
- try {
339
- writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)));
340
- return 0;
341
- } catch (ex) {
342
- const error = ex;
343
- console.error(`Generate ${filename2} Files [${name}] [${error.message}]`);
344
- return 1;
345
- }
346
- });
347
- const succeeded = results.every((result) => result === 0);
348
- return succeeded ? 0 : 1;
349
- };
350
-
351
- // src/lib/generateReadmeFiles.ts
352
- import { execSync as execSync2 } from "child_process";
353
- import FS, { readFileSync as readFileSync3 } from "fs";
354
- import {
355
- mkdir,
356
- readFile,
357
- writeFile
358
- } from "fs/promises";
359
- import { createRequire as createRequire2 } from "module";
360
- import PATH2 from "path";
361
- import { createInterface } from "readline";
362
- import chalk5 from "chalk";
363
- var require3 = createRequire2(import.meta.url);
364
- var packageRoot2 = PATH2.dirname(require3.resolve("@xylabs/ts-scripts-yarn3/package.json"));
365
- var readmeTemplatesDir = PATH2.resolve(packageRoot2, "templates", "readme");
366
- function fillTemplate(template, data) {
367
- const additionalData = { ...data, safeName: data.name.replaceAll("/", "__").replaceAll("@", "") };
368
- return template.replaceAll(/\{\{(.*?)\}\}/g, (_, key) => additionalData[key.trim()] ?? "");
369
- }
370
- function generateTypedoc(packageLocation, entryPoints) {
371
- const tempDir = PATH2.join(packageLocation, ".temp-typedoc");
372
- try {
373
- if (!FS.existsSync(tempDir)) {
374
- FS.mkdirSync(tempDir, { recursive: true });
375
- }
376
- const typedocConfig = {
377
- disableSources: true,
378
- entryPointStrategy: "expand",
379
- entryPoints: entryPoints.map((ep) => PATH2.resolve(packageLocation, ep)),
380
- excludeExternals: true,
381
- excludeInternal: true,
382
- excludePrivate: true,
383
- githubPages: false,
384
- hideBreadcrumbs: true,
385
- hideGenerator: true,
386
- hidePageTitle: true,
387
- out: tempDir,
388
- plugin: ["typedoc-plugin-markdown"],
389
- readme: "none",
390
- skipErrorChecking: true,
391
- sort: ["source-order"],
392
- theme: "markdown",
393
- useCodeBlocks: true
394
- };
395
- const typedocJsonPath = PATH2.join(tempDir, "typedoc.json");
396
- FS.writeFileSync(typedocJsonPath, JSON.stringify(typedocConfig, null, 2));
397
- try {
398
- execSync2(`npx typedoc --options ${typedocJsonPath}`, {
399
- cwd: process.cwd(),
400
- stdio: ["ignore", "pipe", "pipe"]
401
- });
402
- } catch {
403
- return "";
404
- }
405
- return consolidateMarkdown(tempDir);
406
- } catch {
407
- return "";
408
- } finally {
409
- try {
410
- FS.rmSync(tempDir, { force: true, recursive: true });
411
- } catch {
412
- }
413
- }
414
- }
415
- function consolidateMarkdown(tempDir) {
416
- let consolidated = "## Reference\n\n";
417
- const mainReadmePath = PATH2.join(tempDir, "README.md");
418
- if (FS.existsSync(mainReadmePath)) {
419
- const mainContent = FS.readFileSync(mainReadmePath, "utf8").replace(/^---(.|\n)*?---\n/, "").replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
420
- consolidated += mainContent + "\n\n";
421
- }
422
- consolidated += processDirectory(tempDir);
423
- return consolidated.replaceAll(/\n\n\n+/g, "\n\n").replaceAll(/^#### /gm, "### ").replaceAll(/^##### /gm, "#### ").replaceAll(/^###### /gm, "##### ");
424
- }
425
- function processDirectory(dir, level = 0) {
426
- const indent = " ".repeat(level);
427
- let content = "";
428
- try {
429
- const items = FS.readdirSync(dir, { withFileTypes: true });
430
- for (const item of items) {
431
- if (item.isDirectory()) continue;
432
- if (item.name === "README.md" || !item.name.endsWith(".md")) continue;
433
- const fileContent = FS.readFileSync(PATH2.join(dir, item.name), "utf8").replace(/^---(.|\n)*?---\n/, "");
434
- const moduleName = item.name.replace(".md", "");
435
- content += `
436
-
437
- ${indent}### <a id="${moduleName}"></a>${moduleName}
438
-
439
- `;
440
- content += fileContent.replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
441
- }
442
- for (const item of items) {
443
- if (!item.isDirectory()) continue;
444
- if (item.name === "spec" || item.name.includes(".spec")) continue;
445
- content += `
446
-
447
- ${indent}### ${item.name}
448
- `;
449
- content += processDirectory(PATH2.join(dir, item.name), level + 1);
450
- }
451
- } catch {
452
- }
453
- return content;
454
- }
455
- function askConfirmation(question) {
456
- const rl = createInterface({ input: process.stdin, output: process.stdout });
457
- return new Promise((resolve) => {
458
- rl.question(question, (answer) => {
459
- rl.close();
460
- resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
461
- });
462
- });
463
- }
464
- var DEFAULT_README_TEMPLATE = readFileSync3(PATH2.resolve(readmeTemplatesDir, "README.template.md"), "utf8");
465
- var DEFAULT_README_BODY = readFileSync3(PATH2.resolve(readmeTemplatesDir, "README.body.md"), "utf8");
466
- function applyLogoConfig(template, logoUrl, logoLinkUrl) {
467
- let result = template;
468
- if (logoUrl) {
469
- result = result.replace(/\[logo]: .+/, `[logo]: ${logoUrl}`);
470
- if (logoLinkUrl) {
471
- result = result.replace(/\[!\[logo]\[]][^)]*\)/, `[![logo][]](${logoLinkUrl})`);
472
- }
473
- } else {
474
- result = result.replace(/\[!\[logo]\[]][^\n]*\n*/, "");
475
- result = result.replace(/\[logo]: [^\n]*\n?/, "");
476
- }
477
- return result;
478
- }
479
- function resolveTemplatePath(templatePath) {
480
- const cwd = INIT_CWD() ?? ".";
481
- return templatePath ?? PATH2.join(cwd, ".xy", "README.template.md");
482
- }
483
- async function loadOrCreateTemplate(resolvedTemplatePath) {
484
- try {
485
- const template = await readFile(resolvedTemplatePath, "utf8");
486
- return { created: false, template };
487
- } catch {
488
- console.log(chalk5.yellow(`Template not found: ${resolvedTemplatePath}`));
489
- const shouldCreate = await askConfirmation("Would you like to create a stock template? (y/N) ");
490
- if (!shouldCreate) {
491
- throw new Error("Template creation declined");
492
- }
493
- const template = DEFAULT_README_TEMPLATE;
494
- await scaffoldTemplate(resolvedTemplatePath, template);
495
- return { created: true, template };
496
- }
497
- }
498
- async function scaffoldTemplate(resolvedTemplatePath, template) {
499
- const xyDir = PATH2.dirname(resolvedTemplatePath);
500
- await mkdir(xyDir, { recursive: true });
501
- await writeFile(resolvedTemplatePath, template);
502
- console.log(chalk5.green(`Created template: ${resolvedTemplatePath}`));
503
- const bodyPath = PATH2.join(xyDir, "README.body.md");
504
- await writeFile(bodyPath, DEFAULT_README_BODY);
505
- console.log(chalk5.green(`Created body template: ${bodyPath}`));
506
- }
507
- async function resolveBody(location, defaultBody) {
508
- const localBodyPath = PATH2.join(location, "README.body.md");
509
- try {
510
- return await readFile(localBodyPath, "utf8");
511
- } catch {
512
- return defaultBody;
513
- }
514
- }
515
- async function generateReadmeForWorkspace(location, name, template, defaultBody, typedoc, verbose) {
516
- try {
517
- const pkgJsonPath = PATH2.join(location, "package.json");
518
- const pkgJson = JSON.parse(await readFile(pkgJsonPath, "utf8"));
519
- const body = await resolveBody(location, defaultBody);
520
- const typedocContent = typedoc ? generateTypedoc(location, ["src/index*.ts"]) : "";
521
- const readmeContent = fillTemplate(template, {
522
- ...pkgJson,
523
- body,
524
- typedoc: typedocContent
525
- });
526
- await writeFile(PATH2.join(location, "README.md"), readmeContent);
527
- if (verbose) console.log(chalk5.green(` ${name}`));
528
- return true;
529
- } catch (ex) {
530
- const error = ex;
531
- console.warn(chalk5.yellow(` Skipped ${location}: ${error.message}`));
532
- return false;
533
- }
534
- }
535
- async function generateReadmeFiles({
536
- logoLinkUrl,
537
- logoUrl,
538
- pkg,
539
- templatePath,
540
- typedoc = false,
541
- verbose = false
542
- }) {
543
- console.log(chalk5.green("Generate README Files"));
544
- const resolvedTemplatePath = resolveTemplatePath(templatePath);
545
- let template;
546
- let templateCreated;
547
- try {
548
- ({ template, created: templateCreated } = await loadOrCreateTemplate(resolvedTemplatePath));
549
- } catch {
550
- return 1;
551
- }
552
- template = applyLogoConfig(template, logoUrl, logoLinkUrl);
553
- if (templateCreated) {
554
- console.log(chalk5.green("Generating README files for all packages..."));
555
- }
556
- const xyDir = PATH2.dirname(resolvedTemplatePath);
557
- const xyBodyPath = PATH2.join(xyDir, "README.body.md");
558
- let defaultBody;
559
- try {
560
- defaultBody = await readFile(xyBodyPath, "utf8");
561
- } catch {
562
- defaultBody = DEFAULT_README_BODY;
563
- }
564
- const workspaces = pkg && !templateCreated ? [yarnWorkspace(pkg)] : yarnWorkspaces();
565
- let failed = false;
566
- for (const { location, name } of workspaces) {
567
- const success = await generateReadmeForWorkspace(location, name, template, defaultBody, typedoc, verbose);
568
- if (!success) failed = true;
569
- }
570
- return failed ? 1 : 0;
571
- }
572
-
573
- // src/lib/gitignoreTemplate.ts
574
- import { readFileSync as readFileSync4 } from "fs";
575
- import { createRequire as createRequire3 } from "module";
576
- import PATH3 from "path";
577
- var require4 = createRequire3(import.meta.url);
578
- var packageRoot3 = PATH3.dirname(require4.resolve("@xylabs/ts-scripts-yarn3/package.json"));
579
- var templatesDir2 = PATH3.resolve(packageRoot3, "templates", "gitignore");
580
- var gitignoreTemplate = () => readFileSync4(PATH3.resolve(templatesDir2, "template.gitignore"), "utf8");
581
-
582
- // src/lib/loadConfig.ts
583
- import chalk6 from "chalk";
584
- import { cosmiconfig } from "cosmiconfig";
585
- import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
586
- import deepmerge from "deepmerge";
587
- var config;
588
- var loadConfig = async (params) => {
589
- if (config === void 0) {
590
- const cosmicConfigResult = await cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } }).search();
591
- config = cosmicConfigResult?.config;
592
- const configFilePath = cosmicConfigResult?.filepath;
593
- if (configFilePath !== void 0) {
594
- console.log(chalk6.green(`Loaded config from ${configFilePath}`));
595
- if (config.verbose) {
596
- console.log(chalk6.gray(`${JSON.stringify(config, null, 2)}`));
597
- }
598
- }
599
- }
600
- return deepmerge(config, params ?? {});
601
- };
602
-
603
- // src/lib/parsedPackageJSON.ts
604
- import { readFileSync as readFileSync5 } from "fs";
605
- var parsedPackageJSON = (path8) => {
606
- const pathToPackageJSON = path8 ?? process.env.npm_package_json ?? "";
607
- const packageJSON = readFileSync5(pathToPackageJSON).toString();
608
- return JSON.parse(packageJSON);
609
- };
610
-
611
- // src/lib/runSteps.ts
612
- import { spawnSync as spawnSync3 } from "child_process";
613
- import { existsSync as existsSync2 } from "fs";
614
- import chalk7 from "chalk";
615
- var runSteps = (name, steps, exitOnFail = true, messages) => {
616
- return safeExit(() => {
617
- const pkgName = process.env.npm_package_name;
618
- console.log(chalk7.green(`${name} [${pkgName}]`));
619
- let totalStatus = 0;
620
- for (const [i, [command, args, config2]] of steps.entries()) {
621
- if (messages?.[i]) {
622
- console.log(chalk7.gray(messages?.[i]));
623
- }
624
- const argList = Array.isArray(args) ? args : args.split(" ");
625
- if (command === "node" && !existsSync2(argList[0])) {
626
- throw new Error(`File not found [${argList[0]}]`);
627
- }
628
- const status = spawnSync3(command, Array.isArray(args) ? args : args.split(" "), {
629
- ...config2,
630
- encoding: "utf8",
631
- env: { FORCE_COLOR: "3", ...process.env },
632
- shell: true,
633
- stdio: "inherit"
634
- }).status ?? 0;
635
- checkResult(name, status, "error", exitOnFail);
636
- totalStatus += status ?? 0;
637
- }
638
- return totalStatus;
639
- }, !!exitOnFail);
640
- };
641
-
642
- // src/lib/runStepsAsync.ts
643
- import { spawn } from "child_process";
644
- import { existsSync as existsSync3 } from "fs";
645
- import chalk8 from "chalk";
646
- var runStepAsync = (name, step, exitOnFail = true, message) => {
647
- return new Promise((resolve) => {
648
- const [command, args, config2] = step;
649
- if (message) {
650
- console.log(chalk8.gray(message));
651
- }
652
- const argList = Array.isArray(args) ? args : args.split(" ");
653
- if (command === "node" && !existsSync3(argList[0])) {
654
- throw new Error(`File not found [${argList[0]}]`);
655
- }
656
- spawn(command, Array.isArray(args) ? args : args.split(" "), {
657
- ...config2,
658
- env: { FORCE_COLOR: "3", ...process.env },
659
- shell: true,
660
- stdio: "inherit"
661
- }).on("close", (code) => {
662
- if (code) {
663
- console.error(
664
- chalk8.red(
665
- `Command Exited With Non-Zero Result [${chalk8.gray(code)}] | ${chalk8.yellow(command)} ${chalk8.white(
666
- Array.isArray(args) ? args.join(" ") : args
667
- )}`
668
- )
669
- );
670
- checkResult(name, code, "error", exitOnFail);
671
- resolve(code);
672
- } else {
673
- resolve(0);
674
- }
675
- });
676
- });
677
- };
678
- var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
679
- return await safeExitAsync(async () => {
680
- const pkgName = process.env.npm_package_name;
681
- console.log(chalk8.green(`${name} [${pkgName}]`));
682
- let result = 0;
683
- for (const [i, step] of steps.entries()) {
684
- result += await runStepAsync(name, step, exitOnFail, messages?.[i]);
685
- }
686
- return result;
687
- });
688
- };
689
-
690
- // src/lib/tryRunLocalScript.ts
691
- import { spawnSync as spawnSync4 } from "child_process";
692
- import { readFileSync as readFileSync6 } from "fs";
693
- import PATH4 from "path";
694
- import chalk9 from "chalk";
695
- function tryRunLocalScript(commandName) {
696
- if (process.env.XY_LOCAL_SCRIPT === "1") return void 0;
697
- const rootPkgPath = PATH4.resolve(process.cwd(), "package.json");
698
- let rootPkg;
699
- try {
700
- rootPkg = JSON.parse(readFileSync6(rootPkgPath, "utf8"));
701
- } catch {
702
- return void 0;
703
- }
704
- if (!rootPkg.scripts?.[commandName]) return void 0;
705
- console.log(chalk9.blue(`Delegating "${commandName}" to local script`));
706
- const result = spawnSync4("yarn", ["run", commandName], {
707
- cwd: process.cwd(),
708
- encoding: "utf8",
709
- env: {
710
- FORCE_COLOR: "3",
711
- ...process.env,
712
- XY_LOCAL_SCRIPT: "1"
713
- },
714
- shell: true,
715
- stdio: "inherit"
716
- });
717
- return result.status ?? 1;
718
- }
719
-
720
- // src/actions/build.ts
721
- var build = async ({
722
- incremental,
723
- jobs,
724
- target,
725
- verbose,
726
- pkg
727
- }) => {
728
- const start = Date.now();
729
- const pkgOptions = pkg === void 0 ? [] : [pkg];
730
- const incrementalOptions = incremental ? ["-i"] : [];
731
- const verboseOptions = verbose ? ["-v"] : [];
732
- const targetOptions = target === void 0 ? [] : ["-t", target];
733
- const jobsOptions = jobs === void 0 ? [] : ["-j", `${jobs}`];
734
- if (jobs !== void 0) {
735
- console.log(chalk10.blue(`Jobs set to [${jobs}]`));
736
- }
737
- const result = await runStepsAsync(`Build${incremental ? "-Incremental" : ""} [${pkg ?? "All"}]`, [
738
- ["yarn", ["xy", "compile", ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions, "--types", "tsup"]],
739
- ["yarn", ["xy", "publint", ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
740
- ["yarn", ["xy", "deplint", ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
741
- ["yarn", ["xy", "lint", ...pkgOptions, ...verboseOptions, ...incrementalOptions]]
742
- ]);
743
- console.log(`${chalk10.gray("Built in")} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`);
744
- return result;
745
- };
746
-
747
- // src/actions/claude-clean.ts
748
- import {
749
- existsSync as existsSync4,
750
- readdirSync as readdirSync2,
751
- rmSync,
752
- unlinkSync
753
- } from "fs";
754
- import PATH5 from "path";
755
- import chalk11 from "chalk";
756
- function removeFile(filePath, label) {
757
- if (existsSync4(filePath)) {
758
- unlinkSync(filePath);
759
- console.log(chalk11.yellow(` Removed ${label}`));
760
- return true;
761
- }
762
- return false;
763
- }
764
- function removeDir(dirPath, label) {
765
- if (existsSync4(dirPath)) {
766
- rmSync(dirPath, { recursive: true });
767
- console.log(chalk11.yellow(` Removed ${label}`));
768
- return true;
769
- }
770
- return false;
771
- }
772
- function claudeClean() {
773
- console.log(chalk11.green("Clean Claude configuration"));
774
- const cwd = INIT_CWD() ?? process.cwd();
775
- let removed = 0;
776
- const rootFiles = ["CLAUDE.md", "CLAUDE.local.md"];
777
- for (const file of rootFiles) {
778
- if (removeFile(PATH5.resolve(cwd, file), file)) removed++;
779
- }
780
- if (removeDir(PATH5.resolve(cwd, ".claude"), ".claude/")) removed++;
781
- const packagesDir = PATH5.resolve(cwd, "packages");
782
- if (existsSync4(packagesDir)) {
783
- const findClaudeFiles = (dir, prefix) => {
784
- const entries = readdirSync2(dir, { withFileTypes: true });
785
- for (const entry of entries) {
786
- const fullPath = PATH5.resolve(dir, entry.name);
787
- const label = `${prefix}${entry.name}`;
788
- if (entry.isFile() && (entry.name === "CLAUDE.md" || entry.name === "CLAUDE.local.md")) {
789
- if (removeFile(fullPath, label)) removed++;
790
- } else if (entry.isDirectory() && entry.name === ".claude") {
791
- if (removeDir(fullPath, `${label}/`)) removed++;
792
- } else if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "dist") {
793
- findClaudeFiles(fullPath, `${label}/`);
794
- }
795
- }
796
- };
797
- findClaudeFiles(packagesDir, "packages/");
798
- }
799
- if (removed > 0) {
800
- console.log(chalk11.green(` Removed ${removed} item(s)`));
801
- } else {
802
- console.log(chalk11.gray(" Nothing to clean"));
803
- }
804
- return 0;
805
- }
806
-
807
- // src/actions/claude-commands.ts
808
- import {
809
- existsSync as existsSync5,
810
- mkdirSync,
811
- readdirSync as readdirSync3,
812
- readFileSync as readFileSync7,
813
- unlinkSync as unlinkSync2,
814
- writeFileSync as writeFileSync2
815
- } from "fs";
816
- import PATH6 from "path";
817
- import chalk12 from "chalk";
818
- var syncCommandFiles = (commandsDir) => {
819
- const templates = claudeCommandTemplates();
820
- const templateNames = new Set(Object.keys(templates));
821
- let updated = 0;
822
- let created = 0;
823
- for (const [filename2, content] of Object.entries(templates)) {
824
- const targetPath = PATH6.resolve(commandsDir, filename2);
825
- const existing = existsSync5(targetPath) ? readFileSync7(targetPath, "utf8") : void 0;
826
- if (existing === content) continue;
827
- writeFileSync2(targetPath, content, "utf8");
828
- if (existing) {
829
- updated++;
830
- } else {
831
- created++;
832
- }
833
- }
834
- return {
835
- created,
836
- templateNames,
837
- updated
838
- };
839
- };
840
- var removeStaleCommands = (commandsDir, templateNames) => {
841
- const existingCommands = readdirSync3(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
842
- let removed = 0;
843
- for (const file of existingCommands) {
844
- if (!templateNames.has(file)) {
845
- unlinkSync2(PATH6.resolve(commandsDir, file));
846
- removed++;
847
- }
848
- }
849
- return removed;
850
- };
851
- var removeLegacyCommands = (commandsDir) => {
852
- const legacyFiles = readdirSync3(commandsDir).filter((f) => f.startsWith(LEGACY_COMMANDS_PREFIX) && f.endsWith(".md"));
853
- for (const file of legacyFiles) {
854
- unlinkSync2(PATH6.resolve(commandsDir, file));
855
- }
856
- return legacyFiles.length;
857
- };
858
- var logCommandsResult = (created, updated, removed) => {
859
- if (created || updated || removed) {
860
- const parts = [
861
- created ? `${created} created` : "",
862
- updated ? `${updated} updated` : "",
863
- removed ? `${removed} removed` : ""
864
- ].filter(Boolean);
865
- console.log(chalk12.green(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: ${parts.join(", ")}`));
866
- } else {
867
- console.log(chalk12.gray(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: already up to date`));
868
- }
869
- };
870
- var claudeCommands = () => {
871
- const cwd = INIT_CWD() ?? process.cwd();
872
- const commandsDir = PATH6.resolve(cwd, ".claude", "commands");
873
- mkdirSync(commandsDir, { recursive: true });
874
- const legacy = removeLegacyCommands(commandsDir);
875
- const {
876
- created,
877
- templateNames,
878
- updated
879
- } = syncCommandFiles(commandsDir);
880
- const removed = removeStaleCommands(commandsDir, templateNames);
881
- logCommandsResult(created, updated, removed + legacy);
882
- return 0;
883
- };
884
-
885
- // src/actions/claude-rules.ts
886
- import { spawnSync as spawnSync5 } from "child_process";
887
- import {
888
- existsSync as existsSync6,
889
- mkdirSync as mkdirSync2,
890
- readdirSync as readdirSync4,
891
- readFileSync as readFileSync8,
892
- unlinkSync as unlinkSync3,
893
- writeFileSync as writeFileSync3
894
- } from "fs";
895
- import PATH7 from "path";
896
- import chalk13 from "chalk";
897
- var syncRuleFiles = (rulesDir) => {
898
- const templates = claudeMdRuleTemplates();
899
- const templateNames = new Set(Object.keys(templates));
900
- let updated = 0;
901
- let created = 0;
902
- for (const [filename2, content] of Object.entries(templates)) {
903
- const targetPath = PATH7.resolve(rulesDir, filename2);
904
- const existing = existsSync6(targetPath) ? readFileSync8(targetPath, "utf8") : void 0;
905
- if (existing === content) continue;
906
- writeFileSync3(targetPath, content, "utf8");
907
- if (existing) {
908
- updated++;
909
- } else {
910
- created++;
911
- }
912
- }
913
- return {
914
- created,
915
- templateNames,
916
- updated
917
- };
918
- };
919
- var removeStaleRules = (rulesDir, templateNames) => {
920
- const existingRules = readdirSync4(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
921
- let removed = 0;
922
- for (const file of existingRules) {
923
- if (!templateNames.has(file)) {
924
- unlinkSync3(PATH7.resolve(rulesDir, file));
925
- removed++;
926
- }
927
- }
928
- return removed;
929
- };
930
- var logRulesResult = (created, updated, removed) => {
931
- if (created || updated || removed) {
932
- const parts = [
933
- created ? `${created} created` : "",
934
- updated ? `${updated} updated` : "",
935
- removed ? `${removed} removed` : ""
936
- ].filter(Boolean);
937
- console.log(chalk13.green(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: ${parts.join(", ")}`));
938
- } else {
939
- console.log(chalk13.gray(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: already up to date`));
940
- }
941
- };
942
- var ensureProjectClaudeMd = (cwd, force) => {
943
- const projectPath = PATH7.resolve(cwd, "CLAUDE.md");
944
- if (!existsSync6(projectPath) || force) {
945
- if (force && existsSync6(projectPath)) {
946
- console.log(chalk13.yellow("Regenerating CLAUDE.md"));
947
- }
948
- console.log(chalk13.green("Generating CLAUDE.md via claude /init..."));
949
- const result = spawnSync5("claude", ["-p", "/init", "--allowedTools", "Read", "Write", "Glob", "Grep"], {
950
- cwd,
951
- shell: true,
952
- stdio: "inherit"
953
- });
954
- if (result.status !== 0) {
955
- console.error(chalk13.red("claude /init failed \u2014 is Claude Code installed?"));
956
- return 1;
957
- }
958
- } else {
959
- console.log(chalk13.gray("CLAUDE.md already exists (skipped, use --force to regenerate)"));
960
- }
961
- return 0;
962
- };
963
- var ensureLocalClaudeMd = (cwd) => {
964
- const localPath = PATH7.resolve(cwd, "CLAUDE.local.md");
965
- if (existsSync6(localPath)) {
966
- console.log(chalk13.gray("CLAUDE.local.md already exists (skipped)"));
967
- } else {
968
- writeFileSync3(localPath, claudeMdLocalTemplate(), "utf8");
969
- console.log(chalk13.green("Generated CLAUDE.local.md"));
970
- }
971
- };
972
- var claudeRules = ({ force } = {}) => {
973
- const cwd = INIT_CWD() ?? process.cwd();
974
- const rulesDir = PATH7.resolve(cwd, ".claude", "rules");
975
- mkdirSync2(rulesDir, { recursive: true });
976
- const {
977
- created,
978
- templateNames,
979
- updated
980
- } = syncRuleFiles(rulesDir);
981
- const removed = removeStaleRules(rulesDir, templateNames);
982
- logRulesResult(created, updated, removed);
983
- const claudeMdResult = ensureProjectClaudeMd(cwd, force);
984
- ensureLocalClaudeMd(cwd);
985
- return claudeMdResult ?? 0;
986
- };
987
-
988
- // src/actions/claude-settings.ts
989
- import {
990
- existsSync as existsSync7,
991
- mkdirSync as mkdirSync3,
992
- writeFileSync as writeFileSync4
993
- } from "fs";
994
- import PATH8 from "path";
995
- import { createInterface as createInterface2 } from "readline";
996
- import chalk14 from "chalk";
997
- var DEFAULT_SETTINGS = {
998
- permissions: {
999
- allow: [
1000
- "Bash(git *)",
1001
- "Bash(yarn *)",
1002
- "Bash(npx *)",
1003
- "Bash(node *)",
1004
- "Bash(ls *)",
1005
- "Bash(mkdir *)",
1006
- "Bash(cp *)",
1007
- "Bash(mv *)",
1008
- "Bash(rm *)",
1009
- "Bash(cat *)",
1010
- "Bash(head *)",
1011
- "Bash(tail *)",
1012
- "Bash(echo *)",
1013
- "Bash(pwd)",
1014
- "Bash(which *)",
1015
- "Bash(grep *)",
1016
- "Bash(find *)",
1017
- "Bash(npm view *)",
1018
- "Bash(gh *)",
1019
- "Read",
1020
- "Edit",
1021
- "Write",
1022
- "Glob",
1023
- "Grep",
1024
- "Skill"
1025
- ],
1026
- deny: [
1027
- "Bash(git push --force *)",
1028
- "Bash(git reset --hard *)",
1029
- "Bash(rm -rf /*)"
1030
- ]
1031
- }
1032
- };
1033
- function askConfirmation2(question) {
1034
- const rl = createInterface2({ input: process.stdin, output: process.stdout });
1035
- return new Promise((resolve) => {
1036
- rl.question(question, (answer) => {
1037
- rl.close();
1038
- resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
1039
- });
1040
- });
1041
- }
1042
- async function claudeSettings() {
1043
- const cwd = INIT_CWD() ?? process.cwd();
1044
- const claudeDir = PATH8.resolve(cwd, ".claude");
1045
- const settingsPath = PATH8.resolve(claudeDir, "settings.local.json");
1046
- mkdirSync3(claudeDir, { recursive: true });
1047
- if (existsSync7(settingsPath)) {
1048
- const confirmed = await askConfirmation2(
1049
- chalk14.yellow(`${settingsPath} already exists. Replace it? (y/N) `)
1050
- );
1051
- if (!confirmed) {
1052
- console.log(chalk14.gray("Skipped \u2014 existing settings.local.json preserved"));
1053
- return 0;
1054
- }
1055
- }
1056
- writeFileSync4(settingsPath, `${JSON.stringify(DEFAULT_SETTINGS, null, 2)}
1057
- `, "utf8");
1058
- console.log(chalk14.green("Generated .claude/settings.local.json"));
1059
- return 0;
1060
- }
1061
-
1062
- // src/actions/claude-skills.ts
1063
- import {
1064
- existsSync as existsSync8,
1065
- mkdirSync as mkdirSync4,
1066
- readdirSync as readdirSync5,
1067
- readFileSync as readFileSync9,
1068
- rmSync as rmSync2,
1069
- statSync as statSync2,
1070
- writeFileSync as writeFileSync5
1071
- } from "fs";
1072
- import PATH9 from "path";
1073
- import chalk15 from "chalk";
1074
- var syncSkillFiles = (skillsDir) => {
1075
- const templates = claudeSkillTemplates();
1076
- const templateNames = new Set(Object.keys(templates));
1077
- let updated = 0;
1078
- let created = 0;
1079
- for (const [skillName, files] of Object.entries(templates)) {
1080
- const skillDir = PATH9.resolve(skillsDir, skillName);
1081
- mkdirSync4(skillDir, { recursive: true });
1082
- for (const [filename2, content] of Object.entries(files)) {
1083
- const targetPath = PATH9.resolve(skillDir, filename2);
1084
- mkdirSync4(PATH9.dirname(targetPath), { recursive: true });
1085
- const existing = existsSync8(targetPath) ? readFileSync9(targetPath, "utf8") : void 0;
1086
- if (existing === content) continue;
1087
- writeFileSync5(targetPath, content, "utf8");
1088
- if (existing) {
1089
- updated++;
1090
- } else {
1091
- created++;
1092
- }
1093
- }
1094
- }
1095
- return {
1096
- created,
1097
- templateNames,
1098
- updated
1099
- };
1100
- };
1101
- var removeStaleSkills = (skillsDir, templateNames) => {
1102
- const existingSkills = readdirSync5(skillsDir).filter(
1103
- (f) => f.startsWith(XYLABS_SKILLS_PREFIX) && statSync2(PATH9.resolve(skillsDir, f)).isDirectory()
1104
- );
1105
- let removed = 0;
1106
- for (const dir of existingSkills) {
1107
- if (!templateNames.has(dir)) {
1108
- rmSync2(PATH9.resolve(skillsDir, dir), { recursive: true });
1109
- removed++;
1110
- }
1111
- }
1112
- return removed;
1113
- };
1114
- var logSkillsResult = (created, updated, removed) => {
1115
- if (created || updated || removed) {
1116
- const parts = [
1117
- created ? `${created} created` : "",
1118
- updated ? `${updated} updated` : "",
1119
- removed ? `${removed} removed` : ""
1120
- ].filter(Boolean);
1121
- console.log(chalk15.green(`.claude/skills/${XYLABS_SKILLS_PREFIX}*/: ${parts.join(", ")}`));
1122
- } else {
1123
- console.log(chalk15.gray(`.claude/skills/${XYLABS_SKILLS_PREFIX}*/: already up to date`));
1124
- }
1125
- };
1126
- var claudeSkills = () => {
1127
- const cwd = INIT_CWD() ?? process.cwd();
1128
- const skillsDir = PATH9.resolve(cwd, ".claude", "skills");
1129
- mkdirSync4(skillsDir, { recursive: true });
1130
- const {
1131
- created,
1132
- templateNames,
1133
- updated
1134
- } = syncSkillFiles(skillsDir);
1135
- const removed = removeStaleSkills(skillsDir, templateNames);
1136
- logSkillsResult(created, updated, removed);
1137
- return 0;
1138
- };
1139
-
1140
- // src/actions/clean.ts
1141
- var clean = async ({ verbose, pkg }) => {
1142
- return pkg ? await cleanPackage({ pkg, verbose }) : cleanAll({ verbose });
1143
- };
1144
- var cleanPackage = ({ pkg }) => {
1145
- return runStepsAsync(`Clean [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-clean"]]]);
1146
- };
1147
- var cleanAll = ({ verbose }) => {
1148
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
1149
- return runStepsAsync("Clean", [["yarn", ["workspaces foreach", "-pA", "--jobs 64", ...verboseOptions, "run", "package-clean"]]]);
1150
- };
1151
-
1152
- // src/actions/clean-docs.ts
1153
- import path from "path";
1154
- import chalk16 from "chalk";
1155
- var cleanDocs = () => {
1156
- const pkgName = process.env.npm_package_name;
1157
- console.log(chalk16.green(`Cleaning Docs [${pkgName}]`));
1158
- for (const { location } of yarnWorkspaces()) deleteGlob(path.join(location, "docs"));
1159
- return 0;
1160
- };
1161
-
1162
- // src/actions/compile.ts
1163
- import chalk17 from "chalk";
1164
- var compile = ({
1165
- verbose,
1166
- target,
1167
- pkg,
1168
- incremental,
1169
- publint: publint2,
1170
- jobs
1171
- }) => {
1172
- return pkg ? compilePackage({
1173
- pkg,
1174
- publint: publint2,
1175
- target,
1176
- verbose
1177
- }) : compileAll({
1178
- incremental,
1179
- publint: publint2,
1180
- target,
1181
- verbose,
1182
- jobs
1183
- });
1184
- };
1185
- var compilePackage = ({ target, pkg }) => {
1186
- const targetOptions = target ? ["-t", target] : [];
1187
- return runSteps(
1188
- `Compile [${pkg}]`,
1189
- [["yarn", ["workspace", pkg, "run", "package-compile", ...targetOptions]]]
1190
- );
1191
- };
1192
- var compileAll = ({
1193
- jobs,
1194
- verbose,
1195
- target,
1196
- incremental
1197
- }) => {
1198
- const start = Date.now();
1199
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
1200
- const targetOptions = target ? ["-t", target] : [];
1201
- const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
1202
- const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
1203
- if (jobs) {
1204
- console.log(chalk17.blue(`Jobs set to [${jobs}]`));
1205
- }
1206
- const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
1207
- ["yarn", [
1208
- "workspaces",
1209
- "foreach",
1210
- ...incrementalOptions,
1211
- ...jobsOptions,
1212
- ...verboseOptions,
1213
- "run",
1214
- "package-compile",
1215
- ...targetOptions
1216
- ]]
1217
- ]);
1218
- console.log(`${chalk17.gray("Compiled in")} [${chalk17.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk17.gray("seconds")}`);
1219
- return result;
1220
- };
1221
-
1222
- // src/actions/copy-assets.ts
1223
- import path2 from "path/posix";
1224
- import chalk18 from "chalk";
1225
- import cpy from "cpy";
1226
- var copyPackageTargetAssets = async (target, name, location) => {
1227
- try {
1228
- const values = await cpy(
1229
- ["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
1230
- `../dist/${target}`,
1231
- {
1232
- cwd: path2.join(process.cwd(), location, "src"),
1233
- flat: false
1234
- }
1235
- );
1236
- for (const value of values) {
1237
- console.log(`${value.split("/").pop()} => ./dist/${target}`);
1238
- }
1239
- return 0;
1240
- } catch (reason) {
1241
- console.log(`Copy Failed: ${name}: ${reason}`);
1242
- return 1;
1243
- }
1244
- };
1245
- var copyTargetAssets = async (target, pkg) => {
1246
- const workspaces = yarnWorkspaces();
1247
- console.log(chalk18.green(`Copying Assets [${target.toUpperCase()}]`));
1248
- const workspaceList = workspaces.filter(({ name }) => {
1249
- return pkg === void 0 || name === pkg;
1250
- });
1251
- if (workspaceList.length === 0) {
1252
- console.error(`Package not found [${pkg}]`);
1253
- } else {
1254
- const results = await Promise.all(
1255
- workspaceList.map(async (workspace) => {
1256
- const { location, name } = workspace;
1257
- return await copyPackageTargetAssets(target, name, location);
1258
- })
1259
- );
1260
- return results.reduce((prev, result) => prev || result, 0);
1261
- }
1262
- return 0;
1263
- };
1264
- var copyAssets = async ({ target, pkg }) => {
1265
- switch (target) {
1266
- case "esm": {
1267
- return await copyTargetAssets("esm", pkg);
1268
- }
1269
- case "cjs": {
1270
- return await copyTargetAssets("cjs", pkg);
1271
- }
1272
- default: {
1273
- return await copyTargetAssets("esm", pkg) || await copyTargetAssets("cjs", pkg);
1274
- }
1275
- }
1276
- };
1277
-
1278
- // src/actions/cycle.ts
1279
- import { cruise } from "dependency-cruiser";
1280
- var cycle = async ({ verbose, pkg } = {}) => {
1281
- return pkg ? cyclePackage({ pkg, verbose }) : await cycleAll({ verbose });
1282
- };
1283
- var cyclePackage = ({ pkg, verbose }) => {
1284
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
1285
- return runSteps(
1286
- `Cycle [${pkg}]`,
1287
- [["yarn", ["workspace", pkg, "run", "package-cycle", ...verboseOptions]]]
1288
- );
1289
- };
1290
- var cycleAll = async ({ verbose = false }) => {
1291
- const pkgName = process.env.npm_package_name;
1292
- const cruiseOptions = {
1293
- ruleSet: {
1294
- forbidden: [
1295
- {
1296
- name: "no-circular",
1297
- severity: "error",
1298
- comment: "This dependency creates a circular reference",
1299
- from: {},
1300
- to: { circular: true }
1301
- }
1302
- ]
1303
- },
1304
- exclude: "node_modules|packages/.*/packages",
1305
- validate: true,
1306
- doNotFollow: { path: "node_modules|packages/.*/packages" },
1307
- tsPreCompilationDeps: false,
1308
- combinedDependencies: true,
1309
- outputType: verbose ? "text" : "err"
1310
- };
1311
- const target = "**/packages/*/src";
1312
- console.log(`Checking for circular dependencies in ${target}...`);
1313
- const result = await cruise([target], cruiseOptions);
1314
- if (result.output) {
1315
- console.log(result.output);
1316
- }
1317
- if (result.exitCode === 0) {
1318
- console.log(`${pkgName} \u2705 No dependency violations`);
1319
- } else {
1320
- console.error(`${pkgName} \u274C Dependency violations found`);
1321
- }
1322
- return result.exitCode;
1323
- };
1324
-
1325
- // src/actions/dead.ts
1326
- var dead = () => {
1327
- return runSteps("Dead", [["yarn", ["ts-prune", "-p", "tsconfig.json"]]]);
1328
- };
1329
-
1330
- // src/actions/deplint/deplint.ts
1331
- import chalk24 from "chalk";
1332
-
1333
- // src/actions/deplint/findFiles.ts
1334
- import fs2 from "fs";
1335
-
1336
- // src/actions/deplint/findFilesByGlob.ts
1337
- import { globSync } from "glob";
1338
- function findFilesByGlob(cwd, pattern, ignore) {
1339
- return globSync(pattern, {
1340
- cwd,
1341
- absolute: true,
1342
- ignore,
1343
- nodir: true
1344
- });
1345
- }
1346
-
1347
- // src/actions/deplint/findFiles.ts
1348
- var codeExtensions = "*.{ts,tsx,mts,cts,js,mjs,cjs}";
1349
- function getWorkspaceIgnores(location) {
1350
- try {
1351
- const raw = fs2.readFileSync(`${location}/package.json`, "utf8");
1352
- const pkg = JSON.parse(raw);
1353
- return pkg.workspaces ?? [];
1354
- } catch {
1355
- return [];
1356
- }
1357
- }
1358
- function findFiles(location) {
1359
- const workspaceIgnores = getWorkspaceIgnores(location).map((w) => `${w}/**`);
1360
- const ignore = ["**/node_modules/**", "dist/**", ...workspaceIgnores];
1361
- const allFiles = findFilesByGlob(location, `./**/${codeExtensions}`, ignore);
1362
- const distFiles = [
1363
- ...findFilesByGlob(location, "./dist/**/*.d.ts"),
1364
- ...findFilesByGlob(location, `./dist/**/${codeExtensions}`)
1365
- ];
1366
- return { allFiles, distFiles };
1367
- }
1368
-
1369
- // src/actions/deplint/getDependenciesFromPackageJson.ts
1370
- import fs3 from "fs";
1371
- import path3 from "path";
1372
- function getDependenciesFromPackageJson(packageJsonPath) {
1373
- const packageJsonFullPath = path3.resolve(packageJsonPath);
1374
- const rawContent = fs3.readFileSync(packageJsonFullPath, "utf8");
1375
- const packageJson = JSON.parse(rawContent);
1376
- const dependencies = packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
1377
- const devDependencies = packageJson.devDependencies ? Object.keys(packageJson.devDependencies) : [];
1378
- const peerDependencies = packageJson.peerDependencies ? Object.keys(packageJson.peerDependencies) : [];
1379
- return {
1380
- dependencies,
1381
- devDependencies,
1382
- peerDependencies
1383
- };
1384
- }
1385
-
1386
- // src/actions/deplint/getExtendsFromTsconfigs.ts
1387
- import fs4 from "fs";
1388
- import { globSync as globSync2 } from "glob";
1389
-
1390
- // src/actions/deplint/getBasePackageName.ts
1391
- function getBasePackageName(importName) {
1392
- const importNameScrubbed = importName.replaceAll('"', "").trim();
1393
- if (importNameScrubbed.startsWith("@")) {
1394
- const parts = importNameScrubbed.split("/");
1395
- return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : importNameScrubbed;
1396
- }
1397
- return importNameScrubbed.split("/")[0];
1398
- }
1399
-
1400
- // src/actions/deplint/getExtendsFromTsconfigs.ts
1401
- var isExternalReference = (ref) => !ref.startsWith(".") && !ref.startsWith("/");
1402
- function parseExtendsField(value) {
1403
- if (typeof value === "string") return [value];
1404
- if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
1405
- return [];
1406
- }
1407
- function getExtendsFromTsconfigs(location) {
1408
- const tsconfigFiles = globSync2("./tsconfig*.json", { cwd: location, absolute: true });
1409
- const packages = /* @__PURE__ */ new Set();
1410
- for (const file of tsconfigFiles) {
1411
- try {
1412
- const content = fs4.readFileSync(file, "utf8");
1413
- const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
1414
- const parsed = JSON.parse(cleaned);
1415
- const refs = parseExtendsField(parsed.extends);
1416
- for (const ref of refs) {
1417
- if (isExternalReference(ref)) {
1418
- packages.add(getBasePackageName(ref));
1419
- }
1420
- }
1421
- } catch {
1422
- }
1423
- }
1424
- return [...packages];
1425
- }
1426
-
1427
- // src/actions/deplint/getImportsFromFile.ts
1428
- import fs5 from "fs";
1429
- import path4 from "path";
1430
- import ts from "typescript";
1431
- function isTypeOnlyImportClause(clause) {
1432
- if (clause === void 0) {
1433
- return false;
1434
- }
1435
- if ("phaseModifier" in clause) {
1436
- const mod = clause.phaseModifier;
1437
- const kind = typeof mod === "number" ? mod : mod?.kind;
1438
- return kind === ts.SyntaxKind.TypeKeyword;
1439
- }
1440
- return clause.isTypeOnly;
1441
- }
1442
- function getImportsFromFile(filePath, importPaths, typeImportPaths) {
1443
- const sourceCode = fs5.readFileSync(filePath, "utf8");
1444
- const isMjsFile = filePath.endsWith(".mjs");
1445
- const sourceFile = ts.createSourceFile(
1446
- path4.basename(filePath),
1447
- sourceCode,
1448
- ts.ScriptTarget.Latest,
1449
- true,
1450
- isMjsFile ? ts.ScriptKind.JS : void 0
1451
- );
1452
- const imports = [];
1453
- const typeImports = [];
1454
- const isDeclarationFile2 = filePath.endsWith(".d.ts");
1455
- function visit(node) {
1456
- if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
1457
- const moduleSpecifier = node.moduleSpecifier?.getFullText();
1458
- const isTypeImport = ts.isImportDeclaration(node) ? isTypeOnlyImportClause(node.importClause) : false;
1459
- if (typeof moduleSpecifier === "string") {
1460
- const trimmed = moduleSpecifier.replaceAll("'", "").replaceAll('"', "").trim();
1461
- if (isTypeImport || isDeclarationFile2) {
1462
- typeImports.push(trimmed);
1463
- } else {
1464
- imports.push(trimmed);
1465
- }
1466
- }
1467
- } else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
1468
- const [arg] = node.arguments;
1469
- if (ts.isStringLiteral(arg)) {
1470
- imports.push(arg.text);
1471
- }
1472
- } else if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "require" && node.arguments.length > 0 && ts.isStringLiteral(node.arguments[0])) {
1473
- imports.push(node.arguments[0].text);
1474
- }
1475
- ts.forEachChild(node, visit);
1476
- }
1477
- visit(sourceFile);
1478
- for (const ref of sourceFile.typeReferenceDirectives) {
1479
- typeImports.push(ref.fileName);
1480
- }
1481
- const importsStartsWithExcludes = [".", "#", "node:"];
1482
- const isValidImport = (imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc)) && !imp.includes("*") && !imp.includes("!");
1483
- const cleanedImports = imports.filter(isValidImport).map(getBasePackageName);
1484
- const cleanedTypeImports = typeImports.filter(isValidImport).map(getBasePackageName);
1485
- for (const imp of cleanedImports) {
1486
- importPaths[imp] = importPaths[imp] ?? [];
1487
- importPaths[imp].push(filePath);
1488
- }
1489
- for (const imp of cleanedTypeImports) {
1490
- typeImportPaths[imp] = typeImportPaths[imp] ?? [];
1491
- typeImportPaths[imp].push(filePath);
1492
- }
1493
- return [cleanedImports, cleanedTypeImports];
1494
- }
1495
-
1496
- // src/actions/deplint/getExternalImportsFromFiles.ts
1497
- var internalImportPrefixes = [".", "#", "node:"];
1498
- var removeInternalImports = (imports) => {
1499
- return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
1500
- };
1501
- var isDeclarationFile = (file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts");
1502
- function getExternalImportsFromFiles({
1503
- allFiles,
1504
- distFiles,
1505
- tsconfigExtends = []
1506
- }) {
1507
- const allImportPaths = {};
1508
- const distImportPaths = {};
1509
- const distTypeImportPaths = {};
1510
- for (const path8 of allFiles) getImportsFromFile(path8, allImportPaths, allImportPaths).flat();
1511
- const distTypeFiles = distFiles.filter(isDeclarationFile);
1512
- const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
1513
- for (const path8 of distCodeFiles) getImportsFromFile(path8, distImportPaths, distImportPaths).flat();
1514
- for (const path8 of distTypeFiles) getImportsFromFile(path8, distTypeImportPaths, distTypeImportPaths).flat();
1515
- const allImports = Object.keys(allImportPaths);
1516
- const distImports = Object.keys(distImportPaths);
1517
- const externalAllImports = removeInternalImports(allImports);
1518
- const externalDistImports = removeInternalImports(distImports);
1519
- const externalDistTypeImports = removeInternalImports(Object.keys(distTypeImportPaths));
1520
- for (const ext of tsconfigExtends) {
1521
- if (!externalAllImports.includes(ext)) externalAllImports.push(ext);
1522
- }
1523
- return {
1524
- allImportPaths,
1525
- allImports,
1526
- distImportPaths,
1527
- distImports,
1528
- externalAllImports,
1529
- externalDistImports,
1530
- externalDistTypeImports
1531
- };
1532
- }
1533
-
1534
- // src/actions/deplint/checkPackage/getUnlistedDependencies.ts
1535
- import { builtinModules } from "module";
1536
- import chalk19 from "chalk";
1537
- function isRuntimeImportListed(imp, name, dependencies, peerDependencies) {
1538
- return dependencies.includes(imp) || imp === name || peerDependencies.includes(imp) || builtinModules.includes(imp);
1539
- }
1540
- function isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies) {
1541
- return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || devDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp);
1542
- }
1543
- function logMissing(name, imp, importPaths) {
1544
- console.log(`[${chalk19.blue(name)}] Missing dependency in package.json: ${chalk19.red(imp)}`);
1545
- if (importPaths[imp]) {
1546
- console.log(` ${importPaths[imp].join("\n ")}`);
1547
- }
1548
- }
1549
- function getUnlistedDependencies({ name, location }, {
1550
- dependencies,
1551
- devDependencies,
1552
- peerDependencies
1553
- }, {
1554
- externalDistImports,
1555
- externalDistTypeImports,
1556
- distImportPaths
1557
- }) {
1558
- let unlistedDependencies = 0;
1559
- for (const imp of externalDistImports) {
1560
- if (!isRuntimeImportListed(imp, name, dependencies, peerDependencies)) {
1561
- unlistedDependencies++;
1562
- logMissing(name, imp, distImportPaths);
1563
- }
1564
- }
1565
- for (const imp of externalDistTypeImports) {
1566
- if (!isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies)) {
1567
- unlistedDependencies++;
1568
- logMissing(name, imp, distImportPaths);
1569
- }
1570
- }
1571
- if (unlistedDependencies > 0) {
1572
- const packageLocation = `${location}/package.json`;
1573
- console.log(` ${chalk19.yellow(packageLocation)}
1574
- `);
1575
- }
1576
- return unlistedDependencies;
1577
- }
1578
-
1579
- // src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
1580
- import { builtinModules as builtinModules2 } from "module";
1581
- import chalk20 from "chalk";
1582
- function getUnlistedDevDependencies({ name, location }, {
1583
- devDependencies,
1584
- dependencies,
1585
- peerDependencies
1586
- }, {
1587
- allImportPaths,
1588
- externalAllImports,
1589
- distImports
1590
- }) {
1591
- let unlistedDevDependencies = 0;
1592
- for (const imp of externalAllImports) {
1593
- 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)) {
1594
- unlistedDevDependencies++;
1595
- console.log(`[${chalk20.blue(name)}] Missing devDependency in package.json: ${chalk20.red(imp)}`);
1596
- if (allImportPaths[imp]) {
1597
- console.log(` ${allImportPaths[imp].join("\n ")}`);
1598
- }
1599
- }
1600
- }
1601
- if (unlistedDevDependencies > 0) {
1602
- const packageLocation = `${location}/package.json`;
1603
- console.log(` ${chalk20.yellow(packageLocation)}
1604
- `);
1605
- }
1606
- return unlistedDevDependencies;
1607
- }
1608
-
1609
- // src/actions/deplint/checkPackage/getUnusedDependencies.ts
1610
- import chalk21 from "chalk";
1611
- function getUnusedDependencies({ name, location }, { dependencies }, {
1612
- externalDistImports,
1613
- externalDistTypeImports,
1614
- externalAllImports
1615
- }, exclude) {
1616
- let unusedDependencies = 0;
1617
- for (const dep of dependencies) {
1618
- if (exclude?.has(dep)) continue;
1619
- if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
1620
- unusedDependencies++;
1621
- if (externalAllImports.includes(dep)) {
1622
- console.log(`[${chalk21.blue(name)}] dependency should be devDependency in package.json: ${chalk21.red(dep)}`);
1623
- } else {
1624
- console.log(`[${chalk21.blue(name)}] Unused dependency in package.json: ${chalk21.red(dep)}`);
1625
- }
1626
- }
1627
- }
1628
- if (unusedDependencies > 0) {
1629
- const packageLocation = `${location}/package.json`;
1630
- console.log(` ${chalk21.yellow(packageLocation)}
1631
- `);
1632
- }
1633
- return unusedDependencies;
1634
- }
1635
-
1636
- // src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
1637
- import chalk22 from "chalk";
1638
-
1639
- // src/actions/deplint/getCliReferencedPackagesFromFiles.ts
1640
- import fs8 from "fs";
1641
- import path7 from "path";
1642
- import ts2 from "typescript";
1643
-
1644
- // src/actions/deplint/getScriptReferencedPackages.ts
1645
- import fs7 from "fs";
1646
- import path6 from "path";
1647
-
1648
- // src/actions/deplint/getRequiredPeerDependencies.ts
1649
- import fs6 from "fs";
1650
- import path5 from "path";
1651
- function findDepPackageJson(location, dep) {
1652
- let dir = location;
1653
- while (true) {
1654
- const candidate = path5.join(dir, "node_modules", dep, "package.json");
1655
- if (fs6.existsSync(candidate)) return candidate;
1656
- const parent = path5.dirname(dir);
1657
- if (parent === dir) return void 0;
1658
- dir = parent;
1659
- }
1660
- }
1661
- function getRequiredPeerDependencies(location, allDeps) {
1662
- const required = /* @__PURE__ */ new Set();
1663
- for (const dep of allDeps) {
1664
- const depPkgPath = findDepPackageJson(location, dep);
1665
- if (!depPkgPath) continue;
1666
- try {
1667
- const raw = fs6.readFileSync(depPkgPath, "utf8");
1668
- const pkg = JSON.parse(raw);
1669
- if (pkg.peerDependencies) {
1670
- for (const peer of Object.keys(pkg.peerDependencies)) {
1671
- required.add(peer);
1672
- }
1673
- }
1674
- } catch {
1675
- }
1676
- }
1677
- return required;
1678
- }
1679
-
1680
- // src/actions/deplint/getScriptReferencedPackages.ts
1681
- function getBinNames(location, dep) {
1682
- const depPkgPath = findDepPackageJson(location, dep);
1683
- if (!depPkgPath) return [];
1684
- try {
1685
- const raw = fs7.readFileSync(depPkgPath, "utf8");
1686
- const pkg = JSON.parse(raw);
1687
- if (!pkg.bin) return [];
1688
- if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
1689
- return Object.keys(pkg.bin);
1690
- } catch {
1691
- return [];
1692
- }
1693
- }
1694
- function tokenizeScript(script) {
1695
- return script.split(/[&|;$()"`\s]+/).map((t) => t.trim()).filter(Boolean);
1696
- }
1697
- function getScriptReferencedPackages(location, allDeps) {
1698
- const pkgPath = path6.join(location, "package.json");
1699
- let scripts = {};
1700
- try {
1701
- const raw = fs7.readFileSync(pkgPath, "utf8");
1702
- const pkg = JSON.parse(raw);
1703
- scripts = pkg.scripts ?? {};
1704
- } catch {
1705
- return /* @__PURE__ */ new Set();
1706
- }
1707
- const scriptText = Object.values(scripts).join(" ");
1708
- const tokens = new Set(tokenizeScript(scriptText));
1709
- const binToPackage = /* @__PURE__ */ new Map();
1710
- for (const dep of allDeps) {
1711
- const bins = getBinNames(location, dep);
1712
- for (const bin of bins) {
1713
- binToPackage.set(bin, dep);
1714
- }
1715
- }
1716
- const referenced = /* @__PURE__ */ new Set();
1717
- for (const token of tokens) {
1718
- const baseName = getBasePackageName(token);
1719
- if (allDeps.includes(baseName)) {
1720
- referenced.add(baseName);
1721
- }
1722
- const pkg = binToPackage.get(token);
1723
- if (pkg) {
1724
- referenced.add(pkg);
1725
- }
1726
- }
1727
- return referenced;
1728
- }
1729
-
1730
- // src/actions/deplint/getCliReferencedPackagesFromFiles.ts
1731
- var shellCommandFunctions = /* @__PURE__ */ new Set(["execSync", "exec"]);
1732
- var directExecFunctions = /* @__PURE__ */ new Set(["spawn", "spawnSync", "execFile", "execFileSync"]);
1733
- var allExecFunctions = /* @__PURE__ */ new Set([...shellCommandFunctions, ...directExecFunctions]);
1734
- function getCommandTokensFromFile(filePath) {
1735
- const tokens = /* @__PURE__ */ new Set();
1736
- let sourceCode;
1737
- try {
1738
- sourceCode = fs8.readFileSync(filePath, "utf8");
1739
- } catch {
1740
- return tokens;
1741
- }
1742
- const isMjsFile = filePath.endsWith(".mjs");
1743
- const sourceFile = ts2.createSourceFile(
1744
- path7.basename(filePath),
1745
- sourceCode,
1746
- ts2.ScriptTarget.Latest,
1747
- true,
1748
- isMjsFile ? ts2.ScriptKind.JS : void 0
1749
- );
1750
- function visit(node) {
1751
- if (ts2.isCallExpression(node) && node.arguments.length > 0) {
1752
- const fnName = getFunctionName(node.expression);
1753
- if (fnName && allExecFunctions.has(fnName)) {
1754
- const firstArg = node.arguments[0];
1755
- if (ts2.isStringLiteral(firstArg) || ts2.isNoSubstitutionTemplateLiteral(firstArg)) {
1756
- const value = firstArg.text;
1757
- if (shellCommandFunctions.has(fnName)) {
1758
- for (const token of tokenizeScript(value)) {
1759
- tokens.add(token);
1760
- }
1761
- } else {
1762
- tokens.add(value);
1763
- }
1764
- } else if (ts2.isTemplateExpression(firstArg)) {
1765
- const head = firstArg.head.text;
1766
- if (head) {
1767
- for (const token of tokenizeScript(head)) {
1768
- tokens.add(token);
1769
- }
1770
- }
1771
- }
1772
- }
1773
- }
1774
- ts2.forEachChild(node, visit);
1775
- }
1776
- visit(sourceFile);
1777
- return tokens;
1778
- }
1779
- function getFunctionName(expr) {
1780
- if (ts2.isIdentifier(expr)) {
1781
- return expr.text;
1782
- }
1783
- if (ts2.isPropertyAccessExpression(expr) && ts2.isIdentifier(expr.name)) {
1784
- return expr.name.text;
1785
- }
1786
- return void 0;
1787
- }
1788
- function getCliReferencedPackagesFromFiles(allFiles, location, allDeps) {
1789
- const allTokens = /* @__PURE__ */ new Set();
1790
- for (const file of allFiles) {
1791
- for (const token of getCommandTokensFromFile(file)) {
1792
- allTokens.add(token);
1793
- }
1794
- }
1795
- if (allTokens.size === 0) return /* @__PURE__ */ new Set();
1796
- const binToPackage = /* @__PURE__ */ new Map();
1797
- for (const dep of allDeps) {
1798
- for (const bin of getBinNames(location, dep)) {
1799
- binToPackage.set(bin, dep);
1800
- }
1801
- }
1802
- const referenced = /* @__PURE__ */ new Set();
1803
- for (const token of allTokens) {
1804
- const baseName = getBasePackageName(token);
1805
- if (allDeps.includes(baseName)) {
1806
- referenced.add(baseName);
1807
- }
1808
- const pkg = binToPackage.get(token);
1809
- if (pkg) {
1810
- referenced.add(pkg);
1811
- }
1812
- }
1813
- return referenced;
1814
- }
1815
-
1816
- // src/actions/deplint/implicitDevDependencies.ts
1817
- import fs9 from "fs";
1818
- var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
1819
- var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
1820
- var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
1821
- var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
1822
- var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
1823
- try {
1824
- const content = fs9.readFileSync(file, "utf8");
1825
- return decoratorPattern.test(content);
1826
- } catch {
1827
- return false;
1828
- }
1829
- });
1830
- var importPlugins = /* @__PURE__ */ new Set(["eslint-plugin-import-x", "eslint-plugin-import"]);
1831
- function hasImportPlugin({ location, allDependencies }) {
1832
- if (allDependencies.some((d) => importPlugins.has(d))) return true;
1833
- for (const dep of allDependencies) {
1834
- const pkgPath = findDepPackageJson(location, dep);
1835
- if (!pkgPath) continue;
1836
- try {
1837
- const pkg = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
1838
- const transitiveDeps = [
1839
- ...Object.keys(pkg.dependencies ?? {}),
1840
- ...Object.keys(pkg.peerDependencies ?? {})
1841
- ];
1842
- if (transitiveDeps.some((d) => importPlugins.has(d))) return true;
1843
- } catch {
1844
- }
1845
- }
1846
- return false;
1847
- }
1848
- var hasVitest = ({ allDependencies }) => allDependencies.includes("vitest");
1849
- var rules = [
1850
- {
1851
- package: "typescript",
1852
- isNeeded: hasTypescriptFiles
1853
- },
1854
- {
1855
- package: "eslint-import-resolver-typescript",
1856
- isNeeded: (context) => hasTypescriptFiles(context) && context.allDependencies.includes("eslint") && hasImportPlugin(context)
1857
- },
1858
- {
1859
- package: "tslib",
1860
- isNeeded: hasDecorators
1861
- },
1862
- {
1863
- package: "@vitest/coverage-v8",
1864
- isNeeded: hasVitest
1865
- }
1866
- ];
1867
- function getImplicitDevDependencies(context) {
1868
- const implicit = /* @__PURE__ */ new Set();
1869
- for (const rule of rules) {
1870
- if (rule.isNeeded(context)) {
1871
- implicit.add(rule.package);
1872
- }
1873
- }
1874
- return implicit;
1875
- }
1876
-
1877
- // src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
1878
- var allExternalImports = ({
1879
- externalAllImports,
1880
- externalDistImports,
1881
- externalDistTypeImports
1882
- }) => {
1883
- return /* @__PURE__ */ new Set([
1884
- ...externalAllImports,
1885
- ...externalDistImports,
1886
- ...externalDistTypeImports
1887
- ]);
1888
- };
1889
- function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs) {
1890
- if (implicitDeps.has(dep)) return true;
1891
- if (requiredPeers.has(dep)) return true;
1892
- if (scriptRefs.has(dep)) return true;
1893
- if (cliRefs.has(dep)) return true;
1894
- if (dep.startsWith("@types/")) {
1895
- const baseName = dep.replace(/^@types\//, "");
1896
- return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
1897
- }
1898
- return allImports.has(dep);
1899
- }
1900
- function getUnusedDevDependencies({ name, location }, {
1901
- devDependencies,
1902
- dependencies,
1903
- peerDependencies
1904
- }, sourceParams, fileContext, exclude) {
1905
- const allImports = allExternalImports(sourceParams);
1906
- const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
1907
- const implicitDeps = getImplicitDevDependencies({
1908
- ...fileContext,
1909
- allDependencies: allDeps,
1910
- location
1911
- });
1912
- const requiredPeers = getRequiredPeerDependencies(location, allDeps);
1913
- const scriptRefs = getScriptReferencedPackages(location, allDeps);
1914
- const cliRefs = getCliReferencedPackagesFromFiles(fileContext.allFiles, location, allDeps);
1915
- let unusedDevDependencies = 0;
1916
- for (const dep of devDependencies) {
1917
- if (exclude?.has(dep)) continue;
1918
- if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
1919
- if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
1920
- unusedDevDependencies++;
1921
- console.log(`[${chalk22.blue(name)}] Unused devDependency in package.json: ${chalk22.red(dep)}`);
1922
- }
1923
- }
1924
- if (unusedDevDependencies > 0) {
1925
- const packageLocation = `${location}/package.json`;
1926
- console.log(` ${chalk22.yellow(packageLocation)}
1927
- `);
1928
- }
1929
- return unusedDevDependencies;
1930
- }
1931
-
1932
- // src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
1933
- import chalk23 from "chalk";
1934
- function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
1935
- let unusedDependencies = 0;
1936
- for (const dep of peerDependencies) {
1937
- if (exclude?.has(dep)) continue;
1938
- if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
1939
- unusedDependencies++;
1940
- if (dependencies.includes(dep)) {
1941
- console.log(`[${chalk23.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk23.red(dep)}`);
1942
- } else {
1943
- console.log(`[${chalk23.blue(name)}] Unused peerDependency in package.json: ${chalk23.red(dep)}`);
1944
- }
1945
- }
1946
- }
1947
- if (unusedDependencies > 0) {
1948
- const packageLocation = `${location}/package.json`;
1949
- console.log(` ${chalk23.yellow(packageLocation)}
1950
- `);
1951
- }
1952
- return unusedDependencies;
1953
- }
1954
-
1955
- // src/actions/deplint/checkPackage/checkPackage.ts
1956
- function logVerbose(name, location, allFiles, distFiles, tsconfigExtends) {
1957
- console.info(`Checking package: ${name} at ${location}`);
1958
- console.info(`All files: ${allFiles.length}, Distribution files: ${distFiles.length}`);
1959
- for (const file of allFiles) {
1960
- console.info(`File: ${file}`);
1961
- }
1962
- for (const file of distFiles) {
1963
- console.info(`Distribution file: ${file}`);
1964
- }
1965
- for (const ext of tsconfigExtends) {
1966
- console.info(`Tsconfig extends: ${ext}`);
1967
- }
1968
- }
1969
- function checkPackage({
1970
- name,
1971
- location,
1972
- deps = false,
1973
- devDeps = false,
1974
- exclude,
1975
- peerDeps = false,
1976
- verbose = false
1977
- }) {
1978
- const { allFiles, distFiles } = findFiles(location);
1979
- const tsconfigExtends = getExtendsFromTsconfigs(location);
1980
- if (verbose) {
1981
- logVerbose(name, location, allFiles, distFiles, tsconfigExtends);
1982
- }
1983
- const checkDeps = deps || !(deps || devDeps || peerDeps);
1984
- const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
1985
- const checkPeerDeps = peerDeps;
1986
- const sourceParams = getExternalImportsFromFiles({
1987
- allFiles,
1988
- distFiles,
1989
- tsconfigExtends
1990
- });
1991
- const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
1992
- const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
1993
- const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
1994
- const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
1995
- const fileContext = { allFiles, distFiles };
1996
- const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext, exclude) : 0;
1997
- const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
1998
- const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
1999
- return totalErrors;
2000
- }
2001
-
2002
- // src/actions/deplint/deplint.ts
2003
- var deplint = async ({
2004
- pkg,
2005
- deps,
2006
- devDeps,
2007
- peerDeps,
2008
- verbose,
2009
- cliExclude
2010
- }) => {
2011
- const config2 = await loadConfig();
2012
- const exclude = /* @__PURE__ */ new Set([
2013
- ...config2.deplint?.exclude ?? [],
2014
- ...cliExclude ?? []
2015
- ]);
2016
- let totalErrors = 0;
2017
- if (pkg === void 0) {
2018
- const workspaces = yarnWorkspaces();
2019
- console.info("Deplint Started...");
2020
- for (const workspace of workspaces) {
2021
- totalErrors += checkPackage({
2022
- ...workspace,
2023
- deps,
2024
- devDeps,
2025
- exclude,
2026
- peerDeps,
2027
- verbose
2028
- });
2029
- }
2030
- } else {
2031
- const { location, name } = yarnWorkspace(pkg);
2032
- console.info(`Running Deplint for ${name}`);
2033
- totalErrors += checkPackage({
2034
- name,
2035
- location,
2036
- devDeps,
2037
- deps,
2038
- exclude,
2039
- peerDeps,
2040
- verbose
2041
- });
2042
- }
2043
- if (totalErrors > 0) {
2044
- console.warn(`Deplint: Found ${chalk24.red(totalErrors)} dependency problems. ${chalk24.red("\u2716")}`);
2045
- } else {
2046
- console.info(`Deplint: Found no dependency problems. ${chalk24.green("\u2714")}`);
2047
- }
2048
- return 0;
2049
- };
2050
-
2051
- // src/actions/deploy.ts
2052
- import { readFileSync as readFileSync10 } from "fs";
2053
- var privatePackageExcludeList = () => {
2054
- const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
2055
- workspace,
2056
- JSON.parse(readFileSync10(`${workspace.location}/package.json`, { encoding: "utf8" }))
2057
- ]);
2058
- const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
2059
- const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
2060
- return excludeList;
2061
- };
2062
- var deploy = () => {
2063
- const excludeList = privatePackageExcludeList();
2064
- if (excludeList.length > 0) {
2065
- console.log("Excluding private packages from deployment:", excludeList);
2066
- }
2067
- return runSteps("Deploy [Patch]", [
2068
- ["yarn", "workspaces foreach --all version patch --deferred"],
2069
- ["yarn", "xy clean"],
2070
- ["yarn", "xy build"],
2071
- ["yarn", "version apply --all"]
2072
- ]);
2073
- };
2074
-
2075
- // src/actions/deploy-major.ts
2076
- import { readFileSync as readFileSync11 } from "fs";
2077
- var privatePackageExcludeList2 = () => {
2078
- const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
2079
- workspace,
2080
- JSON.parse(readFileSync11(`${workspace.location}/package.json`, { encoding: "utf8" }))
2081
- ]);
2082
- const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
2083
- const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
2084
- return excludeList;
2085
- };
2086
- var deployMajor = () => {
2087
- const excludeList = privatePackageExcludeList2();
2088
- if (excludeList.length > 0) {
2089
- console.log("Excluding private packages from deployment:", excludeList);
2090
- }
2091
- return runSteps("Deploy [Major]", [
2092
- ["yarn", "workspaces foreach --all version major --deferred"],
2093
- ["yarn", "xy clean"],
2094
- ["yarn", "xy build"],
2095
- ["yarn", "version apply --all"]
2096
- ]);
2097
- };
2098
-
2099
- // src/actions/deploy-minor.ts
2100
- import { readFileSync as readFileSync12 } from "fs";
2101
- var privatePackageExcludeList3 = () => {
2102
- const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
2103
- workspace,
2104
- JSON.parse(readFileSync12(`${workspace.location}/package.json`, { encoding: "utf8" }))
2105
- ]);
2106
- const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
2107
- const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
2108
- return excludeList;
2109
- };
2110
- var deployMinor = () => {
2111
- const excludeList = privatePackageExcludeList3();
2112
- if (excludeList.length > 0) {
2113
- console.log("Excluding private packages from deployment:", excludeList);
2114
- }
2115
- return runSteps("Deploy [Minor]", [
2116
- ["yarn", "workspaces foreach --all version minor --deferred"],
2117
- ["yarn", "xy clean"],
2118
- ["yarn", "xy build"],
2119
- ["yarn", "version apply --all"]
2120
- ]);
2121
- };
2122
-
2123
- // src/actions/deploy-next.ts
2124
- import { readFileSync as readFileSync13 } from "fs";
2125
- var privatePackageExcludeList4 = () => {
2126
- const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
2127
- workspace,
2128
- JSON.parse(readFileSync13(`${workspace.location}/package.json`, { encoding: "utf8" }))
2129
- ]);
2130
- const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
2131
- const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
2132
- return excludeList;
2133
- };
2134
- var deployNext = () => {
2135
- const excludeList = privatePackageExcludeList4();
2136
- if (excludeList.length > 0) {
2137
- console.log("Excluding private packages from deployment:", excludeList);
2138
- }
2139
- return runSteps("Deploy [Next]", [
2140
- ["yarn", "workspaces foreach --all version minor --deferred"],
2141
- ["yarn", "xy clean"],
2142
- ["yarn", "xy build"],
2143
- ["yarn", "version apply --all --prerelease"]
2144
- ]);
2145
- };
2146
-
2147
- // src/actions/dupdeps.ts
2148
- import chalk25 from "chalk";
2149
- var dupdeps = () => {
2150
- console.log(chalk25.green("Checking all Dependencies for Duplicates"));
2151
- const pkg = parsedPackageJSON();
2152
- const allDependencies = { ...pkg?.dependencies, ...pkg?.devDependencies };
2153
- const dependencies = Object.keys(allDependencies);
2154
- return detectDuplicateDependencies(dependencies);
2155
- };
2156
-
2157
- // src/actions/lint.ts
2158
- import chalk26 from "chalk";
2159
- var lintPackage = ({
2160
- pkg,
2161
- fix: fix2,
2162
- verbose
2163
- }) => {
2164
- console.log(chalk26.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
2165
- const start = Date.now();
2166
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
2167
- ["yarn", [
2168
- "workspace",
2169
- pkg,
2170
- "run",
2171
- fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
2172
- ]]
2173
- ]);
2174
- console.log(chalk26.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk26.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk26.gray("seconds")}`));
2175
- return result;
2176
- };
2177
- var lint = ({
2178
- pkg,
2179
- verbose,
2180
- incremental,
2181
- fix: fix2
2182
- } = {}) => {
2183
- return pkg === void 0 ? lintAllPackages({
2184
- verbose,
2185
- incremental,
2186
- fix: fix2
2187
- }) : lintPackage({
2188
- pkg,
2189
- fix: fix2,
2190
- verbose
2191
- });
2192
- };
2193
- var lintAllPackages = ({ fix: fix2 = false } = {}) => {
2194
- console.log(chalk26.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
2195
- const start = Date.now();
2196
- const fixOptions = fix2 ? ["--fix"] : [];
2197
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
2198
- ["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
2199
- ]);
2200
- console.log(chalk26.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk26.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk26.gray("seconds")}`));
2201
- return result;
2202
- };
2203
-
2204
- // src/actions/fix.ts
2205
- var fix = (params) => {
2206
- return lint({ ...params, fix: true });
2207
- };
2208
-
2209
- // src/actions/gen-docs.ts
2210
- var genDocs = ({ pkg, incremental }) => {
2211
- return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental });
2212
- };
2213
- var genDocsPackage = ({ pkg }) => {
2214
- const steps = [["yarn", ["workspace", pkg, "run", "package-gen-docs"]]];
2215
- return runSteps(`GenDocs [${pkg}]`, [...steps]);
2216
- };
2217
- var genDocsAll = ({ incremental }) => {
2218
- const incrementalOptions = incremental ? ["--since", "-pA"] : ["-pA"];
2219
- const steps = [["yarn", ["workspaces", "foreach", ...incrementalOptions, "run", "package-gen-docs"]]];
2220
- return runSteps(`GenDocs [All${incremental ? "-Incremental" : ""}]`, [...steps]);
2221
- };
2222
-
2223
- // src/actions/gitignore.ts
2224
- import { unlinkSync as unlinkSync4 } from "fs";
2225
- import chalk27 from "chalk";
2226
- var COMMENT_PREFIX = "#";
2227
- var isComment = (line) => line.startsWith(COMMENT_PREFIX);
2228
- var isNegation = (line) => line.startsWith("!");
2229
- function parseTemplateSections(lines) {
2230
- const sections = [];
2231
- let current = [];
2232
- for (const line of lines) {
2233
- if (isComment(line)) {
2234
- if (current.length > 0) {
2235
- sections.push(current);
2236
- }
2237
- current = [line];
2238
- } else {
2239
- current.push(line);
2240
- }
2241
- }
2242
- if (current.length > 0) {
2243
- sections.push(current);
2244
- }
2245
- return sections;
2246
- }
2247
- function mergeWithTemplate(existing, templateContent) {
2248
- const templateLines = templateContent.split("\n").filter((line) => line.trim().length > 0);
2249
- const sections = parseTemplateSections(templateLines);
2250
- const existingEntries = new Set(existing.filter((line) => !isComment(line)));
2251
- const templateEntries = new Set(templateLines.filter((line) => !isComment(line)));
2252
- const customEntries = [...existingEntries].filter((entry) => !templateEntries.has(entry));
2253
- const result = [];
2254
- for (const section of sections) {
2255
- for (const line of section) {
2256
- result.push(line);
2257
- }
2258
- result.push("");
2259
- }
2260
- if (customEntries.length > 0) {
2261
- result.push("# Custom");
2262
- const sorted = [...union(customEntries, [])].toSorted((a, b) => {
2263
- if (isNegation(a) && !isNegation(b)) return 1;
2264
- if (!isNegation(a) && isNegation(b)) return -1;
2265
- return a.localeCompare(b);
2266
- });
2267
- for (const entry of sorted) {
2268
- result.push(entry);
2269
- }
2270
- result.push("");
2271
- }
2272
- return result;
2273
- }
2274
- function removePackageGitignores(cwd) {
2275
- let removed = 0;
2276
- const workspaces = yarnWorkspaces();
2277
- for (const { location } of workspaces) {
2278
- if (location === ".") continue;
2279
- const filePath = `${cwd}/${location}/.gitignore`;
2280
- try {
2281
- unlinkSync4(filePath);
2282
- console.log(chalk27.yellow(` Removed ${location}/.gitignore`));
2283
- removed++;
2284
- } catch {
2285
- }
2286
- }
2287
- return removed;
2288
- }
2289
- function gitignore() {
2290
- console.log(chalk27.green("Generate .gitignore"));
2291
- const cwd = INIT_CWD() ?? ".";
2292
- const gitignorePath = `${cwd}/.gitignore`;
2293
- try {
2294
- const templateContent = gitignoreTemplate();
2295
- const existing = readNonEmptyLines(gitignorePath);
2296
- const merged = mergeWithTemplate(existing, templateContent);
2297
- writeLines(gitignorePath, merged);
2298
- console.log(chalk27.green(" Root .gitignore updated"));
2299
- const removed = removePackageGitignores(cwd);
2300
- if (removed > 0) {
2301
- console.log(chalk27.green(` Removed ${removed} package .gitignore file(s)`));
2302
- }
2303
- return 0;
2304
- } catch (ex) {
2305
- const error = ex;
2306
- console.error(chalk27.red(`Generate .gitignore failed: ${error.message}`));
2307
- return 1;
2308
- }
2309
- }
2310
-
2311
- // src/actions/gitlint.ts
2312
- import chalk28 from "chalk";
2313
- import ParseGitConfig from "parse-git-config";
2314
- var gitlint = () => {
2315
- console.log(`
2316
- Gitlint Start [${process.cwd()}]
2317
- `);
2318
- let valid = 0;
2319
- let warnings = 0;
2320
- const errors = 0;
2321
- const gitConfig = ParseGitConfig.sync();
2322
- const warn = (message) => {
2323
- console.warn(chalk28.yellow(`Warning: ${message}`));
2324
- warnings++;
2325
- };
2326
- if (gitConfig.core.ignorecase) {
2327
- warn("Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]");
2328
- } else {
2329
- valid++;
2330
- }
2331
- if (gitConfig.core.autocrlf === false) {
2332
- valid++;
2333
- } else {
2334
- warn("Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]");
2335
- }
2336
- if (gitConfig.core.eol === "lf") {
2337
- valid++;
2338
- } else {
2339
- warn('Please set core.eol to "lf" in .git/config file [run yarn gitlint-fix]');
2340
- }
2341
- const resultMessages = [];
2342
- if (valid > 0) {
2343
- resultMessages.push(chalk28.green(`Passed: ${valid}`));
2344
- }
2345
- if (warnings > 0) {
2346
- resultMessages.push(chalk28.yellow(`Warnings: ${warnings}`));
2347
- }
2348
- if (errors > 0) {
2349
- resultMessages.push(chalk28.red(` Errors: ${errors}`));
2350
- }
2351
- console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
2352
- `);
2353
- return warnings + errors === 0 ? 1 : 0;
2354
- };
2355
-
2356
- // src/actions/gitlint-fix.ts
2357
- import { execSync as execSync3 } from "child_process";
2358
- import chalk29 from "chalk";
2359
- import ParseGitConfig2 from "parse-git-config";
2360
- var gitlintFix = () => {
2361
- console.log(`
2362
- Gitlint Fix Start [${process.cwd()}]
2363
- `);
2364
- const gitConfig = ParseGitConfig2.sync();
2365
- if (gitConfig.core.ignorecase) {
2366
- execSync3("git config core.ignorecase false", { stdio: "inherit" });
2367
- console.warn(chalk29.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
2368
- }
2369
- if (gitConfig.core.autocrlf !== false) {
2370
- execSync3("git config core.autocrlf false", { stdio: "inherit" });
2371
- console.warn(chalk29.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
2372
- }
2373
- if (gitConfig.core.eol !== "lf") {
2374
- execSync3("git config core.eol lf", { stdio: "inherit" });
2375
- console.warn(chalk29.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
2376
- }
2377
- return 1;
2378
- };
2379
-
2380
- // src/actions/knip.ts
2381
- var knip = () => {
2382
- return runSteps("Knip", [["yarn", ["knip", "--dependencies", "--no-exit-code"]]]);
2383
- };
2384
-
2385
- // src/actions/license.ts
2386
- import chalk30 from "chalk";
2387
- import { init } from "license-checker";
2388
- var license = async (pkg) => {
2389
- const workspaces = yarnWorkspaces();
2390
- const workspaceList = workspaces.filter(({ name }) => {
2391
- return pkg === void 0 || name === pkg;
2392
- });
2393
- const exclude = /* @__PURE__ */ new Set([
2394
- "MIT",
2395
- "MIT*",
2396
- "ISC",
2397
- "Apache-2.0",
2398
- "BSD",
2399
- "BSD*",
2400
- "BSD-2-Clause",
2401
- "BSD-3-Clause",
2402
- "CC-BY-4.0",
2403
- "Unlicense",
2404
- "CC-BY-3.0",
2405
- "CC0-1.0",
2406
- "LGPL-3.0-only",
2407
- "LGPL-3.0",
2408
- "LGPL-3.0-or-later",
2409
- "Python-2.0"
2410
- ]);
2411
- console.log(chalk30.green("License Checker"));
2412
- return (await Promise.all(
2413
- workspaceList.map(({ location, name }) => {
2414
- return new Promise((resolve) => {
2415
- init({ production: true, start: location }, (error, packages) => {
2416
- if (error) {
2417
- console.error(chalk30.red(`License Checker [${name}] Error`));
2418
- console.error(chalk30.gray(error));
2419
- console.log("\n");
2420
- resolve(1);
2421
- } else {
2422
- console.log(chalk30.green(`License Checker [${name}]`));
2423
- let count = 0;
2424
- for (const [name2, info] of Object.entries(packages)) {
2425
- const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
2426
- for (let license2 of licenses) {
2427
- if (license2) {
2428
- const processedLicense = license2[0] === "(" && license2.at(-1) === ")" ? license2.slice(1, -2) : license2;
2429
- const orLicenses = processedLicense.split(" OR ");
2430
- let orLicenseFound = false;
2431
- for (const orLicense of orLicenses) {
2432
- if (exclude.has(orLicense)) {
2433
- orLicenseFound = true;
2434
- }
2435
- }
2436
- if (!orLicenseFound) {
2437
- count++;
2438
- console.warn(chalk30.yellow(`${name2}: Package License not allowed [${license2}]`));
2439
- }
2440
- }
2441
- }
2442
- }
2443
- console.log("\n");
2444
- resolve(count);
2445
- }
2446
- });
2447
- });
2448
- })
2449
- )).reduce((prev, value) => prev || value, 0);
2450
- };
2451
-
2452
- // src/actions/npmignore-gen.ts
2453
- var filename = ".npmignore";
2454
- var npmignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
2455
-
2456
- // src/actions/package-lint.ts
2457
- import { readFileSync as readFileSync14, writeFileSync as writeFileSync6 } from "fs";
2458
- import PATH10 from "path";
2459
- import chalk31 from "chalk";
2460
- import picomatch from "picomatch";
2461
- function emptyResult() {
2462
- return {
2463
- errors: [],
2464
- fixable: [],
2465
- warnings: []
2466
- };
2467
- }
2468
- function readRootPackageJson(cwd) {
2469
- const raw = readFileSync14(PATH10.resolve(cwd, "package.json"), "utf8");
2470
- return JSON.parse(raw);
2471
- }
2472
- function writeRootPackageJson(cwd, pkg) {
2473
- const path8 = PATH10.resolve(cwd, "package.json");
2474
- writeFileSync6(path8, `${JSON.stringify(pkg, null, 2)}
2475
- `, "utf8");
2476
- }
2477
- function isMonorepo(pkg) {
2478
- const workspaces = pkg.workspaces;
2479
- return Array.isArray(workspaces) && workspaces.length > 0;
2480
- }
2481
- function checkPackagesFolder(workspaces) {
2482
- const result = emptyResult();
2483
- for (const { location, name } of workspaces) {
2484
- if (location === ".") continue;
2485
- if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
2486
- result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
2487
- }
2488
- }
2489
- return result;
2490
- }
2491
- function checkRootPrivate(pkg) {
2492
- const result = emptyResult();
2493
- if (!pkg.private) {
2494
- result.fixable.push("Root package.json must be private to prevent accidental publishing");
2495
- }
2496
- return result;
2497
- }
2498
- function fixRootPrivate(cwd, pkg) {
2499
- pkg.private = true;
2500
- writeRootPackageJson(cwd, pkg);
2501
- console.log(chalk31.green(' \u2714 Fixed: set "private": true in root package.json'));
2502
- }
2503
- function checkNoPublishConfigOnPrivate(pkg) {
2504
- const result = emptyResult();
2505
- if (pkg.private && pkg.publishConfig) {
2506
- result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
2507
- }
2508
- return result;
2509
- }
2510
- function fixNoPublishConfigOnPrivate(cwd, pkg) {
2511
- delete pkg.publishConfig;
2512
- writeRootPackageJson(cwd, pkg);
2513
- console.log(chalk31.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
2514
- }
2515
- function checkDiscoverable(pkg, workspaces) {
2516
- const result = emptyResult();
2517
- const globs = pkg.workspaces;
2518
- const matchers = globs.map((glob2) => picomatch(glob2));
2519
- const isMatch = (location) => matchers.some((m) => m(location));
2520
- for (const { location, name } of workspaces) {
2521
- if (location === ".") continue;
2522
- if (!isMatch(location)) {
2523
- result.errors.push(`${name} (${location}) is not matched by any workspace glob in package.json`);
2524
- }
2525
- }
2526
- return result;
2527
- }
2528
- function logResults(label, result, fix2) {
2529
- let errors = 0;
2530
- let fixed = 0;
2531
- for (const error of result.errors) {
2532
- console.log(chalk31.red(` \u2717 ${error}`));
2533
- errors++;
2534
- }
2535
- for (const fixable of result.fixable) {
2536
- if (fix2) {
2537
- fixed++;
2538
- } else {
2539
- console.log(chalk31.red(` \u2717 ${fixable} (fixable)`));
2540
- errors++;
2541
- }
2542
- }
2543
- for (const warning of result.warnings) {
2544
- console.log(chalk31.yellow(` \u26A0 ${warning}`));
2545
- }
2546
- if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
2547
- console.log(chalk31.green(` \u2713 ${label}`));
2548
- }
2549
- return { errors, fixed };
2550
- }
2551
- function runChecks(entries, cwd, pkg, fix2) {
2552
- let totalErrors = 0;
2553
- let totalFixed = 0;
2554
- for (const entry of entries) {
2555
- const result = entry.check();
2556
- const log = logResults(entry.label, result, fix2);
2557
- if (fix2 && entry.fix && result.fixable.length > 0) {
2558
- entry.fix(cwd, pkg);
2559
- }
2560
- totalErrors += log.errors;
2561
- totalFixed += log.fixed;
2562
- }
2563
- return { errors: totalErrors, fixed: totalFixed };
2564
- }
2565
- function logSummary(errors, fixed) {
2566
- if (fixed > 0) {
2567
- console.log(chalk31.green(`
2568
- Fixed ${fixed} issue(s)`));
2569
- }
2570
- if (errors > 0) {
2571
- console.log(chalk31.red(`
2572
- ${errors} error(s) found`));
2573
- } else if (fixed === 0) {
2574
- console.log(chalk31.green("\n All checks passed"));
2575
- }
2576
- }
2577
- function packageLintMonorepo(fix2 = false) {
2578
- const cwd = INIT_CWD() ?? process.cwd();
2579
- let pkg;
2580
- try {
2581
- pkg = readRootPackageJson(cwd);
2582
- } catch {
2583
- console.error(chalk31.red("Could not read package.json"));
2584
- return 1;
2585
- }
2586
- if (!isMonorepo(pkg)) {
2587
- console.log(chalk31.gray("Not a monorepo \u2014 skipping package-lint checks"));
2588
- return 0;
2589
- }
2590
- console.log(chalk31.green("Package Lint"));
2591
- const workspaces = yarnWorkspaces();
2592
- const checks = [
2593
- {
2594
- check: () => checkRootPrivate(pkg),
2595
- fix: fixRootPrivate,
2596
- label: "Root package is private"
2597
- },
2598
- {
2599
- check: () => checkNoPublishConfigOnPrivate(pkg),
2600
- fix: fixNoPublishConfigOnPrivate,
2601
- label: "No publishConfig on private root"
2602
- },
2603
- { check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
2604
- { check: () => checkDiscoverable(pkg, workspaces), label: "All packages are discoverable from workspace globs" }
2605
- ];
2606
- const { errors, fixed } = runChecks(checks, cwd, pkg, fix2);
2607
- logSummary(errors, fixed);
2608
- return errors > 0 ? 1 : 0;
2609
- }
2610
-
2611
- // src/actions/publint.ts
2612
- var publint = async ({ verbose, pkg }) => {
2613
- return pkg === void 0 ? publintAll({ verbose }) : await publintPackage({ pkg, verbose });
2614
- };
2615
- var publintPackage = ({ pkg }) => {
2616
- return runStepsAsync(`Publint [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-publint"]]]);
2617
- };
2618
- var publintAll = ({ verbose }) => {
2619
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
2620
- return runSteps("Publint", [["yarn", ["workspaces", "foreach", "-pA", ...verboseOptions, "run", "package-publint"]]]);
2621
- };
2622
-
2623
- // src/actions/publish.ts
2624
- var publish = () => {
2625
- return runSteps("Publish", [["npm", ["publish", "--workspaces"]]]);
2626
- };
2627
-
2628
- // src/actions/readme-gen.ts
2629
- async function readmeGen({
2630
- pkg,
2631
- templatePath,
2632
- typedoc,
2633
- verbose
2634
- }) {
2635
- const config2 = await loadConfig();
2636
- return await generateReadmeFiles({
2637
- logoLinkUrl: config2.readme?.logoLinkUrl,
2638
- logoUrl: config2.readme?.logoUrl,
2639
- pkg,
2640
- templatePath,
2641
- typedoc,
2642
- verbose
2643
- });
2644
- }
2645
-
2646
- // src/actions/readme-init.ts
2647
- async function readmeInit({ templatePath }) {
2648
- const config2 = await loadConfig();
2649
- const template = applyLogoConfig(DEFAULT_README_TEMPLATE, config2.readme?.logoUrl, config2.readme?.logoLinkUrl);
2650
- const resolvedTemplatePath = resolveTemplatePath(templatePath);
2651
- await scaffoldTemplate(resolvedTemplatePath, template);
2652
- return 0;
2653
- }
2654
-
2655
- // src/actions/rebuild.ts
2656
- var rebuild = ({ target }) => {
2657
- return runSteps("Rebuild", [
2658
- ["yarn", "xy clean"],
2659
- ["yarn", target ? `xy build -t ${target}` : "xy build"]
2660
- ]);
2661
- };
2662
-
2663
- // src/actions/recompile.ts
2664
- import chalk32 from "chalk";
2665
- var recompile = async ({
2666
- verbose,
2667
- target,
2668
- pkg,
2669
- incremental
2670
- }) => {
2671
- return pkg ? await recompilePackage({
2672
- pkg,
2673
- target,
2674
- verbose
2675
- }) : await recompileAll({
2676
- incremental,
2677
- target,
2678
- verbose
2679
- });
2680
- };
2681
- var recompilePackage = ({ target, pkg }) => {
2682
- const targetOptions = target ? ["-t", target] : [];
2683
- return runStepsAsync(
2684
- `Recompile [${pkg}]`,
2685
- [["yarn", ["workspace", pkg, "run", "package-recompile", ...targetOptions]]]
2686
- );
2687
- };
2688
- var recompileAll = async ({
2689
- jobs,
2690
- verbose,
2691
- target,
2692
- incremental
2693
- }) => {
2694
- const start = Date.now();
2695
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
2696
- const targetOptions = target ? ["-t", target] : [];
2697
- const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
2698
- const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
2699
- if (jobs) {
2700
- console.log(chalk32.blue(`Jobs set to [${jobs}]`));
2701
- }
2702
- const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
2703
- [
2704
- "yarn",
2705
- [
2706
- "workspaces",
2707
- "foreach",
2708
- ...incrementalOptions,
2709
- ...jobsOptions,
2710
- ...verboseOptions,
2711
- "run",
2712
- "package-clean",
2713
- ...targetOptions
2714
- ]
2715
- ],
2716
- [
2717
- "yarn",
2718
- [
2719
- "workspaces",
2720
- "foreach",
2721
- ...incrementalOptions,
2722
- ...jobsOptions,
2723
- ...verboseOptions,
2724
- "run",
2725
- "package-compile",
2726
- ...targetOptions
2727
- ]
2728
- ]
2729
- ]);
2730
- console.log(
2731
- `${chalk32.gray("Recompiled in")} [${chalk32.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk32.gray("seconds")}`
2732
- );
2733
- return result;
2734
- };
2735
-
2736
- // src/actions/reinstall.ts
2737
- import {
2738
- closeSync,
2739
- openSync,
2740
- rmSync as rmSync3
2741
- } from "fs";
2742
- var reinstall = () => {
2743
- console.log("Reinstall [Clear Lock File]");
2744
- closeSync(openSync("./yarn.lock", "w"));
2745
- console.log("Reinstall [Clear Node Modules]");
2746
- const workspaces = yarnWorkspaces();
2747
- const result = workspaces.map(({ location, name }) => {
2748
- const dist = `${location}/node_modules`;
2749
- try {
2750
- rmSync3(dist, { force: true, recursive: true });
2751
- return 0;
2752
- } catch (ex) {
2753
- const error = ex;
2754
- console.error(`Reinstall [Clear Node Modules] Failed [${name}, ${error.message}]`);
2755
- return 1;
2756
- }
2757
- }).reduce((prev, result2) => prev || result2, 0);
2758
- return result || runSteps("Reinstall", [["yarn", "install --network-timeout 10000"]]);
2759
- };
2760
-
2761
- // src/actions/relint.ts
2762
- import chalk33 from "chalk";
2763
- var relintPackage = ({
2764
- pkg,
2765
- fix: fix2,
2766
- verbose
2767
- }) => {
2768
- console.log(chalk33.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
2769
- const start = Date.now();
2770
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
2771
- ["yarn", [
2772
- "workspace",
2773
- pkg,
2774
- "run",
2775
- fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
2776
- ]]
2777
- ]);
2778
- console.log(chalk33.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk33.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk33.gray("seconds")}`));
2779
- return result;
2780
- };
2781
- var relint = ({
2782
- pkg,
2783
- verbose,
2784
- incremental,
2785
- fix: fix2
2786
- } = {}) => {
2787
- return pkg === void 0 ? relintAllPackages({
2788
- verbose,
2789
- incremental,
2790
- fix: fix2
2791
- }) : relintPackage({
2792
- pkg,
2793
- fix: fix2,
2794
- verbose
2795
- });
2796
- };
2797
- var relintAllPackages = ({ fix: fix2 = false } = {}) => {
2798
- console.log(chalk33.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
2799
- const start = Date.now();
2800
- const fixOptions = fix2 ? ["--fix"] : [];
2801
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
2802
- ["yarn", ["eslint", ...fixOptions]]
2803
- ]);
2804
- console.log(chalk33.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk33.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk33.gray("seconds")}`));
2805
- return result;
2806
- };
2807
-
2808
- // src/actions/retest.ts
2809
- function isWorkspace(target) {
2810
- return yarnWorkspaces().some((ws) => ws.name === target);
2811
- }
2812
- var retest = ({ target } = {}) => {
2813
- if (target && isWorkspace(target)) {
2814
- return runSteps(`Re-Test [${target}]`, [
2815
- ["yarn", ["workspace", target, "run", "vitest", "--clearCache"]],
2816
- ["yarn", ["workspace", target, "run", "vitest", "."]]
2817
- ]);
2818
- }
2819
- const path8 = target ?? ".";
2820
- return runSteps("Re-Test", [
2821
- ["yarn", ["vitest", "--clearCache"]],
2822
- ["yarn", ["vitest", path8]]
2823
- ]);
2824
- };
2825
-
2826
- // src/actions/sonar.ts
2827
- var sonar = () => {
2828
- return runSteps("Sonar", [["yarn", ["eslint", "-c", "sonar.eslintrc", "."]]]);
2829
- };
2830
-
2831
- // src/actions/statics.ts
2832
- import chalk34 from "chalk";
2833
- var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
2834
- var statics = () => {
2835
- console.log(chalk34.green("Check Required Static Dependencies"));
2836
- const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
2837
- return detectDuplicateDependencies(statics2, DefaultDependencies);
2838
- };
2839
-
2840
- // src/actions/test.ts
2841
- function isWorkspace2(target) {
2842
- return yarnWorkspaces().some((ws) => ws.name === target);
2843
- }
2844
- var test = ({ target } = {}) => {
2845
- if (target && isWorkspace2(target)) {
2846
- return runSteps(`Test [${target}]`, [["yarn", ["workspace", target, "run", "vitest", "."]]]);
2847
- }
2848
- const path8 = target ?? ".";
2849
- return runSteps("Test", [["yarn", ["vitest", path8]]]);
2850
- };
2851
-
2852
- // src/actions/up.ts
2853
- var up = () => {
2854
- return runSteps("Up", [["yarn", "outdated"]]);
2855
- };
2856
-
2857
- // src/actions/updo.ts
2858
- var updo = () => {
2859
- return runSteps("Updo", [
2860
- ["yarn", "install"],
2861
- ["yarn", "upgrade-interactive"],
2862
- ["yarn", "dedupe"]
2863
- ]);
2864
- };
2865
-
2866
- // src/actions/upplug.ts
2867
- var updateYarnPlugins = () => {
2868
- return runSteps("Update Yarn Plugins", [
2869
- ["yarn", ["plugin", "import", "https://mskelton.dev/yarn-outdated/v3"]],
2870
- ["yarn", ["plugin", "import", "version"]],
2871
- ["yarn", ["plugin", "import", "interactive-tools"]],
2872
- ["yarn", ["plugin", "import", "workspace-tools"]]
2873
- ]);
2874
- };
2875
-
2876
- // src/actions/upyarn.ts
2877
- var updateYarnVersion = () => {
2878
- return runSteps("Update Yarn Version", [["yarn", ["set", "version", "latest"]]]);
2879
- };
2880
-
2881
- // src/actions/yarn3only.ts
2882
- var yarn3Only = () => {
2883
- const [valid, version] = isYarnVersionOrGreater(3);
2884
- if (!valid) {
2885
- processEx(`Invalid Yarn version [${version}]`);
2886
- }
2887
- return 0;
2888
- };
2889
-
2890
- // src/xy/build/buildCommand.ts
2891
- var buildCommand = {
2892
- command: "build [package]",
2893
- describe: "Build - Compile & Lint",
2894
- builder: (yargs2) => {
2895
- return yargs2.positional("package", { describe: "Specific package to build" });
2896
- },
2897
- handler: async (argv) => {
2898
- if (argv.verbose) {
2899
- console.log(`Building: ${argv.package ?? "all"}`);
2900
- }
2901
- process.exitCode = await build({
2902
- incremental: !!argv.incremental,
2903
- jobs: argv.jobs,
2904
- pkg: argv.package,
2905
- target: argv.target,
2906
- verbose: !!argv.verbose
2907
- });
2908
- }
2909
- };
2910
-
2911
- // src/xy/build/compileCommand.ts
2912
- var compileCommand = {
2913
- command: "compile [package]",
2914
- describe: "Compile with Typescript & Copy Images",
2915
- builder: (yargs2) => {
2916
- return yargs2.positional("package", { describe: "Specific package to compile" });
2917
- },
2918
- handler: (argv) => {
2919
- if (argv.verbose) {
2920
- console.log(`Compiling: ${argv.package ?? "all"}`);
2921
- }
2922
- process.exitCode = compile({
2923
- incremental: !!argv.incremental,
2924
- jobs: argv.jobs,
2925
- pkg: argv.package,
2926
- target: argv.target,
2927
- verbose: !!argv.verbose
2928
- });
2929
- }
2930
- };
2931
-
2932
- // src/xy/build/compileOnlyCommand.ts
2933
- var compileOnlyCommand = {
2934
- command: "compile-only [package]",
2935
- describe: "Compile with Typescript & Copy Images (No Publint)",
2936
- builder: (yargs2) => {
2937
- return yargs2.positional("package", { describe: "Specific package to compile" });
2938
- },
2939
- handler: (argv) => {
2940
- if (argv.verbose) {
2941
- console.log(`Compiling: ${argv.package ?? "all"}`);
2942
- }
2943
- process.exitCode = compile({
2944
- incremental: !!argv.incremental,
2945
- jobs: argv.jobs,
2946
- pkg: argv.package,
2947
- publint: false,
2948
- target: argv.target,
2949
- verbose: !!argv.verbose
2950
- });
2951
- }
2952
- };
2953
-
2954
- // src/xy/build/copyAssetsCommand.ts
2955
- var copyAssetsCommand = {
2956
- command: "copy-assets [package]",
2957
- describe: "Copy Assets - Copy the assets from src to dist",
2958
- builder: (yargs2) => {
2959
- return yargs2.positional("package", { describe: "Specific package to copy assets" });
2960
- },
2961
- handler: async (argv) => {
2962
- if (argv.verbose) console.log(`Copying Assets: ${argv.package ?? "all"}`);
2963
- process.exitCode = await copyAssets({ target: argv.target });
2964
- }
2965
- };
2966
-
2967
- // src/xy/build/rebuildCommand.ts
2968
- var rebuildCommand = {
2969
- command: "rebuild [package]",
2970
- describe: "Rebuild - Clean, Compile & Lint",
2971
- builder: (yargs2) => {
2972
- return yargs2.positional("package", { describe: "Specific package to rebuild" });
2973
- },
2974
- handler: (argv) => {
2975
- if (argv.verbose) console.log(`Rebuilding: ${argv.package ?? "all"}`);
2976
- process.exitCode = rebuild({ target: argv.target });
2977
- }
2978
- };
2979
-
2980
- // src/xy/build/recompileCommand.ts
2981
- var recompileCommand = {
2982
- command: "recompile [package]",
2983
- describe: "Re-compile with Typescript & Copy Images",
2984
- builder: (yargs2) => {
2985
- return yargs2.positional("package", { describe: "Specific package to re-compile" });
2986
- },
2987
- handler: async (argv) => {
2988
- if (argv.verbose) {
2989
- console.log(`Re-compiling: ${argv.package ?? "all"}`);
2990
- }
2991
- process.exitCode = await recompile({
2992
- incremental: !!argv.incremental,
2993
- jobs: argv.jobs,
2994
- pkg: argv.package,
2995
- target: argv.target,
2996
- verbose: !!argv.verbose
2997
- });
2998
- }
2999
- };
3000
-
3001
- // src/xy/build/index.ts
3002
- var xyBuildCommands = (args) => {
3003
- return args.command(buildCommand).command(compileCommand).command(compileOnlyCommand).command(recompileCommand).command(rebuildCommand).command(copyAssetsCommand);
3004
- };
3005
-
3006
- // src/xy/common/claude/cleanCommand.ts
3007
- var cleanCommand = {
3008
- command: "clean",
3009
- describe: "Remove all Claude configuration files from the repo",
3010
- handler: (argv) => {
3011
- if (argv.verbose) console.log("Claude Clean");
3012
- process.exitCode = claudeClean();
3013
- }
3014
- };
3015
-
3016
- // src/xy/common/claude/commandsCommand.ts
3017
- var commandsCommand = {
3018
- command: "commands",
3019
- describe: "Sync XY Labs standard Claude slash commands to .claude/commands/",
3020
- handler: (argv) => {
3021
- if (argv.verbose) console.log("Claude Commands");
3022
- process.exitCode = claudeCommands();
3023
- }
3024
- };
3025
-
3026
- // src/xy/common/claude/initCommand.ts
3027
- var initCommand = {
3028
- builder: (yargs2) => {
3029
- return yargs2.option("force", {
3030
- alias: "f",
3031
- default: false,
3032
- description: "Overwrite existing CLAUDE.md",
3033
- type: "boolean"
3034
- });
3035
- },
3036
- command: "init",
3037
- describe: "Initialize all Claude configuration (commands, rules, settings)",
3038
- handler: async (argv) => {
3039
- if (argv.verbose) console.log("Claude Init");
3040
- const commandsResult = claudeCommands();
3041
- const rulesResult = claudeRules({ force: argv.force });
3042
- const settingsResult = await claudeSettings();
3043
- process.exitCode = commandsResult || rulesResult || settingsResult;
3044
- }
3045
- };
3046
-
3047
- // src/xy/common/claude/rulesCommand.ts
3048
- var rulesCommand = {
3049
- builder: (yargs2) => {
3050
- return yargs2.option("force", {
3051
- alias: "f",
3052
- default: false,
3053
- description: "Overwrite existing CLAUDE.md",
3054
- type: "boolean"
3055
- });
3056
- },
3057
- command: "rules",
3058
- describe: "Sync XY Labs standard Claude rules to .claude/rules/",
3059
- handler: (argv) => {
3060
- if (argv.verbose) console.log("Claude Rules");
3061
- process.exitCode = claudeRules({ force: argv.force });
3062
- }
3063
- };
3064
-
3065
- // src/xy/common/claude/settingsCommand.ts
3066
- var settingsCommand = {
3067
- command: "settings",
3068
- describe: "Initialize .claude/settings.local.json with XY Labs defaults",
3069
- handler: async (argv) => {
3070
- if (argv.verbose) console.log("Claude Settings");
3071
- process.exitCode = await claudeSettings();
3072
- }
3073
- };
3074
-
3075
- // src/xy/common/claude/skillsCommand.ts
3076
- var skillsCommand = {
3077
- builder: (yargs2) => yargs2,
3078
- command: "skills",
3079
- describe: "Sync XY Labs standard Claude skills to .claude/skills/",
3080
- handler: (argv) => {
3081
- if (argv.verbose) console.log("Claude Skills");
3082
- process.exitCode = claudeSkills();
3083
- }
3084
- };
3085
-
3086
- // src/xy/common/claude/index.ts
3087
- var claudeCommand = {
3088
- builder: (yargs2) => {
3089
- return yargs2.command(cleanCommand).command(commandsCommand).command(initCommand).command(rulesCommand).command(settingsCommand).command(skillsCommand).demandCommand(1, "Please specify a claude subcommand");
3090
- },
3091
- command: "claude",
3092
- describe: "Claude - Claude Code configuration utilities",
3093
- handler: () => {
3094
- }
18
+ const minorOk = majorDelta > 0 || minorDelta >= 0;
19
+ const patchOk = majorDelta > 0 || minorDelta > 0 || patchDelta >= 0;
20
+ return [majorOk && minorOk && patchOk, version];
3095
21
  };
3096
22
 
3097
- // src/xy/common/cleanDocsCommand.ts
3098
- var cleanDocsCommand = {
3099
- command: "clean-docs",
3100
- describe: "CleanDocs - Clean TypeDocs",
3101
- handler: (argv) => {
3102
- if (argv.verbose) console.log("Cleaning TypeDocs: all");
3103
- process.exitCode = cleanDocs();
23
+ // src/lib/yarn/workspace/yarnWorkspaces.ts
24
+ import { spawnSync as spawnSync2 } from "child_process";
25
+ var yarnWorkspaces = () => {
26
+ const result = spawnSync2("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
27
+ if (result.error) {
28
+ throw result.error;
3104
29
  }
30
+ return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
31
+ return JSON.parse(item);
32
+ });
3105
33
  };
3106
34
 
3107
- // src/xy/param.ts
3108
- var packagePositionalParam = (yargs2) => {
3109
- return yargs2.positional("package", { describe: "Specific package to target", type: "string" });
35
+ // src/actions/deploy.ts
36
+ var privatePackageExcludeList = () => {
37
+ const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
38
+ workspace,
39
+ JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: "utf8" }))
40
+ ]);
41
+ const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
42
+ const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
43
+ return excludeList;
3110
44
  };
3111
-
3112
- // src/xy/common/deadCommand.ts
3113
- var deadCommand = {
3114
- builder: (yargs2) => {
3115
- return packagePositionalParam(yargs2);
3116
- },
3117
- command: "dead [package]",
3118
- describe: "Dead - Check for dead code",
3119
- handler: (argv) => {
3120
- if (argv.verbose) console.log("Dead");
3121
- process.exitCode = dead();
45
+ var deploy = () => {
46
+ const excludeList = privatePackageExcludeList();
47
+ if (excludeList.length > 0) {
48
+ console.log("Excluding private packages from deployment:", excludeList);
3122
49
  }
50
+ return runSteps("Deploy [Patch]", [
51
+ ["yarn", "workspaces foreach --all version patch --deferred"],
52
+ ["yarn", "xy clean"],
53
+ ["yarn", "xy build"],
54
+ ["yarn", "version apply --all"]
55
+ ]);
3123
56
  };
3124
57
 
3125
- // src/xy/common/genDocsCommand.ts
3126
- var genDocsCommand = {
3127
- builder: (yargs2) => {
3128
- return packagePositionalParam(yargs2);
3129
- },
3130
- command: "gen-docs [package]",
3131
- describe: "GenDocs - Generate TypeDocs",
3132
- handler: (argv) => {
3133
- if (argv.verbose) console.log(`Generating TypeDocs: ${argv.package ?? "all"}`);
3134
- process.exitCode = genDocs({ incremental: !!argv.incremental, pkg: argv.package });
3135
- }
58
+ // src/actions/deploy-major.ts
59
+ import { readFileSync as readFileSync2 } from "fs";
60
+ import { runSteps as runSteps2 } from "@xylabs/ts-scripts-common";
61
+ var privatePackageExcludeList2 = () => {
62
+ const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
63
+ workspace,
64
+ JSON.parse(readFileSync2(`${workspace.location}/package.json`, { encoding: "utf8" }))
65
+ ]);
66
+ const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
67
+ const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
68
+ return excludeList;
3136
69
  };
3137
-
3138
- // src/xy/common/gitignoreCommand.ts
3139
- var gitignoreCommand = {
3140
- command: "gitignore",
3141
- describe: "GitIgnore - Generate root .gitignore and remove package .gitignore files",
3142
- handler: (argv) => {
3143
- if (argv.verbose) console.log("GitIgnore");
3144
- process.exitCode = gitignore();
70
+ var deployMajor = () => {
71
+ const excludeList = privatePackageExcludeList2();
72
+ if (excludeList.length > 0) {
73
+ console.log("Excluding private packages from deployment:", excludeList);
3145
74
  }
75
+ return runSteps2("Deploy [Major]", [
76
+ ["yarn", "workspaces foreach --all version major --deferred"],
77
+ ["yarn", "xy clean"],
78
+ ["yarn", "xy build"],
79
+ ["yarn", "version apply --all"]
80
+ ]);
3146
81
  };
3147
82
 
3148
- // src/xy/common/gitlintCommand.ts
3149
- var gitlintCommand = {
3150
- command: "gitlint [package]",
3151
- describe: "Gitlint - Lint your git config",
3152
- handler: (argv) => {
3153
- if (argv.verbose) console.log("Gitlint");
3154
- process.exitCode = argv.fix ? gitlintFix() : gitlint();
3155
- }
83
+ // src/actions/deploy-minor.ts
84
+ import { readFileSync as readFileSync3 } from "fs";
85
+ import { runSteps as runSteps3 } from "@xylabs/ts-scripts-common";
86
+ var privatePackageExcludeList3 = () => {
87
+ const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
88
+ workspace,
89
+ JSON.parse(readFileSync3(`${workspace.location}/package.json`, { encoding: "utf8" }))
90
+ ]);
91
+ const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
92
+ const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
93
+ return excludeList;
3156
94
  };
3157
-
3158
- // src/xy/common/licenseCommand.ts
3159
- var licenseCommand = {
3160
- builder: (yargs2) => {
3161
- return packagePositionalParam(yargs2);
3162
- },
3163
- command: "license [package]",
3164
- describe: "License - Check licenses of dependencies",
3165
- handler: async (argv) => {
3166
- if (argv.verbose) console.log(`License: ${argv.package ?? "all"}`);
3167
- process.exitCode = await license();
95
+ var deployMinor = () => {
96
+ const excludeList = privatePackageExcludeList3();
97
+ if (excludeList.length > 0) {
98
+ console.log("Excluding private packages from deployment:", excludeList);
3168
99
  }
100
+ return runSteps3("Deploy [Minor]", [
101
+ ["yarn", "workspaces foreach --all version minor --deferred"],
102
+ ["yarn", "xy clean"],
103
+ ["yarn", "xy build"],
104
+ ["yarn", "version apply --all"]
105
+ ]);
3169
106
  };
3170
107
 
3171
- // src/xy/common/npmignoreGenCommand.ts
3172
- var npmignoreGenCommand = {
3173
- command: "npmignore-gen",
3174
- describe: "NpmIgnore Gen - Generate .npmignore files",
3175
- handler: (argv) => {
3176
- if (argv.verbose) console.log("NpmIgnore Gen");
3177
- process.exitCode = npmignoreGen();
3178
- }
108
+ // src/actions/deploy-next.ts
109
+ import { readFileSync as readFileSync4 } from "fs";
110
+ import { runSteps as runSteps4 } from "@xylabs/ts-scripts-common";
111
+ var privatePackageExcludeList4 = () => {
112
+ const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
113
+ workspace,
114
+ JSON.parse(readFileSync4(`${workspace.location}/package.json`, { encoding: "utf8" }))
115
+ ]);
116
+ const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
117
+ const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
118
+ return excludeList;
3179
119
  };
3180
-
3181
- // src/xy/common/readme/genCommand.ts
3182
- var genCommand = {
3183
- builder: (yargs2) => {
3184
- return packagePositionalParam(yargs2).option("template", {
3185
- alias: "t",
3186
- description: "Path to README.template.md",
3187
- type: "string"
3188
- }).option("typedoc", {
3189
- default: false,
3190
- description: "Generate TypeDoc reference sections",
3191
- type: "boolean"
3192
- });
3193
- },
3194
- aliases: ["$0"],
3195
- command: "gen [package]",
3196
- describe: "Generate README.md files from template",
3197
- handler: async (argv) => {
3198
- if (argv.verbose) console.log("Readme Gen");
3199
- process.exitCode = await readmeGen({
3200
- pkg: argv.package,
3201
- templatePath: argv.template,
3202
- typedoc: argv.typedoc,
3203
- verbose: !!argv.verbose
3204
- });
120
+ var deployNext = () => {
121
+ const excludeList = privatePackageExcludeList4();
122
+ if (excludeList.length > 0) {
123
+ console.log("Excluding private packages from deployment:", excludeList);
3205
124
  }
125
+ return runSteps4("Deploy [Next]", [
126
+ ["yarn", "workspaces foreach --all version minor --deferred"],
127
+ ["yarn", "xy clean"],
128
+ ["yarn", "xy build"],
129
+ ["yarn", "version apply --all --prerelease"]
130
+ ]);
3206
131
  };
3207
132
 
3208
- // src/xy/common/readme/initCommand.ts
3209
- var initCommand2 = {
3210
- builder: (yargs2) => {
3211
- return yargs2.option("template", {
3212
- alias: "t",
3213
- description: "Path to README.template.md",
3214
- type: "string"
3215
- });
3216
- },
3217
- command: "init",
3218
- describe: "Initialize README template and logo files",
3219
- handler: async (argv) => {
3220
- if (argv.verbose) console.log("Readme Init");
3221
- process.exitCode = await readmeInit({
3222
- templatePath: argv.template,
3223
- verbose: !!argv.verbose
3224
- });
3225
- }
133
+ // src/actions/publish.ts
134
+ import { runSteps as runSteps5 } from "@xylabs/ts-scripts-common";
135
+ var publish = () => {
136
+ return runSteps5("Publish", [["npm", ["publish", "--workspaces"]]]);
3226
137
  };
3227
138
 
3228
- // src/xy/common/readme/index.ts
3229
- var readmeCommand = {
3230
- builder: (yargs2) => {
3231
- return yargs2.command(genCommand).command(initCommand2);
3232
- },
3233
- command: "readme",
3234
- describe: "Readme - README file utilities",
3235
- handler: () => {
3236
- }
139
+ // src/actions/reinstall.ts
140
+ import {
141
+ closeSync,
142
+ openSync,
143
+ rmSync
144
+ } from "fs";
145
+ import { runSteps as runSteps6 } from "@xylabs/ts-scripts-common";
146
+ var reinstall = () => {
147
+ console.log("Reinstall [Clear Lock File]");
148
+ closeSync(openSync("./yarn.lock", "w"));
149
+ console.log("Reinstall [Clear Node Modules]");
150
+ const workspaces = yarnWorkspaces();
151
+ const result = workspaces.map(({ location, name }) => {
152
+ const dist = `${location}/node_modules`;
153
+ try {
154
+ rmSync(dist, { force: true, recursive: true });
155
+ return 0;
156
+ } catch (ex) {
157
+ const error = ex;
158
+ console.error(`Reinstall [Clear Node Modules] Failed [${name}, ${error.message}]`);
159
+ return 1;
160
+ }
161
+ }).reduce((prev, result2) => prev || result2, 0);
162
+ return result || runSteps6("Reinstall", [["yarn", "install --network-timeout 10000"]]);
3237
163
  };
3238
164
 
3239
- // src/xy/common/retestCommand.ts
3240
- var retestCommand = {
3241
- command: "retest [target]",
3242
- describe: "Re-Test - Run Vitest Tests with cleaned cache",
3243
- builder: (yargs2) => {
3244
- return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
3245
- },
3246
- handler: (argv) => {
3247
- if (argv.verbose) console.log(`Re-Testing: ${argv.target ?? "all"}`);
3248
- process.exitCode = retest({ target: argv.target });
3249
- }
165
+ // src/actions/up.ts
166
+ import { runSteps as runSteps7 } from "@xylabs/ts-scripts-common";
167
+ var up = () => {
168
+ return runSteps7("Up", [["yarn", "outdated"]]);
3250
169
  };
3251
170
 
3252
- // src/xy/common/testCommand.ts
3253
- var testCommand = {
3254
- command: "test [target]",
3255
- describe: "Test - Run Vitest Tests",
3256
- builder: (yargs2) => {
3257
- return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
3258
- },
3259
- handler: (argv) => {
3260
- if (argv.verbose) console.log(`Testing: ${argv.target ?? "all"}`);
3261
- process.exitCode = test({ target: argv.target });
3262
- }
171
+ // src/actions/updo.ts
172
+ import { runSteps as runSteps8 } from "@xylabs/ts-scripts-common";
173
+ var updo = () => {
174
+ return runSteps8("Updo", [
175
+ ["yarn", "install"],
176
+ ["yarn", "upgrade-interactive"],
177
+ ["yarn", "dedupe"]
178
+ ]);
3263
179
  };
3264
180
 
3265
- // src/xy/common/upplugCommand.ts
3266
- var upplugCommand = {
3267
- command: "upplug",
3268
- describe: "UpPlug - Update Yarn Plugins",
3269
- handler: (argv) => {
3270
- if (argv.verbose) console.log("UpPlug");
3271
- process.exitCode = updateYarnPlugins();
3272
- }
181
+ // src/actions/upplug.ts
182
+ import { runSteps as runSteps9 } from "@xylabs/ts-scripts-common";
183
+ var updateYarnPlugins = () => {
184
+ return runSteps9("Update Yarn Plugins", [
185
+ ["yarn", ["plugin", "import", "https://mskelton.dev/yarn-outdated/v3"]],
186
+ ["yarn", ["plugin", "import", "version"]],
187
+ ["yarn", ["plugin", "import", "interactive-tools"]],
188
+ ["yarn", ["plugin", "import", "workspace-tools"]]
189
+ ]);
3273
190
  };
3274
191
 
3275
- // src/xy/common/upyarnCommand.ts
3276
- var upyarnCommand = {
3277
- command: "upyarn",
3278
- describe: "UpYarn - Update Yarn Version",
3279
- handler: (argv) => {
3280
- if (argv.verbose) console.log("UpYarn");
3281
- process.exitCode = updateYarnVersion();
3282
- }
192
+ // src/actions/upyarn.ts
193
+ import { runSteps as runSteps10 } from "@xylabs/ts-scripts-common";
194
+ var updateYarnVersion = () => {
195
+ return runSteps10("Update Yarn Version", [["yarn", ["set", "version", "latest"]]]);
3283
196
  };
3284
197
 
3285
- // src/xy/common/yarn3OnlyCommand.ts
3286
- var yarn3OnlyCommand = {
3287
- command: "yarn3only",
3288
- describe: "Yarn3Only - Check if using Yarn v3",
3289
- handler: (argv) => {
3290
- if (argv.verbose) console.log("Yarn 3 Check");
3291
- process.exitCode = yarn3Only();
198
+ // src/actions/yarn3only.ts
199
+ import { processEx } from "@xylabs/ts-scripts-common";
200
+ var yarn3Only = () => {
201
+ const [valid, version] = isYarnVersionOrGreater(3);
202
+ if (!valid) {
203
+ processEx(`Invalid Yarn version [${version}]`);
3292
204
  }
205
+ return 0;
3293
206
  };
3294
207
 
3295
- // src/xy/common/index.ts
3296
- var xyCommonCommands = (args) => {
3297
- return args.command(claudeCommand).command(licenseCommand).command(deadCommand).command(genDocsCommand).command(cleanDocsCommand).command(gitlintCommand).command(gitignoreCommand).command(npmignoreGenCommand).command(readmeCommand).command(retestCommand).command(testCommand).command(upplugCommand).command(upyarnCommand).command(yarn3OnlyCommand);
3298
- };
208
+ // src/actions/index.ts
209
+ import {
210
+ clean,
211
+ dupdeps,
212
+ statics
213
+ } from "@xylabs/ts-scripts-common";
3299
214
 
3300
215
  // src/xy/deploy/deployCommand.ts
3301
216
  var deployCommand = {
@@ -3353,11 +268,11 @@ var xyDeployCommands = (args) => {
3353
268
  };
3354
269
 
3355
270
  // src/xy/install/cleanCommand.ts
3356
- var cleanCommand2 = {
271
+ var cleanCommand = {
3357
272
  command: "clean [package]",
3358
273
  describe: "Clean",
3359
- builder: (yargs2) => {
3360
- return yargs2.positional("package", { describe: "Specific package to clean" });
274
+ builder: (yargs) => {
275
+ return yargs.positional("package", { describe: "Specific package to clean" });
3361
276
  },
3362
277
  handler: async (argv) => {
3363
278
  if (argv.verbose) {
@@ -3422,246 +337,47 @@ var updoCommand = {
3422
337
 
3423
338
  // src/xy/install/index.ts
3424
339
  var xyInstallCommands = (args) => {
3425
- return args.command(cleanCommand2).command(reinstallCommand).command(upCommand).command(updoCommand).command(staticsCommand).command(dupdepsCommand);
3426
- };
3427
-
3428
- // src/xy/lint/cycleCommand.ts
3429
- import chalk35 from "chalk";
3430
- var cycleCommand = {
3431
- command: "cycle [package]",
3432
- describe: "Cycle - Check for dependency cycles",
3433
- builder: (yargs2) => {
3434
- return packagePositionalParam(yargs2);
3435
- },
3436
- handler: async (argv) => {
3437
- const start = Date.now();
3438
- if (argv.verbose) console.log("Cycle");
3439
- process.exitCode = await cycle({ pkg: argv.package });
3440
- console.log(chalk35.blue(`Finished in ${Date.now() - start}ms`));
3441
- }
3442
- };
3443
-
3444
- // src/xy/lint/deplintCommand.ts
3445
- import chalk36 from "chalk";
3446
- var deplintCommand = {
3447
- command: "deplint [package]",
3448
- describe: "Deplint - Run Deplint",
3449
- builder: (yargs2) => {
3450
- return packagePositionalParam(yargs2).option("deps", {
3451
- alias: "d",
3452
- default: false,
3453
- description: "Check dependencies",
3454
- type: "boolean"
3455
- }).option("devDeps", {
3456
- alias: "v",
3457
- default: false,
3458
- description: "Check devDependencies",
3459
- type: "boolean"
3460
- }).option("peerDeps", {
3461
- alias: "p",
3462
- default: false,
3463
- description: "Check peerDependencies",
3464
- type: "boolean"
3465
- }).option("exclude", {
3466
- alias: "e",
3467
- description: "Package names to exclude from unused checks (comma-separated or repeated)",
3468
- type: "array"
3469
- });
3470
- },
3471
- handler: async (argv) => {
3472
- if (argv.verbose) console.log("Deplint");
3473
- const start = Date.now();
3474
- const cliExclude = argv.exclude?.flatMap((v) => String(v).split(",")).map((v) => v.trim()).filter(Boolean);
3475
- process.exitCode = await deplint({
3476
- cliExclude,
3477
- pkg: argv.package,
3478
- deps: !!argv.deps,
3479
- devDeps: !!argv.devDeps,
3480
- peerDeps: !!argv.peerDeps,
3481
- verbose: !!argv.verbose
3482
- });
3483
- console.log(chalk36.blue(`Finished in ${Date.now() - start}ms`));
3484
- }
3485
- };
3486
-
3487
- // src/xy/lint/fixCommand.ts
3488
- import chalk37 from "chalk";
3489
- var fixCommand = {
3490
- command: "fix [package]",
3491
- describe: "Fix - Run Eslint w/fix",
3492
- builder: (yargs2) => {
3493
- return packagePositionalParam(yargs2);
3494
- },
3495
- handler: (argv) => {
3496
- const start = Date.now();
3497
- if (argv.verbose) console.log("Fix");
3498
- process.exitCode = fix();
3499
- console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
3500
- }
3501
- };
3502
-
3503
- // src/xy/lint/knipCommand.ts
3504
- import chalk38 from "chalk";
3505
- var knipCommand = {
3506
- command: "knip",
3507
- describe: "Knip - Run Knip",
3508
- builder: (yargs2) => {
3509
- return packagePositionalParam(yargs2);
3510
- },
3511
- handler: (argv) => {
3512
- if (argv.verbose) console.log("Knip");
3513
- const start = Date.now();
3514
- process.exitCode = knip();
3515
- console.log(chalk38.blue(`Knip finished in ${Date.now() - start}ms`));
3516
- }
3517
- };
3518
-
3519
- // src/xy/lint/lintCommand.ts
3520
- import chalk39 from "chalk";
3521
- var lintCommand = {
3522
- command: "lint [package]",
3523
- describe: "Lint - Run Eslint",
3524
- builder: (yargs2) => {
3525
- return packagePositionalParam(yargs2).option("fix", {
3526
- alias: "f",
3527
- default: false,
3528
- description: "Fix fixable issues",
3529
- type: "boolean"
3530
- }).option("cache", {
3531
- alias: "c",
3532
- default: false,
3533
- description: "Use caching for performance",
3534
- type: "boolean"
3535
- });
3536
- },
3537
- handler: (argv) => {
3538
- if (argv.verbose) console.log("Lint");
3539
- const start = Date.now();
3540
- process.exitCode = argv.fix ? fix({
3541
- pkg: argv.package,
3542
- cache: argv.cache,
3543
- verbose: !!argv.verbose
3544
- }) : lint({
3545
- pkg: argv.package,
3546
- cache: argv.cache,
3547
- verbose: !!argv.verbose
3548
- });
3549
- console.log(chalk39.blue(`Finished in ${Date.now() - start}ms`));
3550
- }
340
+ return args.command(cleanCommand).command(reinstallCommand).command(upCommand).command(updoCommand).command(staticsCommand).command(dupdepsCommand);
3551
341
  };
3552
342
 
3553
- // src/xy/lint/packageLintCommand.ts
3554
- var packageLintCommand = {
3555
- builder: (yargs2) => {
3556
- return yargs2.option("fix", {
3557
- default: false,
3558
- description: "Auto-fix fixable issues",
3559
- type: "boolean"
3560
- });
3561
- },
3562
- command: "package-lint",
3563
- describe: "Package Lint - Check monorepo package structure",
343
+ // src/xy/common/upplugCommand.ts
344
+ var upplugCommand = {
345
+ command: "upplug",
346
+ describe: "UpPlug - Update Yarn Plugins",
3564
347
  handler: (argv) => {
3565
- if (argv.verbose) console.log("Package Lint");
3566
- process.exitCode = packageLintMonorepo(!!argv.fix);
3567
- }
3568
- };
3569
-
3570
- // src/xy/lint/publintCommand.ts
3571
- import chalk40 from "chalk";
3572
- var publintCommand = {
3573
- command: "publint [package]",
3574
- describe: "Publint - Run Publint",
3575
- builder: (yargs2) => {
3576
- return packagePositionalParam(yargs2);
3577
- },
3578
- handler: async (argv) => {
3579
- if (argv.verbose) console.log("Publint");
3580
- const start = Date.now();
3581
- process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
3582
- console.log(chalk40.blue(`Finished in ${Date.now() - start}ms`));
348
+ if (argv.verbose) console.log("UpPlug");
349
+ process.exitCode = updateYarnPlugins();
3583
350
  }
3584
351
  };
3585
352
 
3586
- // src/xy/lint/relintCommand.ts
3587
- import chalk41 from "chalk";
3588
- var relintCommand = {
3589
- command: "relint [package]",
3590
- describe: "Relint - Clean & Lint",
3591
- builder: (yargs2) => {
3592
- return packagePositionalParam(yargs2);
3593
- },
353
+ // src/xy/common/upyarnCommand.ts
354
+ var upyarnCommand = {
355
+ command: "upyarn",
356
+ describe: "UpYarn - Update Yarn Version",
3594
357
  handler: (argv) => {
3595
- if (argv.verbose) console.log("Relinting");
3596
- const start = Date.now();
3597
- process.exitCode = relint();
3598
- console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
358
+ if (argv.verbose) console.log("UpYarn");
359
+ process.exitCode = updateYarnVersion();
3599
360
  }
3600
361
  };
3601
362
 
3602
- // src/xy/lint/sonarCommand.ts
3603
- import chalk42 from "chalk";
3604
- var sonarCommand = {
3605
- command: "sonar",
3606
- describe: "Sonar - Run Sonar Check",
3607
- builder: (yargs2) => {
3608
- return packagePositionalParam(yargs2);
3609
- },
363
+ // src/xy/common/yarn3OnlyCommand.ts
364
+ var yarn3OnlyCommand = {
365
+ command: "yarn3only",
366
+ describe: "Yarn3Only - Check if using Yarn v3",
3610
367
  handler: (argv) => {
3611
- const start = Date.now();
3612
- if (argv.verbose) console.log("Sonar Check");
3613
- process.exitCode = sonar();
3614
- console.log(chalk42.blue(`Finished in ${Date.now() - start}ms`));
368
+ if (argv.verbose) console.log("Yarn 3 Check");
369
+ process.exitCode = yarn3Only();
3615
370
  }
3616
371
  };
3617
372
 
3618
- // src/xy/lint/index.ts
3619
- var xyLintCommands = (args) => {
3620
- return args.command(cycleCommand).command(lintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(packageLintCommand).command(sonarCommand);
3621
- };
3622
-
3623
- // src/xy/xyParseOptions.ts
3624
- import yargs from "yargs";
3625
- import { hideBin } from "yargs/helpers";
3626
- var xyParseOptions = () => {
3627
- return yargs(hideBin(process.argv)).scriptName("yarn xy").middleware((argv) => {
3628
- const commandName = argv._[0];
3629
- if (commandName && argv._.length <= 1) {
3630
- const result = tryRunLocalScript(commandName);
3631
- if (result !== void 0) {
3632
- process.exit(result);
3633
- }
3634
- }
3635
- }, true).option("jobs", {
3636
- alias: "j",
3637
- default: void 0,
3638
- description: "Max parallel jobs",
3639
- type: "number"
3640
- }).option("verbose", {
3641
- alias: "v",
3642
- default: false,
3643
- description: "Run with verbose logging",
3644
- type: "boolean"
3645
- }).option("incremental", {
3646
- alias: "i",
3647
- default: false,
3648
- description: "Attempt to perform the action only on changed packages",
3649
- type: "boolean"
3650
- }).option("profile", {
3651
- alias: "p",
3652
- default: false,
3653
- description: "Profile action",
3654
- type: "boolean"
3655
- });
373
+ // src/xy/yarnCommands.ts
374
+ var xyYarnCommands = (args) => {
375
+ return args.command(upplugCommand).command(upyarnCommand).command(yarn3OnlyCommand);
3656
376
  };
3657
377
 
3658
378
  // src/xy/xy.ts
3659
379
  var xy = async () => {
3660
- const options = xyParseOptions();
3661
- return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
3662
- console.error(chalk43.yellow(`Command not found [${chalk43.magenta(process.argv[2])}]`));
3663
- console.log(chalk43.gray("Try 'yarn xy --help' for list of commands"));
3664
- }).version().help().argv;
380
+ return await xyBase((args) => xyYarnCommands(xyInstallCommands(xyDeployCommands(args))));
3665
381
  };
3666
382
  export {
3667
383
  xy