@xylabs/ts-scripts-common 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/build.mjs +161 -0
- package/dist/actions/build.mjs.map +1 -0
- package/dist/actions/claude-clean.mjs +71 -0
- package/dist/actions/claude-clean.mjs.map +1 -0
- package/dist/actions/claude-commands.mjs +112 -0
- package/dist/actions/claude-commands.mjs.map +1 -0
- package/dist/actions/claude-rules.mjs +137 -0
- package/dist/actions/claude-rules.mjs.map +1 -0
- package/dist/actions/claude-settings.mjs +85 -0
- package/dist/actions/claude-settings.mjs.map +1 -0
- package/dist/actions/claude-skills.mjs +120 -0
- package/dist/actions/claude-skills.mjs.map +1 -0
- package/dist/actions/clean-docs.mjs +45 -0
- package/dist/actions/clean-docs.mjs.map +1 -0
- package/dist/actions/clean-eslint.mjs +26 -0
- package/dist/actions/clean-eslint.mjs.map +1 -0
- package/dist/actions/clean.mjs +145 -0
- package/dist/actions/clean.mjs.map +1 -0
- package/dist/actions/compile.mjs +172 -0
- package/dist/actions/compile.mjs.map +1 -0
- package/dist/actions/copy-assets.mjs +81 -0
- package/dist/actions/copy-assets.mjs.map +1 -0
- package/dist/actions/cycle.mjs +165 -0
- package/dist/actions/cycle.mjs.map +1 -0
- package/dist/actions/dead.mjs +98 -0
- package/dist/actions/dead.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/checkPackage.mjs +672 -0
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs +1 -0
- package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +48 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +33 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +30 -0
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +309 -0
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +26 -0
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/index.mjs +672 -0
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -0
- package/dist/actions/deplint/deplint.mjs +770 -0
- package/dist/actions/deplint/deplint.mjs.map +1 -0
- package/dist/actions/deplint/findFiles.mjs +39 -0
- package/dist/actions/deplint/findFiles.mjs.map +1 -0
- package/dist/actions/deplint/findFilesByGlob.mjs +14 -0
- package/dist/actions/deplint/findFilesByGlob.mjs.map +1 -0
- package/dist/actions/deplint/getBasePackageName.mjs +13 -0
- package/dist/actions/deplint/getBasePackageName.mjs.map +1 -0
- package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs +140 -0
- package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs.map +1 -0
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +20 -0
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +1 -0
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +44 -0
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +1 -0
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +122 -0
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -0
- package/dist/actions/deplint/getImportsFromFile.mjs +85 -0
- package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -0
- package/dist/actions/deplint/getRequiredPeerDependencies.mjs +36 -0
- package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +1 -0
- package/dist/actions/deplint/getScriptReferencedPackages.mjs +83 -0
- package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs +80 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/index.mjs +770 -0
- package/dist/actions/deplint/index.mjs.map +1 -0
- package/dist/actions/dupdeps.mjs +205 -0
- package/dist/actions/dupdeps.mjs.map +1 -0
- package/dist/actions/fix.mjs +163 -0
- package/dist/actions/fix.mjs.map +1 -0
- package/dist/actions/gen-docs.mjs +130 -0
- package/dist/actions/gen-docs.mjs.map +1 -0
- package/dist/actions/gitignore.mjs +160 -0
- package/dist/actions/gitignore.mjs.map +1 -0
- package/dist/actions/gitlint-fix.mjs +27 -0
- package/dist/actions/gitlint-fix.mjs.map +1 -0
- package/dist/actions/gitlint.mjs +48 -0
- package/dist/actions/gitlint.mjs.map +1 -0
- package/dist/actions/index.mjs +4129 -0
- package/dist/actions/index.mjs.map +1 -0
- package/dist/actions/knip.mjs +98 -0
- package/dist/actions/knip.mjs.map +1 -0
- package/dist/actions/license.mjs +92 -0
- package/dist/actions/license.mjs.map +1 -0
- package/dist/actions/lint.mjs +160 -0
- package/dist/actions/lint.mjs.map +1 -0
- package/dist/actions/lintlint.mjs +230 -0
- package/dist/actions/lintlint.mjs.map +1 -0
- package/dist/actions/npmignore-gen.mjs +91 -0
- package/dist/actions/npmignore-gen.mjs.map +1 -0
- package/dist/actions/package/clean-outputs.mjs +29 -0
- package/dist/actions/package/clean-outputs.mjs.map +1 -0
- package/dist/actions/package/clean-typescript.mjs +29 -0
- package/dist/actions/package/clean-typescript.mjs.map +1 -0
- package/dist/actions/package/clean.mjs +48 -0
- package/dist/actions/package/clean.mjs.map +1 -0
- package/dist/actions/package/compile/XyConfig.mjs +1 -0
- package/dist/actions/package/compile/XyConfig.mjs.map +1 -0
- package/dist/actions/package/compile/buildEntries.mjs +53 -0
- package/dist/actions/package/compile/buildEntries.mjs.map +1 -0
- package/dist/actions/package/compile/compile.mjs +433 -0
- package/dist/actions/package/compile/compile.mjs.map +1 -0
- package/dist/actions/package/compile/copyTypeFiles.mjs +34 -0
- package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -0
- package/dist/actions/package/compile/deepMerge.mjs +26 -0
- package/dist/actions/package/compile/deepMerge.mjs.map +1 -0
- package/dist/actions/package/compile/getCompilerOptions.mjs +12 -0
- package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -0
- package/dist/actions/package/compile/index.mjs +436 -0
- package/dist/actions/package/compile/index.mjs.map +1 -0
- package/dist/actions/package/compile/inputs.mjs +22 -0
- package/dist/actions/package/compile/inputs.mjs.map +1 -0
- package/dist/actions/package/compile/packageCompileTsc.mjs +94 -0
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -0
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +92 -0
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -0
- package/dist/actions/package/compile/packageCompileTsup.mjs +402 -0
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -0
- package/dist/actions/package/copy-assets.mjs +46 -0
- package/dist/actions/package/copy-assets.mjs.map +1 -0
- package/dist/actions/package/cycle.mjs +39 -0
- package/dist/actions/package/cycle.mjs.map +1 -0
- package/dist/actions/package/gen-docs.mjs +114 -0
- package/dist/actions/package/gen-docs.mjs.map +1 -0
- package/dist/actions/package/index.mjs +825 -0
- package/dist/actions/package/index.mjs.map +1 -0
- package/dist/actions/package/lint.mjs +80 -0
- package/dist/actions/package/lint.mjs.map +1 -0
- package/dist/actions/package/publint.mjs +66 -0
- package/dist/actions/package/publint.mjs.map +1 -0
- package/dist/actions/package/recompile.mjs +483 -0
- package/dist/actions/package/recompile.mjs.map +1 -0
- package/dist/actions/package-lint.mjs +186 -0
- package/dist/actions/package-lint.mjs.map +1 -0
- package/dist/actions/packman/convert.mjs +387 -0
- package/dist/actions/packman/convert.mjs.map +1 -0
- package/dist/actions/packman/convertToPnpm.mjs +149 -0
- package/dist/actions/packman/convertToPnpm.mjs.map +1 -0
- package/dist/actions/packman/convertToYarn.mjs +171 -0
- package/dist/actions/packman/convertToYarn.mjs.map +1 -0
- package/dist/actions/packman/index.mjs +389 -0
- package/dist/actions/packman/index.mjs.map +1 -0
- package/dist/actions/packman/rewriteScripts.mjs +52 -0
- package/dist/actions/packman/rewriteScripts.mjs.map +1 -0
- package/dist/actions/publint.mjs +187 -0
- package/dist/actions/publint.mjs.map +1 -0
- package/dist/actions/readme-gen.mjs +292 -0
- package/dist/actions/readme-gen.mjs.map +1 -0
- package/dist/actions/readme-init.mjs +83 -0
- package/dist/actions/readme-init.mjs.map +1 -0
- package/dist/actions/rebuild.mjs +122 -0
- package/dist/actions/rebuild.mjs.map +1 -0
- package/dist/actions/recompile.mjs +188 -0
- package/dist/actions/recompile.mjs.map +1 -0
- package/dist/actions/relint.mjs +160 -0
- package/dist/actions/relint.mjs.map +1 -0
- package/dist/actions/retest.mjs +129 -0
- package/dist/actions/retest.mjs.map +1 -0
- package/dist/actions/sonar.mjs +98 -0
- package/dist/actions/sonar.mjs.map +1 -0
- package/dist/actions/statics.mjs +204 -0
- package/dist/actions/statics.mjs.map +1 -0
- package/dist/actions/test.mjs +123 -0
- package/dist/actions/test.mjs.map +1 -0
- package/dist/bin/package/build-only.mjs +445 -0
- package/dist/bin/package/build-only.mjs.map +1 -0
- package/dist/bin/package/build.mjs +445 -0
- package/dist/bin/package/build.mjs.map +1 -0
- package/dist/bin/package/clean-outputs.mjs +29 -0
- package/dist/bin/package/clean-outputs.mjs.map +1 -0
- package/dist/bin/package/clean-typescript.mjs +29 -0
- package/dist/bin/package/clean-typescript.mjs.map +1 -0
- package/dist/bin/package/clean.mjs +53 -0
- package/dist/bin/package/clean.mjs.map +1 -0
- package/dist/bin/package/compile-only.mjs +441 -0
- package/dist/bin/package/compile-only.mjs.map +1 -0
- package/dist/bin/package/compile-tsup.mjs +409 -0
- package/dist/bin/package/compile-tsup.mjs.map +1 -0
- package/dist/bin/package/compile.mjs +445 -0
- package/dist/bin/package/compile.mjs.map +1 -0
- package/dist/bin/package/copy-assets-cjs.mjs +54 -0
- package/dist/bin/package/copy-assets-cjs.mjs.map +1 -0
- package/dist/bin/package/copy-assets-esm.mjs +54 -0
- package/dist/bin/package/copy-assets-esm.mjs.map +1 -0
- package/dist/bin/package/cycle.mjs +51 -0
- package/dist/bin/package/cycle.mjs.map +1 -0
- package/dist/bin/package/fix.mjs +92 -0
- package/dist/bin/package/fix.mjs.map +1 -0
- package/dist/bin/package/gen-docs.mjs +121 -0
- package/dist/bin/package/gen-docs.mjs.map +1 -0
- package/dist/bin/package/lint-verbose.mjs +92 -0
- package/dist/bin/package/lint-verbose.mjs.map +1 -0
- package/dist/bin/package/lint.mjs +92 -0
- package/dist/bin/package/lint.mjs.map +1 -0
- package/dist/bin/package/publint.mjs +75 -0
- package/dist/bin/package/publint.mjs.map +1 -0
- package/dist/bin/package/recompile.mjs +489 -0
- package/dist/bin/package/recompile.mjs.map +1 -0
- package/dist/bin/package/relint.mjs +92 -0
- package/dist/bin/package/relint.mjs.map +1 -0
- package/dist/bin/xy.mjs +3826 -0
- package/dist/bin/xy.mjs.map +1 -0
- package/dist/index.d.ts +564 -0
- package/dist/index.mjs +4979 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/checkResult.mjs +16 -0
- package/dist/lib/checkResult.mjs.map +1 -0
- package/dist/lib/claudeMdTemplate.mjs +65 -0
- package/dist/lib/claudeMdTemplate.mjs.map +1 -0
- package/dist/lib/createBuildConfig.mjs +55 -0
- package/dist/lib/createBuildConfig.mjs.map +1 -0
- package/dist/lib/defaultBuildConfig.mjs +23 -0
- package/dist/lib/defaultBuildConfig.mjs.map +1 -0
- package/dist/lib/deleteGlob.mjs +13 -0
- package/dist/lib/deleteGlob.mjs.map +1 -0
- package/dist/lib/dependencies/DuplicateDetector.mjs +81 -0
- package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -0
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs +185 -0
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -0
- package/dist/lib/dependencies/index.mjs +186 -0
- package/dist/lib/dependencies/index.mjs.map +1 -0
- package/dist/lib/file/ReadFileSyncOptions.mjs +6 -0
- package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -0
- package/dist/lib/file/constants.mjs +8 -0
- package/dist/lib/file/constants.mjs.map +1 -0
- package/dist/lib/file/fileLines.mjs +32 -0
- package/dist/lib/file/fileLines.mjs.map +1 -0
- package/dist/lib/file/index.mjs +42 -0
- package/dist/lib/file/index.mjs.map +1 -0
- package/dist/lib/file/tryReadFileSync.mjs +14 -0
- package/dist/lib/file/tryReadFileSync.mjs.map +1 -0
- package/dist/lib/generateIgnoreFiles.mjs +87 -0
- package/dist/lib/generateIgnoreFiles.mjs.map +1 -0
- package/dist/lib/generateReadmeFiles.mjs +260 -0
- package/dist/lib/generateReadmeFiles.mjs.map +1 -0
- package/dist/lib/gitignoreTemplate.mjs +12 -0
- package/dist/lib/gitignoreTemplate.mjs.map +1 -0
- package/dist/lib/index.mjs +834 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/initCwd.mjs +9 -0
- package/dist/lib/initCwd.mjs.map +1 -0
- package/dist/lib/jsonFormatters.mjs +11 -0
- package/dist/lib/jsonFormatters.mjs.map +1 -0
- package/dist/lib/loadConfig.mjs +24 -0
- package/dist/lib/loadConfig.mjs.map +1 -0
- package/dist/lib/parsedPackageJSON.mjs +11 -0
- package/dist/lib/parsedPackageJSON.mjs.map +1 -0
- package/dist/lib/processEx.mjs +36 -0
- package/dist/lib/processEx.mjs.map +1 -0
- package/dist/lib/runSteps.mjs +95 -0
- package/dist/lib/runSteps.mjs.map +1 -0
- package/dist/lib/runStepsAsync.mjs +113 -0
- package/dist/lib/runStepsAsync.mjs.map +1 -0
- package/dist/lib/runXy.mjs +124 -0
- package/dist/lib/runXy.mjs.map +1 -0
- package/dist/lib/runXyWithWarning.mjs +36 -0
- package/dist/lib/runXyWithWarning.mjs.map +1 -0
- package/dist/lib/safeExit.mjs +61 -0
- package/dist/lib/safeExit.mjs.map +1 -0
- package/dist/lib/string/empty.mjs +8 -0
- package/dist/lib/string/empty.mjs.map +1 -0
- package/dist/lib/string/index.mjs +12 -0
- package/dist/lib/string/index.mjs.map +1 -0
- package/dist/lib/string/union.mjs +6 -0
- package/dist/lib/string/union.mjs.map +1 -0
- package/dist/lib/tryRunLocalScript.mjs +56 -0
- package/dist/lib/tryRunLocalScript.mjs.map +1 -0
- package/dist/lib/withErrnoException.mjs +13 -0
- package/dist/lib/withErrnoException.mjs.map +1 -0
- package/dist/lib/withError.mjs +8 -0
- package/dist/lib/withError.mjs.map +1 -0
- package/dist/loadPackageConfig.mjs +11 -0
- package/dist/loadPackageConfig.mjs.map +1 -0
- package/dist/pm/PackageManager.mjs +1 -0
- package/dist/pm/PackageManager.mjs.map +1 -0
- package/dist/pm/detectPackageManager.mjs +10 -0
- package/dist/pm/detectPackageManager.mjs.map +1 -0
- package/dist/pm/index.mjs +28 -0
- package/dist/pm/index.mjs.map +1 -0
- package/dist/pm/registry.mjs +27 -0
- package/dist/pm/registry.mjs.map +1 -0
- package/dist/types.d.mjs +1 -0
- package/dist/types.d.mjs.map +1 -0
- package/dist/xy/build/buildCommand.mjs +182 -0
- package/dist/xy/build/buildCommand.mjs.map +1 -0
- package/dist/xy/build/compileCommand.mjs +189 -0
- package/dist/xy/build/compileCommand.mjs.map +1 -0
- package/dist/xy/build/compileOnlyCommand.mjs +190 -0
- package/dist/xy/build/compileOnlyCommand.mjs.map +1 -0
- package/dist/xy/build/copyAssetsCommand.mjs +92 -0
- package/dist/xy/build/copyAssetsCommand.mjs.map +1 -0
- package/dist/xy/build/index.mjs +493 -0
- package/dist/xy/build/index.mjs.map +1 -0
- package/dist/xy/build/rebuildCommand.mjs +135 -0
- package/dist/xy/build/rebuildCommand.mjs.map +1 -0
- package/dist/xy/build/recompileCommand.mjs +205 -0
- package/dist/xy/build/recompileCommand.mjs.map +1 -0
- package/dist/xy/common/claude/cleanCommand.mjs +79 -0
- package/dist/xy/common/claude/cleanCommand.mjs.map +1 -0
- package/dist/xy/common/claude/commandsCommand.mjs +120 -0
- package/dist/xy/common/claude/commandsCommand.mjs.map +1 -0
- package/dist/xy/common/claude/index.mjs +546 -0
- package/dist/xy/common/claude/index.mjs.map +1 -0
- package/dist/xy/common/claude/initCommand.mjs +319 -0
- package/dist/xy/common/claude/initCommand.mjs.map +1 -0
- package/dist/xy/common/claude/rulesCommand.mjs +153 -0
- package/dist/xy/common/claude/rulesCommand.mjs.map +1 -0
- package/dist/xy/common/claude/settingsCommand.mjs +93 -0
- package/dist/xy/common/claude/settingsCommand.mjs.map +1 -0
- package/dist/xy/common/claude/skillsCommand.mjs +129 -0
- package/dist/xy/common/claude/skillsCommand.mjs.map +1 -0
- package/dist/xy/common/cleanDocsCommand.mjs +53 -0
- package/dist/xy/common/cleanDocsCommand.mjs.map +1 -0
- package/dist/xy/common/deadCommand.mjs +116 -0
- package/dist/xy/common/deadCommand.mjs.map +1 -0
- package/dist/xy/common/genDocsCommand.mjs +146 -0
- package/dist/xy/common/genDocsCommand.mjs.map +1 -0
- package/dist/xy/common/gitignoreCommand.mjs +166 -0
- package/dist/xy/common/gitignoreCommand.mjs.map +1 -0
- package/dist/xy/common/gitlintCommand.mjs +82 -0
- package/dist/xy/common/gitlintCommand.mjs.map +1 -0
- package/dist/xy/common/index.mjs +1874 -0
- package/dist/xy/common/index.mjs.map +1 -0
- package/dist/xy/common/licenseCommand.mjs +108 -0
- package/dist/xy/common/licenseCommand.mjs.map +1 -0
- package/dist/xy/common/npmignoreGenCommand.mjs +101 -0
- package/dist/xy/common/npmignoreGenCommand.mjs.map +1 -0
- package/dist/xy/common/packmanCommand.mjs +415 -0
- package/dist/xy/common/packmanCommand.mjs.map +1 -0
- package/dist/xy/common/readme/genCommand.mjs +324 -0
- package/dist/xy/common/readme/genCommand.mjs.map +1 -0
- package/dist/xy/common/readme/index.mjs +364 -0
- package/dist/xy/common/readme/index.mjs.map +1 -0
- package/dist/xy/common/readme/initCommand.mjs +103 -0
- package/dist/xy/common/readme/initCommand.mjs.map +1 -0
- package/dist/xy/common/retestCommand.mjs +142 -0
- package/dist/xy/common/retestCommand.mjs.map +1 -0
- package/dist/xy/common/testCommand.mjs +136 -0
- package/dist/xy/common/testCommand.mjs.map +1 -0
- package/dist/xy/index.mjs +3823 -0
- package/dist/xy/index.mjs.map +1 -0
- package/dist/xy/lint/cycleCommand.mjs +184 -0
- package/dist/xy/lint/cycleCommand.mjs.map +1 -0
- package/dist/xy/lint/deplintCommand.mjs +820 -0
- package/dist/xy/lint/deplintCommand.mjs.map +1 -0
- package/dist/xy/lint/fixCommand.mjs +184 -0
- package/dist/xy/lint/fixCommand.mjs.map +1 -0
- package/dist/xy/lint/index.mjs +1691 -0
- package/dist/xy/lint/index.mjs.map +1 -0
- package/dist/xy/lint/knipCommand.mjs +121 -0
- package/dist/xy/lint/knipCommand.mjs.map +1 -0
- package/dist/xy/lint/lintCommand.mjs +202 -0
- package/dist/xy/lint/lintCommand.mjs.map +1 -0
- package/dist/xy/lint/lintlintCommand.mjs +250 -0
- package/dist/xy/lint/lintlintCommand.mjs.map +1 -0
- package/dist/xy/lint/packageLintCommand.mjs +201 -0
- package/dist/xy/lint/packageLintCommand.mjs.map +1 -0
- package/dist/xy/lint/publintCommand.mjs +208 -0
- package/dist/xy/lint/publintCommand.mjs.map +1 -0
- package/dist/xy/lint/relintCommand.mjs +179 -0
- package/dist/xy/lint/relintCommand.mjs.map +1 -0
- package/dist/xy/lint/sonarCommand.mjs +121 -0
- package/dist/xy/lint/sonarCommand.mjs.map +1 -0
- package/dist/xy/param.mjs +8 -0
- package/dist/xy/param.mjs.map +1 -0
- package/dist/xy/xy.mjs +3819 -0
- package/dist/xy/xy.mjs.map +1 -0
- package/dist/xy/xyParseOptions.mjs +91 -0
- package/dist/xy/xyParseOptions.mjs.map +1 -0
- package/package.json +108 -0
- package/templates/claude/CLAUDE-local.md +4 -0
- package/templates/claude/CLAUDE-project.md +4 -0
- package/templates/claude/commands/xy-build.md +5 -0
- package/templates/claude/commands/xy-clean.md +5 -0
- package/templates/claude/commands/xy-compile.md +5 -0
- package/templates/claude/commands/xy-cycle.md +5 -0
- package/templates/claude/commands/xy-dead.md +5 -0
- package/templates/claude/commands/xy-deplint.md +5 -0
- package/templates/claude/commands/xy-deps.md +24 -0
- package/templates/claude/commands/xy-dupdeps.md +5 -0
- package/templates/claude/commands/xy-fix.md +5 -0
- package/templates/claude/commands/xy-gen-docs.md +5 -0
- package/templates/claude/commands/xy-gitignore.md +5 -0
- package/templates/claude/commands/xy-gitlint.md +5 -0
- package/templates/claude/commands/xy-knip.md +5 -0
- package/templates/claude/commands/xy-license.md +5 -0
- package/templates/claude/commands/xy-lint-rules.md +44 -0
- package/templates/claude/commands/xy-lint.md +5 -0
- package/templates/claude/commands/xy-publint.md +5 -0
- package/templates/claude/commands/xy-rebuild.md +5 -0
- package/templates/claude/commands/xy-recompile.md +5 -0
- package/templates/claude/commands/xy-reinstall.md +5 -0
- package/templates/claude/commands/xy-relint.md +5 -0
- package/templates/claude/commands/xy-retest.md +5 -0
- package/templates/claude/commands/xy-sonar.md +5 -0
- package/templates/claude/commands/xy-test.md +5 -0
- package/templates/claude/commands/xy-up.md +7 -0
- package/templates/claude/rules/xylabs-architecture.md +8 -0
- package/templates/claude/rules/xylabs-build.md +9 -0
- package/templates/claude/rules/xylabs-git-workflow.md +7 -0
- package/templates/claude/rules/xylabs-naming.md +7 -0
- package/templates/claude/rules/xylabs-style.md +17 -0
- package/templates/claude/skills/xylabs-e2e-setup/SKILL.md +223 -0
- package/templates/gitignore/template.gitignore +51 -0
- package/templates/readme/README.body.md +11 -0
- package/templates/readme/README.template.md +22 -0
|
@@ -0,0 +1,1874 @@
|
|
|
1
|
+
// src/lib/checkResult.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
var checkResult = (name, result, level = "error", exitOnFail = false) => {
|
|
4
|
+
if (result) {
|
|
5
|
+
const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
|
|
6
|
+
const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
|
|
7
|
+
console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
|
|
8
|
+
if (exitOnFail) {
|
|
9
|
+
process.exit(result);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/lib/claudeMdTemplate.ts
|
|
15
|
+
import {
|
|
16
|
+
readdirSync,
|
|
17
|
+
readFileSync,
|
|
18
|
+
statSync
|
|
19
|
+
} from "fs";
|
|
20
|
+
import { createRequire } from "module";
|
|
21
|
+
import PATH from "path";
|
|
22
|
+
var require2 = createRequire(import.meta.url);
|
|
23
|
+
var packageRoot = PATH.dirname(require2.resolve("@xylabs/ts-scripts-common/package.json"));
|
|
24
|
+
var templatesDir = PATH.resolve(packageRoot, "templates", "claude");
|
|
25
|
+
var XYLABS_RULES_PREFIX = "xylabs-";
|
|
26
|
+
var XYLABS_COMMANDS_PREFIX = "xy-";
|
|
27
|
+
var LEGACY_COMMANDS_PREFIX = "xylabs-";
|
|
28
|
+
var XYLABS_SKILLS_PREFIX = "xylabs-";
|
|
29
|
+
var claudeMdRuleTemplates = () => {
|
|
30
|
+
const rulesDir = PATH.resolve(templatesDir, "rules");
|
|
31
|
+
const files = readdirSync(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
result[file] = readFileSync(PATH.resolve(rulesDir, file), "utf8");
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
var claudeCommandTemplates = () => {
|
|
39
|
+
const commandsDir = PATH.resolve(templatesDir, "commands");
|
|
40
|
+
const files = readdirSync(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
|
|
41
|
+
const result = {};
|
|
42
|
+
for (const file of files) {
|
|
43
|
+
result[file] = readFileSync(PATH.resolve(commandsDir, file), "utf8");
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
var claudeSkillTemplates = () => {
|
|
48
|
+
const skillsDir = PATH.resolve(templatesDir, "skills");
|
|
49
|
+
const dirs = readdirSync(skillsDir).filter(
|
|
50
|
+
(f) => f.startsWith(XYLABS_SKILLS_PREFIX) && statSync(PATH.resolve(skillsDir, f)).isDirectory()
|
|
51
|
+
);
|
|
52
|
+
const result = {};
|
|
53
|
+
for (const dir of dirs) {
|
|
54
|
+
const dirPath = PATH.resolve(skillsDir, dir);
|
|
55
|
+
const files = readdirSync(dirPath, { recursive: true, encoding: "utf8" });
|
|
56
|
+
result[dir] = {};
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
if (statSync(PATH.resolve(dirPath, file)).isFile()) {
|
|
59
|
+
result[dir][file] = readFileSync(PATH.resolve(dirPath, file), "utf8");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
};
|
|
65
|
+
var claudeMdLocalTemplate = () => readFileSync(PATH.resolve(templatesDir, "CLAUDE-local.md"), "utf8");
|
|
66
|
+
|
|
67
|
+
// src/lib/deleteGlob.ts
|
|
68
|
+
import fs from "fs";
|
|
69
|
+
import { glob } from "glob";
|
|
70
|
+
var deleteGlob = (globPath) => {
|
|
71
|
+
const files = glob.sync(globPath);
|
|
72
|
+
for (const file of files) {
|
|
73
|
+
fs.rmSync(file, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/pm/detectPackageManager.ts
|
|
78
|
+
import { existsSync } from "fs";
|
|
79
|
+
function detectPackageManager() {
|
|
80
|
+
if (existsSync("pnpm-lock.yaml") || existsSync("pnpm-workspace.yaml")) return "pnpm";
|
|
81
|
+
return "yarn";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/pm/registry.ts
|
|
85
|
+
var implementations = /* @__PURE__ */ new Map();
|
|
86
|
+
function getPackageManager(name) {
|
|
87
|
+
const pmName = name ?? detectPackageManager();
|
|
88
|
+
const pm = implementations.get(pmName);
|
|
89
|
+
if (!pm) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`No package manager implementation registered for "${pmName}". Install @xylabs/ts-scripts-${pmName === "yarn" ? "yarn3" : pmName} and ensure it is imported.`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return pm;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/lib/processEx.ts
|
|
98
|
+
import chalk2 from "chalk";
|
|
99
|
+
|
|
100
|
+
// src/lib/withError.ts
|
|
101
|
+
var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
|
|
102
|
+
return predicate(ex) ? closure(ex) : void 0;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/lib/withErrnoException.ts
|
|
106
|
+
var withErrnoException = (ex, closure) => {
|
|
107
|
+
return withError(ex, closure, (ex2) => ex2.errno !== void 0);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/lib/processEx.ts
|
|
111
|
+
var processEx = (ex) => {
|
|
112
|
+
const error = typeof ex === "string" ? new Error(ex) : ex;
|
|
113
|
+
const exitCode = withErrnoException(error, (error2) => {
|
|
114
|
+
if (error2.code === "ENOENT") {
|
|
115
|
+
console.error(chalk2.red(`'${error2.path}' not found.`));
|
|
116
|
+
} else {
|
|
117
|
+
console.error(chalk2.red(`Errno: ${error2.code}`));
|
|
118
|
+
}
|
|
119
|
+
return error2.errno ?? -1;
|
|
120
|
+
}) ?? withError(error, (error2) => {
|
|
121
|
+
console.error(chalk2.red(`${error2.name}: ${error2.message}`));
|
|
122
|
+
return -1;
|
|
123
|
+
}) ?? (() => {
|
|
124
|
+
console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
|
|
125
|
+
return -1;
|
|
126
|
+
})();
|
|
127
|
+
process.exit(process.exitCode ?? exitCode);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// src/lib/safeExit.ts
|
|
131
|
+
var safeExit = (func, exitOnFail = true) => {
|
|
132
|
+
try {
|
|
133
|
+
const result = func();
|
|
134
|
+
if (result && exitOnFail) {
|
|
135
|
+
process.exit(result);
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
} catch (ex) {
|
|
139
|
+
return processEx(ex);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// src/lib/file/constants.ts
|
|
144
|
+
var WINDOWS_NEWLINE_REGEX = /\r\n/g;
|
|
145
|
+
var CROSS_PLATFORM_NEWLINE = "\n";
|
|
146
|
+
|
|
147
|
+
// src/lib/file/fileLines.ts
|
|
148
|
+
import {
|
|
149
|
+
existsSync as existsSync2,
|
|
150
|
+
readFileSync as readFileSync2,
|
|
151
|
+
writeFileSync
|
|
152
|
+
} from "fs";
|
|
153
|
+
|
|
154
|
+
// src/lib/string/empty.ts
|
|
155
|
+
var empty = (value) => value?.trim().length === 0;
|
|
156
|
+
var notEmpty = (value) => !empty(value);
|
|
157
|
+
|
|
158
|
+
// src/lib/string/union.ts
|
|
159
|
+
var union = (a, b) => /* @__PURE__ */ new Set([...new Set(a), ...new Set(b)]);
|
|
160
|
+
|
|
161
|
+
// src/lib/file/ReadFileSyncOptions.ts
|
|
162
|
+
var defaultReadFileSyncOptions = { encoding: "utf8" };
|
|
163
|
+
|
|
164
|
+
// src/lib/file/fileLines.ts
|
|
165
|
+
var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync2(uri) ? readFileSync2(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : [];
|
|
166
|
+
var readNonEmptyLines = (uri, options = defaultReadFileSyncOptions) => readLines(uri, options).filter(notEmpty);
|
|
167
|
+
var writeLines = (uri, lines, options = defaultReadFileSyncOptions) => {
|
|
168
|
+
const existing = existsSync2(uri) ? readFileSync2(uri, options) : void 0;
|
|
169
|
+
const desired = lines.join(CROSS_PLATFORM_NEWLINE);
|
|
170
|
+
if (existing !== desired) writeFileSync(uri, desired, options);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// src/lib/generateIgnoreFiles.ts
|
|
174
|
+
import chalk3 from "chalk";
|
|
175
|
+
|
|
176
|
+
// src/lib/initCwd.ts
|
|
177
|
+
function INIT_CWD() {
|
|
178
|
+
if (!process.env.INIT_CWD) console.error("Missing INIT_CWD");
|
|
179
|
+
return process.env.INIT_CWD;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/lib/generateIgnoreFiles.ts
|
|
183
|
+
var localeCompare = (a, b) => a.localeCompare(b);
|
|
184
|
+
var mergeEntries = (a, b) => [...union(a, b)].toSorted(localeCompare);
|
|
185
|
+
var generateIgnoreFiles = (filename2, pkg) => {
|
|
186
|
+
console.log(chalk3.green(`Generate ${filename2} Files`));
|
|
187
|
+
const cwd = INIT_CWD() ?? ".";
|
|
188
|
+
const pm = getPackageManager();
|
|
189
|
+
const singleWorkspace = pkg ? pm.findWorkspace(pkg) : void 0;
|
|
190
|
+
const workspaces = singleWorkspace ? [singleWorkspace] : pm.listWorkspaces();
|
|
191
|
+
const readEntries = (location) => readNonEmptyLines(`${location}/${filename2}`);
|
|
192
|
+
const writeEntries = (location, entries) => writeLines(`${location}/${filename2}`, entries);
|
|
193
|
+
const results = workspaces.map(({ location, name }) => {
|
|
194
|
+
try {
|
|
195
|
+
writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)));
|
|
196
|
+
return 0;
|
|
197
|
+
} catch (ex) {
|
|
198
|
+
const error = ex;
|
|
199
|
+
console.error(`Generate ${filename2} Files [${name}] [${error.message}]`);
|
|
200
|
+
return 1;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
const succeeded = results.every((result) => result === 0);
|
|
204
|
+
return succeeded ? 0 : 1;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/lib/generateReadmeFiles.ts
|
|
208
|
+
import { execSync } from "child_process";
|
|
209
|
+
import FS, { readFileSync as readFileSync3 } from "fs";
|
|
210
|
+
import {
|
|
211
|
+
mkdir,
|
|
212
|
+
readFile,
|
|
213
|
+
writeFile
|
|
214
|
+
} from "fs/promises";
|
|
215
|
+
import { createRequire as createRequire2 } from "module";
|
|
216
|
+
import PATH2 from "path";
|
|
217
|
+
import { createInterface } from "readline";
|
|
218
|
+
import chalk4 from "chalk";
|
|
219
|
+
var require3 = createRequire2(import.meta.url);
|
|
220
|
+
var packageRoot2 = PATH2.dirname(require3.resolve("@xylabs/ts-scripts-common/package.json"));
|
|
221
|
+
var readmeTemplatesDir = PATH2.resolve(packageRoot2, "templates", "readme");
|
|
222
|
+
function fillTemplate(template, data) {
|
|
223
|
+
const additionalData = { ...data, safeName: data.name.replaceAll("/", "__").replaceAll("@", "") };
|
|
224
|
+
return template.replaceAll(/\{\{(.*?)\}\}/g, (_, key) => additionalData[key.trim()] ?? "");
|
|
225
|
+
}
|
|
226
|
+
function generateTypedoc(packageLocation, entryPoints) {
|
|
227
|
+
const tempDir = PATH2.join(packageLocation, ".temp-typedoc");
|
|
228
|
+
try {
|
|
229
|
+
if (!FS.existsSync(tempDir)) {
|
|
230
|
+
FS.mkdirSync(tempDir, { recursive: true });
|
|
231
|
+
}
|
|
232
|
+
const typedocConfig = {
|
|
233
|
+
disableSources: true,
|
|
234
|
+
entryPointStrategy: "expand",
|
|
235
|
+
entryPoints: entryPoints.map((ep) => PATH2.resolve(packageLocation, ep)),
|
|
236
|
+
excludeExternals: true,
|
|
237
|
+
excludeInternal: true,
|
|
238
|
+
excludePrivate: true,
|
|
239
|
+
githubPages: false,
|
|
240
|
+
hideBreadcrumbs: true,
|
|
241
|
+
hideGenerator: true,
|
|
242
|
+
hidePageTitle: true,
|
|
243
|
+
out: tempDir,
|
|
244
|
+
plugin: ["typedoc-plugin-markdown"],
|
|
245
|
+
readme: "none",
|
|
246
|
+
skipErrorChecking: true,
|
|
247
|
+
sort: ["source-order"],
|
|
248
|
+
theme: "markdown",
|
|
249
|
+
useCodeBlocks: true
|
|
250
|
+
};
|
|
251
|
+
const typedocJsonPath = PATH2.join(tempDir, "typedoc.json");
|
|
252
|
+
FS.writeFileSync(typedocJsonPath, JSON.stringify(typedocConfig, null, 2));
|
|
253
|
+
try {
|
|
254
|
+
execSync(`npx typedoc --options ${typedocJsonPath}`, {
|
|
255
|
+
cwd: process.cwd(),
|
|
256
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
257
|
+
});
|
|
258
|
+
} catch {
|
|
259
|
+
return "";
|
|
260
|
+
}
|
|
261
|
+
return consolidateMarkdown(tempDir);
|
|
262
|
+
} catch {
|
|
263
|
+
return "";
|
|
264
|
+
} finally {
|
|
265
|
+
try {
|
|
266
|
+
FS.rmSync(tempDir, { force: true, recursive: true });
|
|
267
|
+
} catch {
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function consolidateMarkdown(tempDir) {
|
|
272
|
+
let consolidated = "## Reference\n\n";
|
|
273
|
+
const mainReadmePath = PATH2.join(tempDir, "README.md");
|
|
274
|
+
if (FS.existsSync(mainReadmePath)) {
|
|
275
|
+
const mainContent = FS.readFileSync(mainReadmePath, "utf8").replace(/^---(.|\n)*?---\n/, "").replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
|
|
276
|
+
consolidated += mainContent + "\n\n";
|
|
277
|
+
}
|
|
278
|
+
consolidated += processDirectory(tempDir);
|
|
279
|
+
return consolidated.replaceAll(/\n\n\n+/g, "\n\n").replaceAll(/^#### /gm, "### ").replaceAll(/^##### /gm, "#### ").replaceAll(/^###### /gm, "##### ");
|
|
280
|
+
}
|
|
281
|
+
function processDirectory(dir, level = 0) {
|
|
282
|
+
const indent = " ".repeat(level);
|
|
283
|
+
let content = "";
|
|
284
|
+
try {
|
|
285
|
+
const items = FS.readdirSync(dir, { withFileTypes: true });
|
|
286
|
+
for (const item of items) {
|
|
287
|
+
if (item.isDirectory()) continue;
|
|
288
|
+
if (item.name === "README.md" || !item.name.endsWith(".md")) continue;
|
|
289
|
+
const fileContent = FS.readFileSync(PATH2.join(dir, item.name), "utf8").replace(/^---(.|\n)*?---\n/, "");
|
|
290
|
+
const moduleName = item.name.replace(".md", "");
|
|
291
|
+
content += `
|
|
292
|
+
|
|
293
|
+
${indent}### <a id="${moduleName}"></a>${moduleName}
|
|
294
|
+
|
|
295
|
+
`;
|
|
296
|
+
content += fileContent.replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
|
|
297
|
+
}
|
|
298
|
+
for (const item of items) {
|
|
299
|
+
if (!item.isDirectory()) continue;
|
|
300
|
+
if (item.name === "spec" || item.name.includes(".spec")) continue;
|
|
301
|
+
content += `
|
|
302
|
+
|
|
303
|
+
${indent}### ${item.name}
|
|
304
|
+
`;
|
|
305
|
+
content += processDirectory(PATH2.join(dir, item.name), level + 1);
|
|
306
|
+
}
|
|
307
|
+
} catch {
|
|
308
|
+
}
|
|
309
|
+
return content;
|
|
310
|
+
}
|
|
311
|
+
function askConfirmation(question) {
|
|
312
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
313
|
+
return new Promise((resolve) => {
|
|
314
|
+
rl.question(question, (answer) => {
|
|
315
|
+
rl.close();
|
|
316
|
+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
var DEFAULT_README_TEMPLATE = readFileSync3(PATH2.resolve(readmeTemplatesDir, "README.template.md"), "utf8");
|
|
321
|
+
var DEFAULT_README_BODY = readFileSync3(PATH2.resolve(readmeTemplatesDir, "README.body.md"), "utf8");
|
|
322
|
+
function applyLogoConfig(template, logoUrl, logoLinkUrl) {
|
|
323
|
+
let result = template;
|
|
324
|
+
if (logoUrl) {
|
|
325
|
+
result = result.replace(/\[logo]: .+/, `[logo]: ${logoUrl}`);
|
|
326
|
+
if (logoLinkUrl) {
|
|
327
|
+
result = result.replace(/\[!\[logo]\[]][^)]*\)/, `[![logo][]](${logoLinkUrl})`);
|
|
328
|
+
}
|
|
329
|
+
} else {
|
|
330
|
+
result = result.replace(/\[!\[logo]\[]][^\n]*\n*/, "");
|
|
331
|
+
result = result.replace(/\[logo]: [^\n]*\n?/, "");
|
|
332
|
+
}
|
|
333
|
+
return result;
|
|
334
|
+
}
|
|
335
|
+
function resolveTemplatePath(templatePath) {
|
|
336
|
+
const cwd = INIT_CWD() ?? ".";
|
|
337
|
+
return templatePath ?? PATH2.join(cwd, ".xy", "README.template.md");
|
|
338
|
+
}
|
|
339
|
+
async function loadOrCreateTemplate(resolvedTemplatePath) {
|
|
340
|
+
try {
|
|
341
|
+
const template = await readFile(resolvedTemplatePath, "utf8");
|
|
342
|
+
return { created: false, template };
|
|
343
|
+
} catch {
|
|
344
|
+
console.log(chalk4.yellow(`Template not found: ${resolvedTemplatePath}`));
|
|
345
|
+
const shouldCreate = await askConfirmation("Would you like to create a stock template? (y/N) ");
|
|
346
|
+
if (!shouldCreate) {
|
|
347
|
+
throw new Error("Template creation declined");
|
|
348
|
+
}
|
|
349
|
+
const template = DEFAULT_README_TEMPLATE;
|
|
350
|
+
await scaffoldTemplate(resolvedTemplatePath, template);
|
|
351
|
+
return { created: true, template };
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
async function scaffoldTemplate(resolvedTemplatePath, template) {
|
|
355
|
+
const xyDir = PATH2.dirname(resolvedTemplatePath);
|
|
356
|
+
await mkdir(xyDir, { recursive: true });
|
|
357
|
+
await writeFile(resolvedTemplatePath, template);
|
|
358
|
+
console.log(chalk4.green(`Created template: ${resolvedTemplatePath}`));
|
|
359
|
+
const bodyPath = PATH2.join(xyDir, "README.body.md");
|
|
360
|
+
await writeFile(bodyPath, DEFAULT_README_BODY);
|
|
361
|
+
console.log(chalk4.green(`Created body template: ${bodyPath}`));
|
|
362
|
+
}
|
|
363
|
+
async function resolveBody(location, defaultBody) {
|
|
364
|
+
const localBodyPath = PATH2.join(location, "README.body.md");
|
|
365
|
+
try {
|
|
366
|
+
return await readFile(localBodyPath, "utf8");
|
|
367
|
+
} catch {
|
|
368
|
+
return defaultBody;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
async function generateReadmeForWorkspace(location, name, template, defaultBody, typedoc, verbose) {
|
|
372
|
+
try {
|
|
373
|
+
const pkgJsonPath = PATH2.join(location, "package.json");
|
|
374
|
+
const pkgJson = JSON.parse(await readFile(pkgJsonPath, "utf8"));
|
|
375
|
+
const body = await resolveBody(location, defaultBody);
|
|
376
|
+
const typedocContent = typedoc ? generateTypedoc(location, ["src/index*.ts"]) : "";
|
|
377
|
+
const readmeContent = fillTemplate(template, {
|
|
378
|
+
...pkgJson,
|
|
379
|
+
body,
|
|
380
|
+
typedoc: typedocContent
|
|
381
|
+
});
|
|
382
|
+
await writeFile(PATH2.join(location, "README.md"), readmeContent);
|
|
383
|
+
if (verbose) console.log(chalk4.green(` ${name}`));
|
|
384
|
+
return true;
|
|
385
|
+
} catch (ex) {
|
|
386
|
+
const error = ex;
|
|
387
|
+
console.warn(chalk4.yellow(` Skipped ${location}: ${error.message}`));
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async function generateReadmeFiles({
|
|
392
|
+
logoLinkUrl,
|
|
393
|
+
logoUrl,
|
|
394
|
+
pkg,
|
|
395
|
+
templatePath,
|
|
396
|
+
typedoc = false,
|
|
397
|
+
verbose = false
|
|
398
|
+
}) {
|
|
399
|
+
console.log(chalk4.green("Generate README Files"));
|
|
400
|
+
const resolvedTemplatePath = resolveTemplatePath(templatePath);
|
|
401
|
+
let template;
|
|
402
|
+
let templateCreated;
|
|
403
|
+
try {
|
|
404
|
+
({ template, created: templateCreated } = await loadOrCreateTemplate(resolvedTemplatePath));
|
|
405
|
+
} catch {
|
|
406
|
+
return 1;
|
|
407
|
+
}
|
|
408
|
+
template = applyLogoConfig(template, logoUrl, logoLinkUrl);
|
|
409
|
+
if (templateCreated) {
|
|
410
|
+
console.log(chalk4.green("Generating README files for all packages..."));
|
|
411
|
+
}
|
|
412
|
+
const xyDir = PATH2.dirname(resolvedTemplatePath);
|
|
413
|
+
const xyBodyPath = PATH2.join(xyDir, "README.body.md");
|
|
414
|
+
let defaultBody;
|
|
415
|
+
try {
|
|
416
|
+
defaultBody = await readFile(xyBodyPath, "utf8");
|
|
417
|
+
} catch {
|
|
418
|
+
defaultBody = DEFAULT_README_BODY;
|
|
419
|
+
}
|
|
420
|
+
const pm = getPackageManager();
|
|
421
|
+
const singleWorkspace = pkg && !templateCreated ? pm.findWorkspace(pkg) : void 0;
|
|
422
|
+
const workspaces = singleWorkspace ? [singleWorkspace] : pm.listWorkspaces();
|
|
423
|
+
let failed = false;
|
|
424
|
+
for (const { location, name } of workspaces) {
|
|
425
|
+
const success = await generateReadmeForWorkspace(location, name, template, defaultBody, typedoc, verbose);
|
|
426
|
+
if (!success) failed = true;
|
|
427
|
+
}
|
|
428
|
+
return failed ? 1 : 0;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// src/lib/gitignoreTemplate.ts
|
|
432
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
433
|
+
import { createRequire as createRequire3 } from "module";
|
|
434
|
+
import PATH3 from "path";
|
|
435
|
+
var require4 = createRequire3(import.meta.url);
|
|
436
|
+
var packageRoot3 = PATH3.dirname(require4.resolve("@xylabs/ts-scripts-common/package.json"));
|
|
437
|
+
var templatesDir2 = PATH3.resolve(packageRoot3, "templates", "gitignore");
|
|
438
|
+
var gitignoreTemplate = () => readFileSync4(PATH3.resolve(templatesDir2, "template.gitignore"), "utf8");
|
|
439
|
+
|
|
440
|
+
// src/lib/loadConfig.ts
|
|
441
|
+
import chalk5 from "chalk";
|
|
442
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
443
|
+
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
444
|
+
import deepmerge from "deepmerge";
|
|
445
|
+
var config;
|
|
446
|
+
var loadConfig = async (params) => {
|
|
447
|
+
if (config === void 0) {
|
|
448
|
+
const cosmicConfigResult = await cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } }).search();
|
|
449
|
+
config = cosmicConfigResult?.config;
|
|
450
|
+
const configFilePath = cosmicConfigResult?.filepath;
|
|
451
|
+
if (configFilePath !== void 0) {
|
|
452
|
+
console.log(chalk5.green(`Loaded config from ${configFilePath}`));
|
|
453
|
+
if (config.verbose) {
|
|
454
|
+
console.log(chalk5.gray(`${JSON.stringify(config, null, 2)}`));
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return deepmerge(config, params ?? {});
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
// src/lib/runSteps.ts
|
|
462
|
+
import { spawnSync } from "child_process";
|
|
463
|
+
import { existsSync as existsSync3 } from "fs";
|
|
464
|
+
import chalk6 from "chalk";
|
|
465
|
+
var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
466
|
+
return safeExit(() => {
|
|
467
|
+
const pkgName = process.env.npm_package_name;
|
|
468
|
+
console.log(chalk6.green(`${name} [${pkgName}]`));
|
|
469
|
+
let totalStatus = 0;
|
|
470
|
+
for (const [i, [command, args, config2]] of steps.entries()) {
|
|
471
|
+
if (messages?.[i]) {
|
|
472
|
+
console.log(chalk6.gray(messages?.[i]));
|
|
473
|
+
}
|
|
474
|
+
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
475
|
+
if (command === "node" && !existsSync3(argList[0])) {
|
|
476
|
+
throw new Error(`File not found [${argList[0]}]`);
|
|
477
|
+
}
|
|
478
|
+
const status = spawnSync(command, Array.isArray(args) ? args : args.split(" "), {
|
|
479
|
+
...config2,
|
|
480
|
+
encoding: "utf8",
|
|
481
|
+
env: { FORCE_COLOR: "3", ...process.env },
|
|
482
|
+
shell: true,
|
|
483
|
+
stdio: "inherit"
|
|
484
|
+
}).status ?? 0;
|
|
485
|
+
checkResult(name, status, "error", exitOnFail);
|
|
486
|
+
totalStatus += status ?? 0;
|
|
487
|
+
}
|
|
488
|
+
return totalStatus;
|
|
489
|
+
}, !!exitOnFail);
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
// src/actions/claude-clean.ts
|
|
493
|
+
import {
|
|
494
|
+
existsSync as existsSync4,
|
|
495
|
+
readdirSync as readdirSync2,
|
|
496
|
+
rmSync,
|
|
497
|
+
unlinkSync
|
|
498
|
+
} from "fs";
|
|
499
|
+
import PATH4 from "path";
|
|
500
|
+
import chalk7 from "chalk";
|
|
501
|
+
function removeFile(filePath, label) {
|
|
502
|
+
if (existsSync4(filePath)) {
|
|
503
|
+
unlinkSync(filePath);
|
|
504
|
+
console.log(chalk7.yellow(` Removed ${label}`));
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
function removeDir(dirPath, label) {
|
|
510
|
+
if (existsSync4(dirPath)) {
|
|
511
|
+
rmSync(dirPath, { recursive: true });
|
|
512
|
+
console.log(chalk7.yellow(` Removed ${label}`));
|
|
513
|
+
return true;
|
|
514
|
+
}
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
function claudeClean() {
|
|
518
|
+
console.log(chalk7.green("Clean Claude configuration"));
|
|
519
|
+
const cwd = INIT_CWD() ?? process.cwd();
|
|
520
|
+
let removed = 0;
|
|
521
|
+
const rootFiles = ["CLAUDE.md", "CLAUDE.local.md"];
|
|
522
|
+
for (const file of rootFiles) {
|
|
523
|
+
if (removeFile(PATH4.resolve(cwd, file), file)) removed++;
|
|
524
|
+
}
|
|
525
|
+
if (removeDir(PATH4.resolve(cwd, ".claude"), ".claude/")) removed++;
|
|
526
|
+
const packagesDir = PATH4.resolve(cwd, "packages");
|
|
527
|
+
if (existsSync4(packagesDir)) {
|
|
528
|
+
const findClaudeFiles = (dir, prefix) => {
|
|
529
|
+
const entries = readdirSync2(dir, { withFileTypes: true });
|
|
530
|
+
for (const entry of entries) {
|
|
531
|
+
const fullPath = PATH4.resolve(dir, entry.name);
|
|
532
|
+
const label = `${prefix}${entry.name}`;
|
|
533
|
+
if (entry.isFile() && (entry.name === "CLAUDE.md" || entry.name === "CLAUDE.local.md")) {
|
|
534
|
+
if (removeFile(fullPath, label)) removed++;
|
|
535
|
+
} else if (entry.isDirectory() && entry.name === ".claude") {
|
|
536
|
+
if (removeDir(fullPath, `${label}/`)) removed++;
|
|
537
|
+
} else if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "dist") {
|
|
538
|
+
findClaudeFiles(fullPath, `${label}/`);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
findClaudeFiles(packagesDir, "packages/");
|
|
543
|
+
}
|
|
544
|
+
if (removed > 0) {
|
|
545
|
+
console.log(chalk7.green(` Removed ${removed} item(s)`));
|
|
546
|
+
} else {
|
|
547
|
+
console.log(chalk7.gray(" Nothing to clean"));
|
|
548
|
+
}
|
|
549
|
+
return 0;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// src/actions/claude-commands.ts
|
|
553
|
+
import {
|
|
554
|
+
existsSync as existsSync5,
|
|
555
|
+
mkdirSync,
|
|
556
|
+
readdirSync as readdirSync3,
|
|
557
|
+
readFileSync as readFileSync5,
|
|
558
|
+
unlinkSync as unlinkSync2,
|
|
559
|
+
writeFileSync as writeFileSync2
|
|
560
|
+
} from "fs";
|
|
561
|
+
import PATH5 from "path";
|
|
562
|
+
import chalk8 from "chalk";
|
|
563
|
+
var syncCommandFiles = (commandsDir) => {
|
|
564
|
+
const templates = claudeCommandTemplates();
|
|
565
|
+
const templateNames = new Set(Object.keys(templates));
|
|
566
|
+
let updated = 0;
|
|
567
|
+
let created = 0;
|
|
568
|
+
for (const [filename2, content] of Object.entries(templates)) {
|
|
569
|
+
const targetPath = PATH5.resolve(commandsDir, filename2);
|
|
570
|
+
const existing = existsSync5(targetPath) ? readFileSync5(targetPath, "utf8") : void 0;
|
|
571
|
+
if (existing === content) continue;
|
|
572
|
+
writeFileSync2(targetPath, content, "utf8");
|
|
573
|
+
if (existing) {
|
|
574
|
+
updated++;
|
|
575
|
+
} else {
|
|
576
|
+
created++;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return {
|
|
580
|
+
created,
|
|
581
|
+
templateNames,
|
|
582
|
+
updated
|
|
583
|
+
};
|
|
584
|
+
};
|
|
585
|
+
var removeStaleCommands = (commandsDir, templateNames) => {
|
|
586
|
+
const existingCommands = readdirSync3(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
|
|
587
|
+
let removed = 0;
|
|
588
|
+
for (const file of existingCommands) {
|
|
589
|
+
if (!templateNames.has(file)) {
|
|
590
|
+
unlinkSync2(PATH5.resolve(commandsDir, file));
|
|
591
|
+
removed++;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return removed;
|
|
595
|
+
};
|
|
596
|
+
var removeLegacyCommands = (commandsDir) => {
|
|
597
|
+
const legacyFiles = readdirSync3(commandsDir).filter((f) => f.startsWith(LEGACY_COMMANDS_PREFIX) && f.endsWith(".md"));
|
|
598
|
+
for (const file of legacyFiles) {
|
|
599
|
+
unlinkSync2(PATH5.resolve(commandsDir, file));
|
|
600
|
+
}
|
|
601
|
+
return legacyFiles.length;
|
|
602
|
+
};
|
|
603
|
+
var logCommandsResult = (created, updated, removed) => {
|
|
604
|
+
if (created || updated || removed) {
|
|
605
|
+
const parts = [
|
|
606
|
+
created ? `${created} created` : "",
|
|
607
|
+
updated ? `${updated} updated` : "",
|
|
608
|
+
removed ? `${removed} removed` : ""
|
|
609
|
+
].filter(Boolean);
|
|
610
|
+
console.log(chalk8.green(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: ${parts.join(", ")}`));
|
|
611
|
+
} else {
|
|
612
|
+
console.log(chalk8.gray(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: already up to date`));
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
var claudeCommands = () => {
|
|
616
|
+
const cwd = INIT_CWD() ?? process.cwd();
|
|
617
|
+
const commandsDir = PATH5.resolve(cwd, ".claude", "commands");
|
|
618
|
+
mkdirSync(commandsDir, { recursive: true });
|
|
619
|
+
const legacy = removeLegacyCommands(commandsDir);
|
|
620
|
+
const {
|
|
621
|
+
created,
|
|
622
|
+
templateNames,
|
|
623
|
+
updated
|
|
624
|
+
} = syncCommandFiles(commandsDir);
|
|
625
|
+
const removed = removeStaleCommands(commandsDir, templateNames);
|
|
626
|
+
logCommandsResult(created, updated, removed + legacy);
|
|
627
|
+
return 0;
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
// src/actions/claude-rules.ts
|
|
631
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
632
|
+
import {
|
|
633
|
+
existsSync as existsSync6,
|
|
634
|
+
mkdirSync as mkdirSync2,
|
|
635
|
+
readdirSync as readdirSync4,
|
|
636
|
+
readFileSync as readFileSync6,
|
|
637
|
+
unlinkSync as unlinkSync3,
|
|
638
|
+
writeFileSync as writeFileSync3
|
|
639
|
+
} from "fs";
|
|
640
|
+
import PATH6 from "path";
|
|
641
|
+
import chalk9 from "chalk";
|
|
642
|
+
var syncRuleFiles = (rulesDir) => {
|
|
643
|
+
const templates = claudeMdRuleTemplates();
|
|
644
|
+
const templateNames = new Set(Object.keys(templates));
|
|
645
|
+
let updated = 0;
|
|
646
|
+
let created = 0;
|
|
647
|
+
for (const [filename2, content] of Object.entries(templates)) {
|
|
648
|
+
const targetPath = PATH6.resolve(rulesDir, filename2);
|
|
649
|
+
const existing = existsSync6(targetPath) ? readFileSync6(targetPath, "utf8") : void 0;
|
|
650
|
+
if (existing === content) continue;
|
|
651
|
+
writeFileSync3(targetPath, content, "utf8");
|
|
652
|
+
if (existing) {
|
|
653
|
+
updated++;
|
|
654
|
+
} else {
|
|
655
|
+
created++;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return {
|
|
659
|
+
created,
|
|
660
|
+
templateNames,
|
|
661
|
+
updated
|
|
662
|
+
};
|
|
663
|
+
};
|
|
664
|
+
var removeStaleRules = (rulesDir, templateNames) => {
|
|
665
|
+
const existingRules = readdirSync4(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
|
|
666
|
+
let removed = 0;
|
|
667
|
+
for (const file of existingRules) {
|
|
668
|
+
if (!templateNames.has(file)) {
|
|
669
|
+
unlinkSync3(PATH6.resolve(rulesDir, file));
|
|
670
|
+
removed++;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return removed;
|
|
674
|
+
};
|
|
675
|
+
var logRulesResult = (created, updated, removed) => {
|
|
676
|
+
if (created || updated || removed) {
|
|
677
|
+
const parts = [
|
|
678
|
+
created ? `${created} created` : "",
|
|
679
|
+
updated ? `${updated} updated` : "",
|
|
680
|
+
removed ? `${removed} removed` : ""
|
|
681
|
+
].filter(Boolean);
|
|
682
|
+
console.log(chalk9.green(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: ${parts.join(", ")}`));
|
|
683
|
+
} else {
|
|
684
|
+
console.log(chalk9.gray(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: already up to date`));
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
var ensureProjectClaudeMd = (cwd, force) => {
|
|
688
|
+
const projectPath = PATH6.resolve(cwd, "CLAUDE.md");
|
|
689
|
+
if (!existsSync6(projectPath) || force) {
|
|
690
|
+
if (force && existsSync6(projectPath)) {
|
|
691
|
+
console.log(chalk9.yellow("Regenerating CLAUDE.md"));
|
|
692
|
+
}
|
|
693
|
+
console.log(chalk9.green("Generating CLAUDE.md via claude /init..."));
|
|
694
|
+
const result = spawnSync2("claude", ["-p", "/init", "--allowedTools", "Read", "Write", "Glob", "Grep"], {
|
|
695
|
+
cwd,
|
|
696
|
+
shell: true,
|
|
697
|
+
stdio: "inherit"
|
|
698
|
+
});
|
|
699
|
+
if (result.status !== 0) {
|
|
700
|
+
console.error(chalk9.red("claude /init failed \u2014 is Claude Code installed?"));
|
|
701
|
+
return 1;
|
|
702
|
+
}
|
|
703
|
+
} else {
|
|
704
|
+
console.log(chalk9.gray("CLAUDE.md already exists (skipped, use --force to regenerate)"));
|
|
705
|
+
}
|
|
706
|
+
return 0;
|
|
707
|
+
};
|
|
708
|
+
var ensureLocalClaudeMd = (cwd) => {
|
|
709
|
+
const localPath = PATH6.resolve(cwd, "CLAUDE.local.md");
|
|
710
|
+
if (existsSync6(localPath)) {
|
|
711
|
+
console.log(chalk9.gray("CLAUDE.local.md already exists (skipped)"));
|
|
712
|
+
} else {
|
|
713
|
+
writeFileSync3(localPath, claudeMdLocalTemplate(), "utf8");
|
|
714
|
+
console.log(chalk9.green("Generated CLAUDE.local.md"));
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
var claudeRules = ({ force } = {}) => {
|
|
718
|
+
const cwd = INIT_CWD() ?? process.cwd();
|
|
719
|
+
const rulesDir = PATH6.resolve(cwd, ".claude", "rules");
|
|
720
|
+
mkdirSync2(rulesDir, { recursive: true });
|
|
721
|
+
const {
|
|
722
|
+
created,
|
|
723
|
+
templateNames,
|
|
724
|
+
updated
|
|
725
|
+
} = syncRuleFiles(rulesDir);
|
|
726
|
+
const removed = removeStaleRules(rulesDir, templateNames);
|
|
727
|
+
logRulesResult(created, updated, removed);
|
|
728
|
+
const claudeMdResult = ensureProjectClaudeMd(cwd, force);
|
|
729
|
+
ensureLocalClaudeMd(cwd);
|
|
730
|
+
return claudeMdResult ?? 0;
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// src/actions/claude-settings.ts
|
|
734
|
+
import {
|
|
735
|
+
existsSync as existsSync7,
|
|
736
|
+
mkdirSync as mkdirSync3,
|
|
737
|
+
writeFileSync as writeFileSync4
|
|
738
|
+
} from "fs";
|
|
739
|
+
import PATH7 from "path";
|
|
740
|
+
import { createInterface as createInterface2 } from "readline";
|
|
741
|
+
import chalk10 from "chalk";
|
|
742
|
+
var DEFAULT_SETTINGS = {
|
|
743
|
+
permissions: {
|
|
744
|
+
allow: [
|
|
745
|
+
"Bash(git *)",
|
|
746
|
+
"Bash(yarn *)",
|
|
747
|
+
"Bash(npx *)",
|
|
748
|
+
"Bash(node *)",
|
|
749
|
+
"Bash(ls *)",
|
|
750
|
+
"Bash(mkdir *)",
|
|
751
|
+
"Bash(cp *)",
|
|
752
|
+
"Bash(mv *)",
|
|
753
|
+
"Bash(rm *)",
|
|
754
|
+
"Bash(cat *)",
|
|
755
|
+
"Bash(head *)",
|
|
756
|
+
"Bash(tail *)",
|
|
757
|
+
"Bash(echo *)",
|
|
758
|
+
"Bash(pwd)",
|
|
759
|
+
"Bash(which *)",
|
|
760
|
+
"Bash(grep *)",
|
|
761
|
+
"Bash(find *)",
|
|
762
|
+
"Bash(npm view *)",
|
|
763
|
+
"Bash(gh *)",
|
|
764
|
+
"Read",
|
|
765
|
+
"Edit",
|
|
766
|
+
"Write",
|
|
767
|
+
"Glob",
|
|
768
|
+
"Grep",
|
|
769
|
+
"Skill"
|
|
770
|
+
],
|
|
771
|
+
deny: [
|
|
772
|
+
"Bash(git push --force *)",
|
|
773
|
+
"Bash(git reset --hard *)",
|
|
774
|
+
"Bash(rm -rf /*)"
|
|
775
|
+
]
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
function askConfirmation2(question) {
|
|
779
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
780
|
+
return new Promise((resolve) => {
|
|
781
|
+
rl.question(question, (answer) => {
|
|
782
|
+
rl.close();
|
|
783
|
+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
async function claudeSettings() {
|
|
788
|
+
const cwd = INIT_CWD() ?? process.cwd();
|
|
789
|
+
const claudeDir = PATH7.resolve(cwd, ".claude");
|
|
790
|
+
const settingsPath = PATH7.resolve(claudeDir, "settings.local.json");
|
|
791
|
+
mkdirSync3(claudeDir, { recursive: true });
|
|
792
|
+
if (existsSync7(settingsPath)) {
|
|
793
|
+
const confirmed = await askConfirmation2(
|
|
794
|
+
chalk10.yellow(`${settingsPath} already exists. Replace it? (y/N) `)
|
|
795
|
+
);
|
|
796
|
+
if (!confirmed) {
|
|
797
|
+
console.log(chalk10.gray("Skipped \u2014 existing settings.local.json preserved"));
|
|
798
|
+
return 0;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
writeFileSync4(settingsPath, `${JSON.stringify(DEFAULT_SETTINGS, null, 2)}
|
|
802
|
+
`, "utf8");
|
|
803
|
+
console.log(chalk10.green("Generated .claude/settings.local.json"));
|
|
804
|
+
return 0;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// src/actions/claude-skills.ts
|
|
808
|
+
import {
|
|
809
|
+
existsSync as existsSync8,
|
|
810
|
+
mkdirSync as mkdirSync4,
|
|
811
|
+
readdirSync as readdirSync5,
|
|
812
|
+
readFileSync as readFileSync7,
|
|
813
|
+
rmSync as rmSync2,
|
|
814
|
+
statSync as statSync2,
|
|
815
|
+
writeFileSync as writeFileSync5
|
|
816
|
+
} from "fs";
|
|
817
|
+
import PATH8 from "path";
|
|
818
|
+
import chalk11 from "chalk";
|
|
819
|
+
var syncSkillFiles = (skillsDir) => {
|
|
820
|
+
const templates = claudeSkillTemplates();
|
|
821
|
+
const templateNames = new Set(Object.keys(templates));
|
|
822
|
+
let updated = 0;
|
|
823
|
+
let created = 0;
|
|
824
|
+
for (const [skillName, files] of Object.entries(templates)) {
|
|
825
|
+
const skillDir = PATH8.resolve(skillsDir, skillName);
|
|
826
|
+
mkdirSync4(skillDir, { recursive: true });
|
|
827
|
+
for (const [filename2, content] of Object.entries(files)) {
|
|
828
|
+
const targetPath = PATH8.resolve(skillDir, filename2);
|
|
829
|
+
mkdirSync4(PATH8.dirname(targetPath), { recursive: true });
|
|
830
|
+
const existing = existsSync8(targetPath) ? readFileSync7(targetPath, "utf8") : void 0;
|
|
831
|
+
if (existing === content) continue;
|
|
832
|
+
writeFileSync5(targetPath, content, "utf8");
|
|
833
|
+
if (existing) {
|
|
834
|
+
updated++;
|
|
835
|
+
} else {
|
|
836
|
+
created++;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return {
|
|
841
|
+
created,
|
|
842
|
+
templateNames,
|
|
843
|
+
updated
|
|
844
|
+
};
|
|
845
|
+
};
|
|
846
|
+
var removeStaleSkills = (skillsDir, templateNames) => {
|
|
847
|
+
const existingSkills = readdirSync5(skillsDir).filter(
|
|
848
|
+
(f) => f.startsWith(XYLABS_SKILLS_PREFIX) && statSync2(PATH8.resolve(skillsDir, f)).isDirectory()
|
|
849
|
+
);
|
|
850
|
+
let removed = 0;
|
|
851
|
+
for (const dir of existingSkills) {
|
|
852
|
+
if (!templateNames.has(dir)) {
|
|
853
|
+
rmSync2(PATH8.resolve(skillsDir, dir), { recursive: true });
|
|
854
|
+
removed++;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return removed;
|
|
858
|
+
};
|
|
859
|
+
var logSkillsResult = (created, updated, removed) => {
|
|
860
|
+
if (created || updated || removed) {
|
|
861
|
+
const parts = [
|
|
862
|
+
created ? `${created} created` : "",
|
|
863
|
+
updated ? `${updated} updated` : "",
|
|
864
|
+
removed ? `${removed} removed` : ""
|
|
865
|
+
].filter(Boolean);
|
|
866
|
+
console.log(chalk11.green(`.claude/skills/${XYLABS_SKILLS_PREFIX}*/: ${parts.join(", ")}`));
|
|
867
|
+
} else {
|
|
868
|
+
console.log(chalk11.gray(`.claude/skills/${XYLABS_SKILLS_PREFIX}*/: already up to date`));
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
var claudeSkills = () => {
|
|
872
|
+
const cwd = INIT_CWD() ?? process.cwd();
|
|
873
|
+
const skillsDir = PATH8.resolve(cwd, ".claude", "skills");
|
|
874
|
+
mkdirSync4(skillsDir, { recursive: true });
|
|
875
|
+
const {
|
|
876
|
+
created,
|
|
877
|
+
templateNames,
|
|
878
|
+
updated
|
|
879
|
+
} = syncSkillFiles(skillsDir);
|
|
880
|
+
const removed = removeStaleSkills(skillsDir, templateNames);
|
|
881
|
+
logSkillsResult(created, updated, removed);
|
|
882
|
+
return 0;
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
// src/actions/clean-docs.ts
|
|
886
|
+
import path from "path";
|
|
887
|
+
import chalk12 from "chalk";
|
|
888
|
+
var cleanDocs = () => {
|
|
889
|
+
const pkgName = process.env.npm_package_name;
|
|
890
|
+
console.log(chalk12.green(`Cleaning Docs [${pkgName}]`));
|
|
891
|
+
for (const { location } of getPackageManager().listWorkspaces()) deleteGlob(path.join(location, "docs"));
|
|
892
|
+
return 0;
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
// src/actions/dead.ts
|
|
896
|
+
var dead = () => {
|
|
897
|
+
return runSteps("Dead", [["ts-prune", ["-p", "tsconfig.json"]]]);
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
// src/actions/gen-docs.ts
|
|
901
|
+
var genDocs = ({ pkg, incremental }) => {
|
|
902
|
+
return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental });
|
|
903
|
+
};
|
|
904
|
+
var genDocsPackage = ({ pkg }) => {
|
|
905
|
+
const pm = getPackageManager();
|
|
906
|
+
return runSteps(`GenDocs [${pkg}]`, [pm.runInWorkspace(pkg, "package-gen-docs")]);
|
|
907
|
+
};
|
|
908
|
+
var genDocsAll = ({ incremental }) => {
|
|
909
|
+
const pm = getPackageManager();
|
|
910
|
+
return runSteps(`GenDocs [All${incremental ? "-Incremental" : ""}]`, [
|
|
911
|
+
pm.foreachWorkspace("package-gen-docs", [], { incremental })
|
|
912
|
+
]);
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
// src/actions/gitignore.ts
|
|
916
|
+
import { unlinkSync as unlinkSync4 } from "fs";
|
|
917
|
+
import chalk13 from "chalk";
|
|
918
|
+
var COMMENT_PREFIX = "#";
|
|
919
|
+
var isComment = (line) => line.startsWith(COMMENT_PREFIX);
|
|
920
|
+
var isNegation = (line) => line.startsWith("!");
|
|
921
|
+
function parseTemplateSections(lines) {
|
|
922
|
+
const sections = [];
|
|
923
|
+
let current = [];
|
|
924
|
+
for (const line of lines) {
|
|
925
|
+
if (isComment(line)) {
|
|
926
|
+
if (current.length > 0) {
|
|
927
|
+
sections.push(current);
|
|
928
|
+
}
|
|
929
|
+
current = [line];
|
|
930
|
+
} else {
|
|
931
|
+
current.push(line);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
if (current.length > 0) {
|
|
935
|
+
sections.push(current);
|
|
936
|
+
}
|
|
937
|
+
return sections;
|
|
938
|
+
}
|
|
939
|
+
function mergeWithTemplate(existing, templateContent) {
|
|
940
|
+
const templateLines = templateContent.split("\n").filter((line) => line.trim().length > 0);
|
|
941
|
+
const sections = parseTemplateSections(templateLines);
|
|
942
|
+
const existingEntries = new Set(existing.filter((line) => !isComment(line)));
|
|
943
|
+
const templateEntries = new Set(templateLines.filter((line) => !isComment(line)));
|
|
944
|
+
const customEntries = [...existingEntries].filter((entry) => !templateEntries.has(entry));
|
|
945
|
+
const result = [];
|
|
946
|
+
for (const section of sections) {
|
|
947
|
+
for (const line of section) {
|
|
948
|
+
result.push(line);
|
|
949
|
+
}
|
|
950
|
+
result.push("");
|
|
951
|
+
}
|
|
952
|
+
if (customEntries.length > 0) {
|
|
953
|
+
result.push("# Custom");
|
|
954
|
+
const sorted = [...union(customEntries, [])].toSorted((a, b) => {
|
|
955
|
+
if (isNegation(a) && !isNegation(b)) return 1;
|
|
956
|
+
if (!isNegation(a) && isNegation(b)) return -1;
|
|
957
|
+
return a.localeCompare(b);
|
|
958
|
+
});
|
|
959
|
+
for (const entry of sorted) {
|
|
960
|
+
result.push(entry);
|
|
961
|
+
}
|
|
962
|
+
result.push("");
|
|
963
|
+
}
|
|
964
|
+
return result;
|
|
965
|
+
}
|
|
966
|
+
function removePackageGitignores(cwd) {
|
|
967
|
+
let removed = 0;
|
|
968
|
+
const workspaces = getPackageManager().listWorkspaces();
|
|
969
|
+
for (const { location } of workspaces) {
|
|
970
|
+
if (location === ".") continue;
|
|
971
|
+
const filePath = `${cwd}/${location}/.gitignore`;
|
|
972
|
+
try {
|
|
973
|
+
unlinkSync4(filePath);
|
|
974
|
+
console.log(chalk13.yellow(` Removed ${location}/.gitignore`));
|
|
975
|
+
removed++;
|
|
976
|
+
} catch {
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return removed;
|
|
980
|
+
}
|
|
981
|
+
function gitignore() {
|
|
982
|
+
console.log(chalk13.green("Generate .gitignore"));
|
|
983
|
+
const cwd = INIT_CWD() ?? ".";
|
|
984
|
+
const gitignorePath = `${cwd}/.gitignore`;
|
|
985
|
+
try {
|
|
986
|
+
const templateContent = gitignoreTemplate();
|
|
987
|
+
const existing = readNonEmptyLines(gitignorePath);
|
|
988
|
+
const merged = mergeWithTemplate(existing, templateContent);
|
|
989
|
+
writeLines(gitignorePath, merged);
|
|
990
|
+
console.log(chalk13.green(" Root .gitignore updated"));
|
|
991
|
+
const removed = removePackageGitignores(cwd);
|
|
992
|
+
if (removed > 0) {
|
|
993
|
+
console.log(chalk13.green(` Removed ${removed} package .gitignore file(s)`));
|
|
994
|
+
}
|
|
995
|
+
return 0;
|
|
996
|
+
} catch (ex) {
|
|
997
|
+
const error = ex;
|
|
998
|
+
console.error(chalk13.red(`Generate .gitignore failed: ${error.message}`));
|
|
999
|
+
return 1;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// src/actions/gitlint.ts
|
|
1004
|
+
import chalk14 from "chalk";
|
|
1005
|
+
import ParseGitConfig from "parse-git-config";
|
|
1006
|
+
var gitlint = () => {
|
|
1007
|
+
console.log(`
|
|
1008
|
+
Gitlint Start [${process.cwd()}]
|
|
1009
|
+
`);
|
|
1010
|
+
let valid = 0;
|
|
1011
|
+
let warnings = 0;
|
|
1012
|
+
const errors = 0;
|
|
1013
|
+
const gitConfig = ParseGitConfig.sync();
|
|
1014
|
+
const warn = (message) => {
|
|
1015
|
+
console.warn(chalk14.yellow(`Warning: ${message}`));
|
|
1016
|
+
warnings++;
|
|
1017
|
+
};
|
|
1018
|
+
if (gitConfig.core.ignorecase) {
|
|
1019
|
+
warn("Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]");
|
|
1020
|
+
} else {
|
|
1021
|
+
valid++;
|
|
1022
|
+
}
|
|
1023
|
+
if (gitConfig.core.autocrlf === false) {
|
|
1024
|
+
valid++;
|
|
1025
|
+
} else {
|
|
1026
|
+
warn("Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]");
|
|
1027
|
+
}
|
|
1028
|
+
if (gitConfig.core.eol === "lf") {
|
|
1029
|
+
valid++;
|
|
1030
|
+
} else {
|
|
1031
|
+
warn('Please set core.eol to "lf" in .git/config file [run yarn gitlint-fix]');
|
|
1032
|
+
}
|
|
1033
|
+
const resultMessages = [];
|
|
1034
|
+
if (valid > 0) {
|
|
1035
|
+
resultMessages.push(chalk14.green(`Passed: ${valid}`));
|
|
1036
|
+
}
|
|
1037
|
+
if (warnings > 0) {
|
|
1038
|
+
resultMessages.push(chalk14.yellow(`Warnings: ${warnings}`));
|
|
1039
|
+
}
|
|
1040
|
+
if (errors > 0) {
|
|
1041
|
+
resultMessages.push(chalk14.red(` Errors: ${errors}`));
|
|
1042
|
+
}
|
|
1043
|
+
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1044
|
+
`);
|
|
1045
|
+
return warnings + errors === 0 ? 1 : 0;
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
// src/actions/gitlint-fix.ts
|
|
1049
|
+
import { execSync as execSync2 } from "child_process";
|
|
1050
|
+
import chalk15 from "chalk";
|
|
1051
|
+
import ParseGitConfig2 from "parse-git-config";
|
|
1052
|
+
var gitlintFix = () => {
|
|
1053
|
+
console.log(`
|
|
1054
|
+
Gitlint Fix Start [${process.cwd()}]
|
|
1055
|
+
`);
|
|
1056
|
+
const gitConfig = ParseGitConfig2.sync();
|
|
1057
|
+
if (gitConfig.core.ignorecase) {
|
|
1058
|
+
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1059
|
+
console.warn(chalk15.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1060
|
+
}
|
|
1061
|
+
if (gitConfig.core.autocrlf !== false) {
|
|
1062
|
+
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1063
|
+
console.warn(chalk15.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1064
|
+
}
|
|
1065
|
+
if (gitConfig.core.eol !== "lf") {
|
|
1066
|
+
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1067
|
+
console.warn(chalk15.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1068
|
+
}
|
|
1069
|
+
return 1;
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
// src/actions/license.ts
|
|
1073
|
+
import chalk16 from "chalk";
|
|
1074
|
+
import { init } from "license-checker";
|
|
1075
|
+
var license = async (pkg) => {
|
|
1076
|
+
const workspaces = getPackageManager().listWorkspaces();
|
|
1077
|
+
const workspaceList = workspaces.filter(({ name }) => {
|
|
1078
|
+
return pkg === void 0 || name === pkg;
|
|
1079
|
+
});
|
|
1080
|
+
const exclude = /* @__PURE__ */ new Set([
|
|
1081
|
+
"MIT",
|
|
1082
|
+
"MIT*",
|
|
1083
|
+
"ISC",
|
|
1084
|
+
"Apache-2.0",
|
|
1085
|
+
"BSD",
|
|
1086
|
+
"BSD*",
|
|
1087
|
+
"BSD-2-Clause",
|
|
1088
|
+
"BSD-3-Clause",
|
|
1089
|
+
"CC-BY-4.0",
|
|
1090
|
+
"Unlicense",
|
|
1091
|
+
"CC-BY-3.0",
|
|
1092
|
+
"CC0-1.0",
|
|
1093
|
+
"LGPL-3.0-only",
|
|
1094
|
+
"LGPL-3.0",
|
|
1095
|
+
"LGPL-3.0-or-later",
|
|
1096
|
+
"Python-2.0"
|
|
1097
|
+
]);
|
|
1098
|
+
console.log(chalk16.green("License Checker"));
|
|
1099
|
+
return (await Promise.all(
|
|
1100
|
+
workspaceList.map(({ location, name }) => {
|
|
1101
|
+
return new Promise((resolve) => {
|
|
1102
|
+
init({ production: true, start: location }, (error, packages) => {
|
|
1103
|
+
if (error) {
|
|
1104
|
+
console.error(chalk16.red(`License Checker [${name}] Error`));
|
|
1105
|
+
console.error(chalk16.gray(error));
|
|
1106
|
+
console.log("\n");
|
|
1107
|
+
resolve(1);
|
|
1108
|
+
} else {
|
|
1109
|
+
console.log(chalk16.green(`License Checker [${name}]`));
|
|
1110
|
+
let count = 0;
|
|
1111
|
+
for (const [name2, info] of Object.entries(packages)) {
|
|
1112
|
+
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
1113
|
+
for (let license2 of licenses) {
|
|
1114
|
+
if (license2) {
|
|
1115
|
+
const processedLicense = license2[0] === "(" && license2.at(-1) === ")" ? license2.slice(1, -2) : license2;
|
|
1116
|
+
const orLicenses = processedLicense.split(" OR ");
|
|
1117
|
+
let orLicenseFound = false;
|
|
1118
|
+
for (const orLicense of orLicenses) {
|
|
1119
|
+
if (exclude.has(orLicense)) {
|
|
1120
|
+
orLicenseFound = true;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
if (!orLicenseFound) {
|
|
1124
|
+
count++;
|
|
1125
|
+
console.warn(chalk16.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
console.log("\n");
|
|
1131
|
+
resolve(count);
|
|
1132
|
+
}
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
})
|
|
1136
|
+
)).reduce((prev, value) => prev || value, 0);
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
// src/actions/npmignore-gen.ts
|
|
1140
|
+
var filename = ".npmignore";
|
|
1141
|
+
var npmignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1142
|
+
|
|
1143
|
+
// src/actions/packman/convert.ts
|
|
1144
|
+
import {
|
|
1145
|
+
existsSync as existsSync11,
|
|
1146
|
+
readdirSync as readdirSync6,
|
|
1147
|
+
readFileSync as readFileSync10,
|
|
1148
|
+
statSync as statSync3
|
|
1149
|
+
} from "fs";
|
|
1150
|
+
import PATH11 from "path";
|
|
1151
|
+
import chalk19 from "chalk";
|
|
1152
|
+
|
|
1153
|
+
// src/actions/packman/convertToPnpm.ts
|
|
1154
|
+
import {
|
|
1155
|
+
existsSync as existsSync9,
|
|
1156
|
+
mkdirSync as mkdirSync5,
|
|
1157
|
+
readFileSync as readFileSync8,
|
|
1158
|
+
rmSync as rmSync3,
|
|
1159
|
+
writeFileSync as writeFileSync6
|
|
1160
|
+
} from "fs";
|
|
1161
|
+
import PATH9 from "path";
|
|
1162
|
+
import chalk17 from "chalk";
|
|
1163
|
+
|
|
1164
|
+
// src/actions/packman/rewriteScripts.ts
|
|
1165
|
+
function rewriteYarnToPnpm(script) {
|
|
1166
|
+
let result = script;
|
|
1167
|
+
result = result.replaceAll(/\byarn workspace (\S+) run /g, "pnpm --filter $1 run ");
|
|
1168
|
+
result = result.replaceAll(/\byarn workspace (\S+) (package-\S+)/g, "pnpm --filter $1 run $2");
|
|
1169
|
+
result = result.replaceAll(/\byarn workspaces foreach\s+(?:[^\s]*\s+)*run /g, "pnpm -r run ");
|
|
1170
|
+
result = result.replaceAll(/\byarn workspaces foreach --all version (\S+) --deferred/g, "pnpm -r exec npm version $1 --no-git-tag-version");
|
|
1171
|
+
result = result.replaceAll(/\byarn version apply --all/g, 'echo "versions applied"');
|
|
1172
|
+
result = result.replaceAll(/\byarn xy\b/g, "pnpm xy");
|
|
1173
|
+
result = result.replaceAll(/\byarn add\b/g, "pnpm add");
|
|
1174
|
+
result = result.replaceAll(/\byarn remove\b/g, "pnpm remove");
|
|
1175
|
+
result = result.replaceAll(/\byarn install\b/g, "pnpm install");
|
|
1176
|
+
result = result.replaceAll(/\byarn dedupe\b/g, "pnpm dedupe");
|
|
1177
|
+
result = result.replaceAll(/\byarn outdated\b/g, "pnpm outdated");
|
|
1178
|
+
result = result.replaceAll(/\byarn run\b/g, "pnpm run");
|
|
1179
|
+
result = result.replaceAll(/\byarn rimraf\b/g, "rimraf");
|
|
1180
|
+
result = result.replaceAll(/\byarn npm\b/g, "npm");
|
|
1181
|
+
result = result.replaceAll(/\byarn\b(?![@/.])/g, "pnpm");
|
|
1182
|
+
return result;
|
|
1183
|
+
}
|
|
1184
|
+
function rewritePnpmToYarn(script) {
|
|
1185
|
+
let result = script;
|
|
1186
|
+
result = result.replaceAll(/\bpnpm --filter (\S+) run /g, "yarn workspace $1 run ");
|
|
1187
|
+
result = result.replaceAll(/\bpnpm -r run /g, "yarn workspaces foreach -Apt run ");
|
|
1188
|
+
result = result.replaceAll(/\bpnpm -r exec npm version (\S+) --no-git-tag-version/g, "yarn workspaces foreach --all version $1 --deferred");
|
|
1189
|
+
result = result.replaceAll(/\bpnpm xy\b/g, "yarn xy");
|
|
1190
|
+
result = result.replaceAll(/\bpnpm add\b/g, "yarn add");
|
|
1191
|
+
result = result.replaceAll(/\bpnpm remove\b/g, "yarn remove");
|
|
1192
|
+
result = result.replaceAll(/\bpnpm install\b/g, "yarn install");
|
|
1193
|
+
result = result.replaceAll(/\bpnpm dedupe\b/g, "yarn dedupe");
|
|
1194
|
+
result = result.replaceAll(/\bpnpm outdated\b/g, "yarn outdated");
|
|
1195
|
+
result = result.replaceAll(/\bpnpm run\b/g, "yarn run");
|
|
1196
|
+
result = result.replaceAll(/\bpnpm\b(?![@/.])/g, "yarn");
|
|
1197
|
+
return result;
|
|
1198
|
+
}
|
|
1199
|
+
function rewriteScript(script, direction) {
|
|
1200
|
+
return direction === "yarn-to-pnpm" ? rewriteYarnToPnpm(script) : rewritePnpmToYarn(script);
|
|
1201
|
+
}
|
|
1202
|
+
function rewriteScriptsInPackageJson(pkg, direction) {
|
|
1203
|
+
const scripts = pkg.scripts;
|
|
1204
|
+
if (!scripts) return pkg;
|
|
1205
|
+
const rewritten = {};
|
|
1206
|
+
for (const [name, script] of Object.entries(scripts)) {
|
|
1207
|
+
rewritten[name] = rewriteScript(script, direction);
|
|
1208
|
+
}
|
|
1209
|
+
return { ...pkg, scripts: rewritten };
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
// src/actions/packman/convertToPnpm.ts
|
|
1213
|
+
var PNPM_VERSION = "10.12.1";
|
|
1214
|
+
function createPnpmWorkspaceYaml(cwd, workspacePatterns) {
|
|
1215
|
+
const lines = ["packages:"];
|
|
1216
|
+
for (const pattern of workspacePatterns) {
|
|
1217
|
+
lines.push(` - '${pattern}'`);
|
|
1218
|
+
}
|
|
1219
|
+
writeFileSync6(PATH9.join(cwd, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
|
|
1220
|
+
console.log(chalk17.green(" Created pnpm-workspace.yaml"));
|
|
1221
|
+
}
|
|
1222
|
+
function updateRootPackageJson(cwd) {
|
|
1223
|
+
const pkgPath = PATH9.join(cwd, "package.json");
|
|
1224
|
+
const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
|
|
1225
|
+
const workspacePatterns = pkg.workspaces ?? [];
|
|
1226
|
+
delete pkg.workspaces;
|
|
1227
|
+
pkg.packageManager = `pnpm@${PNPM_VERSION}`;
|
|
1228
|
+
const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
|
|
1229
|
+
writeFileSync6(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
1230
|
+
console.log(chalk17.green(" Updated root package.json"));
|
|
1231
|
+
return workspacePatterns;
|
|
1232
|
+
}
|
|
1233
|
+
function updateGitignore(cwd) {
|
|
1234
|
+
const gitignorePath = PATH9.join(cwd, ".gitignore");
|
|
1235
|
+
if (!existsSync9(gitignorePath)) return;
|
|
1236
|
+
let content = readFileSync8(gitignorePath, "utf8");
|
|
1237
|
+
const yarnLines = [
|
|
1238
|
+
".pnp.*",
|
|
1239
|
+
".pnp",
|
|
1240
|
+
".yarn/*",
|
|
1241
|
+
"!.yarn/patches",
|
|
1242
|
+
"!.yarn/plugins",
|
|
1243
|
+
"!.yarn/releases",
|
|
1244
|
+
"!.yarn/sdks",
|
|
1245
|
+
"!.yarn/versions"
|
|
1246
|
+
];
|
|
1247
|
+
for (const line of yarnLines) {
|
|
1248
|
+
content = content.replaceAll(new RegExp(String.raw`^${line.replaceAll(".", String.raw`\.`).replaceAll("*", String.raw`\*`).replaceAll("!", String.raw`\!`)}\s*$`, "gm"), "");
|
|
1249
|
+
}
|
|
1250
|
+
content = content.replaceAll(/\n{3,}/g, "\n\n");
|
|
1251
|
+
writeFileSync6(gitignorePath, content, "utf8");
|
|
1252
|
+
console.log(chalk17.green(" Updated .gitignore"));
|
|
1253
|
+
}
|
|
1254
|
+
function deleteYarnArtifacts(cwd) {
|
|
1255
|
+
const yarnLock = PATH9.join(cwd, "yarn.lock");
|
|
1256
|
+
const yarnrc = PATH9.join(cwd, ".yarnrc.yml");
|
|
1257
|
+
const yarnDir = PATH9.join(cwd, ".yarn");
|
|
1258
|
+
if (existsSync9(yarnLock)) {
|
|
1259
|
+
rmSync3(yarnLock);
|
|
1260
|
+
console.log(chalk17.gray(" Deleted yarn.lock"));
|
|
1261
|
+
}
|
|
1262
|
+
if (existsSync9(yarnrc)) {
|
|
1263
|
+
rmSync3(yarnrc);
|
|
1264
|
+
console.log(chalk17.gray(" Deleted .yarnrc.yml"));
|
|
1265
|
+
}
|
|
1266
|
+
if (existsSync9(yarnDir)) {
|
|
1267
|
+
rmSync3(yarnDir, { force: true, recursive: true });
|
|
1268
|
+
console.log(chalk17.gray(" Deleted .yarn/"));
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
function createNpmrc(cwd) {
|
|
1272
|
+
const npmrcPath = PATH9.join(cwd, ".npmrc");
|
|
1273
|
+
if (existsSync9(npmrcPath)) return;
|
|
1274
|
+
mkdirSync5(PATH9.dirname(npmrcPath), { recursive: true });
|
|
1275
|
+
writeFileSync6(npmrcPath, "", "utf8");
|
|
1276
|
+
console.log(chalk17.green(" Created .npmrc"));
|
|
1277
|
+
}
|
|
1278
|
+
function convertToPnpm(cwd, workspacePackageJsonPaths) {
|
|
1279
|
+
console.log(chalk17.blue("\nConverting to pnpm...\n"));
|
|
1280
|
+
const workspacePatterns = updateRootPackageJson(cwd);
|
|
1281
|
+
createPnpmWorkspaceYaml(cwd, workspacePatterns);
|
|
1282
|
+
for (const pkgPath of workspacePackageJsonPaths) {
|
|
1283
|
+
const fullPath = PATH9.resolve(cwd, pkgPath, "package.json");
|
|
1284
|
+
if (!existsSync9(fullPath)) continue;
|
|
1285
|
+
const pkg = JSON.parse(readFileSync8(fullPath, "utf8"));
|
|
1286
|
+
const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
|
|
1287
|
+
if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
|
|
1288
|
+
writeFileSync6(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
console.log(chalk17.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
|
|
1292
|
+
updateGitignore(cwd);
|
|
1293
|
+
createNpmrc(cwd);
|
|
1294
|
+
deleteYarnArtifacts(cwd);
|
|
1295
|
+
console.log(chalk17.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
|
|
1296
|
+
return 0;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// src/actions/packman/convertToYarn.ts
|
|
1300
|
+
import {
|
|
1301
|
+
existsSync as existsSync10,
|
|
1302
|
+
readFileSync as readFileSync9,
|
|
1303
|
+
rmSync as rmSync4,
|
|
1304
|
+
writeFileSync as writeFileSync7
|
|
1305
|
+
} from "fs";
|
|
1306
|
+
import PATH10 from "path";
|
|
1307
|
+
import chalk18 from "chalk";
|
|
1308
|
+
var YARN_VERSION = "4.13.0";
|
|
1309
|
+
var YARNRC_TEMPLATE = `compressionLevel: mixed
|
|
1310
|
+
|
|
1311
|
+
enableGlobalCache: true
|
|
1312
|
+
|
|
1313
|
+
enableInlineBuilds: true
|
|
1314
|
+
|
|
1315
|
+
nmHoistingLimits: none
|
|
1316
|
+
|
|
1317
|
+
nodeLinker: node-modules
|
|
1318
|
+
`;
|
|
1319
|
+
var YARN_GITIGNORE_ENTRIES = `
|
|
1320
|
+
.pnp.*
|
|
1321
|
+
.yarn/*
|
|
1322
|
+
!.yarn/patches
|
|
1323
|
+
!.yarn/plugins
|
|
1324
|
+
!.yarn/releases
|
|
1325
|
+
!.yarn/sdks
|
|
1326
|
+
!.yarn/versions
|
|
1327
|
+
`;
|
|
1328
|
+
function readPnpmWorkspacePatterns(cwd) {
|
|
1329
|
+
const wsPath = PATH10.join(cwd, "pnpm-workspace.yaml");
|
|
1330
|
+
if (!existsSync10(wsPath)) return [];
|
|
1331
|
+
const content = readFileSync9(wsPath, "utf8");
|
|
1332
|
+
const patterns = [];
|
|
1333
|
+
const lines = content.split("\n");
|
|
1334
|
+
let inPackages = false;
|
|
1335
|
+
for (const line of lines) {
|
|
1336
|
+
if (line.trim() === "packages:") {
|
|
1337
|
+
inPackages = true;
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1340
|
+
if (inPackages && /^\s+-\s+/.test(line)) {
|
|
1341
|
+
const pattern = line.replace(/^\s+-\s+/, "").replaceAll(/['"]/g, "").trim();
|
|
1342
|
+
if (pattern) patterns.push(pattern);
|
|
1343
|
+
} else if (inPackages && !/^\s/.test(line) && line.trim()) {
|
|
1344
|
+
inPackages = false;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
return patterns;
|
|
1348
|
+
}
|
|
1349
|
+
function updateRootPackageJson2(cwd, workspacePatterns) {
|
|
1350
|
+
const pkgPath = PATH10.join(cwd, "package.json");
|
|
1351
|
+
const pkg = JSON.parse(readFileSync9(pkgPath, "utf8"));
|
|
1352
|
+
pkg.workspaces = workspacePatterns;
|
|
1353
|
+
pkg.packageManager = `yarn@${YARN_VERSION}`;
|
|
1354
|
+
const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
|
|
1355
|
+
writeFileSync7(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
1356
|
+
console.log(chalk18.green(" Updated root package.json"));
|
|
1357
|
+
}
|
|
1358
|
+
function updateGitignore2(cwd) {
|
|
1359
|
+
const gitignorePath = PATH10.join(cwd, ".gitignore");
|
|
1360
|
+
let content = existsSync10(gitignorePath) ? readFileSync9(gitignorePath, "utf8") : "";
|
|
1361
|
+
if (!content.includes(".yarn/*")) {
|
|
1362
|
+
content = content.trimEnd() + "\n" + YARN_GITIGNORE_ENTRIES;
|
|
1363
|
+
}
|
|
1364
|
+
writeFileSync7(gitignorePath, content, "utf8");
|
|
1365
|
+
console.log(chalk18.green(" Updated .gitignore"));
|
|
1366
|
+
}
|
|
1367
|
+
function deletePnpmArtifacts(cwd) {
|
|
1368
|
+
const lockfile = PATH10.join(cwd, "pnpm-lock.yaml");
|
|
1369
|
+
const workspaceYaml = PATH10.join(cwd, "pnpm-workspace.yaml");
|
|
1370
|
+
const npmrc = PATH10.join(cwd, ".npmrc");
|
|
1371
|
+
if (existsSync10(lockfile)) {
|
|
1372
|
+
rmSync4(lockfile);
|
|
1373
|
+
console.log(chalk18.gray(" Deleted pnpm-lock.yaml"));
|
|
1374
|
+
}
|
|
1375
|
+
if (existsSync10(workspaceYaml)) {
|
|
1376
|
+
rmSync4(workspaceYaml);
|
|
1377
|
+
console.log(chalk18.gray(" Deleted pnpm-workspace.yaml"));
|
|
1378
|
+
}
|
|
1379
|
+
if (existsSync10(npmrc)) {
|
|
1380
|
+
const content = readFileSync9(npmrc, "utf8");
|
|
1381
|
+
if (content.trim() === "" || content.includes("shamefully-hoist") || content.includes("node-linker")) {
|
|
1382
|
+
rmSync4(npmrc);
|
|
1383
|
+
console.log(chalk18.gray(" Deleted .npmrc"));
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
function createYarnrc(cwd) {
|
|
1388
|
+
const yarnrcPath = PATH10.join(cwd, ".yarnrc.yml");
|
|
1389
|
+
if (existsSync10(yarnrcPath)) return;
|
|
1390
|
+
writeFileSync7(yarnrcPath, YARNRC_TEMPLATE, "utf8");
|
|
1391
|
+
console.log(chalk18.green(" Created .yarnrc.yml"));
|
|
1392
|
+
}
|
|
1393
|
+
function convertToYarn(cwd, workspacePackageJsonPaths) {
|
|
1394
|
+
console.log(chalk18.blue("\nConverting to yarn...\n"));
|
|
1395
|
+
const workspacePatterns = readPnpmWorkspacePatterns(cwd);
|
|
1396
|
+
if (workspacePatterns.length === 0) {
|
|
1397
|
+
console.warn(chalk18.yellow(" No workspace patterns found in pnpm-workspace.yaml"));
|
|
1398
|
+
}
|
|
1399
|
+
updateRootPackageJson2(cwd, workspacePatterns);
|
|
1400
|
+
for (const pkgPath of workspacePackageJsonPaths) {
|
|
1401
|
+
const fullPath = PATH10.resolve(cwd, pkgPath, "package.json");
|
|
1402
|
+
if (!existsSync10(fullPath)) continue;
|
|
1403
|
+
const pkg = JSON.parse(readFileSync9(fullPath, "utf8"));
|
|
1404
|
+
const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
|
|
1405
|
+
if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
|
|
1406
|
+
writeFileSync7(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
console.log(chalk18.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
|
|
1410
|
+
updateGitignore2(cwd);
|
|
1411
|
+
createYarnrc(cwd);
|
|
1412
|
+
deletePnpmArtifacts(cwd);
|
|
1413
|
+
console.log(chalk18.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
|
|
1414
|
+
return 0;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
// src/actions/packman/convert.ts
|
|
1418
|
+
function detectCurrentPM(cwd) {
|
|
1419
|
+
if (existsSync11(PATH11.join(cwd, "pnpm-lock.yaml")) || existsSync11(PATH11.join(cwd, "pnpm-workspace.yaml"))) {
|
|
1420
|
+
return "pnpm";
|
|
1421
|
+
}
|
|
1422
|
+
if (existsSync11(PATH11.join(cwd, "yarn.lock")) || existsSync11(PATH11.join(cwd, ".yarnrc.yml"))) {
|
|
1423
|
+
return "yarn";
|
|
1424
|
+
}
|
|
1425
|
+
return "unknown";
|
|
1426
|
+
}
|
|
1427
|
+
function findWorkspacePackagePaths(cwd) {
|
|
1428
|
+
const pkgPath = PATH11.join(cwd, "package.json");
|
|
1429
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
|
|
1430
|
+
let patterns = pkg.workspaces ?? [];
|
|
1431
|
+
if (patterns.length === 0) {
|
|
1432
|
+
const wsPath = PATH11.join(cwd, "pnpm-workspace.yaml");
|
|
1433
|
+
if (existsSync11(wsPath)) {
|
|
1434
|
+
const content = readFileSync10(wsPath, "utf8");
|
|
1435
|
+
const lines = content.split("\n");
|
|
1436
|
+
let inPackages = false;
|
|
1437
|
+
for (const line of lines) {
|
|
1438
|
+
if (line.trim() === "packages:") {
|
|
1439
|
+
inPackages = true;
|
|
1440
|
+
continue;
|
|
1441
|
+
}
|
|
1442
|
+
if (inPackages && /^\s+-\s+/.test(line)) {
|
|
1443
|
+
const pattern = line.replace(/^\s+-\s+/, "").replaceAll(/['"]/g, "").trim();
|
|
1444
|
+
if (pattern) patterns.push(pattern);
|
|
1445
|
+
} else if (inPackages && !/^\s/.test(line) && line.trim()) {
|
|
1446
|
+
inPackages = false;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
const dirs = [];
|
|
1452
|
+
for (const pattern of patterns) {
|
|
1453
|
+
const resolved = resolveWorkspaceGlob(cwd, pattern);
|
|
1454
|
+
dirs.push(...resolved);
|
|
1455
|
+
}
|
|
1456
|
+
return dirs;
|
|
1457
|
+
}
|
|
1458
|
+
function resolveWorkspaceGlob(cwd, pattern) {
|
|
1459
|
+
const parts = pattern.split("/");
|
|
1460
|
+
return walkGlob(cwd, parts, "");
|
|
1461
|
+
}
|
|
1462
|
+
function walkGlob(basePath, parts, currentPath) {
|
|
1463
|
+
if (parts.length === 0) {
|
|
1464
|
+
const fullPath = PATH11.join(basePath, currentPath);
|
|
1465
|
+
if (existsSync11(PATH11.join(fullPath, "package.json"))) {
|
|
1466
|
+
return [currentPath];
|
|
1467
|
+
}
|
|
1468
|
+
return [];
|
|
1469
|
+
}
|
|
1470
|
+
const [part, ...rest] = parts;
|
|
1471
|
+
const dirPath = PATH11.join(basePath, currentPath);
|
|
1472
|
+
if (!existsSync11(dirPath) || !statSync3(dirPath).isDirectory()) {
|
|
1473
|
+
return [];
|
|
1474
|
+
}
|
|
1475
|
+
if (part === "*" || part === "**") {
|
|
1476
|
+
const entries = readdirSync6(dirPath, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".") && e.name !== "node_modules" && e.name !== "dist");
|
|
1477
|
+
const results = [];
|
|
1478
|
+
if (part === "**") {
|
|
1479
|
+
results.push(...walkGlob(basePath, rest, currentPath));
|
|
1480
|
+
}
|
|
1481
|
+
for (const entry of entries) {
|
|
1482
|
+
const subPath2 = currentPath ? `${currentPath}/${entry.name}` : entry.name;
|
|
1483
|
+
if (part === "**") {
|
|
1484
|
+
results.push(
|
|
1485
|
+
...walkGlob(basePath, rest, subPath2),
|
|
1486
|
+
...walkGlob(basePath, parts, subPath2)
|
|
1487
|
+
);
|
|
1488
|
+
} else {
|
|
1489
|
+
results.push(...walkGlob(basePath, rest, subPath2));
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
return results;
|
|
1493
|
+
}
|
|
1494
|
+
const subPath = currentPath ? `${currentPath}/${part}` : part;
|
|
1495
|
+
return walkGlob(basePath, rest, subPath);
|
|
1496
|
+
}
|
|
1497
|
+
function convert({ target, verbose }) {
|
|
1498
|
+
const validTargets = ["pnpm", "yarn"];
|
|
1499
|
+
if (!validTargets.includes(target)) {
|
|
1500
|
+
console.error(chalk19.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
|
|
1501
|
+
return 1;
|
|
1502
|
+
}
|
|
1503
|
+
const cwd = process.cwd();
|
|
1504
|
+
const currentPM = detectCurrentPM(cwd);
|
|
1505
|
+
if (verbose) {
|
|
1506
|
+
console.log(chalk19.gray(`Current package manager: ${currentPM}`));
|
|
1507
|
+
console.log(chalk19.gray(`Target package manager: ${target}`));
|
|
1508
|
+
}
|
|
1509
|
+
if (currentPM === target) {
|
|
1510
|
+
console.error(chalk19.red(`Already using ${target}. No conversion needed.`));
|
|
1511
|
+
return 1;
|
|
1512
|
+
}
|
|
1513
|
+
if (currentPM === "unknown") {
|
|
1514
|
+
console.error(chalk19.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
|
|
1515
|
+
return 1;
|
|
1516
|
+
}
|
|
1517
|
+
const workspacePaths = findWorkspacePackagePaths(cwd);
|
|
1518
|
+
if (verbose) {
|
|
1519
|
+
console.log(chalk19.gray(`Found ${workspacePaths.length} workspace packages`));
|
|
1520
|
+
}
|
|
1521
|
+
if (target === "pnpm") {
|
|
1522
|
+
return convertToPnpm(cwd, workspacePaths);
|
|
1523
|
+
}
|
|
1524
|
+
return convertToYarn(cwd, workspacePaths);
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// src/actions/readme-gen.ts
|
|
1528
|
+
async function readmeGen({
|
|
1529
|
+
pkg,
|
|
1530
|
+
templatePath,
|
|
1531
|
+
typedoc,
|
|
1532
|
+
verbose
|
|
1533
|
+
}) {
|
|
1534
|
+
const config2 = await loadConfig();
|
|
1535
|
+
return await generateReadmeFiles({
|
|
1536
|
+
logoLinkUrl: config2.readme?.logoLinkUrl,
|
|
1537
|
+
logoUrl: config2.readme?.logoUrl,
|
|
1538
|
+
pkg,
|
|
1539
|
+
templatePath,
|
|
1540
|
+
typedoc,
|
|
1541
|
+
verbose
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
// src/actions/readme-init.ts
|
|
1546
|
+
async function readmeInit({ templatePath }) {
|
|
1547
|
+
const config2 = await loadConfig();
|
|
1548
|
+
const template = applyLogoConfig(DEFAULT_README_TEMPLATE, config2.readme?.logoUrl, config2.readme?.logoLinkUrl);
|
|
1549
|
+
const resolvedTemplatePath = resolveTemplatePath(templatePath);
|
|
1550
|
+
await scaffoldTemplate(resolvedTemplatePath, template);
|
|
1551
|
+
return 0;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
// src/actions/retest.ts
|
|
1555
|
+
var retest = ({ target } = {}) => {
|
|
1556
|
+
const pm = getPackageManager();
|
|
1557
|
+
if (target && pm.findWorkspace(target)) {
|
|
1558
|
+
return runSteps(`Re-Test [${target}]`, [
|
|
1559
|
+
pm.runInWorkspace(target, "vitest", ["--clearCache"]),
|
|
1560
|
+
pm.runInWorkspace(target, "vitest", ["."])
|
|
1561
|
+
]);
|
|
1562
|
+
}
|
|
1563
|
+
const path2 = target ?? ".";
|
|
1564
|
+
return runSteps("Re-Test", [
|
|
1565
|
+
["vitest", ["--clearCache"]],
|
|
1566
|
+
["vitest", [path2]]
|
|
1567
|
+
]);
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
// src/actions/test.ts
|
|
1571
|
+
var test = ({ target } = {}) => {
|
|
1572
|
+
const pm = getPackageManager();
|
|
1573
|
+
if (target && pm.findWorkspace(target)) {
|
|
1574
|
+
return runSteps(`Test [${target}]`, [pm.runInWorkspace(target, "vitest", ["."])]);
|
|
1575
|
+
}
|
|
1576
|
+
const path2 = target ?? ".";
|
|
1577
|
+
return runSteps("Test", [["vitest", [path2]]]);
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
// src/xy/common/claude/cleanCommand.ts
|
|
1581
|
+
var cleanCommand = {
|
|
1582
|
+
command: "clean",
|
|
1583
|
+
describe: "Remove all Claude configuration files from the repo",
|
|
1584
|
+
handler: (argv) => {
|
|
1585
|
+
if (argv.verbose) console.log("Claude Clean");
|
|
1586
|
+
process.exitCode = claudeClean();
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
// src/xy/common/claude/commandsCommand.ts
|
|
1591
|
+
var commandsCommand = {
|
|
1592
|
+
command: "commands",
|
|
1593
|
+
describe: "Sync XY Labs standard Claude slash commands to .claude/commands/",
|
|
1594
|
+
handler: (argv) => {
|
|
1595
|
+
if (argv.verbose) console.log("Claude Commands");
|
|
1596
|
+
process.exitCode = claudeCommands();
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1599
|
+
|
|
1600
|
+
// src/xy/common/claude/initCommand.ts
|
|
1601
|
+
var initCommand = {
|
|
1602
|
+
builder: (yargs) => {
|
|
1603
|
+
return yargs.option("force", {
|
|
1604
|
+
alias: "f",
|
|
1605
|
+
default: false,
|
|
1606
|
+
description: "Overwrite existing CLAUDE.md",
|
|
1607
|
+
type: "boolean"
|
|
1608
|
+
});
|
|
1609
|
+
},
|
|
1610
|
+
command: "init",
|
|
1611
|
+
describe: "Initialize all Claude configuration (commands, rules, settings)",
|
|
1612
|
+
handler: async (argv) => {
|
|
1613
|
+
if (argv.verbose) console.log("Claude Init");
|
|
1614
|
+
const commandsResult = claudeCommands();
|
|
1615
|
+
const rulesResult = claudeRules({ force: argv.force });
|
|
1616
|
+
const settingsResult = await claudeSettings();
|
|
1617
|
+
process.exitCode = commandsResult || rulesResult || settingsResult;
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
// src/xy/common/claude/rulesCommand.ts
|
|
1622
|
+
var rulesCommand = {
|
|
1623
|
+
builder: (yargs) => {
|
|
1624
|
+
return yargs.option("force", {
|
|
1625
|
+
alias: "f",
|
|
1626
|
+
default: false,
|
|
1627
|
+
description: "Overwrite existing CLAUDE.md",
|
|
1628
|
+
type: "boolean"
|
|
1629
|
+
});
|
|
1630
|
+
},
|
|
1631
|
+
command: "rules",
|
|
1632
|
+
describe: "Sync XY Labs standard Claude rules to .claude/rules/",
|
|
1633
|
+
handler: (argv) => {
|
|
1634
|
+
if (argv.verbose) console.log("Claude Rules");
|
|
1635
|
+
process.exitCode = claudeRules({ force: argv.force });
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
|
|
1639
|
+
// src/xy/common/claude/settingsCommand.ts
|
|
1640
|
+
var settingsCommand = {
|
|
1641
|
+
command: "settings",
|
|
1642
|
+
describe: "Initialize .claude/settings.local.json with XY Labs defaults",
|
|
1643
|
+
handler: async (argv) => {
|
|
1644
|
+
if (argv.verbose) console.log("Claude Settings");
|
|
1645
|
+
process.exitCode = await claudeSettings();
|
|
1646
|
+
}
|
|
1647
|
+
};
|
|
1648
|
+
|
|
1649
|
+
// src/xy/common/claude/skillsCommand.ts
|
|
1650
|
+
var skillsCommand = {
|
|
1651
|
+
builder: (yargs) => yargs,
|
|
1652
|
+
command: "skills",
|
|
1653
|
+
describe: "Sync XY Labs standard Claude skills to .claude/skills/",
|
|
1654
|
+
handler: (argv) => {
|
|
1655
|
+
if (argv.verbose) console.log("Claude Skills");
|
|
1656
|
+
process.exitCode = claudeSkills();
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
|
|
1660
|
+
// src/xy/common/claude/index.ts
|
|
1661
|
+
var claudeCommand = {
|
|
1662
|
+
builder: (yargs) => {
|
|
1663
|
+
return yargs.command(cleanCommand).command(commandsCommand).command(initCommand).command(rulesCommand).command(settingsCommand).command(skillsCommand).demandCommand(1, "Please specify a claude subcommand");
|
|
1664
|
+
},
|
|
1665
|
+
command: "claude",
|
|
1666
|
+
describe: "Claude - Claude Code configuration utilities",
|
|
1667
|
+
handler: () => {
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1671
|
+
// src/xy/common/cleanDocsCommand.ts
|
|
1672
|
+
var cleanDocsCommand = {
|
|
1673
|
+
command: "clean-docs",
|
|
1674
|
+
describe: "CleanDocs - Clean TypeDocs",
|
|
1675
|
+
handler: (argv) => {
|
|
1676
|
+
if (argv.verbose) console.log("Cleaning TypeDocs: all");
|
|
1677
|
+
process.exitCode = cleanDocs();
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
// src/xy/param.ts
|
|
1682
|
+
var packagePositionalParam = (yargs) => {
|
|
1683
|
+
return yargs.positional("package", { describe: "Specific package to target", type: "string" });
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
// src/xy/common/deadCommand.ts
|
|
1687
|
+
var deadCommand = {
|
|
1688
|
+
builder: (yargs) => {
|
|
1689
|
+
return packagePositionalParam(yargs);
|
|
1690
|
+
},
|
|
1691
|
+
command: "dead [package]",
|
|
1692
|
+
describe: "Dead - Check for dead code",
|
|
1693
|
+
handler: (argv) => {
|
|
1694
|
+
if (argv.verbose) console.log("Dead");
|
|
1695
|
+
process.exitCode = dead();
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1698
|
+
|
|
1699
|
+
// src/xy/common/genDocsCommand.ts
|
|
1700
|
+
var genDocsCommand = {
|
|
1701
|
+
builder: (yargs) => {
|
|
1702
|
+
return packagePositionalParam(yargs);
|
|
1703
|
+
},
|
|
1704
|
+
command: "gen-docs [package]",
|
|
1705
|
+
describe: "GenDocs - Generate TypeDocs",
|
|
1706
|
+
handler: (argv) => {
|
|
1707
|
+
if (argv.verbose) console.log(`Generating TypeDocs: ${argv.package ?? "all"}`);
|
|
1708
|
+
process.exitCode = genDocs({ incremental: !!argv.incremental, pkg: argv.package });
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
|
|
1712
|
+
// src/xy/common/gitignoreCommand.ts
|
|
1713
|
+
var gitignoreCommand = {
|
|
1714
|
+
command: "gitignore",
|
|
1715
|
+
describe: "GitIgnore - Generate root .gitignore and remove package .gitignore files",
|
|
1716
|
+
handler: (argv) => {
|
|
1717
|
+
if (argv.verbose) console.log("GitIgnore");
|
|
1718
|
+
process.exitCode = gitignore();
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
// src/xy/common/gitlintCommand.ts
|
|
1723
|
+
var gitlintCommand = {
|
|
1724
|
+
command: "gitlint [package]",
|
|
1725
|
+
describe: "Gitlint - Lint your git config",
|
|
1726
|
+
handler: (argv) => {
|
|
1727
|
+
if (argv.verbose) console.log("Gitlint");
|
|
1728
|
+
process.exitCode = argv.fix ? gitlintFix() : gitlint();
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
|
|
1732
|
+
// src/xy/common/licenseCommand.ts
|
|
1733
|
+
var licenseCommand = {
|
|
1734
|
+
builder: (yargs) => {
|
|
1735
|
+
return packagePositionalParam(yargs);
|
|
1736
|
+
},
|
|
1737
|
+
command: "license [package]",
|
|
1738
|
+
describe: "License - Check licenses of dependencies",
|
|
1739
|
+
handler: async (argv) => {
|
|
1740
|
+
if (argv.verbose) console.log(`License: ${argv.package ?? "all"}`);
|
|
1741
|
+
process.exitCode = await license();
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1745
|
+
// src/xy/common/npmignoreGenCommand.ts
|
|
1746
|
+
var npmignoreGenCommand = {
|
|
1747
|
+
command: "npmignore-gen",
|
|
1748
|
+
describe: "NpmIgnore Gen - Generate .npmignore files",
|
|
1749
|
+
handler: (argv) => {
|
|
1750
|
+
if (argv.verbose) console.log("NpmIgnore Gen");
|
|
1751
|
+
process.exitCode = npmignoreGen();
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
|
|
1755
|
+
// src/xy/common/packmanCommand.ts
|
|
1756
|
+
var convertCommand = {
|
|
1757
|
+
command: "convert <target>",
|
|
1758
|
+
describe: "Convert repo to a different package manager (pnpm or yarn)",
|
|
1759
|
+
builder: (yargs) => {
|
|
1760
|
+
return yargs.positional("target", {
|
|
1761
|
+
choices: ["pnpm", "yarn"],
|
|
1762
|
+
describe: "Target package manager",
|
|
1763
|
+
type: "string"
|
|
1764
|
+
});
|
|
1765
|
+
},
|
|
1766
|
+
handler: (argv) => {
|
|
1767
|
+
process.exitCode = convert({
|
|
1768
|
+
target: argv.target,
|
|
1769
|
+
verbose: !!argv.verbose
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
var packmanCommand = {
|
|
1774
|
+
builder: (yargs) => {
|
|
1775
|
+
return yargs.command(convertCommand).demandCommand(1, "Please specify a packman subcommand");
|
|
1776
|
+
},
|
|
1777
|
+
command: "packman",
|
|
1778
|
+
describe: "Package Manager - Conversion utilities",
|
|
1779
|
+
handler: () => {
|
|
1780
|
+
}
|
|
1781
|
+
};
|
|
1782
|
+
|
|
1783
|
+
// src/xy/common/readme/genCommand.ts
|
|
1784
|
+
var genCommand = {
|
|
1785
|
+
builder: (yargs) => {
|
|
1786
|
+
return packagePositionalParam(yargs).option("template", {
|
|
1787
|
+
alias: "t",
|
|
1788
|
+
description: "Path to README.template.md",
|
|
1789
|
+
type: "string"
|
|
1790
|
+
}).option("typedoc", {
|
|
1791
|
+
default: false,
|
|
1792
|
+
description: "Generate TypeDoc reference sections",
|
|
1793
|
+
type: "boolean"
|
|
1794
|
+
});
|
|
1795
|
+
},
|
|
1796
|
+
aliases: ["$0"],
|
|
1797
|
+
command: "gen [package]",
|
|
1798
|
+
describe: "Generate README.md files from template",
|
|
1799
|
+
handler: async (argv) => {
|
|
1800
|
+
if (argv.verbose) console.log("Readme Gen");
|
|
1801
|
+
process.exitCode = await readmeGen({
|
|
1802
|
+
pkg: argv.package,
|
|
1803
|
+
templatePath: argv.template,
|
|
1804
|
+
typedoc: argv.typedoc,
|
|
1805
|
+
verbose: !!argv.verbose
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
|
|
1810
|
+
// src/xy/common/readme/initCommand.ts
|
|
1811
|
+
var initCommand2 = {
|
|
1812
|
+
builder: (yargs) => {
|
|
1813
|
+
return yargs.option("template", {
|
|
1814
|
+
alias: "t",
|
|
1815
|
+
description: "Path to README.template.md",
|
|
1816
|
+
type: "string"
|
|
1817
|
+
});
|
|
1818
|
+
},
|
|
1819
|
+
command: "init",
|
|
1820
|
+
describe: "Initialize README template and logo files",
|
|
1821
|
+
handler: async (argv) => {
|
|
1822
|
+
if (argv.verbose) console.log("Readme Init");
|
|
1823
|
+
process.exitCode = await readmeInit({
|
|
1824
|
+
templatePath: argv.template,
|
|
1825
|
+
verbose: !!argv.verbose
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
|
|
1830
|
+
// src/xy/common/readme/index.ts
|
|
1831
|
+
var readmeCommand = {
|
|
1832
|
+
builder: (yargs) => {
|
|
1833
|
+
return yargs.command(genCommand).command(initCommand2);
|
|
1834
|
+
},
|
|
1835
|
+
command: "readme",
|
|
1836
|
+
describe: "Readme - README file utilities",
|
|
1837
|
+
handler: () => {
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
// src/xy/common/retestCommand.ts
|
|
1842
|
+
var retestCommand = {
|
|
1843
|
+
command: "retest [target]",
|
|
1844
|
+
describe: "Re-Test - Run Vitest Tests with cleaned cache",
|
|
1845
|
+
builder: (yargs) => {
|
|
1846
|
+
return yargs.positional("target", { describe: "Package name or file/folder path to test" });
|
|
1847
|
+
},
|
|
1848
|
+
handler: (argv) => {
|
|
1849
|
+
if (argv.verbose) console.log(`Re-Testing: ${argv.target ?? "all"}`);
|
|
1850
|
+
process.exitCode = retest({ target: argv.target });
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
|
|
1854
|
+
// src/xy/common/testCommand.ts
|
|
1855
|
+
var testCommand = {
|
|
1856
|
+
command: "test [target]",
|
|
1857
|
+
describe: "Test - Run Vitest Tests",
|
|
1858
|
+
builder: (yargs) => {
|
|
1859
|
+
return yargs.positional("target", { describe: "Package name or file/folder path to test" });
|
|
1860
|
+
},
|
|
1861
|
+
handler: (argv) => {
|
|
1862
|
+
if (argv.verbose) console.log(`Testing: ${argv.target ?? "all"}`);
|
|
1863
|
+
process.exitCode = test({ target: argv.target });
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1866
|
+
|
|
1867
|
+
// src/xy/common/index.ts
|
|
1868
|
+
var xyCommonCommands = (args) => {
|
|
1869
|
+
return args.command(claudeCommand).command(licenseCommand).command(deadCommand).command(genDocsCommand).command(cleanDocsCommand).command(gitlintCommand).command(gitignoreCommand).command(npmignoreGenCommand).command(packmanCommand).command(readmeCommand).command(retestCommand).command(testCommand);
|
|
1870
|
+
};
|
|
1871
|
+
export {
|
|
1872
|
+
xyCommonCommands
|
|
1873
|
+
};
|
|
1874
|
+
//# sourceMappingURL=index.mjs.map
|