@xylabs/toolchain 7.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (622) hide show
  1. package/dist/actions/analyze.mjs +140 -0
  2. package/dist/actions/analyze.mjs.map +1 -0
  3. package/dist/actions/build.mjs +173 -0
  4. package/dist/actions/build.mjs.map +1 -0
  5. package/dist/actions/claude-check.mjs +199 -0
  6. package/dist/actions/claude-check.mjs.map +1 -0
  7. package/dist/actions/claude-clean.mjs +70 -0
  8. package/dist/actions/claude-clean.mjs.map +1 -0
  9. package/dist/actions/claude-commands.mjs +126 -0
  10. package/dist/actions/claude-commands.mjs.map +1 -0
  11. package/dist/actions/claude-rules.mjs +151 -0
  12. package/dist/actions/claude-rules.mjs.map +1 -0
  13. package/dist/actions/claude-settings.mjs +99 -0
  14. package/dist/actions/claude-settings.mjs.map +1 -0
  15. package/dist/actions/claude-skills.mjs +131 -0
  16. package/dist/actions/claude-skills.mjs.map +1 -0
  17. package/dist/actions/clean-docs.mjs +66 -0
  18. package/dist/actions/clean-docs.mjs.map +1 -0
  19. package/dist/actions/clean-eslint.mjs +47 -0
  20. package/dist/actions/clean-eslint.mjs.map +1 -0
  21. package/dist/actions/clean.mjs +166 -0
  22. package/dist/actions/clean.mjs.map +1 -0
  23. package/dist/actions/compile.mjs +184 -0
  24. package/dist/actions/compile.mjs.map +1 -0
  25. package/dist/actions/copy-assets.mjs +81 -0
  26. package/dist/actions/copy-assets.mjs.map +1 -0
  27. package/dist/actions/cycle.mjs +275 -0
  28. package/dist/actions/cycle.mjs.map +1 -0
  29. package/dist/actions/dead.mjs +119 -0
  30. package/dist/actions/dead.mjs.map +1 -0
  31. package/dist/actions/deplint/checkPackage/checkPackage.mjs +1556 -0
  32. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -0
  33. package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs +1 -0
  34. package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs.map +1 -0
  35. package/dist/actions/deplint/checkPackage/getMismatchedPeerDevVersions.mjs +77 -0
  36. package/dist/actions/deplint/checkPackage/getMismatchedPeerDevVersions.mjs.map +1 -0
  37. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +158 -0
  38. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -0
  39. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +125 -0
  40. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -0
  41. package/dist/actions/deplint/checkPackage/getUnnecessaryPeerDependencies.mjs +207 -0
  42. package/dist/actions/deplint/checkPackage/getUnnecessaryPeerDependencies.mjs.map +1 -0
  43. package/dist/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.mjs +318 -0
  44. package/dist/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.mjs.map +1 -0
  45. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +163 -0
  46. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -0
  47. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +408 -0
  48. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
  49. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +75 -0
  50. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -0
  51. package/dist/actions/deplint/checkPackage/getWorkspaceVersionProblems.mjs +128 -0
  52. package/dist/actions/deplint/checkPackage/getWorkspaceVersionProblems.mjs.map +1 -0
  53. package/dist/actions/deplint/checkPackage/index.mjs +1609 -0
  54. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -0
  55. package/dist/actions/deplint/deplint.mjs +1840 -0
  56. package/dist/actions/deplint/deplint.mjs.map +1 -0
  57. package/dist/actions/deplint/engine.mjs +1736 -0
  58. package/dist/actions/deplint/engine.mjs.map +1 -0
  59. package/dist/actions/deplint/findFiles.mjs +39 -0
  60. package/dist/actions/deplint/findFiles.mjs.map +1 -0
  61. package/dist/actions/deplint/findFilesByGlob.mjs +14 -0
  62. package/dist/actions/deplint/findFilesByGlob.mjs.map +1 -0
  63. package/dist/actions/deplint/fixer.mjs +103 -0
  64. package/dist/actions/deplint/fixer.mjs.map +1 -0
  65. package/dist/actions/deplint/getBasePackageName.mjs +13 -0
  66. package/dist/actions/deplint/getBasePackageName.mjs.map +1 -0
  67. package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs +140 -0
  68. package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs.map +1 -0
  69. package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +29 -0
  70. package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +1 -0
  71. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +68 -0
  72. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +1 -0
  73. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +143 -0
  74. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -0
  75. package/dist/actions/deplint/getImportsFromFile.mjs +85 -0
  76. package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -0
  77. package/dist/actions/deplint/getRequiredPeerDependencies.mjs +37 -0
  78. package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +1 -0
  79. package/dist/actions/deplint/getScriptReferencedPackages.mjs +83 -0
  80. package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -0
  81. package/dist/actions/deplint/implicitDevDependencies.mjs +116 -0
  82. package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
  83. package/dist/actions/deplint/index.mjs +1848 -0
  84. package/dist/actions/deplint/index.mjs.map +1 -0
  85. package/dist/actions/deplint/packageEditor.mjs +82 -0
  86. package/dist/actions/deplint/packageEditor.mjs.map +1 -0
  87. package/dist/actions/deplint/packageJsonEditor.mjs +101 -0
  88. package/dist/actions/deplint/packageJsonEditor.mjs.map +1 -0
  89. package/dist/actions/deplint/reporters.mjs +36 -0
  90. package/dist/actions/deplint/reporters.mjs.map +1 -0
  91. package/dist/actions/deplint/rules.mjs +1223 -0
  92. package/dist/actions/deplint/rules.mjs.map +1 -0
  93. package/dist/actions/deplint/snapshot.mjs +372 -0
  94. package/dist/actions/deplint/snapshot.mjs.map +1 -0
  95. package/dist/actions/deplint/tsScriptsAliases.mjs +20 -0
  96. package/dist/actions/deplint/tsScriptsAliases.mjs.map +1 -0
  97. package/dist/actions/deplint/types.mjs +1 -0
  98. package/dist/actions/deplint/types.mjs.map +1 -0
  99. package/dist/actions/deploy.mjs +194 -0
  100. package/dist/actions/deploy.mjs.map +1 -0
  101. package/dist/actions/dupdeps.mjs +226 -0
  102. package/dist/actions/dupdeps.mjs.map +1 -0
  103. package/dist/actions/eject.mjs +142 -0
  104. package/dist/actions/eject.mjs.map +1 -0
  105. package/dist/actions/fix.mjs +359 -0
  106. package/dist/actions/fix.mjs.map +1 -0
  107. package/dist/actions/gen-docs.mjs +155 -0
  108. package/dist/actions/gen-docs.mjs.map +1 -0
  109. package/dist/actions/gitignore.mjs +159 -0
  110. package/dist/actions/gitignore.mjs.map +1 -0
  111. package/dist/actions/gitlint-fix.mjs +27 -0
  112. package/dist/actions/gitlint-fix.mjs.map +1 -0
  113. package/dist/actions/gitlint.mjs +48 -0
  114. package/dist/actions/gitlint.mjs.map +1 -0
  115. package/dist/actions/index.mjs +8259 -0
  116. package/dist/actions/index.mjs.map +1 -0
  117. package/dist/actions/knip.mjs +119 -0
  118. package/dist/actions/knip.mjs.map +1 -0
  119. package/dist/actions/license.mjs +92 -0
  120. package/dist/actions/license.mjs.map +1 -0
  121. package/dist/actions/lint-init.mjs +275 -0
  122. package/dist/actions/lint-init.mjs.map +1 -0
  123. package/dist/actions/lint.mjs +356 -0
  124. package/dist/actions/lint.mjs.map +1 -0
  125. package/dist/actions/lintNext.mjs +209 -0
  126. package/dist/actions/lintNext.mjs.map +1 -0
  127. package/dist/actions/lintlint.mjs +341 -0
  128. package/dist/actions/lintlint.mjs.map +1 -0
  129. package/dist/actions/npmignore-gen.mjs +90 -0
  130. package/dist/actions/npmignore-gen.mjs.map +1 -0
  131. package/dist/actions/orphan.mjs +110 -0
  132. package/dist/actions/orphan.mjs.map +1 -0
  133. package/dist/actions/package/clean-outputs.mjs +50 -0
  134. package/dist/actions/package/clean-outputs.mjs.map +1 -0
  135. package/dist/actions/package/clean-typescript.mjs +50 -0
  136. package/dist/actions/package/clean-typescript.mjs.map +1 -0
  137. package/dist/actions/package/clean.mjs +69 -0
  138. package/dist/actions/package/clean.mjs.map +1 -0
  139. package/dist/actions/package/compile/XyConfig.mjs +32 -0
  140. package/dist/actions/package/compile/XyConfig.mjs.map +1 -0
  141. package/dist/actions/package/compile/buildEntries.mjs +53 -0
  142. package/dist/actions/package/compile/buildEntries.mjs.map +1 -0
  143. package/dist/actions/package/compile/compile.mjs +439 -0
  144. package/dist/actions/package/compile/compile.mjs.map +1 -0
  145. package/dist/actions/package/compile/copyTypeFiles.mjs +34 -0
  146. package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -0
  147. package/dist/actions/package/compile/deepMerge.mjs +27 -0
  148. package/dist/actions/package/compile/deepMerge.mjs.map +1 -0
  149. package/dist/actions/package/compile/getCompilerOptions.mjs +12 -0
  150. package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -0
  151. package/dist/actions/package/compile/index.mjs +472 -0
  152. package/dist/actions/package/compile/index.mjs.map +1 -0
  153. package/dist/actions/package/compile/inputs.mjs +22 -0
  154. package/dist/actions/package/compile/inputs.mjs.map +1 -0
  155. package/dist/actions/package/compile/packageCompileTsc.mjs +93 -0
  156. package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -0
  157. package/dist/actions/package/compile/packageCompileTscTypes.mjs +92 -0
  158. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -0
  159. package/dist/actions/package/compile/packageCompileTsup.mjs +402 -0
  160. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -0
  161. package/dist/actions/package/copy-assets.mjs +69 -0
  162. package/dist/actions/package/copy-assets.mjs.map +1 -0
  163. package/dist/actions/package/cycle.mjs +62 -0
  164. package/dist/actions/package/cycle.mjs.map +1 -0
  165. package/dist/actions/package/gen-docs.mjs +137 -0
  166. package/dist/actions/package/gen-docs.mjs.map +1 -0
  167. package/dist/actions/package/index.mjs +1131 -0
  168. package/dist/actions/package/index.mjs.map +1 -0
  169. package/dist/actions/package/lint.mjs +87 -0
  170. package/dist/actions/package/lint.mjs.map +1 -0
  171. package/dist/actions/package/publint.mjs +336 -0
  172. package/dist/actions/package/publint.mjs.map +1 -0
  173. package/dist/actions/package/recompile.mjs +510 -0
  174. package/dist/actions/package/recompile.mjs.map +1 -0
  175. package/dist/actions/package-lint-deps.mjs +348 -0
  176. package/dist/actions/package-lint-deps.mjs.map +1 -0
  177. package/dist/actions/package-lint.mjs +774 -0
  178. package/dist/actions/package-lint.mjs.map +1 -0
  179. package/dist/actions/packman/clean.mjs +144 -0
  180. package/dist/actions/packman/clean.mjs.map +1 -0
  181. package/dist/actions/packman/convert.mjs +1331 -0
  182. package/dist/actions/packman/convert.mjs.map +1 -0
  183. package/dist/actions/packman/convertToPnpm.mjs +295 -0
  184. package/dist/actions/packman/convertToPnpm.mjs.map +1 -0
  185. package/dist/actions/packman/convertToYarn.mjs +307 -0
  186. package/dist/actions/packman/convertToYarn.mjs.map +1 -0
  187. package/dist/actions/packman/index.mjs +1493 -0
  188. package/dist/actions/packman/index.mjs.map +1 -0
  189. package/dist/actions/packman/lint.mjs +109 -0
  190. package/dist/actions/packman/lint.mjs.map +1 -0
  191. package/dist/actions/packman/rewriteScripts.mjs +52 -0
  192. package/dist/actions/packman/rewriteScripts.mjs.map +1 -0
  193. package/dist/actions/packman/rewriteSourceImports.mjs +60 -0
  194. package/dist/actions/packman/rewriteSourceImports.mjs.map +1 -0
  195. package/dist/actions/packman/swapTsScriptsDependency.mjs +57 -0
  196. package/dist/actions/packman/swapTsScriptsDependency.mjs.map +1 -0
  197. package/dist/actions/publint.mjs +748 -0
  198. package/dist/actions/publint.mjs.map +1 -0
  199. package/dist/actions/publish.mjs +208 -0
  200. package/dist/actions/publish.mjs.map +1 -0
  201. package/dist/actions/reactTest.mjs +142 -0
  202. package/dist/actions/reactTest.mjs.map +1 -0
  203. package/dist/actions/readme-gen.mjs +362 -0
  204. package/dist/actions/readme-gen.mjs.map +1 -0
  205. package/dist/actions/readme-init.mjs +89 -0
  206. package/dist/actions/readme-init.mjs.map +1 -0
  207. package/dist/actions/readme-lint.mjs +147 -0
  208. package/dist/actions/readme-lint.mjs.map +1 -0
  209. package/dist/actions/rebuild.mjs +143 -0
  210. package/dist/actions/rebuild.mjs.map +1 -0
  211. package/dist/actions/recompile.mjs +196 -0
  212. package/dist/actions/recompile.mjs.map +1 -0
  213. package/dist/actions/reinstall.mjs +283 -0
  214. package/dist/actions/reinstall.mjs.map +1 -0
  215. package/dist/actions/relint.mjs +355 -0
  216. package/dist/actions/relint.mjs.map +1 -0
  217. package/dist/actions/repo-init.mjs +217 -0
  218. package/dist/actions/repo-init.mjs.map +1 -0
  219. package/dist/actions/retest.mjs +150 -0
  220. package/dist/actions/retest.mjs.map +1 -0
  221. package/dist/actions/sitemap.mjs +121 -0
  222. package/dist/actions/sitemap.mjs.map +1 -0
  223. package/dist/actions/sonar.mjs +119 -0
  224. package/dist/actions/sonar.mjs.map +1 -0
  225. package/dist/actions/start.mjs +142 -0
  226. package/dist/actions/start.mjs.map +1 -0
  227. package/dist/actions/statics.mjs +225 -0
  228. package/dist/actions/statics.mjs.map +1 -0
  229. package/dist/actions/test.mjs +144 -0
  230. package/dist/actions/test.mjs.map +1 -0
  231. package/dist/actions/up.mjs +140 -0
  232. package/dist/actions/up.mjs.map +1 -0
  233. package/dist/actions/updo.mjs +533 -0
  234. package/dist/actions/updo.mjs.map +1 -0
  235. package/dist/actions/upplug.mjs +124 -0
  236. package/dist/actions/upplug.mjs.map +1 -0
  237. package/dist/actions/upyarn.mjs +119 -0
  238. package/dist/actions/upyarn.mjs.map +1 -0
  239. package/dist/actions/yarn3only.mjs +60 -0
  240. package/dist/actions/yarn3only.mjs.map +1 -0
  241. package/dist/bin/package/build-only.mjs +451 -0
  242. package/dist/bin/package/build-only.mjs.map +1 -0
  243. package/dist/bin/package/build.mjs +451 -0
  244. package/dist/bin/package/build.mjs.map +1 -0
  245. package/dist/bin/package/clean-outputs.mjs +50 -0
  246. package/dist/bin/package/clean-outputs.mjs.map +1 -0
  247. package/dist/bin/package/clean-typescript.mjs +50 -0
  248. package/dist/bin/package/clean-typescript.mjs.map +1 -0
  249. package/dist/bin/package/clean.mjs +75 -0
  250. package/dist/bin/package/clean.mjs.map +1 -0
  251. package/dist/bin/package/compile-only.mjs +447 -0
  252. package/dist/bin/package/compile-only.mjs.map +1 -0
  253. package/dist/bin/package/compile-tsup.mjs +409 -0
  254. package/dist/bin/package/compile-tsup.mjs.map +1 -0
  255. package/dist/bin/package/compile.mjs +451 -0
  256. package/dist/bin/package/compile.mjs.map +1 -0
  257. package/dist/bin/package/copy-assets-cjs.mjs +75 -0
  258. package/dist/bin/package/copy-assets-cjs.mjs.map +1 -0
  259. package/dist/bin/package/copy-assets-esm.mjs +75 -0
  260. package/dist/bin/package/copy-assets-esm.mjs.map +1 -0
  261. package/dist/bin/package/cycle.mjs +72 -0
  262. package/dist/bin/package/cycle.mjs.map +1 -0
  263. package/dist/bin/package/fix.mjs +97 -0
  264. package/dist/bin/package/fix.mjs.map +1 -0
  265. package/dist/bin/package/gen-docs.mjs +142 -0
  266. package/dist/bin/package/gen-docs.mjs.map +1 -0
  267. package/dist/bin/package/lint-verbose.mjs +97 -0
  268. package/dist/bin/package/lint-verbose.mjs.map +1 -0
  269. package/dist/bin/package/lint.mjs +97 -0
  270. package/dist/bin/package/lint.mjs.map +1 -0
  271. package/dist/bin/package/publint.mjs +423 -0
  272. package/dist/bin/package/publint.mjs.map +1 -0
  273. package/dist/bin/package/recompile.mjs +516 -0
  274. package/dist/bin/package/recompile.mjs.map +1 -0
  275. package/dist/bin/package/relint.mjs +97 -0
  276. package/dist/bin/package/relint.mjs.map +1 -0
  277. package/dist/bin/run-or-exec.mjs +20 -0
  278. package/dist/bin/run-or-exec.mjs.map +1 -0
  279. package/dist/bin/xy.mjs +8885 -0
  280. package/dist/bin/xy.mjs.map +1 -0
  281. package/dist/index.d.ts +1102 -0
  282. package/dist/index.mjs +9986 -0
  283. package/dist/index.mjs.map +1 -0
  284. package/dist/lib/checkResult.mjs +16 -0
  285. package/dist/lib/checkResult.mjs.map +1 -0
  286. package/dist/lib/claudeMdTemplate.mjs +69 -0
  287. package/dist/lib/claudeMdTemplate.mjs.map +1 -0
  288. package/dist/lib/concurrency.mjs +38 -0
  289. package/dist/lib/concurrency.mjs.map +1 -0
  290. package/dist/lib/createBuildConfig.mjs +55 -0
  291. package/dist/lib/createBuildConfig.mjs.map +1 -0
  292. package/dist/lib/defaultBuildConfig.mjs +23 -0
  293. package/dist/lib/defaultBuildConfig.mjs.map +1 -0
  294. package/dist/lib/deleteGlob.mjs +13 -0
  295. package/dist/lib/deleteGlob.mjs.map +1 -0
  296. package/dist/lib/dependencies/DuplicateDetector.mjs +99 -0
  297. package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -0
  298. package/dist/lib/dependencies/detectDuplicateDependencies.mjs +203 -0
  299. package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -0
  300. package/dist/lib/dependencies/index.mjs +281 -0
  301. package/dist/lib/dependencies/index.mjs.map +1 -0
  302. package/dist/lib/dependencies/workspaceCycles.mjs +79 -0
  303. package/dist/lib/dependencies/workspaceCycles.mjs.map +1 -0
  304. package/dist/lib/file/ReadFileSyncOptions.mjs +6 -0
  305. package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -0
  306. package/dist/lib/file/constants.mjs +8 -0
  307. package/dist/lib/file/constants.mjs.map +1 -0
  308. package/dist/lib/file/fileLines.mjs +32 -0
  309. package/dist/lib/file/fileLines.mjs.map +1 -0
  310. package/dist/lib/file/index.mjs +42 -0
  311. package/dist/lib/file/index.mjs.map +1 -0
  312. package/dist/lib/file/tryReadFileSync.mjs +14 -0
  313. package/dist/lib/file/tryReadFileSync.mjs.map +1 -0
  314. package/dist/lib/fillTemplate.mjs +8 -0
  315. package/dist/lib/fillTemplate.mjs.map +1 -0
  316. package/dist/lib/generateIgnoreFiles.mjs +86 -0
  317. package/dist/lib/generateIgnoreFiles.mjs.map +1 -0
  318. package/dist/lib/generateReadmeFiles.mjs +323 -0
  319. package/dist/lib/generateReadmeFiles.mjs.map +1 -0
  320. package/dist/lib/gitignoreTemplate.mjs +12 -0
  321. package/dist/lib/gitignoreTemplate.mjs.map +1 -0
  322. package/dist/lib/index.mjs +1627 -0
  323. package/dist/lib/index.mjs.map +1 -0
  324. package/dist/lib/initCwd.mjs +8 -0
  325. package/dist/lib/initCwd.mjs.map +1 -0
  326. package/dist/lib/jsonFormatters.mjs +11 -0
  327. package/dist/lib/jsonFormatters.mjs.map +1 -0
  328. package/dist/lib/latestVersions.mjs +12 -0
  329. package/dist/lib/latestVersions.mjs.map +1 -0
  330. package/dist/lib/loadConfig.mjs +72 -0
  331. package/dist/lib/loadConfig.mjs.map +1 -0
  332. package/dist/lib/packageName.mjs +26 -0
  333. package/dist/lib/packageName.mjs.map +1 -0
  334. package/dist/lib/parsedPackageJSON.mjs +11 -0
  335. package/dist/lib/parsedPackageJSON.mjs.map +1 -0
  336. package/dist/lib/processEx.mjs +36 -0
  337. package/dist/lib/processEx.mjs.map +1 -0
  338. package/dist/lib/repoTemplates.mjs +34 -0
  339. package/dist/lib/repoTemplates.mjs.map +1 -0
  340. package/dist/lib/runInstall.mjs +30 -0
  341. package/dist/lib/runInstall.mjs.map +1 -0
  342. package/dist/lib/runSteps.mjs +118 -0
  343. package/dist/lib/runSteps.mjs.map +1 -0
  344. package/dist/lib/runStepsAsync.mjs +136 -0
  345. package/dist/lib/runStepsAsync.mjs.map +1 -0
  346. package/dist/lib/runXy.mjs +147 -0
  347. package/dist/lib/runXy.mjs.map +1 -0
  348. package/dist/lib/runXyWithWarning.mjs +36 -0
  349. package/dist/lib/runXyWithWarning.mjs.map +1 -0
  350. package/dist/lib/safeExit.mjs +61 -0
  351. package/dist/lib/safeExit.mjs.map +1 -0
  352. package/dist/lib/string/empty.mjs +8 -0
  353. package/dist/lib/string/empty.mjs.map +1 -0
  354. package/dist/lib/string/index.mjs +12 -0
  355. package/dist/lib/string/index.mjs.map +1 -0
  356. package/dist/lib/string/union.mjs +6 -0
  357. package/dist/lib/string/union.mjs.map +1 -0
  358. package/dist/lib/tryRunLocalScript.mjs +57 -0
  359. package/dist/lib/tryRunLocalScript.mjs.map +1 -0
  360. package/dist/lib/updo/applyUpdates.mjs +44 -0
  361. package/dist/lib/updo/applyUpdates.mjs.map +1 -0
  362. package/dist/lib/updo/collectWorkspaceDeps.mjs +48 -0
  363. package/dist/lib/updo/collectWorkspaceDeps.mjs.map +1 -0
  364. package/dist/lib/updo/fetchRegistryInfo.mjs +53 -0
  365. package/dist/lib/updo/fetchRegistryInfo.mjs.map +1 -0
  366. package/dist/lib/updo/index.mjs +594 -0
  367. package/dist/lib/updo/index.mjs.map +1 -0
  368. package/dist/lib/updo/interactiveSelect.mjs +185 -0
  369. package/dist/lib/updo/interactiveSelect.mjs.map +1 -0
  370. package/dist/lib/updo/interfaces.mjs +1 -0
  371. package/dist/lib/updo/interfaces.mjs.map +1 -0
  372. package/dist/lib/updo/renderTable.mjs +79 -0
  373. package/dist/lib/updo/renderTable.mjs.map +1 -0
  374. package/dist/lib/updo/resolveVersions.mjs +49 -0
  375. package/dist/lib/updo/resolveVersions.mjs.map +1 -0
  376. package/dist/lib/updo/runUpdo.mjs +511 -0
  377. package/dist/lib/updo/runUpdo.mjs.map +1 -0
  378. package/dist/lib/withErrnoException.mjs +13 -0
  379. package/dist/lib/withErrnoException.mjs.map +1 -0
  380. package/dist/lib/withError.mjs +8 -0
  381. package/dist/lib/withError.mjs.map +1 -0
  382. package/dist/lib/yarn/index.mjs +39 -0
  383. package/dist/lib/yarn/index.mjs.map +1 -0
  384. package/dist/lib/yarn/isYarnVersionOrGreater.mjs +18 -0
  385. package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -0
  386. package/dist/lib/yarn/workspace/Workspace.mjs +1 -0
  387. package/dist/lib/yarn/workspace/Workspace.mjs.map +1 -0
  388. package/dist/lib/yarn/workspace/index.mjs +23 -0
  389. package/dist/lib/yarn/workspace/index.mjs.map +1 -0
  390. package/dist/lib/yarn/workspace/yarnWorkspace.mjs +22 -0
  391. package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -0
  392. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs +15 -0
  393. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -0
  394. package/dist/lib/yarn/yarnInitCwd.mjs +8 -0
  395. package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -0
  396. package/dist/loadPackageConfig.mjs +18 -0
  397. package/dist/loadPackageConfig.mjs.map +1 -0
  398. package/dist/pm/PackageManager.mjs +1 -0
  399. package/dist/pm/PackageManager.mjs.map +1 -0
  400. package/dist/pm/detectPackageManager.mjs +10 -0
  401. package/dist/pm/detectPackageManager.mjs.map +1 -0
  402. package/dist/pm/detectReact.mjs +52 -0
  403. package/dist/pm/detectReact.mjs.map +1 -0
  404. package/dist/pm/index.mjs +263 -0
  405. package/dist/pm/index.mjs.map +1 -0
  406. package/dist/pm/pnpmPackageManager.mjs +97 -0
  407. package/dist/pm/pnpmPackageManager.mjs.map +1 -0
  408. package/dist/pm/registry.mjs +27 -0
  409. package/dist/pm/registry.mjs.map +1 -0
  410. package/dist/pm/yarnPackageManager.mjs +112 -0
  411. package/dist/pm/yarnPackageManager.mjs.map +1 -0
  412. package/dist/types.d.mjs +1 -0
  413. package/dist/types.d.mjs.map +1 -0
  414. package/dist/xy/build/buildCommand.mjs +194 -0
  415. package/dist/xy/build/buildCommand.mjs.map +1 -0
  416. package/dist/xy/build/compileCommand.mjs +203 -0
  417. package/dist/xy/build/compileCommand.mjs.map +1 -0
  418. package/dist/xy/build/compileOnlyCommand.mjs +204 -0
  419. package/dist/xy/build/compileOnlyCommand.mjs.map +1 -0
  420. package/dist/xy/build/copyAssetsCommand.mjs +92 -0
  421. package/dist/xy/build/copyAssetsCommand.mjs.map +1 -0
  422. package/dist/xy/build/index.mjs +487 -0
  423. package/dist/xy/build/index.mjs.map +1 -0
  424. package/dist/xy/build/rebuildCommand.mjs +156 -0
  425. package/dist/xy/build/rebuildCommand.mjs.map +1 -0
  426. package/dist/xy/build/recompileCommand.mjs +215 -0
  427. package/dist/xy/build/recompileCommand.mjs.map +1 -0
  428. package/dist/xy/common/checkCommand.mjs +1909 -0
  429. package/dist/xy/common/checkCommand.mjs.map +1 -0
  430. package/dist/xy/common/claude/checkCommand.mjs +207 -0
  431. package/dist/xy/common/claude/checkCommand.mjs.map +1 -0
  432. package/dist/xy/common/claude/cleanCommand.mjs +78 -0
  433. package/dist/xy/common/claude/cleanCommand.mjs.map +1 -0
  434. package/dist/xy/common/claude/commandsCommand.mjs +134 -0
  435. package/dist/xy/common/claude/commandsCommand.mjs.map +1 -0
  436. package/dist/xy/common/claude/index.mjs +734 -0
  437. package/dist/xy/common/claude/index.mjs.map +1 -0
  438. package/dist/xy/common/claude/initCommand.mjs +458 -0
  439. package/dist/xy/common/claude/initCommand.mjs.map +1 -0
  440. package/dist/xy/common/claude/rulesCommand.mjs +167 -0
  441. package/dist/xy/common/claude/rulesCommand.mjs.map +1 -0
  442. package/dist/xy/common/claude/settingsCommand.mjs +115 -0
  443. package/dist/xy/common/claude/settingsCommand.mjs.map +1 -0
  444. package/dist/xy/common/claude/skillsCommand.mjs +140 -0
  445. package/dist/xy/common/claude/skillsCommand.mjs.map +1 -0
  446. package/dist/xy/common/cleanDocsCommand.mjs +74 -0
  447. package/dist/xy/common/cleanDocsCommand.mjs.map +1 -0
  448. package/dist/xy/common/deadCommand.mjs +137 -0
  449. package/dist/xy/common/deadCommand.mjs.map +1 -0
  450. package/dist/xy/common/genDocsCommand.mjs +175 -0
  451. package/dist/xy/common/genDocsCommand.mjs.map +1 -0
  452. package/dist/xy/common/gitignoreCommand.mjs +165 -0
  453. package/dist/xy/common/gitignoreCommand.mjs.map +1 -0
  454. package/dist/xy/common/gitlintCommand.mjs +89 -0
  455. package/dist/xy/common/gitlintCommand.mjs.map +1 -0
  456. package/dist/xy/common/index.mjs +4654 -0
  457. package/dist/xy/common/index.mjs.map +1 -0
  458. package/dist/xy/common/licenseCommand.mjs +108 -0
  459. package/dist/xy/common/licenseCommand.mjs.map +1 -0
  460. package/dist/xy/common/npmignoreGenCommand.mjs +100 -0
  461. package/dist/xy/common/npmignoreGenCommand.mjs.map +1 -0
  462. package/dist/xy/common/orphan/cleanCommand.mjs +102 -0
  463. package/dist/xy/common/orphan/cleanCommand.mjs.map +1 -0
  464. package/dist/xy/common/orphan/index.mjs +138 -0
  465. package/dist/xy/common/orphan/index.mjs.map +1 -0
  466. package/dist/xy/common/orphan/listCommand.mjs +100 -0
  467. package/dist/xy/common/orphan/listCommand.mjs.map +1 -0
  468. package/dist/xy/common/packmanCommand.mjs +1538 -0
  469. package/dist/xy/common/packmanCommand.mjs.map +1 -0
  470. package/dist/xy/common/readme/genCommand.mjs +395 -0
  471. package/dist/xy/common/readme/genCommand.mjs.map +1 -0
  472. package/dist/xy/common/readme/index.mjs +538 -0
  473. package/dist/xy/common/readme/index.mjs.map +1 -0
  474. package/dist/xy/common/readme/initCommand.mjs +109 -0
  475. package/dist/xy/common/readme/initCommand.mjs.map +1 -0
  476. package/dist/xy/common/readme/lintCommand.mjs +181 -0
  477. package/dist/xy/common/readme/lintCommand.mjs.map +1 -0
  478. package/dist/xy/common/repo/index.mjs +1070 -0
  479. package/dist/xy/common/repo/index.mjs.map +1 -0
  480. package/dist/xy/common/repo/initCommand.mjs +273 -0
  481. package/dist/xy/common/repo/initCommand.mjs.map +1 -0
  482. package/dist/xy/common/repo/lintCommand.mjs +789 -0
  483. package/dist/xy/common/repo/lintCommand.mjs.map +1 -0
  484. package/dist/xy/common/retestCommand.mjs +163 -0
  485. package/dist/xy/common/retestCommand.mjs.map +1 -0
  486. package/dist/xy/common/testCommand.mjs +157 -0
  487. package/dist/xy/common/testCommand.mjs.map +1 -0
  488. package/dist/xy/deploy/deployCommand.mjs +214 -0
  489. package/dist/xy/deploy/deployCommand.mjs.map +1 -0
  490. package/dist/xy/deploy/index.mjs +289 -0
  491. package/dist/xy/deploy/index.mjs.map +1 -0
  492. package/dist/xy/deploy/publishCommand.mjs +218 -0
  493. package/dist/xy/deploy/publishCommand.mjs.map +1 -0
  494. package/dist/xy/index.mjs +8887 -0
  495. package/dist/xy/index.mjs.map +1 -0
  496. package/dist/xy/install/cleanCommand.mjs +182 -0
  497. package/dist/xy/install/cleanCommand.mjs.map +1 -0
  498. package/dist/xy/install/dupdepsCommand.mjs +234 -0
  499. package/dist/xy/install/dupdepsCommand.mjs.map +1 -0
  500. package/dist/xy/install/index.mjs +1006 -0
  501. package/dist/xy/install/index.mjs.map +1 -0
  502. package/dist/xy/install/reinstallCommand.mjs +292 -0
  503. package/dist/xy/install/reinstallCommand.mjs.map +1 -0
  504. package/dist/xy/install/staticsCommand.mjs +233 -0
  505. package/dist/xy/install/staticsCommand.mjs.map +1 -0
  506. package/dist/xy/install/upCommand.mjs +150 -0
  507. package/dist/xy/install/upCommand.mjs.map +1 -0
  508. package/dist/xy/install/updoCommand.mjs +550 -0
  509. package/dist/xy/install/updoCommand.mjs.map +1 -0
  510. package/dist/xy/lint/cycleCommand.mjs +289 -0
  511. package/dist/xy/lint/cycleCommand.mjs.map +1 -0
  512. package/dist/xy/lint/deplintCommand.mjs +1897 -0
  513. package/dist/xy/lint/deplintCommand.mjs.map +1 -0
  514. package/dist/xy/lint/fixCommand.mjs +398 -0
  515. package/dist/xy/lint/fixCommand.mjs.map +1 -0
  516. package/dist/xy/lint/index.mjs +3759 -0
  517. package/dist/xy/lint/index.mjs.map +1 -0
  518. package/dist/xy/lint/knipCommand.mjs +142 -0
  519. package/dist/xy/lint/knipCommand.mjs.map +1 -0
  520. package/dist/xy/lint/lint/index.mjs +695 -0
  521. package/dist/xy/lint/lint/index.mjs.map +1 -0
  522. package/dist/xy/lint/lint/initCommand.mjs +282 -0
  523. package/dist/xy/lint/lint/initCommand.mjs.map +1 -0
  524. package/dist/xy/lint/lint/runCommand.mjs +405 -0
  525. package/dist/xy/lint/lint/runCommand.mjs.map +1 -0
  526. package/dist/xy/lint/lintCommand.mjs +695 -0
  527. package/dist/xy/lint/lintCommand.mjs.map +1 -0
  528. package/dist/xy/lint/lintlintCommand.mjs +359 -0
  529. package/dist/xy/lint/lintlintCommand.mjs.map +1 -0
  530. package/dist/xy/lint/publintCommand.mjs +778 -0
  531. package/dist/xy/lint/publintCommand.mjs.map +1 -0
  532. package/dist/xy/lint/relintCommand.mjs +381 -0
  533. package/dist/xy/lint/relintCommand.mjs.map +1 -0
  534. package/dist/xy/lint/sonarCommand.mjs +137 -0
  535. package/dist/xy/lint/sonarCommand.mjs.map +1 -0
  536. package/dist/xy/param.mjs +8 -0
  537. package/dist/xy/param.mjs.map +1 -0
  538. package/dist/xy/react/analyzeCommand.mjs +150 -0
  539. package/dist/xy/react/analyzeCommand.mjs.map +1 -0
  540. package/dist/xy/react/ejectCommand.mjs +150 -0
  541. package/dist/xy/react/ejectCommand.mjs.map +1 -0
  542. package/dist/xy/react/index.mjs +202 -0
  543. package/dist/xy/react/index.mjs.map +1 -0
  544. package/dist/xy/react/sitemapCommand.mjs +129 -0
  545. package/dist/xy/react/sitemapCommand.mjs.map +1 -0
  546. package/dist/xy/react/startCommand.mjs +150 -0
  547. package/dist/xy/react/startCommand.mjs.map +1 -0
  548. package/dist/xy/xy.mjs +8879 -0
  549. package/dist/xy/xy.mjs.map +1 -0
  550. package/dist/xy/xyParseOptions.mjs +117 -0
  551. package/dist/xy/xyParseOptions.mjs.map +1 -0
  552. package/dist/xy/yarn/index.mjs +188 -0
  553. package/dist/xy/yarn/index.mjs.map +1 -0
  554. package/dist/xy/yarn/upplugCommand.mjs +134 -0
  555. package/dist/xy/yarn/upplugCommand.mjs.map +1 -0
  556. package/dist/xy/yarn/upyarnCommand.mjs +129 -0
  557. package/dist/xy/yarn/upyarnCommand.mjs.map +1 -0
  558. package/dist/xy/yarn/yarn3OnlyCommand.mjs +70 -0
  559. package/dist/xy/yarn/yarn3OnlyCommand.mjs.map +1 -0
  560. package/package.json +119 -0
  561. package/templates/claude/CLAUDE-local.md +4 -0
  562. package/templates/claude/CLAUDE-project.md +4 -0
  563. package/templates/claude/commands/xy-build.md +7 -0
  564. package/templates/claude/commands/xy-clean.md +7 -0
  565. package/templates/claude/commands/xy-compile.md +7 -0
  566. package/templates/claude/commands/xy-cycle.md +7 -0
  567. package/templates/claude/commands/xy-dead.md +7 -0
  568. package/templates/claude/commands/xy-deplint.md +7 -0
  569. package/templates/claude/commands/xy-deps.md +24 -0
  570. package/templates/claude/commands/xy-dupdeps.md +7 -0
  571. package/templates/claude/commands/xy-fix.md +7 -0
  572. package/templates/claude/commands/xy-gen-docs.md +7 -0
  573. package/templates/claude/commands/xy-gitignore.md +7 -0
  574. package/templates/claude/commands/xy-gitlint.md +7 -0
  575. package/templates/claude/commands/xy-knip.md +7 -0
  576. package/templates/claude/commands/xy-license.md +7 -0
  577. package/templates/claude/commands/xy-lint-rules.md +44 -0
  578. package/templates/claude/commands/xy-lint.md +7 -0
  579. package/templates/claude/commands/xy-publint.md +7 -0
  580. package/templates/claude/commands/xy-rebuild.md +7 -0
  581. package/templates/claude/commands/xy-recompile.md +7 -0
  582. package/templates/claude/commands/xy-reinstall.md +7 -0
  583. package/templates/claude/commands/xy-relint.md +7 -0
  584. package/templates/claude/commands/xy-retest.md +7 -0
  585. package/templates/claude/commands/xy-sonar.md +7 -0
  586. package/templates/claude/commands/xy-test.md +7 -0
  587. package/templates/claude/commands/xy-up.md +9 -0
  588. package/templates/claude/rules/xylabs-architecture.md +8 -0
  589. package/templates/claude/rules/xylabs-git-workflow.md +7 -0
  590. package/templates/claude/rules/xylabs-naming.md +7 -0
  591. package/templates/claude/rules/xylabs-style.md +17 -0
  592. package/templates/claude/skills/xylabs-e2e-setup/SKILL.md +223 -0
  593. package/templates/claude/skills/xylabs-xy-cli/SKILL.md +236 -0
  594. package/templates/claude/skills/xylabs-xy-deplint-fix/SKILL.md +122 -0
  595. package/templates/gitignore/gitignore/template.gitignore +51 -0
  596. package/templates/gitignore/template.gitignore +51 -0
  597. package/templates/readme/README.body.md +25 -0
  598. package/templates/readme/README.template.md +22 -0
  599. package/templates/repo/cli/package/package.json.tmpl +63 -0
  600. package/templates/repo/cli/package/src/__packageName__.ts.tmpl +21 -0
  601. package/templates/repo/cli/package/src/actions/index.ts +1 -0
  602. package/templates/repo/cli/package/src/actions/printVersion.ts.tmpl +8 -0
  603. package/templates/repo/cli/package/src/bin/__packageName__.ts.tmpl +12 -0
  604. package/templates/repo/cli/package/src/commands/index.ts +1 -0
  605. package/templates/repo/cli/package/src/commands/versionCommand.ts.tmpl +11 -0
  606. package/templates/repo/cli/package/src/index.ts.tmpl +1 -0
  607. package/templates/repo/cli/package/tsconfig.build.json +25 -0
  608. package/templates/repo/cli/package/tsconfig.json +4 -0
  609. package/templates/repo/cli/package/tsup.config.ts +15 -0
  610. package/templates/repo/cli/package/xy.config.ts +3 -0
  611. package/templates/repo/cli/root/CLAUDE.md.tmpl +38 -0
  612. package/templates/repo/cli/root/cspell.json.tmpl +13 -0
  613. package/templates/repo/cli/root/eslint.config.ts +28 -0
  614. package/templates/repo/cli/root/github/workflows/build-pnpm.yml.tmpl +34 -0
  615. package/templates/repo/cli/root/github/workflows/build-yarn.yml.tmpl +32 -0
  616. package/templates/repo/cli/root/gitignore.tmpl +47 -0
  617. package/templates/repo/cli/root/knip.config.ts +16 -0
  618. package/templates/repo/cli/root/package.json.tmpl +54 -0
  619. package/templates/repo/cli/root/pnpm-workspace.yaml +2 -0
  620. package/templates/repo/cli/root/tsconfig.json +4 -0
  621. package/templates/repo/cli/root/vitest.config.ts +31 -0
  622. package/templates/repo/cli/root/xy.config.ts.tmpl +5 -0
