@xylabs/toolchain 7.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (622) hide show
  1. package/dist/actions/analyze.mjs +140 -0
  2. package/dist/actions/analyze.mjs.map +1 -0
  3. package/dist/actions/build.mjs +173 -0
  4. package/dist/actions/build.mjs.map +1 -0
  5. package/dist/actions/claude-check.mjs +199 -0
  6. package/dist/actions/claude-check.mjs.map +1 -0
  7. package/dist/actions/claude-clean.mjs +70 -0
  8. package/dist/actions/claude-clean.mjs.map +1 -0
  9. package/dist/actions/claude-commands.mjs +126 -0
  10. package/dist/actions/claude-commands.mjs.map +1 -0
  11. package/dist/actions/claude-rules.mjs +151 -0
  12. package/dist/actions/claude-rules.mjs.map +1 -0
  13. package/dist/actions/claude-settings.mjs +99 -0
  14. package/dist/actions/claude-settings.mjs.map +1 -0
  15. package/dist/actions/claude-skills.mjs +131 -0
  16. package/dist/actions/claude-skills.mjs.map +1 -0
  17. package/dist/actions/clean-docs.mjs +66 -0
  18. package/dist/actions/clean-docs.mjs.map +1 -0
  19. package/dist/actions/clean-eslint.mjs +47 -0
  20. package/dist/actions/clean-eslint.mjs.map +1 -0
  21. package/dist/actions/clean.mjs +166 -0
  22. package/dist/actions/clean.mjs.map +1 -0
  23. package/dist/actions/compile.mjs +184 -0
  24. package/dist/actions/compile.mjs.map +1 -0
  25. package/dist/actions/copy-assets.mjs +81 -0
  26. package/dist/actions/copy-assets.mjs.map +1 -0
  27. package/dist/actions/cycle.mjs +275 -0
  28. package/dist/actions/cycle.mjs.map +1 -0
  29. package/dist/actions/dead.mjs +119 -0
  30. package/dist/actions/dead.mjs.map +1 -0
  31. package/dist/actions/deplint/checkPackage/checkPackage.mjs +1556 -0
  32. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -0
  33. package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs +1 -0
  34. package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs.map +1 -0
  35. package/dist/actions/deplint/checkPackage/getMismatchedPeerDevVersions.mjs +77 -0
  36. package/dist/actions/deplint/checkPackage/getMismatchedPeerDevVersions.mjs.map +1 -0
  37. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +158 -0
  38. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -0
  39. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +125 -0
  40. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -0
  41. package/dist/actions/deplint/checkPackage/getUnnecessaryPeerDependencies.mjs +207 -0
  42. package/dist/actions/deplint/checkPackage/getUnnecessaryPeerDependencies.mjs.map +1 -0
  43. package/dist/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.mjs +318 -0
  44. package/dist/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.mjs.map +1 -0
  45. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +163 -0
  46. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -0
  47. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +408 -0
  48. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
  49. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +75 -0
  50. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -0
  51. package/dist/actions/deplint/checkPackage/getWorkspaceVersionProblems.mjs +128 -0
  52. package/dist/actions/deplint/checkPackage/getWorkspaceVersionProblems.mjs.map +1 -0
  53. package/dist/actions/deplint/checkPackage/index.mjs +1609 -0
  54. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -0
  55. package/dist/actions/deplint/deplint.mjs +1840 -0
  56. package/dist/actions/deplint/deplint.mjs.map +1 -0
  57. package/dist/actions/deplint/engine.mjs +1736 -0
  58. package/dist/actions/deplint/engine.mjs.map +1 -0
  59. package/dist/actions/deplint/findFiles.mjs +39 -0
  60. package/dist/actions/deplint/findFiles.mjs.map +1 -0
  61. package/dist/actions/deplint/findFilesByGlob.mjs +14 -0
  62. package/dist/actions/deplint/findFilesByGlob.mjs.map +1 -0
  63. package/dist/actions/deplint/fixer.mjs +103 -0
  64. package/dist/actions/deplint/fixer.mjs.map +1 -0
  65. package/dist/actions/deplint/getBasePackageName.mjs +13 -0
  66. package/dist/actions/deplint/getBasePackageName.mjs.map +1 -0
  67. package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs +140 -0
  68. package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs.map +1 -0
  69. package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +29 -0
  70. package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +1 -0
  71. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +68 -0
  72. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +1 -0
  73. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +143 -0
  74. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -0
  75. package/dist/actions/deplint/getImportsFromFile.mjs +85 -0
  76. package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -0
  77. package/dist/actions/deplint/getRequiredPeerDependencies.mjs +37 -0
  78. package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +1 -0
  79. package/dist/actions/deplint/getScriptReferencedPackages.mjs +83 -0
  80. package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -0
  81. package/dist/actions/deplint/implicitDevDependencies.mjs +116 -0
  82. package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
  83. package/dist/actions/deplint/index.mjs +1848 -0
  84. package/dist/actions/deplint/index.mjs.map +1 -0
  85. package/dist/actions/deplint/packageEditor.mjs +82 -0
  86. package/dist/actions/deplint/packageEditor.mjs.map +1 -0
  87. package/dist/actions/deplint/packageJsonEditor.mjs +101 -0
  88. package/dist/actions/deplint/packageJsonEditor.mjs.map +1 -0
  89. package/dist/actions/deplint/reporters.mjs +36 -0
  90. package/dist/actions/deplint/reporters.mjs.map +1 -0
  91. package/dist/actions/deplint/rules.mjs +1223 -0
  92. package/dist/actions/deplint/rules.mjs.map +1 -0
  93. package/dist/actions/deplint/snapshot.mjs +372 -0
  94. package/dist/actions/deplint/snapshot.mjs.map +1 -0
  95. package/dist/actions/deplint/tsScriptsAliases.mjs +20 -0
  96. package/dist/actions/deplint/tsScriptsAliases.mjs.map +1 -0
  97. package/dist/actions/deplint/types.mjs +1 -0
  98. package/dist/actions/deplint/types.mjs.map +1 -0
  99. package/dist/actions/deploy.mjs +194 -0
  100. package/dist/actions/deploy.mjs.map +1 -0
  101. package/dist/actions/dupdeps.mjs +226 -0
  102. package/dist/actions/dupdeps.mjs.map +1 -0
  103. package/dist/actions/eject.mjs +142 -0
  104. package/dist/actions/eject.mjs.map +1 -0
  105. package/dist/actions/fix.mjs +359 -0
  106. package/dist/actions/fix.mjs.map +1 -0
  107. package/dist/actions/gen-docs.mjs +155 -0
  108. package/dist/actions/gen-docs.mjs.map +1 -0
  109. package/dist/actions/gitignore.mjs +159 -0
  110. package/dist/actions/gitignore.mjs.map +1 -0
  111. package/dist/actions/gitlint-fix.mjs +27 -0
  112. package/dist/actions/gitlint-fix.mjs.map +1 -0
  113. package/dist/actions/gitlint.mjs +48 -0
  114. package/dist/actions/gitlint.mjs.map +1 -0
  115. package/dist/actions/index.mjs +8259 -0
  116. package/dist/actions/index.mjs.map +1 -0
  117. package/dist/actions/knip.mjs +119 -0
  118. package/dist/actions/knip.mjs.map +1 -0
  119. package/dist/actions/license.mjs +92 -0
  120. package/dist/actions/license.mjs.map +1 -0
  121. package/dist/actions/lint-init.mjs +275 -0
  122. package/dist/actions/lint-init.mjs.map +1 -0
  123. package/dist/actions/lint.mjs +356 -0
  124. package/dist/actions/lint.mjs.map +1 -0
  125. package/dist/actions/lintNext.mjs +209 -0
  126. package/dist/actions/lintNext.mjs.map +1 -0
  127. package/dist/actions/lintlint.mjs +341 -0
  128. package/dist/actions/lintlint.mjs.map +1 -0
  129. package/dist/actions/npmignore-gen.mjs +90 -0
  130. package/dist/actions/npmignore-gen.mjs.map +1 -0
  131. package/dist/actions/orphan.mjs +110 -0
  132. package/dist/actions/orphan.mjs.map +1 -0
  133. package/dist/actions/package/clean-outputs.mjs +50 -0
  134. package/dist/actions/package/clean-outputs.mjs.map +1 -0
  135. package/dist/actions/package/clean-typescript.mjs +50 -0
  136. package/dist/actions/package/clean-typescript.mjs.map +1 -0
  137. package/dist/actions/package/clean.mjs +69 -0
  138. package/dist/actions/package/clean.mjs.map +1 -0
  139. package/dist/actions/package/compile/XyConfig.mjs +32 -0
  140. package/dist/actions/package/compile/XyConfig.mjs.map +1 -0
  141. package/dist/actions/package/compile/buildEntries.mjs +53 -0
  142. package/dist/actions/package/compile/buildEntries.mjs.map +1 -0
  143. package/dist/actions/package/compile/compile.mjs +439 -0
  144. package/dist/actions/package/compile/compile.mjs.map +1 -0
  145. package/dist/actions/package/compile/copyTypeFiles.mjs +34 -0
  146. package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -0
  147. package/dist/actions/package/compile/deepMerge.mjs +27 -0
  148. package/dist/actions/package/compile/deepMerge.mjs.map +1 -0
  149. package/dist/actions/package/compile/getCompilerOptions.mjs +12 -0
  150. package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -0
  151. package/dist/actions/package/compile/index.mjs +472 -0
  152. package/dist/actions/package/compile/index.mjs.map +1 -0
  153. package/dist/actions/package/compile/inputs.mjs +22 -0
  154. package/dist/actions/package/compile/inputs.mjs.map +1 -0
  155. package/dist/actions/package/compile/packageCompileTsc.mjs +93 -0
  156. package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -0
  157. package/dist/actions/package/compile/packageCompileTscTypes.mjs +92 -0
  158. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -0
  159. package/dist/actions/package/compile/packageCompileTsup.mjs +402 -0
  160. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -0
  161. package/dist/actions/package/copy-assets.mjs +69 -0
  162. package/dist/actions/package/copy-assets.mjs.map +1 -0
  163. package/dist/actions/package/cycle.mjs +62 -0
  164. package/dist/actions/package/cycle.mjs.map +1 -0
  165. package/dist/actions/package/gen-docs.mjs +137 -0
  166. package/dist/actions/package/gen-docs.mjs.map +1 -0
  167. package/dist/actions/package/index.mjs +1131 -0
  168. package/dist/actions/package/index.mjs.map +1 -0
  169. package/dist/actions/package/lint.mjs +87 -0
  170. package/dist/actions/package/lint.mjs.map +1 -0
  171. package/dist/actions/package/publint.mjs +336 -0
  172. package/dist/actions/package/publint.mjs.map +1 -0
  173. package/dist/actions/package/recompile.mjs +510 -0
  174. package/dist/actions/package/recompile.mjs.map +1 -0
  175. package/dist/actions/package-lint-deps.mjs +348 -0
  176. package/dist/actions/package-lint-deps.mjs.map +1 -0
  177. package/dist/actions/package-lint.mjs +774 -0
  178. package/dist/actions/package-lint.mjs.map +1 -0
  179. package/dist/actions/packman/clean.mjs +144 -0
  180. package/dist/actions/packman/clean.mjs.map +1 -0
  181. package/dist/actions/packman/convert.mjs +1331 -0
  182. package/dist/actions/packman/convert.mjs.map +1 -0
  183. package/dist/actions/packman/convertToPnpm.mjs +295 -0
  184. package/dist/actions/packman/convertToPnpm.mjs.map +1 -0
  185. package/dist/actions/packman/convertToYarn.mjs +307 -0
  186. package/dist/actions/packman/convertToYarn.mjs.map +1 -0
  187. package/dist/actions/packman/index.mjs +1493 -0
  188. package/dist/actions/packman/index.mjs.map +1 -0
  189. package/dist/actions/packman/lint.mjs +109 -0
  190. package/dist/actions/packman/lint.mjs.map +1 -0
  191. package/dist/actions/packman/rewriteScripts.mjs +52 -0
  192. package/dist/actions/packman/rewriteScripts.mjs.map +1 -0
  193. package/dist/actions/packman/rewriteSourceImports.mjs +60 -0
  194. package/dist/actions/packman/rewriteSourceImports.mjs.map +1 -0
  195. package/dist/actions/packman/swapTsScriptsDependency.mjs +57 -0
  196. package/dist/actions/packman/swapTsScriptsDependency.mjs.map +1 -0
  197. package/dist/actions/publint.mjs +748 -0
  198. package/dist/actions/publint.mjs.map +1 -0
  199. package/dist/actions/publish.mjs +208 -0
  200. package/dist/actions/publish.mjs.map +1 -0
  201. package/dist/actions/reactTest.mjs +142 -0
  202. package/dist/actions/reactTest.mjs.map +1 -0
  203. package/dist/actions/readme-gen.mjs +362 -0
  204. package/dist/actions/readme-gen.mjs.map +1 -0
  205. package/dist/actions/readme-init.mjs +89 -0
  206. package/dist/actions/readme-init.mjs.map +1 -0
  207. package/dist/actions/readme-lint.mjs +147 -0
  208. package/dist/actions/readme-lint.mjs.map +1 -0
  209. package/dist/actions/rebuild.mjs +143 -0
  210. package/dist/actions/rebuild.mjs.map +1 -0
  211. package/dist/actions/recompile.mjs +196 -0
  212. package/dist/actions/recompile.mjs.map +1 -0
  213. package/dist/actions/reinstall.mjs +283 -0
  214. package/dist/actions/reinstall.mjs.map +1 -0
  215. package/dist/actions/relint.mjs +355 -0
  216. package/dist/actions/relint.mjs.map +1 -0
  217. package/dist/actions/repo-init.mjs +217 -0
  218. package/dist/actions/repo-init.mjs.map +1 -0
  219. package/dist/actions/retest.mjs +150 -0
  220. package/dist/actions/retest.mjs.map +1 -0
  221. package/dist/actions/sitemap.mjs +121 -0
  222. package/dist/actions/sitemap.mjs.map +1 -0
  223. package/dist/actions/sonar.mjs +119 -0
  224. package/dist/actions/sonar.mjs.map +1 -0
  225. package/dist/actions/start.mjs +142 -0
  226. package/dist/actions/start.mjs.map +1 -0
  227. package/dist/actions/statics.mjs +225 -0
  228. package/dist/actions/statics.mjs.map +1 -0
  229. package/dist/actions/test.mjs +144 -0
  230. package/dist/actions/test.mjs.map +1 -0
  231. package/dist/actions/up.mjs +140 -0
  232. package/dist/actions/up.mjs.map +1 -0
  233. package/dist/actions/updo.mjs +533 -0
  234. package/dist/actions/updo.mjs.map +1 -0
  235. package/dist/actions/upplug.mjs +124 -0
  236. package/dist/actions/upplug.mjs.map +1 -0
  237. package/dist/actions/upyarn.mjs +119 -0
  238. package/dist/actions/upyarn.mjs.map +1 -0
  239. package/dist/actions/yarn3only.mjs +60 -0
  240. package/dist/actions/yarn3only.mjs.map +1 -0
  241. package/dist/bin/package/build-only.mjs +451 -0
  242. package/dist/bin/package/build-only.mjs.map +1 -0
  243. package/dist/bin/package/build.mjs +451 -0
  244. package/dist/bin/package/build.mjs.map +1 -0
  245. package/dist/bin/package/clean-outputs.mjs +50 -0
  246. package/dist/bin/package/clean-outputs.mjs.map +1 -0
  247. package/dist/bin/package/clean-typescript.mjs +50 -0
  248. package/dist/bin/package/clean-typescript.mjs.map +1 -0
  249. package/dist/bin/package/clean.mjs +75 -0
  250. package/dist/bin/package/clean.mjs.map +1 -0
  251. package/dist/bin/package/compile-only.mjs +447 -0
  252. package/dist/bin/package/compile-only.mjs.map +1 -0
  253. package/dist/bin/package/compile-tsup.mjs +409 -0
  254. package/dist/bin/package/compile-tsup.mjs.map +1 -0
  255. package/dist/bin/package/compile.mjs +451 -0
  256. package/dist/bin/package/compile.mjs.map +1 -0
  257. package/dist/bin/package/copy-assets-cjs.mjs +75 -0
  258. package/dist/bin/package/copy-assets-cjs.mjs.map +1 -0
  259. package/dist/bin/package/copy-assets-esm.mjs +75 -0
  260. package/dist/bin/package/copy-assets-esm.mjs.map +1 -0
  261. package/dist/bin/package/cycle.mjs +72 -0
  262. package/dist/bin/package/cycle.mjs.map +1 -0
  263. package/dist/bin/package/fix.mjs +97 -0
  264. package/dist/bin/package/fix.mjs.map +1 -0
  265. package/dist/bin/package/gen-docs.mjs +142 -0
  266. package/dist/bin/package/gen-docs.mjs.map +1 -0
  267. package/dist/bin/package/lint-verbose.mjs +97 -0
  268. package/dist/bin/package/lint-verbose.mjs.map +1 -0
  269. package/dist/bin/package/lint.mjs +97 -0
  270. package/dist/bin/package/lint.mjs.map +1 -0
  271. package/dist/bin/package/publint.mjs +423 -0
  272. package/dist/bin/package/publint.mjs.map +1 -0
  273. package/dist/bin/package/recompile.mjs +516 -0
  274. package/dist/bin/package/recompile.mjs.map +1 -0
  275. package/dist/bin/package/relint.mjs +97 -0
  276. package/dist/bin/package/relint.mjs.map +1 -0
  277. package/dist/bin/run-or-exec.mjs +20 -0
  278. package/dist/bin/run-or-exec.mjs.map +1 -0
  279. package/dist/bin/xy.mjs +8885 -0
  280. package/dist/bin/xy.mjs.map +1 -0
  281. package/dist/index.d.ts +1102 -0
  282. package/dist/index.mjs +9986 -0
  283. package/dist/index.mjs.map +1 -0
  284. package/dist/lib/checkResult.mjs +16 -0
  285. package/dist/lib/checkResult.mjs.map +1 -0
  286. package/dist/lib/claudeMdTemplate.mjs +69 -0
  287. package/dist/lib/claudeMdTemplate.mjs.map +1 -0
  288. package/dist/lib/concurrency.mjs +38 -0
  289. package/dist/lib/concurrency.mjs.map +1 -0
  290. package/dist/lib/createBuildConfig.mjs +55 -0
  291. package/dist/lib/createBuildConfig.mjs.map +1 -0
  292. package/dist/lib/defaultBuildConfig.mjs +23 -0
  293. package/dist/lib/defaultBuildConfig.mjs.map +1 -0
  294. package/dist/lib/deleteGlob.mjs +13 -0
  295. package/dist/lib/deleteGlob.mjs.map +1 -0
  296. package/dist/lib/dependencies/DuplicateDetector.mjs +99 -0
  297. package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -0
  298. package/dist/lib/dependencies/detectDuplicateDependencies.mjs +203 -0
  299. package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -0
  300. package/dist/lib/dependencies/index.mjs +281 -0
  301. package/dist/lib/dependencies/index.mjs.map +1 -0
  302. package/dist/lib/dependencies/workspaceCycles.mjs +79 -0
  303. package/dist/lib/dependencies/workspaceCycles.mjs.map +1 -0
  304. package/dist/lib/file/ReadFileSyncOptions.mjs +6 -0
  305. package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -0
  306. package/dist/lib/file/constants.mjs +8 -0
  307. package/dist/lib/file/constants.mjs.map +1 -0
  308. package/dist/lib/file/fileLines.mjs +32 -0
  309. package/dist/lib/file/fileLines.mjs.map +1 -0
  310. package/dist/lib/file/index.mjs +42 -0
  311. package/dist/lib/file/index.mjs.map +1 -0
  312. package/dist/lib/file/tryReadFileSync.mjs +14 -0
  313. package/dist/lib/file/tryReadFileSync.mjs.map +1 -0
  314. package/dist/lib/fillTemplate.mjs +8 -0
  315. package/dist/lib/fillTemplate.mjs.map +1 -0
  316. package/dist/lib/generateIgnoreFiles.mjs +86 -0
  317. package/dist/lib/generateIgnoreFiles.mjs.map +1 -0
  318. package/dist/lib/generateReadmeFiles.mjs +323 -0
  319. package/dist/lib/generateReadmeFiles.mjs.map +1 -0
  320. package/dist/lib/gitignoreTemplate.mjs +12 -0
  321. package/dist/lib/gitignoreTemplate.mjs.map +1 -0
  322. package/dist/lib/index.mjs +1627 -0
  323. package/dist/lib/index.mjs.map +1 -0
  324. package/dist/lib/initCwd.mjs +8 -0
  325. package/dist/lib/initCwd.mjs.map +1 -0
  326. package/dist/lib/jsonFormatters.mjs +11 -0
  327. package/dist/lib/jsonFormatters.mjs.map +1 -0
  328. package/dist/lib/latestVersions.mjs +12 -0
  329. package/dist/lib/latestVersions.mjs.map +1 -0
  330. package/dist/lib/loadConfig.mjs +72 -0
  331. package/dist/lib/loadConfig.mjs.map +1 -0
  332. package/dist/lib/packageName.mjs +26 -0
  333. package/dist/lib/packageName.mjs.map +1 -0
  334. package/dist/lib/parsedPackageJSON.mjs +11 -0
  335. package/dist/lib/parsedPackageJSON.mjs.map +1 -0
  336. package/dist/lib/processEx.mjs +36 -0
  337. package/dist/lib/processEx.mjs.map +1 -0
  338. package/dist/lib/repoTemplates.mjs +34 -0
  339. package/dist/lib/repoTemplates.mjs.map +1 -0
  340. package/dist/lib/runInstall.mjs +30 -0
  341. package/dist/lib/runInstall.mjs.map +1 -0
  342. package/dist/lib/runSteps.mjs +118 -0
  343. package/dist/lib/runSteps.mjs.map +1 -0
  344. package/dist/lib/runStepsAsync.mjs +136 -0
  345. package/dist/lib/runStepsAsync.mjs.map +1 -0
  346. package/dist/lib/runXy.mjs +147 -0
  347. package/dist/lib/runXy.mjs.map +1 -0
  348. package/dist/lib/runXyWithWarning.mjs +36 -0
  349. package/dist/lib/runXyWithWarning.mjs.map +1 -0
  350. package/dist/lib/safeExit.mjs +61 -0
  351. package/dist/lib/safeExit.mjs.map +1 -0
  352. package/dist/lib/string/empty.mjs +8 -0
  353. package/dist/lib/string/empty.mjs.map +1 -0
  354. package/dist/lib/string/index.mjs +12 -0
  355. package/dist/lib/string/index.mjs.map +1 -0
  356. package/dist/lib/string/union.mjs +6 -0
  357. package/dist/lib/string/union.mjs.map +1 -0
  358. package/dist/lib/tryRunLocalScript.mjs +57 -0
  359. package/dist/lib/tryRunLocalScript.mjs.map +1 -0
  360. package/dist/lib/updo/applyUpdates.mjs +44 -0
  361. package/dist/lib/updo/applyUpdates.mjs.map +1 -0
  362. package/dist/lib/updo/collectWorkspaceDeps.mjs +48 -0
  363. package/dist/lib/updo/collectWorkspaceDeps.mjs.map +1 -0
  364. package/dist/lib/updo/fetchRegistryInfo.mjs +53 -0
  365. package/dist/lib/updo/fetchRegistryInfo.mjs.map +1 -0
  366. package/dist/lib/updo/index.mjs +594 -0
  367. package/dist/lib/updo/index.mjs.map +1 -0
  368. package/dist/lib/updo/interactiveSelect.mjs +185 -0
  369. package/dist/lib/updo/interactiveSelect.mjs.map +1 -0
  370. package/dist/lib/updo/interfaces.mjs +1 -0
  371. package/dist/lib/updo/interfaces.mjs.map +1 -0
  372. package/dist/lib/updo/renderTable.mjs +79 -0
  373. package/dist/lib/updo/renderTable.mjs.map +1 -0
  374. package/dist/lib/updo/resolveVersions.mjs +49 -0
  375. package/dist/lib/updo/resolveVersions.mjs.map +1 -0
  376. package/dist/lib/updo/runUpdo.mjs +511 -0
  377. package/dist/lib/updo/runUpdo.mjs.map +1 -0
  378. package/dist/lib/withErrnoException.mjs +13 -0
  379. package/dist/lib/withErrnoException.mjs.map +1 -0
  380. package/dist/lib/withError.mjs +8 -0
  381. package/dist/lib/withError.mjs.map +1 -0
  382. package/dist/lib/yarn/index.mjs +39 -0
  383. package/dist/lib/yarn/index.mjs.map +1 -0
  384. package/dist/lib/yarn/isYarnVersionOrGreater.mjs +18 -0
  385. package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -0
  386. package/dist/lib/yarn/workspace/Workspace.mjs +1 -0
  387. package/dist/lib/yarn/workspace/Workspace.mjs.map +1 -0
  388. package/dist/lib/yarn/workspace/index.mjs +23 -0
  389. package/dist/lib/yarn/workspace/index.mjs.map +1 -0
  390. package/dist/lib/yarn/workspace/yarnWorkspace.mjs +22 -0
  391. package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -0
  392. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs +15 -0
  393. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -0
  394. package/dist/lib/yarn/yarnInitCwd.mjs +8 -0
  395. package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -0
  396. package/dist/loadPackageConfig.mjs +18 -0
  397. package/dist/loadPackageConfig.mjs.map +1 -0
  398. package/dist/pm/PackageManager.mjs +1 -0
  399. package/dist/pm/PackageManager.mjs.map +1 -0
  400. package/dist/pm/detectPackageManager.mjs +10 -0
  401. package/dist/pm/detectPackageManager.mjs.map +1 -0
  402. package/dist/pm/detectReact.mjs +52 -0
  403. package/dist/pm/detectReact.mjs.map +1 -0
  404. package/dist/pm/index.mjs +263 -0
  405. package/dist/pm/index.mjs.map +1 -0
  406. package/dist/pm/pnpmPackageManager.mjs +97 -0
  407. package/dist/pm/pnpmPackageManager.mjs.map +1 -0
  408. package/dist/pm/registry.mjs +27 -0
  409. package/dist/pm/registry.mjs.map +1 -0
  410. package/dist/pm/yarnPackageManager.mjs +112 -0
  411. package/dist/pm/yarnPackageManager.mjs.map +1 -0
  412. package/dist/types.d.mjs +1 -0
  413. package/dist/types.d.mjs.map +1 -0
  414. package/dist/xy/build/buildCommand.mjs +194 -0
  415. package/dist/xy/build/buildCommand.mjs.map +1 -0
  416. package/dist/xy/build/compileCommand.mjs +203 -0
  417. package/dist/xy/build/compileCommand.mjs.map +1 -0
  418. package/dist/xy/build/compileOnlyCommand.mjs +204 -0
  419. package/dist/xy/build/compileOnlyCommand.mjs.map +1 -0
  420. package/dist/xy/build/copyAssetsCommand.mjs +92 -0
  421. package/dist/xy/build/copyAssetsCommand.mjs.map +1 -0
  422. package/dist/xy/build/index.mjs +487 -0
  423. package/dist/xy/build/index.mjs.map +1 -0
  424. package/dist/xy/build/rebuildCommand.mjs +156 -0
  425. package/dist/xy/build/rebuildCommand.mjs.map +1 -0
  426. package/dist/xy/build/recompileCommand.mjs +215 -0
  427. package/dist/xy/build/recompileCommand.mjs.map +1 -0
  428. package/dist/xy/common/checkCommand.mjs +1909 -0
  429. package/dist/xy/common/checkCommand.mjs.map +1 -0
  430. package/dist/xy/common/claude/checkCommand.mjs +207 -0
  431. package/dist/xy/common/claude/checkCommand.mjs.map +1 -0
  432. package/dist/xy/common/claude/cleanCommand.mjs +78 -0
  433. package/dist/xy/common/claude/cleanCommand.mjs.map +1 -0
  434. package/dist/xy/common/claude/commandsCommand.mjs +134 -0
  435. package/dist/xy/common/claude/commandsCommand.mjs.map +1 -0
  436. package/dist/xy/common/claude/index.mjs +734 -0
  437. package/dist/xy/common/claude/index.mjs.map +1 -0
  438. package/dist/xy/common/claude/initCommand.mjs +458 -0
  439. package/dist/xy/common/claude/initCommand.mjs.map +1 -0
  440. package/dist/xy/common/claude/rulesCommand.mjs +167 -0
  441. package/dist/xy/common/claude/rulesCommand.mjs.map +1 -0
  442. package/dist/xy/common/claude/settingsCommand.mjs +115 -0
  443. package/dist/xy/common/claude/settingsCommand.mjs.map +1 -0
  444. package/dist/xy/common/claude/skillsCommand.mjs +140 -0
  445. package/dist/xy/common/claude/skillsCommand.mjs.map +1 -0
  446. package/dist/xy/common/cleanDocsCommand.mjs +74 -0
  447. package/dist/xy/common/cleanDocsCommand.mjs.map +1 -0
  448. package/dist/xy/common/deadCommand.mjs +137 -0
  449. package/dist/xy/common/deadCommand.mjs.map +1 -0
  450. package/dist/xy/common/genDocsCommand.mjs +175 -0
  451. package/dist/xy/common/genDocsCommand.mjs.map +1 -0
  452. package/dist/xy/common/gitignoreCommand.mjs +165 -0
  453. package/dist/xy/common/gitignoreCommand.mjs.map +1 -0
  454. package/dist/xy/common/gitlintCommand.mjs +89 -0
  455. package/dist/xy/common/gitlintCommand.mjs.map +1 -0
  456. package/dist/xy/common/index.mjs +4654 -0
  457. package/dist/xy/common/index.mjs.map +1 -0
  458. package/dist/xy/common/licenseCommand.mjs +108 -0
  459. package/dist/xy/common/licenseCommand.mjs.map +1 -0
  460. package/dist/xy/common/npmignoreGenCommand.mjs +100 -0
  461. package/dist/xy/common/npmignoreGenCommand.mjs.map +1 -0
  462. package/dist/xy/common/orphan/cleanCommand.mjs +102 -0
  463. package/dist/xy/common/orphan/cleanCommand.mjs.map +1 -0
  464. package/dist/xy/common/orphan/index.mjs +138 -0
  465. package/dist/xy/common/orphan/index.mjs.map +1 -0
  466. package/dist/xy/common/orphan/listCommand.mjs +100 -0
  467. package/dist/xy/common/orphan/listCommand.mjs.map +1 -0
  468. package/dist/xy/common/packmanCommand.mjs +1538 -0
  469. package/dist/xy/common/packmanCommand.mjs.map +1 -0
  470. package/dist/xy/common/readme/genCommand.mjs +395 -0
  471. package/dist/xy/common/readme/genCommand.mjs.map +1 -0
  472. package/dist/xy/common/readme/index.mjs +538 -0
  473. package/dist/xy/common/readme/index.mjs.map +1 -0
  474. package/dist/xy/common/readme/initCommand.mjs +109 -0
  475. package/dist/xy/common/readme/initCommand.mjs.map +1 -0
  476. package/dist/xy/common/readme/lintCommand.mjs +181 -0
  477. package/dist/xy/common/readme/lintCommand.mjs.map +1 -0
  478. package/dist/xy/common/repo/index.mjs +1070 -0
  479. package/dist/xy/common/repo/index.mjs.map +1 -0
  480. package/dist/xy/common/repo/initCommand.mjs +273 -0
  481. package/dist/xy/common/repo/initCommand.mjs.map +1 -0
  482. package/dist/xy/common/repo/lintCommand.mjs +789 -0
  483. package/dist/xy/common/repo/lintCommand.mjs.map +1 -0
  484. package/dist/xy/common/retestCommand.mjs +163 -0
  485. package/dist/xy/common/retestCommand.mjs.map +1 -0
  486. package/dist/xy/common/testCommand.mjs +157 -0
  487. package/dist/xy/common/testCommand.mjs.map +1 -0
  488. package/dist/xy/deploy/deployCommand.mjs +214 -0
  489. package/dist/xy/deploy/deployCommand.mjs.map +1 -0
  490. package/dist/xy/deploy/index.mjs +289 -0
  491. package/dist/xy/deploy/index.mjs.map +1 -0
  492. package/dist/xy/deploy/publishCommand.mjs +218 -0
  493. package/dist/xy/deploy/publishCommand.mjs.map +1 -0
  494. package/dist/xy/index.mjs +8887 -0
  495. package/dist/xy/index.mjs.map +1 -0
  496. package/dist/xy/install/cleanCommand.mjs +182 -0
  497. package/dist/xy/install/cleanCommand.mjs.map +1 -0
  498. package/dist/xy/install/dupdepsCommand.mjs +234 -0
  499. package/dist/xy/install/dupdepsCommand.mjs.map +1 -0
  500. package/dist/xy/install/index.mjs +1006 -0
  501. package/dist/xy/install/index.mjs.map +1 -0
  502. package/dist/xy/install/reinstallCommand.mjs +292 -0
  503. package/dist/xy/install/reinstallCommand.mjs.map +1 -0
  504. package/dist/xy/install/staticsCommand.mjs +233 -0
  505. package/dist/xy/install/staticsCommand.mjs.map +1 -0
  506. package/dist/xy/install/upCommand.mjs +150 -0
  507. package/dist/xy/install/upCommand.mjs.map +1 -0
  508. package/dist/xy/install/updoCommand.mjs +550 -0
  509. package/dist/xy/install/updoCommand.mjs.map +1 -0
  510. package/dist/xy/lint/cycleCommand.mjs +289 -0
  511. package/dist/xy/lint/cycleCommand.mjs.map +1 -0
  512. package/dist/xy/lint/deplintCommand.mjs +1897 -0
  513. package/dist/xy/lint/deplintCommand.mjs.map +1 -0
  514. package/dist/xy/lint/fixCommand.mjs +398 -0
  515. package/dist/xy/lint/fixCommand.mjs.map +1 -0
  516. package/dist/xy/lint/index.mjs +3759 -0
  517. package/dist/xy/lint/index.mjs.map +1 -0
  518. package/dist/xy/lint/knipCommand.mjs +142 -0
  519. package/dist/xy/lint/knipCommand.mjs.map +1 -0
  520. package/dist/xy/lint/lint/index.mjs +695 -0
  521. package/dist/xy/lint/lint/index.mjs.map +1 -0
  522. package/dist/xy/lint/lint/initCommand.mjs +282 -0
  523. package/dist/xy/lint/lint/initCommand.mjs.map +1 -0
  524. package/dist/xy/lint/lint/runCommand.mjs +405 -0
  525. package/dist/xy/lint/lint/runCommand.mjs.map +1 -0
  526. package/dist/xy/lint/lintCommand.mjs +695 -0
  527. package/dist/xy/lint/lintCommand.mjs.map +1 -0
  528. package/dist/xy/lint/lintlintCommand.mjs +359 -0
  529. package/dist/xy/lint/lintlintCommand.mjs.map +1 -0
  530. package/dist/xy/lint/publintCommand.mjs +778 -0
  531. package/dist/xy/lint/publintCommand.mjs.map +1 -0
  532. package/dist/xy/lint/relintCommand.mjs +381 -0
  533. package/dist/xy/lint/relintCommand.mjs.map +1 -0
  534. package/dist/xy/lint/sonarCommand.mjs +137 -0
  535. package/dist/xy/lint/sonarCommand.mjs.map +1 -0
  536. package/dist/xy/param.mjs +8 -0
  537. package/dist/xy/param.mjs.map +1 -0
  538. package/dist/xy/react/analyzeCommand.mjs +150 -0
  539. package/dist/xy/react/analyzeCommand.mjs.map +1 -0
  540. package/dist/xy/react/ejectCommand.mjs +150 -0
  541. package/dist/xy/react/ejectCommand.mjs.map +1 -0
  542. package/dist/xy/react/index.mjs +202 -0
  543. package/dist/xy/react/index.mjs.map +1 -0
  544. package/dist/xy/react/sitemapCommand.mjs +129 -0
  545. package/dist/xy/react/sitemapCommand.mjs.map +1 -0
  546. package/dist/xy/react/startCommand.mjs +150 -0
  547. package/dist/xy/react/startCommand.mjs.map +1 -0
  548. package/dist/xy/xy.mjs +8879 -0
  549. package/dist/xy/xy.mjs.map +1 -0
  550. package/dist/xy/xyParseOptions.mjs +117 -0
  551. package/dist/xy/xyParseOptions.mjs.map +1 -0
  552. package/dist/xy/yarn/index.mjs +188 -0
  553. package/dist/xy/yarn/index.mjs.map +1 -0
  554. package/dist/xy/yarn/upplugCommand.mjs +134 -0
  555. package/dist/xy/yarn/upplugCommand.mjs.map +1 -0
  556. package/dist/xy/yarn/upyarnCommand.mjs +129 -0
  557. package/dist/xy/yarn/upyarnCommand.mjs.map +1 -0
  558. package/dist/xy/yarn/yarn3OnlyCommand.mjs +70 -0
  559. package/dist/xy/yarn/yarn3OnlyCommand.mjs.map +1 -0
  560. package/package.json +119 -0
  561. package/templates/claude/CLAUDE-local.md +4 -0
  562. package/templates/claude/CLAUDE-project.md +4 -0
  563. package/templates/claude/commands/xy-build.md +7 -0
  564. package/templates/claude/commands/xy-clean.md +7 -0
  565. package/templates/claude/commands/xy-compile.md +7 -0
  566. package/templates/claude/commands/xy-cycle.md +7 -0
  567. package/templates/claude/commands/xy-dead.md +7 -0
  568. package/templates/claude/commands/xy-deplint.md +7 -0
  569. package/templates/claude/commands/xy-deps.md +24 -0
  570. package/templates/claude/commands/xy-dupdeps.md +7 -0
  571. package/templates/claude/commands/xy-fix.md +7 -0
  572. package/templates/claude/commands/xy-gen-docs.md +7 -0
  573. package/templates/claude/commands/xy-gitignore.md +7 -0
  574. package/templates/claude/commands/xy-gitlint.md +7 -0
  575. package/templates/claude/commands/xy-knip.md +7 -0
  576. package/templates/claude/commands/xy-license.md +7 -0
  577. package/templates/claude/commands/xy-lint-rules.md +44 -0
  578. package/templates/claude/commands/xy-lint.md +7 -0
  579. package/templates/claude/commands/xy-publint.md +7 -0
  580. package/templates/claude/commands/xy-rebuild.md +7 -0
  581. package/templates/claude/commands/xy-recompile.md +7 -0
  582. package/templates/claude/commands/xy-reinstall.md +7 -0
  583. package/templates/claude/commands/xy-relint.md +7 -0
  584. package/templates/claude/commands/xy-retest.md +7 -0
  585. package/templates/claude/commands/xy-sonar.md +7 -0
  586. package/templates/claude/commands/xy-test.md +7 -0
  587. package/templates/claude/commands/xy-up.md +9 -0
  588. package/templates/claude/rules/xylabs-architecture.md +8 -0
  589. package/templates/claude/rules/xylabs-git-workflow.md +7 -0
  590. package/templates/claude/rules/xylabs-naming.md +7 -0
  591. package/templates/claude/rules/xylabs-style.md +17 -0
  592. package/templates/claude/skills/xylabs-e2e-setup/SKILL.md +223 -0
  593. package/templates/claude/skills/xylabs-xy-cli/SKILL.md +236 -0
  594. package/templates/claude/skills/xylabs-xy-deplint-fix/SKILL.md +122 -0
  595. package/templates/gitignore/gitignore/template.gitignore +51 -0
  596. package/templates/gitignore/template.gitignore +51 -0
  597. package/templates/readme/README.body.md +25 -0
  598. package/templates/readme/README.template.md +22 -0
  599. package/templates/repo/cli/package/package.json.tmpl +63 -0
  600. package/templates/repo/cli/package/src/__packageName__.ts.tmpl +21 -0
  601. package/templates/repo/cli/package/src/actions/index.ts +1 -0
  602. package/templates/repo/cli/package/src/actions/printVersion.ts.tmpl +8 -0
  603. package/templates/repo/cli/package/src/bin/__packageName__.ts.tmpl +12 -0
  604. package/templates/repo/cli/package/src/commands/index.ts +1 -0
  605. package/templates/repo/cli/package/src/commands/versionCommand.ts.tmpl +11 -0
  606. package/templates/repo/cli/package/src/index.ts.tmpl +1 -0
  607. package/templates/repo/cli/package/tsconfig.build.json +25 -0
  608. package/templates/repo/cli/package/tsconfig.json +4 -0
  609. package/templates/repo/cli/package/tsup.config.ts +15 -0
  610. package/templates/repo/cli/package/xy.config.ts +3 -0
  611. package/templates/repo/cli/root/CLAUDE.md.tmpl +38 -0
  612. package/templates/repo/cli/root/cspell.json.tmpl +13 -0
  613. package/templates/repo/cli/root/eslint.config.ts +28 -0
  614. package/templates/repo/cli/root/github/workflows/build-pnpm.yml.tmpl +34 -0
  615. package/templates/repo/cli/root/github/workflows/build-yarn.yml.tmpl +32 -0
  616. package/templates/repo/cli/root/gitignore.tmpl +47 -0
  617. package/templates/repo/cli/root/knip.config.ts +16 -0
  618. package/templates/repo/cli/root/package.json.tmpl +54 -0
  619. package/templates/repo/cli/root/pnpm-workspace.yaml +2 -0
  620. package/templates/repo/cli/root/tsconfig.json +4 -0
  621. package/templates/repo/cli/root/vitest.config.ts +31 -0
  622. package/templates/repo/cli/root/xy.config.ts.tmpl +5 -0
