@xylabs/ts-scripts-yarn3 7.4.28 → 7.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (412) 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 +128 -3840
  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 +222 -3684
  26. package/dist/bin/xy.mjs.map +1 -1
  27. package/dist/index.d.ts +24 -502
  28. package/dist/index.mjs +224 -4659
  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 +183 -3717
  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 +64 -3595
  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/lintlint.mjs +0 -230
  166. package/dist/actions/lintlint.mjs.map +0 -1
  167. package/dist/actions/npmignore-gen.mjs +0 -88
  168. package/dist/actions/npmignore-gen.mjs.map +0 -1
  169. package/dist/actions/package/clean-outputs.mjs +0 -29
  170. package/dist/actions/package/clean-outputs.mjs.map +0 -1
  171. package/dist/actions/package/clean-typescript.mjs +0 -29
  172. package/dist/actions/package/clean-typescript.mjs.map +0 -1
  173. package/dist/actions/package/clean.mjs +0 -48
  174. package/dist/actions/package/clean.mjs.map +0 -1
  175. package/dist/actions/package/compile/XyConfig.mjs +0 -1
  176. package/dist/actions/package/compile/XyConfig.mjs.map +0 -1
  177. package/dist/actions/package/compile/buildEntries.mjs +0 -53
  178. package/dist/actions/package/compile/buildEntries.mjs.map +0 -1
  179. package/dist/actions/package/compile/compile.mjs +0 -433
  180. package/dist/actions/package/compile/compile.mjs.map +0 -1
  181. package/dist/actions/package/compile/copyTypeFiles.mjs +0 -34
  182. package/dist/actions/package/compile/copyTypeFiles.mjs.map +0 -1
  183. package/dist/actions/package/compile/deepMerge.mjs +0 -26
  184. package/dist/actions/package/compile/deepMerge.mjs.map +0 -1
  185. package/dist/actions/package/compile/getCompilerOptions.mjs +0 -12
  186. package/dist/actions/package/compile/getCompilerOptions.mjs.map +0 -1
  187. package/dist/actions/package/compile/index.mjs +0 -436
  188. package/dist/actions/package/compile/index.mjs.map +0 -1
  189. package/dist/actions/package/compile/inputs.mjs +0 -22
  190. package/dist/actions/package/compile/inputs.mjs.map +0 -1
  191. package/dist/actions/package/compile/packageCompileTsc.mjs +0 -94
  192. package/dist/actions/package/compile/packageCompileTsc.mjs.map +0 -1
  193. package/dist/actions/package/compile/packageCompileTscTypes.mjs +0 -92
  194. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +0 -1
  195. package/dist/actions/package/compile/packageCompileTsup.mjs +0 -402
  196. package/dist/actions/package/compile/packageCompileTsup.mjs.map +0 -1
  197. package/dist/actions/package/copy-assets.mjs +0 -46
  198. package/dist/actions/package/copy-assets.mjs.map +0 -1
  199. package/dist/actions/package/cycle.mjs +0 -39
  200. package/dist/actions/package/cycle.mjs.map +0 -1
  201. package/dist/actions/package/gen-docs.mjs +0 -114
  202. package/dist/actions/package/gen-docs.mjs.map +0 -1
  203. package/dist/actions/package/index.mjs +0 -825
  204. package/dist/actions/package/index.mjs.map +0 -1
  205. package/dist/actions/package/lint.mjs +0 -80
  206. package/dist/actions/package/lint.mjs.map +0 -1
  207. package/dist/actions/package/publint.mjs +0 -66
  208. package/dist/actions/package/publint.mjs.map +0 -1
  209. package/dist/actions/package/recompile.mjs +0 -483
  210. package/dist/actions/package/recompile.mjs.map +0 -1
  211. package/dist/actions/package-lint.mjs +0 -178
  212. package/dist/actions/package-lint.mjs.map +0 -1
  213. package/dist/actions/publint.mjs +0 -166
  214. package/dist/actions/publint.mjs.map +0 -1
  215. package/dist/actions/readme-gen.mjs +0 -289
  216. package/dist/actions/readme-gen.mjs.map +0 -1
  217. package/dist/actions/readme-init.mjs +0 -83
  218. package/dist/actions/readme-init.mjs.map +0 -1
  219. package/dist/actions/rebuild.mjs +0 -101
  220. package/dist/actions/rebuild.mjs.map +0 -1
  221. package/dist/actions/recompile.mjs +0 -187
  222. package/dist/actions/recompile.mjs.map +0 -1
  223. package/dist/actions/relint.mjs +0 -144
  224. package/dist/actions/relint.mjs.map +0 -1
  225. package/dist/actions/retest.mjs +0 -123
  226. package/dist/actions/retest.mjs.map +0 -1
  227. package/dist/actions/sonar.mjs +0 -98
  228. package/dist/actions/sonar.mjs.map +0 -1
  229. package/dist/actions/statics.mjs +0 -183
  230. package/dist/actions/statics.mjs.map +0 -1
  231. package/dist/actions/test.mjs +0 -117
  232. package/dist/actions/test.mjs.map +0 -1
  233. package/dist/bin/package/build-only.mjs +0 -445
  234. package/dist/bin/package/build-only.mjs.map +0 -1
  235. package/dist/bin/package/build.mjs +0 -445
  236. package/dist/bin/package/build.mjs.map +0 -1
  237. package/dist/bin/package/clean-outputs.mjs +0 -29
  238. package/dist/bin/package/clean-outputs.mjs.map +0 -1
  239. package/dist/bin/package/clean-typescript.mjs +0 -29
  240. package/dist/bin/package/clean-typescript.mjs.map +0 -1
  241. package/dist/bin/package/clean.mjs +0 -53
  242. package/dist/bin/package/clean.mjs.map +0 -1
  243. package/dist/bin/package/compile-only.mjs +0 -441
  244. package/dist/bin/package/compile-only.mjs.map +0 -1
  245. package/dist/bin/package/compile-tsup.mjs +0 -409
  246. package/dist/bin/package/compile-tsup.mjs.map +0 -1
  247. package/dist/bin/package/compile.mjs +0 -445
  248. package/dist/bin/package/compile.mjs.map +0 -1
  249. package/dist/bin/package/copy-assets-cjs.mjs +0 -54
  250. package/dist/bin/package/copy-assets-cjs.mjs.map +0 -1
  251. package/dist/bin/package/copy-assets-esm.mjs +0 -54
  252. package/dist/bin/package/copy-assets-esm.mjs.map +0 -1
  253. package/dist/bin/package/cycle.mjs +0 -51
  254. package/dist/bin/package/cycle.mjs.map +0 -1
  255. package/dist/bin/package/fix.mjs +0 -92
  256. package/dist/bin/package/fix.mjs.map +0 -1
  257. package/dist/bin/package/gen-docs.mjs +0 -121
  258. package/dist/bin/package/gen-docs.mjs.map +0 -1
  259. package/dist/bin/package/lint-verbose.mjs +0 -92
  260. package/dist/bin/package/lint-verbose.mjs.map +0 -1
  261. package/dist/bin/package/lint.mjs +0 -92
  262. package/dist/bin/package/lint.mjs.map +0 -1
  263. package/dist/bin/package/publint.mjs +0 -75
  264. package/dist/bin/package/publint.mjs.map +0 -1
  265. package/dist/bin/package/recompile.mjs +0 -489
  266. package/dist/bin/package/recompile.mjs.map +0 -1
  267. package/dist/bin/package/relint.mjs +0 -92
  268. package/dist/bin/package/relint.mjs.map +0 -1
  269. package/dist/lib/checkResult.mjs +0 -16
  270. package/dist/lib/checkResult.mjs.map +0 -1
  271. package/dist/lib/claudeMdTemplate.mjs +0 -65
  272. package/dist/lib/claudeMdTemplate.mjs.map +0 -1
  273. package/dist/lib/createBuildConfig.mjs +0 -55
  274. package/dist/lib/createBuildConfig.mjs.map +0 -1
  275. package/dist/lib/defaultBuildConfig.mjs +0 -23
  276. package/dist/lib/defaultBuildConfig.mjs.map +0 -1
  277. package/dist/lib/deleteGlob.mjs +0 -13
  278. package/dist/lib/deleteGlob.mjs.map +0 -1
  279. package/dist/lib/dependencies/DuplicateDetector.mjs +0 -81
  280. package/dist/lib/dependencies/DuplicateDetector.mjs.map +0 -1
  281. package/dist/lib/dependencies/detectDuplicateDependencies.mjs +0 -164
  282. package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +0 -1
  283. package/dist/lib/dependencies/index.mjs +0 -165
  284. package/dist/lib/dependencies/index.mjs.map +0 -1
  285. package/dist/lib/file/ReadFileSyncOptions.mjs +0 -6
  286. package/dist/lib/file/ReadFileSyncOptions.mjs.map +0 -1
  287. package/dist/lib/file/constants.mjs +0 -8
  288. package/dist/lib/file/constants.mjs.map +0 -1
  289. package/dist/lib/file/fileLines.mjs +0 -32
  290. package/dist/lib/file/fileLines.mjs.map +0 -1
  291. package/dist/lib/file/index.mjs +0 -42
  292. package/dist/lib/file/index.mjs.map +0 -1
  293. package/dist/lib/file/tryReadFileSync.mjs +0 -14
  294. package/dist/lib/file/tryReadFileSync.mjs.map +0 -1
  295. package/dist/lib/generateIgnoreFiles.mjs +0 -84
  296. package/dist/lib/generateIgnoreFiles.mjs.map +0 -1
  297. package/dist/lib/generateReadmeFiles.mjs +0 -257
  298. package/dist/lib/generateReadmeFiles.mjs.map +0 -1
  299. package/dist/lib/gitignoreTemplate.mjs +0 -12
  300. package/dist/lib/gitignoreTemplate.mjs.map +0 -1
  301. package/dist/lib/jsonFormatters.mjs +0 -11
  302. package/dist/lib/jsonFormatters.mjs.map +0 -1
  303. package/dist/lib/loadConfig.mjs +0 -24
  304. package/dist/lib/loadConfig.mjs.map +0 -1
  305. package/dist/lib/parsedPackageJSON.mjs +0 -11
  306. package/dist/lib/parsedPackageJSON.mjs.map +0 -1
  307. package/dist/lib/processEx.mjs +0 -36
  308. package/dist/lib/processEx.mjs.map +0 -1
  309. package/dist/lib/runSteps.mjs +0 -95
  310. package/dist/lib/runSteps.mjs.map +0 -1
  311. package/dist/lib/runStepsAsync.mjs +0 -113
  312. package/dist/lib/runStepsAsync.mjs.map +0 -1
  313. package/dist/lib/runXy.mjs +0 -103
  314. package/dist/lib/runXy.mjs.map +0 -1
  315. package/dist/lib/runXyWithWarning.mjs +0 -13
  316. package/dist/lib/runXyWithWarning.mjs.map +0 -1
  317. package/dist/lib/safeExit.mjs +0 -61
  318. package/dist/lib/safeExit.mjs.map +0 -1
  319. package/dist/lib/string/empty.mjs +0 -8
  320. package/dist/lib/string/empty.mjs.map +0 -1
  321. package/dist/lib/string/index.mjs +0 -12
  322. package/dist/lib/string/index.mjs.map +0 -1
  323. package/dist/lib/string/union.mjs +0 -6
  324. package/dist/lib/string/union.mjs.map +0 -1
  325. package/dist/lib/tryRunLocalScript.mjs +0 -33
  326. package/dist/lib/tryRunLocalScript.mjs.map +0 -1
  327. package/dist/lib/withErrnoException.mjs +0 -13
  328. package/dist/lib/withErrnoException.mjs.map +0 -1
  329. package/dist/lib/withError.mjs +0 -8
  330. package/dist/lib/withError.mjs.map +0 -1
  331. package/dist/loadPackageConfig.mjs +0 -11
  332. package/dist/loadPackageConfig.mjs.map +0 -1
  333. package/dist/types.d.mjs +0 -1
  334. package/dist/types.d.mjs.map +0 -1
  335. package/dist/xy/build/buildCommand.mjs +0 -161
  336. package/dist/xy/build/buildCommand.mjs.map +0 -1
  337. package/dist/xy/build/compileCommand.mjs +0 -174
  338. package/dist/xy/build/compileCommand.mjs.map +0 -1
  339. package/dist/xy/build/compileOnlyCommand.mjs +0 -175
  340. package/dist/xy/build/compileOnlyCommand.mjs.map +0 -1
  341. package/dist/xy/build/copyAssetsCommand.mjs +0 -84
  342. package/dist/xy/build/copyAssetsCommand.mjs.map +0 -1
  343. package/dist/xy/build/index.mjs +0 -507
  344. package/dist/xy/build/index.mjs.map +0 -1
  345. package/dist/xy/build/rebuildCommand.mjs +0 -114
  346. package/dist/xy/build/rebuildCommand.mjs.map +0 -1
  347. package/dist/xy/build/recompileCommand.mjs +0 -204
  348. package/dist/xy/build/recompileCommand.mjs.map +0 -1
  349. package/dist/xy/common/claude/cleanCommand.mjs +0 -79
  350. package/dist/xy/common/claude/cleanCommand.mjs.map +0 -1
  351. package/dist/xy/common/claude/commandsCommand.mjs +0 -120
  352. package/dist/xy/common/claude/commandsCommand.mjs.map +0 -1
  353. package/dist/xy/common/claude/index.mjs +0 -546
  354. package/dist/xy/common/claude/index.mjs.map +0 -1
  355. package/dist/xy/common/claude/initCommand.mjs +0 -319
  356. package/dist/xy/common/claude/initCommand.mjs.map +0 -1
  357. package/dist/xy/common/claude/rulesCommand.mjs +0 -153
  358. package/dist/xy/common/claude/rulesCommand.mjs.map +0 -1
  359. package/dist/xy/common/claude/settingsCommand.mjs +0 -93
  360. package/dist/xy/common/claude/settingsCommand.mjs.map +0 -1
  361. package/dist/xy/common/claude/skillsCommand.mjs +0 -129
  362. package/dist/xy/common/claude/skillsCommand.mjs.map +0 -1
  363. package/dist/xy/common/cleanDocsCommand.mjs +0 -45
  364. package/dist/xy/common/cleanDocsCommand.mjs.map +0 -1
  365. package/dist/xy/common/deadCommand.mjs +0 -116
  366. package/dist/xy/common/deadCommand.mjs.map +0 -1
  367. package/dist/xy/common/genDocsCommand.mjs +0 -125
  368. package/dist/xy/common/genDocsCommand.mjs.map +0 -1
  369. package/dist/xy/common/gitignoreCommand.mjs +0 -158
  370. package/dist/xy/common/gitignoreCommand.mjs.map +0 -1
  371. package/dist/xy/common/gitlintCommand.mjs +0 -82
  372. package/dist/xy/common/gitlintCommand.mjs.map +0 -1
  373. package/dist/xy/common/licenseCommand.mjs +0 -100
  374. package/dist/xy/common/licenseCommand.mjs.map +0 -1
  375. package/dist/xy/common/npmignoreGenCommand.mjs +0 -98
  376. package/dist/xy/common/npmignoreGenCommand.mjs.map +0 -1
  377. package/dist/xy/common/readme/genCommand.mjs +0 -321
  378. package/dist/xy/common/readme/genCommand.mjs.map +0 -1
  379. package/dist/xy/common/readme/index.mjs +0 -361
  380. package/dist/xy/common/readme/index.mjs.map +0 -1
  381. package/dist/xy/common/readme/initCommand.mjs +0 -103
  382. package/dist/xy/common/readme/initCommand.mjs.map +0 -1
  383. package/dist/xy/common/retestCommand.mjs +0 -136
  384. package/dist/xy/common/retestCommand.mjs.map +0 -1
  385. package/dist/xy/common/testCommand.mjs +0 -130
  386. package/dist/xy/common/testCommand.mjs.map +0 -1
  387. package/dist/xy/lint/cycleCommand.mjs +0 -163
  388. package/dist/xy/lint/cycleCommand.mjs.map +0 -1
  389. package/dist/xy/lint/deplintCommand.mjs +0 -814
  390. package/dist/xy/lint/deplintCommand.mjs.map +0 -1
  391. package/dist/xy/lint/fixCommand.mjs +0 -168
  392. package/dist/xy/lint/fixCommand.mjs.map +0 -1
  393. package/dist/xy/lint/index.mjs +0 -1691
  394. package/dist/xy/lint/index.mjs.map +0 -1
  395. package/dist/xy/lint/knipCommand.mjs +0 -121
  396. package/dist/xy/lint/knipCommand.mjs.map +0 -1
  397. package/dist/xy/lint/lintCommand.mjs +0 -186
  398. package/dist/xy/lint/lintCommand.mjs.map +0 -1
  399. package/dist/xy/lint/lintlintCommand.mjs +0 -250
  400. package/dist/xy/lint/lintlintCommand.mjs.map +0 -1
  401. package/dist/xy/lint/packageLintCommand.mjs +0 -193
  402. package/dist/xy/lint/packageLintCommand.mjs.map +0 -1
  403. package/dist/xy/lint/publintCommand.mjs +0 -187
  404. package/dist/xy/lint/publintCommand.mjs.map +0 -1
  405. package/dist/xy/lint/relintCommand.mjs +0 -163
  406. package/dist/xy/lint/relintCommand.mjs.map +0 -1
  407. package/dist/xy/lint/sonarCommand.mjs +0 -121
  408. package/dist/xy/lint/sonarCommand.mjs.map +0 -1
  409. package/dist/xy/param.mjs +0 -8
  410. package/dist/xy/param.mjs.map +0 -1
  411. package/dist/xy/xyParseOptions.mjs +0 -70
  412. 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 chalk44 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";
