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