@xylabs/ts-scripts-common 7.5.0

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