@@ -312,1748 +32,11 @@ var yarnWorkspaces = () => {
312
32
  });
313
33
  };
314
34
 
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
35
  // src/actions/deploy.ts
2052
- import { readFileSync as readFileSync10 } from "fs";
2053
36
  var privatePackageExcludeList = () => {
2054
37
  const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
2055
38
  workspace,
2056
- JSON.parse(readFileSync10(`${workspace.location}/package.json`, { encoding: "utf8" }))
39
+ JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: "utf8" }))
2057
40
  ]);
2058
41
  const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
2059
42
  const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
@@ -2073,11 +56,12 @@ var deploy = () => {
2073
56
  };
2074
57
 
2075
58
  // src/actions/deploy-major.ts
2076
- import { readFileSync as readFileSync11 } from "fs";
59
+ import { readFileSync as readFileSync2 } from "fs";
60
+ import { runSteps as runSteps2 } from "@xylabs/ts-scripts-common";
2077
61
  var privatePackageExcludeList2 = () => {
2078
62
  const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
2079
63
  workspace,
2080
- JSON.parse(readFileSync11(`${workspace.location}/package.json`, { encoding: "utf8" }))
64
+ JSON.parse(readFileSync2(`${workspace.location}/package.json`, { encoding: "utf8" }))
2081
65
  ]);
2082
66
  const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
2083
67
  const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