@@ -0,0 +1,1627 @@
1
+ // src/lib/checkResult.ts
2
+ import chalk from "chalk";
3
+ var checkResult = (name, result, level = "error", exitOnFail = false) => {
4
+ if (result) {
5
+ const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
6
+ const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
7
+ console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
8
+ if (exitOnFail) {
9
+ process.exit(result);
10
+ }
11
+ }
12
+ };
13
+
14
+ // src/lib/claudeMdTemplate.ts
15
+ import {
16
+ readdirSync,
17
+ readFileSync,
18
+ statSync
19
+ } from "fs";
20
+ import { createRequire } from "module";
21
+ import PATH from "path";
22
+ var require2 = createRequire(import.meta.url);
23
+ var packageRoot = PATH.dirname(require2.resolve("@xylabs/ts-scripts-common/package.json"));
24
+ var templatesDir = PATH.resolve(packageRoot, "templates", "claude");
25
+ function applyPackageManager(content, pm) {
26
+ return content.replaceAll("yarn xy", `${pm} xy`).replaceAll("yarn add", `${pm} add`);
27
+ }
28
+ var XYLABS_RULES_PREFIX = "xylabs-";
29
+ var XYLABS_COMMANDS_PREFIX = "xy-";
30
+ var LEGACY_COMMANDS_PREFIX = "xylabs-";
31
+ var XYLABS_SKILLS_PREFIX = "xylabs-";
32
+ var claudeMdRuleTemplates = () => {
33
+ const rulesDir = PATH.resolve(templatesDir, "rules");
34
+ const files = readdirSync(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
35
+ const result = {};
36
+ for (const file of files) {
37
+ result[file] = readFileSync(PATH.resolve(rulesDir, file), "utf8");
38
+ }
39
+ return result;
40
+ };
41
+ var claudeCommandTemplates = () => {
42
+ const commandsDir = PATH.resolve(templatesDir, "commands");
43
+ const files = readdirSync(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
44
+ const result = {};
45
+ for (const file of files) {
46
+ result[file] = readFileSync(PATH.resolve(commandsDir, file), "utf8");
47
+ }
48
+ return result;
49
+ };
50
+ var claudeSkillTemplates = () => {
51
+ const skillsDir = PATH.resolve(templatesDir, "skills");
52
+ const dirs = readdirSync(skillsDir).filter(
53
+ (f) => f.startsWith(XYLABS_SKILLS_PREFIX) && statSync(PATH.resolve(skillsDir, f)).isDirectory()
54
+ );
55
+ const result = {};
56
+ for (const dir of dirs) {
57
+ const dirPath = PATH.resolve(skillsDir, dir);
58
+ const files = readdirSync(dirPath, { recursive: true, encoding: "utf8" });
59
+ result[dir] = {};
60
+ for (const file of files) {
61
+ if (statSync(PATH.resolve(dirPath, file)).isFile()) {
62
+ result[dir][file] = readFileSync(PATH.resolve(dirPath, file), "utf8");
63
+ }
64
+ }
65
+ }
66
+ return result;
67
+ };
68
+ var claudeMdProjectTemplate = () => readFileSync(PATH.resolve(templatesDir, "CLAUDE-project.md"), "utf8");
69
+ var claudeMdLocalTemplate = () => readFileSync(PATH.resolve(templatesDir, "CLAUDE-local.md"), "utf8");
70
+
71
+ // src/lib/concurrency.ts
72
+ import { AsyncLocalStorage } from "async_hooks";
73
+ var outputStorage = new AsyncLocalStorage();
74
+ var captureInstalled = false;
75
+ function installOutputCapture() {
76
+ if (captureInstalled) return;
77
+ captureInstalled = true;
78
+ const originalStdoutWrite = process.stdout.write.bind(process.stdout);
79
+ const originalStderrWrite = process.stderr.write.bind(process.stderr);
80
+ function intercept(original) {
81
+ return function(chunk, ...args) {
82
+ const buffer = outputStorage.getStore();
83
+ if (buffer) {
84
+ buffer.push(typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk));
85
+ return true;
86
+ }
87
+ return original(chunk, ...args);
88
+ };
89
+ }
90
+ process.stdout.write = intercept(originalStdoutWrite);
91
+ process.stderr.write = intercept(originalStderrWrite);
92
+ }
93
+ async function runWithConcurrency(items, concurrency, fn) {
94
+ let next = 0;
95
+ async function worker() {
96
+ while (next < items.length) {
97
+ const i = next++;
98
+ await fn(items[i]);
99
+ }
100
+ }
101
+ await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, () => worker()));
102
+ }
103
+
104
+ // src/lib/createBuildConfig.ts
105
+ import { readFileSync as readFileSync2 } from "fs";
106
+
107
+ // src/lib/defaultBuildConfig.ts
108
+ var defaultBuildConfig = {
109
+ compilerOptions: {
110
+ rootDir: "src",
111
+ rootDirs: ["package.json"]
112
+ },
113
+ exclude: [
114
+ "**/build",
115
+ "**/dist",
116
+ "**/node_modules",
117
+ "**/*.spec.*",
118
+ "**/*.spec",
119
+ "**/*.stories.*",
120
+ "**/*.example.*",
121
+ "**/spec/*",
122
+ "**/stories/*"
123
+ ],
124
+ include: ["src"]
125
+ };
126
+
127
+ // src/lib/createBuildConfig.ts
128
+ var getGeneralTypescriptConfig = (location) => {
129
+ let generalConfig;
130
+ try {
131
+ generalConfig = readFileSync2(`${location}/tsconfig.json`, { encoding: "utf8" });
132
+ } catch {
133
+ return false;
134
+ }
135
+ return JSON.parse(generalConfig);
136
+ };
137
+ var createBuildConfig = (location, module, target, outDirSuffix) => {
138
+ const generalConfigObject = getGeneralTypescriptConfig(location);
139
+ if (generalConfigObject === false) {
140
+ return void 0;
141
+ }
142
+ return {
143
+ ...generalConfigObject,
144
+ compilerOptions: {
145
+ ...defaultBuildConfig.compilerOptions,
146
+ ...generalConfigObject.compilerOptions,
147
+ module,
148
+ outDir: `./${generalConfigObject.compilerOptions?.outDir ?? "dist"}/${outDirSuffix}`,
149
+ target
150
+ },
151
+ exclude: [...generalConfigObject.exclude ?? [], ...defaultBuildConfig.exclude],
152
+ include: [...generalConfigObject.include ?? [], ...defaultBuildConfig.include]
153
+ };
154
+ };
155
+
156
+ // src/lib/deleteGlob.ts
157
+ import fs from "fs";
158
+ import { glob } from "glob";
159
+ var deleteGlob = (globPath) => {
160
+ const files = glob.sync(globPath);
161
+ for (const file of files) {
162
+ fs.rmSync(file, { recursive: true, force: true });
163
+ }
164
+ };
165
+
166
+ // src/lib/dependencies/detectDuplicateDependencies.ts
167
+ import { execSync } from "child_process";
168
+
169
+ // src/pm/detectPackageManager.ts
170
+ import { existsSync } from "fs";
171
+ function detectPackageManager() {
172
+ if (existsSync("pnpm-lock.yaml") || existsSync("pnpm-workspace.yaml")) return "pnpm";
173
+ return "yarn";
174
+ }
175
+
176
+ // src/pm/registry.ts
177
+ var implementations = /* @__PURE__ */ new Map();
178
+ function getPackageManager(name) {
179
+ const pmName = name ?? detectPackageManager();
180
+ const pm = implementations.get(pmName);
181
+ if (!pm) {
182
+ throw new Error(
183
+ `No package manager implementation registered for "${pmName}". Ensure registerPackageManager() has been called before getPackageManager().`
184
+ );
185
+ }
186
+ return pm;
187
+ }
188
+
189
+ // src/lib/yarn/isYarnVersionOrGreater.ts
190
+ import { spawnSync } from "child_process";
191
+ var isYarnVersionOrGreater = (major, minor, patch) => {
192
+ const result = spawnSync("yarn", ["-v"], { encoding: "utf8", shell: true });
193
+ const version = result.stdout.toString().replaceAll("\n", "");
194
+ const versionNumbers = version.split(".").map((ver) => Number.parseInt(ver));
195
+ const majorDelta = versionNumbers[0] - major;
196
+ const minorDelta = versionNumbers[1] - (minor ?? versionNumbers[1]);
197
+ const patchDelta = versionNumbers[2] - (patch ?? versionNumbers[2]);
198
+ const majorOk = majorDelta >= 0;
199
+ const minorOk = majorDelta > 0 || minorDelta >= 0;
200
+ const patchOk = majorDelta > 0 || minorDelta > 0 || patchDelta >= 0;
201
+ return [majorOk && minorOk && patchOk, version];
202
+ };
203
+
204
+ // src/lib/yarn/workspace/yarnWorkspaces.ts
205
+ import { spawnSync as spawnSync2 } from "child_process";
206
+ var yarnWorkspaces = () => {
207
+ const result = spawnSync2("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8" });
208
+ if (result.error) {
209
+ throw result.error;
210
+ }
211
+ return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
212
+ return JSON.parse(item);
213
+ });
214
+ };
215
+
216
+ // src/lib/yarn/workspace/yarnWorkspace.ts
217
+ var yarnWorkspace = (pkg) => {
218
+ const workspace = yarnWorkspaces().find(({ name }) => name === pkg);
219
+ if (!workspace) throw new Error(`Workspace ${pkg} not found`);
220
+ return workspace;
221
+ };
222
+
223
+ // src/lib/processEx.ts
224
+ import chalk2 from "chalk";
225
+
226
+ // src/lib/withError.ts
227
+ var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
228
+ return predicate(ex) ? closure(ex) : void 0;
229
+ };
230
+
231
+ // src/lib/withErrnoException.ts
232
+ var withErrnoException = (ex, closure) => {
233
+ return withError(ex, closure, (ex2) => ex2.errno !== void 0);
234
+ };
235
+
236
+ // src/lib/processEx.ts
237
+ var processEx = (ex) => {
238
+ const error = typeof ex === "string" ? new Error(ex) : ex;
239
+ const exitCode = withErrnoException(error, (error2) => {
240
+ if (error2.code === "ENOENT") {
241
+ console.error(chalk2.red(`'${error2.path}' not found.`));
242
+ } else {
243
+ console.error(chalk2.red(`Errno: ${error2.code}`));
244
+ }
245
+ return error2.errno ?? -1;
246
+ }) ?? withError(error, (error2) => {
247
+ console.error(chalk2.red(`${error2.name}: ${error2.message}`));
248
+ return -1;
249
+ }) ?? (() => {
250
+ console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
251
+ return -1;
252
+ })();
253
+ process.exit(process.exitCode ?? exitCode);
254
+ };
255
+
256
+ // src/lib/safeExit.ts
257
+ var safeExit = (func, exitOnFail = true) => {
258
+ try {
259
+ const result = func();
260
+ if (result && exitOnFail) {
261
+ process.exit(result);
262
+ }
263
+ return result;
264
+ } catch (ex) {
265
+ return processEx(ex);
266
+ }
267
+ };
268
+ var safeExitAsync = async (func, exitOnFail = true) => {
269
+ try {
270
+ const result = await func();
271
+ if (result && exitOnFail) {
272
+ process.exit(result);
273
+ }
274
+ return result;
275
+ } catch (ex) {
276
+ return processEx(ex);
277
+ }
278
+ };
279
+
280
+ // src/lib/dependencies/DuplicateDetector.ts
281
+ import { EOL } from "os";
282
+ import chalk3 from "chalk";
283
+
284
+ // src/lib/jsonFormatters.ts
285
+ var multiLineToJSONArray = (output) => {
286
+ const withCommas = output.replaceAll("\r\n", "").replaceAll("\n", ",");
287
+ const cleanCollection = withCommas.slice(0, Math.max(0, withCommas.length - 1));
288
+ const collection = `[${cleanCollection}]`;
289
+ return JSON.parse(collection);
290
+ };
291
+
292
+ // src/lib/dependencies/DuplicateDetector.ts
293
+ var trimVirtualMeta = (value) => {
294
+ const virtualParts = value.split("virtual:");
295
+ if (virtualParts.length > 1) {
296
+ const hashParts = virtualParts[1].split("#");
297
+ return virtualParts[0] + hashParts[1];
298
+ } else {
299
+ return value;
300
+ }
301
+ };
302
+ var trimObjectDependencyVirtualMeta = (obj) => {
303
+ const resultObj = {};
304
+ for (const [key, value] of Object.entries(obj)) {
305
+ resultObj[trimVirtualMeta(key)] = {
306
+ descriptor: trimVirtualMeta(value.descriptor),
307
+ locator: trimVirtualMeta(value.locator)
308
+ };
309
+ }
310
+ return resultObj;
311
+ };
312
+ var trimDependencyVirtualMeta = (dependencies) => {
313
+ return dependencies.map((dependency) => {
314
+ return { children: trimObjectDependencyVirtualMeta(dependency.children), value: trimVirtualMeta(dependency.value) };
315
+ });
316
+ };
317
+ function extractPnpmVersions(data, depName) {
318
+ const versions = /* @__PURE__ */ new Set();
319
+ function walk(obj) {
320
+ if (Array.isArray(obj)) {
321
+ for (const item of obj) walk(item);
322
+ } else if (obj && typeof obj === "object") {
323
+ const record = obj;
324
+ if (typeof record.version === "string" && typeof record.from === "string" && record.from === depName) {
325
+ versions.add(record.version);
326
+ }
327
+ for (const val of Object.values(record)) walk(val);
328
+ }
329
+ }
330
+ walk(data);
331
+ return [...versions];
332
+ }
333
+ var DuplicateDetector = class {
334
+ dependency;
335
+ duplicateVersions;
336
+ constructor(output, dependency) {
337
+ this.dependency = dependency;
338
+ this.duplicateVersions = this.parseVersions(output, dependency);
339
+ }
340
+ detect() {
341
+ if (this.duplicateVersions.length > 1) {
342
+ console.log(chalk3.yellow(`${EOL}Duplicates found for: ${this.dependency}`));
343
+ const duplicateVersions = this.duplicateVersions.join(`${EOL} `);
344
+ console.log(chalk3.grey(` ${duplicateVersions}`, EOL));
345
+ return 1;
346
+ } else {
347
+ console.log(`${this.dependency} - OK`);
348
+ return 0;
349
+ }
350
+ }
351
+ parseVersions(output, dependency) {
352
+ try {
353
+ const parsed = JSON.parse(output);
354
+ if (Array.isArray(parsed)) {
355
+ return extractPnpmVersions(parsed, dependency);
356
+ }
357
+ } catch {
358
+ }
359
+ try {
360
+ const entries = trimDependencyVirtualMeta(multiLineToJSONArray(output));
361
+ const versions = /* @__PURE__ */ new Set();
362
+ for (const entry of entries) {
363
+ for (const key of Object.keys(entry.children)) {
364
+ const version = key.includes("@virtual:") ? void 0 : key;
365
+ if (version) versions.add(version);
366
+ }
367
+ }
368
+ return [...versions];
369
+ } catch {
370
+ console.warn(chalk3.yellow(`Could not parse dependency output for ${dependency}`));
371
+ return [];
372
+ }
373
+ }
374
+ };
375
+
376
+ // src/lib/dependencies/detectDuplicateDependencies.ts
377
+ var detectDuplicateDependencies = (depsFromPackageJSON, DefaultDependencies) => {
378
+ let exitCode = 0;
379
+ const dependencies = depsFromPackageJSON?.length ? depsFromPackageJSON : DefaultDependencies;
380
+ return safeExit(() => {
381
+ if (dependencies) {
382
+ for (const dependency of dependencies) {
383
+ let output;
384
+ try {
385
+ const pm = getPackageManager();
386
+ const cmd = `${pm.command} why ${dependency} --json`;
387
+ output = execSync(cmd, { maxBuffer: 64 * 1024 * 1024 }).toString();
388
+ } catch (e) {
389
+ console.error(`Error running dependency check: ${String(e)}`);
390
+ exitCode = 1;
391
+ continue;
392
+ }
393
+ if (output) {
394
+ exitCode = new DuplicateDetector(output, dependency).detect();
395
+ } else {
396
+ console.log(`${dependency} - N/A`);
397
+ if (depsFromPackageJSON) {
398
+ exitCode = 1;
399
+ console.log(`\u{1F6A8} Library ${dependency} was requested in package.json but not found`);
400
+ }
401
+ }
402
+ }
403
+ return exitCode;
404
+ } else {
405
+ console.log("\u{1F6A8} No dependencies where passed");
406
+ return exitCode;
407
+ }
408
+ });
409
+ };
410
+
411
+ // src/lib/dependencies/workspaceCycles.ts
412
+ import { readFileSync as readFileSync3 } from "fs";
413
+ import PATH2 from "path";
414
+ import chalk4 from "chalk";
415
+ function detectWorkspaceCycles(workspaces) {
416
+ const workspaceNames = new Set(workspaces.map((ws) => ws.name));
417
+ const graph = /* @__PURE__ */ new Map();
418
+ for (const ws of workspaces) {
419
+ const pkgPath = PATH2.join(ws.location, "package.json");
420
+ const pkg = JSON.parse(readFileSync3(pkgPath, "utf8"));
421
+ const deps = pkg.dependencies ?? {};
422
+ const devDeps = pkg.devDependencies ?? {};
423
+ const edges = [];
424
+ for (const dep of Object.keys(deps)) {
425
+ if (workspaceNames.has(dep)) edges.push({ name: dep, type: "dep" });
426
+ }
427
+ for (const dep of Object.keys(devDeps)) {
428
+ if (workspaceNames.has(dep)) edges.push({ name: dep, type: "devDep" });
429
+ }
430
+ graph.set(ws.name, edges);
431
+ }
432
+ const WHITE = 0;
433
+ const GRAY = 1;
434
+ const BLACK = 2;
435
+ const color = /* @__PURE__ */ new Map();
436
+ const cycles = [];
437
+ const path2 = [];
438
+ const onPath = /* @__PURE__ */ new Set();
439
+ for (const name of workspaceNames) color.set(name, WHITE);
440
+ function dfs(u, incomingEdgeType) {
441
+ color.set(u, GRAY);
442
+ onPath.add(u);
443
+ path2.push({ name: u, edgeType: incomingEdgeType });
444
+ for (const edge of graph.get(u) ?? []) {
445
+ const v = edge.name;
446
+ if (onPath.has(v)) {
447
+ const cycleEdges = [];
448
+ const startIdx = path2.findIndex((p) => p.name === v);
449
+ for (let i = startIdx; i < path2.length - 1; i++) {
450
+ const nextEdgeType = path2[i + 1].edgeType ?? "dep";
451
+ cycleEdges.push({
452
+ from: path2[i].name,
453
+ to: path2[i + 1].name,
454
+ type: nextEdgeType
455
+ });
456
+ }
457
+ cycleEdges.push({
458
+ from: u,
459
+ to: v,
460
+ type: edge.type
461
+ });
462
+ cycles.push(cycleEdges);
463
+ } else if (color.get(v) === WHITE) {
464
+ dfs(v, edge.type);
465
+ }
466
+ }
467
+ path2.pop();
468
+ onPath.delete(u);
469
+ color.set(u, BLACK);
470
+ }
471
+ for (const name of workspaceNames) {
472
+ if (color.get(name) === WHITE) dfs(name);
473
+ }
474
+ return cycles;
475
+ }
476
+ function printWorkspaceCycles(cycles) {
477
+ for (const cycle of cycles) {
478
+ console.error(chalk4.red(" Workspace dependency cycle:"));
479
+ for (const edge of cycle) {
480
+ const edgeLabel = edge.type === "devDep" ? chalk4.yellow("devDep") : chalk4.cyan("dep");
481
+ console.error(` ${chalk4.white(edge.from)} --(${edgeLabel})--> ${chalk4.white(edge.to)}`);
482
+ }
483
+ }
484
+ }
485
+
486
+ // src/lib/file/constants.ts
487
+ var WINDOWS_NEWLINE_REGEX = /\r\n/g;
488
+ var CROSS_PLATFORM_NEWLINE = "\n";
489
+
490
+ // src/lib/file/fileLines.ts
491
+ import {
492
+ existsSync as existsSync2,
493
+ readFileSync as readFileSync4,
494
+ writeFileSync
495
+ } from "fs";
496
+
497
+ // src/lib/string/empty.ts
498
+ var empty = (value) => value?.trim().length === 0;
499
+ var notEmpty = (value) => !empty(value);
500
+
501
+ // src/lib/string/union.ts
502
+ var union = (a, b) => /* @__PURE__ */ new Set([...new Set(a), ...new Set(b)]);
503
+
504
+ // src/lib/file/ReadFileSyncOptions.ts
505
+ var defaultReadFileSyncOptions = { encoding: "utf8" };
506
+
507
+ // src/lib/file/fileLines.ts
508
+ var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync2(uri) ? readFileSync4(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : [];
509
+ var readNonEmptyLines = (uri, options = defaultReadFileSyncOptions) => readLines(uri, options).filter(notEmpty);
510
+ var writeLines = (uri, lines, options = defaultReadFileSyncOptions) => {
511
+ const existing = existsSync2(uri) ? readFileSync4(uri, options) : void 0;
512
+ const desired = lines.join(CROSS_PLATFORM_NEWLINE);
513
+ if (existing !== desired) writeFileSync(uri, desired, options);
514
+ };
515
+
516
+ // src/lib/file/tryReadFileSync.ts
517
+ import { existsSync as existsSync3, readFileSync as readFileSync5 } from "fs";
518
+ var tryReadFileSync = (uri, options = defaultReadFileSyncOptions) => {
519
+ return existsSync3(uri) ? readFileSync5(uri, options) : void 0;
520
+ };
521
+
522
+ // src/lib/fillTemplate.ts
523
+ function fillTemplate(template, data) {
524
+ return template.replaceAll(/\{\{(.*?)\}\}/g, (_, key) => data[key.trim()] ?? "");
525
+ }
526
+
527
+ // src/lib/generateIgnoreFiles.ts
528
+ import chalk5 from "chalk";
529
+
530
+ // src/lib/initCwd.ts
531
+ function INIT_CWD() {
532
+ return process.env.INIT_CWD ?? process.cwd();
533
+ }
534
+
535
+ // src/lib/generateIgnoreFiles.ts
536
+ var localeCompare = (a, b) => a.localeCompare(b);
537
+ var mergeEntries = (a, b) => [...union(a, b)].toSorted(localeCompare);
538
+ var generateIgnoreFiles = (filename, pkg) => {
539
+ console.log(chalk5.green(`Generate ${filename} Files`));
540
+ const cwd = INIT_CWD();
541
+ const pm = getPackageManager();
542
+ const singleWorkspace = pkg ? pm.findWorkspace(pkg) : void 0;
543
+ const workspaces = singleWorkspace ? [singleWorkspace] : pm.listWorkspaces();
544
+ const readEntries = (location) => readNonEmptyLines(`${location}/${filename}`);
545
+ const writeEntries = (location, entries) => writeLines(`${location}/${filename}`, entries);
546
+ const results = workspaces.map(({ location, name }) => {
547
+ try {
548
+ writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)));
549
+ return 0;
550
+ } catch (ex) {
551
+ const error = ex;
552
+ console.error(`Generate ${filename} Files [${name}] [${error.message}]`);
553
+ return 1;
554
+ }
555
+ });
556
+ const succeeded = results.every((result) => result === 0);
557
+ return succeeded ? 0 : 1;
558
+ };
559
+
560
+ // src/lib/generateReadmeFiles.ts
561
+ import { execFile } from "child_process";
562
+ import FS, { readFileSync as readFileSync6 } from "fs";
563
+ import {
564
+ mkdir,
565
+ readFile,
566
+ writeFile
567
+ } from "fs/promises";
568
+ import { createRequire as createRequire2 } from "module";
569
+ import PATH3 from "path";
570
+ import { createInterface } from "readline";
571
+ import { promisify } from "util";
572
+ import chalk6 from "chalk";
573
+ var execFileAsync = promisify(execFile);
574
+ var require3 = createRequire2(import.meta.url);
575
+ var packageRoot2 = PATH3.dirname(require3.resolve("@xylabs/ts-scripts-common/package.json"));
576
+ var readmeTemplatesDir = PATH3.resolve(packageRoot2, "templates", "readme");
577
+ function fillReadmeTemplate(template, data) {
578
+ const additionalData = { ...data, safeName: data.name.replaceAll("/", "__").replaceAll("@", "") };
579
+ return fillTemplate(template, additionalData);
580
+ }
581
+ async function generateTypedoc(packageLocation, entryPoints) {
582
+ const tempDir = PATH3.join(packageLocation, ".temp-typedoc");
583
+ try {
584
+ if (!FS.existsSync(tempDir)) {
585
+ FS.mkdirSync(tempDir, { recursive: true });
586
+ }
587
+ const typedocConfig = {
588
+ disableSources: true,
589
+ entryPointStrategy: "expand",
590
+ entryPoints: entryPoints.map((ep) => PATH3.resolve(packageLocation, ep)),
591
+ excludeExternals: true,
592
+ excludeInternal: true,
593
+ excludePrivate: true,
594
+ githubPages: false,
595
+ hideBreadcrumbs: true,
596
+ hideGenerator: true,
597
+ hidePageTitle: true,
598
+ out: tempDir,
599
+ plugin: ["typedoc-plugin-markdown"],
600
+ readme: "none",
601
+ skipErrorChecking: true,
602
+ sort: ["source-order"],
603
+ theme: "markdown",
604
+ useCodeBlocks: true
605
+ };
606
+ const typedocJsonPath = PATH3.join(tempDir, "typedoc.json");
607
+ FS.writeFileSync(typedocJsonPath, JSON.stringify(typedocConfig, null, 2));
608
+ try {
609
+ await execFileAsync("npx", ["typedoc", "--options", typedocJsonPath], { cwd: process.cwd() });
610
+ } catch {
611
+ return "";
612
+ }
613
+ return consolidateMarkdown(tempDir);
614
+ } catch {
615
+ return "";
616
+ } finally {
617
+ try {
618
+ FS.rmSync(tempDir, { force: true, recursive: true });
619
+ } catch {
620
+ }
621
+ }
622
+ }
623
+ function consolidateMarkdown(tempDir) {
624
+ let consolidated = "## Reference\n\n";
625
+ const mainReadmePath = PATH3.join(tempDir, "README.md");
626
+ if (FS.existsSync(mainReadmePath)) {
627
+ const mainContent = FS.readFileSync(mainReadmePath, "utf8").replace(/^---(.|\n)*?---\n/, "").replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
628
+ consolidated += mainContent + "\n\n";
629
+ }
630
+ consolidated += processDirectory(tempDir);
631
+ return consolidated.replaceAll(/\n\n\n+/g, "\n\n").replaceAll(/^#### /gm, "### ").replaceAll(/^##### /gm, "#### ").replaceAll(/^###### /gm, "##### ");
632
+ }
633
+ function processDirectory(dir, level = 0) {
634
+ const indent = " ".repeat(level);
635
+ let content = "";
636
+ try {
637
+ const items = FS.readdirSync(dir, { withFileTypes: true });
638
+ for (const item of items) {
639
+ if (item.isDirectory()) continue;
640
+ if (item.name === "README.md" || !item.name.endsWith(".md")) continue;
641
+ const fileContent = FS.readFileSync(PATH3.join(dir, item.name), "utf8").replace(/^---(.|\n)*?---\n/, "");
642
+ const moduleName = item.name.replace(".md", "");
643
+ content += `
644
+
645
+ ${indent}### <a id="${moduleName}"></a>${moduleName}
646
+
647
+ `;
648
+ content += fileContent.replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
649
+ }
650
+ for (const item of items) {
651
+ if (!item.isDirectory()) continue;
652
+ if (item.name === "spec" || item.name.includes(".spec")) continue;
653
+ content += `
654
+
655
+ ${indent}### ${item.name}
656
+ `;
657
+ content += processDirectory(PATH3.join(dir, item.name), level + 1);
658
+ }
659
+ } catch {
660
+ }
661
+ return content;
662
+ }
663
+ function askConfirmation(question) {
664
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
665
+ return new Promise((resolve) => {
666
+ rl.question(question, (answer) => {
667
+ rl.close();
668
+ resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
669
+ });
670
+ });
671
+ }
672
+ var DEFAULT_README_TEMPLATE = readFileSync6(PATH3.resolve(readmeTemplatesDir, "README.template.md"), "utf8");
673
+ var DEFAULT_README_BODY = readFileSync6(PATH3.resolve(readmeTemplatesDir, "README.body.md"), "utf8");
674
+ function applyLogoConfig(template, logoUrl, logoLinkUrl) {
675
+ let result = template;
676
+ if (logoUrl) {
677
+ result = result.replace(/\[logo]: .+/, `[logo]: ${logoUrl}`);
678
+ if (logoLinkUrl) {
679
+ result = result.replace(/\[!\[logo]\[]][^)]*\)/, `[![logo][]](${logoLinkUrl})`);
680
+ }
681
+ } else {
682
+ result = result.replace(/\[!\[logo]\[]][^\n]*\n*/, "");
683
+ result = result.replace(/\[logo]: [^\n]*\n?/, "");
684
+ }
685
+ return result;
686
+ }
687
+ function resolveTemplatePath(templatePath) {
688
+ const cwd = INIT_CWD();
689
+ return templatePath ?? PATH3.join(cwd, ".xy", "README.template.md");
690
+ }
691
+ async function loadOrCreateTemplate(resolvedTemplatePath) {
692
+ try {
693
+ const template = await readFile(resolvedTemplatePath, "utf8");
694
+ return { created: false, template };
695
+ } catch {
696
+ console.log(chalk6.yellow(`Template not found: ${resolvedTemplatePath}`));
697
+ const shouldCreate = await askConfirmation("Would you like to create a stock template? (y/N) ");
698
+ if (!shouldCreate) {
699
+ throw new Error("Template creation declined");
700
+ }
701
+ const template = DEFAULT_README_TEMPLATE;
702
+ await scaffoldTemplate(resolvedTemplatePath, template);
703
+ return { created: true, template };
704
+ }
705
+ }
706
+ async function scaffoldTemplate(resolvedTemplatePath, template) {
707
+ const xyDir = PATH3.dirname(resolvedTemplatePath);
708
+ await mkdir(xyDir, { recursive: true });
709
+ await writeFile(resolvedTemplatePath, template);
710
+ console.log(chalk6.green(`Created template: ${resolvedTemplatePath}`));
711
+ const bodyPath = PATH3.join(xyDir, "README.body.md");
712
+ await writeFile(bodyPath, DEFAULT_README_BODY);
713
+ console.log(chalk6.green(`Created body template: ${bodyPath}`));
714
+ }
715
+ async function resolveBody(location, defaultBody) {
716
+ const localBodyPath = PATH3.join(location, "README.body.md");
717
+ try {
718
+ return await readFile(localBodyPath, "utf8");
719
+ } catch {
720
+ return defaultBody;
721
+ }
722
+ }
723
+ async function generateReadmeForWorkspace(location, name, template, defaultBody, typedoc, verbose, pm) {
724
+ try {
725
+ const pkgJsonPath = PATH3.join(location, "package.json");
726
+ const pkgJson = JSON.parse(await readFile(pkgJsonPath, "utf8"));
727
+ const body = await resolveBody(location, defaultBody);
728
+ const typedocContent = typedoc ? await generateTypedoc(location, ["src/index*.ts"]) : "";
729
+ const readmeContent = fillReadmeTemplate(template, {
730
+ ...pkgJson,
731
+ body,
732
+ pm,
733
+ typedoc: typedocContent
734
+ });
735
+ await writeFile(PATH3.join(location, "README.md"), readmeContent);
736
+ if (verbose) console.log(chalk6.green(` ${name}`));
737
+ return true;
738
+ } catch (ex) {
739
+ const error = ex;
740
+ console.warn(chalk6.yellow(` Skipped ${location}: ${error.message}`));
741
+ return false;
742
+ }
743
+ }
744
+ async function loadDefaultBody(resolvedTemplatePath) {
745
+ const xyBodyPath = PATH3.join(PATH3.dirname(resolvedTemplatePath), "README.body.md");
746
+ try {
747
+ return await readFile(xyBodyPath, "utf8");
748
+ } catch {
749
+ return DEFAULT_README_BODY;
750
+ }
751
+ }
752
+ function flushResults(results) {
753
+ let failed = false;
754
+ for (const { output, success } of results) {
755
+ for (const line of output) {
756
+ process.stdout.write(line);
757
+ }
758
+ if (!success) failed = true;
759
+ }
760
+ return failed;
761
+ }
762
+ async function generateReadmeFiles({
763
+ jobs,
764
+ logoLinkUrl,
765
+ logoUrl,
766
+ pkg,
767
+ templatePath,
768
+ typedoc = false,
769
+ verbose = false
770
+ }) {
771
+ console.log(chalk6.green("Generate README Files"));
772
+ const resolvedTemplatePath = resolveTemplatePath(templatePath);
773
+ let template;
774
+ let templateCreated;
775
+ try {
776
+ ({ template, created: templateCreated } = await loadOrCreateTemplate(resolvedTemplatePath));
777
+ } catch {
778
+ return 1;
779
+ }
780
+ template = applyLogoConfig(template, logoUrl, logoLinkUrl);
781
+ if (templateCreated) {
782
+ console.log(chalk6.green("Generating README files for all packages..."));
783
+ }
784
+ const defaultBody = await loadDefaultBody(resolvedTemplatePath);
785
+ const pmName = detectPackageManager();
786
+ const pm = getPackageManager();
787
+ const singleWorkspace = pkg && !templateCreated ? pm.findWorkspace(pkg) : void 0;
788
+ const workspaces = singleWorkspace ? [singleWorkspace] : pm.listWorkspaces();
789
+ const concurrency = jobs;
790
+ const results = Array.from({ length: workspaces.length }, () => ({ output: [], success: true }));
791
+ installOutputCapture();
792
+ const start = performance.now();
793
+ await runWithConcurrency(
794
+ workspaces.map((ws, i) => ({ i, ws })),
795
+ concurrency,
796
+ async ({ i, ws }) => {
797
+ const output = [];
798
+ await outputStorage.run(output, async () => {
799
+ const success = await generateReadmeForWorkspace(ws.location, ws.name, template, defaultBody, typedoc, verbose, pmName);
800
+ results[i] = { output, success };
801
+ });
802
+ }
803
+ );
804
+ const failed = flushResults(results);
805
+ const ms = performance.now() - start;
806
+ console.log(chalk6.blue(`Generated ${workspaces.length} README(s) in ${ms.toFixed(0)}ms`));
807
+ return failed ? 1 : 0;
808
+ }
809
+
810
+ // src/lib/gitignoreTemplate.ts
811
+ import { readFileSync as readFileSync7 } from "fs";
812
+ import { createRequire as createRequire3 } from "module";
813
+ import PATH4 from "path";
814
+ var require4 = createRequire3(import.meta.url);
815
+ var packageRoot3 = PATH4.dirname(require4.resolve("@xylabs/ts-scripts-common/package.json"));
816
+ var templatesDir2 = PATH4.resolve(packageRoot3, "templates", "gitignore");
817
+ var gitignoreTemplate = () => readFileSync7(PATH4.resolve(templatesDir2, "template.gitignore"), "utf8");
818
+
819
+ // src/lib/latestVersions.ts
820
+ var latestVersions = {
821
+ node: "24.14.1",
822
+ nodeLtsCodename: "Krypton",
823
+ npm: "11.11.0",
824
+ pnpm: "10.33.0",
825
+ yarn: "4.13.0"
826
+ };
827
+
828
+ // src/lib/loadConfig.ts
829
+ import chalk7 from "chalk";
830
+ import { cosmiconfig } from "cosmiconfig";
831
+ import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
832
+ import deepmerge from "deepmerge";
833
+ var config;
834
+ var rootConfigPath;
835
+ var workspaceConfigCache = /* @__PURE__ */ new Map();
836
+ var deprecationWarned = /* @__PURE__ */ new Set();
837
+ function createExplorer() {
838
+ return cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } });
839
+ }
840
+ var loadConfig = async (params) => {
841
+ if (config === void 0) {
842
+ const cosmicConfigResult = await createExplorer().search();
843
+ config = cosmicConfigResult?.config ?? {};
844
+ rootConfigPath = cosmicConfigResult?.filepath;
845
+ const configFilePath = cosmicConfigResult?.filepath;
846
+ if (configFilePath !== void 0) {
847
+ console.log(chalk7.green(`Loaded config from ${configFilePath}`));
848
+ if (config.verbose) {
849
+ console.log(chalk7.gray(`${JSON.stringify(config, null, 2)}`));
850
+ }
851
+ }
852
+ }
853
+ return deepmerge(config, params ?? {});
854
+ };
855
+ async function loadWorkspaceConfig(workspaceDir) {
856
+ const cached = workspaceConfigCache.get(workspaceDir);
857
+ if (cached !== void 0) return cached;
858
+ const result = await createExplorer().search(workspaceDir);
859
+ if (!result || result.filepath === rootConfigPath) {
860
+ workspaceConfigCache.set(workspaceDir, {});
861
+ return {};
862
+ }
863
+ const wsConfig = result.config ?? {};
864
+ workspaceConfigCache.set(workspaceDir, wsConfig);
865
+ return wsConfig;
866
+ }
867
+ var DEPRECATED_COMMAND_FIELDS = /* @__PURE__ */ new Set(["deplint", "publint"]);
868
+ function resolveCommandField(cfg, commandName, configPath) {
869
+ const commands = cfg.commands;
870
+ const fromCommands = commands?.[commandName];
871
+ const fromTopLevel = cfg[commandName];
872
+ if (fromCommands !== void 0 && typeof fromCommands === "object") {
873
+ return fromCommands;
874
+ }
875
+ if (fromTopLevel !== void 0 && typeof fromTopLevel === "object" && DEPRECATED_COMMAND_FIELDS.has(commandName)) {
876
+ const key = `${configPath ?? "unknown"}:${commandName}`;
877
+ if (!deprecationWarned.has(key)) {
878
+ deprecationWarned.add(key);
879
+ console.warn(chalk7.yellow(
880
+ `[xy] Deprecated: top-level "${commandName}" in ${configPath ?? "xy.config"} \u2014 move to "commands.${commandName}"`
881
+ ));
882
+ }
883
+ return fromTopLevel;
884
+ }
885
+ return {};
886
+ }
887
+ async function loadWorkspaceCommandConfig(workspaceDir, commandName) {
888
+ const root = await loadConfig();
889
+ const rootCmd = resolveCommandField(root, commandName, rootConfigPath);
890
+ const wsConfig = await loadWorkspaceConfig(workspaceDir);
891
+ const wsConfigPath = workspaceConfigCache.has(workspaceDir) ? workspaceDir : void 0;
892
+ const wsCmd = resolveCommandField(wsConfig, commandName, wsConfigPath);
893
+ return deepmerge(rootCmd, wsCmd);
894
+ }
895
+
896
+ // src/lib/packageName.ts
897
+ import { readFileSync as readFileSync8 } from "fs";
898
+ import path from "path";
899
+ function packageName() {
900
+ if (process.env.npm_package_name) {
901
+ return process.env.npm_package_name;
902
+ }
903
+ try {
904
+ const pkgPath = path.join(INIT_CWD(), "package.json");
905
+ const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
906
+ return pkg.name;
907
+ } catch {
908
+ return void 0;
909
+ }
910
+ }
911
+
912
+ // src/lib/parsedPackageJSON.ts
913
+ import { readFileSync as readFileSync9 } from "fs";
914
+ var parsedPackageJSON = (path2) => {
915
+ const pathToPackageJSON = path2 ?? process.env.npm_package_json ?? "";
916
+ const packageJSON = readFileSync9(pathToPackageJSON).toString();
917
+ return JSON.parse(packageJSON);
918
+ };
919
+
920
+ // src/lib/repoTemplates.ts
921
+ import { readdirSync as readdirSync2, readFileSync as readFileSync10 } from "fs";
922
+ import { createRequire as createRequire4 } from "module";
923
+ import PATH5 from "path";
924
+ var require5 = createRequire4(import.meta.url);
925
+ var packageRoot4 = PATH5.dirname(require5.resolve("@xylabs/ts-scripts-common/package.json"));
926
+ var repoTemplatesDir = PATH5.resolve(packageRoot4, "templates", "repo");
927
+ function collectFiles(dir, prefix) {
928
+ const results = [];
929
+ for (const entry of readdirSync2(dir, { withFileTypes: true })) {
930
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
931
+ if (entry.isDirectory()) {
932
+ results.push(...collectFiles(PATH5.resolve(dir, entry.name), rel));
933
+ } else {
934
+ results.push({
935
+ content: readFileSync10(PATH5.resolve(dir, entry.name), "utf8"),
936
+ relativePath: rel
937
+ });
938
+ }
939
+ }
940
+ return results;
941
+ }
942
+ function loadRepoTemplateFiles(template, section) {
943
+ const dir = PATH5.resolve(repoTemplatesDir, template, section);
944
+ return collectFiles(dir, "");
945
+ }
946
+ function listRepoTemplates() {
947
+ return readdirSync2(repoTemplatesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
948
+ }
949
+
950
+ // src/lib/runInstall.ts
951
+ import { spawnSync as spawnSync3 } from "child_process";
952
+ import chalk8 from "chalk";
953
+ function runInstall(cwd) {
954
+ const pm = detectPackageManager();
955
+ console.log(chalk8.gray(`Running ${pm} install...`));
956
+ const result = spawnSync3(pm, ["install"], {
957
+ cwd,
958
+ stdio: "inherit"
959
+ });
960
+ if (result.status !== 0) {
961
+ console.warn(chalk8.yellow(`${pm} install failed`));
962
+ return false;
963
+ }
964
+ console.log(chalk8.green("Dependencies installed"));
965
+ return true;
966
+ }
967
+
968
+ // src/lib/runSteps.ts
969
+ import { spawnSync as spawnSync4 } from "child_process";
970
+ import { existsSync as existsSync4 } from "fs";
971
+ import chalk9 from "chalk";
972
+ var runSteps = (name, steps, exitOnFail = true, messages) => {
973
+ return safeExit(() => {
974
+ const pkgName = packageName();
975
+ console.log(chalk9.green(`${name} [${pkgName}]`));
976
+ let totalStatus = 0;
977
+ for (const [i, [command, args, config2]] of steps.entries()) {
978
+ if (messages?.[i]) {
979
+ console.log(chalk9.gray(messages?.[i]));
980
+ }
981
+ const argList = Array.isArray(args) ? args : args.split(" ");
982
+ if (command === "node" && !existsSync4(argList[0])) {
983
+ throw new Error(`File not found [${argList[0]}]`);
984
+ }
985
+ const status = spawnSync4(command, Array.isArray(args) ? args : args.split(" "), {
986
+ ...config2,
987
+ encoding: "utf8",
988
+ env: { FORCE_COLOR: "3", ...process.env },
989
+ shell: true,
990
+ stdio: "inherit"
991
+ }).status ?? 0;
992
+ checkResult(name, status, "error", exitOnFail);
993
+ totalStatus += status ?? 0;
994
+ }
995
+ return totalStatus;
996
+ }, !!exitOnFail);
997
+ };
998
+
999
+ // src/lib/runStepsAsync.ts
1000
+ import { spawn } from "child_process";
1001
+ import { existsSync as existsSync5 } from "fs";
1002
+ import chalk10 from "chalk";
1003
+ var runStepAsync = (name, step, exitOnFail = true, message) => {
1004
+ return new Promise((resolve) => {
1005
+ const [command, args, config2] = step;
1006
+ if (message) {
1007
+ console.log(chalk10.gray(message));
1008
+ }
1009
+ const argList = Array.isArray(args) ? args : args.split(" ");
1010
+ if (command === "node" && !existsSync5(argList[0])) {
1011
+ throw new Error(`File not found [${argList[0]}]`);
1012
+ }
1013
+ spawn(command, Array.isArray(args) ? args : args.split(" "), {
1014
+ ...config2,
1015
+ env: { FORCE_COLOR: "3", ...process.env },
1016
+ shell: true,
1017
+ stdio: "inherit"
1018
+ }).on("close", (code) => {
1019
+ if (code) {
1020
+ console.error(
1021
+ chalk10.red(
1022
+ `Command Exited With Non-Zero Result [${chalk10.gray(code)}] | ${chalk10.yellow(command)} ${chalk10.white(
1023
+ Array.isArray(args) ? args.join(" ") : args
1024
+ )}`
1025
+ )
1026
+ );
1027
+ checkResult(name, code, "error", exitOnFail);
1028
+ resolve(code);
1029
+ } else {
1030
+ resolve(0);
1031
+ }
1032
+ });
1033
+ });
1034
+ };
1035
+ var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
1036
+ return await safeExitAsync(async () => {
1037
+ const pkgName = packageName();
1038
+ console.log(chalk10.green(`${name} [${pkgName}]`));
1039
+ let result = 0;
1040
+ for (const [i, step] of steps.entries()) {
1041
+ result += await runStepAsync(name, step, exitOnFail, messages?.[i]);
1042
+ }
1043
+ return result;
1044
+ });
1045
+ };
1046
+
1047
+ // src/lib/runXy.ts
1048
+ var runXy = (command) => {
1049
+ const pm = getPackageManager();
1050
+ return runSteps(
1051
+ `XY [${command}]`,
1052
+ [pm.runXy([command, ...process.argv.filter((value, index) => index > 1 ? value : void 0)])]
1053
+ );
1054
+ };
1055
+
1056
+ // src/lib/runXyWithWarning.ts
1057
+ import chalk11 from "chalk";
1058
+ var runXyWithWarning = (command) => {
1059
+ const pm = getPackageManager();
1060
+ const commandString = `${pm.command} ${command}`;
1061
+ const commandXyString = `${pm.command} xy ${command}`;
1062
+ console.warn(chalk11.yellow(`WARNING: [${chalk11.white(commandString)}] is deprecated for XY Labs Scripts.`));
1063
+ console.warn(chalk11.gray(`Did you mean [${chalk11.magenta(commandXyString)}]?`));
1064
+ return 1;
1065
+ };
1066
+
1067
+ // src/lib/tryRunLocalScript.ts
1068
+ import { spawnSync as spawnSync5 } from "child_process";
1069
+ import { readFileSync as readFileSync11 } from "fs";
1070
+ import PATH6 from "path";
1071
+ import chalk12 from "chalk";
1072
+ function tryRunLocalScript(commandName) {
1073
+ if (process.env.XY_LOCAL_SCRIPT === "1") return void 0;
1074
+ const rootPkgPath = PATH6.resolve(process.cwd(), "package.json");
1075
+ let rootPkg;
1076
+ try {
1077
+ rootPkg = JSON.parse(readFileSync11(rootPkgPath, "utf8"));
1078
+ } catch {
1079
+ return void 0;
1080
+ }
1081
+ if (!rootPkg.scripts?.[commandName]) return void 0;
1082
+ const extraArgs = process.argv.slice(process.argv.indexOf(commandName) + 1);
1083
+ console.log(chalk12.blue(`Delegating "${commandName}" to local script`));
1084
+ const pm = getPackageManager();
1085
+ const result = spawnSync5(pm.command, ["run", commandName, ...extraArgs], {
1086
+ cwd: process.cwd(),
1087
+ encoding: "utf8",
1088
+ env: {
1089
+ FORCE_COLOR: "3",
1090
+ ...process.env,
1091
+ XY_LOCAL_SCRIPT: "1"
1092
+ },
1093
+ shell: true,
1094
+ stdio: "inherit"
1095
+ });
1096
+ return result.status ?? 1;
1097
+ }
1098
+
1099
+ // src/lib/updo/applyUpdates.ts
1100
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync2 } from "fs";
1101
+ import PATH7 from "path";
1102
+ import chalk13 from "chalk";
1103
+ function applyUpdates(cwd, workspaces, updates) {
1104
+ const updateMap = new Map(updates.map((u) => [u.name, u]));
1105
+ let modified = 0;
1106
+ for (const ws of workspaces) {
1107
+ const pkgPath = PATH7.resolve(cwd, ws.location, "package.json");
1108
+ let content;
1109
+ try {
1110
+ content = readFileSync12(pkgPath, "utf8");
1111
+ } catch {
1112
+ continue;
1113
+ }
1114
+ const pkg = JSON.parse(content);
1115
+ let changed = false;
1116
+ for (const depField of ["dependencies", "devDependencies", "peerDependencies"]) {
1117
+ const deps = pkg[depField];
1118
+ if (!deps) continue;
1119
+ for (const [name, currentRange] of Object.entries(deps)) {
1120
+ const update = updateMap.get(name);
1121
+ if (!update) continue;
1122
+ const prefix = /^([~^]|>=?|<=?)/.exec(currentRange)?.[0] ?? "~";
1123
+ const newRange = `${prefix}${update.targetVersion}`;
1124
+ if (deps[name] !== newRange) {
1125
+ deps[name] = newRange;
1126
+ changed = true;
1127
+ }
1128
+ }
1129
+ }
1130
+ if (changed) {
1131
+ writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
1132
+ `);
1133
+ modified++;
1134
+ console.log(chalk13.gray(` Updated ${ws.name}`));
1135
+ }
1136
+ }
1137
+ return modified;
1138
+ }
1139
+
1140
+ // src/lib/updo/collectWorkspaceDeps.ts
1141
+ import { readFileSync as readFileSync13 } from "fs";
1142
+ import PATH8 from "path";
1143
+ var DEP_FIELDS = ["dependencies", "devDependencies", "peerDependencies"];
1144
+ function collectWorkspaceDeps(cwd, workspaces, workspaceNames) {
1145
+ const depMap = /* @__PURE__ */ new Map();
1146
+ for (const ws of workspaces) {
1147
+ const pkgPath = PATH8.resolve(cwd, ws.location, "package.json");
1148
+ let pkg;
1149
+ try {
1150
+ pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
1151
+ } catch {
1152
+ continue;
1153
+ }
1154
+ for (const depField of DEP_FIELDS) {
1155
+ const deps = pkg[depField];
1156
+ if (!deps) continue;
1157
+ for (const [name, range] of Object.entries(deps)) {
1158
+ if (workspaceNames.has(name)) continue;
1159
+ if (range.startsWith("workspace:")) continue;
1160
+ const existing = depMap.get(name);
1161
+ if (existing) {
1162
+ if (!existing.workspaces.includes(ws.name)) {
1163
+ existing.workspaces.push(ws.name);
1164
+ }
1165
+ if (!existing.depTypes.includes(depField)) {
1166
+ existing.depTypes.push(depField);
1167
+ }
1168
+ if (!existing.ranges.includes(range)) {
1169
+ existing.ranges.push(range);
1170
+ }
1171
+ } else {
1172
+ depMap.set(name, {
1173
+ depTypes: [depField],
1174
+ name,
1175
+ ranges: [range],
1176
+ workspaces: [ws.name]
1177
+ });
1178
+ }
1179
+ }
1180
+ }
1181
+ }
1182
+ return depMap;
1183
+ }
1184
+
1185
+ // src/lib/updo/fetchRegistryInfo.ts
1186
+ var REGISTRY_BASE = "https://registry.npmjs.org";
1187
+ async function fetchRegistryInfo(packageName2) {
1188
+ try {
1189
+ const url = `${REGISTRY_BASE}/${encodeURIComponent(packageName2)}`;
1190
+ const res = await fetch(url, { headers: { Accept: "application/vnd.npm.install-v1+json" } });
1191
+ if (!res.ok) {
1192
+ return { distTags: {}, versions: [] };
1193
+ }
1194
+ const data = await res.json();
1195
+ return {
1196
+ distTags: data["dist-tags"] ?? {},
1197
+ versions: Object.keys(data.versions ?? {})
1198
+ };
1199
+ } catch {
1200
+ return { distTags: {}, versions: [] };
1201
+ }
1202
+ }
1203
+ async function fetchAllRegistryInfo(packageNames, concurrency = 16) {
1204
+ const results = /* @__PURE__ */ new Map();
1205
+ let completed = 0;
1206
+ const total = packageNames.length;
1207
+ await runWithConcurrency(packageNames, concurrency, async (name) => {
1208
+ results.set(name, await fetchRegistryInfo(name));
1209
+ completed++;
1210
+ if (completed % 25 === 0 || completed === total) {
1211
+ process.stderr.write(`\r Fetched ${completed}/${total} packages...`);
1212
+ }
1213
+ });
1214
+ if (total > 0) {
1215
+ process.stderr.write("\n");
1216
+ }
1217
+ return results;
1218
+ }
1219
+
1220
+ // src/lib/updo/interactiveSelect.ts
1221
+ import {
1222
+ createPrompt,
1223
+ ExitPromptError,
1224
+ isDownKey,
1225
+ isEnterKey,
1226
+ isSpaceKey,
1227
+ isUpKey,
1228
+ useKeypress,
1229
+ useRef,
1230
+ useState
1231
+ } from "@inquirer/core";
1232
+ import chalk14 from "chalk";
1233
+ import semver from "semver";
1234
+ function versionColor(version, current) {
1235
+ if (!version || !current) return chalk14.gray;
1236
+ if (version === current) return chalk14.gray;
1237
+ const diff = semver.diff(current, version);
1238
+ if (diff === "major" || diff === "premajor") return chalk14.red;
1239
+ if (diff === "minor" || diff === "preminor") return chalk14.yellow;
1240
+ return chalk14.green;
1241
+ }
1242
+ function pad(raw, colored, width) {
1243
+ return colored + " ".repeat(Math.max(0, width - raw.length));
1244
+ }
1245
+ function dot(selected) {
1246
+ return selected ? chalk14.green("\u25CF") : chalk14.dim("\u25CB");
1247
+ }
1248
+ function renderHeader(w) {
1249
+ const header = [
1250
+ " ",
1251
+ chalk14.bold("Package".padEnd(w.name)),
1252
+ chalk14.bold("Current".padEnd(w.current)),
1253
+ chalk14.bold(" Wanted".padEnd(w.wanted + 2)),
1254
+ chalk14.bold(" Latest".padEnd(w.latest + 2)),
1255
+ chalk14.bold(" Next/RC".padEnd(w.next + 2))
1256
+ ].join(" ");
1257
+ const totalWidth = w.name + w.current + w.wanted + w.latest + w.next + 24;
1258
+ return `${header}
1259
+ ${chalk14.gray("\u2500".repeat(totalWidth))}`;
1260
+ }
1261
+ function renderRow(dep, selection, active, w) {
1262
+ const pointer = active ? chalk14.cyan("\u276F") : " ";
1263
+ const rawName = dep.name;
1264
+ const name = active ? chalk14.white(rawName) : chalk14.gray(rawName);
1265
+ const rawCurrent = dep.current ?? "-";
1266
+ const current = chalk14.gray(rawCurrent);
1267
+ const rawWanted = dep.wanted ?? "-";
1268
+ const wantedColorFn = dep.wanted ? versionColor(dep.wanted, dep.current) : chalk14.gray;
1269
+ const wantedDot = dep.wanted ? dot(selection === 0) : " ";
1270
+ const wanted = `${wantedDot} ${pad(rawWanted, wantedColorFn(rawWanted), w.wanted)}`;
1271
+ const rawLatest = dep.latest ?? "-";
1272
+ const latestColorFn = dep.latest ? versionColor(dep.latest, dep.current) : chalk14.gray;
1273
+ const latestDot = dep.latest ? dot(selection === 1) : " ";
1274
+ const latest = `${latestDot} ${pad(rawLatest, latestColorFn(rawLatest), w.latest)}`;
1275
+ const rawNext = dep.next ?? "-";
1276
+ const nextColorFn = dep.next ? versionColor(dep.next, dep.current) : chalk14.gray;
1277
+ const nextDot = dep.next ? dot(selection === 2) : " ";
1278
+ const next = `${nextDot} ${pad(rawNext, nextColorFn(rawNext), w.next)}`;
1279
+ return `${pointer} ${pad(rawName, name, w.name)} ${pad(rawCurrent, current, w.current)} ${wanted} ${latest} ${next}`;
1280
+ }
1281
+ function getAvailableSelections(dep) {
1282
+ const available = [-1];
1283
+ if (dep.wanted) available.push(0);
1284
+ if (dep.latest && dep.latest !== dep.wanted) available.push(1);
1285
+ if (dep.next) available.push(2);
1286
+ return available;
1287
+ }
1288
+ function getTargetVersion(dep, selection) {
1289
+ if (selection === 0) return dep.wanted;
1290
+ if (selection === 1) return dep.latest;
1291
+ if (selection === 2) return dep.next;
1292
+ return void 0;
1293
+ }
1294
+ function computeWidths(rows) {
1295
+ let name = 7;
1296
+ let current = 7;
1297
+ let wanted = 6;
1298
+ let latest = 6;
1299
+ let next = 7;
1300
+ for (const dep of rows) {
1301
+ name = Math.max(name, dep.name.length);
1302
+ current = Math.max(current, (dep.current ?? "-").length);
1303
+ wanted = Math.max(wanted, (dep.wanted ?? "-").length);
1304
+ latest = Math.max(latest, (dep.latest ?? "-").length);
1305
+ next = Math.max(next, (dep.next ?? "-").length);
1306
+ }
1307
+ return {
1308
+ current,
1309
+ latest,
1310
+ name,
1311
+ next,
1312
+ wanted
1313
+ };
1314
+ }
1315
+ function renderPage(rows, cursor, selections, w, pageSize) {
1316
+ const total = rows.length;
1317
+ let start = 0;
1318
+ if (total > pageSize) {
1319
+ start = Math.max(0, Math.min(cursor - Math.floor(pageSize / 2), total - pageSize));
1320
+ }
1321
+ const end = Math.min(start + pageSize, total);
1322
+ const lines = [];
1323
+ for (let i = start; i < end; i++) {
1324
+ lines.push(renderRow(rows[i], selections[i], i === cursor, w));
1325
+ }
1326
+ if (total > pageSize) {
1327
+ if (start > 0) lines.unshift(chalk14.dim(" \u2191 more"));
1328
+ if (end < total) lines.push(chalk14.dim(" \u2193 more"));
1329
+ }
1330
+ return lines.join("\n");
1331
+ }
1332
+ var updoPrompt = createPrompt((config2, done) => {
1333
+ const { rows } = config2;
1334
+ const [cursor, setCursor] = useState(0);
1335
+ const [tick, setTick] = useState(0);
1336
+ const availableSelections = useRef(rows.map((r) => getAvailableSelections(r)));
1337
+ const selections = useRef(rows.map(() => -1));
1338
+ const widths = useRef(computeWidths(rows));
1339
+ useKeypress((key) => {
1340
+ if (key.name === "escape" || key.ctrl && key.name === "c") {
1341
+ done([]);
1342
+ return;
1343
+ }
1344
+ if (isEnterKey(key)) {
1345
+ const results = [];
1346
+ for (const [i, dep] of rows.entries()) {
1347
+ const version = getTargetVersion(dep, selections.current[i]);
1348
+ if (version) {
1349
+ results.push({
1350
+ depTypes: dep.depTypes,
1351
+ name: dep.name,
1352
+ targetVersion: version,
1353
+ workspaces: dep.workspaces
1354
+ });
1355
+ }
1356
+ }
1357
+ done(results);
1358
+ return;
1359
+ }
1360
+ if (isUpKey(key)) {
1361
+ setCursor(Math.max(0, cursor - 1));
1362
+ } else if (isDownKey(key)) {
1363
+ setCursor(Math.min(rows.length - 1, cursor + 1));
1364
+ } else if (isSpaceKey(key)) {
1365
+ const available = availableSelections.current[cursor];
1366
+ const currentSel = selections.current[cursor];
1367
+ const currentIdx = available.indexOf(currentSel);
1368
+ const nextIdx = (currentIdx + 1) % available.length;
1369
+ selections.current[cursor] = available[nextIdx];
1370
+ setTick(tick + 1);
1371
+ }
1372
+ });
1373
+ const w = widths.current;
1374
+ const header = renderHeader(w);
1375
+ const page = renderPage(rows, cursor, selections.current, w, 20);
1376
+ const selectedCount = selections.current.filter((s) => s >= 0).length;
1377
+ const status = chalk14.gray(` ${selectedCount} selected \u2191/\u2193 navigate space cycle version enter confirm`);
1378
+ return `${header}
1379
+ ${page}
1380
+ ${status}`;
1381
+ });
1382
+ async function interactiveSelect(deps) {
1383
+ const updatable = deps.filter((d) => d.updateAvailable);
1384
+ if (updatable.length === 0) {
1385
+ console.log(chalk14.green("\nAll packages are up to date!"));
1386
+ return [];
1387
+ }
1388
+ if (!process.stdout.isTTY) {
1389
+ console.log(chalk14.yellow("Non-interactive environment detected, skipping selection."));
1390
+ return [];
1391
+ }
1392
+ try {
1393
+ return await updoPrompt({ rows: updatable });
1394
+ } catch (error) {
1395
+ if (error instanceof ExitPromptError) {
1396
+ return [];
1397
+ }
1398
+ throw error;
1399
+ }
1400
+ }
1401
+
1402
+ // src/lib/updo/renderTable.ts
1403
+ import chalk15 from "chalk";
1404
+ import semver2 from "semver";
1405
+ function versionColor2(version, current) {
1406
+ if (!version || !current) return chalk15.gray(version ?? "-");
1407
+ if (version === current) return chalk15.gray(version);
1408
+ const diff = semver2.diff(current, version);
1409
+ if (diff === "major" || diff === "premajor") return chalk15.red(version);
1410
+ if (diff === "minor" || diff === "preminor") return chalk15.yellow(version);
1411
+ return chalk15.green(version);
1412
+ }
1413
+ var columns = [
1414
+ {
1415
+ color: (_v, dep) => dep.updateAvailable ? chalk15.white(dep.name) : chalk15.gray(dep.name),
1416
+ header: "Package",
1417
+ value: (dep) => dep.name
1418
+ },
1419
+ {
1420
+ color: (_v, dep) => chalk15.gray(dep.current ?? "-"),
1421
+ header: "Current",
1422
+ value: (dep) => dep.current ?? "-"
1423
+ },
1424
+ {
1425
+ color: (_v, dep) => versionColor2(dep.wanted, dep.current),
1426
+ header: "Wanted",
1427
+ value: (dep) => dep.wanted ?? "-"
1428
+ },
1429
+ {
1430
+ color: (_v, dep) => versionColor2(dep.latest, dep.current),
1431
+ header: "Latest",
1432
+ value: (dep) => dep.latest ?? "-"
1433
+ },
1434
+ {
1435
+ color: (_v, dep) => versionColor2(dep.next, dep.current),
1436
+ header: "Next/RC",
1437
+ value: (dep) => dep.next ?? "-"
1438
+ },
1439
+ {
1440
+ color: (_v, dep) => chalk15.gray(dep.depTypes.join(", ")),
1441
+ header: "Type",
1442
+ value: (dep) => dep.depTypes.join(", ")
1443
+ }
1444
+ ];
1445
+ function renderTable(deps) {
1446
+ const updatable = deps.filter((d) => d.updateAvailable);
1447
+ if (updatable.length === 0) {
1448
+ console.log(chalk15.green("\nAll packages are up to date!"));
1449
+ return;
1450
+ }
1451
+ const widths = columns.map((col) => {
1452
+ let maxData = 0;
1453
+ for (const dep of updatable) {
1454
+ maxData = Math.max(maxData, col.value(dep).length);
1455
+ }
1456
+ return Math.max(col.header.length, maxData);
1457
+ });
1458
+ const header = columns.map((col, i) => chalk15.bold(col.header.padEnd(widths[i]))).join(" ");
1459
+ console.log(`
1460
+ ${header}`);
1461
+ let totalWidth = -2;
1462
+ for (const w of widths) {
1463
+ totalWidth += w + 2;
1464
+ }
1465
+ console.log(chalk15.gray("\u2500".repeat(totalWidth)));
1466
+ for (const dep of updatable) {
1467
+ const row = columns.map((col, i) => {
1468
+ const raw = col.value(dep);
1469
+ const colored = col.color(raw, dep);
1470
+ const padding = widths[i] - raw.length;
1471
+ return colored + " ".repeat(Math.max(0, padding));
1472
+ }).join(" ");
1473
+ console.log(row);
1474
+ }
1475
+ console.log();
1476
+ }
1477
+
1478
+ // src/lib/updo/resolveVersions.ts
1479
+ import semver3 from "semver";
1480
+ function computeWanted(info, ranges) {
1481
+ const candidates = ranges.map((range) => semver3.maxSatisfying(info.versions, range));
1482
+ const valid = candidates.filter((v) => v !== null);
1483
+ if (valid.length === 0) return void 0;
1484
+ let min = valid[0];
1485
+ for (const v of valid) {
1486
+ if (semver3.lt(v, min)) min = v;
1487
+ }
1488
+ return min;
1489
+ }
1490
+ function hasNewerVersion(version, current) {
1491
+ return version !== void 0 && semver3.gt(version, current);
1492
+ }
1493
+ function isUpdateAvailable(current, wanted, latest, next) {
1494
+ if (!current) return false;
1495
+ return hasNewerVersion(wanted, current) || hasNewerVersion(latest, current) || hasNewerVersion(next, current);
1496
+ }
1497
+ function resolveVersions(deps, registry, installedVersions) {
1498
+ const resolved = [];
1499
+ for (const [name, dep] of deps) {
1500
+ const info = registry.get(name);
1501
+ const current = installedVersions.get(name);
1502
+ const wanted = info ? computeWanted(info, dep.ranges) : void 0;
1503
+ const latest = info?.distTags.latest;
1504
+ const next = info?.distTags.next ?? info?.distTags.rc;
1505
+ const updateAvailable = isUpdateAvailable(current, wanted, latest, next);
1506
+ resolved.push({
1507
+ current,
1508
+ declaredRange: dep.ranges.length === 1 ? dep.ranges[0] : dep.ranges.join(" | "),
1509
+ depTypes: dep.depTypes,
1510
+ latest,
1511
+ name,
1512
+ next: next && latest && next !== latest ? next : void 0,
1513
+ updateAvailable,
1514
+ wanted: wanted && current && wanted !== current ? wanted : void 0,
1515
+ workspaces: dep.workspaces
1516
+ });
1517
+ }
1518
+ return resolved.toSorted((a, b) => {
1519
+ if (a.updateAvailable !== b.updateAvailable) return a.updateAvailable ? -1 : 1;
1520
+ return a.name.localeCompare(b.name);
1521
+ });
1522
+ }
1523
+
1524
+ // src/lib/updo/runUpdo.ts
1525
+ import chalk16 from "chalk";
1526
+ async function runUpdo(pm, _options = {}) {
1527
+ const cwd = INIT_CWD();
1528
+ const workspaces = pm.listWorkspaces();
1529
+ const workspaceNames = new Set(workspaces.map((ws) => ws.name));
1530
+ console.log(chalk16.gray("Scanning workspace dependencies..."));
1531
+ const declaredDeps = collectWorkspaceDeps(cwd, workspaces, workspaceNames);
1532
+ console.log(chalk16.gray(` Found ${declaredDeps.size} unique dependencies across ${workspaces.length} workspaces`));
1533
+ console.log(chalk16.gray("Fetching registry info..."));
1534
+ const registryInfo = await fetchAllRegistryInfo([...declaredDeps.keys()]);
1535
+ console.log(chalk16.gray("Reading installed versions..."));
1536
+ const installedVersions = pm.listInstalledVersions();
1537
+ const resolved = resolveVersions(declaredDeps, registryInfo, installedVersions);
1538
+ const updates = await interactiveSelect(resolved);
1539
+ if (updates.length === 0) {
1540
+ console.log(chalk16.gray("No updates selected."));
1541
+ return 0;
1542
+ }
1543
+ console.log(chalk16.gray(`
1544
+ Applying ${updates.length} updates...`));
1545
+ const modified = applyUpdates(cwd, workspaces, updates);
1546
+ console.log(chalk16.gray(` Modified ${modified} package.json files`));
1547
+ console.log(chalk16.gray("Installing updated dependencies..."));
1548
+ return runSteps("Updo", [
1549
+ pm.install(),
1550
+ pm.dedupe()
1551
+ ], true);
1552
+ }
1553
+ export {
1554
+ CROSS_PLATFORM_NEWLINE,
1555
+ DEFAULT_README_BODY,
1556
+ DEFAULT_README_TEMPLATE,
1557
+ DuplicateDetector,
1558
+ INIT_CWD,
1559
+ LEGACY_COMMANDS_PREFIX,
1560
+ WINDOWS_NEWLINE_REGEX,
1561
+ XYLABS_COMMANDS_PREFIX,
1562
+ XYLABS_RULES_PREFIX,
1563
+ XYLABS_SKILLS_PREFIX,
1564
+ applyLogoConfig,
1565
+ applyPackageManager,
1566
+ applyUpdates,
1567
+ checkResult,
1568
+ claudeCommandTemplates,
1569
+ claudeMdLocalTemplate,
1570
+ claudeMdProjectTemplate,
1571
+ claudeMdRuleTemplates,
1572
+ claudeSkillTemplates,
1573
+ collectWorkspaceDeps,
1574
+ createBuildConfig,
1575
+ defaultBuildConfig,
1576
+ defaultReadFileSyncOptions,
1577
+ deleteGlob,
1578
+ detectDuplicateDependencies,
1579
+ detectWorkspaceCycles,
1580
+ empty,
1581
+ fetchAllRegistryInfo,
1582
+ fetchRegistryInfo,
1583
+ fillTemplate,
1584
+ generateIgnoreFiles,
1585
+ generateReadmeFiles,
1586
+ gitignoreTemplate,
1587
+ installOutputCapture,
1588
+ interactiveSelect,
1589
+ isYarnVersionOrGreater,
1590
+ latestVersions,
1591
+ listRepoTemplates,
1592
+ loadConfig,
1593
+ loadRepoTemplateFiles,
1594
+ loadWorkspaceCommandConfig,
1595
+ multiLineToJSONArray,
1596
+ notEmpty,
1597
+ outputStorage,
1598
+ packageName,
1599
+ parsedPackageJSON,
1600
+ printWorkspaceCycles,
1601
+ processEx,
1602
+ readLines,
1603
+ readNonEmptyLines,
1604
+ renderTable,
1605
+ resolveTemplatePath,
1606
+ resolveVersions,
1607
+ runInstall,
1608
+ runStepAsync,
1609
+ runSteps,
1610
+ runStepsAsync,
1611
+ runUpdo,
1612
+ runWithConcurrency,
1613
+ runXy,
1614
+ runXyWithWarning,
1615
+ safeExit,
1616
+ safeExitAsync,
1617
+ scaffoldTemplate,
1618
+ tryReadFileSync,
1619
+ tryRunLocalScript,
1620
+ union,
1621
+ withErrnoException,
1622
+ withError,
1623
+ writeLines,
1624
+ yarnWorkspace,
1625
+ yarnWorkspaces
1626
+ };
1627
+ //# sourceMappingURL=index.mjs.map