@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,789 @@
|
|
|
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/initCwd.ts
|
|
22
|
+
function INIT_CWD() {
|
|
23
|
+
return process.env.INIT_CWD ?? process.cwd();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/lib/latestVersions.ts
|
|
27
|
+
var latestVersions = {
|
|
28
|
+
node: "24.14.1",
|
|
29
|
+
nodeLtsCodename: "Krypton",
|
|
30
|
+
npm: "11.11.0",
|
|
31
|
+
pnpm: "10.33.0",
|
|
32
|
+
yarn: "4.13.0"
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/lib/runInstall.ts
|
|
36
|
+
import { spawnSync } from "child_process";
|
|
37
|
+
import chalk from "chalk";
|
|
38
|
+
function runInstall(cwd) {
|
|
39
|
+
const pm = detectPackageManager();
|
|
40
|
+
console.log(chalk.gray(`Running ${pm} install...`));
|
|
41
|
+
const result = spawnSync(pm, ["install"], {
|
|
42
|
+
cwd,
|
|
43
|
+
stdio: "inherit"
|
|
44
|
+
});
|
|
45
|
+
if (result.status !== 0) {
|
|
46
|
+
console.warn(chalk.yellow(`${pm} install failed`));
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
console.log(chalk.green("Dependencies installed"));
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/actions/package-lint-deps.ts
|
|
54
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
55
|
+
import PATH from "path";
|
|
56
|
+
import chalk2 from "chalk";
|
|
57
|
+
import semver from "semver";
|
|
58
|
+
function readWorkspacePackageJson(cwd, location) {
|
|
59
|
+
const pkgPath = PATH.resolve(cwd, location, "package.json");
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
62
|
+
} catch {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function writeWorkspacePackageJson(cwd, location, pkg) {
|
|
67
|
+
const pkgPath = PATH.resolve(cwd, location, "package.json");
|
|
68
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
69
|
+
`, "utf8");
|
|
70
|
+
}
|
|
71
|
+
function buildWorkspaceVersionMap(cwd, workspaces) {
|
|
72
|
+
const map = /* @__PURE__ */ new Map();
|
|
73
|
+
for (const { location, name } of workspaces) {
|
|
74
|
+
if (location === ".") continue;
|
|
75
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
76
|
+
if (!pkg) continue;
|
|
77
|
+
const version = pkg.version;
|
|
78
|
+
if (version) map.set(name, version);
|
|
79
|
+
}
|
|
80
|
+
return map;
|
|
81
|
+
}
|
|
82
|
+
function expectedPeerRange(devDepVersion, targetVersion) {
|
|
83
|
+
const parsed = semver.parse(targetVersion);
|
|
84
|
+
if (!parsed) return `~${targetVersion}`;
|
|
85
|
+
if (devDepVersion === "workspace:^") {
|
|
86
|
+
return `^${parsed.major}`;
|
|
87
|
+
}
|
|
88
|
+
return `~${parsed.major}.${parsed.minor}`;
|
|
89
|
+
}
|
|
90
|
+
function checkVersionConsistency(cwd, rootPkg, workspaces) {
|
|
91
|
+
const result = {
|
|
92
|
+
errors: [],
|
|
93
|
+
fixable: [],
|
|
94
|
+
warnings: []
|
|
95
|
+
};
|
|
96
|
+
if (rootPkg.version !== void 0) {
|
|
97
|
+
result.fixable.push('Root package.json should not have a "version" field in a monorepo');
|
|
98
|
+
}
|
|
99
|
+
const versions = /* @__PURE__ */ new Map();
|
|
100
|
+
for (const { location, name } of workspaces) {
|
|
101
|
+
if (location === ".") continue;
|
|
102
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
103
|
+
if (!pkg) continue;
|
|
104
|
+
const version = pkg.version;
|
|
105
|
+
if (version) {
|
|
106
|
+
versions.set(name, version);
|
|
107
|
+
} else {
|
|
108
|
+
result.errors.push(`${name} (${location}) is missing a "version" field`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const uniqueVersions = new Set(versions.values());
|
|
112
|
+
if (uniqueVersions.size > 1) {
|
|
113
|
+
const versionList = [...uniqueVersions].toSorted(semver.rcompare);
|
|
114
|
+
for (const [name, version] of versions) {
|
|
115
|
+
if (version !== versionList[0]) {
|
|
116
|
+
result.fixable.push(`${name} has version ${version} (expected ${versionList[0]})`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
function fixVersionConsistency(cwd, rootPkg, writeRootPackageJson2, workspaces) {
|
|
123
|
+
if (rootPkg.version !== void 0) {
|
|
124
|
+
delete rootPkg.version;
|
|
125
|
+
writeRootPackageJson2(cwd, rootPkg);
|
|
126
|
+
console.log(chalk2.green(' \u2714 Fixed: removed "version" from root package.json'));
|
|
127
|
+
}
|
|
128
|
+
const versions = [];
|
|
129
|
+
for (const { location } of workspaces) {
|
|
130
|
+
if (location === ".") continue;
|
|
131
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
132
|
+
if (!pkg) continue;
|
|
133
|
+
const version = pkg.version;
|
|
134
|
+
if (version && semver.valid(version)) {
|
|
135
|
+
versions.push(version);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (versions.length === 0) return;
|
|
139
|
+
const highest = versions.toSorted(semver.rcompare)[0];
|
|
140
|
+
for (const { location, name } of workspaces) {
|
|
141
|
+
if (location === ".") continue;
|
|
142
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
143
|
+
if (!pkg) continue;
|
|
144
|
+
if (pkg.version !== highest) {
|
|
145
|
+
pkg.version = highest;
|
|
146
|
+
writeWorkspacePackageJson(cwd, location, pkg);
|
|
147
|
+
console.log(chalk2.green(` \u2714 Fixed: set version to ${highest} in ${name} (${location})`));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function expectedDepVersion(targetVersion) {
|
|
152
|
+
const parsed = semver.parse(targetVersion);
|
|
153
|
+
if (!parsed) return `~${targetVersion}`;
|
|
154
|
+
return `~${targetVersion}`;
|
|
155
|
+
}
|
|
156
|
+
function checkInternalDepVersions(cwd, workspaces) {
|
|
157
|
+
const result = {
|
|
158
|
+
errors: [],
|
|
159
|
+
fixable: [],
|
|
160
|
+
warnings: []
|
|
161
|
+
};
|
|
162
|
+
const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
|
|
163
|
+
for (const { location, name } of workspaces) {
|
|
164
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
165
|
+
if (!pkg) continue;
|
|
166
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
167
|
+
const deps = pkg[depField];
|
|
168
|
+
if (!deps) continue;
|
|
169
|
+
for (const [dep, version] of Object.entries(deps)) {
|
|
170
|
+
const targetVersion = workspaceVersions.get(dep);
|
|
171
|
+
if (!targetVersion) continue;
|
|
172
|
+
const expected = expectedDepVersion(targetVersion);
|
|
173
|
+
if (version.startsWith("workspace:")) {
|
|
174
|
+
result.fixable.push(
|
|
175
|
+
`${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should be "${expected}" (not workspace: protocol)`
|
|
176
|
+
);
|
|
177
|
+
} else if (version !== expected) {
|
|
178
|
+
result.fixable.push(
|
|
179
|
+
`${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should be "${expected}"`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
function fixInternalDepVersions(cwd, workspaces) {
|
|
188
|
+
const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
|
|
189
|
+
for (const { location, name } of workspaces) {
|
|
190
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
191
|
+
if (!pkg) continue;
|
|
192
|
+
let modified = false;
|
|
193
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
194
|
+
const deps = pkg[depField];
|
|
195
|
+
if (!deps) continue;
|
|
196
|
+
for (const [dep, version] of Object.entries(deps)) {
|
|
197
|
+
const targetVersion = workspaceVersions.get(dep);
|
|
198
|
+
if (!targetVersion) continue;
|
|
199
|
+
const expected = expectedDepVersion(targetVersion);
|
|
200
|
+
if (version !== expected) {
|
|
201
|
+
deps[dep] = expected;
|
|
202
|
+
console.log(chalk2.green(` \u2714 Fixed: set ${depField}.${dep} to "${expected}" in ${name} (${location})`));
|
|
203
|
+
modified = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (modified) {
|
|
208
|
+
writeWorkspacePackageJson(cwd, location, pkg);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function checkWorkspaceProtocol(cwd, workspaces) {
|
|
213
|
+
const result = {
|
|
214
|
+
errors: [],
|
|
215
|
+
fixable: [],
|
|
216
|
+
warnings: []
|
|
217
|
+
};
|
|
218
|
+
const workspaceNames = new Set(workspaces.map((w) => w.name));
|
|
219
|
+
for (const { location, name } of workspaces) {
|
|
220
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
221
|
+
if (!pkg) continue;
|
|
222
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
223
|
+
const deps = pkg[depField];
|
|
224
|
+
if (!deps) continue;
|
|
225
|
+
for (const [dep, version] of Object.entries(deps)) {
|
|
226
|
+
if (!workspaceNames.has(dep)) continue;
|
|
227
|
+
if (!version.startsWith("workspace:")) {
|
|
228
|
+
result.fixable.push(
|
|
229
|
+
`${name} (${location}) ${depField}.${dep} is "${version}" \u2014 should use workspace: protocol`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
function fixWorkspaceProtocol(cwd, workspaces) {
|
|
238
|
+
const workspaceNames = new Set(workspaces.map((w) => w.name));
|
|
239
|
+
for (const { location, name } of workspaces) {
|
|
240
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
241
|
+
if (!pkg) continue;
|
|
242
|
+
let modified = false;
|
|
243
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
244
|
+
const deps = pkg[depField];
|
|
245
|
+
if (!deps) continue;
|
|
246
|
+
for (const [dep, version] of Object.entries(deps)) {
|
|
247
|
+
if (!workspaceNames.has(dep)) continue;
|
|
248
|
+
if (!version.startsWith("workspace:")) {
|
|
249
|
+
deps[dep] = "workspace:~";
|
|
250
|
+
console.log(chalk2.green(` \u2714 Fixed: set ${depField}.${dep} to "workspace:~" in ${name} (${location})`));
|
|
251
|
+
modified = true;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (modified) {
|
|
256
|
+
writeWorkspacePackageJson(cwd, location, pkg);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function checkInternalPeerVersions(cwd, workspaces) {
|
|
261
|
+
const result = {
|
|
262
|
+
errors: [],
|
|
263
|
+
fixable: [],
|
|
264
|
+
warnings: []
|
|
265
|
+
};
|
|
266
|
+
const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
|
|
267
|
+
for (const { location, name } of workspaces) {
|
|
268
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
269
|
+
if (!pkg) continue;
|
|
270
|
+
const peerDeps = pkg.peerDependencies;
|
|
271
|
+
if (!peerDeps) continue;
|
|
272
|
+
const devDeps = pkg.devDependencies;
|
|
273
|
+
for (const [dep, version] of Object.entries(peerDeps)) {
|
|
274
|
+
const targetVersion = workspaceVersions.get(dep);
|
|
275
|
+
if (!targetVersion) continue;
|
|
276
|
+
if (version.startsWith("workspace:")) {
|
|
277
|
+
const expected2 = expectedPeerRange(devDeps?.[dep], targetVersion);
|
|
278
|
+
result.fixable.push(
|
|
279
|
+
`${name} (${location}) peerDependencies.${dep} uses workspace: protocol \u2014 should be "${expected2}"`
|
|
280
|
+
);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const expected = expectedPeerRange(devDeps?.[dep], targetVersion);
|
|
284
|
+
if (version !== expected && !semver.satisfies(targetVersion, version)) {
|
|
285
|
+
result.fixable.push(
|
|
286
|
+
`${name} (${location}) peerDependencies.${dep} is "${version}" \u2014 current version ${targetVersion} is not satisfied; expected "${expected}"`
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return result;
|
|
292
|
+
}
|
|
293
|
+
function fixInternalPeerVersions(cwd, workspaces) {
|
|
294
|
+
const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces);
|
|
295
|
+
for (const { location, name } of workspaces) {
|
|
296
|
+
const pkg = readWorkspacePackageJson(cwd, location);
|
|
297
|
+
if (!pkg) continue;
|
|
298
|
+
const peerDeps = pkg.peerDependencies;
|
|
299
|
+
if (!peerDeps) continue;
|
|
300
|
+
const devDeps = pkg.devDependencies;
|
|
301
|
+
let modified = false;
|
|
302
|
+
for (const [dep, version] of Object.entries(peerDeps)) {
|
|
303
|
+
const targetVersion = workspaceVersions.get(dep);
|
|
304
|
+
if (!targetVersion) continue;
|
|
305
|
+
const expected = expectedPeerRange(devDeps?.[dep], targetVersion);
|
|
306
|
+
if (version !== expected) {
|
|
307
|
+
peerDeps[dep] = expected;
|
|
308
|
+
console.log(chalk2.green(` \u2714 Fixed: set peerDependencies.${dep} to "${expected}" in ${name} (${location})`));
|
|
309
|
+
modified = true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (modified) {
|
|
313
|
+
writeWorkspacePackageJson(cwd, location, pkg);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/actions/package-lint.ts
|
|
319
|
+
import {
|
|
320
|
+
existsSync as existsSync2,
|
|
321
|
+
readFileSync as readFileSync2,
|
|
322
|
+
writeFileSync as writeFileSync2
|
|
323
|
+
} from "fs";
|
|
324
|
+
import PATH2 from "path";
|
|
325
|
+
import chalk3 from "chalk";
|
|
326
|
+
import picomatch from "picomatch";
|
|
327
|
+
import semver2 from "semver";
|
|
328
|
+
function emptyResult() {
|
|
329
|
+
return {
|
|
330
|
+
errors: [],
|
|
331
|
+
fixable: [],
|
|
332
|
+
warnings: []
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function readRootPackageJson(cwd) {
|
|
336
|
+
const raw = readFileSync2(PATH2.resolve(cwd, "package.json"), "utf8");
|
|
337
|
+
return JSON.parse(raw);
|
|
338
|
+
}
|
|
339
|
+
function writeRootPackageJson(cwd, pkg) {
|
|
340
|
+
const path = PATH2.resolve(cwd, "package.json");
|
|
341
|
+
writeFileSync2(path, `${JSON.stringify(pkg, null, 2)}
|
|
342
|
+
`, "utf8");
|
|
343
|
+
}
|
|
344
|
+
function readPnpmWorkspaceGlobs(cwd) {
|
|
345
|
+
const wsPath = PATH2.resolve(cwd, "pnpm-workspace.yaml");
|
|
346
|
+
if (!existsSync2(wsPath)) return void 0;
|
|
347
|
+
const raw = readFileSync2(wsPath, "utf8");
|
|
348
|
+
const globs = [];
|
|
349
|
+
let inPackages = false;
|
|
350
|
+
for (const line of raw.split("\n")) {
|
|
351
|
+
if (/^packages\s*:/.test(line)) {
|
|
352
|
+
inPackages = true;
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (inPackages) {
|
|
356
|
+
const match = /^\s+-\s+['"]?([^'"]+)['"]?\s*$/.exec(line);
|
|
357
|
+
if (match) {
|
|
358
|
+
globs.push(match[1]);
|
|
359
|
+
} else if (/^\S/.test(line) && line.trim() !== "") {
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return globs.length > 0 ? globs : void 0;
|
|
365
|
+
}
|
|
366
|
+
function isMonorepo(pkg, cwd) {
|
|
367
|
+
const workspaces = pkg.workspaces;
|
|
368
|
+
if (Array.isArray(workspaces) && workspaces.length > 0) return true;
|
|
369
|
+
return readPnpmWorkspaceGlobs(cwd) !== void 0;
|
|
370
|
+
}
|
|
371
|
+
function checkPackagesFolder(workspaces) {
|
|
372
|
+
const result = emptyResult();
|
|
373
|
+
for (const { location, name } of workspaces) {
|
|
374
|
+
if (location === ".") continue;
|
|
375
|
+
if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
|
|
376
|
+
result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return result;
|
|
380
|
+
}
|
|
381
|
+
function checkRootPrivate(pkg) {
|
|
382
|
+
const result = emptyResult();
|
|
383
|
+
if (!pkg.private) {
|
|
384
|
+
result.fixable.push("Root package.json must be private to prevent accidental publishing");
|
|
385
|
+
}
|
|
386
|
+
return result;
|
|
387
|
+
}
|
|
388
|
+
function fixRootPrivate(cwd, pkg) {
|
|
389
|
+
pkg.private = true;
|
|
390
|
+
writeRootPackageJson(cwd, pkg);
|
|
391
|
+
console.log(chalk3.green(' \u2714 Fixed: set "private": true in root package.json'));
|
|
392
|
+
}
|
|
393
|
+
function checkNoPublishConfigOnPrivate(pkg) {
|
|
394
|
+
const result = emptyResult();
|
|
395
|
+
if (pkg.private && pkg.publishConfig) {
|
|
396
|
+
result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
|
|
397
|
+
}
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
function fixNoPublishConfigOnPrivate(cwd, pkg) {
|
|
401
|
+
delete pkg.publishConfig;
|
|
402
|
+
writeRootPackageJson(cwd, pkg);
|
|
403
|
+
console.log(chalk3.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
|
|
404
|
+
}
|
|
405
|
+
function checkNoPackageManagerInWorkspaces(cwd, workspaces) {
|
|
406
|
+
const result = emptyResult();
|
|
407
|
+
for (const { location, name } of workspaces) {
|
|
408
|
+
if (location === ".") continue;
|
|
409
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
410
|
+
try {
|
|
411
|
+
const raw = readFileSync2(pkgPath, "utf8");
|
|
412
|
+
const pkg = JSON.parse(raw);
|
|
413
|
+
if (pkg.packageManager) {
|
|
414
|
+
result.fixable.push(`${name} (${location}) has a packageManager field \u2014 only the root should define this`);
|
|
415
|
+
}
|
|
416
|
+
} catch {
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return result;
|
|
420
|
+
}
|
|
421
|
+
function fixNoPackageManagerInWorkspaces(cwd, _pkg, workspaces) {
|
|
422
|
+
for (const { location } of workspaces) {
|
|
423
|
+
if (location === ".") continue;
|
|
424
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
425
|
+
try {
|
|
426
|
+
const raw = readFileSync2(pkgPath, "utf8");
|
|
427
|
+
const pkg = JSON.parse(raw);
|
|
428
|
+
if (pkg.packageManager) {
|
|
429
|
+
delete pkg.packageManager;
|
|
430
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
431
|
+
`, "utf8");
|
|
432
|
+
console.log(chalk3.green(` \u2714 Fixed: removed packageManager from ${location}/package.json`));
|
|
433
|
+
}
|
|
434
|
+
} catch {
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function checkWorkspacesFieldPlacement(cwd, pm, workspaces) {
|
|
439
|
+
const result = emptyResult();
|
|
440
|
+
for (const { location, name } of workspaces) {
|
|
441
|
+
if (pm === "pnpm" ? true : location !== ".") {
|
|
442
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
443
|
+
try {
|
|
444
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf8"));
|
|
445
|
+
if (pkg.workspaces) {
|
|
446
|
+
const label = location === "." ? "Root" : `${name} (${location})`;
|
|
447
|
+
const reason = pm === "pnpm" ? "pnpm uses pnpm-workspace.yaml instead" : "only the root should define workspaces";
|
|
448
|
+
result.fixable.push(`${label} has a workspaces field \u2014 ${reason}`);
|
|
449
|
+
}
|
|
450
|
+
} catch {
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return result;
|
|
455
|
+
}
|
|
456
|
+
function fixWorkspacesFieldPlacement(cwd, pm, workspaces) {
|
|
457
|
+
for (const { location } of workspaces) {
|
|
458
|
+
if (pm === "pnpm" ? true : location !== ".") {
|
|
459
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
460
|
+
try {
|
|
461
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf8"));
|
|
462
|
+
if (pkg.workspaces) {
|
|
463
|
+
delete pkg.workspaces;
|
|
464
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
465
|
+
`, "utf8");
|
|
466
|
+
const label = location === "." ? "root" : location;
|
|
467
|
+
console.log(chalk3.green(` \u2714 Fixed: removed workspaces from ${label}/package.json`));
|
|
468
|
+
}
|
|
469
|
+
} catch {
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces) {
|
|
475
|
+
const result = emptyResult();
|
|
476
|
+
const globs = pm === "pnpm" ? readPnpmWorkspaceGlobs(cwd) ?? [] : Array.isArray(pkg.workspaces) ? pkg.workspaces : [];
|
|
477
|
+
if (globs.length === 0) {
|
|
478
|
+
const source = pm === "pnpm" ? "pnpm-workspace.yaml" : "root package.json workspaces";
|
|
479
|
+
result.errors.push(`No workspace globs found in ${source}`);
|
|
480
|
+
return result;
|
|
481
|
+
}
|
|
482
|
+
const matchers = globs.map((glob) => picomatch(glob));
|
|
483
|
+
const isMatch = (location) => matchers.some((m) => m(location));
|
|
484
|
+
for (const { location, name } of workspaces) {
|
|
485
|
+
if (location === ".") continue;
|
|
486
|
+
if (!isMatch(location)) {
|
|
487
|
+
const source = pm === "pnpm" ? "pnpm-workspace.yaml" : "root package.json workspaces";
|
|
488
|
+
result.errors.push(`${name} (${location}) is not matched by any glob in ${source}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return result;
|
|
492
|
+
}
|
|
493
|
+
function logResults(label, result, fix) {
|
|
494
|
+
let errors = 0;
|
|
495
|
+
let fixed = 0;
|
|
496
|
+
for (const error of result.errors) {
|
|
497
|
+
console.log(chalk3.red(` \u2717 ${error}`));
|
|
498
|
+
errors++;
|
|
499
|
+
}
|
|
500
|
+
for (const fixable of result.fixable) {
|
|
501
|
+
if (fix) {
|
|
502
|
+
fixed++;
|
|
503
|
+
} else {
|
|
504
|
+
console.log(chalk3.red(` \u2717 ${fixable} (fixable)`));
|
|
505
|
+
errors++;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
for (const warning of result.warnings) {
|
|
509
|
+
console.log(chalk3.yellow(` \u26A0 ${warning}`));
|
|
510
|
+
}
|
|
511
|
+
if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
|
|
512
|
+
console.log(chalk3.green(` \u2713 ${label}`));
|
|
513
|
+
}
|
|
514
|
+
return { errors, fixed };
|
|
515
|
+
}
|
|
516
|
+
function runChecks(entries, cwd, pkg, fix) {
|
|
517
|
+
let totalErrors = 0;
|
|
518
|
+
let totalFixed = 0;
|
|
519
|
+
for (const entry of entries) {
|
|
520
|
+
const result = entry.check();
|
|
521
|
+
const log = logResults(entry.label, result, fix);
|
|
522
|
+
if (fix && entry.fix && result.fixable.length > 0) {
|
|
523
|
+
entry.fix(cwd, pkg);
|
|
524
|
+
}
|
|
525
|
+
totalErrors += log.errors;
|
|
526
|
+
totalFixed += log.fixed;
|
|
527
|
+
}
|
|
528
|
+
return { errors: totalErrors, fixed: totalFixed };
|
|
529
|
+
}
|
|
530
|
+
function checkVoltaOnlyInRoot(cwd, workspaces) {
|
|
531
|
+
const result = emptyResult();
|
|
532
|
+
for (const { location, name } of workspaces) {
|
|
533
|
+
if (location === ".") continue;
|
|
534
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
535
|
+
try {
|
|
536
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf8"));
|
|
537
|
+
if (pkg.volta) {
|
|
538
|
+
result.fixable.push(`${name} (${location}) has a volta field \u2014 only the root should define this`);
|
|
539
|
+
}
|
|
540
|
+
} catch {
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return result;
|
|
544
|
+
}
|
|
545
|
+
function fixVoltaOnlyInRoot(cwd, _pkg, workspaces) {
|
|
546
|
+
for (const { location } of workspaces) {
|
|
547
|
+
if (location === ".") continue;
|
|
548
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
549
|
+
try {
|
|
550
|
+
const raw = readFileSync2(pkgPath, "utf8");
|
|
551
|
+
const pkg = JSON.parse(raw);
|
|
552
|
+
if (pkg.volta) {
|
|
553
|
+
delete pkg.volta;
|
|
554
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
555
|
+
`, "utf8");
|
|
556
|
+
console.log(chalk3.green(` \u2714 Fixed: removed volta from ${location}/package.json`));
|
|
557
|
+
}
|
|
558
|
+
} catch {
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function isTerminalPackage(pkg) {
|
|
563
|
+
return pkg.private === true;
|
|
564
|
+
}
|
|
565
|
+
function checkEnginesOnlyInNonTerminal(cwd, workspaces) {
|
|
566
|
+
const result = emptyResult();
|
|
567
|
+
const rootPkg = JSON.parse(readFileSync2(PATH2.resolve(cwd, "package.json"), "utf8"));
|
|
568
|
+
if (rootPkg.engines) {
|
|
569
|
+
result.fixable.push("Root package.json has engines \u2014 terminal packages should not declare engines (use volta instead)");
|
|
570
|
+
}
|
|
571
|
+
for (const { location, name } of workspaces) {
|
|
572
|
+
if (location === ".") continue;
|
|
573
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
574
|
+
try {
|
|
575
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf8"));
|
|
576
|
+
if (isTerminalPackage(pkg) && pkg.engines) {
|
|
577
|
+
result.fixable.push(`${name} (${location}) is terminal (private) but has engines \u2014 terminal packages should not declare engines`);
|
|
578
|
+
}
|
|
579
|
+
if (!isTerminalPackage(pkg) && !pkg.engines) {
|
|
580
|
+
result.fixable.push(`${name} (${location}) is a library but has no engines field`);
|
|
581
|
+
}
|
|
582
|
+
} catch {
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return result;
|
|
586
|
+
}
|
|
587
|
+
function fixEnginesOnlyInNonTerminal(cwd, _pkg, workspaces) {
|
|
588
|
+
const rootPath = PATH2.resolve(cwd, "package.json");
|
|
589
|
+
const rootRaw = readFileSync2(rootPath, "utf8");
|
|
590
|
+
const rootPkg = JSON.parse(rootRaw);
|
|
591
|
+
if (rootPkg.engines) {
|
|
592
|
+
delete rootPkg.engines;
|
|
593
|
+
writeFileSync2(rootPath, `${JSON.stringify(rootPkg, null, 2)}
|
|
594
|
+
`, "utf8");
|
|
595
|
+
console.log(chalk3.green(" \u2714 Fixed: removed engines from root package.json"));
|
|
596
|
+
}
|
|
597
|
+
const enginesTemplate = resolveEnginesTemplate(cwd, workspaces);
|
|
598
|
+
for (const { location } of workspaces) {
|
|
599
|
+
if (location === ".") continue;
|
|
600
|
+
const pkgPath = PATH2.resolve(cwd, location, "package.json");
|
|
601
|
+
try {
|
|
602
|
+
const raw = readFileSync2(pkgPath, "utf8");
|
|
603
|
+
const pkg = JSON.parse(raw);
|
|
604
|
+
if (isTerminalPackage(pkg) && pkg.engines) {
|
|
605
|
+
delete pkg.engines;
|
|
606
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
607
|
+
`, "utf8");
|
|
608
|
+
console.log(chalk3.green(` \u2714 Fixed: removed engines from ${location}/package.json`));
|
|
609
|
+
}
|
|
610
|
+
if (!isTerminalPackage(pkg) && !pkg.engines && enginesTemplate) {
|
|
611
|
+
pkg.engines = enginesTemplate;
|
|
612
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
613
|
+
`, "utf8");
|
|
614
|
+
console.log(chalk3.green(` \u2714 Fixed: added engines to ${location}/package.json`));
|
|
615
|
+
}
|
|
616
|
+
} catch {
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
function resolveEnginesTemplate(cwd, workspaces) {
|
|
621
|
+
for (const { location } of workspaces) {
|
|
622
|
+
if (location === ".") continue;
|
|
623
|
+
try {
|
|
624
|
+
const pkg = JSON.parse(readFileSync2(PATH2.resolve(cwd, location, "package.json"), "utf8"));
|
|
625
|
+
if (!isTerminalPackage(pkg) && pkg.engines) {
|
|
626
|
+
return pkg.engines;
|
|
627
|
+
}
|
|
628
|
+
} catch {
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return void 0;
|
|
632
|
+
}
|
|
633
|
+
function checkVersionsIncludeLts(cwd, workspaces) {
|
|
634
|
+
const result = emptyResult();
|
|
635
|
+
const toolVersions = {
|
|
636
|
+
node: latestVersions.node,
|
|
637
|
+
npm: latestVersions.npm,
|
|
638
|
+
pnpm: latestVersions.pnpm,
|
|
639
|
+
yarn: latestVersions.yarn
|
|
640
|
+
};
|
|
641
|
+
for (const { location, name } of workspaces) {
|
|
642
|
+
const pkgPath = location === "." ? PATH2.resolve(cwd, "package.json") : PATH2.resolve(cwd, location, "package.json");
|
|
643
|
+
try {
|
|
644
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf8"));
|
|
645
|
+
const label = location === "." ? "root" : `${name} (${location})`;
|
|
646
|
+
const engines = pkg.engines;
|
|
647
|
+
if (engines) {
|
|
648
|
+
for (const [tool, range] of Object.entries(engines)) {
|
|
649
|
+
const latest = toolVersions[tool];
|
|
650
|
+
if (latest && !semver2.satisfies(latest, range)) {
|
|
651
|
+
result.errors.push(
|
|
652
|
+
`${label} engines.${tool} "${range}" does not include latest ${tool === "node" ? "LTS " : ""}version ${latest}`
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const volta = pkg.volta;
|
|
658
|
+
if (volta) {
|
|
659
|
+
for (const [tool, pinnedVersion] of Object.entries(volta)) {
|
|
660
|
+
const latest = toolVersions[tool];
|
|
661
|
+
if (latest && semver2.lt(pinnedVersion, latest)) {
|
|
662
|
+
result.warnings.push(
|
|
663
|
+
`${label} volta.${tool} "${pinnedVersion}" is older than latest ${tool === "node" ? "LTS " : ""}version ${latest}`
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
} catch {
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return result;
|
|
672
|
+
}
|
|
673
|
+
function logSummary(errors, fixed) {
|
|
674
|
+
if (fixed > 0) {
|
|
675
|
+
console.log(chalk3.green(`
|
|
676
|
+
Fixed ${fixed} issue(s)`));
|
|
677
|
+
}
|
|
678
|
+
if (errors > 0) {
|
|
679
|
+
console.log(chalk3.red(`
|
|
680
|
+
${errors} error(s) found`));
|
|
681
|
+
} else if (fixed === 0) {
|
|
682
|
+
console.log(chalk3.green("\n All checks passed"));
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function packageLintMonorepo(fix = false) {
|
|
686
|
+
const cwd = INIT_CWD();
|
|
687
|
+
let pkg;
|
|
688
|
+
try {
|
|
689
|
+
pkg = readRootPackageJson(cwd);
|
|
690
|
+
} catch {
|
|
691
|
+
console.error(chalk3.red("Could not read package.json"));
|
|
692
|
+
return 1;
|
|
693
|
+
}
|
|
694
|
+
if (!isMonorepo(pkg, cwd)) {
|
|
695
|
+
console.log(chalk3.gray("Not a monorepo \u2014 skipping repo lint checks"));
|
|
696
|
+
return 0;
|
|
697
|
+
}
|
|
698
|
+
console.log(chalk3.green("Repo Lint"));
|
|
699
|
+
const pm = detectPackageManager();
|
|
700
|
+
const workspaces = getPackageManager().listWorkspaces();
|
|
701
|
+
const internalDepCheck = pm === "pnpm" ? {
|
|
702
|
+
check: () => checkWorkspaceProtocol(cwd, workspaces),
|
|
703
|
+
fix: () => fixWorkspaceProtocol(cwd, workspaces),
|
|
704
|
+
label: "Internal deps/devDeps use workspace: protocol"
|
|
705
|
+
} : {
|
|
706
|
+
check: () => checkInternalDepVersions(cwd, workspaces),
|
|
707
|
+
fix: () => fixInternalDepVersions(cwd, workspaces),
|
|
708
|
+
label: "Internal deps/devDeps use correct version ranges"
|
|
709
|
+
};
|
|
710
|
+
const checks = [
|
|
711
|
+
{
|
|
712
|
+
check: () => checkRootPrivate(pkg),
|
|
713
|
+
fix: fixRootPrivate,
|
|
714
|
+
label: "Root package is private"
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
check: () => checkNoPublishConfigOnPrivate(pkg),
|
|
718
|
+
fix: fixNoPublishConfigOnPrivate,
|
|
719
|
+
label: "No publishConfig on private root"
|
|
720
|
+
},
|
|
721
|
+
{ check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
|
|
722
|
+
{
|
|
723
|
+
check: () => checkWorkspacesFieldPlacement(cwd, pm, workspaces),
|
|
724
|
+
fix: () => fixWorkspacesFieldPlacement(cwd, pm, workspaces),
|
|
725
|
+
label: pm === "pnpm" ? "No workspaces field in package.json (use pnpm-workspace.yaml)" : "Workspaces field only in root package.json"
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
check: () => checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces),
|
|
729
|
+
label: "Workspace globs cover all packages"
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
check: () => checkNoPackageManagerInWorkspaces(cwd, workspaces),
|
|
733
|
+
fix: () => fixNoPackageManagerInWorkspaces(cwd, pkg, workspaces),
|
|
734
|
+
label: "No packageManager in workspace packages"
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
check: () => checkVoltaOnlyInRoot(cwd, workspaces),
|
|
738
|
+
fix: () => fixVoltaOnlyInRoot(cwd, pkg, workspaces),
|
|
739
|
+
label: "Volta only in root package.json"
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
check: () => checkEnginesOnlyInNonTerminal(cwd, workspaces),
|
|
743
|
+
fix: () => fixEnginesOnlyInNonTerminal(cwd, pkg, workspaces),
|
|
744
|
+
label: "Engines only in non-terminal (library) packages"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
check: () => checkVersionsIncludeLts(cwd, workspaces),
|
|
748
|
+
label: "Engine/volta versions include latest LTS"
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
check: () => checkVersionConsistency(cwd, pkg, workspaces),
|
|
752
|
+
fix: () => fixVersionConsistency(cwd, pkg, writeRootPackageJson, workspaces),
|
|
753
|
+
label: "Consistent versions across packages"
|
|
754
|
+
},
|
|
755
|
+
internalDepCheck,
|
|
756
|
+
{
|
|
757
|
+
check: () => checkInternalPeerVersions(cwd, workspaces),
|
|
758
|
+
fix: () => fixInternalPeerVersions(cwd, workspaces),
|
|
759
|
+
label: "Internal peerDeps use semver ranges (not workspace: protocol)"
|
|
760
|
+
}
|
|
761
|
+
];
|
|
762
|
+
const { errors, fixed } = runChecks(checks, cwd, pkg, fix);
|
|
763
|
+
logSummary(errors, fixed);
|
|
764
|
+
if (fix && fixed > 0) {
|
|
765
|
+
runInstall();
|
|
766
|
+
}
|
|
767
|
+
return errors > 0 ? 1 : 0;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// src/xy/common/repo/lintCommand.ts
|
|
771
|
+
var lintCommand = {
|
|
772
|
+
command: "lint",
|
|
773
|
+
describe: "Check monorepo package structure",
|
|
774
|
+
builder: (yargs) => {
|
|
775
|
+
return yargs.option("fix", {
|
|
776
|
+
default: false,
|
|
777
|
+
description: "Auto-fix fixable issues",
|
|
778
|
+
type: "boolean"
|
|
779
|
+
});
|
|
780
|
+
},
|
|
781
|
+
handler: (argv) => {
|
|
782
|
+
if (argv.verbose) console.log("Repo Lint");
|
|
783
|
+
process.exitCode = packageLintMonorepo(!!argv.fix);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
export {
|
|
787
|
+
lintCommand
|
|
788
|
+
};
|
|
789
|
+
//# sourceMappingURL=lintCommand.mjs.map
|