@@ -2088,7 +72,7 @@ var deployMajor = () => {
2088
72
  if (excludeList.length > 0) {
2089
73
  console.log("Excluding private packages from deployment:", excludeList);
2090
74
  }
2091
- return runSteps("Deploy [Major]", [
75
+ return runSteps2("Deploy [Major]", [
2092
76
  ["yarn", "workspaces foreach --all version major --deferred"],
2093
77
  ["yarn", "xy clean"],
2094
78
  ["yarn", "xy build"],
@@ -2097,11 +81,12 @@ var deployMajor = () => {
2097
81
  };
2098
82
 
2099
83
  // src/actions/deploy-minor.ts
2100
- import { readFileSync as readFileSync12 } from "fs";
84
+ import { readFileSync as readFileSync3 } from "fs";
85
+ import { runSteps as runSteps3 } from "@xylabs/ts-scripts-common";
2101
86
  var privatePackageExcludeList3 = () => {
2102
87
  const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
2103
88
  workspace,
2104
- JSON.parse(readFileSync12(`${workspace.location}/package.json`, { encoding: "utf8" }))
89
+ JSON.parse(readFileSync3(`${workspace.location}/package.json`, { encoding: "utf8" }))
2105
90
  ]);
2106
91
  const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
2107
92
  const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
@@ -2112,7 +97,7 @@ var deployMinor = () => {
2112
97
  if (excludeList.length > 0) {
2113
98
  console.log("Excluding private packages from deployment:", excludeList);
2114
99
  }
2115
- return runSteps("Deploy [Minor]", [
100
+ return runSteps3("Deploy [Minor]", [
2116
101
  ["yarn", "workspaces foreach --all version minor --deferred"],
2117
102
  ["yarn", "xy clean"],
2118
103
  ["yarn", "xy build"],
@@ -2121,11 +106,12 @@ var deployMinor = () => {
2121
106
  };
2122
107
 
2123
108
  // src/actions/deploy-next.ts
2124
- import { readFileSync as readFileSync13 } from "fs";
109
+ import { readFileSync as readFileSync4 } from "fs";
110
+ import { runSteps as runSteps4 } from "@xylabs/ts-scripts-common";
2125
111
  var privatePackageExcludeList4 = () => {
2126
112
  const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
2127
113
  workspace,
2128
- JSON.parse(readFileSync13(`${workspace.location}/package.json`, { encoding: "utf8" }))
114
+ JSON.parse(readFileSync4(`${workspace.location}/package.json`, { encoding: "utf8" }))
2129
115
  ]);
2130
116
  const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
2131
117
  const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
@@ -2136,7 +122,7 @@ var deployNext = () => {
2136
122
  if (excludeList.length > 0) {
2137
123
  console.log("Excluding private packages from deployment:", excludeList);
2138
124
  }
2139
- return runSteps("Deploy [Next]", [
125
+ return runSteps4("Deploy [Next]", [
2140
126
  ["yarn", "workspaces foreach --all version minor --deferred"],
2141
127
  ["yarn", "xy clean"],
2142
128
  ["yarn", "xy build"],
@@ -2144,828 +130,19 @@ var deployNext = () => {
2144
130
  ]);
2145
131
  };
2146
132
 
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/lintlint.ts
2453
- import { readFileSync as readFileSync14, writeFileSync as writeFileSync6 } from "fs";
2454
- import PATH10 from "path";
2455
- import chalk31 from "chalk";
2456
- import { findUp } from "find-up";
2457
- function parseRuleValue(value) {
2458
- if (typeof value === "string") {
2459
- return { level: value };
2460
- }
2461
- if (typeof value === "number") {
2462
- return { level: String(value) };
2463
- }
2464
- if (Array.isArray(value) && value.length > 0) {
2465
- return {
2466
- level: String(value[0]),
2467
- options: value.length > 1 ? value.slice(1) : void 0
2468
- };
2469
- }
2470
- return void 0;
2471
- }
2472
- function normalizeLevel(level) {
2473
- if (level === "0" || level === "off") return "off";
2474
- if (level === "1" || level === "warn") return "warn";
2475
- if (level === "2" || level === "error") return "error";
2476
- return level;
2477
- }
2478
- function rulesMatch(a, b) {
2479
- if (normalizeLevel(a.level) !== normalizeLevel(b.level)) return false;
2480
- return JSON.stringify(a.options) === JSON.stringify(b.options);
2481
- }
2482
- function formatRule(entry) {
2483
- if (entry.options) {
2484
- return JSON.stringify([entry.level, ...entry.options]);
2485
- }
2486
- return JSON.stringify([entry.level]);
2487
- }
2488
- function mergeRulesFromBlocks(blocks) {
2489
- const merged = /* @__PURE__ */ new Map();
2490
- for (const block of blocks) {
2491
- if (!block.rules) continue;
2492
- for (const [name, value] of Object.entries(block.rules)) {
2493
- const parsed = parseRuleValue(value);
2494
- if (parsed) merged.set(name, parsed);
2495
- }
2496
- }
2497
- return merged;
2498
- }
2499
- function detectSharedPackage(source) {
2500
- if (source.includes("@xylabs/eslint-config-react-flat")) return "@xylabs/eslint-config-react-flat";
2501
- if (source.includes("@xylabs/eslint-config-flat")) return "@xylabs/eslint-config-flat";
2502
- return void 0;
2503
- }
2504
- function extractLocalRuleBlocks(source) {
2505
- const blocks = [];
2506
- const ruleBlockRegex = /\{\s*(?:files\s*:\s*\[.*?\]\s*,\s*)?rules\s*:\s*\{([^}]*(?:\{[^}]*\}[^}]*)*)\}/g;
2507
- let match;
2508
- while ((match = ruleBlockRegex.exec(source)) !== null) {
2509
- blocks.push(match[1]);
2510
- }
2511
- return blocks;
2512
- }
2513
- function extractRulesFromSourceBlocks(blocks) {
2514
- const rules2 = /* @__PURE__ */ new Map();
2515
- for (const block of blocks) {
2516
- const ruleRegex = /['"]([^'"]+)['"]\s*:\s*(\[[\s\S]*?\](?=\s*,|\s*$))/gm;
2517
- let match;
2518
- while ((match = ruleRegex.exec(block)) !== null) {
2519
- rules2.set(match[1], match[2]);
2520
- }
2521
- }
2522
- return rules2;
2523
- }
2524
- async function resolveSharedConfig(configDir, sharedPkg) {
2525
- try {
2526
- const sharedModule = await import(sharedPkg);
2527
- const config2 = sharedModule.config ?? sharedModule.default;
2528
- if (Array.isArray(config2)) return config2;
2529
- return [];
2530
- } catch {
2531
- const distPath = PATH10.resolve(configDir, "node_modules", sharedPkg, "dist", "node", "index.mjs");
2532
- try {
2533
- const sharedModule = await import(distPath);
2534
- const config2 = sharedModule.config ?? sharedModule.default;
2535
- if (Array.isArray(config2)) return config2;
2536
- } catch {
2537
- const neutralPath = PATH10.resolve(configDir, "node_modules", sharedPkg, "dist", "neutral", "index.mjs");
2538
- const sharedModule = await import(neutralPath);
2539
- const config2 = sharedModule.config ?? sharedModule.default;
2540
- if (Array.isArray(config2)) return config2;
2541
- }
2542
- return [];
2543
- }
2544
- }
2545
- async function loadSharedRules(configDir, sharedPkg, verbose) {
2546
- const sharedBlocks = await resolveSharedConfig(configDir, sharedPkg);
2547
- const sharedRules = mergeRulesFromBlocks(sharedBlocks);
2548
- if (verbose) {
2549
- console.log(chalk31.gray(`Shared config defines ${sharedRules.size} rules`));
2550
- }
2551
- if (sharedRules.size === 0) {
2552
- console.error(chalk31.red("Could not load rules from shared config. Is it installed and built?"));
2553
- return void 0;
2554
- }
2555
- return sharedRules;
2556
- }
2557
- async function loadLocalRules(eslintConfigPath, source, verbose) {
2558
- const localModule = await import(eslintConfigPath);
2559
- const localConfig = localModule.default ?? localModule;
2560
- const localBlocks = Array.isArray(localConfig) ? localConfig : [localConfig];
2561
- const resolved = mergeRulesFromBlocks(localBlocks);
2562
- const localRuleBlocks = extractLocalRuleBlocks(source);
2563
- const explicit = extractRulesFromSourceBlocks(localRuleBlocks);
2564
- if (verbose) {
2565
- console.log(chalk31.gray(`Local config has ${explicit.size} explicit rule setting(s)`));
2566
- }
2567
- return { explicit, resolved };
2568
- }
2569
- function compareRules(explicitRuleNames, allResolvedRules, sharedRules) {
2570
- const redundant = [];
2571
- const overrides = [];
2572
- const additions = [];
2573
- for (const ruleName of explicitRuleNames.keys()) {
2574
- const resolvedEntry = allResolvedRules.get(ruleName);
2575
- const sharedEntry = sharedRules.get(ruleName);
2576
- if (!resolvedEntry) continue;
2577
- if (!sharedEntry) {
2578
- additions.push({ local: resolvedEntry, rule: ruleName });
2579
- } else if (rulesMatch(resolvedEntry, sharedEntry)) {
2580
- redundant.push({
2581
- local: resolvedEntry,
2582
- rule: ruleName,
2583
- shared: sharedEntry
2584
- });
2585
- } else {
2586
- overrides.push({
2587
- local: resolvedEntry,
2588
- rule: ruleName,
2589
- shared: sharedEntry
2590
- });
2591
- }
2592
- }
2593
- return {
2594
- additions,
2595
- overrides,
2596
- redundant
2597
- };
2598
- }
2599
- function reportResults({
2600
- additions,
2601
- overrides,
2602
- redundant
2603
- }, verbose) {
2604
- if (redundant.length > 0) {
2605
- console.log(chalk31.yellow(`
2606
- ${redundant.length} redundant rule(s) (same as shared config \u2014 can be removed):`));
2607
- for (const { rule, local } of redundant) {
2608
- console.log(chalk31.yellow(` ${rule}: ${formatRule(local)}`));
2609
- }
2610
- }
2611
- if (overrides.length > 0) {
2612
- console.log(chalk31.cyan(`
2613
- ${overrides.length} rule override(s) (different from shared config):`));
2614
- for (const {
2615
- rule,
2616
- local,
2617
- shared
2618
- } of overrides) {
2619
- console.log(chalk31.cyan(` ${rule}:`));
2620
- console.log(chalk31.gray(` shared: ${formatRule(shared)}`));
2621
- console.log(chalk31.white(` local: ${formatRule(local)}`));
2622
- }
2623
- }
2624
- if (additions.length > 0 && verbose) {
2625
- console.log(chalk31.gray(`
2626
- ${additions.length} local addition(s) (not in shared config):`));
2627
- for (const { rule, local } of additions) {
2628
- console.log(chalk31.gray(` ${rule}: ${formatRule(local)}`));
2629
- }
2630
- }
2631
- if (redundant.length === 0 && overrides.length === 0) {
2632
- console.log(chalk31.green("No redundant or overridden rules found"));
2633
- }
2634
- }
2635
- function fixRedundantRules(eslintConfigPath, source, redundant) {
2636
- let updated = source;
2637
- for (const { rule } of redundant) {
2638
- const escaped = rule.replaceAll("/", String.raw`\/`);
2639
- const pattern = new RegExp(String.raw`[ \t]*['"]${escaped}['"]\s*:\s*\[[^\]]*\],?[ \t]*\n?`, "g");
2640
- updated = updated.replace(pattern, "");
2641
- }
2642
- updated = updated.replaceAll(/\n{3,}/g, "\n\n");
2643
- if (updated !== source) {
2644
- writeFileSync6(eslintConfigPath, updated, "utf8");
2645
- console.log(chalk31.green(`
2646
- Fixed: removed ${redundant.length} redundant rule(s)`));
2647
- }
2648
- }
2649
- async function lintlint({ fix: fix2, verbose } = {}) {
2650
- const eslintConfigPath = await findUp("eslint.config.mjs");
2651
- if (!eslintConfigPath) {
2652
- console.error(chalk31.red("No eslint.config.mjs found"));
2653
- return 1;
2654
- }
2655
- const configDir = PATH10.dirname(eslintConfigPath);
2656
- if (verbose) {
2657
- console.log(chalk31.gray(`Found config: ${eslintConfigPath}`));
2658
- }
2659
- const source = readFileSync14(eslintConfigPath, "utf8");
2660
- const sharedPkg = detectSharedPackage(source);
2661
- if (!sharedPkg) {
2662
- console.log(chalk31.yellow("No @xylabs/eslint-config-flat or @xylabs/eslint-config-react-flat imports found"));
2663
- return 0;
2664
- }
2665
- if (verbose) {
2666
- console.log(chalk31.gray(`Shared package: ${sharedPkg}`));
2667
- }
2668
- const sharedRules = await loadSharedRules(configDir, sharedPkg, !!verbose);
2669
- if (!sharedRules) return 1;
2670
- const { explicit, resolved } = await loadLocalRules(eslintConfigPath, source, !!verbose);
2671
- const results = compareRules(explicit, resolved, sharedRules);
2672
- reportResults(results, !!verbose);
2673
- if (results.redundant.length > 0 && fix2) {
2674
- fixRedundantRules(eslintConfigPath, source, results.redundant);
2675
- }
2676
- return results.redundant.length > 0 && !fix2 ? 1 : 0;
2677
- }
2678
-
2679
- // src/actions/npmignore-gen.ts
2680
- var filename = ".npmignore";
2681
- var npmignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
2682
-
2683
- // src/actions/package-lint.ts
2684
- import { readFileSync as readFileSync15, writeFileSync as writeFileSync7 } from "fs";
2685
- import PATH11 from "path";
2686
- import chalk32 from "chalk";
2687
- import picomatch from "picomatch";
2688
- function emptyResult() {
2689
- return {
2690
- errors: [],
2691
- fixable: [],
2692
- warnings: []
2693
- };
2694
- }
2695
- function readRootPackageJson(cwd) {
2696
- const raw = readFileSync15(PATH11.resolve(cwd, "package.json"), "utf8");
2697
- return JSON.parse(raw);
2698
- }
2699
- function writeRootPackageJson(cwd, pkg) {
2700
- const path8 = PATH11.resolve(cwd, "package.json");
2701
- writeFileSync7(path8, `${JSON.stringify(pkg, null, 2)}
2702
- `, "utf8");
2703
- }
2704
- function isMonorepo(pkg) {
2705
- const workspaces = pkg.workspaces;
2706
- return Array.isArray(workspaces) && workspaces.length > 0;
2707
- }
2708
- function checkPackagesFolder(workspaces) {
2709
- const result = emptyResult();
2710
- for (const { location, name } of workspaces) {
2711
- if (location === ".") continue;
2712
- if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
2713
- result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
2714
- }
2715
- }
2716
- return result;
2717
- }
2718
- function checkRootPrivate(pkg) {
2719
- const result = emptyResult();
2720
- if (!pkg.private) {
2721
- result.fixable.push("Root package.json must be private to prevent accidental publishing");
2722
- }
2723
- return result;
2724
- }
2725
- function fixRootPrivate(cwd, pkg) {
2726
- pkg.private = true;
2727
- writeRootPackageJson(cwd, pkg);
2728
- console.log(chalk32.green(' \u2714 Fixed: set "private": true in root package.json'));
2729
- }
2730
- function checkNoPublishConfigOnPrivate(pkg) {
2731
- const result = emptyResult();
2732
- if (pkg.private && pkg.publishConfig) {
2733
- result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
2734
- }
2735
- return result;
2736
- }
2737
- function fixNoPublishConfigOnPrivate(cwd, pkg) {
2738
- delete pkg.publishConfig;
2739
- writeRootPackageJson(cwd, pkg);
2740
- console.log(chalk32.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
2741
- }
2742
- function checkDiscoverable(pkg, workspaces) {
2743
- const result = emptyResult();
2744
- const globs = pkg.workspaces;
2745
- const matchers = globs.map((glob2) => picomatch(glob2));
2746
- const isMatch = (location) => matchers.some((m) => m(location));
2747
- for (const { location, name } of workspaces) {
2748
- if (location === ".") continue;
2749
- if (!isMatch(location)) {
2750
- result.errors.push(`${name} (${location}) is not matched by any workspace glob in package.json`);
2751
- }
2752
- }
2753
- return result;
2754
- }
2755
- function logResults(label, result, fix2) {
2756
- let errors = 0;
2757
- let fixed = 0;
2758
- for (const error of result.errors) {
2759
- console.log(chalk32.red(` \u2717 ${error}`));
2760
- errors++;
2761
- }
2762
- for (const fixable of result.fixable) {
2763
- if (fix2) {
2764
- fixed++;
2765
- } else {
2766
- console.log(chalk32.red(` \u2717 ${fixable} (fixable)`));
2767
- errors++;
2768
- }
2769
- }
2770
- for (const warning of result.warnings) {
2771
- console.log(chalk32.yellow(` \u26A0 ${warning}`));
2772
- }
2773
- if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
2774
- console.log(chalk32.green(` \u2713 ${label}`));
2775
- }
2776
- return { errors, fixed };
2777
- }
2778
- function runChecks(entries, cwd, pkg, fix2) {
2779
- let totalErrors = 0;
2780
- let totalFixed = 0;
2781
- for (const entry of entries) {
2782
- const result = entry.check();
2783
- const log = logResults(entry.label, result, fix2);
2784
- if (fix2 && entry.fix && result.fixable.length > 0) {
2785
- entry.fix(cwd, pkg);
2786
- }
2787
- totalErrors += log.errors;
2788
- totalFixed += log.fixed;
2789
- }
2790
- return { errors: totalErrors, fixed: totalFixed };
2791
- }
2792
- function logSummary(errors, fixed) {
2793
- if (fixed > 0) {
2794
- console.log(chalk32.green(`
2795
- Fixed ${fixed} issue(s)`));
2796
- }
2797
- if (errors > 0) {
2798
- console.log(chalk32.red(`
2799
- ${errors} error(s) found`));
2800
- } else if (fixed === 0) {
2801
- console.log(chalk32.green("\n All checks passed"));
2802
- }
2803
- }
2804
- function packageLintMonorepo(fix2 = false) {
2805
- const cwd = INIT_CWD() ?? process.cwd();
2806
- let pkg;
2807
- try {
2808
- pkg = readRootPackageJson(cwd);
2809
- } catch {
2810
- console.error(chalk32.red("Could not read package.json"));
2811
- return 1;
2812
- }
2813
- if (!isMonorepo(pkg)) {
2814
- console.log(chalk32.gray("Not a monorepo \u2014 skipping package-lint checks"));
2815
- return 0;
2816
- }
2817
- console.log(chalk32.green("Package Lint"));
2818
- const workspaces = yarnWorkspaces();
2819
- const checks = [
2820
- {
2821
- check: () => checkRootPrivate(pkg),
2822
- fix: fixRootPrivate,
2823
- label: "Root package is private"
2824
- },
2825
- {
2826
- check: () => checkNoPublishConfigOnPrivate(pkg),
2827
- fix: fixNoPublishConfigOnPrivate,
2828
- label: "No publishConfig on private root"
2829
- },
2830
- { check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
2831
- { check: () => checkDiscoverable(pkg, workspaces), label: "All packages are discoverable from workspace globs" }
2832
- ];
2833
- const { errors, fixed } = runChecks(checks, cwd, pkg, fix2);
2834
- logSummary(errors, fixed);
2835
- return errors > 0 ? 1 : 0;
2836
- }
2837
-
2838
- // src/actions/publint.ts
2839
- var publint = async ({ verbose, pkg }) => {
2840
- return pkg === void 0 ? publintAll({ verbose }) : await publintPackage({ pkg, verbose });
2841
- };
2842
- var publintPackage = ({ pkg }) => {
2843
- return runStepsAsync(`Publint [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-publint"]]]);
2844
- };
2845
- var publintAll = ({ verbose }) => {
2846
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
2847
- return runSteps("Publint", [["yarn", ["workspaces", "foreach", "-pA", ...verboseOptions, "run", "package-publint"]]]);
2848
- };
2849
-
2850
133
  // src/actions/publish.ts
134
+ import { runSteps as runSteps5 } from "@xylabs/ts-scripts-common";
2851
135
  var publish = () => {
2852
- return runSteps("Publish", [["npm", ["publish", "--workspaces"]]]);
2853
- };
2854
-
2855
- // src/actions/readme-gen.ts
2856
- async function readmeGen({
2857
- pkg,
2858
- templatePath,
2859
- typedoc,
2860
- verbose
2861
- }) {
2862
- const config2 = await loadConfig();
2863
- return await generateReadmeFiles({
2864
- logoLinkUrl: config2.readme?.logoLinkUrl,
2865
- logoUrl: config2.readme?.logoUrl,
2866
- pkg,
2867
- templatePath,
2868
- typedoc,
2869
- verbose
2870
- });
2871
- }
2872
-
2873
- // src/actions/readme-init.ts
2874
- async function readmeInit({ templatePath }) {
2875
- const config2 = await loadConfig();
2876
- const template = applyLogoConfig(DEFAULT_README_TEMPLATE, config2.readme?.logoUrl, config2.readme?.logoLinkUrl);
2877
- const resolvedTemplatePath = resolveTemplatePath(templatePath);
2878
- await scaffoldTemplate(resolvedTemplatePath, template);
2879
- return 0;
2880
- }
2881
-
2882
- // src/actions/rebuild.ts
2883
- var rebuild = ({ target }) => {
2884
- return runSteps("Rebuild", [
2885
- ["yarn", "xy clean"],
2886
- ["yarn", target ? `xy build -t ${target}` : "xy build"]
2887
- ]);
2888
- };
2889
-
2890
- // src/actions/recompile.ts
2891
- import chalk33 from "chalk";
2892
- var recompile = async ({
2893
- verbose,
2894
- target,
2895
- pkg,
2896
- incremental
2897
- }) => {
2898
- return pkg ? await recompilePackage({
2899
- pkg,
2900
- target,
2901
- verbose
2902
- }) : await recompileAll({
2903
- incremental,
2904
- target,
2905
- verbose
2906
- });
2907
- };
2908
- var recompilePackage = ({ target, pkg }) => {
2909
- const targetOptions = target ? ["-t", target] : [];
2910
- return runStepsAsync(
2911
- `Recompile [${pkg}]`,
2912
- [["yarn", ["workspace", pkg, "run", "package-recompile", ...targetOptions]]]
2913
- );
2914
- };
2915
- var recompileAll = async ({
2916
- jobs,
2917
- verbose,
2918
- target,
2919
- incremental
2920
- }) => {
2921
- const start = Date.now();
2922
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
2923
- const targetOptions = target ? ["-t", target] : [];
2924
- const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
2925
- const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
2926
- if (jobs) {
2927
- console.log(chalk33.blue(`Jobs set to [${jobs}]`));
2928
- }
2929
- const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
2930
- [
2931
- "yarn",
2932
- [
2933
- "workspaces",
2934
- "foreach",
2935
- ...incrementalOptions,
2936
- ...jobsOptions,
2937
- ...verboseOptions,
2938
- "run",
2939
- "package-clean",
2940
- ...targetOptions
2941
- ]
2942
- ],
2943
- [
2944
- "yarn",
2945
- [
2946
- "workspaces",
2947
- "foreach",
2948
- ...incrementalOptions,
2949
- ...jobsOptions,
2950
- ...verboseOptions,
2951
- "run",
2952
- "package-compile",
2953
- ...targetOptions
2954
- ]
2955
- ]
2956
- ]);
2957
- console.log(
2958
- `${chalk33.gray("Recompiled in")} [${chalk33.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk33.gray("seconds")}`
2959
- );
2960
- return result;
136
+ return runSteps5("Publish", [["npm", ["publish", "--workspaces"]]]);
2961
137
  };
2962
138
 
2963
139
  // src/actions/reinstall.ts
2964
140
  import {
2965
141
  closeSync,
2966
142
  openSync,
2967
- rmSync as rmSync3
143
+ rmSync
2968
144
  } from "fs";
145
+ import { runSteps as runSteps6 } from "@xylabs/ts-scripts-common";
2969
146
  var reinstall = () => {
2970
147
  console.log("Reinstall [Clear Lock File]");
2971
148
  closeSync(openSync("./yarn.lock", "w"));
@@ -2974,7 +151,7 @@ var reinstall = () => {
2974
151
  const result = workspaces.map(({ location, name }) => {
2975
152
  const dist = `${location}/node_modules`;
2976
153
  try {
2977
- rmSync3(dist, { force: true, recursive: true });
154
+ rmSync(dist, { force: true, recursive: true });
2978
155
  return 0;
2979
156
  } catch (ex) {
2980
157
  const error = ex;
@@ -2982,108 +159,19 @@ var reinstall = () => {
2982
159
  return 1;
2983
160
  }
2984
161
  }).reduce((prev, result2) => prev || result2, 0);
2985
- return result || runSteps("Reinstall", [["yarn", "install --network-timeout 10000"]]);
2986
- };
2987
-
2988
- // src/actions/relint.ts
2989
- import chalk34 from "chalk";
2990
- var relintPackage = ({
2991
- pkg,
2992
- fix: fix2,
2993
- verbose
2994
- }) => {
2995
- console.log(chalk34.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
2996
- const start = Date.now();
2997
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
2998
- ["yarn", [
2999
- "workspace",
3000
- pkg,
3001
- "run",
3002
- fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
3003
- ]]
3004
- ]);
3005
- console.log(chalk34.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`));
3006
- return result;
3007
- };
3008
- var relint = ({
3009
- pkg,
3010
- verbose,
3011
- incremental,
3012
- fix: fix2
3013
- } = {}) => {
3014
- return pkg === void 0 ? relintAllPackages({
3015
- verbose,
3016
- incremental,
3017
- fix: fix2
3018
- }) : relintPackage({
3019
- pkg,
3020
- fix: fix2,
3021
- verbose
3022
- });
3023
- };
3024
- var relintAllPackages = ({ fix: fix2 = false } = {}) => {
3025
- console.log(chalk34.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
3026
- const start = Date.now();
3027
- const fixOptions = fix2 ? ["--fix"] : [];
3028
- const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
3029
- ["yarn", ["eslint", ...fixOptions]]
3030
- ]);
3031
- console.log(chalk34.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`));
3032
- return result;
3033
- };
3034
-
3035
- // src/actions/retest.ts
3036
- function isWorkspace(target) {
3037
- return yarnWorkspaces().some((ws) => ws.name === target);
3038
- }
3039
- var retest = ({ target } = {}) => {
3040
- if (target && isWorkspace(target)) {
3041
- return runSteps(`Re-Test [${target}]`, [
3042
- ["yarn", ["workspace", target, "run", "vitest", "--clearCache"]],
3043
- ["yarn", ["workspace", target, "run", "vitest", "."]]
3044
- ]);
3045
- }
3046
- const path8 = target ?? ".";
3047
- return runSteps("Re-Test", [
3048
- ["yarn", ["vitest", "--clearCache"]],
3049
- ["yarn", ["vitest", path8]]
3050
- ]);
3051
- };
3052
-
3053
- // src/actions/sonar.ts
3054
- var sonar = () => {
3055
- return runSteps("Sonar", [["yarn", ["eslint", "-c", "sonar.eslintrc", "."]]]);
3056
- };
3057
-
3058
- // src/actions/statics.ts
3059
- import chalk35 from "chalk";
3060
- var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
3061
- var statics = () => {
3062
- console.log(chalk35.green("Check Required Static Dependencies"));
3063
- const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
3064
- return detectDuplicateDependencies(statics2, DefaultDependencies);
3065
- };
3066
-
3067
- // src/actions/test.ts
3068
- function isWorkspace2(target) {
3069
- return yarnWorkspaces().some((ws) => ws.name === target);
3070
- }
3071
- var test = ({ target } = {}) => {
3072
- if (target && isWorkspace2(target)) {
3073
- return runSteps(`Test [${target}]`, [["yarn", ["workspace", target, "run", "vitest", "."]]]);
3074
- }
3075
- const path8 = target ?? ".";
3076
- return runSteps("Test", [["yarn", ["vitest", path8]]]);
162
+ return result || runSteps6("Reinstall", [["yarn", "install --network-timeout 10000"]]);
3077
163
  };
3078
164
 
3079
165
  // src/actions/up.ts
166
+ import { runSteps as runSteps7 } from "@xylabs/ts-scripts-common";
3080
167
  var up = () => {
3081
- return runSteps("Up", [["yarn", "outdated"]]);
168
+ return runSteps7("Up", [["yarn", "outdated"]]);
3082
169
  };
3083
170
 
3084
171
  // src/actions/updo.ts
172
+ import { runSteps as runSteps8 } from "@xylabs/ts-scripts-common";
3085
173
  var updo = () => {
3086
- return runSteps("Updo", [
174
+ return runSteps8("Updo", [
3087
175
  ["yarn", "install"],
3088
176
  ["yarn", "upgrade-interactive"],
3089
177
  ["yarn", "dedupe"]
@@ -3091,8 +179,9 @@ var updo = () => {
3091
179
  };
3092
180
 
3093
181
  // src/actions/upplug.ts
182
+ import { runSteps as runSteps9 } from "@xylabs/ts-scripts-common";
3094
183
  var updateYarnPlugins = () => {
3095
- return runSteps("Update Yarn Plugins", [
184
+ return runSteps9("Update Yarn Plugins", [
3096
185
  ["yarn", ["plugin", "import", "https://mskelton.dev/yarn-outdated/v3"]],
3097
186
  ["yarn", ["plugin", "import", "version"]],
3098
187
  ["yarn", ["plugin", "import", "interactive-tools"]],
@@ -3101,11 +190,13 @@ var updateYarnPlugins = () => {
3101
190
  };
3102
191
 
3103
192
  // src/actions/upyarn.ts
193
+ import { runSteps as runSteps10 } from "@xylabs/ts-scripts-common";
3104
194
  var updateYarnVersion = () => {
3105
- return runSteps("Update Yarn Version", [["yarn", ["set", "version", "latest"]]]);
195
+ return runSteps10("Update Yarn Version", [["yarn", ["set", "version", "latest"]]]);
3106
196
  };
3107
197
 
3108
198
  // src/actions/yarn3only.ts
199
+ import { processEx } from "@xylabs/ts-scripts-common";
3109
200
  var yarn3Only = () => {
3110
201
  const [valid, version] = isYarnVersionOrGreater(3);
3111
202
  if (!valid) {
@@ -3114,415 +205,12 @@ var yarn3Only = () => {
3114
205
  return 0;
3115
206
  };
3116
207
 
3117
- // src/xy/build/buildCommand.ts
3118
- var buildCommand = {
3119
- command: "build [package]",
3120
- describe: "Build - Compile & Lint",
3121
- builder: (yargs2) => {
3122
- return yargs2.positional("package", { describe: "Specific package to build" });
3123
- },
3124
- handler: async (argv) => {
3125
- if (argv.verbose) {
3126
- console.log(`Building: ${argv.package ?? "all"}`);
3127
- }
3128
- process.exitCode = await build({
3129
- incremental: !!argv.incremental,
3130
- jobs: argv.jobs,
3131
- pkg: argv.package,
3132
- target: argv.target,
3133
- verbose: !!argv.verbose
3134
- });
3135
- }
3136
- };
3137
-
3138
- // src/xy/build/compileCommand.ts
3139
- var compileCommand = {
3140
- command: "compile [package]",
3141
- describe: "Compile with Typescript & Copy Images",
3142
- builder: (yargs2) => {
3143
- return yargs2.positional("package", { describe: "Specific package to compile" });
3144
- },
3145
- handler: (argv) => {
3146
- if (argv.verbose) {
3147
- console.log(`Compiling: ${argv.package ?? "all"}`);
3148
- }
3149
- process.exitCode = compile({
3150
- incremental: !!argv.incremental,
3151
- jobs: argv.jobs,
3152
- pkg: argv.package,
3153
- target: argv.target,
3154
- verbose: !!argv.verbose
3155
- });
3156
- }
3157
- };
3158
-
3159
- // src/xy/build/compileOnlyCommand.ts
3160
- var compileOnlyCommand = {
3161
- command: "compile-only [package]",
3162
- describe: "Compile with Typescript & Copy Images (No Publint)",
3163
- builder: (yargs2) => {
3164
- return yargs2.positional("package", { describe: "Specific package to compile" });
3165
- },
3166
- handler: (argv) => {
3167
- if (argv.verbose) {
3168
- console.log(`Compiling: ${argv.package ?? "all"}`);
3169
- }
3170
- process.exitCode = compile({
3171
- incremental: !!argv.incremental,
3172
- jobs: argv.jobs,
3173
- pkg: argv.package,
3174
- publint: false,
3175
- target: argv.target,
3176
- verbose: !!argv.verbose
3177
- });
3178
- }
3179
- };
3180
-
3181
- // src/xy/build/copyAssetsCommand.ts
3182
- var copyAssetsCommand = {
3183
- command: "copy-assets [package]",
3184
- describe: "Copy Assets - Copy the assets from src to dist",
3185
- builder: (yargs2) => {
3186
- return yargs2.positional("package", { describe: "Specific package to copy assets" });
3187
- },
3188
- handler: async (argv) => {
3189
- if (argv.verbose) console.log(`Copying Assets: ${argv.package ?? "all"}`);
3190
- process.exitCode = await copyAssets({ target: argv.target });
3191
- }
3192
- };
3193
-
3194
- // src/xy/build/rebuildCommand.ts
3195
- var rebuildCommand = {
3196
- command: "rebuild [package]",
3197
- describe: "Rebuild - Clean, Compile & Lint",
3198
- builder: (yargs2) => {
3199
- return yargs2.positional("package", { describe: "Specific package to rebuild" });
3200
- },
3201
- handler: (argv) => {
3202
- if (argv.verbose) console.log(`Rebuilding: ${argv.package ?? "all"}`);
3203
- process.exitCode = rebuild({ target: argv.target });
3204
- }
3205
- };
3206
-
3207
- // src/xy/build/recompileCommand.ts
3208
- var recompileCommand = {
3209
- command: "recompile [package]",
3210
- describe: "Re-compile with Typescript & Copy Images",
3211
- builder: (yargs2) => {
3212
- return yargs2.positional("package", { describe: "Specific package to re-compile" });
3213
- },
3214
- handler: async (argv) => {
3215
- if (argv.verbose) {
3216
- console.log(`Re-compiling: ${argv.package ?? "all"}`);
3217
- }
3218
- process.exitCode = await recompile({
3219
- incremental: !!argv.incremental,
3220
- jobs: argv.jobs,
3221
- pkg: argv.package,
3222
- target: argv.target,
3223
- verbose: !!argv.verbose
3224
- });
3225
- }
3226
- };
3227
-
3228
- // src/xy/build/index.ts
3229
- var xyBuildCommands = (args) => {
3230
- return args.command(buildCommand).command(compileCommand).command(compileOnlyCommand).command(recompileCommand).command(rebuildCommand).command(copyAssetsCommand);
3231
- };
3232
-
3233
- // src/xy/common/claude/cleanCommand.ts
3234
- var cleanCommand = {
3235
- command: "clean",
3236
- describe: "Remove all Claude configuration files from the repo",
3237
- handler: (argv) => {
3238
- if (argv.verbose) console.log("Claude Clean");
3239
- process.exitCode = claudeClean();
3240
- }
3241
- };
3242
-
3243
- // src/xy/common/claude/commandsCommand.ts
3244
- var commandsCommand = {
3245
- command: "commands",
3246
- describe: "Sync XY Labs standard Claude slash commands to .claude/commands/",
3247
- handler: (argv) => {
3248
- if (argv.verbose) console.log("Claude Commands");
3249
- process.exitCode = claudeCommands();
3250
- }
3251
- };
3252
-
3253
- // src/xy/common/claude/initCommand.ts
3254
- var initCommand = {
3255
- builder: (yargs2) => {
3256
- return yargs2.option("force", {
3257
- alias: "f",
3258
- default: false,
3259
- description: "Overwrite existing CLAUDE.md",
3260
- type: "boolean"
3261
- });
3262
- },
3263
- command: "init",
3264
- describe: "Initialize all Claude configuration (commands, rules, settings)",
3265
- handler: async (argv) => {
3266
- if (argv.verbose) console.log("Claude Init");
3267
- const commandsResult = claudeCommands();
3268
- const rulesResult = claudeRules({ force: argv.force });
3269
- const settingsResult = await claudeSettings();
3270
- process.exitCode = commandsResult || rulesResult || settingsResult;
3271
- }
3272
- };
3273
-
3274
- // src/xy/common/claude/rulesCommand.ts
3275
- var rulesCommand = {
3276
- builder: (yargs2) => {
3277
- return yargs2.option("force", {
3278
- alias: "f",
3279
- default: false,
3280
- description: "Overwrite existing CLAUDE.md",
3281
- type: "boolean"
3282
- });
3283
- },
3284
- command: "rules",
3285
- describe: "Sync XY Labs standard Claude rules to .claude/rules/",
3286
- handler: (argv) => {
3287
- if (argv.verbose) console.log("Claude Rules");
3288
- process.exitCode = claudeRules({ force: argv.force });
3289
- }
3290
- };
3291
-
3292
- // src/xy/common/claude/settingsCommand.ts
3293
- var settingsCommand = {
3294
- command: "settings",
3295
- describe: "Initialize .claude/settings.local.json with XY Labs defaults",
3296
- handler: async (argv) => {
3297
- if (argv.verbose) console.log("Claude Settings");
3298
- process.exitCode = await claudeSettings();
3299
- }
3300
- };
3301
-
3302
- // src/xy/common/claude/skillsCommand.ts
3303
- var skillsCommand = {
3304
- builder: (yargs2) => yargs2,
3305
- command: "skills",
3306
- describe: "Sync XY Labs standard Claude skills to .claude/skills/",
3307
- handler: (argv) => {
3308
- if (argv.verbose) console.log("Claude Skills");
3309
- process.exitCode = claudeSkills();
3310
- }
3311
- };
3312
-
3313
- // src/xy/common/claude/index.ts
3314
- var claudeCommand = {
3315
- builder: (yargs2) => {
3316
- return yargs2.command(cleanCommand).command(commandsCommand).command(initCommand).command(rulesCommand).command(settingsCommand).command(skillsCommand).demandCommand(1, "Please specify a claude subcommand");
3317
- },
3318
- command: "claude",
3319
- describe: "Claude - Claude Code configuration utilities",
3320
- handler: () => {
3321
- }
3322
- };
3323
-
3324
- // src/xy/common/cleanDocsCommand.ts
3325
- var cleanDocsCommand = {
3326
- command: "clean-docs",
3327
- describe: "CleanDocs - Clean TypeDocs",
3328
- handler: (argv) => {
3329
- if (argv.verbose) console.log("Cleaning TypeDocs: all");
3330
- process.exitCode = cleanDocs();
3331
- }
3332
- };
3333
-
3334
- // src/xy/param.ts
3335
- var packagePositionalParam = (yargs2) => {
3336
- return yargs2.positional("package", { describe: "Specific package to target", type: "string" });
3337
- };
3338
-
3339
- // src/xy/common/deadCommand.ts
3340
- var deadCommand = {
3341
- builder: (yargs2) => {
3342
- return packagePositionalParam(yargs2);
3343
- },
3344
- command: "dead [package]",
3345
- describe: "Dead - Check for dead code",
3346
- handler: (argv) => {
3347
- if (argv.verbose) console.log("Dead");
3348
- process.exitCode = dead();
3349
- }
3350
- };
3351
-
3352
- // src/xy/common/genDocsCommand.ts
3353
- var genDocsCommand = {
3354
- builder: (yargs2) => {
3355
- return packagePositionalParam(yargs2);
3356
- },
3357
- command: "gen-docs [package]",
3358
- describe: "GenDocs - Generate TypeDocs",
3359
- handler: (argv) => {
3360
- if (argv.verbose) console.log(`Generating TypeDocs: ${argv.package ?? "all"}`);
3361
- process.exitCode = genDocs({ incremental: !!argv.incremental, pkg: argv.package });
3362
- }
3363
- };
3364
-
3365
- // src/xy/common/gitignoreCommand.ts
3366
- var gitignoreCommand = {
3367
- command: "gitignore",
3368
- describe: "GitIgnore - Generate root .gitignore and remove package .gitignore files",
3369
- handler: (argv) => {
3370
- if (argv.verbose) console.log("GitIgnore");
3371
- process.exitCode = gitignore();
3372
- }
3373
- };
3374
-
3375
- // src/xy/common/gitlintCommand.ts
3376
- var gitlintCommand = {
3377
- command: "gitlint [package]",
3378
- describe: "Gitlint - Lint your git config",
3379
- handler: (argv) => {
3380
- if (argv.verbose) console.log("Gitlint");
3381
- process.exitCode = argv.fix ? gitlintFix() : gitlint();
3382
- }
3383
- };
3384
-
3385
- // src/xy/common/licenseCommand.ts
3386
- var licenseCommand = {
3387
- builder: (yargs2) => {
3388
- return packagePositionalParam(yargs2);
3389
- },
3390
- command: "license [package]",
3391
- describe: "License - Check licenses of dependencies",
3392
- handler: async (argv) => {
3393
- if (argv.verbose) console.log(`License: ${argv.package ?? "all"}`);
3394
- process.exitCode = await license();
3395
- }
3396
- };
3397
-
3398
- // src/xy/common/npmignoreGenCommand.ts
3399
- var npmignoreGenCommand = {
3400
- command: "npmignore-gen",
3401
- describe: "NpmIgnore Gen - Generate .npmignore files",
3402
- handler: (argv) => {
3403
- if (argv.verbose) console.log("NpmIgnore Gen");
3404
- process.exitCode = npmignoreGen();
3405
- }
3406
- };
3407
-
3408
- // src/xy/common/readme/genCommand.ts
3409
- var genCommand = {
3410
- builder: (yargs2) => {
3411
- return packagePositionalParam(yargs2).option("template", {
3412
- alias: "t",
3413
- description: "Path to README.template.md",
3414
- type: "string"
3415
- }).option("typedoc", {
3416
- default: false,
3417
- description: "Generate TypeDoc reference sections",
3418
- type: "boolean"
3419
- });
3420
- },
3421
- aliases: ["$0"],
3422
- command: "gen [package]",
3423
- describe: "Generate README.md files from template",
3424
- handler: async (argv) => {
3425
- if (argv.verbose) console.log("Readme Gen");
3426
- process.exitCode = await readmeGen({
3427
- pkg: argv.package,
3428
- templatePath: argv.template,
3429
- typedoc: argv.typedoc,
3430
- verbose: !!argv.verbose
3431
- });
3432
- }
3433
- };
3434
-
3435
- // src/xy/common/readme/initCommand.ts
3436
- var initCommand2 = {
3437
- builder: (yargs2) => {
3438
- return yargs2.option("template", {
3439
- alias: "t",
3440
- description: "Path to README.template.md",
3441
- type: "string"
3442
- });
3443
- },
3444
- command: "init",
3445
- describe: "Initialize README template and logo files",
3446
- handler: async (argv) => {
3447
- if (argv.verbose) console.log("Readme Init");
3448
- process.exitCode = await readmeInit({
3449
- templatePath: argv.template,
3450
- verbose: !!argv.verbose
3451
- });
3452
- }
3453
- };
3454
-
3455
- // src/xy/common/readme/index.ts
3456
- var readmeCommand = {
3457
- builder: (yargs2) => {
3458
- return yargs2.command(genCommand).command(initCommand2);
3459
- },
3460
- command: "readme",
3461
- describe: "Readme - README file utilities",
3462
- handler: () => {
3463
- }
3464
- };
3465
-
3466
- // src/xy/common/retestCommand.ts
3467
- var retestCommand = {
3468
- command: "retest [target]",
3469
- describe: "Re-Test - Run Vitest Tests with cleaned cache",
3470
- builder: (yargs2) => {
3471
- return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
3472
- },
3473
- handler: (argv) => {
3474
- if (argv.verbose) console.log(`Re-Testing: ${argv.target ?? "all"}`);
3475
- process.exitCode = retest({ target: argv.target });
3476
- }
3477
- };
3478
-
3479
- // src/xy/common/testCommand.ts
3480
- var testCommand = {
3481
- command: "test [target]",
3482
- describe: "Test - Run Vitest Tests",
3483
- builder: (yargs2) => {
3484
- return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
3485
- },
3486
- handler: (argv) => {
3487
- if (argv.verbose) console.log(`Testing: ${argv.target ?? "all"}`);
3488
- process.exitCode = test({ target: argv.target });
3489
- }
3490
- };
3491
-
3492
- // src/xy/common/upplugCommand.ts
3493
- var upplugCommand = {
3494
- command: "upplug",
3495
- describe: "UpPlug - Update Yarn Plugins",
3496
- handler: (argv) => {
3497
- if (argv.verbose) console.log("UpPlug");
3498
- process.exitCode = updateYarnPlugins();
3499
- }
3500
- };
3501
-
3502
- // src/xy/common/upyarnCommand.ts
3503
- var upyarnCommand = {
3504
- command: "upyarn",
3505
- describe: "UpYarn - Update Yarn Version",
3506
- handler: (argv) => {
3507
- if (argv.verbose) console.log("UpYarn");
3508
- process.exitCode = updateYarnVersion();
3509
- }
3510
- };
3511
-
3512
- // src/xy/common/yarn3OnlyCommand.ts
3513
- var yarn3OnlyCommand = {
3514
- command: "yarn3only",
3515
- describe: "Yarn3Only - Check if using Yarn v3",
3516
- handler: (argv) => {
3517
- if (argv.verbose) console.log("Yarn 3 Check");
3518
- process.exitCode = yarn3Only();
3519
- }
3520
- };
3521
-
3522
- // src/xy/common/index.ts
3523
- var xyCommonCommands = (args) => {
3524
- 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);
3525
- };
208
+ // src/actions/index.ts
209
+ import {
210
+ clean,
211
+ dupdeps,
212
+ statics
213
+ } from "@xylabs/ts-scripts-common";
3526
214
 
3527
215
  // src/xy/deploy/deployCommand.ts
3528
216
  var deployCommand = {
@@ -3580,11 +268,11 @@ var xyDeployCommands = (args) => {
3580
268
  };
3581
269
 
3582
270
  // src/xy/install/cleanCommand.ts
3583
- var cleanCommand2 = {
271
+ var cleanCommand = {
3584
272
  command: "clean [package]",
3585
273
  describe: "Clean",
3586
- builder: (yargs2) => {
3587
- return yargs2.positional("package", { describe: "Specific package to clean" });
274
+ builder: (yargs) => {
275
+ return yargs.positional("package", { describe: "Specific package to clean" });
3588
276
  },
3589
277
  handler: async (argv) => {
3590
278
  if (argv.verbose) {
@@ -3649,266 +337,47 @@ var updoCommand = {
3649
337
 
3650
338
  // src/xy/install/index.ts
3651
339
  var xyInstallCommands = (args) => {
3652
- return args.command(cleanCommand2).command(reinstallCommand).command(upCommand).command(updoCommand).command(staticsCommand).command(dupdepsCommand);
3653
- };
3654
-
3655
- // src/xy/lint/cycleCommand.ts
3656
- import chalk36 from "chalk";
3657
- var cycleCommand = {
3658
- command: "cycle [package]",
3659
- describe: "Cycle - Check for dependency cycles",
3660
- builder: (yargs2) => {
3661
- return packagePositionalParam(yargs2);
3662
- },
3663
- handler: async (argv) => {
3664
- const start = Date.now();
3665
- if (argv.verbose) console.log("Cycle");
3666
- process.exitCode = await cycle({ pkg: argv.package });
3667
- console.log(chalk36.blue(`Finished in ${Date.now() - start}ms`));
3668
- }
3669
- };
3670
-
3671
- // src/xy/lint/deplintCommand.ts
3672
- import chalk37 from "chalk";
3673
- var deplintCommand = {
3674
- command: "deplint [package]",
3675
- describe: "Deplint - Run Deplint",
3676
- builder: (yargs2) => {
3677
- return packagePositionalParam(yargs2).option("deps", {
3678
- alias: "d",
3679
- default: false,
3680
- description: "Check dependencies",
3681
- type: "boolean"
3682
- }).option("devDeps", {
3683
- alias: "v",
3684
- default: false,
3685
- description: "Check devDependencies",
3686
- type: "boolean"
3687
- }).option("peerDeps", {
3688
- alias: "p",
3689
- default: false,
3690
- description: "Check peerDependencies",
3691
- type: "boolean"
3692
- }).option("exclude", {
3693
- alias: "e",
3694
- description: "Package names to exclude from unused checks (comma-separated or repeated)",
3695
- type: "array"
3696
- });
3697
- },
3698
- handler: async (argv) => {
3699
- if (argv.verbose) console.log("Deplint");
3700
- const start = Date.now();
3701
- const cliExclude = argv.exclude?.flatMap((v) => String(v).split(",")).map((v) => v.trim()).filter(Boolean);
3702
- process.exitCode = await deplint({
3703
- cliExclude,
3704
- pkg: argv.package,
3705
- deps: !!argv.deps,
3706
- devDeps: !!argv.devDeps,
3707
- peerDeps: !!argv.peerDeps,
3708
- verbose: !!argv.verbose
3709
- });
3710
- console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
3711
- }
3712
- };
3713
-
3714
- // src/xy/lint/fixCommand.ts
3715
- import chalk38 from "chalk";
3716
- var fixCommand = {
3717
- command: "fix [package]",
3718
- describe: "Fix - Run Eslint w/fix",
3719
- builder: (yargs2) => {
3720
- return packagePositionalParam(yargs2);
3721
- },
3722
- handler: (argv) => {
3723
- const start = Date.now();
3724
- if (argv.verbose) console.log("Fix");
3725
- process.exitCode = fix();
3726
- console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
3727
- }
3728
- };
3729
-
3730
- // src/xy/lint/knipCommand.ts
3731
- import chalk39 from "chalk";
3732
- var knipCommand = {
3733
- command: "knip",
3734
- describe: "Knip - Run Knip",
3735
- builder: (yargs2) => {
3736
- return packagePositionalParam(yargs2);
3737
- },
3738
- handler: (argv) => {
3739
- if (argv.verbose) console.log("Knip");
3740
- const start = Date.now();
3741
- process.exitCode = knip();
3742
- console.log(chalk39.blue(`Knip finished in ${Date.now() - start}ms`));
3743
- }
3744
- };
3745
-
3746
- // src/xy/lint/lintCommand.ts
3747
- import chalk40 from "chalk";
3748
- var lintCommand = {
3749
- command: "lint [package]",
3750
- describe: "Lint - Run Eslint",
3751
- builder: (yargs2) => {
3752
- return packagePositionalParam(yargs2).option("fix", {
3753
- alias: "f",
3754
- default: false,
3755
- description: "Fix fixable issues",
3756
- type: "boolean"
3757
- }).option("cache", {
3758
- alias: "c",
3759
- default: false,
3760
- description: "Use caching for performance",
3761
- type: "boolean"
3762
- });
3763
- },
3764
- handler: (argv) => {
3765
- if (argv.verbose) console.log("Lint");
3766
- const start = Date.now();
3767
- process.exitCode = argv.fix ? fix({
3768
- pkg: argv.package,
3769
- cache: argv.cache,
3770
- verbose: !!argv.verbose
3771
- }) : lint({
3772
- pkg: argv.package,
3773
- cache: argv.cache,
3774
- verbose: !!argv.verbose
3775
- });
3776
- console.log(chalk40.blue(`Finished in ${Date.now() - start}ms`));
3777
- }
3778
- };
3779
-
3780
- // src/xy/lint/lintlintCommand.ts
3781
- var lintlintCommand = {
3782
- command: "lintlint",
3783
- describe: "Lint Lint - Check for redundant or overridden ESLint rules vs shared config",
3784
- builder: (yargs2) => {
3785
- return yargs2.option("fix", {
3786
- default: false,
3787
- description: "Remove redundant rules from local config",
3788
- type: "boolean"
3789
- });
3790
- },
3791
- handler: async (argv) => {
3792
- if (argv.verbose) console.log("Lint Lint");
3793
- process.exitCode = await lintlint({
3794
- fix: argv.fix,
3795
- verbose: !!argv.verbose
3796
- });
3797
- }
340
+ return args.command(cleanCommand).command(reinstallCommand).command(upCommand).command(updoCommand).command(staticsCommand).command(dupdepsCommand);
3798
341
  };
3799
342
 
3800
- // src/xy/lint/packageLintCommand.ts
3801
- var packageLintCommand = {
3802
- builder: (yargs2) => {
3803
- return yargs2.option("fix", {
3804
- default: false,
3805
- description: "Auto-fix fixable issues",
3806
- type: "boolean"
3807
- });
3808
- },
3809
- command: "package-lint",
3810
- 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",
3811
347
  handler: (argv) => {
3812
- if (argv.verbose) console.log("Package Lint");
3813
- process.exitCode = packageLintMonorepo(!!argv.fix);
3814
- }
3815
- };
3816
-
3817
- // src/xy/lint/publintCommand.ts
3818
- import chalk41 from "chalk";
3819
- var publintCommand = {
3820
- command: "publint [package]",
3821
- describe: "Publint - Run Publint",
3822
- builder: (yargs2) => {
3823
- return packagePositionalParam(yargs2);
3824
- },
3825
- handler: async (argv) => {
3826
- if (argv.verbose) console.log("Publint");
3827
- const start = Date.now();
3828
- process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
3829
- console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
348
+ if (argv.verbose) console.log("UpPlug");
349
+ process.exitCode = updateYarnPlugins();
3830
350
  }
3831
351
  };
3832
352
 
3833
- // src/xy/lint/relintCommand.ts
3834
- import chalk42 from "chalk";
3835
- var relintCommand = {
3836
- command: "relint [package]",
3837
- describe: "Relint - Clean & Lint",
3838
- builder: (yargs2) => {
3839
- return packagePositionalParam(yargs2);
3840
- },
353
+ // src/xy/common/upyarnCommand.ts
354
+ var upyarnCommand = {
355
+ command: "upyarn",
356
+ describe: "UpYarn - Update Yarn Version",
3841
357
  handler: (argv) => {
3842
- if (argv.verbose) console.log("Relinting");
3843
- const start = Date.now();
3844
- process.exitCode = relint();
3845
- console.log(chalk42.blue(`Finished in ${Date.now() - start}ms`));
358
+ if (argv.verbose) console.log("UpYarn");
359
+ process.exitCode = updateYarnVersion();
3846
360
  }
3847
361
  };
3848
362
 
3849
- // src/xy/lint/sonarCommand.ts
3850
- import chalk43 from "chalk";
3851
- var sonarCommand = {
3852
- command: "sonar",
3853
- describe: "Sonar - Run Sonar Check",
3854
- builder: (yargs2) => {
3855
- return packagePositionalParam(yargs2);
3856
- },
363
+ // src/xy/common/yarn3OnlyCommand.ts
364
+ var yarn3OnlyCommand = {
365
+ command: "yarn3only",
366
+ describe: "Yarn3Only - Check if using Yarn v3",
3857
367
  handler: (argv) => {
3858
- const start = Date.now();
3859
- if (argv.verbose) console.log("Sonar Check");
3860
- process.exitCode = sonar();
3861
- console.log(chalk43.blue(`Finished in ${Date.now() - start}ms`));
368
+ if (argv.verbose) console.log("Yarn 3 Check");
369
+ process.exitCode = yarn3Only();
3862
370
  }
3863
371
  };
3864
372
 
3865
- // src/xy/lint/index.ts
3866
- var xyLintCommands = (args) => {
3867
- return args.command(cycleCommand).command(lintCommand).command(lintlintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(packageLintCommand).command(sonarCommand);
3868
- };
3869
-
3870
- // src/xy/xyParseOptions.ts
3871
- import yargs from "yargs";
3872
- import { hideBin } from "yargs/helpers";
3873
- var xyParseOptions = () => {
3874
- return yargs(hideBin(process.argv)).scriptName("yarn xy").middleware((argv) => {
3875
- const commandName = argv._[0];
3876
- if (commandName && argv._.length <= 1) {
3877
- const result = tryRunLocalScript(commandName);
3878
- if (result !== void 0) {
3879
- process.exit(result);
3880
- }
3881
- }
3882
- }, true).option("jobs", {
3883
- alias: "j",
3884
- default: void 0,
3885
- description: "Max parallel jobs",
3886
- type: "number"
3887
- }).option("verbose", {
3888
- alias: "v",
3889
- default: false,
3890
- description: "Run with verbose logging",
3891
- type: "boolean"
3892
- }).option("incremental", {
3893
- alias: "i",
3894
- default: false,
3895
- description: "Attempt to perform the action only on changed packages",
3896
- type: "boolean"
3897
- }).option("profile", {
3898
- alias: "p",
3899
- default: false,
3900
- description: "Profile action",
3901
- type: "boolean"
3902
- });
373
+ // src/xy/yarnCommands.ts
374
+ var xyYarnCommands = (args) => {
375
+ return args.command(upplugCommand).command(upyarnCommand).command(yarn3OnlyCommand);
3903
376
  };
3904
377
 
3905
378
  // src/xy/xy.ts
3906
379
  var xy = async () => {
3907
- const options = xyParseOptions();
3908
- return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
3909
- console.error(chalk44.yellow(`Command not found [${chalk44.magenta(process.argv[2])}]`));
3910
- console.log(chalk44.gray("Try 'yarn xy --help' for list of commands"));
3911
- }).version().help().argv;
380
+ return await xyBase((args) => xyYarnCommands(xyInstallCommands(xyDeployCommands(args))));
3912
381
  };
3913
382
  export {
3914
383
  xy