@xylabs/toolchain 7.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/analyze.mjs +140 -0
- package/dist/actions/analyze.mjs.map +1 -0
- package/dist/actions/build.mjs +173 -0
- package/dist/actions/build.mjs.map +1 -0
- package/dist/actions/claude-check.mjs +199 -0
- package/dist/actions/claude-check.mjs.map +1 -0
- package/dist/actions/claude-clean.mjs +70 -0
- package/dist/actions/claude-clean.mjs.map +1 -0
- package/dist/actions/claude-commands.mjs +126 -0
- package/dist/actions/claude-commands.mjs.map +1 -0
- package/dist/actions/claude-rules.mjs +151 -0
- package/dist/actions/claude-rules.mjs.map +1 -0
- package/dist/actions/claude-settings.mjs +99 -0
- package/dist/actions/claude-settings.mjs.map +1 -0
- package/dist/actions/claude-skills.mjs +131 -0
- package/dist/actions/claude-skills.mjs.map +1 -0
- package/dist/actions/clean-docs.mjs +66 -0
- package/dist/actions/clean-docs.mjs.map +1 -0
- package/dist/actions/clean-eslint.mjs +47 -0
- package/dist/actions/clean-eslint.mjs.map +1 -0
- package/dist/actions/clean.mjs +166 -0
- package/dist/actions/clean.mjs.map +1 -0
- package/dist/actions/compile.mjs +184 -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 +275 -0
- package/dist/actions/cycle.mjs.map +1 -0
- package/dist/actions/dead.mjs +119 -0
- package/dist/actions/dead.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/checkPackage.mjs +1556 -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/getMismatchedPeerDevVersions.mjs +77 -0
- package/dist/actions/deplint/checkPackage/getMismatchedPeerDevVersions.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +158 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +125 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnnecessaryPeerDependencies.mjs +207 -0
- package/dist/actions/deplint/checkPackage/getUnnecessaryPeerDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.mjs +318 -0
- package/dist/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +163 -0
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +408 -0
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +75 -0
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getWorkspaceVersionProblems.mjs +128 -0
- package/dist/actions/deplint/checkPackage/getWorkspaceVersionProblems.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/index.mjs +1609 -0
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -0
- package/dist/actions/deplint/deplint.mjs +1840 -0
- package/dist/actions/deplint/deplint.mjs.map +1 -0
- package/dist/actions/deplint/engine.mjs +1736 -0
- package/dist/actions/deplint/engine.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/fixer.mjs +103 -0
- package/dist/actions/deplint/fixer.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 +29 -0
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +1 -0
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +68 -0
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +1 -0
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +143 -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 +37 -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 +116 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/index.mjs +1848 -0
- package/dist/actions/deplint/index.mjs.map +1 -0
- package/dist/actions/deplint/packageEditor.mjs +82 -0
- package/dist/actions/deplint/packageEditor.mjs.map +1 -0
- package/dist/actions/deplint/packageJsonEditor.mjs +101 -0
- package/dist/actions/deplint/packageJsonEditor.mjs.map +1 -0
- package/dist/actions/deplint/reporters.mjs +36 -0
- package/dist/actions/deplint/reporters.mjs.map +1 -0
- package/dist/actions/deplint/rules.mjs +1223 -0
- package/dist/actions/deplint/rules.mjs.map +1 -0
- package/dist/actions/deplint/snapshot.mjs +372 -0
- package/dist/actions/deplint/snapshot.mjs.map +1 -0
- package/dist/actions/deplint/tsScriptsAliases.mjs +20 -0
- package/dist/actions/deplint/tsScriptsAliases.mjs.map +1 -0
- package/dist/actions/deplint/types.mjs +1 -0
- package/dist/actions/deplint/types.mjs.map +1 -0
- package/dist/actions/deploy.mjs +194 -0
- package/dist/actions/deploy.mjs.map +1 -0
- package/dist/actions/dupdeps.mjs +226 -0
- package/dist/actions/dupdeps.mjs.map +1 -0
- package/dist/actions/eject.mjs +142 -0
- package/dist/actions/eject.mjs.map +1 -0
- package/dist/actions/fix.mjs +359 -0
- package/dist/actions/fix.mjs.map +1 -0
- package/dist/actions/gen-docs.mjs +155 -0
- package/dist/actions/gen-docs.mjs.map +1 -0
- package/dist/actions/gitignore.mjs +159 -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 +8259 -0
- package/dist/actions/index.mjs.map +1 -0
- package/dist/actions/knip.mjs +119 -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-init.mjs +275 -0
- package/dist/actions/lint-init.mjs.map +1 -0
- package/dist/actions/lint.mjs +356 -0
- package/dist/actions/lint.mjs.map +1 -0
- package/dist/actions/lintNext.mjs +209 -0
- package/dist/actions/lintNext.mjs.map +1 -0
- package/dist/actions/lintlint.mjs +341 -0
- package/dist/actions/lintlint.mjs.map +1 -0
- package/dist/actions/npmignore-gen.mjs +90 -0
- package/dist/actions/npmignore-gen.mjs.map +1 -0
- package/dist/actions/orphan.mjs +110 -0
- package/dist/actions/orphan.mjs.map +1 -0
- package/dist/actions/package/clean-outputs.mjs +50 -0
- package/dist/actions/package/clean-outputs.mjs.map +1 -0
- package/dist/actions/package/clean-typescript.mjs +50 -0
- package/dist/actions/package/clean-typescript.mjs.map +1 -0
- package/dist/actions/package/clean.mjs +69 -0
- package/dist/actions/package/clean.mjs.map +1 -0
- package/dist/actions/package/compile/XyConfig.mjs +32 -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 +439 -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 +27 -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 +472 -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 +93 -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 +69 -0
- package/dist/actions/package/copy-assets.mjs.map +1 -0
- package/dist/actions/package/cycle.mjs +62 -0
- package/dist/actions/package/cycle.mjs.map +1 -0
- package/dist/actions/package/gen-docs.mjs +137 -0
- package/dist/actions/package/gen-docs.mjs.map +1 -0
- package/dist/actions/package/index.mjs +1131 -0
- package/dist/actions/package/index.mjs.map +1 -0
- package/dist/actions/package/lint.mjs +87 -0
- package/dist/actions/package/lint.mjs.map +1 -0
- package/dist/actions/package/publint.mjs +336 -0
- package/dist/actions/package/publint.mjs.map +1 -0
- package/dist/actions/package/recompile.mjs +510 -0
- package/dist/actions/package/recompile.mjs.map +1 -0
- package/dist/actions/package-lint-deps.mjs +348 -0
- package/dist/actions/package-lint-deps.mjs.map +1 -0
- package/dist/actions/package-lint.mjs +774 -0
- package/dist/actions/package-lint.mjs.map +1 -0
- package/dist/actions/packman/clean.mjs +144 -0
- package/dist/actions/packman/clean.mjs.map +1 -0
- package/dist/actions/packman/convert.mjs +1331 -0
- package/dist/actions/packman/convert.mjs.map +1 -0
- package/dist/actions/packman/convertToPnpm.mjs +295 -0
- package/dist/actions/packman/convertToPnpm.mjs.map +1 -0
- package/dist/actions/packman/convertToYarn.mjs +307 -0
- package/dist/actions/packman/convertToYarn.mjs.map +1 -0
- package/dist/actions/packman/index.mjs +1493 -0
- package/dist/actions/packman/index.mjs.map +1 -0
- package/dist/actions/packman/lint.mjs +109 -0
- package/dist/actions/packman/lint.mjs.map +1 -0
- package/dist/actions/packman/rewriteScripts.mjs +52 -0
- package/dist/actions/packman/rewriteScripts.mjs.map +1 -0
- package/dist/actions/packman/rewriteSourceImports.mjs +60 -0
- package/dist/actions/packman/rewriteSourceImports.mjs.map +1 -0
- package/dist/actions/packman/swapTsScriptsDependency.mjs +57 -0
- package/dist/actions/packman/swapTsScriptsDependency.mjs.map +1 -0
- package/dist/actions/publint.mjs +748 -0
- package/dist/actions/publint.mjs.map +1 -0
- package/dist/actions/publish.mjs +208 -0
- package/dist/actions/publish.mjs.map +1 -0
- package/dist/actions/reactTest.mjs +142 -0
- package/dist/actions/reactTest.mjs.map +1 -0
- package/dist/actions/readme-gen.mjs +362 -0
- package/dist/actions/readme-gen.mjs.map +1 -0
- package/dist/actions/readme-init.mjs +89 -0
- package/dist/actions/readme-init.mjs.map +1 -0
- package/dist/actions/readme-lint.mjs +147 -0
- package/dist/actions/readme-lint.mjs.map +1 -0
- package/dist/actions/rebuild.mjs +143 -0
- package/dist/actions/rebuild.mjs.map +1 -0
- package/dist/actions/recompile.mjs +196 -0
- package/dist/actions/recompile.mjs.map +1 -0
- package/dist/actions/reinstall.mjs +283 -0
- package/dist/actions/reinstall.mjs.map +1 -0
- package/dist/actions/relint.mjs +355 -0
- package/dist/actions/relint.mjs.map +1 -0
- package/dist/actions/repo-init.mjs +217 -0
- package/dist/actions/repo-init.mjs.map +1 -0
- package/dist/actions/retest.mjs +150 -0
- package/dist/actions/retest.mjs.map +1 -0
- package/dist/actions/sitemap.mjs +121 -0
- package/dist/actions/sitemap.mjs.map +1 -0
- package/dist/actions/sonar.mjs +119 -0
- package/dist/actions/sonar.mjs.map +1 -0
- package/dist/actions/start.mjs +142 -0
- package/dist/actions/start.mjs.map +1 -0
- package/dist/actions/statics.mjs +225 -0
- package/dist/actions/statics.mjs.map +1 -0
- package/dist/actions/test.mjs +144 -0
- package/dist/actions/test.mjs.map +1 -0
- package/dist/actions/up.mjs +140 -0
- package/dist/actions/up.mjs.map +1 -0
- package/dist/actions/updo.mjs +533 -0
- package/dist/actions/updo.mjs.map +1 -0
- package/dist/actions/upplug.mjs +124 -0
- package/dist/actions/upplug.mjs.map +1 -0
- package/dist/actions/upyarn.mjs +119 -0
- package/dist/actions/upyarn.mjs.map +1 -0
- package/dist/actions/yarn3only.mjs +60 -0
- package/dist/actions/yarn3only.mjs.map +1 -0
- package/dist/bin/package/build-only.mjs +451 -0
- package/dist/bin/package/build-only.mjs.map +1 -0
- package/dist/bin/package/build.mjs +451 -0
- package/dist/bin/package/build.mjs.map +1 -0
- package/dist/bin/package/clean-outputs.mjs +50 -0
- package/dist/bin/package/clean-outputs.mjs.map +1 -0
- package/dist/bin/package/clean-typescript.mjs +50 -0
- package/dist/bin/package/clean-typescript.mjs.map +1 -0
- package/dist/bin/package/clean.mjs +75 -0
- package/dist/bin/package/clean.mjs.map +1 -0
- package/dist/bin/package/compile-only.mjs +447 -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 +451 -0
- package/dist/bin/package/compile.mjs.map +1 -0
- package/dist/bin/package/copy-assets-cjs.mjs +75 -0
- package/dist/bin/package/copy-assets-cjs.mjs.map +1 -0
- package/dist/bin/package/copy-assets-esm.mjs +75 -0
- package/dist/bin/package/copy-assets-esm.mjs.map +1 -0
- package/dist/bin/package/cycle.mjs +72 -0
- package/dist/bin/package/cycle.mjs.map +1 -0
- package/dist/bin/package/fix.mjs +97 -0
- package/dist/bin/package/fix.mjs.map +1 -0
- package/dist/bin/package/gen-docs.mjs +142 -0
- package/dist/bin/package/gen-docs.mjs.map +1 -0
- package/dist/bin/package/lint-verbose.mjs +97 -0
- package/dist/bin/package/lint-verbose.mjs.map +1 -0
- package/dist/bin/package/lint.mjs +97 -0
- package/dist/bin/package/lint.mjs.map +1 -0
- package/dist/bin/package/publint.mjs +423 -0
- package/dist/bin/package/publint.mjs.map +1 -0
- package/dist/bin/package/recompile.mjs +516 -0
- package/dist/bin/package/recompile.mjs.map +1 -0
- package/dist/bin/package/relint.mjs +97 -0
- package/dist/bin/package/relint.mjs.map +1 -0
- package/dist/bin/run-or-exec.mjs +20 -0
- package/dist/bin/run-or-exec.mjs.map +1 -0
- package/dist/bin/xy.mjs +8885 -0
- package/dist/bin/xy.mjs.map +1 -0
- package/dist/index.d.ts +1102 -0
- package/dist/index.mjs +9986 -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 +69 -0
- package/dist/lib/claudeMdTemplate.mjs.map +1 -0
- package/dist/lib/concurrency.mjs +38 -0
- package/dist/lib/concurrency.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 +99 -0
- package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -0
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs +203 -0
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -0
- package/dist/lib/dependencies/index.mjs +281 -0
- package/dist/lib/dependencies/index.mjs.map +1 -0
- package/dist/lib/dependencies/workspaceCycles.mjs +79 -0
- package/dist/lib/dependencies/workspaceCycles.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/fillTemplate.mjs +8 -0
- package/dist/lib/fillTemplate.mjs.map +1 -0
- package/dist/lib/generateIgnoreFiles.mjs +86 -0
- package/dist/lib/generateIgnoreFiles.mjs.map +1 -0
- package/dist/lib/generateReadmeFiles.mjs +323 -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 +1627 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/initCwd.mjs +8 -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/latestVersions.mjs +12 -0
- package/dist/lib/latestVersions.mjs.map +1 -0
- package/dist/lib/loadConfig.mjs +72 -0
- package/dist/lib/loadConfig.mjs.map +1 -0
- package/dist/lib/packageName.mjs +26 -0
- package/dist/lib/packageName.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/repoTemplates.mjs +34 -0
- package/dist/lib/repoTemplates.mjs.map +1 -0
- package/dist/lib/runInstall.mjs +30 -0
- package/dist/lib/runInstall.mjs.map +1 -0
- package/dist/lib/runSteps.mjs +118 -0
- package/dist/lib/runSteps.mjs.map +1 -0
- package/dist/lib/runStepsAsync.mjs +136 -0
- package/dist/lib/runStepsAsync.mjs.map +1 -0
- package/dist/lib/runXy.mjs +147 -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 +57 -0
- package/dist/lib/tryRunLocalScript.mjs.map +1 -0
- package/dist/lib/updo/applyUpdates.mjs +44 -0
- package/dist/lib/updo/applyUpdates.mjs.map +1 -0
- package/dist/lib/updo/collectWorkspaceDeps.mjs +48 -0
- package/dist/lib/updo/collectWorkspaceDeps.mjs.map +1 -0
- package/dist/lib/updo/fetchRegistryInfo.mjs +53 -0
- package/dist/lib/updo/fetchRegistryInfo.mjs.map +1 -0
- package/dist/lib/updo/index.mjs +594 -0
- package/dist/lib/updo/index.mjs.map +1 -0
- package/dist/lib/updo/interactiveSelect.mjs +185 -0
- package/dist/lib/updo/interactiveSelect.mjs.map +1 -0
- package/dist/lib/updo/interfaces.mjs +1 -0
- package/dist/lib/updo/interfaces.mjs.map +1 -0
- package/dist/lib/updo/renderTable.mjs +79 -0
- package/dist/lib/updo/renderTable.mjs.map +1 -0
- package/dist/lib/updo/resolveVersions.mjs +49 -0
- package/dist/lib/updo/resolveVersions.mjs.map +1 -0
- package/dist/lib/updo/runUpdo.mjs +511 -0
- package/dist/lib/updo/runUpdo.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/lib/yarn/index.mjs +39 -0
- package/dist/lib/yarn/index.mjs.map +1 -0
- package/dist/lib/yarn/isYarnVersionOrGreater.mjs +18 -0
- package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -0
- package/dist/lib/yarn/workspace/Workspace.mjs +1 -0
- package/dist/lib/yarn/workspace/Workspace.mjs.map +1 -0
- package/dist/lib/yarn/workspace/index.mjs +23 -0
- package/dist/lib/yarn/workspace/index.mjs.map +1 -0
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs +22 -0
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -0
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs +15 -0
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -0
- package/dist/lib/yarn/yarnInitCwd.mjs +8 -0
- package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -0
- package/dist/loadPackageConfig.mjs +18 -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/detectReact.mjs +52 -0
- package/dist/pm/detectReact.mjs.map +1 -0
- package/dist/pm/index.mjs +263 -0
- package/dist/pm/index.mjs.map +1 -0
- package/dist/pm/pnpmPackageManager.mjs +97 -0
- package/dist/pm/pnpmPackageManager.mjs.map +1 -0
- package/dist/pm/registry.mjs +27 -0
- package/dist/pm/registry.mjs.map +1 -0
- package/dist/pm/yarnPackageManager.mjs +112 -0
- package/dist/pm/yarnPackageManager.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 +194 -0
- package/dist/xy/build/buildCommand.mjs.map +1 -0
- package/dist/xy/build/compileCommand.mjs +203 -0
- package/dist/xy/build/compileCommand.mjs.map +1 -0
- package/dist/xy/build/compileOnlyCommand.mjs +204 -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 +487 -0
- package/dist/xy/build/index.mjs.map +1 -0
- package/dist/xy/build/rebuildCommand.mjs +156 -0
- package/dist/xy/build/rebuildCommand.mjs.map +1 -0
- package/dist/xy/build/recompileCommand.mjs +215 -0
- package/dist/xy/build/recompileCommand.mjs.map +1 -0
- package/dist/xy/common/checkCommand.mjs +1909 -0
- package/dist/xy/common/checkCommand.mjs.map +1 -0
- package/dist/xy/common/claude/checkCommand.mjs +207 -0
- package/dist/xy/common/claude/checkCommand.mjs.map +1 -0
- package/dist/xy/common/claude/cleanCommand.mjs +78 -0
- package/dist/xy/common/claude/cleanCommand.mjs.map +1 -0
- package/dist/xy/common/claude/commandsCommand.mjs +134 -0
- package/dist/xy/common/claude/commandsCommand.mjs.map +1 -0
- package/dist/xy/common/claude/index.mjs +734 -0
- package/dist/xy/common/claude/index.mjs.map +1 -0
- package/dist/xy/common/claude/initCommand.mjs +458 -0
- package/dist/xy/common/claude/initCommand.mjs.map +1 -0
- package/dist/xy/common/claude/rulesCommand.mjs +167 -0
- package/dist/xy/common/claude/rulesCommand.mjs.map +1 -0
- package/dist/xy/common/claude/settingsCommand.mjs +115 -0
- package/dist/xy/common/claude/settingsCommand.mjs.map +1 -0
- package/dist/xy/common/claude/skillsCommand.mjs +140 -0
- package/dist/xy/common/claude/skillsCommand.mjs.map +1 -0
- package/dist/xy/common/cleanDocsCommand.mjs +74 -0
- package/dist/xy/common/cleanDocsCommand.mjs.map +1 -0
- package/dist/xy/common/deadCommand.mjs +137 -0
- package/dist/xy/common/deadCommand.mjs.map +1 -0
- package/dist/xy/common/genDocsCommand.mjs +175 -0
- package/dist/xy/common/genDocsCommand.mjs.map +1 -0
- package/dist/xy/common/gitignoreCommand.mjs +165 -0
- package/dist/xy/common/gitignoreCommand.mjs.map +1 -0
- package/dist/xy/common/gitlintCommand.mjs +89 -0
- package/dist/xy/common/gitlintCommand.mjs.map +1 -0
- package/dist/xy/common/index.mjs +4654 -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 +100 -0
- package/dist/xy/common/npmignoreGenCommand.mjs.map +1 -0
- package/dist/xy/common/orphan/cleanCommand.mjs +102 -0
- package/dist/xy/common/orphan/cleanCommand.mjs.map +1 -0
- package/dist/xy/common/orphan/index.mjs +138 -0
- package/dist/xy/common/orphan/index.mjs.map +1 -0
- package/dist/xy/common/orphan/listCommand.mjs +100 -0
- package/dist/xy/common/orphan/listCommand.mjs.map +1 -0
- package/dist/xy/common/packmanCommand.mjs +1538 -0
- package/dist/xy/common/packmanCommand.mjs.map +1 -0
- package/dist/xy/common/readme/genCommand.mjs +395 -0
- package/dist/xy/common/readme/genCommand.mjs.map +1 -0
- package/dist/xy/common/readme/index.mjs +538 -0
- package/dist/xy/common/readme/index.mjs.map +1 -0
- package/dist/xy/common/readme/initCommand.mjs +109 -0
- package/dist/xy/common/readme/initCommand.mjs.map +1 -0
- package/dist/xy/common/readme/lintCommand.mjs +181 -0
- package/dist/xy/common/readme/lintCommand.mjs.map +1 -0
- package/dist/xy/common/repo/index.mjs +1070 -0
- package/dist/xy/common/repo/index.mjs.map +1 -0
- package/dist/xy/common/repo/initCommand.mjs +273 -0
- package/dist/xy/common/repo/initCommand.mjs.map +1 -0
- package/dist/xy/common/repo/lintCommand.mjs +789 -0
- package/dist/xy/common/repo/lintCommand.mjs.map +1 -0
- package/dist/xy/common/retestCommand.mjs +163 -0
- package/dist/xy/common/retestCommand.mjs.map +1 -0
- package/dist/xy/common/testCommand.mjs +157 -0
- package/dist/xy/common/testCommand.mjs.map +1 -0
- package/dist/xy/deploy/deployCommand.mjs +214 -0
- package/dist/xy/deploy/deployCommand.mjs.map +1 -0
- package/dist/xy/deploy/index.mjs +289 -0
- package/dist/xy/deploy/index.mjs.map +1 -0
- package/dist/xy/deploy/publishCommand.mjs +218 -0
- package/dist/xy/deploy/publishCommand.mjs.map +1 -0
- package/dist/xy/index.mjs +8887 -0
- package/dist/xy/index.mjs.map +1 -0
- package/dist/xy/install/cleanCommand.mjs +182 -0
- package/dist/xy/install/cleanCommand.mjs.map +1 -0
- package/dist/xy/install/dupdepsCommand.mjs +234 -0
- package/dist/xy/install/dupdepsCommand.mjs.map +1 -0
- package/dist/xy/install/index.mjs +1006 -0
- package/dist/xy/install/index.mjs.map +1 -0
- package/dist/xy/install/reinstallCommand.mjs +292 -0
- package/dist/xy/install/reinstallCommand.mjs.map +1 -0
- package/dist/xy/install/staticsCommand.mjs +233 -0
- package/dist/xy/install/staticsCommand.mjs.map +1 -0
- package/dist/xy/install/upCommand.mjs +150 -0
- package/dist/xy/install/upCommand.mjs.map +1 -0
- package/dist/xy/install/updoCommand.mjs +550 -0
- package/dist/xy/install/updoCommand.mjs.map +1 -0
- package/dist/xy/lint/cycleCommand.mjs +289 -0
- package/dist/xy/lint/cycleCommand.mjs.map +1 -0
- package/dist/xy/lint/deplintCommand.mjs +1897 -0
- package/dist/xy/lint/deplintCommand.mjs.map +1 -0
- package/dist/xy/lint/fixCommand.mjs +398 -0
- package/dist/xy/lint/fixCommand.mjs.map +1 -0
- package/dist/xy/lint/index.mjs +3759 -0
- package/dist/xy/lint/index.mjs.map +1 -0
- package/dist/xy/lint/knipCommand.mjs +142 -0
- package/dist/xy/lint/knipCommand.mjs.map +1 -0
- package/dist/xy/lint/lint/index.mjs +695 -0
- package/dist/xy/lint/lint/index.mjs.map +1 -0
- package/dist/xy/lint/lint/initCommand.mjs +282 -0
- package/dist/xy/lint/lint/initCommand.mjs.map +1 -0
- package/dist/xy/lint/lint/runCommand.mjs +405 -0
- package/dist/xy/lint/lint/runCommand.mjs.map +1 -0
- package/dist/xy/lint/lintCommand.mjs +695 -0
- package/dist/xy/lint/lintCommand.mjs.map +1 -0
- package/dist/xy/lint/lintlintCommand.mjs +359 -0
- package/dist/xy/lint/lintlintCommand.mjs.map +1 -0
- package/dist/xy/lint/publintCommand.mjs +778 -0
- package/dist/xy/lint/publintCommand.mjs.map +1 -0
- package/dist/xy/lint/relintCommand.mjs +381 -0
- package/dist/xy/lint/relintCommand.mjs.map +1 -0
- package/dist/xy/lint/sonarCommand.mjs +137 -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/react/analyzeCommand.mjs +150 -0
- package/dist/xy/react/analyzeCommand.mjs.map +1 -0
- package/dist/xy/react/ejectCommand.mjs +150 -0
- package/dist/xy/react/ejectCommand.mjs.map +1 -0
- package/dist/xy/react/index.mjs +202 -0
- package/dist/xy/react/index.mjs.map +1 -0
- package/dist/xy/react/sitemapCommand.mjs +129 -0
- package/dist/xy/react/sitemapCommand.mjs.map +1 -0
- package/dist/xy/react/startCommand.mjs +150 -0
- package/dist/xy/react/startCommand.mjs.map +1 -0
- package/dist/xy/xy.mjs +8879 -0
- package/dist/xy/xy.mjs.map +1 -0
- package/dist/xy/xyParseOptions.mjs +117 -0
- package/dist/xy/xyParseOptions.mjs.map +1 -0
- package/dist/xy/yarn/index.mjs +188 -0
- package/dist/xy/yarn/index.mjs.map +1 -0
- package/dist/xy/yarn/upplugCommand.mjs +134 -0
- package/dist/xy/yarn/upplugCommand.mjs.map +1 -0
- package/dist/xy/yarn/upyarnCommand.mjs +129 -0
- package/dist/xy/yarn/upyarnCommand.mjs.map +1 -0
- package/dist/xy/yarn/yarn3OnlyCommand.mjs +70 -0
- package/dist/xy/yarn/yarn3OnlyCommand.mjs.map +1 -0
- package/package.json +119 -0
- package/templates/claude/CLAUDE-local.md +4 -0
- package/templates/claude/CLAUDE-project.md +4 -0
- package/templates/claude/commands/xy-build.md +7 -0
- package/templates/claude/commands/xy-clean.md +7 -0
- package/templates/claude/commands/xy-compile.md +7 -0
- package/templates/claude/commands/xy-cycle.md +7 -0
- package/templates/claude/commands/xy-dead.md +7 -0
- package/templates/claude/commands/xy-deplint.md +7 -0
- package/templates/claude/commands/xy-deps.md +24 -0
- package/templates/claude/commands/xy-dupdeps.md +7 -0
- package/templates/claude/commands/xy-fix.md +7 -0
- package/templates/claude/commands/xy-gen-docs.md +7 -0
- package/templates/claude/commands/xy-gitignore.md +7 -0
- package/templates/claude/commands/xy-gitlint.md +7 -0
- package/templates/claude/commands/xy-knip.md +7 -0
- package/templates/claude/commands/xy-license.md +7 -0
- package/templates/claude/commands/xy-lint-rules.md +44 -0
- package/templates/claude/commands/xy-lint.md +7 -0
- package/templates/claude/commands/xy-publint.md +7 -0
- package/templates/claude/commands/xy-rebuild.md +7 -0
- package/templates/claude/commands/xy-recompile.md +7 -0
- package/templates/claude/commands/xy-reinstall.md +7 -0
- package/templates/claude/commands/xy-relint.md +7 -0
- package/templates/claude/commands/xy-retest.md +7 -0
- package/templates/claude/commands/xy-sonar.md +7 -0
- package/templates/claude/commands/xy-test.md +7 -0
- package/templates/claude/commands/xy-up.md +9 -0
- package/templates/claude/rules/xylabs-architecture.md +8 -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/claude/skills/xylabs-xy-cli/SKILL.md +236 -0
- package/templates/claude/skills/xylabs-xy-deplint-fix/SKILL.md +122 -0
- package/templates/gitignore/gitignore/template.gitignore +51 -0
- package/templates/gitignore/template.gitignore +51 -0
- package/templates/readme/README.body.md +25 -0
- package/templates/readme/README.template.md +22 -0
- package/templates/repo/cli/package/package.json.tmpl +63 -0
- package/templates/repo/cli/package/src/__packageName__.ts.tmpl +21 -0
- package/templates/repo/cli/package/src/actions/index.ts +1 -0
- package/templates/repo/cli/package/src/actions/printVersion.ts.tmpl +8 -0
- package/templates/repo/cli/package/src/bin/__packageName__.ts.tmpl +12 -0
- package/templates/repo/cli/package/src/commands/index.ts +1 -0
- package/templates/repo/cli/package/src/commands/versionCommand.ts.tmpl +11 -0
- package/templates/repo/cli/package/src/index.ts.tmpl +1 -0
- package/templates/repo/cli/package/tsconfig.build.json +25 -0
- package/templates/repo/cli/package/tsconfig.json +4 -0
- package/templates/repo/cli/package/tsup.config.ts +15 -0
- package/templates/repo/cli/package/xy.config.ts +3 -0
- package/templates/repo/cli/root/CLAUDE.md.tmpl +38 -0
- package/templates/repo/cli/root/cspell.json.tmpl +13 -0
- package/templates/repo/cli/root/eslint.config.ts +28 -0
- package/templates/repo/cli/root/github/workflows/build-pnpm.yml.tmpl +34 -0
- package/templates/repo/cli/root/github/workflows/build-yarn.yml.tmpl +32 -0
- package/templates/repo/cli/root/gitignore.tmpl +47 -0
- package/templates/repo/cli/root/knip.config.ts +16 -0
- package/templates/repo/cli/root/package.json.tmpl +54 -0
- package/templates/repo/cli/root/pnpm-workspace.yaml +2 -0
- package/templates/repo/cli/root/tsconfig.json +4 -0
- package/templates/repo/cli/root/vitest.config.ts +31 -0
- package/templates/repo/cli/root/xy.config.ts.tmpl +5 -0
|
@@ -0,0 +1,1070 @@
|
|
|
1
|
+
// src/pm/detectPackageManager.ts
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
function detectPackageManager() {
|
|
4
|
+
if (existsSync("pnpm-lock.yaml") || existsSync("pnpm-workspace.yaml")) return "pnpm";
|
|
5
|
+
return "yarn";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/pm/registry.ts
|
|
9
|
+
var implementations = /* @__PURE__ */ new Map();
|
|
10
|
+
function getPackageManager(name) {
|
|
11
|
+
const pmName = name ?? detectPackageManager();
|
|
12
|
+
const pm = implementations.get(pmName);
|
|
13
|
+
if (!pm) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`No package manager implementation registered for "${pmName}". Ensure registerPackageManager() has been called before getPackageManager().`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return pm;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// src/lib/fillTemplate.ts
|
|
22
|
+
function fillTemplate(template, data) {
|
|
23
|
+
return template.replaceAll(/\{\{(.*?)\}\}/g, (_, key) => data[key.trim()] ?? "");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/lib/initCwd.ts
|
|
27
|
+
function INIT_CWD() {
|
|
28
|
+
return process.env.INIT_CWD ?? process.cwd();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/lib/latestVersions.ts
|
|
32
|
+
var latestVersions = {
|
|
33
|
+
node: "24.14.1",
|
|
34
|
+
nodeLtsCodename: "Krypton",
|
|
35
|
+
npm: "11.11.0",
|
|
36
|
+
pnpm: "10.33.0",
|
|
37
|
+
yarn: "4.13.0"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/lib/repoTemplates.ts
|
|
41
|
+
import { readdirSync, readFileSync } from "fs";
|
|
42
|
+
import { createRequire } from "module";
|
|
43
|
+
import PATH from "path";
|
|
44
|
+
var require2 = createRequire(import.meta.url);
|
|
45
|
+
var packageRoot = PATH.dirname(require2.resolve("@xylabs/ts-scripts-common/package.json"));
|
|
46
|
+
var repoTemplatesDir = PATH.resolve(packageRoot, "templates", "repo");
|
|
47
|
+
function collectFiles(dir, prefix) {
|
|
48
|
+
const results = [];
|
|
49
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
50
|
+
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
51
|
+
if (entry.isDirectory()) {
|
|
52
|
+
results.push(...collectFiles(PATH.resolve(dir, entry.name), rel));
|
|
53
|
+
} else {
|
|
54
|
+
results.push({
|
|
55
|
+
content: readFileSync(PATH.resolve(dir, entry.name), "utf8"),
|
|
56
|
+
relativePath: rel
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return results;
|
|
61
|
+
}
|
|
62
|
+
function loadRepoTemplateFiles(template, section) {
|
|
63
|
+
const dir = PATH.resolve(repoTemplatesDir, template, section);
|
|
64
|
+
return collectFiles(dir, "");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/lib/runInstall.ts
|
|
68
|
+
import { spawnSync } from "child_process";
|
|
69
|
+
import chalk from "chalk";
|
|
70
|
+
function runInstall(cwd) {
|
|
71
|
+
const pm = detectPackageManager();
|
|
72
|
+
console.log(chalk.gray(`Running ${pm} install...`));
|
|
73
|
+
const result = spawnSync(pm, ["install"], {
|
|
74
|
+
cwd,
|
|
75
|
+
stdio: "inherit"
|
|
76
|
+
});
|
|
77
|
+
if (result.status !== 0) {
|
|
78
|
+
console.warn(chalk.yellow(`${pm} install failed`));
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
console.log(chalk.green("Dependencies installed"));
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/actions/package-lint-deps.ts
|
|
86
|
+
import { readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
87
|
+
import PATH2 from "path";
|
|
88
|
+
import chalk2 from "chalk";
|
|
89
|
+
import semver from "semver";
|
|
90
|
+
function readWorkspacePackageJson(cwd, location) {
|
|
91
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
92
|
+
try {
|
|
93
|
+
return JSON.parse(readFileSync2(pkgPath, "utf8"));
|
|
94
|
+
} catch {
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function writeWorkspacePackageJson(cwd, location, pkg) {
|
|
99
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
100
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
101
|
+
`, "utf8");
|
|
102
|
+
}
|
|
103
|
+
function buildWorkspaceVersionMap(cwd, workspaces) {
|
|
104
|
+
const map = /* @__PURE__ */ new Map();
|
|
105
|
+
for (const { location, name } of workspaces) {
|
|
106
|
+
if (location === ".") continue;
|
|
107
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
108
|
+
if (!pkg) continue;
|
|
109
|
+
const version = pkg.version;
|
|
110
|
+
if (version) map.set(name, version);
|
|
111
|
+
}
|
|
112
|
+
return map;
|
|
113
|
+
}
|
|
114
|
+
function expectedPeerRange(devDepVersion, targetVersion) {
|
|
115
|
+
const parsed = semver.parse(targetVersion);
|
|
116
|
+
if (!parsed) return `~${targetVersion}`;
|
|
117
|
+
if (devDepVersion === "workspace:^") {
|
|
118
|
+
return `^${parsed.major}`;
|
|
119
|
+
}
|
|
120
|
+
return `~${parsed.major}.${parsed.minor}`;
|
|
121
|
+
}
|
|
122
|
+
function checkVersionConsistency(cwd, rootPkg, workspaces) {
|
|
123
|
+
const result = {
|
|
124
|
+
errors: [],
|
|
125
|
+
fixable: [],
|
|
126
|
+
warnings: []
|
|
127
|
+
};
|
|
128
|
+
if (rootPkg.version !== void 0) {
|
|
129
|
+
result.fixable.push('Root package.json should not have a "version" field in a monorepo');
|
|
130
|
+
}
|
|
131
|
+
const versions = /* @__PURE__ */ new Map();
|
|
132
|
+
for (const { location, name } of workspaces) {
|
|
133
|
+
if (location === ".") continue;
|
|
134
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
135
|
+
if (!pkg) continue;
|
|
136
|
+
const version = pkg.version;
|
|
137
|
+
if (version) {
|
|
138
|
+
versions.set(name, version);
|
|
139
|
+
} else {
|
|
140
|
+
result.errors.push(`${name} (${location}) is missing a "version" field`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const uniqueVersions = new Set(versions.values());
|
|
144
|
+
if (uniqueVersions.size > 1) {
|
|
145
|
+
const versionList = [...uniqueVersions].toSorted(semver.rcompare);
|
|
146
|
+
for (const [name, version] of versions) {
|
|
147
|
+
if (version !== versionList[0]) {
|
|
148
|
+
result.fixable.push(`${name} has version ${version} (expected ${versionList[0]})`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
function fixVersionConsistency(cwd, rootPkg, writeRootPackageJson2, workspaces) {
|
|
155
|
+
if (rootPkg.version !== void 0) {
|
|
156
|
+
delete rootPkg.version;
|
|
157
|
+
writeRootPackageJson2(cwd, rootPkg);
|
|
158
|
+
console.log(chalk2.green(' \u2714 Fixed: removed "version" from root package.json'));
|
|
159
|
+
}
|
|
160
|
+
const versions = [];
|
|
161
|
+
for (const { location } of workspaces) {
|
|
162
|
+
if (location === ".") continue;
|
|
163
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
164
|
+
if (!pkg) continue;
|
|
165
|
+
const version = pkg.version;
|
|
166
|
+
if (version && semver.valid(version)) {
|
|
167
|
+
versions.push(version);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (versions.length === 0) return;
|
|
171
|
+
const highest = versions.toSorted(semver.rcompare)[0];
|
|
172
|
+
for (const { location, name } of workspaces) {
|
|
173
|
+
if (location === ".") continue;
|
|
174
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
175
|
+
if (!pkg) continue;
|
|
176
|
+
if (pkg.version !== highest) {
|
|
177
|
+
pkg.version = highest;
|
|
178
|
+
writeWorkspacePackageJson(cwd, location, pkg);
|
|
179
|
+
console.log(chalk2.green(` \u2714 Fixed: set version to ${highest} in ${name} (${location})`));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function expectedDepVersion(targetVersion) {
|
|
184
|
+
const parsed = semver.parse(targetVersion);
|
|
185
|
+
if (!parsed) return `~${targetVersion}`;
|
|
186
|
+
return `~${targetVersion}`;
|
|
187
|
+
}
|
|
188
|
+
function checkInternalDepVersions(cwd, workspaces) {
|
|
189
|
+
const result = {
|
|
190
|
+
errors: [],
|
|
191
|
+
fixable: [],
|
|
192
|
+
warnings: []
|
|
193
|
+
};
|
|
194
|
+
const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
|
|
195
|
+
for (const { location, name } of workspaces) {
|
|
196
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
197
|
+
if (!pkg) continue;
|
|
198
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
199
|
+
const deps = pkg[depField];
|
|
200
|
+
if (!deps) continue;
|
|
201
|
+
for (const [dep, version] of Object.entries(deps)) {
|
|
202
|
+
const targetVersion = workspaceVersions.get(dep);
|
|
203
|
+
if (!targetVersion) continue;
|
|
204
|
+
const expected = expectedDepVersion(targetVersion);
|
|
205
|
+
if (version.startsWith("workspace:")) {
|
|
206
|
+
result.fixable.push(
|
|
207
|
+
`${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should be "${expected}" (not workspace: protocol)`
|
|
208
|
+
);
|
|
209
|
+
} else if (version !== expected) {
|
|
210
|
+
result.fixable.push(
|
|
211
|
+
`${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should be "${expected}"`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
function fixInternalDepVersions(cwd, workspaces) {
|
|
220
|
+
const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
|
|
221
|
+
for (const { location, name } of workspaces) {
|
|
222
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
223
|
+
if (!pkg) continue;
|
|
224
|
+
let modified = false;
|
|
225
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
226
|
+
const deps = pkg[depField];
|
|
227
|
+
if (!deps) continue;
|
|
228
|
+
for (const [dep, version] of Object.entries(deps)) {
|
|
229
|
+
const targetVersion = workspaceVersions.get(dep);
|
|
230
|
+
if (!targetVersion) continue;
|
|
231
|
+
const expected = expectedDepVersion(targetVersion);
|
|
232
|
+
if (version !== expected) {
|
|
233
|
+
deps[dep] = expected;
|
|
234
|
+
console.log(chalk2.green(` \u2714 Fixed: set ${depField}.${dep} to "${expected}" in ${name} (${location})`));
|
|
235
|
+
modified = true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (modified) {
|
|
240
|
+
writeWorkspacePackageJson(cwd, location, pkg);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function checkWorkspaceProtocol(cwd, workspaces) {
|
|
245
|
+
const result = {
|
|
246
|
+
errors: [],
|
|
247
|
+
fixable: [],
|
|
248
|
+
warnings: []
|
|
249
|
+
};
|
|
250
|
+
const workspaceNames = new Set(workspaces.map((w) => w.name));
|
|
251
|
+
for (const { location, name } of workspaces) {
|
|
252
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
253
|
+
if (!pkg) continue;
|
|
254
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
255
|
+
const deps = pkg[depField];
|
|
256
|
+
if (!deps) continue;
|
|
257
|
+
for (const [dep, version] of Object.entries(deps)) {
|
|
258
|
+
if (!workspaceNames.has(dep)) continue;
|
|
259
|
+
if (!version.startsWith("workspace:")) {
|
|
260
|
+
result.fixable.push(
|
|
261
|
+
`${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should use workspace: protocol`
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
function fixWorkspaceProtocol(cwd, workspaces) {
|
|
270
|
+
const workspaceNames = new Set(workspaces.map((w) => w.name));
|
|
271
|
+
for (const { location, name } of workspaces) {
|
|
272
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
273
|
+
if (!pkg) continue;
|
|
274
|
+
let modified = false;
|
|
275
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
276
|
+
const deps = pkg[depField];
|
|
277
|
+
if (!deps) continue;
|
|
278
|
+
for (const [dep, version] of Object.entries(deps)) {
|
|
279
|
+
if (!workspaceNames.has(dep)) continue;
|
|
280
|
+
if (!version.startsWith("workspace:")) {
|
|
281
|
+
deps[dep] = "workspace:~";
|
|
282
|
+
console.log(chalk2.green(` \u2714 Fixed: set ${depField}.${dep} to "workspace:~" in ${name} (${location})`));
|
|
283
|
+
modified = true;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (modified) {
|
|
288
|
+
writeWorkspacePackageJson(cwd, location, pkg);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function checkInternalPeerVersions(cwd, workspaces) {
|
|
293
|
+
const result = {
|
|
294
|
+
errors: [],
|
|
295
|
+
fixable: [],
|
|
296
|
+
warnings: []
|
|
297
|
+
};
|
|
298
|
+
const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
|
|
299
|
+
for (const { location, name } of workspaces) {
|
|
300
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
301
|
+
if (!pkg) continue;
|
|
302
|
+
const peerDeps = pkg.peerDependencies;
|
|
303
|
+
if (!peerDeps) continue;
|
|
304
|
+
const devDeps = pkg.devDependencies;
|
|
305
|
+
for (const [dep, version] of Object.entries(peerDeps)) {
|
|
306
|
+
const targetVersion = workspaceVersions.get(dep);
|
|
307
|
+
if (!targetVersion) continue;
|
|
308
|
+
if (version.startsWith("workspace:")) {
|
|
309
|
+
const expected2 = expectedPeerRange(devDeps?.[dep], targetVersion);
|
|
310
|
+
result.fixable.push(
|
|
311
|
+
`${name} (${location}) peerDependencies.${dep} uses workspace: protocol \u2014 should be "${expected2}"`
|
|
312
|
+
);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const expected = expectedPeerRange(devDeps?.[dep], targetVersion);
|
|
316
|
+
if (version !== expected && !semver.satisfies(targetVersion, version)) {
|
|
317
|
+
result.fixable.push(
|
|
318
|
+
`${name} (${location}) peerDependencies.${dep} is "${version}" \u2014 current version ${targetVersion} is not satisfied; expected "${expected}"`
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return result;
|
|
324
|
+
}
|
|
325
|
+
function fixInternalPeerVersions(cwd, workspaces) {
|
|
326
|
+
const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
|
|
327
|
+
for (const { location, name } of workspaces) {
|
|
328
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
329
|
+
if (!pkg) continue;
|
|
330
|
+
const peerDeps = pkg.peerDependencies;
|
|
331
|
+
if (!peerDeps) continue;
|
|
332
|
+
const devDeps = pkg.devDependencies;
|
|
333
|
+
let modified = false;
|
|
334
|
+
for (const [dep, version] of Object.entries(peerDeps)) {
|
|
335
|
+
const targetVersion = workspaceVersions.get(dep);
|
|
336
|
+
if (!targetVersion) continue;
|
|
337
|
+
const expected = expectedPeerRange(devDeps?.[dep], targetVersion);
|
|
338
|
+
if (version !== expected) {
|
|
339
|
+
peerDeps[dep] = expected;
|
|
340
|
+
console.log(chalk2.green(` \u2714 Fixed: set peerDependencies.${dep} to "${expected}" in ${name} (${location})`));
|
|
341
|
+
modified = true;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (modified) {
|
|
345
|
+
writeWorkspacePackageJson(cwd, location, pkg);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// src/actions/package-lint.ts
|
|
351
|
+
import {
|
|
352
|
+
existsSync as existsSync2,
|
|
353
|
+
readFileSync as readFileSync3,
|
|
354
|
+
writeFileSync as writeFileSync2
|
|
355
|
+
} from "fs";
|
|
356
|
+
import PATH3 from "path";
|
|
357
|
+
import chalk3 from "chalk";
|
|
358
|
+
import picomatch from "picomatch";
|
|
359
|
+
import semver2 from "semver";
|
|
360
|
+
function emptyResult() {
|
|
361
|
+
return {
|
|
362
|
+
errors: [],
|
|
363
|
+
fixable: [],
|
|
364
|
+
warnings: []
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function readRootPackageJson(cwd) {
|
|
368
|
+
const raw = readFileSync3(PATH3.resolve(cwd, "package.json"), "utf8");
|
|
369
|
+
return JSON.parse(raw);
|
|
370
|
+
}
|
|
371
|
+
function writeRootPackageJson(cwd, pkg) {
|
|
372
|
+
const path = PATH3.resolve(cwd, "package.json");
|
|
373
|
+
writeFileSync2(path, `${JSON.stringify(pkg, null, 2)}
|
|
374
|
+
`, "utf8");
|
|
375
|
+
}
|
|
376
|
+
function readPnpmWorkspaceGlobs(cwd) {
|
|
377
|
+
const wsPath = PATH3.resolve(cwd, "pnpm-workspace.yaml");
|
|
378
|
+
if (!existsSync2(wsPath)) return void 0;
|
|
379
|
+
const raw = readFileSync3(wsPath, "utf8");
|
|
380
|
+
const globs = [];
|
|
381
|
+
let inPackages = false;
|
|
382
|
+
for (const line of raw.split("\n")) {
|
|
383
|
+
if (/^packages\s*:/.test(line)) {
|
|
384
|
+
inPackages = true;
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
if (inPackages) {
|
|
388
|
+
const match = /^\s+-\s+['"]?([^'"]+)['"]?\s*$/.exec(line);
|
|
389
|
+
if (match) {
|
|
390
|
+
globs.push(match[1]);
|
|
391
|
+
} else if (/^\S/.test(line) && line.trim() !== "") {
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return globs.length > 0 ? globs : void 0;
|
|
397
|
+
}
|
|
398
|
+
function isMonorepo(pkg, cwd) {
|
|
399
|
+
const workspaces = pkg.workspaces;
|
|
400
|
+
if (Array.isArray(workspaces) && workspaces.length > 0) return true;
|
|
401
|
+
return readPnpmWorkspaceGlobs(cwd) !== void 0;
|
|
402
|
+
}
|
|
403
|
+
function checkPackagesFolder(workspaces) {
|
|
404
|
+
const result = emptyResult();
|
|
405
|
+
for (const { location, name } of workspaces) {
|
|
406
|
+
if (location === ".") continue;
|
|
407
|
+
if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
|
|
408
|
+
result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
function checkRootPrivate(pkg) {
|
|
414
|
+
const result = emptyResult();
|
|
415
|
+
if (!pkg.private) {
|
|
416
|
+
result.fixable.push("Root package.json must be private to prevent accidental publishing");
|
|
417
|
+
}
|
|
418
|
+
return result;
|
|
419
|
+
}
|
|
420
|
+
function fixRootPrivate(cwd, pkg) {
|
|
421
|
+
pkg.private = true;
|
|
422
|
+
writeRootPackageJson(cwd, pkg);
|
|
423
|
+
console.log(chalk3.green(' \u2714 Fixed: set "private": true in root package.json'));
|
|
424
|
+
}
|
|
425
|
+
function checkNoPublishConfigOnPrivate(pkg) {
|
|
426
|
+
const result = emptyResult();
|
|
427
|
+
if (pkg.private && pkg.publishConfig) {
|
|
428
|
+
result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
|
|
429
|
+
}
|
|
430
|
+
return result;
|
|
431
|
+
}
|
|
432
|
+
function fixNoPublishConfigOnPrivate(cwd, pkg) {
|
|
433
|
+
delete pkg.publishConfig;
|
|
434
|
+
writeRootPackageJson(cwd, pkg);
|
|
435
|
+
console.log(chalk3.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
|
|
436
|
+
}
|
|
437
|
+
function checkNoPackageManagerInWorkspaces(cwd, workspaces) {
|
|
438
|
+
const result = emptyResult();
|
|
439
|
+
for (const { location, name } of workspaces) {
|
|
440
|
+
if (location === ".") continue;
|
|
441
|
+
const pkgPath = PATH3.resolve(cwd, location, "package.json");
|
|
442
|
+
try {
|
|
443
|
+
const raw = readFileSync3(pkgPath, "utf8");
|
|
444
|
+
const pkg = JSON.parse(raw);
|
|
445
|
+
if (pkg.packageManager) {
|
|
446
|
+
result.fixable.push(`${name} (${location}) has a packageManager field \u2014 only the root should define this`);
|
|
447
|
+
}
|
|
448
|
+
} catch {
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return result;
|
|
452
|
+
}
|
|
453
|
+
function fixNoPackageManagerInWorkspaces(cwd, _pkg, workspaces) {
|
|
454
|
+
for (const { location } of workspaces) {
|
|
455
|
+
if (location === ".") continue;
|
|
456
|
+
const pkgPath = PATH3.resolve(cwd, location, "package.json");
|
|
457
|
+
try {
|
|
458
|
+
const raw = readFileSync3(pkgPath, "utf8");
|
|
459
|
+
const pkg = JSON.parse(raw);
|
|
460
|
+
if (pkg.packageManager) {
|
|
461
|
+
delete pkg.packageManager;
|
|
462
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
463
|
+
`, "utf8");
|
|
464
|
+
console.log(chalk3.green(` \u2714 Fixed: removed packageManager from ${location}/package.json`));
|
|
465
|
+
}
|
|
466
|
+
} catch {
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
function checkWorkspacesFieldPlacement(cwd, pm, workspaces) {
|
|
471
|
+
const result = emptyResult();
|
|
472
|
+
for (const { location, name } of workspaces) {
|
|
473
|
+
if (pm === "pnpm" ? true : location !== ".") {
|
|
474
|
+
const pkgPath = PATH3.resolve(cwd, location, "package.json");
|
|
475
|
+
try {
|
|
476
|
+
const pkg = JSON.parse(readFileSync3(pkgPath, "utf8"));
|
|
477
|
+
if (pkg.workspaces) {
|
|
478
|
+
const label = location === "." ? "Root" : `${name} (${location})`;
|
|
479
|
+
const reason = pm === "pnpm" ? "pnpm uses pnpm-workspace.yaml instead" : "only the root should define workspaces";
|
|
480
|
+
result.fixable.push(`${label} has a workspaces field \u2014 ${reason}`);
|
|
481
|
+
}
|
|
482
|
+
} catch {
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
function fixWorkspacesFieldPlacement(cwd, pm, workspaces) {
|
|
489
|
+
for (const { location } of workspaces) {
|
|
490
|
+
if (pm === "pnpm" ? true : location !== ".") {
|
|
491
|
+
const pkgPath = PATH3.resolve(cwd, location, "package.json");
|
|
492
|
+
try {
|
|
493
|
+
const pkg = JSON.parse(readFileSync3(pkgPath, "utf8"));
|
|
494
|
+
if (pkg.workspaces) {
|
|
495
|
+
delete pkg.workspaces;
|
|
496
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
497
|
+
`, "utf8");
|
|
498
|
+
const label = location === "." ? "root" : location;
|
|
499
|
+
console.log(chalk3.green(` \u2714 Fixed: removed workspaces from ${label}/package.json`));
|
|
500
|
+
}
|
|
501
|
+
} catch {
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces) {
|
|
507
|
+
const result = emptyResult();
|
|
508
|
+
const globs = pm === "pnpm" ? readPnpmWorkspaceGlobs(cwd) ?? [] : Array.isArray(pkg.workspaces) ? pkg.workspaces : [];
|
|
509
|
+
if (globs.length === 0) {
|
|
510
|
+
const source = pm === "pnpm" ? "pnpm-workspace.yaml" : "root package.json workspaces";
|
|
511
|
+
result.errors.push(`No workspace globs found in ${source}`);
|
|
512
|
+
return result;
|
|
513
|
+
}
|
|
514
|
+
const matchers = globs.map((glob) => picomatch(glob));
|
|
515
|
+
const isMatch = (location) => matchers.some((m) => m(location));
|
|
516
|
+
for (const { location, name } of workspaces) {
|
|
517
|
+
if (location === ".") continue;
|
|
518
|
+
if (!isMatch(location)) {
|
|
519
|
+
const source = pm === "pnpm" ? "pnpm-workspace.yaml" : "root package.json workspaces";
|
|
520
|
+
result.errors.push(`${name} (${location}) is not matched by any glob in ${source}`);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return result;
|
|
524
|
+
}
|
|
525
|
+
function logResults(label, result, fix) {
|
|
526
|
+
let errors = 0;
|
|
527
|
+
let fixed = 0;
|
|
528
|
+
for (const error of result.errors) {
|
|
529
|
+
console.log(chalk3.red(` \u2717 ${error}`));
|
|
530
|
+
errors++;
|
|
531
|
+
}
|
|
532
|
+
for (const fixable of result.fixable) {
|
|
533
|
+
if (fix) {
|
|
534
|
+
fixed++;
|
|
535
|
+
} else {
|
|
536
|
+
console.log(chalk3.red(` \u2717 ${fixable} (fixable)`));
|
|
537
|
+
errors++;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
for (const warning of result.warnings) {
|
|
541
|
+
console.log(chalk3.yellow(` \u26A0 ${warning}`));
|
|
542
|
+
}
|
|
543
|
+
if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
|
|
544
|
+
console.log(chalk3.green(` \u2713 ${label}`));
|
|
545
|
+
}
|
|
546
|
+
return { errors, fixed };
|
|
547
|
+
}
|
|
548
|
+
function runChecks(entries, cwd, pkg, fix) {
|
|
549
|
+
let totalErrors = 0;
|
|
550
|
+
let totalFixed = 0;
|
|
551
|
+
for (const entry of entries) {
|
|
552
|
+
const result = entry.check();
|
|
553
|
+
const log = logResults(entry.label, result, fix);
|
|
554
|
+
if (fix && entry.fix && result.fixable.length > 0) {
|
|
555
|
+
entry.fix(cwd, pkg);
|
|
556
|
+
}
|
|
557
|
+
totalErrors += log.errors;
|
|
558
|
+
totalFixed += log.fixed;
|
|
559
|
+
}
|
|
560
|
+
return { errors: totalErrors, fixed: totalFixed };
|
|
561
|
+
}
|
|
562
|
+
function checkVoltaOnlyInRoot(cwd, workspaces) {
|
|
563
|
+
const result = emptyResult();
|
|
564
|
+
for (const { location, name } of workspaces) {
|
|
565
|
+
if (location === ".") continue;
|
|
566
|
+
const pkgPath = PATH3.resolve(cwd, location, "package.json");
|
|
567
|
+
try {
|
|
568
|
+
const pkg = JSON.parse(readFileSync3(pkgPath, "utf8"));
|
|
569
|
+
if (pkg.volta) {
|
|
570
|
+
result.fixable.push(`${name} (${location}) has a volta field \u2014 only the root should define this`);
|
|
571
|
+
}
|
|
572
|
+
} catch {
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return result;
|
|
576
|
+
}
|
|
577
|
+
function fixVoltaOnlyInRoot(cwd, _pkg, workspaces) {
|
|
578
|
+
for (const { location } of workspaces) {
|
|
579
|
+
if (location === ".") continue;
|
|
580
|
+
const pkgPath = PATH3.resolve(cwd, location, "package.json");
|
|
581
|
+
try {
|
|
582
|
+
const raw = readFileSync3(pkgPath, "utf8");
|
|
583
|
+
const pkg = JSON.parse(raw);
|
|
584
|
+
if (pkg.volta) {
|
|
585
|
+
delete pkg.volta;
|
|
586
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
587
|
+
`, "utf8");
|
|
588
|
+
console.log(chalk3.green(` \u2714 Fixed: removed volta from ${location}/package.json`));
|
|
589
|
+
}
|
|
590
|
+
} catch {
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
function isTerminalPackage(pkg) {
|
|
595
|
+
return pkg.private === true;
|
|
596
|
+
}
|
|
597
|
+
function checkEnginesOnlyInNonTerminal(cwd, workspaces) {
|
|
598
|
+
const result = emptyResult();
|
|
599
|
+
const rootPkg = JSON.parse(readFileSync3(PATH3.resolve(cwd, "package.json"), "utf8"));
|
|
600
|
+
if (rootPkg.engines) {
|
|
601
|
+
result.fixable.push("Root package.json has engines \u2014 terminal packages should not declare engines (use volta instead)");
|
|
602
|
+
}
|
|
603
|
+
for (const { location, name } of workspaces) {
|
|
604
|
+
if (location === ".") continue;
|
|
605
|
+
const pkgPath = PATH3.resolve(cwd, location, "package.json");
|
|
606
|
+
try {
|
|
607
|
+
const pkg = JSON.parse(readFileSync3(pkgPath, "utf8"));
|
|
608
|
+
if (isTerminalPackage(pkg) && pkg.engines) {
|
|
609
|
+
result.fixable.push(`${name} (${location}) is terminal (private) but has engines \u2014 terminal packages should not declare engines`);
|
|
610
|
+
}
|
|
611
|
+
if (!isTerminalPackage(pkg) && !pkg.engines) {
|
|
612
|
+
result.fixable.push(`${name} (${location}) is a library but has no engines field`);
|
|
613
|
+
}
|
|
614
|
+
} catch {
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return result;
|
|
618
|
+
}
|
|
619
|
+
function fixEnginesOnlyInNonTerminal(cwd, _pkg, workspaces) {
|
|
620
|
+
const rootPath = PATH3.resolve(cwd, "package.json");
|
|
621
|
+
const rootRaw = readFileSync3(rootPath, "utf8");
|
|
622
|
+
const rootPkg = JSON.parse(rootRaw);
|
|
623
|
+
if (rootPkg.engines) {
|
|
624
|
+
delete rootPkg.engines;
|
|
625
|
+
writeFileSync2(rootPath, `${JSON.stringify(rootPkg, null, 2)}
|
|
626
|
+
`, "utf8");
|
|
627
|
+
console.log(chalk3.green(" \u2714 Fixed: removed engines from root package.json"));
|
|
628
|
+
}
|
|
629
|
+
const enginesTemplate = resolveEnginesTemplate(cwd, workspaces);
|
|
630
|
+
for (const { location } of workspaces) {
|
|
631
|
+
if (location === ".") continue;
|
|
632
|
+
const pkgPath = PATH3.resolve(cwd, location, "package.json");
|
|
633
|
+
try {
|
|
634
|
+
const raw = readFileSync3(pkgPath, "utf8");
|
|
635
|
+
const pkg = JSON.parse(raw);
|
|
636
|
+
if (isTerminalPackage(pkg) && pkg.engines) {
|
|
637
|
+
delete pkg.engines;
|
|
638
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
639
|
+
`, "utf8");
|
|
640
|
+
console.log(chalk3.green(` \u2714 Fixed: removed engines from ${location}/package.json`));
|
|
641
|
+
}
|
|
642
|
+
if (!isTerminalPackage(pkg) && !pkg.engines && enginesTemplate) {
|
|
643
|
+
pkg.engines = enginesTemplate;
|
|
644
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
645
|
+
`, "utf8");
|
|
646
|
+
console.log(chalk3.green(` \u2714 Fixed: added engines to ${location}/package.json`));
|
|
647
|
+
}
|
|
648
|
+
} catch {
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
function resolveEnginesTemplate(cwd, workspaces) {
|
|
653
|
+
for (const { location } of workspaces) {
|
|
654
|
+
if (location === ".") continue;
|
|
655
|
+
try {
|
|
656
|
+
const pkg = JSON.parse(readFileSync3(PATH3.resolve(cwd, location, "package.json"), "utf8"));
|
|
657
|
+
if (!isTerminalPackage(pkg) && pkg.engines) {
|
|
658
|
+
return pkg.engines;
|
|
659
|
+
}
|
|
660
|
+
} catch {
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return void 0;
|
|
664
|
+
}
|
|
665
|
+
function checkVersionsIncludeLts(cwd, workspaces) {
|
|
666
|
+
const result = emptyResult();
|
|
667
|
+
const toolVersions = {
|
|
668
|
+
node: latestVersions.node,
|
|
669
|
+
npm: latestVersions.npm,
|
|
670
|
+
pnpm: latestVersions.pnpm,
|
|
671
|
+
yarn: latestVersions.yarn
|
|
672
|
+
};
|
|
673
|
+
for (const { location, name } of workspaces) {
|
|
674
|
+
const pkgPath = location === "." ? PATH3.resolve(cwd, "package.json") : PATH3.resolve(cwd, location, "package.json");
|
|
675
|
+
try {
|
|
676
|
+
const pkg = JSON.parse(readFileSync3(pkgPath, "utf8"));
|
|
677
|
+
const label = location === "." ? "root" : `${name} (${location})`;
|
|
678
|
+
const engines = pkg.engines;
|
|
679
|
+
if (engines) {
|
|
680
|
+
for (const [tool, range] of Object.entries(engines)) {
|
|
681
|
+
const latest = toolVersions[tool];
|
|
682
|
+
if (latest && !semver2.satisfies(latest, range)) {
|
|
683
|
+
result.errors.push(
|
|
684
|
+
`${label} engines.${tool} "${range}" does not include latest ${tool === "node" ? "LTS " : ""}version ${latest}`
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
const volta = pkg.volta;
|
|
690
|
+
if (volta) {
|
|
691
|
+
for (const [tool, pinnedVersion] of Object.entries(volta)) {
|
|
692
|
+
const latest = toolVersions[tool];
|
|
693
|
+
if (latest && semver2.lt(pinnedVersion, latest)) {
|
|
694
|
+
result.warnings.push(
|
|
695
|
+
`${label} volta.${tool} "${pinnedVersion}" is older than latest ${tool === "node" ? "LTS " : ""}version ${latest}`
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
} catch {
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return result;
|
|
704
|
+
}
|
|
705
|
+
function logSummary(errors, fixed) {
|
|
706
|
+
if (fixed > 0) {
|
|
707
|
+
console.log(chalk3.green(`
|
|
708
|
+
Fixed ${fixed} issue(s)`));
|
|
709
|
+
}
|
|
710
|
+
if (errors > 0) {
|
|
711
|
+
console.log(chalk3.red(`
|
|
712
|
+
${errors} error(s) found`));
|
|
713
|
+
} else if (fixed === 0) {
|
|
714
|
+
console.log(chalk3.green("\n All checks passed"));
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function packageLintMonorepo(fix = false) {
|
|
718
|
+
const cwd = INIT_CWD();
|
|
719
|
+
let pkg;
|
|
720
|
+
try {
|
|
721
|
+
pkg = readRootPackageJson(cwd);
|
|
722
|
+
} catch {
|
|
723
|
+
console.error(chalk3.red("Could not read package.json"));
|
|
724
|
+
return 1;
|
|
725
|
+
}
|
|
726
|
+
if (!isMonorepo(pkg, cwd)) {
|
|
727
|
+
console.log(chalk3.gray("Not a monorepo \u2014 skipping repo lint checks"));
|
|
728
|
+
return 0;
|
|
729
|
+
}
|
|
730
|
+
console.log(chalk3.green("Repo Lint"));
|
|
731
|
+
const pm = detectPackageManager();
|
|
732
|
+
const workspaces = getPackageManager().listWorkspaces();
|
|
733
|
+
const internalDepCheck = pm === "pnpm" ? {
|
|
734
|
+
check: () => checkWorkspaceProtocol(cwd, workspaces),
|
|
735
|
+
fix: () => fixWorkspaceProtocol(cwd, workspaces),
|
|
736
|
+
label: "Internal deps/devDeps use workspace: protocol"
|
|
737
|
+
} : {
|
|
738
|
+
check: () => checkInternalDepVersions(cwd, workspaces),
|
|
739
|
+
fix: () => fixInternalDepVersions(cwd, workspaces),
|
|
740
|
+
label: "Internal deps/devDeps use correct version ranges"
|
|
741
|
+
};
|
|
742
|
+
const checks = [
|
|
743
|
+
{
|
|
744
|
+
check: () => checkRootPrivate(pkg),
|
|
745
|
+
fix: fixRootPrivate,
|
|
746
|
+
label: "Root package is private"
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
check: () => checkNoPublishConfigOnPrivate(pkg),
|
|
750
|
+
fix: fixNoPublishConfigOnPrivate,
|
|
751
|
+
label: "No publishConfig on private root"
|
|
752
|
+
},
|
|
753
|
+
{ check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
|
|
754
|
+
{
|
|
755
|
+
check: () => checkWorkspacesFieldPlacement(cwd, pm, workspaces),
|
|
756
|
+
fix: () => fixWorkspacesFieldPlacement(cwd, pm, workspaces),
|
|
757
|
+
label: pm === "pnpm" ? "No workspaces field in package.json (use pnpm-workspace.yaml)" : "Workspaces field only in root package.json"
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
check: () => checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces),
|
|
761
|
+
label: "Workspace globs cover all packages"
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
check: () => checkNoPackageManagerInWorkspaces(cwd, workspaces),
|
|
765
|
+
fix: () => fixNoPackageManagerInWorkspaces(cwd, pkg, workspaces),
|
|
766
|
+
label: "No packageManager in workspace packages"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
check: () => checkVoltaOnlyInRoot(cwd, workspaces),
|
|
770
|
+
fix: () => fixVoltaOnlyInRoot(cwd, pkg, workspaces),
|
|
771
|
+
label: "Volta only in root package.json"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
check: () => checkEnginesOnlyInNonTerminal(cwd, workspaces),
|
|
775
|
+
fix: () => fixEnginesOnlyInNonTerminal(cwd, pkg, workspaces),
|
|
776
|
+
label: "Engines only in non-terminal (library) packages"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
check: () => checkVersionsIncludeLts(cwd, workspaces),
|
|
780
|
+
label: "Engine/volta versions include latest LTS"
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
check: () => checkVersionConsistency(cwd, pkg, workspaces),
|
|
784
|
+
fix: () => fixVersionConsistency(cwd, pkg, writeRootPackageJson, workspaces),
|
|
785
|
+
label: "Consistent versions across packages"
|
|
786
|
+
},
|
|
787
|
+
internalDepCheck,
|
|
788
|
+
{
|
|
789
|
+
check: () => checkInternalPeerVersions(cwd, workspaces),
|
|
790
|
+
fix: () => fixInternalPeerVersions(cwd, workspaces),
|
|
791
|
+
label: "Internal peerDeps use semver ranges (not workspace: protocol)"
|
|
792
|
+
}
|
|
793
|
+
];
|
|
794
|
+
const { errors, fixed } = runChecks(checks, cwd, pkg, fix);
|
|
795
|
+
logSummary(errors, fixed);
|
|
796
|
+
if (fix && fixed > 0) {
|
|
797
|
+
runInstall();
|
|
798
|
+
}
|
|
799
|
+
return errors > 0 ? 1 : 0;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// src/actions/repo-init.ts
|
|
803
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
804
|
+
import {
|
|
805
|
+
existsSync as existsSync3,
|
|
806
|
+
mkdirSync,
|
|
807
|
+
readdirSync as readdirSync2,
|
|
808
|
+
readFileSync as readFileSync4,
|
|
809
|
+
writeFileSync as writeFileSync3
|
|
810
|
+
} from "fs";
|
|
811
|
+
import { createRequire as createRequire2 } from "module";
|
|
812
|
+
import PATH4 from "path";
|
|
813
|
+
import { createInterface } from "readline";
|
|
814
|
+
import chalk4 from "chalk";
|
|
815
|
+
function askQuestion(question) {
|
|
816
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
817
|
+
return new Promise((resolve) => {
|
|
818
|
+
rl.question(question, (answer) => {
|
|
819
|
+
rl.close();
|
|
820
|
+
resolve(answer.trim());
|
|
821
|
+
});
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
function getConfigVersion() {
|
|
825
|
+
const require3 = createRequire2(import.meta.url);
|
|
826
|
+
const pkgPath = require3.resolve("@xylabs/ts-scripts-common/package.json");
|
|
827
|
+
const pkg = JSON.parse(readFileSync4(pkgPath, "utf8"));
|
|
828
|
+
return pkg.version.replace(/\.\d+$/, "");
|
|
829
|
+
}
|
|
830
|
+
function mapOutputPath(relativePath, variables) {
|
|
831
|
+
let result = relativePath;
|
|
832
|
+
if (result.endsWith(".tmpl")) {
|
|
833
|
+
result = result.slice(0, -5);
|
|
834
|
+
}
|
|
835
|
+
if (result === "gitignore") {
|
|
836
|
+
result = ".gitignore";
|
|
837
|
+
}
|
|
838
|
+
if (result.startsWith("github/")) {
|
|
839
|
+
result = `.${result}`;
|
|
840
|
+
}
|
|
841
|
+
result = result.replaceAll("__packageName__", variables.packageName);
|
|
842
|
+
return result;
|
|
843
|
+
}
|
|
844
|
+
function isPmSpecificFile(relativePath, pm) {
|
|
845
|
+
if (relativePath === "pnpm-workspace.yaml" && pm === "yarn") return true;
|
|
846
|
+
if (relativePath.includes("build-pnpm") && pm !== "pnpm") return true;
|
|
847
|
+
if (relativePath.includes("build-yarn") && pm !== "yarn") return true;
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
function mapBuildWorkflowName(outputPath) {
|
|
851
|
+
return outputPath.replace(/build-(pnpm|yarn)\.yml/, "build.yml");
|
|
852
|
+
}
|
|
853
|
+
function buildVariables(params) {
|
|
854
|
+
const {
|
|
855
|
+
description,
|
|
856
|
+
githubOrg,
|
|
857
|
+
packageName,
|
|
858
|
+
pm,
|
|
859
|
+
projectName,
|
|
860
|
+
scope
|
|
861
|
+
} = params;
|
|
862
|
+
const identifierName = packageName.replaceAll(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
863
|
+
const pmPackage = pm === "pnpm" ? "@xylabs/ts-scripts-pnpm" : "@xylabs/ts-scripts-yarn3";
|
|
864
|
+
return {
|
|
865
|
+
configVersion: getConfigVersion(),
|
|
866
|
+
description,
|
|
867
|
+
githubOrg,
|
|
868
|
+
identifierName,
|
|
869
|
+
npmScope: scope,
|
|
870
|
+
packageName,
|
|
871
|
+
pmName: pm,
|
|
872
|
+
pmPackage,
|
|
873
|
+
projectName
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
function ensureEmptyDir(projectDir, name) {
|
|
877
|
+
if (existsSync3(projectDir)) {
|
|
878
|
+
const entries = readdirSync2(projectDir);
|
|
879
|
+
if (entries.length > 0) {
|
|
880
|
+
console.error(chalk4.red(`Directory '${name}' already exists and is not empty`));
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
mkdirSync(projectDir, { recursive: true });
|
|
885
|
+
return true;
|
|
886
|
+
}
|
|
887
|
+
function scaffoldFiles(templateName, layer, outputDir, pm, variables, verbose) {
|
|
888
|
+
const files = loadRepoTemplateFiles(templateName, layer);
|
|
889
|
+
let count = 0;
|
|
890
|
+
for (const file of files) {
|
|
891
|
+
if (isPmSpecificFile(file.relativePath, pm)) continue;
|
|
892
|
+
const content = fillTemplate(file.content, variables);
|
|
893
|
+
let outputPath = mapOutputPath(file.relativePath, variables);
|
|
894
|
+
if (!outputPath) continue;
|
|
895
|
+
if (layer === "root") outputPath = mapBuildWorkflowName(outputPath);
|
|
896
|
+
const fullPath = PATH4.resolve(outputDir, outputPath);
|
|
897
|
+
mkdirSync(PATH4.dirname(fullPath), { recursive: true });
|
|
898
|
+
writeFileSync3(fullPath, content);
|
|
899
|
+
count++;
|
|
900
|
+
if (verbose) console.log(chalk4.gray(` ${layer === "root" ? outputPath : `packages/${variables.packageName}/${outputPath}`}`));
|
|
901
|
+
}
|
|
902
|
+
return count;
|
|
903
|
+
}
|
|
904
|
+
function initGitRepo(projectDir, verbose) {
|
|
905
|
+
if (verbose) console.log(chalk4.gray("Initializing git repository..."));
|
|
906
|
+
const result = spawnSync2("git", ["init", "-b", "main"], {
|
|
907
|
+
cwd: projectDir,
|
|
908
|
+
stdio: verbose ? "inherit" : "pipe"
|
|
909
|
+
});
|
|
910
|
+
if (result.status === 0) {
|
|
911
|
+
console.log(chalk4.green("Initialized git repository"));
|
|
912
|
+
} else {
|
|
913
|
+
console.warn(chalk4.yellow("git init failed, skipping"));
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
function installDependencies(projectDir, pm) {
|
|
917
|
+
console.log(chalk4.gray(`Running ${pm} install...`));
|
|
918
|
+
const result = spawnSync2(pm, ["install"], {
|
|
919
|
+
cwd: projectDir,
|
|
920
|
+
stdio: "inherit"
|
|
921
|
+
});
|
|
922
|
+
if (result.status !== 0) {
|
|
923
|
+
console.warn(chalk4.yellow(`${pm} install failed`));
|
|
924
|
+
return false;
|
|
925
|
+
}
|
|
926
|
+
console.log(chalk4.green("Dependencies installed"));
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
async function repoInit(params) {
|
|
930
|
+
const {
|
|
931
|
+
description,
|
|
932
|
+
pm,
|
|
933
|
+
scope,
|
|
934
|
+
skipGit,
|
|
935
|
+
skipInstall,
|
|
936
|
+
template,
|
|
937
|
+
verbose
|
|
938
|
+
} = params;
|
|
939
|
+
let name = params.name;
|
|
940
|
+
if (!name) {
|
|
941
|
+
name = await askQuestion(chalk4.cyan("Project name: "));
|
|
942
|
+
if (!name) {
|
|
943
|
+
console.error(chalk4.red("Project name is required"));
|
|
944
|
+
return 1;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
const projectName = PATH4.basename(name);
|
|
948
|
+
const packageName = params.packageName ?? projectName;
|
|
949
|
+
const githubOrg = params.githubOrg ?? scope.replace(/^@/, "");
|
|
950
|
+
const variables = buildVariables({
|
|
951
|
+
description,
|
|
952
|
+
githubOrg,
|
|
953
|
+
packageName,
|
|
954
|
+
pm,
|
|
955
|
+
projectName,
|
|
956
|
+
scope
|
|
957
|
+
});
|
|
958
|
+
if (verbose) {
|
|
959
|
+
console.log(chalk4.gray("Template variables:"));
|
|
960
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
961
|
+
console.log(chalk4.gray(` ${key}: ${value}`));
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
const projectDir = PATH4.resolve(process.cwd(), name);
|
|
965
|
+
if (!ensureEmptyDir(projectDir, name)) return 1;
|
|
966
|
+
const rootCount = scaffoldFiles(template, "root", projectDir, pm, variables, verbose);
|
|
967
|
+
const pkgDir = PATH4.resolve(projectDir, "packages", packageName);
|
|
968
|
+
const pkgCount = scaffoldFiles(template, "package", pkgDir, pm, variables, verbose);
|
|
969
|
+
console.log(chalk4.green(`Scaffolded ${rootCount + pkgCount} files into ${name}/`));
|
|
970
|
+
if (!skipGit) initGitRepo(projectDir, verbose);
|
|
971
|
+
if (!skipInstall && !installDependencies(projectDir, pm)) return 1;
|
|
972
|
+
console.log("");
|
|
973
|
+
console.log(chalk4.cyan(`Project ${name} created successfully!`));
|
|
974
|
+
console.log("");
|
|
975
|
+
console.log(chalk4.gray("Next steps:"));
|
|
976
|
+
console.log(chalk4.gray(` cd ${name}`));
|
|
977
|
+
if (skipInstall) console.log(chalk4.gray(` ${pm} install`));
|
|
978
|
+
console.log(chalk4.gray(` ${pm} xy build`));
|
|
979
|
+
return 0;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// src/xy/common/repo/initCommand.ts
|
|
983
|
+
var initCommand = {
|
|
984
|
+
command: "init <template> [name]",
|
|
985
|
+
describe: "Scaffold a new monorepo from a template",
|
|
986
|
+
builder: (yargs) => {
|
|
987
|
+
return yargs.positional("template", {
|
|
988
|
+
choices: ["cli"],
|
|
989
|
+
describe: "Template to use",
|
|
990
|
+
type: "string"
|
|
991
|
+
}).positional("name", {
|
|
992
|
+
describe: "Project name (also used as directory name)",
|
|
993
|
+
type: "string"
|
|
994
|
+
}).option("scope", {
|
|
995
|
+
default: "@xylabs",
|
|
996
|
+
describe: "npm scope for packages",
|
|
997
|
+
type: "string"
|
|
998
|
+
}).option("package", {
|
|
999
|
+
describe: "Package name within the monorepo (defaults to project name)",
|
|
1000
|
+
type: "string"
|
|
1001
|
+
}).option("description", {
|
|
1002
|
+
default: "",
|
|
1003
|
+
describe: "Project description",
|
|
1004
|
+
type: "string"
|
|
1005
|
+
}).option("github-org", {
|
|
1006
|
+
describe: "GitHub organization (derived from scope if not set)",
|
|
1007
|
+
type: "string"
|
|
1008
|
+
}).option("pm", {
|
|
1009
|
+
choices: ["pnpm", "yarn"],
|
|
1010
|
+
default: "pnpm",
|
|
1011
|
+
describe: "Package manager to configure",
|
|
1012
|
+
type: "string"
|
|
1013
|
+
}).option("skip-install", {
|
|
1014
|
+
default: false,
|
|
1015
|
+
describe: "Skip dependency installation after scaffolding",
|
|
1016
|
+
type: "boolean"
|
|
1017
|
+
}).option("skip-git", {
|
|
1018
|
+
default: false,
|
|
1019
|
+
describe: "Skip git init after scaffolding",
|
|
1020
|
+
type: "boolean"
|
|
1021
|
+
});
|
|
1022
|
+
},
|
|
1023
|
+
handler: async (argv) => {
|
|
1024
|
+
if (argv.verbose) console.log("Repo Init");
|
|
1025
|
+
process.exitCode = await repoInit({
|
|
1026
|
+
description: argv.description,
|
|
1027
|
+
githubOrg: argv["github-org"],
|
|
1028
|
+
name: argv.name,
|
|
1029
|
+
packageName: argv.package,
|
|
1030
|
+
pm: argv.pm,
|
|
1031
|
+
scope: argv.scope,
|
|
1032
|
+
skipGit: !!argv.skipGit,
|
|
1033
|
+
skipInstall: !!argv.skipInstall,
|
|
1034
|
+
template: argv.template,
|
|
1035
|
+
verbose: !!argv.verbose
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
// src/xy/common/repo/lintCommand.ts
|
|
1041
|
+
var lintCommand = {
|
|
1042
|
+
command: "lint",
|
|
1043
|
+
describe: "Check monorepo package structure",
|
|
1044
|
+
builder: (yargs) => {
|
|
1045
|
+
return yargs.option("fix", {
|
|
1046
|
+
default: false,
|
|
1047
|
+
description: "Auto-fix fixable issues",
|
|
1048
|
+
type: "boolean"
|
|
1049
|
+
});
|
|
1050
|
+
},
|
|
1051
|
+
handler: (argv) => {
|
|
1052
|
+
if (argv.verbose) console.log("Repo Lint");
|
|
1053
|
+
process.exitCode = packageLintMonorepo(!!argv.fix);
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
// src/xy/common/repo/index.ts
|
|
1058
|
+
var repoCommand = {
|
|
1059
|
+
builder: (yargs) => {
|
|
1060
|
+
return yargs.command(initCommand).command(lintCommand).demandCommand(1, "Please specify a repo subcommand").strictCommands();
|
|
1061
|
+
},
|
|
1062
|
+
command: "repo",
|
|
1063
|
+
describe: "Repo - Repository structure utilities",
|
|
1064
|
+
handler: () => {
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
export {
|
|
1068
|
+
repoCommand
|
|
1069
|
+
};
|
|
1070
|
+
//# sourceMappingURL=index.mjs.map
|