@@ -0,0 +1,1909 @@
1
+ // src/xy/common/checkCommand.ts
2
+ import chalk13 from "chalk";
3
+
4
+ // src/lib/concurrency.ts
5
+ import { AsyncLocalStorage } from "async_hooks";
6
+ var outputStorage = new AsyncLocalStorage();
7
+ var captureInstalled = false;
8
+ function installOutputCapture() {
9
+ if (captureInstalled) return;
10
+ captureInstalled = true;
11
+ const originalStdoutWrite = process.stdout.write.bind(process.stdout);
12
+ const originalStderrWrite = process.stderr.write.bind(process.stderr);
13
+ function intercept(original) {
14
+ return function(chunk, ...args) {
15
+ const buffer = outputStorage.getStore();
16
+ if (buffer) {
17
+ buffer.push(typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk));
18
+ return true;
19
+ }
20
+ return original(chunk, ...args);
21
+ };
22
+ }
23
+ process.stdout.write = intercept(originalStdoutWrite);
24
+ process.stderr.write = intercept(originalStderrWrite);
25
+ }
26
+ async function runWithConcurrency(items, concurrency, fn) {
27
+ let next = 0;
28
+ async function worker() {
29
+ while (next < items.length) {
30
+ const i = next++;
31
+ await fn(items[i]);
32
+ }
33
+ }
34
+ await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, () => worker()));
35
+ }
36
+
37
+ // src/pm/detectPackageManager.ts
38
+ import { existsSync } from "fs";
39
+ function detectPackageManager() {
40
+ if (existsSync("pnpm-lock.yaml") || existsSync("pnpm-workspace.yaml")) return "pnpm";
41
+ return "yarn";
42
+ }
43
+
44
+ // src/pm/registry.ts
45
+ var implementations = /* @__PURE__ */ new Map();
46
+ function getPackageManager(name) {
47
+ const pmName = name ?? detectPackageManager();
48
+ const pm = implementations.get(pmName);
49
+ if (!pm) {
50
+ throw new Error(
51
+ `No package manager implementation registered for "${pmName}". Ensure registerPackageManager() has been called before getPackageManager().`
52
+ );
53
+ }
54
+ return pm;
55
+ }
56
+
57
+ // src/lib/initCwd.ts
58
+ function INIT_CWD() {
59
+ return process.env.INIT_CWD ?? process.cwd();
60
+ }
61
+
62
+ // src/lib/generateReadmeFiles.ts
63
+ import { execFile } from "child_process";
64
+ import FS, { readFileSync } from "fs";
65
+ import {
66
+ mkdir,
67
+ readFile,
68
+ writeFile
69
+ } from "fs/promises";
70
+ import { createRequire } from "module";
71
+ import PATH from "path";
72
+ import { createInterface } from "readline";
73
+ import { promisify } from "util";
74
+ import chalk from "chalk";
75
+ var execFileAsync = promisify(execFile);
76
+ var require2 = createRequire(import.meta.url);
77
+ var packageRoot = PATH.dirname(require2.resolve("@xylabs/ts-scripts-common/package.json"));
78
+ var readmeTemplatesDir = PATH.resolve(packageRoot, "templates", "readme");
79
+ var DEFAULT_README_TEMPLATE = readFileSync(PATH.resolve(readmeTemplatesDir, "README.template.md"), "utf8");
80
+ var DEFAULT_README_BODY = readFileSync(PATH.resolve(readmeTemplatesDir, "README.body.md"), "utf8");
81
+ function resolveTemplatePath(templatePath) {
82
+ const cwd = INIT_CWD();
83
+ return templatePath ?? PATH.join(cwd, ".xy", "README.template.md");
84
+ }
85
+
86
+ // src/lib/latestVersions.ts
87
+ var latestVersions = {
88
+ node: "24.14.1",
89
+ nodeLtsCodename: "Krypton",
90
+ npm: "11.11.0",
91
+ pnpm: "10.33.0",
92
+ yarn: "4.13.0"
93
+ };
94
+
95
+ // src/lib/loadConfig.ts
96
+ import chalk2 from "chalk";
97
+ import { cosmiconfig } from "cosmiconfig";
98
+ import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
99
+ import deepmerge from "deepmerge";
100
+ var config;
101
+ var rootConfigPath;
102
+ var workspaceConfigCache = /* @__PURE__ */ new Map();
103
+ var deprecationWarned = /* @__PURE__ */ new Set();
104
+ function createExplorer() {
105
+ return cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } });
106
+ }
107
+ var loadConfig = async (params) => {
108
+ if (config === void 0) {
109
+ const cosmicConfigResult = await createExplorer().search();
110
+ config = cosmicConfigResult?.config ?? {};
111
+ rootConfigPath = cosmicConfigResult?.filepath;
112
+ const configFilePath = cosmicConfigResult?.filepath;
113
+ if (configFilePath !== void 0) {
114
+ console.log(chalk2.green(`Loaded config from ${configFilePath}`));
115
+ if (config.verbose) {
116
+ console.log(chalk2.gray(`${JSON.stringify(config, null, 2)}`));
117
+ }
118
+ }
119
+ }
120
+ return deepmerge(config, params ?? {});
121
+ };
122
+ async function loadWorkspaceConfig(workspaceDir) {
123
+ const cached = workspaceConfigCache.get(workspaceDir);
124
+ if (cached !== void 0) return cached;
125
+ const result = await createExplorer().search(workspaceDir);
126
+ if (!result || result.filepath === rootConfigPath) {
127
+ workspaceConfigCache.set(workspaceDir, {});
128
+ return {};
129
+ }
130
+ const wsConfig = result.config ?? {};
131
+ workspaceConfigCache.set(workspaceDir, wsConfig);
132
+ return wsConfig;
133
+ }
134
+ var DEPRECATED_COMMAND_FIELDS = /* @__PURE__ */ new Set(["deplint", "publint"]);
135
+ function resolveCommandField(cfg, commandName, configPath) {
136
+ const commands = cfg.commands;
137
+ const fromCommands = commands?.[commandName];
138
+ const fromTopLevel = cfg[commandName];
139
+ if (fromCommands !== void 0 && typeof fromCommands === "object") {
140
+ return fromCommands;
141
+ }
142
+ if (fromTopLevel !== void 0 && typeof fromTopLevel === "object" && DEPRECATED_COMMAND_FIELDS.has(commandName)) {
143
+ const key = `${configPath ?? "unknown"}:${commandName}`;
144
+ if (!deprecationWarned.has(key)) {
145
+ deprecationWarned.add(key);
146
+ console.warn(chalk2.yellow(
147
+ `[xy] Deprecated: top-level "${commandName}" in ${configPath ?? "xy.config"} \u2014 move to "commands.${commandName}"`
148
+ ));
149
+ }
150
+ return fromTopLevel;
151
+ }
152
+ return {};
153
+ }
154
+ async function loadWorkspaceCommandConfig(workspaceDir, commandName) {
155
+ const root = await loadConfig();
156
+ const rootCmd = resolveCommandField(root, commandName, rootConfigPath);
157
+ const wsConfig = await loadWorkspaceConfig(workspaceDir);
158
+ const wsConfigPath = workspaceConfigCache.has(workspaceDir) ? workspaceDir : void 0;
159
+ const wsCmd = resolveCommandField(wsConfig, commandName, wsConfigPath);
160
+ return deepmerge(rootCmd, wsCmd);
161
+ }
162
+
163
+ // src/lib/runInstall.ts
164
+ import { spawnSync } from "child_process";
165
+ import chalk3 from "chalk";
166
+ function runInstall(cwd) {
167
+ const pm = detectPackageManager();
168
+ console.log(chalk3.gray(`Running ${pm} install...`));
169
+ const result = spawnSync(pm, ["install"], {
170
+ cwd,
171
+ stdio: "inherit"
172
+ });
173
+ if (result.status !== 0) {
174
+ console.warn(chalk3.yellow(`${pm} install failed`));
175
+ return false;
176
+ }
177
+ console.log(chalk3.green("Dependencies installed"));
178
+ return true;
179
+ }
180
+
181
+ // src/actions/package-lint-deps.ts
182
+ import { readFileSync as readFileSync2, writeFileSync } from "fs";
183
+ import PATH2 from "path";
184
+ import chalk4 from "chalk";
185
+ import semver from "semver";
186
+ function readWorkspacePackageJson(cwd, location) {
187
+ const pkgPath = PATH2.resolve(cwd, location, "package.json");
188
+ try {
189
+ return JSON.parse(readFileSync2(pkgPath, "utf8"));
190
+ } catch {
191
+ return void 0;
192
+ }
193
+ }
194
+ function writeWorkspacePackageJson(cwd, location, pkg) {
195
+ const pkgPath = PATH2.resolve(cwd, location, "package.json");
196
+ writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
197
+ `, "utf8");
198
+ }
199
+ function buildWorkspaceVersionMap(cwd, workspaces) {
200
+ const map = /* @__PURE__ */ new Map();
201
+ for (const { location, name } of workspaces) {
202
+ if (location === ".") continue;
203
+ const pkg = readWorkspacePackageJson(cwd, location);
204
+ if (!pkg) continue;
205
+ const version = pkg.version;
206
+ if (version) map.set(name, version);
207
+ }
208
+ return map;
209
+ }
210
+ function expectedPeerRange(devDepVersion, targetVersion) {
211
+ const parsed = semver.parse(targetVersion);
212
+ if (!parsed) return `~${targetVersion}`;
213
+ if (devDepVersion === "workspace:^") {
214
+ return `^${parsed.major}`;
215
+ }
216
+ return `~${parsed.major}.${parsed.minor}`;
217
+ }
218
+ function checkVersionConsistency(cwd, rootPkg, workspaces) {
219
+ const result = {
220
+ errors: [],
221
+ fixable: [],
222
+ warnings: []
223
+ };
224
+ if (rootPkg.version !== void 0) {
225
+ result.fixable.push('Root package.json should not have a "version" field in a monorepo');
226
+ }
227
+ const versions = /* @__PURE__ */ new Map();
228
+ for (const { location, name } of workspaces) {
229
+ if (location === ".") continue;
230
+ const pkg = readWorkspacePackageJson(cwd, location);
231
+ if (!pkg) continue;
232
+ const version = pkg.version;
233
+ if (version) {
234
+ versions.set(name, version);
235
+ } else {
236
+ result.errors.push(`${name} (${location}) is missing a "version" field`);
237
+ }
238
+ }
239
+ const uniqueVersions = new Set(versions.values());
240
+ if (uniqueVersions.size > 1) {
241
+ const versionList = [...uniqueVersions].toSorted(semver.rcompare);
242
+ for (const [name, version] of versions) {
243
+ if (version !== versionList[0]) {
244
+ result.fixable.push(`${name} has version ${version} (expected ${versionList[0]})`);
245
+ }
246
+ }
247
+ }
248
+ return result;
249
+ }
250
+ function fixVersionConsistency(cwd, rootPkg, writeRootPackageJson2, workspaces) {
251
+ if (rootPkg.version !== void 0) {
252
+ delete rootPkg.version;
253
+ writeRootPackageJson2(cwd, rootPkg);
254
+ console.log(chalk4.green(' \u2714 Fixed: removed "version" from root package.json'));
255
+ }
256
+ const versions = [];
257
+ for (const { location } of workspaces) {
258
+ if (location === ".") continue;
259
+ const pkg = readWorkspacePackageJson(cwd, location);
260
+ if (!pkg) continue;
261
+ const version = pkg.version;
262
+ if (version && semver.valid(version)) {
263
+ versions.push(version);
264
+ }
265
+ }
266
+ if (versions.length === 0) return;
267
+ const highest = versions.toSorted(semver.rcompare)[0];
268
+ for (const { location, name } of workspaces) {
269
+ if (location === ".") continue;
270
+ const pkg = readWorkspacePackageJson(cwd, location);
271
+ if (!pkg) continue;
272
+ if (pkg.version !== highest) {
273
+ pkg.version = highest;
274
+ writeWorkspacePackageJson(cwd, location, pkg);
275
+ console.log(chalk4.green(` \u2714 Fixed: set version to ${highest} in ${name} (${location})`));
276
+ }
277
+ }
278
+ }
279
+ function expectedDepVersion(targetVersion) {
280
+ const parsed = semver.parse(targetVersion);
281
+ if (!parsed) return `~${targetVersion}`;
282
+ return `~${targetVersion}`;
283
+ }
284
+ function checkInternalDepVersions(cwd, workspaces) {
285
+ const result = {
286
+ errors: [],
287
+ fixable: [],
288
+ warnings: []
289
+ };
290
+ const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
291
+ for (const { location, name } of workspaces) {
292
+ const pkg = readWorkspacePackageJson(cwd, location);
293
+ if (!pkg) continue;
294
+ for (const depField of ["dependencies", "devDependencies"]) {
295
+ const deps = pkg[depField];
296
+ if (!deps) continue;
297
+ for (const [dep, version] of Object.entries(deps)) {
298
+ const targetVersion = workspaceVersions.get(dep);
299
+ if (!targetVersion) continue;
300
+ const expected = expectedDepVersion(targetVersion);
301
+ if (version.startsWith("workspace:")) {
302
+ result.fixable.push(
303
+ `${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should be "${expected}" (not workspace: protocol)`
304
+ );
305
+ } else if (version !== expected) {
306
+ result.fixable.push(
307
+ `${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should be "${expected}"`
308
+ );
309
+ }
310
+ }
311
+ }
312
+ }
313
+ return result;
314
+ }
315
+ function fixInternalDepVersions(cwd, workspaces) {
316
+ const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
317
+ for (const { location, name } of workspaces) {
318
+ const pkg = readWorkspacePackageJson(cwd, location);
319
+ if (!pkg) continue;
320
+ let modified = false;
321
+ for (const depField of ["dependencies", "devDependencies"]) {
322
+ const deps = pkg[depField];
323
+ if (!deps) continue;
324
+ for (const [dep, version] of Object.entries(deps)) {
325
+ const targetVersion = workspaceVersions.get(dep);
326
+ if (!targetVersion) continue;
327
+ const expected = expectedDepVersion(targetVersion);
328
+ if (version !== expected) {
329
+ deps[dep] = expected;
330
+ console.log(chalk4.green(` \u2714 Fixed: set ${depField}.${dep} to "${expected}" in ${name} (${location})`));
331
+ modified = true;
332
+ }
333
+ }
334
+ }
335
+ if (modified) {
336
+ writeWorkspacePackageJson(cwd, location, pkg);
337
+ }
338
+ }
339
+ }
340
+ function checkWorkspaceProtocol(cwd, workspaces) {
341
+ const result = {
342
+ errors: [],
343
+ fixable: [],
344
+ warnings: []
345
+ };
346
+ const workspaceNames = new Set(workspaces.map((w) => w.name));
347
+ for (const { location, name } of workspaces) {
348
+ const pkg = readWorkspacePackageJson(cwd, location);
349
+ if (!pkg) continue;
350
+ for (const depField of ["dependencies", "devDependencies"]) {
351
+ const deps = pkg[depField];
352
+ if (!deps) continue;
353
+ for (const [dep, version] of Object.entries(deps)) {
354
+ if (!workspaceNames.has(dep)) continue;
355
+ if (!version.startsWith("workspace:")) {
356
+ result.fixable.push(
357
+ `${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should use workspace: protocol`
358
+ );
359
+ }
360
+ }
361
+ }
362
+ }
363
+ return result;
364
+ }
365
+ function fixWorkspaceProtocol(cwd, workspaces) {
366
+ const workspaceNames = new Set(workspaces.map((w) => w.name));
367
+ for (const { location, name } of workspaces) {
368
+ const pkg = readWorkspacePackageJson(cwd, location);
369
+ if (!pkg) continue;
370
+ let modified = false;
371
+ for (const depField of ["dependencies", "devDependencies"]) {
372
+ const deps = pkg[depField];
373
+ if (!deps) continue;
374
+ for (const [dep, version] of Object.entries(deps)) {
375
+ if (!workspaceNames.has(dep)) continue;
376
+ if (!version.startsWith("workspace:")) {
377
+ deps[dep] = "workspace:~";
378
+ console.log(chalk4.green(` \u2714 Fixed: set ${depField}.${dep} to "workspace:~" in ${name} (${location})`));
379
+ modified = true;
380
+ }
381
+ }
382
+ }
383
+ if (modified) {
384
+ writeWorkspacePackageJson(cwd, location, pkg);
385
+ }
386
+ }
387
+ }
388
+ function checkInternalPeerVersions(cwd, workspaces) {
389
+ const result = {
390
+ errors: [],
391
+ fixable: [],
392
+ warnings: []
393
+ };
394
+ const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
395
+ for (const { location, name } of workspaces) {
396
+ const pkg = readWorkspacePackageJson(cwd, location);
397
+ if (!pkg) continue;
398
+ const peerDeps = pkg.peerDependencies;
399
+ if (!peerDeps) continue;
400
+ const devDeps = pkg.devDependencies;
401
+ for (const [dep, version] of Object.entries(peerDeps)) {
402
+ const targetVersion = workspaceVersions.get(dep);
403
+ if (!targetVersion) continue;
404
+ if (version.startsWith("workspace:")) {
405
+ const expected2 = expectedPeerRange(devDeps?.[dep], targetVersion);
406
+ result.fixable.push(
407
+ `${name} (${location}) peerDependencies.${dep} uses workspace: protocol \u2014 should be "${expected2}"`
408
+ );
409
+ continue;
410
+ }
411
+ const expected = expectedPeerRange(devDeps?.[dep], targetVersion);
412
+ if (version !== expected && !semver.satisfies(targetVersion, version)) {
413
+ result.fixable.push(
414
+ `${name} (${location}) peerDependencies.${dep} is "${version}" \u2014 current version ${targetVersion} is not satisfied; expected "${expected}"`
415
+ );
416
+ }
417
+ }
418
+ }
419
+ return result;
420
+ }
421
+ function fixInternalPeerVersions(cwd, workspaces) {
422
+ const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
423
+ for (const { location, name } of workspaces) {
424
+ const pkg = readWorkspacePackageJson(cwd, location);
425
+ if (!pkg) continue;
426
+ const peerDeps = pkg.peerDependencies;
427
+ if (!peerDeps) continue;
428
+ const devDeps = pkg.devDependencies;
429
+ let modified = false;
430
+ for (const [dep, version] of Object.entries(peerDeps)) {
431
+ const targetVersion = workspaceVersions.get(dep);
432
+ if (!targetVersion) continue;
433
+ const expected = expectedPeerRange(devDeps?.[dep], targetVersion);
434
+ if (version !== expected) {
435
+ peerDeps[dep] = expected;
436
+ console.log(chalk4.green(` \u2714 Fixed: set peerDependencies.${dep} to "${expected}" in ${name} (${location})`));
437
+ modified = true;
438
+ }
439
+ }
440
+ if (modified) {
441
+ writeWorkspacePackageJson(cwd, location, pkg);
442
+ }
443
+ }
444
+ }
445
+
446
+ // src/actions/gitlint.ts
447
+ import chalk5 from "chalk";
448
+ import ParseGitConfig from "parse-git-config";
449
+ var gitlint = () => {
450
+ console.log(`
451
+ Gitlint Start [${process.cwd()}]
452
+ `);
453
+ let valid = 0;
454
+ let warnings = 0;
455
+ const errors = 0;
456
+ const gitConfig = ParseGitConfig.sync();
457
+ const warn = (message) => {
458
+ console.warn(chalk5.yellow(`Warning: ${message}`));
459
+ warnings++;
460
+ };
461
+ if (gitConfig.core.ignorecase) {
462
+ warn("Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]");
463
+ } else {
464
+ valid++;
465
+ }
466
+ if (gitConfig.core.autocrlf === false) {
467
+ valid++;
468
+ } else {
469
+ warn("Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]");
470
+ }
471
+ if (gitConfig.core.eol === "lf") {
472
+ valid++;
473
+ } else {
474
+ warn('Please set core.eol to "lf" in .git/config file [run yarn gitlint-fix]');
475
+ }
476
+ const resultMessages = [];
477
+ if (valid > 0) {
478
+ resultMessages.push(chalk5.green(`Passed: ${valid}`));
479
+ }
480
+ if (warnings > 0) {
481
+ resultMessages.push(chalk5.yellow(`Warnings: ${warnings}`));
482
+ }
483
+ if (errors > 0) {
484
+ resultMessages.push(chalk5.red(` Errors: ${errors}`));
485
+ }
486
+ console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
487
+ `);
488
+ return warnings + errors === 0 ? 0 : 1;
489
+ };
490
+
491
+ // src/actions/gitlint-fix.ts
492
+ import { execSync } from "child_process";
493
+ import chalk6 from "chalk";
494
+ import ParseGitConfig2 from "parse-git-config";
495
+ var gitlintFix = () => {
496
+ console.log(`
497
+ Gitlint Fix Start [${process.cwd()}]
498
+ `);
499
+ const gitConfig = ParseGitConfig2.sync();
500
+ if (gitConfig.core.ignorecase) {
501
+ execSync("git config core.ignorecase false", { stdio: "inherit" });
502
+ console.warn(chalk6.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
503
+ }
504
+ if (gitConfig.core.autocrlf !== false) {
505
+ execSync("git config core.autocrlf false", { stdio: "inherit" });
506
+ console.warn(chalk6.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
507
+ }
508
+ if (gitConfig.core.eol !== "lf") {
509
+ execSync("git config core.eol lf", { stdio: "inherit" });
510
+ console.warn(chalk6.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
511
+ }
512
+ return 1;
513
+ };
514
+
515
+ // src/actions/lint-init.ts
516
+ import {
517
+ existsSync as existsSync2,
518
+ readFileSync as readFileSync3,
519
+ unlinkSync,
520
+ writeFileSync as writeFileSync2
521
+ } from "fs";
522
+ import PATH3 from "path";
523
+ import { createInterface as createInterface2 } from "readline";
524
+ import chalk7 from "chalk";
525
+ import { globSync } from "glob";
526
+ function detectReactInMonorepo(cwd, verbose) {
527
+ const packageJsonPaths = globSync("packages/**/package.json", {
528
+ cwd,
529
+ ignore: ["**/node_modules/**"]
530
+ });
531
+ for (const relPath of packageJsonPaths) {
532
+ const fullPath = PATH3.resolve(cwd, relPath);
533
+ try {
534
+ const content = readFileSync3(fullPath, "utf8");
535
+ const pkg = JSON.parse(content);
536
+ const deps = pkg.dependencies;
537
+ const peerDeps = pkg.peerDependencies;
538
+ if (deps?.react || peerDeps?.react) {
539
+ if (verbose) console.log(chalk7.gray(` React detected in ${relPath}`));
540
+ return true;
541
+ }
542
+ } catch {
543
+ }
544
+ }
545
+ return false;
546
+ }
547
+
548
+ // src/actions/lintlint.ts
549
+ import { spawnSync as spawnSync2 } from "child_process";
550
+ import {
551
+ existsSync as existsSync3,
552
+ readFileSync as readFileSync4,
553
+ writeFileSync as writeFileSync3
554
+ } from "fs";
555
+ import PATH4 from "path";
556
+ import chalk8 from "chalk";
557
+ import { findUp } from "find-up";
558
+ function parseRuleValue(value) {
559
+ if (typeof value === "string") {
560
+ return { level: value };
561
+ }
562
+ if (typeof value === "number") {
563
+ return { level: String(value) };
564
+ }
565
+ if (Array.isArray(value) && value.length > 0) {
566
+ return {
567
+ level: String(value[0]),
568
+ options: value.length > 1 ? value.slice(1) : void 0
569
+ };
570
+ }
571
+ return void 0;
572
+ }
573
+ function normalizeLevel(level) {
574
+ if (level === "0" || level === "off") return "off";
575
+ if (level === "1" || level === "warn") return "warn";
576
+ if (level === "2" || level === "error") return "error";
577
+ return level;
578
+ }
579
+ function rulesMatch(a, b) {
580
+ if (normalizeLevel(a.level) !== normalizeLevel(b.level)) return false;
581
+ return JSON.stringify(a.options) === JSON.stringify(b.options);
582
+ }
583
+ function formatRule(entry) {
584
+ if (entry.options) {
585
+ return JSON.stringify([entry.level, ...entry.options]);
586
+ }
587
+ return JSON.stringify([entry.level]);
588
+ }
589
+ function mergeRulesFromBlocks(blocks) {
590
+ const merged = /* @__PURE__ */ new Map();
591
+ for (const block of blocks) {
592
+ if (!block.rules) continue;
593
+ for (const [name, value] of Object.entries(block.rules)) {
594
+ const parsed = parseRuleValue(value);
595
+ if (parsed) merged.set(name, parsed);
596
+ }
597
+ }
598
+ return merged;
599
+ }
600
+ function detectSharedPackage(source) {
601
+ if (source.includes("@xylabs/eslint-config-react-flat")) return "@xylabs/eslint-config-react-flat";
602
+ if (source.includes("@xylabs/eslint-config-flat")) return "@xylabs/eslint-config-flat";
603
+ return void 0;
604
+ }
605
+ function extractLocalRuleBlocks(source) {
606
+ const blocks = [];
607
+ const ruleBlockRegex = /\{\s*(?:files\s*:\s*\[.*?\]\s*,\s*)?rules\s*:\s*\{([^}]*(?:\{[^}]*\}[^}]*)*)\}/g;
608
+ let match;
609
+ while ((match = ruleBlockRegex.exec(source)) !== null) {
610
+ blocks.push(match[1]);
611
+ }
612
+ return blocks;
613
+ }
614
+ function extractRulesFromSourceBlocks(blocks) {
615
+ const rules = /* @__PURE__ */ new Map();
616
+ for (const block of blocks) {
617
+ const ruleRegex = /['"]([^'"]+)['"]\s*:\s*(\[[\s\S]*?\](?=\s*,|\s*$))/gm;
618
+ let match;
619
+ while ((match = ruleRegex.exec(block)) !== null) {
620
+ rules.set(match[1], match[2]);
621
+ }
622
+ }
623
+ return rules;
624
+ }
625
+ function extractConfigBlocks(sharedModule) {
626
+ const config2 = sharedModule.config ?? sharedModule.default;
627
+ if (Array.isArray(config2)) return config2;
628
+ return [];
629
+ }
630
+ async function resolveSharedConfig(configDir, sharedPkg) {
631
+ try {
632
+ const sharedModule = await import(sharedPkg);
633
+ return extractConfigBlocks(sharedModule);
634
+ } catch {
635
+ const distPath = PATH4.resolve(configDir, "node_modules", sharedPkg, "dist", "node", "index.mjs");
636
+ try {
637
+ const sharedModule = await import(distPath);
638
+ return extractConfigBlocks(sharedModule);
639
+ } catch {
640
+ const neutralPath = PATH4.resolve(configDir, "node_modules", sharedPkg, "dist", "neutral", "index.mjs");
641
+ const sharedModule = await import(neutralPath);
642
+ return extractConfigBlocks(sharedModule);
643
+ }
644
+ return [];
645
+ }
646
+ }
647
+ async function loadSharedRules(configDir, sharedPkg, verbose) {
648
+ const sharedBlocks = await resolveSharedConfig(configDir, sharedPkg);
649
+ const sharedRules = mergeRulesFromBlocks(sharedBlocks);
650
+ if (verbose) {
651
+ console.log(chalk8.gray(`Shared config defines ${sharedRules.size} rules`));
652
+ }
653
+ if (sharedRules.size === 0) {
654
+ console.error(chalk8.red("Could not load rules from shared config. Is it installed and built?"));
655
+ return void 0;
656
+ }
657
+ return sharedRules;
658
+ }
659
+ async function loadLocalRules(eslintConfigPath, source, verbose) {
660
+ const localModule = await import(eslintConfigPath);
661
+ const localConfig = localModule.default ?? localModule;
662
+ const localBlocks = Array.isArray(localConfig) ? localConfig : [localConfig];
663
+ const resolved = mergeRulesFromBlocks(localBlocks);
664
+ const localRuleBlocks = extractLocalRuleBlocks(source);
665
+ const explicit = extractRulesFromSourceBlocks(localRuleBlocks);
666
+ if (verbose) {
667
+ console.log(chalk8.gray(`Local config has ${explicit.size} explicit rule setting(s)`));
668
+ }
669
+ return { explicit, resolved };
670
+ }
671
+ function compareRules(explicitRuleNames, allResolvedRules, sharedRules) {
672
+ const redundant = [];
673
+ const overrides = [];
674
+ const additions = [];
675
+ for (const ruleName of explicitRuleNames.keys()) {
676
+ const resolvedEntry = allResolvedRules.get(ruleName);
677
+ const sharedEntry = sharedRules.get(ruleName);
678
+ if (!resolvedEntry) continue;
679
+ if (!sharedEntry) {
680
+ additions.push({ local: resolvedEntry, rule: ruleName });
681
+ } else if (rulesMatch(resolvedEntry, sharedEntry)) {
682
+ redundant.push({
683
+ local: resolvedEntry,
684
+ rule: ruleName,
685
+ shared: sharedEntry
686
+ });
687
+ } else {
688
+ overrides.push({
689
+ local: resolvedEntry,
690
+ rule: ruleName,
691
+ shared: sharedEntry
692
+ });
693
+ }
694
+ }
695
+ return {
696
+ additions,
697
+ overrides,
698
+ redundant
699
+ };
700
+ }
701
+ function reportResults({
702
+ additions,
703
+ overrides,
704
+ redundant
705
+ }, verbose) {
706
+ if (redundant.length > 0) {
707
+ console.log(chalk8.yellow(`
708
+ ${redundant.length} redundant rule(s) (same as shared config \u2014 can be removed):`));
709
+ for (const { rule, local } of redundant) {
710
+ console.log(chalk8.yellow(` ${rule}: ${formatRule(local)}`));
711
+ }
712
+ }
713
+ if (overrides.length > 0) {
714
+ console.log(chalk8.cyan(`
715
+ ${overrides.length} rule override(s) (different from shared config):`));
716
+ for (const {
717
+ rule,
718
+ local,
719
+ shared
720
+ } of overrides) {
721
+ console.log(chalk8.cyan(` ${rule}:`));
722
+ console.log(chalk8.gray(` shared: ${formatRule(shared)}`));
723
+ console.log(chalk8.white(` local: ${formatRule(local)}`));
724
+ }
725
+ }
726
+ if (additions.length > 0 && verbose) {
727
+ console.log(chalk8.gray(`
728
+ ${additions.length} local addition(s) (not in shared config):`));
729
+ for (const { rule, local } of additions) {
730
+ console.log(chalk8.gray(` ${rule}: ${formatRule(local)}`));
731
+ }
732
+ }
733
+ if (redundant.length === 0 && overrides.length === 0) {
734
+ console.log(chalk8.green("No redundant or overridden rules found"));
735
+ }
736
+ }
737
+ function fixRedundantRules(eslintConfigPath, redundant) {
738
+ let updated = readFileSync4(eslintConfigPath, "utf8");
739
+ const original = updated;
740
+ for (const { rule } of redundant) {
741
+ const escaped = rule.replaceAll("/", String.raw`\/`);
742
+ const pattern = new RegExp(String.raw`[ \t]*['"]${escaped}['"]\s*:\s*\[[^\]]*\],?[ \t]*\n?`, "g");
743
+ updated = updated.replace(pattern, "");
744
+ }
745
+ updated = updated.replaceAll(/\{\s*rules\s*:\s*\{\s*\}\s*,?\s*\}\s*,?/g, "");
746
+ updated = updated.replaceAll(/\n{3,}/g, "\n\n");
747
+ if (updated !== original) {
748
+ writeFileSync3(eslintConfigPath, updated, "utf8");
749
+ console.log(chalk8.green(`
750
+ Fixed: removed ${redundant.length} redundant rule(s)`));
751
+ }
752
+ }
753
+ function formatConfigFile(eslintConfigPath) {
754
+ spawnSync2("eslint", ["--fix", eslintConfigPath], { stdio: "inherit" });
755
+ }
756
+ function fixConfigMismatch(eslintConfigPath, configDir, source, sharedPkg, expectedPkg) {
757
+ const updated = source.replaceAll(sharedPkg, expectedPkg);
758
+ writeFileSync3(eslintConfigPath, updated, "utf8");
759
+ console.log(chalk8.green(`Fixed: replaced ${sharedPkg} with ${expectedPkg}`));
760
+ const packageJsonPath = PATH4.resolve(configDir, "package.json");
761
+ if (!existsSync3(packageJsonPath)) return;
762
+ const content = readFileSync4(packageJsonPath, "utf8");
763
+ const pkg = JSON.parse(content);
764
+ const devDeps = pkg.devDependencies ?? {};
765
+ const oldVersion = devDeps[sharedPkg];
766
+ if (!oldVersion) return;
767
+ delete devDeps[sharedPkg];
768
+ devDeps[expectedPkg] = oldVersion;
769
+ const sorted = Object.fromEntries(Object.entries(devDeps).toSorted(([a], [b]) => a.localeCompare(b)));
770
+ pkg.devDependencies = sorted;
771
+ writeFileSync3(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
772
+ `, "utf8");
773
+ console.log(chalk8.green(`Updated package.json: ${sharedPkg} \u2192 ${expectedPkg}`));
774
+ runInstall(configDir);
775
+ }
776
+ function checkConfigVariant(eslintConfigPath, configDir, source, sharedPkg, fix, verbose) {
777
+ const hasReact = detectReactInMonorepo(configDir, verbose);
778
+ const expectedPkg = hasReact ? "@xylabs/eslint-config-react-flat" : "@xylabs/eslint-config-flat";
779
+ if (sharedPkg === expectedPkg) return false;
780
+ console.log(chalk8.yellow(`
781
+ Config mismatch: using ${sharedPkg} but ${hasReact ? "React packages detected" : "no React packages found"}`));
782
+ console.log(chalk8.yellow(` Expected: ${expectedPkg}`));
783
+ if (fix) {
784
+ fixConfigMismatch(eslintConfigPath, configDir, source, sharedPkg, expectedPkg);
785
+ }
786
+ return true;
787
+ }
788
+ async function lintlint({ fix, verbose } = {}) {
789
+ const eslintConfigPath = await findUp(["eslint.config.ts", "eslint.config.mjs"]);
790
+ if (!eslintConfigPath) {
791
+ console.error(chalk8.red("No eslint.config.ts found"));
792
+ return 1;
793
+ }
794
+ const configDir = PATH4.dirname(eslintConfigPath);
795
+ if (verbose) {
796
+ console.log(chalk8.gray(`Found config: ${eslintConfigPath}`));
797
+ }
798
+ const source = readFileSync4(eslintConfigPath, "utf8");
799
+ const sharedPkg = detectSharedPackage(source);
800
+ if (!sharedPkg) {
801
+ console.log(chalk8.yellow("No @xylabs/eslint-config-flat or @xylabs/eslint-config-react-flat imports found"));
802
+ return 0;
803
+ }
804
+ if (verbose) {
805
+ console.log(chalk8.gray(`Shared package: ${sharedPkg}`));
806
+ }
807
+ const hasMismatch = checkConfigVariant(eslintConfigPath, configDir, source, sharedPkg, !!fix, !!verbose);
808
+ const currentSource = hasMismatch && fix ? readFileSync4(eslintConfigPath, "utf8") : source;
809
+ const sharedRules = await loadSharedRules(configDir, sharedPkg, !!verbose);
810
+ if (!sharedRules) return 1;
811
+ const { explicit, resolved } = await loadLocalRules(eslintConfigPath, currentSource, !!verbose);
812
+ const results = compareRules(explicit, resolved, sharedRules);
813
+ reportResults(results, !!verbose);
814
+ if (results.redundant.length > 0 && fix) {
815
+ fixRedundantRules(eslintConfigPath, results.redundant);
816
+ }
817
+ const didFix = fix && (hasMismatch || results.redundant.length > 0);
818
+ if (didFix) {
819
+ formatConfigFile(eslintConfigPath);
820
+ }
821
+ const hasUnfixedMismatch = hasMismatch && !fix;
822
+ const hasUnfixedRedundant = results.redundant.length > 0 && !fix;
823
+ return hasUnfixedMismatch || hasUnfixedRedundant ? 1 : 0;
824
+ }
825
+
826
+ // src/actions/package/compile/XyConfig.ts
827
+ var ALL_PUBLINT_CHECKS = [
828
+ "files",
829
+ "importToDefault",
830
+ "main",
831
+ "module",
832
+ "peerDeps",
833
+ "publint",
834
+ "resolutions",
835
+ "rootSource",
836
+ "rootTypes",
837
+ "sideEffects",
838
+ "source",
839
+ "types"
840
+ ];
841
+ var PUBLISH_ONLY_CHECKS = [
842
+ "files",
843
+ "importToDefault",
844
+ "main",
845
+ "module",
846
+ "publint",
847
+ "rootSource",
848
+ "rootTypes",
849
+ "sideEffects",
850
+ "source",
851
+ "types"
852
+ ];
853
+
854
+ // src/actions/package/publint.ts
855
+ import { promises as fs } from "fs";
856
+ import path from "path";
857
+ import chalk9 from "chalk";
858
+ import { glob } from "glob";
859
+ import sortPackageJson from "sort-package-json";
860
+ var removeSourceFromExports = (exports) => {
861
+ let removed = false;
862
+ for (const [key, value] of Object.entries(exports)) {
863
+ if (key === "source") {
864
+ delete exports[key];
865
+ removed = true;
866
+ } else if (typeof value === "object" && value !== null && removeSourceFromExports(value)) removed = true;
867
+ }
868
+ return removed;
869
+ };
870
+ var hasSourceInExports = (exports) => {
871
+ for (const [key, value] of Object.entries(exports)) {
872
+ if (key === "source") return true;
873
+ if (typeof value === "object" && value !== null && hasSourceInExports(value)) return true;
874
+ }
875
+ return false;
876
+ };
877
+ var hasImportKeyInExports = (exports) => {
878
+ for (const [key, value] of Object.entries(exports)) {
879
+ if (key === "import" && typeof value === "string" && value.endsWith(".mjs")) return true;
880
+ if (typeof value === "object" && value !== null && hasImportKeyInExports(value)) return true;
881
+ }
882
+ return false;
883
+ };
884
+ var replaceImportWithDefault = (exports) => {
885
+ let modified = false;
886
+ for (const [key, value] of Object.entries(exports)) {
887
+ if (key === "import" && typeof value === "string" && value.endsWith(".mjs")) {
888
+ if (exports.default === void 0) {
889
+ exports.default = value;
890
+ }
891
+ delete exports.import;
892
+ if (exports.types === void 0) {
893
+ exports.types = value.replace(/\.mjs$/, ".d.ts");
894
+ }
895
+ modified = true;
896
+ } else if (typeof value === "object" && value !== null && replaceImportWithDefault(value)) modified = true;
897
+ }
898
+ return modified;
899
+ };
900
+ var hasTypesInExports = (exports) => {
901
+ for (const [key, value] of Object.entries(exports)) {
902
+ if (key === "types") return true;
903
+ if (typeof value === "object" && value !== null && hasTypesInExports(value)) return true;
904
+ }
905
+ return false;
906
+ };
907
+ function ensureExportsPath(value) {
908
+ if (value.startsWith("./") || value.startsWith("../")) return value;
909
+ return `./${value}`;
910
+ }
911
+ function emptyCustomResult() {
912
+ return {
913
+ errors: 0,
914
+ modified: false,
915
+ warnings: 0
916
+ };
917
+ }
918
+ function mergeResults(target, source) {
919
+ target.errors += source.errors;
920
+ target.warnings += source.warnings;
921
+ target.modified = target.modified || source.modified;
922
+ }
923
+ function checkFiles(pkg, fix) {
924
+ const result = emptyCustomResult();
925
+ const files = pkg.files;
926
+ if (files === void 0) {
927
+ console.warn(chalk9.yellow('Publint [custom]: "files" field is missing'));
928
+ result.warnings++;
929
+ }
930
+ if (Array.isArray(files) && !files.includes("README.md")) {
931
+ files.push("README.md");
932
+ console.warn(chalk9.yellow('Publint [custom]: added "README.md" to "files"'));
933
+ result.modified = true;
934
+ result.warnings++;
935
+ }
936
+ if (Array.isArray(files) && files.includes("src")) {
937
+ if (fix) {
938
+ pkg.files = files.filter((f) => f !== "src");
939
+ console.warn(chalk9.yellow('Publint [custom]: removed "src" from "files"'));
940
+ result.modified = true;
941
+ } else {
942
+ console.warn(chalk9.yellow('Publint [custom]: "src" should not be in "files" (use --fix to remove)'));
943
+ }
944
+ result.warnings++;
945
+ }
946
+ return result;
947
+ }
948
+ function checkExportsSource(pkg, fix) {
949
+ const result = emptyCustomResult();
950
+ const exports = pkg.exports;
951
+ if (exports && typeof exports === "object" && hasSourceInExports(exports)) {
952
+ if (fix) {
953
+ removeSourceFromExports(exports);
954
+ console.warn(chalk9.yellow('Publint [custom]: removed "source" entries from "exports"'));
955
+ result.modified = true;
956
+ } else {
957
+ console.warn(chalk9.yellow('Publint [custom]: "source" entries should not be in "exports" (use --fix to remove)'));
958
+ }
959
+ result.warnings++;
960
+ }
961
+ return result;
962
+ }
963
+ function migrateFieldToExports(pkg, field, exportKey, fix) {
964
+ const result = emptyCustomResult();
965
+ if (pkg[field] === void 0) return result;
966
+ const fieldValue = pkg[field];
967
+ if (!fieldValue.endsWith(".js") && !fieldValue.endsWith(".mjs") && !fieldValue.endsWith(".cjs")) return result;
968
+ if (fix) {
969
+ const exportValue = ensureExportsPath(fieldValue);
970
+ const exports = pkg.exports;
971
+ if (exports && typeof exports === "object") {
972
+ const dot = exports["."];
973
+ if (dot && typeof dot === "object" && !dot[exportKey]) {
974
+ dot[exportKey] = exportValue;
975
+ console.warn(chalk9.yellow(`Publint [custom]: migrated "${field}" to "exports['.'].${exportKey}" (${fieldValue})`));
976
+ }
977
+ } else if (!pkg.exports) {
978
+ pkg.exports = { ".": { [exportKey]: exportValue } };
979
+ console.warn(chalk9.yellow(`Publint [custom]: migrated "${field}" to "exports" (.\u2192${fieldValue})`));
980
+ }
981
+ delete pkg[field];
982
+ console.warn(chalk9.yellow(`Publint [custom]: removed deprecated "${field}" field`));
983
+ result.modified = true;
984
+ } else {
985
+ console.warn(chalk9.yellow(`Publint [custom]: "${field}" field is deprecated, use "exports" instead (use --fix to remove)`));
986
+ }
987
+ result.warnings++;
988
+ return result;
989
+ }
990
+ function checkSideEffects(pkg) {
991
+ const result = emptyCustomResult();
992
+ if (pkg.sideEffects !== false) {
993
+ console.warn(chalk9.yellow('Publint [custom]: "sideEffects" field should be set to false'));
994
+ result.warnings++;
995
+ }
996
+ return result;
997
+ }
998
+ function checkRootSource(pkg, fix) {
999
+ const result = emptyCustomResult();
1000
+ for (const field of ["source", "src"]) {
1001
+ if (pkg[field] !== void 0) {
1002
+ if (fix) {
1003
+ delete pkg[field];
1004
+ console.warn(chalk9.yellow(`Publint [custom]: removed root-level "${field}" field`));
1005
+ result.modified = true;
1006
+ } else {
1007
+ console.warn(chalk9.yellow(`Publint [custom]: root-level "${field}" field should not be in package.json (use --fix to remove)`));
1008
+ }
1009
+ result.warnings++;
1010
+ }
1011
+ }
1012
+ return result;
1013
+ }
1014
+ function checkResolutions(pkg) {
1015
+ const result = emptyCustomResult();
1016
+ if (pkg.resolutions !== void 0) {
1017
+ console.warn(chalk9.yellow('Publint [custom]: "resolutions" in use'));
1018
+ console.warn(chalk9.gray(JSON.stringify(pkg.resolutions, null, 2)));
1019
+ result.warnings++;
1020
+ }
1021
+ return result;
1022
+ }
1023
+ function checkImportToDefault(pkg, fix) {
1024
+ const result = emptyCustomResult();
1025
+ const exports = pkg.exports;
1026
+ if (!exports || typeof exports !== "object") return result;
1027
+ if (!hasImportKeyInExports(exports)) return result;
1028
+ if (fix) {
1029
+ replaceImportWithDefault(exports);
1030
+ console.warn(chalk9.yellow('Publint [custom]: renamed "import" to "default" in "exports" and ensured "types" siblings'));
1031
+ result.modified = true;
1032
+ } else {
1033
+ console.warn(chalk9.yellow('Publint [custom]: "import" entries in "exports" should use "default" instead (use --fix to rename)'));
1034
+ }
1035
+ result.warnings++;
1036
+ return result;
1037
+ }
1038
+ function checkRootTypes(pkg, fix) {
1039
+ const result = emptyCustomResult();
1040
+ if (pkg.types === void 0) return result;
1041
+ const exports = pkg.exports;
1042
+ if (!exports || typeof exports !== "object" || !hasTypesInExports(exports)) return result;
1043
+ if (fix) {
1044
+ delete pkg.types;
1045
+ console.warn(chalk9.yellow('Publint [custom]: removed redundant root "types" field (already defined in "exports")'));
1046
+ result.modified = true;
1047
+ } else {
1048
+ console.warn(chalk9.yellow('Publint [custom]: root "types" field is redundant when "exports" defines types (use --fix to remove)'));
1049
+ }
1050
+ result.warnings++;
1051
+ return result;
1052
+ }
1053
+ function customPubLint(pkg, fix = false, exclude = /* @__PURE__ */ new Set()) {
1054
+ const result = emptyCustomResult();
1055
+ if (!exclude.has("files")) mergeResults(result, checkFiles(pkg, fix));
1056
+ if (!exclude.has("source")) mergeResults(result, checkExportsSource(pkg, fix));
1057
+ if (!exclude.has("rootSource")) mergeResults(result, checkRootSource(pkg, fix));
1058
+ if (!exclude.has("main")) mergeResults(result, migrateFieldToExports(pkg, "main", "default", fix));
1059
+ if (!exclude.has("types")) mergeResults(result, migrateFieldToExports(pkg, "types", "types", fix));
1060
+ if (!exclude.has("module")) mergeResults(result, migrateFieldToExports(pkg, "module", "default", fix));
1061
+ if (!exclude.has("importToDefault")) mergeResults(result, checkImportToDefault(pkg, fix));
1062
+ if (!exclude.has("rootTypes")) mergeResults(result, checkRootTypes(pkg, fix));
1063
+ if (!exclude.has("sideEffects")) mergeResults(result, checkSideEffects(pkg));
1064
+ if (!exclude.has("resolutions")) mergeResults(result, checkResolutions(pkg));
1065
+ return [result.errors, result.warnings, result.modified];
1066
+ }
1067
+ var ALWAYS_INCLUDED_PATTERNS = [
1068
+ "package.json",
1069
+ "README",
1070
+ "README.*",
1071
+ "LICENCE",
1072
+ "LICENCE.*",
1073
+ "LICENSE",
1074
+ "LICENSE.*",
1075
+ "CHANGELOG",
1076
+ "CHANGELOG.*"
1077
+ ];
1078
+ async function resolvePackFiles(pkgDir, filesField) {
1079
+ const patterns = [...ALWAYS_INCLUDED_PATTERNS];
1080
+ if (filesField) {
1081
+ for (const pattern of filesField) {
1082
+ if (pattern.startsWith("!")) {
1083
+ patterns.push(pattern);
1084
+ } else {
1085
+ patterns.push(pattern, `${pattern}/**`);
1086
+ }
1087
+ }
1088
+ }
1089
+ const matched = await glob(patterns, {
1090
+ cwd: pkgDir,
1091
+ nodir: true,
1092
+ dot: false
1093
+ });
1094
+ const files = await Promise.all(
1095
+ matched.map(async (rel) => {
1096
+ const abs = path.join(pkgDir, rel);
1097
+ const data = await fs.readFile(abs, "utf8").catch(() => "");
1098
+ return { name: path.join(pkgDir, rel), data };
1099
+ })
1100
+ );
1101
+ return files;
1102
+ }
1103
+ async function runPublintLibrary(pkgDir, pkg, strict, pack) {
1104
+ const { publint: publint2 } = await import("publint");
1105
+ let packOption = false;
1106
+ if (pack) {
1107
+ const files = await resolvePackFiles(pkgDir, pkg.files);
1108
+ packOption = { files };
1109
+ }
1110
+ const { messages } = await publint2({
1111
+ level: "suggestion",
1112
+ pack: packOption,
1113
+ pkgDir,
1114
+ strict
1115
+ });
1116
+ const { formatMessage } = await import("publint/utils");
1117
+ for (const message of messages) {
1118
+ switch (message.type) {
1119
+ case "error": {
1120
+ console.error(chalk9.red(`[${message.code}] ${formatMessage(message, pkg)}`));
1121
+ break;
1122
+ }
1123
+ case "warning": {
1124
+ console.warn(chalk9.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
1125
+ break;
1126
+ }
1127
+ default: {
1128
+ console.log(chalk9.white(`[${message.code}] ${formatMessage(message, pkg)}`));
1129
+ break;
1130
+ }
1131
+ }
1132
+ }
1133
+ return {
1134
+ errors: messages.filter((message) => message.type === "error").length,
1135
+ total: messages.length
1136
+ };
1137
+ }
1138
+ var packagePublint = async ({
1139
+ exclude = /* @__PURE__ */ new Set(),
1140
+ fix = false,
1141
+ pack = true,
1142
+ pkgDir: pkgDirParam,
1143
+ strict = true,
1144
+ verbose: _verbose = false
1145
+ } = {}) => {
1146
+ const pkgDir = pkgDirParam ?? INIT_CWD();
1147
+ const sortedPkg = sortPackageJson(await fs.readFile(`${pkgDir}/package.json`, "utf8"));
1148
+ await fs.writeFile(`${pkgDir}/package.json`, sortedPkg);
1149
+ const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, "utf8"));
1150
+ const effectiveExclude = pkg.private ? /* @__PURE__ */ new Set([...exclude, ...PUBLISH_ONLY_CHECKS]) : exclude;
1151
+ console.log(chalk9.green(`Publint: ${String(pkg.name)}${pkg.private ? chalk9.gray(" (private)") : ""}`));
1152
+ console.log(chalk9.gray(pkgDir));
1153
+ let libraryErrors = 0;
1154
+ if (!effectiveExclude.has("publint")) {
1155
+ const library = await runPublintLibrary(pkgDir, pkg, strict, pack);
1156
+ libraryErrors = library.errors;
1157
+ }
1158
+ const [errorCount, _warningCount, modified] = customPubLint(pkg, fix, effectiveExclude);
1159
+ if (modified) {
1160
+ const sorted = sortPackageJson(JSON.stringify(pkg, null, 2));
1161
+ await fs.writeFile(`${pkgDir}/package.json`, sorted);
1162
+ }
1163
+ return libraryErrors + errorCount;
1164
+ };
1165
+
1166
+ // src/actions/package-lint.ts
1167
+ import {
1168
+ existsSync as existsSync4,
1169
+ readFileSync as readFileSync5,
1170
+ writeFileSync as writeFileSync4
1171
+ } from "fs";
1172
+ import PATH5 from "path";
1173
+ import chalk10 from "chalk";
1174
+ import picomatch from "picomatch";
1175
+ import semver2 from "semver";
1176
+ function emptyResult() {
1177
+ return {
1178
+ errors: [],
1179
+ fixable: [],
1180
+ warnings: []
1181
+ };
1182
+ }
1183
+ function readRootPackageJson(cwd) {
1184
+ const raw = readFileSync5(PATH5.resolve(cwd, "package.json"), "utf8");
1185
+ return JSON.parse(raw);
1186
+ }
1187
+ function writeRootPackageJson(cwd, pkg) {
1188
+ const path2 = PATH5.resolve(cwd, "package.json");
1189
+ writeFileSync4(path2, `${JSON.stringify(pkg, null, 2)}
1190
+ `, "utf8");
1191
+ }
1192
+ function readPnpmWorkspaceGlobs(cwd) {
1193
+ const wsPath = PATH5.resolve(cwd, "pnpm-workspace.yaml");
1194
+ if (!existsSync4(wsPath)) return void 0;
1195
+ const raw = readFileSync5(wsPath, "utf8");
1196
+ const globs = [];
1197
+ let inPackages = false;
1198
+ for (const line of raw.split("\n")) {
1199
+ if (/^packages\s*:/.test(line)) {
1200
+ inPackages = true;
1201
+ continue;
1202
+ }
1203
+ if (inPackages) {
1204
+ const match = /^\s+-\s+['"]?([^'"]+)['"]?\s*$/.exec(line);
1205
+ if (match) {
1206
+ globs.push(match[1]);
1207
+ } else if (/^\S/.test(line) && line.trim() !== "") {
1208
+ break;
1209
+ }
1210
+ }
1211
+ }
1212
+ return globs.length > 0 ? globs : void 0;
1213
+ }
1214
+ function isMonorepo(pkg, cwd) {
1215
+ const workspaces = pkg.workspaces;
1216
+ if (Array.isArray(workspaces) && workspaces.length > 0) return true;
1217
+ return readPnpmWorkspaceGlobs(cwd) !== void 0;
1218
+ }
1219
+ function checkPackagesFolder(workspaces) {
1220
+ const result = emptyResult();
1221
+ for (const { location, name } of workspaces) {
1222
+ if (location === ".") continue;
1223
+ if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
1224
+ result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
1225
+ }
1226
+ }
1227
+ return result;
1228
+ }
1229
+ function checkRootPrivate(pkg) {
1230
+ const result = emptyResult();
1231
+ if (!pkg.private) {
1232
+ result.fixable.push("Root package.json must be private to prevent accidental publishing");
1233
+ }
1234
+ return result;
1235
+ }
1236
+ function fixRootPrivate(cwd, pkg) {
1237
+ pkg.private = true;
1238
+ writeRootPackageJson(cwd, pkg);
1239
+ console.log(chalk10.green(' \u2714 Fixed: set "private": true in root package.json'));
1240
+ }
1241
+ function checkNoPublishConfigOnPrivate(pkg) {
1242
+ const result = emptyResult();
1243
+ if (pkg.private && pkg.publishConfig) {
1244
+ result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
1245
+ }
1246
+ return result;
1247
+ }
1248
+ function fixNoPublishConfigOnPrivate(cwd, pkg) {
1249
+ delete pkg.publishConfig;
1250
+ writeRootPackageJson(cwd, pkg);
1251
+ console.log(chalk10.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
1252
+ }
1253
+ function checkNoPackageManagerInWorkspaces(cwd, workspaces) {
1254
+ const result = emptyResult();
1255
+ for (const { location, name } of workspaces) {
1256
+ if (location === ".") continue;
1257
+ const pkgPath = PATH5.resolve(cwd, location, "package.json");
1258
+ try {
1259
+ const raw = readFileSync5(pkgPath, "utf8");
1260
+ const pkg = JSON.parse(raw);
1261
+ if (pkg.packageManager) {
1262
+ result.fixable.push(`${name} (${location}) has a packageManager field \u2014 only the root should define this`);
1263
+ }
1264
+ } catch {
1265
+ }
1266
+ }
1267
+ return result;
1268
+ }
1269
+ function fixNoPackageManagerInWorkspaces(cwd, _pkg, workspaces) {
1270
+ for (const { location } of workspaces) {
1271
+ if (location === ".") continue;
1272
+ const pkgPath = PATH5.resolve(cwd, location, "package.json");
1273
+ try {
1274
+ const raw = readFileSync5(pkgPath, "utf8");
1275
+ const pkg = JSON.parse(raw);
1276
+ if (pkg.packageManager) {
1277
+ delete pkg.packageManager;
1278
+ writeFileSync4(pkgPath, `${JSON.stringify(pkg, null, 2)}
1279
+ `, "utf8");
1280
+ console.log(chalk10.green(` \u2714 Fixed: removed packageManager from ${location}/package.json`));
1281
+ }
1282
+ } catch {
1283
+ }
1284
+ }
1285
+ }
1286
+ function checkWorkspacesFieldPlacement(cwd, pm, workspaces) {
1287
+ const result = emptyResult();
1288
+ for (const { location, name } of workspaces) {
1289
+ if (pm === "pnpm" ? true : location !== ".") {
1290
+ const pkgPath = PATH5.resolve(cwd, location, "package.json");
1291
+ try {
1292
+ const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
1293
+ if (pkg.workspaces) {
1294
+ const label = location === "." ? "Root" : `${name} (${location})`;
1295
+ const reason = pm === "pnpm" ? "pnpm uses pnpm-workspace.yaml instead" : "only the root should define workspaces";
1296
+ result.fixable.push(`${label} has a workspaces field \u2014 ${reason}`);
1297
+ }
1298
+ } catch {
1299
+ }
1300
+ }
1301
+ }
1302
+ return result;
1303
+ }
1304
+ function fixWorkspacesFieldPlacement(cwd, pm, workspaces) {
1305
+ for (const { location } of workspaces) {
1306
+ if (pm === "pnpm" ? true : location !== ".") {
1307
+ const pkgPath = PATH5.resolve(cwd, location, "package.json");
1308
+ try {
1309
+ const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
1310
+ if (pkg.workspaces) {
1311
+ delete pkg.workspaces;
1312
+ writeFileSync4(pkgPath, `${JSON.stringify(pkg, null, 2)}
1313
+ `, "utf8");
1314
+ const label = location === "." ? "root" : location;
1315
+ console.log(chalk10.green(` \u2714 Fixed: removed workspaces from ${label}/package.json`));
1316
+ }
1317
+ } catch {
1318
+ }
1319
+ }
1320
+ }
1321
+ }
1322
+ function checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces) {
1323
+ const result = emptyResult();
1324
+ const globs = pm === "pnpm" ? readPnpmWorkspaceGlobs(cwd) ?? [] : Array.isArray(pkg.workspaces) ? pkg.workspaces : [];
1325
+ if (globs.length === 0) {
1326
+ const source = pm === "pnpm" ? "pnpm-workspace.yaml" : "root package.json workspaces";
1327
+ result.errors.push(`No workspace globs found in ${source}`);
1328
+ return result;
1329
+ }
1330
+ const matchers = globs.map((glob2) => picomatch(glob2));
1331
+ const isMatch = (location) => matchers.some((m) => m(location));
1332
+ for (const { location, name } of workspaces) {
1333
+ if (location === ".") continue;
1334
+ if (!isMatch(location)) {
1335
+ const source = pm === "pnpm" ? "pnpm-workspace.yaml" : "root package.json workspaces";
1336
+ result.errors.push(`${name} (${location}) is not matched by any glob in ${source}`);
1337
+ }
1338
+ }
1339
+ return result;
1340
+ }
1341
+ function logResults(label, result, fix) {
1342
+ let errors = 0;
1343
+ let fixed = 0;
1344
+ for (const error of result.errors) {
1345
+ console.log(chalk10.red(` \u2717 ${error}`));
1346
+ errors++;
1347
+ }
1348
+ for (const fixable of result.fixable) {
1349
+ if (fix) {
1350
+ fixed++;
1351
+ } else {
1352
+ console.log(chalk10.red(` \u2717 ${fixable} (fixable)`));
1353
+ errors++;
1354
+ }
1355
+ }
1356
+ for (const warning of result.warnings) {
1357
+ console.log(chalk10.yellow(` \u26A0 ${warning}`));
1358
+ }
1359
+ if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
1360
+ console.log(chalk10.green(` \u2713 ${label}`));
1361
+ }
1362
+ return { errors, fixed };
1363
+ }
1364
+ function runChecks(entries, cwd, pkg, fix) {
1365
+ let totalErrors = 0;
1366
+ let totalFixed = 0;
1367
+ for (const entry of entries) {
1368
+ const result = entry.check();
1369
+ const log = logResults(entry.label, result, fix);
1370
+ if (fix && entry.fix && result.fixable.length > 0) {
1371
+ entry.fix(cwd, pkg);
1372
+ }
1373
+ totalErrors += log.errors;
1374
+ totalFixed += log.fixed;
1375
+ }
1376
+ return { errors: totalErrors, fixed: totalFixed };
1377
+ }
1378
+ function checkVoltaOnlyInRoot(cwd, workspaces) {
1379
+ const result = emptyResult();
1380
+ for (const { location, name } of workspaces) {
1381
+ if (location === ".") continue;
1382
+ const pkgPath = PATH5.resolve(cwd, location, "package.json");
1383
+ try {
1384
+ const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
1385
+ if (pkg.volta) {
1386
+ result.fixable.push(`${name} (${location}) has a volta field \u2014 only the root should define this`);
1387
+ }
1388
+ } catch {
1389
+ }
1390
+ }
1391
+ return result;
1392
+ }
1393
+ function fixVoltaOnlyInRoot(cwd, _pkg, workspaces) {
1394
+ for (const { location } of workspaces) {
1395
+ if (location === ".") continue;
1396
+ const pkgPath = PATH5.resolve(cwd, location, "package.json");
1397
+ try {
1398
+ const raw = readFileSync5(pkgPath, "utf8");
1399
+ const pkg = JSON.parse(raw);
1400
+ if (pkg.volta) {
1401
+ delete pkg.volta;
1402
+ writeFileSync4(pkgPath, `${JSON.stringify(pkg, null, 2)}
1403
+ `, "utf8");
1404
+ console.log(chalk10.green(` \u2714 Fixed: removed volta from ${location}/package.json`));
1405
+ }
1406
+ } catch {
1407
+ }
1408
+ }
1409
+ }
1410
+ function isTerminalPackage(pkg) {
1411
+ return pkg.private === true;
1412
+ }
1413
+ function checkEnginesOnlyInNonTerminal(cwd, workspaces) {
1414
+ const result = emptyResult();
1415
+ const rootPkg = JSON.parse(readFileSync5(PATH5.resolve(cwd, "package.json"), "utf8"));
1416
+ if (rootPkg.engines) {
1417
+ result.fixable.push("Root package.json has engines \u2014 terminal packages should not declare engines (use volta instead)");
1418
+ }
1419
+ for (const { location, name } of workspaces) {
1420
+ if (location === ".") continue;
1421
+ const pkgPath = PATH5.resolve(cwd, location, "package.json");
1422
+ try {
1423
+ const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
1424
+ if (isTerminalPackage(pkg) && pkg.engines) {
1425
+ result.fixable.push(`${name} (${location}) is terminal (private) but has engines \u2014 terminal packages should not declare engines`);
1426
+ }
1427
+ if (!isTerminalPackage(pkg) && !pkg.engines) {
1428
+ result.fixable.push(`${name} (${location}) is a library but has no engines field`);
1429
+ }
1430
+ } catch {
1431
+ }
1432
+ }
1433
+ return result;
1434
+ }
1435
+ function fixEnginesOnlyInNonTerminal(cwd, _pkg, workspaces) {
1436
+ const rootPath = PATH5.resolve(cwd, "package.json");
1437
+ const rootRaw = readFileSync5(rootPath, "utf8");
1438
+ const rootPkg = JSON.parse(rootRaw);
1439
+ if (rootPkg.engines) {
1440
+ delete rootPkg.engines;
1441
+ writeFileSync4(rootPath, `${JSON.stringify(rootPkg, null, 2)}
1442
+ `, "utf8");
1443
+ console.log(chalk10.green(" \u2714 Fixed: removed engines from root package.json"));
1444
+ }
1445
+ const enginesTemplate = resolveEnginesTemplate(cwd, workspaces);
1446
+ for (const { location } of workspaces) {
1447
+ if (location === ".") continue;
1448
+ const pkgPath = PATH5.resolve(cwd, location, "package.json");
1449
+ try {
1450
+ const raw = readFileSync5(pkgPath, "utf8");
1451
+ const pkg = JSON.parse(raw);
1452
+ if (isTerminalPackage(pkg) && pkg.engines) {
1453
+ delete pkg.engines;
1454
+ writeFileSync4(pkgPath, `${JSON.stringify(pkg, null, 2)}
1455
+ `, "utf8");
1456
+ console.log(chalk10.green(` \u2714 Fixed: removed engines from ${location}/package.json`));
1457
+ }
1458
+ if (!isTerminalPackage(pkg) && !pkg.engines && enginesTemplate) {
1459
+ pkg.engines = enginesTemplate;
1460
+ writeFileSync4(pkgPath, `${JSON.stringify(pkg, null, 2)}
1461
+ `, "utf8");
1462
+ console.log(chalk10.green(` \u2714 Fixed: added engines to ${location}/package.json`));
1463
+ }
1464
+ } catch {
1465
+ }
1466
+ }
1467
+ }
1468
+ function resolveEnginesTemplate(cwd, workspaces) {
1469
+ for (const { location } of workspaces) {
1470
+ if (location === ".") continue;
1471
+ try {
1472
+ const pkg = JSON.parse(readFileSync5(PATH5.resolve(cwd, location, "package.json"), "utf8"));
1473
+ if (!isTerminalPackage(pkg) && pkg.engines) {
1474
+ return pkg.engines;
1475
+ }
1476
+ } catch {
1477
+ }
1478
+ }
1479
+ return void 0;
1480
+ }
1481
+ function checkVersionsIncludeLts(cwd, workspaces) {
1482
+ const result = emptyResult();
1483
+ const toolVersions = {
1484
+ node: latestVersions.node,
1485
+ npm: latestVersions.npm,
1486
+ pnpm: latestVersions.pnpm,
1487
+ yarn: latestVersions.yarn
1488
+ };
1489
+ for (const { location, name } of workspaces) {
1490
+ const pkgPath = location === "." ? PATH5.resolve(cwd, "package.json") : PATH5.resolve(cwd, location, "package.json");
1491
+ try {
1492
+ const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
1493
+ const label = location === "." ? "root" : `${name} (${location})`;
1494
+ const engines = pkg.engines;
1495
+ if (engines) {
1496
+ for (const [tool, range] of Object.entries(engines)) {
1497
+ const latest = toolVersions[tool];
1498
+ if (latest && !semver2.satisfies(latest, range)) {
1499
+ result.errors.push(
1500
+ `${label} engines.${tool} "${range}" does not include latest ${tool === "node" ? "LTS " : ""}version ${latest}`
1501
+ );
1502
+ }
1503
+ }
1504
+ }
1505
+ const volta = pkg.volta;
1506
+ if (volta) {
1507
+ for (const [tool, pinnedVersion] of Object.entries(volta)) {
1508
+ const latest = toolVersions[tool];
1509
+ if (latest && semver2.lt(pinnedVersion, latest)) {
1510
+ result.warnings.push(
1511
+ `${label} volta.${tool} "${pinnedVersion}" is older than latest ${tool === "node" ? "LTS " : ""}version ${latest}`
1512
+ );
1513
+ }
1514
+ }
1515
+ }
1516
+ } catch {
1517
+ }
1518
+ }
1519
+ return result;
1520
+ }
1521
+ function logSummary(errors, fixed) {
1522
+ if (fixed > 0) {
1523
+ console.log(chalk10.green(`
1524
+ Fixed ${fixed} issue(s)`));
1525
+ }
1526
+ if (errors > 0) {
1527
+ console.log(chalk10.red(`
1528
+ ${errors} error(s) found`));
1529
+ } else if (fixed === 0) {
1530
+ console.log(chalk10.green("\n All checks passed"));
1531
+ }
1532
+ }
1533
+ function packageLintMonorepo(fix = false) {
1534
+ const cwd = INIT_CWD();
1535
+ let pkg;
1536
+ try {
1537
+ pkg = readRootPackageJson(cwd);
1538
+ } catch {
1539
+ console.error(chalk10.red("Could not read package.json"));
1540
+ return 1;
1541
+ }
1542
+ if (!isMonorepo(pkg, cwd)) {
1543
+ console.log(chalk10.gray("Not a monorepo \u2014 skipping repo lint checks"));
1544
+ return 0;
1545
+ }
1546
+ console.log(chalk10.green("Repo Lint"));
1547
+ const pm = detectPackageManager();
1548
+ const workspaces = getPackageManager().listWorkspaces();
1549
+ const internalDepCheck = pm === "pnpm" ? {
1550
+ check: () => checkWorkspaceProtocol(cwd, workspaces),
1551
+ fix: () => fixWorkspaceProtocol(cwd, workspaces),
1552
+ label: "Internal deps/devDeps use workspace: protocol"
1553
+ } : {
1554
+ check: () => checkInternalDepVersions(cwd, workspaces),
1555
+ fix: () => fixInternalDepVersions(cwd, workspaces),
1556
+ label: "Internal deps/devDeps use correct version ranges"
1557
+ };
1558
+ const checks = [
1559
+ {
1560
+ check: () => checkRootPrivate(pkg),
1561
+ fix: fixRootPrivate,
1562
+ label: "Root package is private"
1563
+ },
1564
+ {
1565
+ check: () => checkNoPublishConfigOnPrivate(pkg),
1566
+ fix: fixNoPublishConfigOnPrivate,
1567
+ label: "No publishConfig on private root"
1568
+ },
1569
+ { check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
1570
+ {
1571
+ check: () => checkWorkspacesFieldPlacement(cwd, pm, workspaces),
1572
+ fix: () => fixWorkspacesFieldPlacement(cwd, pm, workspaces),
1573
+ label: pm === "pnpm" ? "No workspaces field in package.json (use pnpm-workspace.yaml)" : "Workspaces field only in root package.json"
1574
+ },
1575
+ {
1576
+ check: () => checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces),
1577
+ label: "Workspace globs cover all packages"
1578
+ },
1579
+ {
1580
+ check: () => checkNoPackageManagerInWorkspaces(cwd, workspaces),
1581
+ fix: () => fixNoPackageManagerInWorkspaces(cwd, pkg, workspaces),
1582
+ label: "No packageManager in workspace packages"
1583
+ },
1584
+ {
1585
+ check: () => checkVoltaOnlyInRoot(cwd, workspaces),
1586
+ fix: () => fixVoltaOnlyInRoot(cwd, pkg, workspaces),
1587
+ label: "Volta only in root package.json"
1588
+ },
1589
+ {
1590
+ check: () => checkEnginesOnlyInNonTerminal(cwd, workspaces),
1591
+ fix: () => fixEnginesOnlyInNonTerminal(cwd, pkg, workspaces),
1592
+ label: "Engines only in non-terminal (library) packages"
1593
+ },
1594
+ {
1595
+ check: () => checkVersionsIncludeLts(cwd, workspaces),
1596
+ label: "Engine/volta versions include latest LTS"
1597
+ },
1598
+ {
1599
+ check: () => checkVersionConsistency(cwd, pkg, workspaces),
1600
+ fix: () => fixVersionConsistency(cwd, pkg, writeRootPackageJson, workspaces),
1601
+ label: "Consistent versions across packages"
1602
+ },
1603
+ internalDepCheck,
1604
+ {
1605
+ check: () => checkInternalPeerVersions(cwd, workspaces),
1606
+ fix: () => fixInternalPeerVersions(cwd, workspaces),
1607
+ label: "Internal peerDeps use semver ranges (not workspace: protocol)"
1608
+ }
1609
+ ];
1610
+ const { errors, fixed } = runChecks(checks, cwd, pkg, fix);
1611
+ logSummary(errors, fixed);
1612
+ if (fix && fixed > 0) {
1613
+ runInstall();
1614
+ }
1615
+ return errors > 0 ? 1 : 0;
1616
+ }
1617
+
1618
+ // src/actions/publint.ts
1619
+ import chalk11 from "chalk";
1620
+ function resolveExclude(publintConfig, cliExclude, cliInclude) {
1621
+ const hasExclude = (publintConfig.exclude?.length ?? 0) > 0 || (cliExclude?.length ?? 0) > 0;
1622
+ const hasInclude = (publintConfig.include?.length ?? 0) > 0 || (cliInclude?.length ?? 0) > 0;
1623
+ if (hasExclude && hasInclude) {
1624
+ console.error(chalk11.red("Publint: --include and --exclude cannot be used together"));
1625
+ return void 0;
1626
+ }
1627
+ if (hasInclude) {
1628
+ const include = /* @__PURE__ */ new Set([
1629
+ ...publintConfig.include ?? [],
1630
+ ...cliInclude ?? []
1631
+ ]);
1632
+ return new Set(ALL_PUBLINT_CHECKS.filter((c) => !include.has(c)));
1633
+ }
1634
+ return /* @__PURE__ */ new Set([
1635
+ ...publintConfig.exclude ?? [],
1636
+ ...cliExclude ?? []
1637
+ ]);
1638
+ }
1639
+ function normalizePublintConfig(value) {
1640
+ if (typeof value === "object") return value;
1641
+ return {};
1642
+ }
1643
+ var publint = async ({
1644
+ cliExclude,
1645
+ cliInclude,
1646
+ fix,
1647
+ jobs,
1648
+ pack,
1649
+ verbose,
1650
+ pkg
1651
+ }) => {
1652
+ return pkg === void 0 ? await publintAll({
1653
+ cliExclude,
1654
+ cliInclude,
1655
+ fix,
1656
+ jobs,
1657
+ pack,
1658
+ verbose
1659
+ }) : await publintSingle({
1660
+ cliExclude,
1661
+ cliInclude,
1662
+ fix,
1663
+ pack,
1664
+ pkg,
1665
+ verbose
1666
+ });
1667
+ };
1668
+ function logPublintSummary(packages, errors, ms) {
1669
+ const color = errors > 0 ? chalk11.red : chalk11.blue;
1670
+ console.log(color(`Checked ${packages} package(s) in ${ms.toFixed(0)}ms with ${errors} issue(s) found.`));
1671
+ }
1672
+ var publintSingle = async ({
1673
+ cliExclude,
1674
+ cliInclude,
1675
+ fix,
1676
+ pack,
1677
+ pkg,
1678
+ verbose
1679
+ }) => {
1680
+ const start = performance.now();
1681
+ const pm = getPackageManager();
1682
+ const workspace = pm.findWorkspace(pkg);
1683
+ if (!workspace) {
1684
+ console.error(chalk11.red(`Publint: workspace "${pkg}" not found`));
1685
+ return 1;
1686
+ }
1687
+ const wsPublintConfig = normalizePublintConfig(
1688
+ await loadWorkspaceCommandConfig(workspace.location, "publint")
1689
+ );
1690
+ const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude);
1691
+ if (!exclude) return 1;
1692
+ const shouldPack = pack ?? wsPublintConfig.pack ?? true;
1693
+ const errors = await packagePublint({
1694
+ exclude,
1695
+ fix,
1696
+ pack: shouldPack,
1697
+ pkgDir: workspace.location,
1698
+ verbose
1699
+ });
1700
+ logPublintSummary(1, errors, performance.now() - start);
1701
+ return errors;
1702
+ };
1703
+ var publintAll = async ({
1704
+ cliExclude,
1705
+ cliInclude,
1706
+ fix,
1707
+ jobs,
1708
+ pack,
1709
+ verbose
1710
+ }) => {
1711
+ const start = performance.now();
1712
+ const pm = getPackageManager();
1713
+ const workspaces = pm.listWorkspaces();
1714
+ const concurrency = jobs;
1715
+ const results = Array.from({ length: workspaces.length }, () => ({ errors: 0, output: [] }));
1716
+ installOutputCapture();
1717
+ await runWithConcurrency(
1718
+ workspaces.map((ws, i) => ({ i, ws })),
1719
+ concurrency,
1720
+ async ({ i, ws }) => {
1721
+ const output = [];
1722
+ await outputStorage.run(output, async () => {
1723
+ try {
1724
+ const wsPublintConfig = normalizePublintConfig(
1725
+ await loadWorkspaceCommandConfig(ws.location, "publint")
1726
+ );
1727
+ const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude) ?? /* @__PURE__ */ new Set();
1728
+ const shouldPack = pack ?? wsPublintConfig.pack ?? true;
1729
+ const errors = await packagePublint({
1730
+ exclude,
1731
+ fix,
1732
+ pack: shouldPack,
1733
+ pkgDir: ws.location,
1734
+ verbose
1735
+ });
1736
+ results[i] = { errors, output };
1737
+ } catch (ex) {
1738
+ output.push(chalk11.red(`Publint failed for ${ws.name}: ${ex.message}
1739
+ `));
1740
+ results[i] = { errors: 1, output };
1741
+ }
1742
+ });
1743
+ }
1744
+ );
1745
+ let totalErrors = 0;
1746
+ for (const { errors, output } of results) {
1747
+ for (const line of output) {
1748
+ process.stdout.write(line);
1749
+ }
1750
+ totalErrors += errors;
1751
+ }
1752
+ const allExclude = resolveExclude({}, cliExclude, cliInclude) ?? /* @__PURE__ */ new Set();
1753
+ if (!allExclude.has("peerDeps")) {
1754
+ const cwd = INIT_CWD();
1755
+ const peerResult = checkInternalPeerVersions(cwd, workspaces);
1756
+ if (peerResult.fixable.length > 0) {
1757
+ if (fix) {
1758
+ fixInternalPeerVersions(cwd, workspaces);
1759
+ runInstall();
1760
+ } else {
1761
+ for (const msg of peerResult.fixable) {
1762
+ console.log(chalk11.red(` \u2717 ${msg} (fixable)`));
1763
+ }
1764
+ totalErrors += peerResult.fixable.length;
1765
+ }
1766
+ }
1767
+ totalErrors += peerResult.errors.length;
1768
+ }
1769
+ logPublintSummary(workspaces.length, totalErrors, performance.now() - start);
1770
+ return totalErrors;
1771
+ };
1772
+
1773
+ // src/actions/readme-lint.ts
1774
+ import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
1775
+ import PATH6 from "path";
1776
+ import chalk12 from "chalk";
1777
+ function lintTemplate(cwd) {
1778
+ const result = { errors: [], warnings: [] };
1779
+ const templatePath = resolveTemplatePath();
1780
+ if (!existsSync5(templatePath)) {
1781
+ result.errors.push('Missing .xy/README.template.md (run "xy readme init" to create)');
1782
+ return result;
1783
+ }
1784
+ const template = readFileSync6(templatePath, "utf8");
1785
+ if (!template.includes("{{body}}")) {
1786
+ result.warnings.push(".xy/README.template.md does not contain a {{body}} placeholder");
1787
+ }
1788
+ if (!template.includes("{{description}}")) {
1789
+ result.warnings.push(".xy/README.template.md does not contain a {{description}} placeholder");
1790
+ }
1791
+ const bodyPath = PATH6.join(cwd, ".xy", "README.body.md");
1792
+ if (!existsSync5(bodyPath)) {
1793
+ result.errors.push('Missing .xy/README.body.md (run "xy readme init" to create)');
1794
+ }
1795
+ return result;
1796
+ }
1797
+ function lintLogoConfig(cwd, config2) {
1798
+ const result = { errors: [], warnings: [] };
1799
+ const templatePath = resolveTemplatePath();
1800
+ if (existsSync5(templatePath)) {
1801
+ const template = readFileSync6(templatePath, "utf8");
1802
+ const logoRef = /\[logo]: (.+)/.exec(template);
1803
+ if (logoRef?.[1].includes("example.com")) {
1804
+ result.warnings.push(".xy/README.template.md still has the example.com logo placeholder \u2014 update it or set readme.logoUrl in xy.config.ts");
1805
+ } else if (!logoRef && !config2.readme?.logoUrl) {
1806
+ result.warnings.push("No logo URL configured in xy.config.ts (readme.logoUrl) or template");
1807
+ }
1808
+ }
1809
+ if (!config2.readme?.logoUrl && !config2.readme?.logoLinkUrl) {
1810
+ result.warnings.push("No readme.logoUrl or readme.logoLinkUrl configured in xy.config.ts");
1811
+ }
1812
+ return result;
1813
+ }
1814
+ function lintPackages(cwd) {
1815
+ const result = { errors: [], warnings: [] };
1816
+ const pm = getPackageManager();
1817
+ const workspaces = pm.listWorkspaces();
1818
+ for (const { location, name } of workspaces) {
1819
+ if (location === ".") continue;
1820
+ const pkgPath = PATH6.join(cwd, location, "package.json");
1821
+ try {
1822
+ const pkg = JSON.parse(readFileSync6(pkgPath, "utf8"));
1823
+ if (pkg.private) continue;
1824
+ if (!pkg.description) {
1825
+ result.warnings.push(`${name} is missing a "description" in package.json`);
1826
+ }
1827
+ const readmePath = PATH6.join(cwd, location, "README.md");
1828
+ if (!existsSync5(readmePath)) {
1829
+ result.errors.push(`${name} is missing README.md`);
1830
+ }
1831
+ } catch {
1832
+ }
1833
+ }
1834
+ return result;
1835
+ }
1836
+ function readmeLint({ config: config2, verbose }) {
1837
+ const cwd = INIT_CWD();
1838
+ console.log(chalk12.green("Readme Lint"));
1839
+ const checks = [
1840
+ lintTemplate(cwd),
1841
+ lintLogoConfig(cwd, config2),
1842
+ lintPackages(cwd)
1843
+ ];
1844
+ let errorCount = 0;
1845
+ let warningCount = 0;
1846
+ for (const { errors, warnings } of checks) {
1847
+ for (const error of errors) {
1848
+ console.log(chalk12.red(` \u2717 ${error}`));
1849
+ errorCount++;
1850
+ }
1851
+ for (const warning of warnings) {
1852
+ console.log(chalk12.yellow(` \u26A0 ${warning}`));
1853
+ warningCount++;
1854
+ }
1855
+ }
1856
+ if (errorCount === 0 && warningCount === 0) {
1857
+ console.log(chalk12.green(" All checks passed"));
1858
+ } else {
1859
+ if (verbose) {
1860
+ console.log(chalk12.gray(` ${errorCount} error(s), ${warningCount} warning(s)`));
1861
+ }
1862
+ }
1863
+ return errorCount > 0 ? 1 : 0;
1864
+ }
1865
+
1866
+ // src/xy/common/checkCommand.ts
1867
+ var checkCommand = {
1868
+ command: "check",
1869
+ describe: "Check - Run gitlint, publint, repo lint, lintlint, and readme lint",
1870
+ builder: (yargs) => {
1871
+ return yargs.option("fix", {
1872
+ default: false,
1873
+ description: "Auto-fix fixable issues",
1874
+ type: "boolean"
1875
+ });
1876
+ },
1877
+ handler: async (argv) => {
1878
+ const verbose = !!argv.verbose;
1879
+ const fix = !!argv.fix;
1880
+ const jobs = argv.jobs;
1881
+ let errors = 0;
1882
+ if (verbose) console.log("Check");
1883
+ console.log(chalk13.blue("\n\u2014 gitlint \u2014"));
1884
+ errors += fix ? gitlintFix() : gitlint();
1885
+ console.log(chalk13.blue("\n\u2014 publint \u2014"));
1886
+ errors += await publint({
1887
+ fix,
1888
+ jobs,
1889
+ verbose
1890
+ });
1891
+ console.log(chalk13.blue("\n\u2014 repo lint \u2014"));
1892
+ errors += packageLintMonorepo(fix);
1893
+ console.log(chalk13.blue("\n\u2014 lintlint \u2014"));
1894
+ errors += await lintlint({ fix, verbose });
1895
+ console.log(chalk13.blue("\n\u2014 readme lint \u2014"));
1896
+ const config2 = await loadConfig();
1897
+ errors += readmeLint({ config: config2, verbose });
1898
+ if (errors > 0) {
1899
+ console.log(chalk13.red(`${errors} issue(s) found`));
1900
+ } else {
1901
+ console.log(chalk13.green("All checks passed"));
1902
+ }
1903
+ process.exitCode = errors > 0 ? 1 : 0;
1904
+ }
1905
+ };
1906
+ export {
1907
+ checkCommand
1908
+ };
1909
+ //# sourceMappingURL=checkCommand.mjs.map