@xylabs/ts-scripts-yarn3 7.4.27 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/deploy-major.mjs +1 -90
- package/dist/actions/deploy-major.mjs.map +1 -1
- package/dist/actions/deploy-minor.mjs +1 -90
- package/dist/actions/deploy-minor.mjs.map +1 -1
- package/dist/actions/deploy-next.mjs +1 -90
- package/dist/actions/deploy-next.mjs.map +1 -1
- package/dist/actions/deploy.mjs +1 -90
- package/dist/actions/deploy.mjs.map +1 -1
- package/dist/actions/index.mjs +50 -3534
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/publish.mjs +1 -90
- package/dist/actions/publish.mjs.map +1 -1
- package/dist/actions/reinstall.mjs +1 -90
- package/dist/actions/reinstall.mjs.map +1 -1
- package/dist/actions/up.mjs +1 -90
- package/dist/actions/up.mjs.map +1 -1
- package/dist/actions/updo.mjs +1 -90
- package/dist/actions/updo.mjs.map +1 -1
- package/dist/actions/upplug.mjs +1 -90
- package/dist/actions/upplug.mjs.map +1 -1
- package/dist/actions/upyarn.mjs +1 -90
- package/dist/actions/upyarn.mjs.map +1 -1
- package/dist/actions/yarn3only.mjs +2 -32
- package/dist/actions/yarn3only.mjs.map +1 -1
- package/dist/bin/xy.mjs +221 -3436
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +24 -496
- package/dist/index.mjs +226 -4413
- package/dist/index.mjs.map +1 -1
- package/dist/lib/index.mjs +0 -804
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/yarn/index.mjs +0 -7
- package/dist/lib/yarn/index.mjs.map +1 -1
- package/dist/pm/index.mjs +82 -0
- package/dist/pm/index.mjs.map +1 -0
- package/dist/pm/yarnPackageManager.mjs +82 -0
- package/dist/pm/yarnPackageManager.mjs.map +1 -0
- package/dist/xy/common/index.mjs +7 -1459
- package/dist/xy/common/index.mjs.map +1 -1
- package/dist/xy/common/upplugCommand.mjs +1 -90
- package/dist/xy/common/upplugCommand.mjs.map +1 -1
- package/dist/xy/common/upyarnCommand.mjs +1 -90
- package/dist/xy/common/upyarnCommand.mjs.map +1 -1
- package/dist/xy/common/yarn3OnlyCommand.mjs +1 -33
- package/dist/xy/common/yarn3OnlyCommand.mjs.map +1 -1
- package/dist/xy/deploy/deployCommand.mjs +3 -90
- package/dist/xy/deploy/deployCommand.mjs.map +1 -1
- package/dist/xy/deploy/deployMajorCommand.mjs +1 -90
- package/dist/xy/deploy/deployMajorCommand.mjs.map +1 -1
- package/dist/xy/deploy/deployMinorCommand.mjs +1 -90
- package/dist/xy/deploy/deployMinorCommand.mjs.map +1 -1
- package/dist/xy/deploy/deployNextCommand.mjs +1 -90
- package/dist/xy/deploy/deployNextCommand.mjs.map +1 -1
- package/dist/xy/deploy/index.mjs +11 -94
- package/dist/xy/deploy/index.mjs.map +1 -1
- package/dist/xy/deploy/publishCommand.mjs +1 -90
- package/dist/xy/deploy/publishCommand.mjs.map +1 -1
- package/dist/xy/index.mjs +190 -3477
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/install/cleanCommand.mjs +6 -118
- package/dist/xy/install/cleanCommand.mjs.map +1 -1
- package/dist/xy/install/dupdepsCommand.mjs +6 -178
- package/dist/xy/install/dupdepsCommand.mjs.map +1 -1
- package/dist/xy/install/index.mjs +12 -305
- package/dist/xy/install/index.mjs.map +1 -1
- package/dist/xy/install/reinstallCommand.mjs +1 -90
- package/dist/xy/install/reinstallCommand.mjs.map +1 -1
- package/dist/xy/install/staticsCommand.mjs +6 -177
- package/dist/xy/install/staticsCommand.mjs.map +1 -1
- package/dist/xy/install/upCommand.mjs +1 -90
- package/dist/xy/install/upCommand.mjs.map +1 -1
- package/dist/xy/install/updoCommand.mjs +1 -90
- package/dist/xy/install/updoCommand.mjs.map +1 -1
- package/dist/xy/xy.mjs +190 -3474
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/yarnCommands.mjs +80 -0
- package/dist/xy/yarnCommands.mjs.map +1 -0
- package/package.json +5 -47
- package/dist/actions/build.mjs +0 -140
- package/dist/actions/build.mjs.map +0 -1
- package/dist/actions/claude-clean.mjs +0 -71
- package/dist/actions/claude-clean.mjs.map +0 -1
- package/dist/actions/claude-commands.mjs +0 -112
- package/dist/actions/claude-commands.mjs.map +0 -1
- package/dist/actions/claude-rules.mjs +0 -137
- package/dist/actions/claude-rules.mjs.map +0 -1
- package/dist/actions/claude-settings.mjs +0 -85
- package/dist/actions/claude-settings.mjs.map +0 -1
- package/dist/actions/claude-skills.mjs +0 -120
- package/dist/actions/claude-skills.mjs.map +0 -1
- package/dist/actions/clean-docs.mjs +0 -37
- package/dist/actions/clean-docs.mjs.map +0 -1
- package/dist/actions/clean-eslint.mjs +0 -26
- package/dist/actions/clean-eslint.mjs.map +0 -1
- package/dist/actions/clean.mjs +0 -124
- package/dist/actions/clean.mjs.map +0 -1
- package/dist/actions/compile.mjs +0 -157
- package/dist/actions/compile.mjs.map +0 -1
- package/dist/actions/copy-assets.mjs +0 -73
- package/dist/actions/copy-assets.mjs.map +0 -1
- package/dist/actions/cycle.mjs +0 -144
- package/dist/actions/cycle.mjs.map +0 -1
- package/dist/actions/dead.mjs +0 -98
- package/dist/actions/dead.mjs.map +0 -1
- package/dist/actions/deplint/checkPackage/checkPackage.mjs +0 -672
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +0 -1
- package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs +0 -1
- package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs.map +0 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +0 -48
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +0 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +0 -33
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +0 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +0 -30
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +0 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +0 -309
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +0 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +0 -26
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +0 -1
- package/dist/actions/deplint/checkPackage/index.mjs +0 -672
- package/dist/actions/deplint/checkPackage/index.mjs.map +0 -1
- package/dist/actions/deplint/deplint.mjs +0 -764
- package/dist/actions/deplint/deplint.mjs.map +0 -1
- package/dist/actions/deplint/findFiles.mjs +0 -39
- package/dist/actions/deplint/findFiles.mjs.map +0 -1
- package/dist/actions/deplint/findFilesByGlob.mjs +0 -14
- package/dist/actions/deplint/findFilesByGlob.mjs.map +0 -1
- package/dist/actions/deplint/getBasePackageName.mjs +0 -13
- package/dist/actions/deplint/getBasePackageName.mjs.map +0 -1
- package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs +0 -140
- package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs.map +0 -1
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +0 -20
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +0 -1
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +0 -44
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +0 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +0 -122
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +0 -1
- package/dist/actions/deplint/getImportsFromFile.mjs +0 -85
- package/dist/actions/deplint/getImportsFromFile.mjs.map +0 -1
- package/dist/actions/deplint/getRequiredPeerDependencies.mjs +0 -36
- package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +0 -1
- package/dist/actions/deplint/getScriptReferencedPackages.mjs +0 -83
- package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +0 -1
- package/dist/actions/deplint/implicitDevDependencies.mjs +0 -80
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +0 -1
- package/dist/actions/deplint/index.mjs +0 -764
- package/dist/actions/deplint/index.mjs.map +0 -1
- package/dist/actions/dupdeps.mjs +0 -184
- package/dist/actions/dupdeps.mjs.map +0 -1
- package/dist/actions/fix.mjs +0 -147
- package/dist/actions/fix.mjs.map +0 -1
- package/dist/actions/gen-docs.mjs +0 -109
- package/dist/actions/gen-docs.mjs.map +0 -1
- package/dist/actions/gitignore.mjs +0 -152
- package/dist/actions/gitignore.mjs.map +0 -1
- package/dist/actions/gitlint-fix.mjs +0 -27
- package/dist/actions/gitlint-fix.mjs.map +0 -1
- package/dist/actions/gitlint.mjs +0 -48
- package/dist/actions/gitlint.mjs.map +0 -1
- package/dist/actions/knip.mjs +0 -98
- package/dist/actions/knip.mjs.map +0 -1
- package/dist/actions/license.mjs +0 -84
- package/dist/actions/license.mjs.map +0 -1
- package/dist/actions/lint.mjs +0 -144
- package/dist/actions/lint.mjs.map +0 -1
- package/dist/actions/npmignore-gen.mjs +0 -88
- package/dist/actions/npmignore-gen.mjs.map +0 -1
- package/dist/actions/package/clean-outputs.mjs +0 -29
- package/dist/actions/package/clean-outputs.mjs.map +0 -1
- package/dist/actions/package/clean-typescript.mjs +0 -29
- package/dist/actions/package/clean-typescript.mjs.map +0 -1
- package/dist/actions/package/clean.mjs +0 -48
- package/dist/actions/package/clean.mjs.map +0 -1
- package/dist/actions/package/compile/XyConfig.mjs +0 -1
- package/dist/actions/package/compile/XyConfig.mjs.map +0 -1
- package/dist/actions/package/compile/buildEntries.mjs +0 -53
- package/dist/actions/package/compile/buildEntries.mjs.map +0 -1
- package/dist/actions/package/compile/compile.mjs +0 -433
- package/dist/actions/package/compile/compile.mjs.map +0 -1
- package/dist/actions/package/compile/copyTypeFiles.mjs +0 -34
- package/dist/actions/package/compile/copyTypeFiles.mjs.map +0 -1
- package/dist/actions/package/compile/deepMerge.mjs +0 -26
- package/dist/actions/package/compile/deepMerge.mjs.map +0 -1
- package/dist/actions/package/compile/getCompilerOptions.mjs +0 -12
- package/dist/actions/package/compile/getCompilerOptions.mjs.map +0 -1
- package/dist/actions/package/compile/index.mjs +0 -436
- package/dist/actions/package/compile/index.mjs.map +0 -1
- package/dist/actions/package/compile/inputs.mjs +0 -22
- package/dist/actions/package/compile/inputs.mjs.map +0 -1
- package/dist/actions/package/compile/packageCompileTsc.mjs +0 -94
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +0 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +0 -92
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +0 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +0 -402
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +0 -1
- package/dist/actions/package/copy-assets.mjs +0 -46
- package/dist/actions/package/copy-assets.mjs.map +0 -1
- package/dist/actions/package/cycle.mjs +0 -39
- package/dist/actions/package/cycle.mjs.map +0 -1
- package/dist/actions/package/gen-docs.mjs +0 -114
- package/dist/actions/package/gen-docs.mjs.map +0 -1
- package/dist/actions/package/index.mjs +0 -825
- package/dist/actions/package/index.mjs.map +0 -1
- package/dist/actions/package/lint.mjs +0 -80
- package/dist/actions/package/lint.mjs.map +0 -1
- package/dist/actions/package/publint.mjs +0 -66
- package/dist/actions/package/publint.mjs.map +0 -1
- package/dist/actions/package/recompile.mjs +0 -483
- package/dist/actions/package/recompile.mjs.map +0 -1
- package/dist/actions/package-lint.mjs +0 -178
- package/dist/actions/package-lint.mjs.map +0 -1
- package/dist/actions/publint.mjs +0 -166
- package/dist/actions/publint.mjs.map +0 -1
- package/dist/actions/readme-gen.mjs +0 -289
- package/dist/actions/readme-gen.mjs.map +0 -1
- package/dist/actions/readme-init.mjs +0 -83
- package/dist/actions/readme-init.mjs.map +0 -1
- package/dist/actions/rebuild.mjs +0 -101
- package/dist/actions/rebuild.mjs.map +0 -1
- package/dist/actions/recompile.mjs +0 -187
- package/dist/actions/recompile.mjs.map +0 -1
- package/dist/actions/relint.mjs +0 -144
- package/dist/actions/relint.mjs.map +0 -1
- package/dist/actions/retest.mjs +0 -123
- package/dist/actions/retest.mjs.map +0 -1
- package/dist/actions/sonar.mjs +0 -98
- package/dist/actions/sonar.mjs.map +0 -1
- package/dist/actions/statics.mjs +0 -183
- package/dist/actions/statics.mjs.map +0 -1
- package/dist/actions/test.mjs +0 -117
- package/dist/actions/test.mjs.map +0 -1
- package/dist/bin/package/build-only.mjs +0 -445
- package/dist/bin/package/build-only.mjs.map +0 -1
- package/dist/bin/package/build.mjs +0 -445
- package/dist/bin/package/build.mjs.map +0 -1
- package/dist/bin/package/clean-outputs.mjs +0 -29
- package/dist/bin/package/clean-outputs.mjs.map +0 -1
- package/dist/bin/package/clean-typescript.mjs +0 -29
- package/dist/bin/package/clean-typescript.mjs.map +0 -1
- package/dist/bin/package/clean.mjs +0 -53
- package/dist/bin/package/clean.mjs.map +0 -1
- package/dist/bin/package/compile-only.mjs +0 -441
- package/dist/bin/package/compile-only.mjs.map +0 -1
- package/dist/bin/package/compile-tsup.mjs +0 -409
- package/dist/bin/package/compile-tsup.mjs.map +0 -1
- package/dist/bin/package/compile.mjs +0 -445
- package/dist/bin/package/compile.mjs.map +0 -1
- package/dist/bin/package/copy-assets-cjs.mjs +0 -54
- package/dist/bin/package/copy-assets-cjs.mjs.map +0 -1
- package/dist/bin/package/copy-assets-esm.mjs +0 -54
- package/dist/bin/package/copy-assets-esm.mjs.map +0 -1
- package/dist/bin/package/cycle.mjs +0 -51
- package/dist/bin/package/cycle.mjs.map +0 -1
- package/dist/bin/package/fix.mjs +0 -92
- package/dist/bin/package/fix.mjs.map +0 -1
- package/dist/bin/package/gen-docs.mjs +0 -121
- package/dist/bin/package/gen-docs.mjs.map +0 -1
- package/dist/bin/package/lint-verbose.mjs +0 -92
- package/dist/bin/package/lint-verbose.mjs.map +0 -1
- package/dist/bin/package/lint.mjs +0 -92
- package/dist/bin/package/lint.mjs.map +0 -1
- package/dist/bin/package/publint.mjs +0 -75
- package/dist/bin/package/publint.mjs.map +0 -1
- package/dist/bin/package/recompile.mjs +0 -489
- package/dist/bin/package/recompile.mjs.map +0 -1
- package/dist/bin/package/relint.mjs +0 -92
- package/dist/bin/package/relint.mjs.map +0 -1
- package/dist/lib/checkResult.mjs +0 -16
- package/dist/lib/checkResult.mjs.map +0 -1
- package/dist/lib/claudeMdTemplate.mjs +0 -65
- package/dist/lib/claudeMdTemplate.mjs.map +0 -1
- package/dist/lib/createBuildConfig.mjs +0 -55
- package/dist/lib/createBuildConfig.mjs.map +0 -1
- package/dist/lib/defaultBuildConfig.mjs +0 -23
- package/dist/lib/defaultBuildConfig.mjs.map +0 -1
- package/dist/lib/deleteGlob.mjs +0 -13
- package/dist/lib/deleteGlob.mjs.map +0 -1
- package/dist/lib/dependencies/DuplicateDetector.mjs +0 -81
- package/dist/lib/dependencies/DuplicateDetector.mjs.map +0 -1
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs +0 -164
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +0 -1
- package/dist/lib/dependencies/index.mjs +0 -165
- package/dist/lib/dependencies/index.mjs.map +0 -1
- package/dist/lib/file/ReadFileSyncOptions.mjs +0 -6
- package/dist/lib/file/ReadFileSyncOptions.mjs.map +0 -1
- package/dist/lib/file/constants.mjs +0 -8
- package/dist/lib/file/constants.mjs.map +0 -1
- package/dist/lib/file/fileLines.mjs +0 -32
- package/dist/lib/file/fileLines.mjs.map +0 -1
- package/dist/lib/file/index.mjs +0 -42
- package/dist/lib/file/index.mjs.map +0 -1
- package/dist/lib/file/tryReadFileSync.mjs +0 -14
- package/dist/lib/file/tryReadFileSync.mjs.map +0 -1
- package/dist/lib/generateIgnoreFiles.mjs +0 -84
- package/dist/lib/generateIgnoreFiles.mjs.map +0 -1
- package/dist/lib/generateReadmeFiles.mjs +0 -257
- package/dist/lib/generateReadmeFiles.mjs.map +0 -1
- package/dist/lib/gitignoreTemplate.mjs +0 -12
- package/dist/lib/gitignoreTemplate.mjs.map +0 -1
- package/dist/lib/jsonFormatters.mjs +0 -11
- package/dist/lib/jsonFormatters.mjs.map +0 -1
- package/dist/lib/loadConfig.mjs +0 -24
- package/dist/lib/loadConfig.mjs.map +0 -1
- package/dist/lib/parsedPackageJSON.mjs +0 -11
- package/dist/lib/parsedPackageJSON.mjs.map +0 -1
- package/dist/lib/processEx.mjs +0 -36
- package/dist/lib/processEx.mjs.map +0 -1
- package/dist/lib/runSteps.mjs +0 -95
- package/dist/lib/runSteps.mjs.map +0 -1
- package/dist/lib/runStepsAsync.mjs +0 -113
- package/dist/lib/runStepsAsync.mjs.map +0 -1
- package/dist/lib/runXy.mjs +0 -103
- package/dist/lib/runXy.mjs.map +0 -1
- package/dist/lib/runXyWithWarning.mjs +0 -13
- package/dist/lib/runXyWithWarning.mjs.map +0 -1
- package/dist/lib/safeExit.mjs +0 -61
- package/dist/lib/safeExit.mjs.map +0 -1
- package/dist/lib/string/empty.mjs +0 -8
- package/dist/lib/string/empty.mjs.map +0 -1
- package/dist/lib/string/index.mjs +0 -12
- package/dist/lib/string/index.mjs.map +0 -1
- package/dist/lib/string/union.mjs +0 -6
- package/dist/lib/string/union.mjs.map +0 -1
- package/dist/lib/tryRunLocalScript.mjs +0 -33
- package/dist/lib/tryRunLocalScript.mjs.map +0 -1
- package/dist/lib/withErrnoException.mjs +0 -13
- package/dist/lib/withErrnoException.mjs.map +0 -1
- package/dist/lib/withError.mjs +0 -8
- package/dist/lib/withError.mjs.map +0 -1
- package/dist/loadPackageConfig.mjs +0 -11
- package/dist/loadPackageConfig.mjs.map +0 -1
- package/dist/types.d.mjs +0 -1
- package/dist/types.d.mjs.map +0 -1
- package/dist/xy/build/buildCommand.mjs +0 -161
- package/dist/xy/build/buildCommand.mjs.map +0 -1
- package/dist/xy/build/compileCommand.mjs +0 -174
- package/dist/xy/build/compileCommand.mjs.map +0 -1
- package/dist/xy/build/compileOnlyCommand.mjs +0 -175
- package/dist/xy/build/compileOnlyCommand.mjs.map +0 -1
- package/dist/xy/build/copyAssetsCommand.mjs +0 -84
- package/dist/xy/build/copyAssetsCommand.mjs.map +0 -1
- package/dist/xy/build/index.mjs +0 -507
- package/dist/xy/build/index.mjs.map +0 -1
- package/dist/xy/build/rebuildCommand.mjs +0 -114
- package/dist/xy/build/rebuildCommand.mjs.map +0 -1
- package/dist/xy/build/recompileCommand.mjs +0 -204
- package/dist/xy/build/recompileCommand.mjs.map +0 -1
- package/dist/xy/common/claude/cleanCommand.mjs +0 -79
- package/dist/xy/common/claude/cleanCommand.mjs.map +0 -1
- package/dist/xy/common/claude/commandsCommand.mjs +0 -120
- package/dist/xy/common/claude/commandsCommand.mjs.map +0 -1
- package/dist/xy/common/claude/index.mjs +0 -546
- package/dist/xy/common/claude/index.mjs.map +0 -1
- package/dist/xy/common/claude/initCommand.mjs +0 -319
- package/dist/xy/common/claude/initCommand.mjs.map +0 -1
- package/dist/xy/common/claude/rulesCommand.mjs +0 -153
- package/dist/xy/common/claude/rulesCommand.mjs.map +0 -1
- package/dist/xy/common/claude/settingsCommand.mjs +0 -93
- package/dist/xy/common/claude/settingsCommand.mjs.map +0 -1
- package/dist/xy/common/claude/skillsCommand.mjs +0 -129
- package/dist/xy/common/claude/skillsCommand.mjs.map +0 -1
- package/dist/xy/common/cleanDocsCommand.mjs +0 -45
- package/dist/xy/common/cleanDocsCommand.mjs.map +0 -1
- package/dist/xy/common/deadCommand.mjs +0 -116
- package/dist/xy/common/deadCommand.mjs.map +0 -1
- package/dist/xy/common/genDocsCommand.mjs +0 -125
- package/dist/xy/common/genDocsCommand.mjs.map +0 -1
- package/dist/xy/common/gitignoreCommand.mjs +0 -158
- package/dist/xy/common/gitignoreCommand.mjs.map +0 -1
- package/dist/xy/common/gitlintCommand.mjs +0 -82
- package/dist/xy/common/gitlintCommand.mjs.map +0 -1
- package/dist/xy/common/licenseCommand.mjs +0 -100
- package/dist/xy/common/licenseCommand.mjs.map +0 -1
- package/dist/xy/common/npmignoreGenCommand.mjs +0 -98
- package/dist/xy/common/npmignoreGenCommand.mjs.map +0 -1
- package/dist/xy/common/readme/genCommand.mjs +0 -321
- package/dist/xy/common/readme/genCommand.mjs.map +0 -1
- package/dist/xy/common/readme/index.mjs +0 -361
- package/dist/xy/common/readme/index.mjs.map +0 -1
- package/dist/xy/common/readme/initCommand.mjs +0 -103
- package/dist/xy/common/readme/initCommand.mjs.map +0 -1
- package/dist/xy/common/retestCommand.mjs +0 -136
- package/dist/xy/common/retestCommand.mjs.map +0 -1
- package/dist/xy/common/testCommand.mjs +0 -130
- package/dist/xy/common/testCommand.mjs.map +0 -1
- package/dist/xy/lint/cycleCommand.mjs +0 -163
- package/dist/xy/lint/cycleCommand.mjs.map +0 -1
- package/dist/xy/lint/deplintCommand.mjs +0 -814
- package/dist/xy/lint/deplintCommand.mjs.map +0 -1
- package/dist/xy/lint/fixCommand.mjs +0 -168
- package/dist/xy/lint/fixCommand.mjs.map +0 -1
- package/dist/xy/lint/index.mjs +0 -1444
- package/dist/xy/lint/index.mjs.map +0 -1
- package/dist/xy/lint/knipCommand.mjs +0 -121
- package/dist/xy/lint/knipCommand.mjs.map +0 -1
- package/dist/xy/lint/lintCommand.mjs +0 -186
- package/dist/xy/lint/lintCommand.mjs.map +0 -1
- package/dist/xy/lint/packageLintCommand.mjs +0 -193
- package/dist/xy/lint/packageLintCommand.mjs.map +0 -1
- package/dist/xy/lint/publintCommand.mjs +0 -187
- package/dist/xy/lint/publintCommand.mjs.map +0 -1
- package/dist/xy/lint/relintCommand.mjs +0 -163
- package/dist/xy/lint/relintCommand.mjs.map +0 -1
- package/dist/xy/lint/sonarCommand.mjs +0 -121
- package/dist/xy/lint/sonarCommand.mjs.map +0 -1
- package/dist/xy/param.mjs +0 -8
- package/dist/xy/param.mjs.map +0 -1
- package/dist/xy/xyParseOptions.mjs +0 -70
- package/dist/xy/xyParseOptions.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,345 +1,5 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
// src/lib/checkResult.ts
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
var checkResult = (name, result, level = "error", exitOnFail = false) => {
|
|
7
|
-
if (result) {
|
|
8
|
-
const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
|
|
9
|
-
const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
|
|
10
|
-
console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
|
|
11
|
-
if (exitOnFail) {
|
|
12
|
-
process.exit(result);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// src/lib/claudeMdTemplate.ts
|
|
18
|
-
import {
|
|
19
|
-
readdirSync,
|
|
20
|
-
readFileSync,
|
|
21
|
-
statSync
|
|
22
|
-
} from "fs";
|
|
23
|
-
import { createRequire } from "module";
|
|
24
|
-
import PATH from "path";
|
|
25
|
-
var require2 = createRequire(import.meta.url);
|
|
26
|
-
var packageRoot = PATH.dirname(require2.resolve("@xylabs/ts-scripts-yarn3/package.json"));
|
|
27
|
-
var templatesDir = PATH.resolve(packageRoot, "templates", "claude");
|
|
28
|
-
var XYLABS_RULES_PREFIX = "xylabs-";
|
|
29
|
-
var XYLABS_COMMANDS_PREFIX = "xy-";
|
|
30
|
-
var LEGACY_COMMANDS_PREFIX = "xylabs-";
|
|
31
|
-
var XYLABS_SKILLS_PREFIX = "xylabs-";
|
|
32
|
-
var claudeMdRuleTemplates = () => {
|
|
33
|
-
const rulesDir = PATH.resolve(templatesDir, "rules");
|
|
34
|
-
const files = readdirSync(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
|
|
35
|
-
const result = {};
|
|
36
|
-
for (const file of files) {
|
|
37
|
-
result[file] = readFileSync(PATH.resolve(rulesDir, file), "utf8");
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
};
|
|
41
|
-
var claudeCommandTemplates = () => {
|
|
42
|
-
const commandsDir = PATH.resolve(templatesDir, "commands");
|
|
43
|
-
const files = readdirSync(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
|
|
44
|
-
const result = {};
|
|
45
|
-
for (const file of files) {
|
|
46
|
-
result[file] = readFileSync(PATH.resolve(commandsDir, file), "utf8");
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
50
|
-
var claudeSkillTemplates = () => {
|
|
51
|
-
const skillsDir = PATH.resolve(templatesDir, "skills");
|
|
52
|
-
const dirs = readdirSync(skillsDir).filter(
|
|
53
|
-
(f) => f.startsWith(XYLABS_SKILLS_PREFIX) && statSync(PATH.resolve(skillsDir, f)).isDirectory()
|
|
54
|
-
);
|
|
55
|
-
const result = {};
|
|
56
|
-
for (const dir of dirs) {
|
|
57
|
-
const dirPath = PATH.resolve(skillsDir, dir);
|
|
58
|
-
const files = readdirSync(dirPath, { recursive: true, encoding: "utf8" });
|
|
59
|
-
result[dir] = {};
|
|
60
|
-
for (const file of files) {
|
|
61
|
-
if (statSync(PATH.resolve(dirPath, file)).isFile()) {
|
|
62
|
-
result[dir][file] = readFileSync(PATH.resolve(dirPath, file), "utf8");
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
};
|
|
68
|
-
var claudeMdProjectTemplate = () => readFileSync(PATH.resolve(templatesDir, "CLAUDE-project.md"), "utf8");
|
|
69
|
-
var claudeMdLocalTemplate = () => readFileSync(PATH.resolve(templatesDir, "CLAUDE-local.md"), "utf8");
|
|
70
|
-
|
|
71
|
-
// src/lib/createBuildConfig.ts
|
|
72
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
73
|
-
|
|
74
|
-
// src/lib/defaultBuildConfig.ts
|
|
75
|
-
var defaultBuildConfig = {
|
|
76
|
-
compilerOptions: {
|
|
77
|
-
rootDir: "src",
|
|
78
|
-
rootDirs: ["package.json"]
|
|
79
|
-
},
|
|
80
|
-
exclude: [
|
|
81
|
-
"**/build",
|
|
82
|
-
"**/dist",
|
|
83
|
-
"**/node_modules",
|
|
84
|
-
"**/*.spec.*",
|
|
85
|
-
"**/*.spec",
|
|
86
|
-
"**/*.stories.*",
|
|
87
|
-
"**/*.example.*",
|
|
88
|
-
"**/spec/*",
|
|
89
|
-
"**/stories/*"
|
|
90
|
-
],
|
|
91
|
-
include: ["src"]
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// src/lib/createBuildConfig.ts
|
|
95
|
-
var getGeneralTypescriptConfig = (location) => {
|
|
96
|
-
let generalConfig;
|
|
97
|
-
try {
|
|
98
|
-
generalConfig = readFileSync2(`${location}/tsconfig.json`, { encoding: "utf8" });
|
|
99
|
-
} catch {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
return JSON.parse(generalConfig);
|
|
103
|
-
};
|
|
104
|
-
var createBuildConfig = (location, module, target, outDirSuffix) => {
|
|
105
|
-
const generalConfigObject = getGeneralTypescriptConfig(location);
|
|
106
|
-
if (generalConfigObject === false) {
|
|
107
|
-
return void 0;
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
...generalConfigObject,
|
|
111
|
-
compilerOptions: {
|
|
112
|
-
...defaultBuildConfig.compilerOptions,
|
|
113
|
-
...generalConfigObject.compilerOptions,
|
|
114
|
-
module,
|
|
115
|
-
outDir: `./${generalConfigObject.compilerOptions?.outDir ?? "dist"}/${outDirSuffix}`,
|
|
116
|
-
target
|
|
117
|
-
},
|
|
118
|
-
exclude: [...generalConfigObject.exclude ?? [], ...defaultBuildConfig.exclude],
|
|
119
|
-
include: [...generalConfigObject.include ?? [], ...defaultBuildConfig.include]
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
// src/lib/deleteGlob.ts
|
|
124
|
-
import fs from "fs";
|
|
125
|
-
import { glob } from "glob";
|
|
126
|
-
var deleteGlob = (globPath) => {
|
|
127
|
-
const files = glob.sync(globPath);
|
|
128
|
-
for (const file of files) {
|
|
129
|
-
fs.rmSync(file, { recursive: true, force: true });
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// src/lib/dependencies/detectDuplicateDependencies.ts
|
|
134
|
-
import { execSync } from "child_process";
|
|
135
|
-
|
|
136
|
-
// src/lib/processEx.ts
|
|
137
|
-
import chalk2 from "chalk";
|
|
138
|
-
|
|
139
|
-
// src/lib/withError.ts
|
|
140
|
-
var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
|
|
141
|
-
return predicate(ex) ? closure(ex) : void 0;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// src/lib/withErrnoException.ts
|
|
145
|
-
var withErrnoException = (ex, closure) => {
|
|
146
|
-
return withError(ex, closure, (ex2) => ex2.errno !== void 0);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// src/lib/processEx.ts
|
|
150
|
-
var processEx = (ex) => {
|
|
151
|
-
const error = typeof ex === "string" ? new Error(ex) : ex;
|
|
152
|
-
const exitCode = withErrnoException(error, (error2) => {
|
|
153
|
-
if (error2.code === "ENOENT") {
|
|
154
|
-
console.error(chalk2.red(`'${error2.path}' not found.`));
|
|
155
|
-
} else {
|
|
156
|
-
console.error(chalk2.red(`Errno: ${error2.code}`));
|
|
157
|
-
}
|
|
158
|
-
return error2.errno ?? -1;
|
|
159
|
-
}) ?? withError(error, (error2) => {
|
|
160
|
-
console.error(chalk2.red(`${error2.name}: ${error2.message}`));
|
|
161
|
-
return -1;
|
|
162
|
-
}) ?? (() => {
|
|
163
|
-
console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
|
|
164
|
-
return -1;
|
|
165
|
-
})();
|
|
166
|
-
process.exit(process.exitCode ?? exitCode);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
// src/lib/safeExit.ts
|
|
170
|
-
var safeExit = (func, exitOnFail = true) => {
|
|
171
|
-
try {
|
|
172
|
-
const result = func();
|
|
173
|
-
if (result && exitOnFail) {
|
|
174
|
-
process.exit(result);
|
|
175
|
-
}
|
|
176
|
-
return result;
|
|
177
|
-
} catch (ex) {
|
|
178
|
-
return processEx(ex);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
var safeExitAsync = async (func, exitOnFail = true) => {
|
|
182
|
-
try {
|
|
183
|
-
const result = await func();
|
|
184
|
-
if (result && exitOnFail) {
|
|
185
|
-
process.exit(result);
|
|
186
|
-
}
|
|
187
|
-
return result;
|
|
188
|
-
} catch (ex) {
|
|
189
|
-
return processEx(ex);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
// src/lib/dependencies/DuplicateDetector.ts
|
|
194
|
-
import { EOL } from "os";
|
|
195
|
-
import chalk3 from "chalk";
|
|
196
|
-
|
|
197
|
-
// src/lib/jsonFormatters.ts
|
|
198
|
-
var multiLineToJSONArray = (output) => {
|
|
199
|
-
const withCommas = output.replaceAll("\r\n", "").replaceAll("\n", ",");
|
|
200
|
-
const cleanCollection = withCommas.slice(0, Math.max(0, withCommas.length - 1));
|
|
201
|
-
const collection = `[${cleanCollection}]`;
|
|
202
|
-
return JSON.parse(collection);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
// src/lib/dependencies/DuplicateDetector.ts
|
|
206
|
-
var trimVirtualMeta = (value) => {
|
|
207
|
-
const virtualParts = value.split("virtual:");
|
|
208
|
-
if (virtualParts.length > 1) {
|
|
209
|
-
const hashParts = virtualParts[1].split("#");
|
|
210
|
-
return virtualParts[0] + hashParts[1];
|
|
211
|
-
} else {
|
|
212
|
-
return value;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
var trimObjectDependencyVirtualMeta = (obj) => {
|
|
216
|
-
const resultObj = {};
|
|
217
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
218
|
-
resultObj[trimVirtualMeta(key)] = {
|
|
219
|
-
descriptor: trimVirtualMeta(value.descriptor),
|
|
220
|
-
locator: trimVirtualMeta(value.locator)
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
return resultObj;
|
|
224
|
-
};
|
|
225
|
-
var trimDependencyVirtualMeta = (dependencies) => {
|
|
226
|
-
return dependencies.map((dependency) => {
|
|
227
|
-
return { children: trimObjectDependencyVirtualMeta(dependency.children), value: trimVirtualMeta(dependency.value) };
|
|
228
|
-
});
|
|
229
|
-
};
|
|
230
|
-
var DuplicateDetector = class {
|
|
231
|
-
dependency;
|
|
232
|
-
dependencyEntries;
|
|
233
|
-
constructor(output, dependency) {
|
|
234
|
-
this.dependency = dependency;
|
|
235
|
-
this.dependencyEntries = trimDependencyVirtualMeta(multiLineToJSONArray(output));
|
|
236
|
-
}
|
|
237
|
-
detect() {
|
|
238
|
-
const result = this.dependencyEntries.reduce(this.detectReducer, this.resultsFactory(this.dependency));
|
|
239
|
-
if (result.duplicateVersions.length > 0) {
|
|
240
|
-
console.log(chalk3.yellow(`${EOL}Duplicates found for: ${this.dependency}`));
|
|
241
|
-
const duplicateVersions = result.duplicateVersions.toString().replaceAll(",", `${EOL} `);
|
|
242
|
-
console.log(chalk3.grey(` ${duplicateVersions}`, EOL));
|
|
243
|
-
return 1;
|
|
244
|
-
} else {
|
|
245
|
-
console.log(`${this.dependency} - OK`);
|
|
246
|
-
return 0;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
detectReducer(acc, entry) {
|
|
250
|
-
const version = Object.entries(entry.children).map(([k]) => k)[0];
|
|
251
|
-
if (!acc.currentVersion) {
|
|
252
|
-
acc.currentVersion = version;
|
|
253
|
-
return acc;
|
|
254
|
-
}
|
|
255
|
-
if (acc.currentVersion && acc.currentVersion !== version && !version.includes("@virtual:")) {
|
|
256
|
-
if (acc.duplicateVersions.length === 0) {
|
|
257
|
-
acc.duplicateVersions.push(acc.currentVersion);
|
|
258
|
-
}
|
|
259
|
-
acc.duplicateVersions.push(version);
|
|
260
|
-
acc.duplicateVersions = [...new Set(acc.duplicateVersions)];
|
|
261
|
-
}
|
|
262
|
-
return acc;
|
|
263
|
-
}
|
|
264
|
-
resultsFactory = (dependency) => ({
|
|
265
|
-
currentVersion: void 0,
|
|
266
|
-
dependency,
|
|
267
|
-
duplicateVersions: []
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
// src/lib/dependencies/detectDuplicateDependencies.ts
|
|
272
|
-
var detectDuplicateDependencies = (depsFromPackageJSON, DefaultDependencies2) => {
|
|
273
|
-
let exitCode = 0;
|
|
274
|
-
const dependencies = depsFromPackageJSON?.length ? depsFromPackageJSON : DefaultDependencies2;
|
|
275
|
-
return safeExit(() => {
|
|
276
|
-
if (dependencies) {
|
|
277
|
-
for (const dependency of dependencies) {
|
|
278
|
-
let output;
|
|
279
|
-
try {
|
|
280
|
-
const cmd = `yarn why ${dependency} --json`;
|
|
281
|
-
output = execSync(cmd).toString();
|
|
282
|
-
} catch (e) {
|
|
283
|
-
console.error(`Error running yarn why: ${e}`);
|
|
284
|
-
exitCode = 1;
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
if (output) {
|
|
288
|
-
exitCode = new DuplicateDetector(output, dependency).detect();
|
|
289
|
-
} else {
|
|
290
|
-
console.log(`${dependency} - N/A`);
|
|
291
|
-
if (depsFromPackageJSON) {
|
|
292
|
-
exitCode = 1;
|
|
293
|
-
console.log(`\u{1F6A8} Library ${dependency} was requested in package.json but not found`);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return exitCode;
|
|
298
|
-
} else {
|
|
299
|
-
console.log("\u{1F6A8} No dependencies where passed");
|
|
300
|
-
return exitCode;
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
// src/lib/file/constants.ts
|
|
306
|
-
var WINDOWS_NEWLINE_REGEX = /\r\n/g;
|
|
307
|
-
var CROSS_PLATFORM_NEWLINE = "\n";
|
|
308
|
-
|
|
309
|
-
// src/lib/file/fileLines.ts
|
|
310
|
-
import {
|
|
311
|
-
existsSync,
|
|
312
|
-
readFileSync as readFileSync3,
|
|
313
|
-
writeFileSync
|
|
314
|
-
} from "fs";
|
|
315
|
-
|
|
316
|
-
// src/lib/string/empty.ts
|
|
317
|
-
var empty = (value) => value?.trim().length === 0;
|
|
318
|
-
var notEmpty = (value) => !empty(value);
|
|
319
|
-
|
|
320
|
-
// src/lib/string/union.ts
|
|
321
|
-
var union = (a, b) => /* @__PURE__ */ new Set([...new Set(a), ...new Set(b)]);
|
|
322
|
-
|
|
323
|
-
// src/lib/file/ReadFileSyncOptions.ts
|
|
324
|
-
var defaultReadFileSyncOptions = { encoding: "utf8" };
|
|
325
|
-
|
|
326
|
-
// src/lib/file/fileLines.ts
|
|
327
|
-
var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync(uri) ? readFileSync3(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : [];
|
|
328
|
-
var readNonEmptyLines = (uri, options = defaultReadFileSyncOptions) => readLines(uri, options).filter(notEmpty);
|
|
329
|
-
var writeLines = (uri, lines, options = defaultReadFileSyncOptions) => {
|
|
330
|
-
const existing = existsSync(uri) ? readFileSync3(uri, options) : void 0;
|
|
331
|
-
const desired = lines.join(CROSS_PLATFORM_NEWLINE);
|
|
332
|
-
if (existing !== desired) writeFileSync(uri, desired, options);
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
// src/lib/file/tryReadFileSync.ts
|
|
336
|
-
import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
|
|
337
|
-
var tryReadFileSync = (uri, options = defaultReadFileSyncOptions) => {
|
|
338
|
-
return existsSync2(uri) ? readFileSync4(uri, options) : void 0;
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
// src/lib/generateIgnoreFiles.ts
|
|
342
|
-
import chalk4 from "chalk";
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { registerPackageManager } from "@xylabs/ts-scripts-common";
|
|
343
3
|
|
|
344
4
|
// src/lib/yarn/isYarnVersionOrGreater.ts
|
|
345
5
|
import { spawnSync } from "child_process";
|
|
@@ -375,3787 +35,247 @@ var yarnWorkspace = (pkg) => {
|
|
|
375
35
|
return workspace;
|
|
376
36
|
};
|
|
377
37
|
|
|
378
|
-
// src/
|
|
379
|
-
var
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
var generateIgnoreFiles = (filename2, pkg) => {
|
|
388
|
-
console.log(chalk4.green(`Generate ${filename2} Files`));
|
|
389
|
-
const cwd5 = INIT_CWD() ?? ".";
|
|
390
|
-
const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces();
|
|
391
|
-
const readEntries = (location) => readNonEmptyLines(`${location}/${filename2}`);
|
|
392
|
-
const writeEntries = (location, entries) => writeLines(`${location}/${filename2}`, entries);
|
|
393
|
-
const results = workspaces.map(({ location, name }) => {
|
|
394
|
-
try {
|
|
395
|
-
writeEntries(location, mergeEntries(readEntries(cwd5), readEntries(location)));
|
|
396
|
-
return 0;
|
|
397
|
-
} catch (ex) {
|
|
398
|
-
const error = ex;
|
|
399
|
-
console.error(`Generate ${filename2} Files [${name}] [${error.message}]`);
|
|
400
|
-
return 1;
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
const succeeded = results.every((result) => result === 0);
|
|
404
|
-
return succeeded ? 0 : 1;
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
// src/lib/generateReadmeFiles.ts
|
|
408
|
-
import { execSync as execSync2 } from "child_process";
|
|
409
|
-
import FS, { readFileSync as readFileSync5 } from "fs";
|
|
410
|
-
import {
|
|
411
|
-
mkdir,
|
|
412
|
-
readFile,
|
|
413
|
-
writeFile
|
|
414
|
-
} from "fs/promises";
|
|
415
|
-
import { createRequire as createRequire2 } from "module";
|
|
416
|
-
import PATH2 from "path";
|
|
417
|
-
import { createInterface } from "readline";
|
|
418
|
-
import chalk5 from "chalk";
|
|
419
|
-
var require3 = createRequire2(import.meta.url);
|
|
420
|
-
var packageRoot2 = PATH2.dirname(require3.resolve("@xylabs/ts-scripts-yarn3/package.json"));
|
|
421
|
-
var readmeTemplatesDir = PATH2.resolve(packageRoot2, "templates", "readme");
|
|
422
|
-
function fillTemplate(template, data) {
|
|
423
|
-
const additionalData = { ...data, safeName: data.name.replaceAll("/", "__").replaceAll("@", "") };
|
|
424
|
-
return template.replaceAll(/\{\{(.*?)\}\}/g, (_, key) => additionalData[key.trim()] ?? "");
|
|
425
|
-
}
|
|
426
|
-
function generateTypedoc(packageLocation, entryPoints) {
|
|
427
|
-
const tempDir = PATH2.join(packageLocation, ".temp-typedoc");
|
|
428
|
-
try {
|
|
429
|
-
if (!FS.existsSync(tempDir)) {
|
|
430
|
-
FS.mkdirSync(tempDir, { recursive: true });
|
|
431
|
-
}
|
|
432
|
-
const typedocConfig = {
|
|
433
|
-
disableSources: true,
|
|
434
|
-
entryPointStrategy: "expand",
|
|
435
|
-
entryPoints: entryPoints.map((ep) => PATH2.resolve(packageLocation, ep)),
|
|
436
|
-
excludeExternals: true,
|
|
437
|
-
excludeInternal: true,
|
|
438
|
-
excludePrivate: true,
|
|
439
|
-
githubPages: false,
|
|
440
|
-
hideBreadcrumbs: true,
|
|
441
|
-
hideGenerator: true,
|
|
442
|
-
hidePageTitle: true,
|
|
443
|
-
out: tempDir,
|
|
444
|
-
plugin: ["typedoc-plugin-markdown"],
|
|
445
|
-
readme: "none",
|
|
446
|
-
skipErrorChecking: true,
|
|
447
|
-
sort: ["source-order"],
|
|
448
|
-
theme: "markdown",
|
|
449
|
-
useCodeBlocks: true
|
|
450
|
-
};
|
|
451
|
-
const typedocJsonPath = PATH2.join(tempDir, "typedoc.json");
|
|
452
|
-
FS.writeFileSync(typedocJsonPath, JSON.stringify(typedocConfig, null, 2));
|
|
453
|
-
try {
|
|
454
|
-
execSync2(`npx typedoc --options ${typedocJsonPath}`, {
|
|
455
|
-
cwd: process.cwd(),
|
|
456
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
457
|
-
});
|
|
458
|
-
} catch {
|
|
459
|
-
return "";
|
|
460
|
-
}
|
|
461
|
-
return consolidateMarkdown(tempDir);
|
|
462
|
-
} catch {
|
|
463
|
-
return "";
|
|
464
|
-
} finally {
|
|
38
|
+
// src/pm/yarnPackageManager.ts
|
|
39
|
+
var YarnPackageManager = class {
|
|
40
|
+
command = "yarn";
|
|
41
|
+
lockfile = "yarn.lock";
|
|
42
|
+
name = "yarn";
|
|
43
|
+
dedupe() {
|
|
44
|
+
return ["yarn", ["dedupe"]];
|
|
45
|
+
}
|
|
46
|
+
findWorkspace(name) {
|
|
465
47
|
try {
|
|
466
|
-
|
|
48
|
+
return yarnWorkspace(name);
|
|
467
49
|
} catch {
|
|
50
|
+
return void 0;
|
|
468
51
|
}
|
|
469
52
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const mainContent = FS.readFileSync(mainReadmePath, "utf8").replace(/^---(.|\n)*?---\n/, "").replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
|
|
476
|
-
consolidated += mainContent + "\n\n";
|
|
477
|
-
}
|
|
478
|
-
consolidated += processDirectory(tempDir);
|
|
479
|
-
return consolidated.replaceAll(/\n\n\n+/g, "\n\n").replaceAll(/^#### /gm, "### ").replaceAll(/^##### /gm, "#### ").replaceAll(/^###### /gm, "##### ");
|
|
480
|
-
}
|
|
481
|
-
function processDirectory(dir, level = 0) {
|
|
482
|
-
const indent = " ".repeat(level);
|
|
483
|
-
let content = "";
|
|
484
|
-
try {
|
|
485
|
-
const items = FS.readdirSync(dir, { withFileTypes: true });
|
|
486
|
-
for (const item of items) {
|
|
487
|
-
if (item.isDirectory()) continue;
|
|
488
|
-
if (item.name === "README.md" || !item.name.endsWith(".md")) continue;
|
|
489
|
-
const fileContent = FS.readFileSync(PATH2.join(dir, item.name), "utf8").replace(/^---(.|\n)*?---\n/, "");
|
|
490
|
-
const moduleName = item.name.replace(".md", "");
|
|
491
|
-
content += `
|
|
492
|
-
|
|
493
|
-
${indent}### <a id="${moduleName}"></a>${moduleName}
|
|
494
|
-
|
|
495
|
-
`;
|
|
496
|
-
content += fileContent.replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
|
|
497
|
-
}
|
|
498
|
-
for (const item of items) {
|
|
499
|
-
if (!item.isDirectory()) continue;
|
|
500
|
-
if (item.name === "spec" || item.name.includes(".spec")) continue;
|
|
501
|
-
content += `
|
|
502
|
-
|
|
503
|
-
${indent}### ${item.name}
|
|
504
|
-
`;
|
|
505
|
-
content += processDirectory(PATH2.join(dir, item.name), level + 1);
|
|
506
|
-
}
|
|
507
|
-
} catch {
|
|
508
|
-
}
|
|
509
|
-
return content;
|
|
510
|
-
}
|
|
511
|
-
function askConfirmation(question) {
|
|
512
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
513
|
-
return new Promise((resolve) => {
|
|
514
|
-
rl.question(question, (answer) => {
|
|
515
|
-
rl.close();
|
|
516
|
-
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
var DEFAULT_README_TEMPLATE = readFileSync5(PATH2.resolve(readmeTemplatesDir, "README.template.md"), "utf8");
|
|
521
|
-
var DEFAULT_README_BODY = readFileSync5(PATH2.resolve(readmeTemplatesDir, "README.body.md"), "utf8");
|
|
522
|
-
function applyLogoConfig(template, logoUrl, logoLinkUrl) {
|
|
523
|
-
let result = template;
|
|
524
|
-
if (logoUrl) {
|
|
525
|
-
result = result.replace(/\[logo]: .+/, `[logo]: ${logoUrl}`);
|
|
526
|
-
if (logoLinkUrl) {
|
|
527
|
-
result = result.replace(/\[!\[logo]\[]][^)]*\)/, `[![logo][]](${logoLinkUrl})`);
|
|
528
|
-
}
|
|
529
|
-
} else {
|
|
530
|
-
result = result.replace(/\[!\[logo]\[]][^\n]*\n*/, "");
|
|
531
|
-
result = result.replace(/\[logo]: [^\n]*\n?/, "");
|
|
532
|
-
}
|
|
533
|
-
return result;
|
|
534
|
-
}
|
|
535
|
-
function resolveTemplatePath(templatePath) {
|
|
536
|
-
const cwd5 = INIT_CWD() ?? ".";
|
|
537
|
-
return templatePath ?? PATH2.join(cwd5, ".xy", "README.template.md");
|
|
538
|
-
}
|
|
539
|
-
async function loadOrCreateTemplate(resolvedTemplatePath) {
|
|
540
|
-
try {
|
|
541
|
-
const template = await readFile(resolvedTemplatePath, "utf8");
|
|
542
|
-
return { created: false, template };
|
|
543
|
-
} catch {
|
|
544
|
-
console.log(chalk5.yellow(`Template not found: ${resolvedTemplatePath}`));
|
|
545
|
-
const shouldCreate = await askConfirmation("Would you like to create a stock template? (y/N) ");
|
|
546
|
-
if (!shouldCreate) {
|
|
547
|
-
throw new Error("Template creation declined");
|
|
548
|
-
}
|
|
549
|
-
const template = DEFAULT_README_TEMPLATE;
|
|
550
|
-
await scaffoldTemplate(resolvedTemplatePath, template);
|
|
551
|
-
return { created: true, template };
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
async function scaffoldTemplate(resolvedTemplatePath, template) {
|
|
555
|
-
const xyDir = PATH2.dirname(resolvedTemplatePath);
|
|
556
|
-
await mkdir(xyDir, { recursive: true });
|
|
557
|
-
await writeFile(resolvedTemplatePath, template);
|
|
558
|
-
console.log(chalk5.green(`Created template: ${resolvedTemplatePath}`));
|
|
559
|
-
const bodyPath = PATH2.join(xyDir, "README.body.md");
|
|
560
|
-
await writeFile(bodyPath, DEFAULT_README_BODY);
|
|
561
|
-
console.log(chalk5.green(`Created body template: ${bodyPath}`));
|
|
562
|
-
}
|
|
563
|
-
async function resolveBody(location, defaultBody) {
|
|
564
|
-
const localBodyPath = PATH2.join(location, "README.body.md");
|
|
565
|
-
try {
|
|
566
|
-
return await readFile(localBodyPath, "utf8");
|
|
567
|
-
} catch {
|
|
568
|
-
return defaultBody;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
async function generateReadmeForWorkspace(location, name, template, defaultBody, typedoc, verbose) {
|
|
572
|
-
try {
|
|
573
|
-
const pkgJsonPath = PATH2.join(location, "package.json");
|
|
574
|
-
const pkgJson = JSON.parse(await readFile(pkgJsonPath, "utf8"));
|
|
575
|
-
const body = await resolveBody(location, defaultBody);
|
|
576
|
-
const typedocContent = typedoc ? generateTypedoc(location, ["src/index*.ts"]) : "";
|
|
577
|
-
const readmeContent = fillTemplate(template, {
|
|
578
|
-
...pkgJson,
|
|
579
|
-
body,
|
|
580
|
-
typedoc: typedocContent
|
|
581
|
-
});
|
|
582
|
-
await writeFile(PATH2.join(location, "README.md"), readmeContent);
|
|
583
|
-
if (verbose) console.log(chalk5.green(` ${name}`));
|
|
584
|
-
return true;
|
|
585
|
-
} catch (ex) {
|
|
586
|
-
const error = ex;
|
|
587
|
-
console.warn(chalk5.yellow(` Skipped ${location}: ${error.message}`));
|
|
588
|
-
return false;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
async function generateReadmeFiles({
|
|
592
|
-
logoLinkUrl,
|
|
593
|
-
logoUrl,
|
|
594
|
-
pkg,
|
|
595
|
-
templatePath,
|
|
596
|
-
typedoc = false,
|
|
597
|
-
verbose = false
|
|
598
|
-
}) {
|
|
599
|
-
console.log(chalk5.green("Generate README Files"));
|
|
600
|
-
const resolvedTemplatePath = resolveTemplatePath(templatePath);
|
|
601
|
-
let template;
|
|
602
|
-
let templateCreated;
|
|
603
|
-
try {
|
|
604
|
-
({ template, created: templateCreated } = await loadOrCreateTemplate(resolvedTemplatePath));
|
|
605
|
-
} catch {
|
|
606
|
-
return 1;
|
|
607
|
-
}
|
|
608
|
-
template = applyLogoConfig(template, logoUrl, logoLinkUrl);
|
|
609
|
-
if (templateCreated) {
|
|
610
|
-
console.log(chalk5.green("Generating README files for all packages..."));
|
|
611
|
-
}
|
|
612
|
-
const xyDir = PATH2.dirname(resolvedTemplatePath);
|
|
613
|
-
const xyBodyPath = PATH2.join(xyDir, "README.body.md");
|
|
614
|
-
let defaultBody;
|
|
615
|
-
try {
|
|
616
|
-
defaultBody = await readFile(xyBodyPath, "utf8");
|
|
617
|
-
} catch {
|
|
618
|
-
defaultBody = DEFAULT_README_BODY;
|
|
619
|
-
}
|
|
620
|
-
const workspaces = pkg && !templateCreated ? [yarnWorkspace(pkg)] : yarnWorkspaces();
|
|
621
|
-
let failed = false;
|
|
622
|
-
for (const { location, name } of workspaces) {
|
|
623
|
-
const success = await generateReadmeForWorkspace(location, name, template, defaultBody, typedoc, verbose);
|
|
624
|
-
if (!success) failed = true;
|
|
625
|
-
}
|
|
626
|
-
return failed ? 1 : 0;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// src/lib/gitignoreTemplate.ts
|
|
630
|
-
import { readFileSync as readFileSync6 } from "fs";
|
|
631
|
-
import { createRequire as createRequire3 } from "module";
|
|
632
|
-
import PATH3 from "path";
|
|
633
|
-
var require4 = createRequire3(import.meta.url);
|
|
634
|
-
var packageRoot3 = PATH3.dirname(require4.resolve("@xylabs/ts-scripts-yarn3/package.json"));
|
|
635
|
-
var templatesDir2 = PATH3.resolve(packageRoot3, "templates", "gitignore");
|
|
636
|
-
var gitignoreTemplate = () => readFileSync6(PATH3.resolve(templatesDir2, "template.gitignore"), "utf8");
|
|
637
|
-
|
|
638
|
-
// src/lib/loadConfig.ts
|
|
639
|
-
import chalk6 from "chalk";
|
|
640
|
-
import { cosmiconfig } from "cosmiconfig";
|
|
641
|
-
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
642
|
-
import deepmerge from "deepmerge";
|
|
643
|
-
var config;
|
|
644
|
-
var loadConfig = async (params) => {
|
|
645
|
-
if (config === void 0) {
|
|
646
|
-
const cosmicConfigResult = await cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } }).search();
|
|
647
|
-
config = cosmicConfigResult?.config;
|
|
648
|
-
const configFilePath = cosmicConfigResult?.filepath;
|
|
649
|
-
if (configFilePath !== void 0) {
|
|
650
|
-
console.log(chalk6.green(`Loaded config from ${configFilePath}`));
|
|
651
|
-
if (config.verbose) {
|
|
652
|
-
console.log(chalk6.gray(`${JSON.stringify(config, null, 2)}`));
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
return deepmerge(config, params ?? {});
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
// src/lib/parsedPackageJSON.ts
|
|
660
|
-
import { readFileSync as readFileSync7 } from "fs";
|
|
661
|
-
var parsedPackageJSON = (path14) => {
|
|
662
|
-
const pathToPackageJSON = path14 ?? process.env.npm_package_json ?? "";
|
|
663
|
-
const packageJSON = readFileSync7(pathToPackageJSON).toString();
|
|
664
|
-
return JSON.parse(packageJSON);
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
// src/lib/runSteps.ts
|
|
668
|
-
import { spawnSync as spawnSync3 } from "child_process";
|
|
669
|
-
import { existsSync as existsSync3 } from "fs";
|
|
670
|
-
import chalk7 from "chalk";
|
|
671
|
-
var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
672
|
-
return safeExit(() => {
|
|
673
|
-
const pkgName = process.env.npm_package_name;
|
|
674
|
-
console.log(chalk7.green(`${name} [${pkgName}]`));
|
|
675
|
-
let totalStatus = 0;
|
|
676
|
-
for (const [i, [command, args, config2]] of steps.entries()) {
|
|
677
|
-
if (messages?.[i]) {
|
|
678
|
-
console.log(chalk7.gray(messages?.[i]));
|
|
679
|
-
}
|
|
680
|
-
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
681
|
-
if (command === "node" && !existsSync3(argList[0])) {
|
|
682
|
-
throw new Error(`File not found [${argList[0]}]`);
|
|
683
|
-
}
|
|
684
|
-
const status = spawnSync3(command, Array.isArray(args) ? args : args.split(" "), {
|
|
685
|
-
...config2,
|
|
686
|
-
encoding: "utf8",
|
|
687
|
-
env: { FORCE_COLOR: "3", ...process.env },
|
|
688
|
-
shell: true,
|
|
689
|
-
stdio: "inherit"
|
|
690
|
-
}).status ?? 0;
|
|
691
|
-
checkResult(name, status, "error", exitOnFail);
|
|
692
|
-
totalStatus += status ?? 0;
|
|
693
|
-
}
|
|
694
|
-
return totalStatus;
|
|
695
|
-
}, !!exitOnFail);
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
// src/lib/runStepsAsync.ts
|
|
699
|
-
import { spawn } from "child_process";
|
|
700
|
-
import { existsSync as existsSync4 } from "fs";
|
|
701
|
-
import chalk8 from "chalk";
|
|
702
|
-
var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
703
|
-
return new Promise((resolve) => {
|
|
704
|
-
const [command, args, config2] = step;
|
|
705
|
-
if (message) {
|
|
706
|
-
console.log(chalk8.gray(message));
|
|
707
|
-
}
|
|
708
|
-
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
709
|
-
if (command === "node" && !existsSync4(argList[0])) {
|
|
710
|
-
throw new Error(`File not found [${argList[0]}]`);
|
|
711
|
-
}
|
|
712
|
-
spawn(command, Array.isArray(args) ? args : args.split(" "), {
|
|
713
|
-
...config2,
|
|
714
|
-
env: { FORCE_COLOR: "3", ...process.env },
|
|
715
|
-
shell: true,
|
|
716
|
-
stdio: "inherit"
|
|
717
|
-
}).on("close", (code) => {
|
|
718
|
-
if (code) {
|
|
719
|
-
console.error(
|
|
720
|
-
chalk8.red(
|
|
721
|
-
`Command Exited With Non-Zero Result [${chalk8.gray(code)}] | ${chalk8.yellow(command)} ${chalk8.white(
|
|
722
|
-
Array.isArray(args) ? args.join(" ") : args
|
|
723
|
-
)}`
|
|
724
|
-
)
|
|
725
|
-
);
|
|
726
|
-
checkResult(name, code, "error", exitOnFail);
|
|
727
|
-
resolve(code);
|
|
728
|
-
} else {
|
|
729
|
-
resolve(0);
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
});
|
|
733
|
-
};
|
|
734
|
-
var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
|
|
735
|
-
return await safeExitAsync(async () => {
|
|
736
|
-
const pkgName = process.env.npm_package_name;
|
|
737
|
-
console.log(chalk8.green(`${name} [${pkgName}]`));
|
|
738
|
-
let result = 0;
|
|
739
|
-
for (const [i, step] of steps.entries()) {
|
|
740
|
-
result += await runStepAsync(name, step, exitOnFail, messages?.[i]);
|
|
741
|
-
}
|
|
742
|
-
return result;
|
|
743
|
-
});
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
// src/lib/runXy.ts
|
|
747
|
-
var runXy = (command) => {
|
|
748
|
-
return runSteps(
|
|
749
|
-
`XY [${command}]`,
|
|
750
|
-
[["yarn", ["xy", command, ...process.argv.filter((value, index) => index > 1 ? value : void 0)]]]
|
|
751
|
-
);
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
// src/lib/runXyWithWarning.ts
|
|
755
|
-
import chalk9 from "chalk";
|
|
756
|
-
var runXyWithWarning = (command) => {
|
|
757
|
-
const commandString = `yarn ${command}`;
|
|
758
|
-
const commandXyString = `yarn xy ${command}`;
|
|
759
|
-
console.warn(chalk9.yellow(`WARNING: [${chalk9.white(commandString)}] is deprecated for XY Labs Scripts.`));
|
|
760
|
-
console.warn(chalk9.gray(`Did you mean [${chalk9.magenta(commandXyString)}]?`));
|
|
761
|
-
return 1;
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
// src/lib/tryRunLocalScript.ts
|
|
765
|
-
import { spawnSync as spawnSync4 } from "child_process";
|
|
766
|
-
import { readFileSync as readFileSync8 } from "fs";
|
|
767
|
-
import PATH4 from "path";
|
|
768
|
-
import chalk10 from "chalk";
|
|
769
|
-
function tryRunLocalScript(commandName) {
|
|
770
|
-
if (process.env.XY_LOCAL_SCRIPT === "1") return void 0;
|
|
771
|
-
const rootPkgPath = PATH4.resolve(process.cwd(), "package.json");
|
|
772
|
-
let rootPkg;
|
|
773
|
-
try {
|
|
774
|
-
rootPkg = JSON.parse(readFileSync8(rootPkgPath, "utf8"));
|
|
775
|
-
} catch {
|
|
776
|
-
return void 0;
|
|
777
|
-
}
|
|
778
|
-
if (!rootPkg.scripts?.[commandName]) return void 0;
|
|
779
|
-
console.log(chalk10.blue(`Delegating "${commandName}" to local script`));
|
|
780
|
-
const result = spawnSync4("yarn", ["run", commandName], {
|
|
781
|
-
cwd: process.cwd(),
|
|
782
|
-
encoding: "utf8",
|
|
783
|
-
env: {
|
|
784
|
-
FORCE_COLOR: "3",
|
|
785
|
-
...process.env,
|
|
786
|
-
XY_LOCAL_SCRIPT: "1"
|
|
787
|
-
},
|
|
788
|
-
shell: true,
|
|
789
|
-
stdio: "inherit"
|
|
790
|
-
});
|
|
791
|
-
return result.status ?? 1;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
// src/actions/build.ts
|
|
795
|
-
var build = async ({
|
|
796
|
-
incremental,
|
|
797
|
-
jobs,
|
|
798
|
-
target,
|
|
799
|
-
verbose,
|
|
800
|
-
pkg
|
|
801
|
-
}) => {
|
|
802
|
-
const start = Date.now();
|
|
803
|
-
const pkgOptions = pkg === void 0 ? [] : [pkg];
|
|
804
|
-
const incrementalOptions = incremental ? ["-i"] : [];
|
|
805
|
-
const verboseOptions = verbose ? ["-v"] : [];
|
|
806
|
-
const targetOptions = target === void 0 ? [] : ["-t", target];
|
|
807
|
-
const jobsOptions = jobs === void 0 ? [] : ["-j", `${jobs}`];
|
|
808
|
-
if (jobs !== void 0) {
|
|
809
|
-
console.log(chalk11.blue(`Jobs set to [${jobs}]`));
|
|
810
|
-
}
|
|
811
|
-
const result = await runStepsAsync(`Build${incremental ? "-Incremental" : ""} [${pkg ?? "All"}]`, [
|
|
812
|
-
["yarn", ["xy", "compile", ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions, "--types", "tsup"]],
|
|
813
|
-
["yarn", ["xy", "publint", ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
|
|
814
|
-
["yarn", ["xy", "deplint", ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
|
|
815
|
-
["yarn", ["xy", "lint", ...pkgOptions, ...verboseOptions, ...incrementalOptions]]
|
|
816
|
-
]);
|
|
817
|
-
console.log(`${chalk11.gray("Built in")} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`);
|
|
818
|
-
return result;
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
// src/actions/claude-clean.ts
|
|
822
|
-
import {
|
|
823
|
-
existsSync as existsSync5,
|
|
824
|
-
readdirSync as readdirSync2,
|
|
825
|
-
rmSync,
|
|
826
|
-
unlinkSync
|
|
827
|
-
} from "fs";
|
|
828
|
-
import PATH5 from "path";
|
|
829
|
-
import chalk12 from "chalk";
|
|
830
|
-
function removeFile(filePath, label) {
|
|
831
|
-
if (existsSync5(filePath)) {
|
|
832
|
-
unlinkSync(filePath);
|
|
833
|
-
console.log(chalk12.yellow(` Removed ${label}`));
|
|
834
|
-
return true;
|
|
835
|
-
}
|
|
836
|
-
return false;
|
|
837
|
-
}
|
|
838
|
-
function removeDir(dirPath, label) {
|
|
839
|
-
if (existsSync5(dirPath)) {
|
|
840
|
-
rmSync(dirPath, { recursive: true });
|
|
841
|
-
console.log(chalk12.yellow(` Removed ${label}`));
|
|
842
|
-
return true;
|
|
843
|
-
}
|
|
844
|
-
return false;
|
|
845
|
-
}
|
|
846
|
-
function claudeClean() {
|
|
847
|
-
console.log(chalk12.green("Clean Claude configuration"));
|
|
848
|
-
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
849
|
-
let removed = 0;
|
|
850
|
-
const rootFiles = ["CLAUDE.md", "CLAUDE.local.md"];
|
|
851
|
-
for (const file of rootFiles) {
|
|
852
|
-
if (removeFile(PATH5.resolve(cwd5, file), file)) removed++;
|
|
853
|
-
}
|
|
854
|
-
if (removeDir(PATH5.resolve(cwd5, ".claude"), ".claude/")) removed++;
|
|
855
|
-
const packagesDir = PATH5.resolve(cwd5, "packages");
|
|
856
|
-
if (existsSync5(packagesDir)) {
|
|
857
|
-
const findClaudeFiles = (dir, prefix) => {
|
|
858
|
-
const entries = readdirSync2(dir, { withFileTypes: true });
|
|
859
|
-
for (const entry of entries) {
|
|
860
|
-
const fullPath = PATH5.resolve(dir, entry.name);
|
|
861
|
-
const label = `${prefix}${entry.name}`;
|
|
862
|
-
if (entry.isFile() && (entry.name === "CLAUDE.md" || entry.name === "CLAUDE.local.md")) {
|
|
863
|
-
if (removeFile(fullPath, label)) removed++;
|
|
864
|
-
} else if (entry.isDirectory() && entry.name === ".claude") {
|
|
865
|
-
if (removeDir(fullPath, `${label}/`)) removed++;
|
|
866
|
-
} else if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "dist") {
|
|
867
|
-
findClaudeFiles(fullPath, `${label}/`);
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
findClaudeFiles(packagesDir, "packages/");
|
|
872
|
-
}
|
|
873
|
-
if (removed > 0) {
|
|
874
|
-
console.log(chalk12.green(` Removed ${removed} item(s)`));
|
|
875
|
-
} else {
|
|
876
|
-
console.log(chalk12.gray(" Nothing to clean"));
|
|
877
|
-
}
|
|
878
|
-
return 0;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
// src/actions/claude-commands.ts
|
|
882
|
-
import {
|
|
883
|
-
existsSync as existsSync6,
|
|
884
|
-
mkdirSync,
|
|
885
|
-
readdirSync as readdirSync3,
|
|
886
|
-
readFileSync as readFileSync9,
|
|
887
|
-
unlinkSync as unlinkSync2,
|
|
888
|
-
writeFileSync as writeFileSync2
|
|
889
|
-
} from "fs";
|
|
890
|
-
import PATH6 from "path";
|
|
891
|
-
import chalk13 from "chalk";
|
|
892
|
-
var syncCommandFiles = (commandsDir) => {
|
|
893
|
-
const templates = claudeCommandTemplates();
|
|
894
|
-
const templateNames = new Set(Object.keys(templates));
|
|
895
|
-
let updated = 0;
|
|
896
|
-
let created = 0;
|
|
897
|
-
for (const [filename2, content] of Object.entries(templates)) {
|
|
898
|
-
const targetPath = PATH6.resolve(commandsDir, filename2);
|
|
899
|
-
const existing = existsSync6(targetPath) ? readFileSync9(targetPath, "utf8") : void 0;
|
|
900
|
-
if (existing === content) continue;
|
|
901
|
-
writeFileSync2(targetPath, content, "utf8");
|
|
902
|
-
if (existing) {
|
|
903
|
-
updated++;
|
|
904
|
-
} else {
|
|
905
|
-
created++;
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
return {
|
|
909
|
-
created,
|
|
910
|
-
templateNames,
|
|
911
|
-
updated
|
|
912
|
-
};
|
|
913
|
-
};
|
|
914
|
-
var removeStaleCommands = (commandsDir, templateNames) => {
|
|
915
|
-
const existingCommands = readdirSync3(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
|
|
916
|
-
let removed = 0;
|
|
917
|
-
for (const file of existingCommands) {
|
|
918
|
-
if (!templateNames.has(file)) {
|
|
919
|
-
unlinkSync2(PATH6.resolve(commandsDir, file));
|
|
920
|
-
removed++;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
return removed;
|
|
924
|
-
};
|
|
925
|
-
var removeLegacyCommands = (commandsDir) => {
|
|
926
|
-
const legacyFiles = readdirSync3(commandsDir).filter((f) => f.startsWith(LEGACY_COMMANDS_PREFIX) && f.endsWith(".md"));
|
|
927
|
-
for (const file of legacyFiles) {
|
|
928
|
-
unlinkSync2(PATH6.resolve(commandsDir, file));
|
|
929
|
-
}
|
|
930
|
-
return legacyFiles.length;
|
|
931
|
-
};
|
|
932
|
-
var logCommandsResult = (created, updated, removed) => {
|
|
933
|
-
if (created || updated || removed) {
|
|
934
|
-
const parts = [
|
|
935
|
-
created ? `${created} created` : "",
|
|
936
|
-
updated ? `${updated} updated` : "",
|
|
937
|
-
removed ? `${removed} removed` : ""
|
|
938
|
-
].filter(Boolean);
|
|
939
|
-
console.log(chalk13.green(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: ${parts.join(", ")}`));
|
|
940
|
-
} else {
|
|
941
|
-
console.log(chalk13.gray(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: already up to date`));
|
|
942
|
-
}
|
|
943
|
-
};
|
|
944
|
-
var claudeCommands = () => {
|
|
945
|
-
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
946
|
-
const commandsDir = PATH6.resolve(cwd5, ".claude", "commands");
|
|
947
|
-
mkdirSync(commandsDir, { recursive: true });
|
|
948
|
-
const legacy = removeLegacyCommands(commandsDir);
|
|
949
|
-
const {
|
|
950
|
-
created,
|
|
951
|
-
templateNames,
|
|
952
|
-
updated
|
|
953
|
-
} = syncCommandFiles(commandsDir);
|
|
954
|
-
const removed = removeStaleCommands(commandsDir, templateNames);
|
|
955
|
-
logCommandsResult(created, updated, removed + legacy);
|
|
956
|
-
return 0;
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
// src/actions/claude-rules.ts
|
|
960
|
-
import { spawnSync as spawnSync5 } from "child_process";
|
|
961
|
-
import {
|
|
962
|
-
existsSync as existsSync7,
|
|
963
|
-
mkdirSync as mkdirSync2,
|
|
964
|
-
readdirSync as readdirSync4,
|
|
965
|
-
readFileSync as readFileSync10,
|
|
966
|
-
unlinkSync as unlinkSync3,
|
|
967
|
-
writeFileSync as writeFileSync3
|
|
968
|
-
} from "fs";
|
|
969
|
-
import PATH7 from "path";
|
|
970
|
-
import chalk14 from "chalk";
|
|
971
|
-
var syncRuleFiles = (rulesDir) => {
|
|
972
|
-
const templates = claudeMdRuleTemplates();
|
|
973
|
-
const templateNames = new Set(Object.keys(templates));
|
|
974
|
-
let updated = 0;
|
|
975
|
-
let created = 0;
|
|
976
|
-
for (const [filename2, content] of Object.entries(templates)) {
|
|
977
|
-
const targetPath = PATH7.resolve(rulesDir, filename2);
|
|
978
|
-
const existing = existsSync7(targetPath) ? readFileSync10(targetPath, "utf8") : void 0;
|
|
979
|
-
if (existing === content) continue;
|
|
980
|
-
writeFileSync3(targetPath, content, "utf8");
|
|
981
|
-
if (existing) {
|
|
982
|
-
updated++;
|
|
983
|
-
} else {
|
|
984
|
-
created++;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
return {
|
|
988
|
-
created,
|
|
989
|
-
templateNames,
|
|
990
|
-
updated
|
|
991
|
-
};
|
|
992
|
-
};
|
|
993
|
-
var removeStaleRules = (rulesDir, templateNames) => {
|
|
994
|
-
const existingRules = readdirSync4(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
|
|
995
|
-
let removed = 0;
|
|
996
|
-
for (const file of existingRules) {
|
|
997
|
-
if (!templateNames.has(file)) {
|
|
998
|
-
unlinkSync3(PATH7.resolve(rulesDir, file));
|
|
999
|
-
removed++;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
return removed;
|
|
1003
|
-
};
|
|
1004
|
-
var logRulesResult = (created, updated, removed) => {
|
|
1005
|
-
if (created || updated || removed) {
|
|
1006
|
-
const parts = [
|
|
1007
|
-
created ? `${created} created` : "",
|
|
1008
|
-
updated ? `${updated} updated` : "",
|
|
1009
|
-
removed ? `${removed} removed` : ""
|
|
1010
|
-
].filter(Boolean);
|
|
1011
|
-
console.log(chalk14.green(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: ${parts.join(", ")}`));
|
|
1012
|
-
} else {
|
|
1013
|
-
console.log(chalk14.gray(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: already up to date`));
|
|
1014
|
-
}
|
|
1015
|
-
};
|
|
1016
|
-
var ensureProjectClaudeMd = (cwd5, force) => {
|
|
1017
|
-
const projectPath = PATH7.resolve(cwd5, "CLAUDE.md");
|
|
1018
|
-
if (!existsSync7(projectPath) || force) {
|
|
1019
|
-
if (force && existsSync7(projectPath)) {
|
|
1020
|
-
console.log(chalk14.yellow("Regenerating CLAUDE.md"));
|
|
1021
|
-
}
|
|
1022
|
-
console.log(chalk14.green("Generating CLAUDE.md via claude /init..."));
|
|
1023
|
-
const result = spawnSync5("claude", ["-p", "/init", "--allowedTools", "Read", "Write", "Glob", "Grep"], {
|
|
1024
|
-
cwd: cwd5,
|
|
1025
|
-
shell: true,
|
|
1026
|
-
stdio: "inherit"
|
|
1027
|
-
});
|
|
1028
|
-
if (result.status !== 0) {
|
|
1029
|
-
console.error(chalk14.red("claude /init failed \u2014 is Claude Code installed?"));
|
|
1030
|
-
return 1;
|
|
1031
|
-
}
|
|
1032
|
-
} else {
|
|
1033
|
-
console.log(chalk14.gray("CLAUDE.md already exists (skipped, use --force to regenerate)"));
|
|
1034
|
-
}
|
|
1035
|
-
return 0;
|
|
1036
|
-
};
|
|
1037
|
-
var ensureLocalClaudeMd = (cwd5) => {
|
|
1038
|
-
const localPath = PATH7.resolve(cwd5, "CLAUDE.local.md");
|
|
1039
|
-
if (existsSync7(localPath)) {
|
|
1040
|
-
console.log(chalk14.gray("CLAUDE.local.md already exists (skipped)"));
|
|
1041
|
-
} else {
|
|
1042
|
-
writeFileSync3(localPath, claudeMdLocalTemplate(), "utf8");
|
|
1043
|
-
console.log(chalk14.green("Generated CLAUDE.local.md"));
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
var claudeRules = ({ force } = {}) => {
|
|
1047
|
-
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
1048
|
-
const rulesDir = PATH7.resolve(cwd5, ".claude", "rules");
|
|
1049
|
-
mkdirSync2(rulesDir, { recursive: true });
|
|
1050
|
-
const {
|
|
1051
|
-
created,
|
|
1052
|
-
templateNames,
|
|
1053
|
-
updated
|
|
1054
|
-
} = syncRuleFiles(rulesDir);
|
|
1055
|
-
const removed = removeStaleRules(rulesDir, templateNames);
|
|
1056
|
-
logRulesResult(created, updated, removed);
|
|
1057
|
-
const claudeMdResult = ensureProjectClaudeMd(cwd5, force);
|
|
1058
|
-
ensureLocalClaudeMd(cwd5);
|
|
1059
|
-
return claudeMdResult ?? 0;
|
|
1060
|
-
};
|
|
1061
|
-
|
|
1062
|
-
// src/actions/claude-settings.ts
|
|
1063
|
-
import {
|
|
1064
|
-
existsSync as existsSync8,
|
|
1065
|
-
mkdirSync as mkdirSync3,
|
|
1066
|
-
writeFileSync as writeFileSync4
|
|
1067
|
-
} from "fs";
|
|
1068
|
-
import PATH8 from "path";
|
|
1069
|
-
import { createInterface as createInterface2 } from "readline";
|
|
1070
|
-
import chalk15 from "chalk";
|
|
1071
|
-
var DEFAULT_SETTINGS = {
|
|
1072
|
-
permissions: {
|
|
1073
|
-
allow: [
|
|
1074
|
-
"Bash(git *)",
|
|
1075
|
-
"Bash(yarn *)",
|
|
1076
|
-
"Bash(npx *)",
|
|
1077
|
-
"Bash(node *)",
|
|
1078
|
-
"Bash(ls *)",
|
|
1079
|
-
"Bash(mkdir *)",
|
|
1080
|
-
"Bash(cp *)",
|
|
1081
|
-
"Bash(mv *)",
|
|
1082
|
-
"Bash(rm *)",
|
|
1083
|
-
"Bash(cat *)",
|
|
1084
|
-
"Bash(head *)",
|
|
1085
|
-
"Bash(tail *)",
|
|
1086
|
-
"Bash(echo *)",
|
|
1087
|
-
"Bash(pwd)",
|
|
1088
|
-
"Bash(which *)",
|
|
1089
|
-
"Bash(grep *)",
|
|
1090
|
-
"Bash(find *)",
|
|
1091
|
-
"Bash(npm view *)",
|
|
1092
|
-
"Bash(gh *)",
|
|
1093
|
-
"Read",
|
|
1094
|
-
"Edit",
|
|
1095
|
-
"Write",
|
|
1096
|
-
"Glob",
|
|
1097
|
-
"Grep",
|
|
1098
|
-
"Skill"
|
|
1099
|
-
],
|
|
1100
|
-
deny: [
|
|
1101
|
-
"Bash(git push --force *)",
|
|
1102
|
-
"Bash(git reset --hard *)",
|
|
1103
|
-
"Bash(rm -rf /*)"
|
|
1104
|
-
]
|
|
1105
|
-
}
|
|
1106
|
-
};
|
|
1107
|
-
function askConfirmation2(question) {
|
|
1108
|
-
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
1109
|
-
return new Promise((resolve) => {
|
|
1110
|
-
rl.question(question, (answer) => {
|
|
1111
|
-
rl.close();
|
|
1112
|
-
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
1113
|
-
});
|
|
1114
|
-
});
|
|
1115
|
-
}
|
|
1116
|
-
async function claudeSettings() {
|
|
1117
|
-
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
1118
|
-
const claudeDir = PATH8.resolve(cwd5, ".claude");
|
|
1119
|
-
const settingsPath = PATH8.resolve(claudeDir, "settings.local.json");
|
|
1120
|
-
mkdirSync3(claudeDir, { recursive: true });
|
|
1121
|
-
if (existsSync8(settingsPath)) {
|
|
1122
|
-
const confirmed = await askConfirmation2(
|
|
1123
|
-
chalk15.yellow(`${settingsPath} already exists. Replace it? (y/N) `)
|
|
1124
|
-
);
|
|
1125
|
-
if (!confirmed) {
|
|
1126
|
-
console.log(chalk15.gray("Skipped \u2014 existing settings.local.json preserved"));
|
|
1127
|
-
return 0;
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
writeFileSync4(settingsPath, `${JSON.stringify(DEFAULT_SETTINGS, null, 2)}
|
|
1131
|
-
`, "utf8");
|
|
1132
|
-
console.log(chalk15.green("Generated .claude/settings.local.json"));
|
|
1133
|
-
return 0;
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
// src/actions/claude-skills.ts
|
|
1137
|
-
import {
|
|
1138
|
-
existsSync as existsSync9,
|
|
1139
|
-
mkdirSync as mkdirSync4,
|
|
1140
|
-
readdirSync as readdirSync5,
|
|
1141
|
-
readFileSync as readFileSync11,
|
|
1142
|
-
rmSync as rmSync2,
|
|
1143
|
-
statSync as statSync2,
|
|
1144
|
-
writeFileSync as writeFileSync5
|
|
1145
|
-
} from "fs";
|
|
1146
|
-
import PATH9 from "path";
|
|
1147
|
-
import chalk16 from "chalk";
|
|
1148
|
-
var syncSkillFiles = (skillsDir) => {
|
|
1149
|
-
const templates = claudeSkillTemplates();
|
|
1150
|
-
const templateNames = new Set(Object.keys(templates));
|
|
1151
|
-
let updated = 0;
|
|
1152
|
-
let created = 0;
|
|
1153
|
-
for (const [skillName, files] of Object.entries(templates)) {
|
|
1154
|
-
const skillDir = PATH9.resolve(skillsDir, skillName);
|
|
1155
|
-
mkdirSync4(skillDir, { recursive: true });
|
|
1156
|
-
for (const [filename2, content] of Object.entries(files)) {
|
|
1157
|
-
const targetPath = PATH9.resolve(skillDir, filename2);
|
|
1158
|
-
mkdirSync4(PATH9.dirname(targetPath), { recursive: true });
|
|
1159
|
-
const existing = existsSync9(targetPath) ? readFileSync11(targetPath, "utf8") : void 0;
|
|
1160
|
-
if (existing === content) continue;
|
|
1161
|
-
writeFileSync5(targetPath, content, "utf8");
|
|
1162
|
-
if (existing) {
|
|
1163
|
-
updated++;
|
|
1164
|
-
} else {
|
|
1165
|
-
created++;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
return {
|
|
1170
|
-
created,
|
|
1171
|
-
templateNames,
|
|
1172
|
-
updated
|
|
1173
|
-
};
|
|
1174
|
-
};
|
|
1175
|
-
var removeStaleSkills = (skillsDir, templateNames) => {
|
|
1176
|
-
const existingSkills = readdirSync5(skillsDir).filter(
|
|
1177
|
-
(f) => f.startsWith(XYLABS_SKILLS_PREFIX) && statSync2(PATH9.resolve(skillsDir, f)).isDirectory()
|
|
1178
|
-
);
|
|
1179
|
-
let removed = 0;
|
|
1180
|
-
for (const dir of existingSkills) {
|
|
1181
|
-
if (!templateNames.has(dir)) {
|
|
1182
|
-
rmSync2(PATH9.resolve(skillsDir, dir), { recursive: true });
|
|
1183
|
-
removed++;
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
return removed;
|
|
1187
|
-
};
|
|
1188
|
-
var logSkillsResult = (created, updated, removed) => {
|
|
1189
|
-
if (created || updated || removed) {
|
|
1190
|
-
const parts = [
|
|
1191
|
-
created ? `${created} created` : "",
|
|
1192
|
-
updated ? `${updated} updated` : "",
|
|
1193
|
-
removed ? `${removed} removed` : ""
|
|
1194
|
-
].filter(Boolean);
|
|
1195
|
-
console.log(chalk16.green(`.claude/skills/${XYLABS_SKILLS_PREFIX}*/: ${parts.join(", ")}`));
|
|
1196
|
-
} else {
|
|
1197
|
-
console.log(chalk16.gray(`.claude/skills/${XYLABS_SKILLS_PREFIX}*/: already up to date`));
|
|
1198
|
-
}
|
|
1199
|
-
};
|
|
1200
|
-
var claudeSkills = () => {
|
|
1201
|
-
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
1202
|
-
const skillsDir = PATH9.resolve(cwd5, ".claude", "skills");
|
|
1203
|
-
mkdirSync4(skillsDir, { recursive: true });
|
|
1204
|
-
const {
|
|
1205
|
-
created,
|
|
1206
|
-
templateNames,
|
|
1207
|
-
updated
|
|
1208
|
-
} = syncSkillFiles(skillsDir);
|
|
1209
|
-
const removed = removeStaleSkills(skillsDir, templateNames);
|
|
1210
|
-
logSkillsResult(created, updated, removed);
|
|
1211
|
-
return 0;
|
|
1212
|
-
};
|
|
1213
|
-
|
|
1214
|
-
// src/actions/clean.ts
|
|
1215
|
-
var clean = async ({ verbose, pkg }) => {
|
|
1216
|
-
return pkg ? await cleanPackage({ pkg, verbose }) : cleanAll({ verbose });
|
|
1217
|
-
};
|
|
1218
|
-
var cleanPackage = ({ pkg }) => {
|
|
1219
|
-
return runStepsAsync(`Clean [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-clean"]]]);
|
|
1220
|
-
};
|
|
1221
|
-
var cleanAll = ({ verbose }) => {
|
|
1222
|
-
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
1223
|
-
return runStepsAsync("Clean", [["yarn", ["workspaces foreach", "-pA", "--jobs 64", ...verboseOptions, "run", "package-clean"]]]);
|
|
1224
|
-
};
|
|
1225
|
-
|
|
1226
|
-
// src/actions/clean-docs.ts
|
|
1227
|
-
import path from "path";
|
|
1228
|
-
import chalk17 from "chalk";
|
|
1229
|
-
var cleanDocs = () => {
|
|
1230
|
-
const pkgName = process.env.npm_package_name;
|
|
1231
|
-
console.log(chalk17.green(`Cleaning Docs [${pkgName}]`));
|
|
1232
|
-
for (const { location } of yarnWorkspaces()) deleteGlob(path.join(location, "docs"));
|
|
1233
|
-
return 0;
|
|
1234
|
-
};
|
|
1235
|
-
|
|
1236
|
-
// src/actions/compile.ts
|
|
1237
|
-
import chalk18 from "chalk";
|
|
1238
|
-
var compile = ({
|
|
1239
|
-
verbose,
|
|
1240
|
-
target,
|
|
1241
|
-
pkg,
|
|
1242
|
-
incremental,
|
|
1243
|
-
publint: publint2,
|
|
1244
|
-
jobs
|
|
1245
|
-
}) => {
|
|
1246
|
-
return pkg ? compilePackage({
|
|
1247
|
-
pkg,
|
|
1248
|
-
publint: publint2,
|
|
1249
|
-
target,
|
|
1250
|
-
verbose
|
|
1251
|
-
}) : compileAll({
|
|
1252
|
-
incremental,
|
|
1253
|
-
publint: publint2,
|
|
1254
|
-
target,
|
|
1255
|
-
verbose,
|
|
1256
|
-
jobs
|
|
1257
|
-
});
|
|
1258
|
-
};
|
|
1259
|
-
var compilePackage = ({ target, pkg }) => {
|
|
1260
|
-
const targetOptions = target ? ["-t", target] : [];
|
|
1261
|
-
return runSteps(
|
|
1262
|
-
`Compile [${pkg}]`,
|
|
1263
|
-
[["yarn", ["workspace", pkg, "run", "package-compile", ...targetOptions]]]
|
|
1264
|
-
);
|
|
1265
|
-
};
|
|
1266
|
-
var compileAll = ({
|
|
1267
|
-
jobs,
|
|
1268
|
-
verbose,
|
|
1269
|
-
target,
|
|
1270
|
-
incremental
|
|
1271
|
-
}) => {
|
|
1272
|
-
const start = Date.now();
|
|
1273
|
-
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
1274
|
-
const targetOptions = target ? ["-t", target] : [];
|
|
1275
|
-
const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
|
|
1276
|
-
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
1277
|
-
if (jobs) {
|
|
1278
|
-
console.log(chalk18.blue(`Jobs set to [${jobs}]`));
|
|
1279
|
-
}
|
|
1280
|
-
const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
|
|
1281
|
-
["yarn", [
|
|
53
|
+
foreachWorkspace(script, args = [], options) {
|
|
54
|
+
const jobsOptions = options?.jobs ? ["-j", `${options.jobs}`] : [];
|
|
55
|
+
const verboseOptions = options?.verbose ? ["--verbose"] : ["--no-verbose"];
|
|
56
|
+
const incrementalOptions = options?.incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
|
|
57
|
+
return ["yarn", [
|
|
1282
58
|
"workspaces",
|
|
1283
59
|
"foreach",
|
|
1284
60
|
...incrementalOptions,
|
|
1285
61
|
...jobsOptions,
|
|
1286
62
|
...verboseOptions,
|
|
1287
63
|
"run",
|
|
1288
|
-
|
|
1289
|
-
...
|
|
1290
|
-
]]
|
|
1291
|
-
]);
|
|
1292
|
-
console.log(`${chalk18.gray("Compiled in")} [${chalk18.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk18.gray("seconds")}`);
|
|
1293
|
-
return result;
|
|
1294
|
-
};
|
|
1295
|
-
|
|
1296
|
-
// src/actions/copy-assets.ts
|
|
1297
|
-
import path2 from "path/posix";
|
|
1298
|
-
import chalk19 from "chalk";
|
|
1299
|
-
import cpy from "cpy";
|
|
1300
|
-
var copyPackageTargetAssets = async (target, name, location) => {
|
|
1301
|
-
try {
|
|
1302
|
-
const values = await cpy(
|
|
1303
|
-
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1304
|
-
`../dist/${target}`,
|
|
1305
|
-
{
|
|
1306
|
-
cwd: path2.join(process.cwd(), location, "src"),
|
|
1307
|
-
flat: false
|
|
1308
|
-
}
|
|
1309
|
-
);
|
|
1310
|
-
for (const value of values) {
|
|
1311
|
-
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
1312
|
-
}
|
|
1313
|
-
return 0;
|
|
1314
|
-
} catch (reason) {
|
|
1315
|
-
console.log(`Copy Failed: ${name}: ${reason}`);
|
|
1316
|
-
return 1;
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
var copyTargetAssets = async (target, pkg) => {
|
|
1320
|
-
const workspaces = yarnWorkspaces();
|
|
1321
|
-
console.log(chalk19.green(`Copying Assets [${target.toUpperCase()}]`));
|
|
1322
|
-
const workspaceList = workspaces.filter(({ name }) => {
|
|
1323
|
-
return pkg === void 0 || name === pkg;
|
|
1324
|
-
});
|
|
1325
|
-
if (workspaceList.length === 0) {
|
|
1326
|
-
console.error(`Package not found [${pkg}]`);
|
|
1327
|
-
} else {
|
|
1328
|
-
const results = await Promise.all(
|
|
1329
|
-
workspaceList.map(async (workspace) => {
|
|
1330
|
-
const { location, name } = workspace;
|
|
1331
|
-
return await copyPackageTargetAssets(target, name, location);
|
|
1332
|
-
})
|
|
1333
|
-
);
|
|
1334
|
-
return results.reduce((prev, result) => prev || result, 0);
|
|
1335
|
-
}
|
|
1336
|
-
return 0;
|
|
1337
|
-
};
|
|
1338
|
-
var copyAssets = async ({ target, pkg }) => {
|
|
1339
|
-
switch (target) {
|
|
1340
|
-
case "esm": {
|
|
1341
|
-
return await copyTargetAssets("esm", pkg);
|
|
1342
|
-
}
|
|
1343
|
-
case "cjs": {
|
|
1344
|
-
return await copyTargetAssets("cjs", pkg);
|
|
1345
|
-
}
|
|
1346
|
-
default: {
|
|
1347
|
-
return await copyTargetAssets("esm", pkg) || await copyTargetAssets("cjs", pkg);
|
|
1348
|
-
}
|
|
64
|
+
script,
|
|
65
|
+
...args
|
|
66
|
+
]];
|
|
1349
67
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
// src/actions/cycle.ts
|
|
1353
|
-
import { cruise } from "dependency-cruiser";
|
|
1354
|
-
var cycle = async ({ verbose, pkg } = {}) => {
|
|
1355
|
-
return pkg ? cyclePackage({ pkg, verbose }) : await cycleAll({ verbose });
|
|
1356
|
-
};
|
|
1357
|
-
var cyclePackage = ({ pkg, verbose }) => {
|
|
1358
|
-
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
1359
|
-
return runSteps(
|
|
1360
|
-
`Cycle [${pkg}]`,
|
|
1361
|
-
[["yarn", ["workspace", pkg, "run", "package-cycle", ...verboseOptions]]]
|
|
1362
|
-
);
|
|
1363
|
-
};
|
|
1364
|
-
var cycleAll = async ({ verbose = false }) => {
|
|
1365
|
-
const pkgName = process.env.npm_package_name;
|
|
1366
|
-
const cruiseOptions = {
|
|
1367
|
-
ruleSet: {
|
|
1368
|
-
forbidden: [
|
|
1369
|
-
{
|
|
1370
|
-
name: "no-circular",
|
|
1371
|
-
severity: "error",
|
|
1372
|
-
comment: "This dependency creates a circular reference",
|
|
1373
|
-
from: {},
|
|
1374
|
-
to: { circular: true }
|
|
1375
|
-
}
|
|
1376
|
-
]
|
|
1377
|
-
},
|
|
1378
|
-
exclude: "node_modules|packages/.*/packages",
|
|
1379
|
-
validate: true,
|
|
1380
|
-
doNotFollow: { path: "node_modules|packages/.*/packages" },
|
|
1381
|
-
tsPreCompilationDeps: false,
|
|
1382
|
-
combinedDependencies: true,
|
|
1383
|
-
outputType: verbose ? "text" : "err"
|
|
1384
|
-
};
|
|
1385
|
-
const target = "**/packages/*/src";
|
|
1386
|
-
console.log(`Checking for circular dependencies in ${target}...`);
|
|
1387
|
-
const result = await cruise([target], cruiseOptions);
|
|
1388
|
-
if (result.output) {
|
|
1389
|
-
console.log(result.output);
|
|
68
|
+
install() {
|
|
69
|
+
return ["yarn", ["install"]];
|
|
1390
70
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
} else {
|
|
1394
|
-
console.error(`${pkgName} \u274C Dependency violations found`);
|
|
71
|
+
listWorkspaces() {
|
|
72
|
+
return yarnWorkspaces();
|
|
1395
73
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
// src/actions/dead.ts
|
|
1400
|
-
var dead = () => {
|
|
1401
|
-
return runSteps("Dead", [["yarn", ["ts-prune", "-p", "tsconfig.json"]]]);
|
|
1402
|
-
};
|
|
1403
|
-
|
|
1404
|
-
// src/actions/deplint/deplint.ts
|
|
1405
|
-
import chalk25 from "chalk";
|
|
1406
|
-
|
|
1407
|
-
// src/actions/deplint/findFiles.ts
|
|
1408
|
-
import fs2 from "fs";
|
|
1409
|
-
|
|
1410
|
-
// src/actions/deplint/findFilesByGlob.ts
|
|
1411
|
-
import { globSync } from "glob";
|
|
1412
|
-
function findFilesByGlob(cwd5, pattern, ignore) {
|
|
1413
|
-
return globSync(pattern, {
|
|
1414
|
-
cwd: cwd5,
|
|
1415
|
-
absolute: true,
|
|
1416
|
-
ignore,
|
|
1417
|
-
nodir: true
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
// src/actions/deplint/findFiles.ts
|
|
1422
|
-
var codeExtensions = "*.{ts,tsx,mts,cts,js,mjs,cjs}";
|
|
1423
|
-
function getWorkspaceIgnores(location) {
|
|
1424
|
-
try {
|
|
1425
|
-
const raw = fs2.readFileSync(`${location}/package.json`, "utf8");
|
|
1426
|
-
const pkg = JSON.parse(raw);
|
|
1427
|
-
return pkg.workspaces ?? [];
|
|
1428
|
-
} catch {
|
|
1429
|
-
return [];
|
|
74
|
+
outdated() {
|
|
75
|
+
return ["yarn", ["outdated"]];
|
|
1430
76
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
const workspaceIgnores = getWorkspaceIgnores(location).map((w) => `${w}/**`);
|
|
1434
|
-
const ignore = ["**/node_modules/**", "dist/**", ...workspaceIgnores];
|
|
1435
|
-
const allFiles = findFilesByGlob(location, `./**/${codeExtensions}`, ignore);
|
|
1436
|
-
const distFiles = [
|
|
1437
|
-
...findFilesByGlob(location, "./dist/**/*.d.ts"),
|
|
1438
|
-
...findFilesByGlob(location, `./dist/**/${codeExtensions}`)
|
|
1439
|
-
];
|
|
1440
|
-
return { allFiles, distFiles };
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
// src/actions/deplint/getDependenciesFromPackageJson.ts
|
|
1444
|
-
import fs3 from "fs";
|
|
1445
|
-
import path3 from "path";
|
|
1446
|
-
function getDependenciesFromPackageJson(packageJsonPath) {
|
|
1447
|
-
const packageJsonFullPath = path3.resolve(packageJsonPath);
|
|
1448
|
-
const rawContent = fs3.readFileSync(packageJsonFullPath, "utf8");
|
|
1449
|
-
const packageJson = JSON.parse(rawContent);
|
|
1450
|
-
const dependencies = packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
|
|
1451
|
-
const devDependencies = packageJson.devDependencies ? Object.keys(packageJson.devDependencies) : [];
|
|
1452
|
-
const peerDependencies = packageJson.peerDependencies ? Object.keys(packageJson.peerDependencies) : [];
|
|
1453
|
-
return {
|
|
1454
|
-
dependencies,
|
|
1455
|
-
devDependencies,
|
|
1456
|
-
peerDependencies
|
|
1457
|
-
};
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
// src/actions/deplint/getExtendsFromTsconfigs.ts
|
|
1461
|
-
import fs4 from "fs";
|
|
1462
|
-
import { globSync as globSync2 } from "glob";
|
|
1463
|
-
|
|
1464
|
-
// src/actions/deplint/getBasePackageName.ts
|
|
1465
|
-
function getBasePackageName(importName) {
|
|
1466
|
-
const importNameScrubbed = importName.replaceAll('"', "").trim();
|
|
1467
|
-
if (importNameScrubbed.startsWith("@")) {
|
|
1468
|
-
const parts = importNameScrubbed.split("/");
|
|
1469
|
-
return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : importNameScrubbed;
|
|
77
|
+
runInWorkspace(pkg, script, args = []) {
|
|
78
|
+
return ["yarn", ["workspace", pkg, "run", script, ...args]];
|
|
1470
79
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
// src/actions/deplint/getExtendsFromTsconfigs.ts
|
|
1475
|
-
var isExternalReference = (ref) => !ref.startsWith(".") && !ref.startsWith("/");
|
|
1476
|
-
function parseExtendsField(value) {
|
|
1477
|
-
if (typeof value === "string") return [value];
|
|
1478
|
-
if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
|
|
1479
|
-
return [];
|
|
1480
|
-
}
|
|
1481
|
-
function getExtendsFromTsconfigs(location) {
|
|
1482
|
-
const tsconfigFiles = globSync2("./tsconfig*.json", { cwd: location, absolute: true });
|
|
1483
|
-
const packages = /* @__PURE__ */ new Set();
|
|
1484
|
-
for (const file of tsconfigFiles) {
|
|
1485
|
-
try {
|
|
1486
|
-
const content = fs4.readFileSync(file, "utf8");
|
|
1487
|
-
const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
|
|
1488
|
-
const parsed = JSON.parse(cleaned);
|
|
1489
|
-
const refs = parseExtendsField(parsed.extends);
|
|
1490
|
-
for (const ref of refs) {
|
|
1491
|
-
if (isExternalReference(ref)) {
|
|
1492
|
-
packages.add(getBasePackageName(ref));
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
} catch {
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
return [...packages];
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
// src/actions/deplint/getImportsFromFile.ts
|
|
1502
|
-
import fs5 from "fs";
|
|
1503
|
-
import path4 from "path";
|
|
1504
|
-
import ts from "typescript";
|
|
1505
|
-
function isTypeOnlyImportClause(clause) {
|
|
1506
|
-
if (clause === void 0) {
|
|
1507
|
-
return false;
|
|
1508
|
-
}
|
|
1509
|
-
if ("phaseModifier" in clause) {
|
|
1510
|
-
const mod = clause.phaseModifier;
|
|
1511
|
-
const kind = typeof mod === "number" ? mod : mod?.kind;
|
|
1512
|
-
return kind === ts.SyntaxKind.TypeKeyword;
|
|
1513
|
-
}
|
|
1514
|
-
return clause.isTypeOnly;
|
|
1515
|
-
}
|
|
1516
|
-
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
1517
|
-
const sourceCode = fs5.readFileSync(filePath, "utf8");
|
|
1518
|
-
const isMjsFile = filePath.endsWith(".mjs");
|
|
1519
|
-
const sourceFile = ts.createSourceFile(
|
|
1520
|
-
path4.basename(filePath),
|
|
1521
|
-
sourceCode,
|
|
1522
|
-
ts.ScriptTarget.Latest,
|
|
1523
|
-
true,
|
|
1524
|
-
isMjsFile ? ts.ScriptKind.JS : void 0
|
|
1525
|
-
);
|
|
1526
|
-
const imports = [];
|
|
1527
|
-
const typeImports = [];
|
|
1528
|
-
const isDeclarationFile2 = filePath.endsWith(".d.ts");
|
|
1529
|
-
function visit(node) {
|
|
1530
|
-
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
1531
|
-
const moduleSpecifier = node.moduleSpecifier?.getFullText();
|
|
1532
|
-
const isTypeImport = ts.isImportDeclaration(node) ? isTypeOnlyImportClause(node.importClause) : false;
|
|
1533
|
-
if (typeof moduleSpecifier === "string") {
|
|
1534
|
-
const trimmed = moduleSpecifier.replaceAll("'", "").replaceAll('"', "").trim();
|
|
1535
|
-
if (isTypeImport || isDeclarationFile2) {
|
|
1536
|
-
typeImports.push(trimmed);
|
|
1537
|
-
} else {
|
|
1538
|
-
imports.push(trimmed);
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
} else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
1542
|
-
const [arg] = node.arguments;
|
|
1543
|
-
if (ts.isStringLiteral(arg)) {
|
|
1544
|
-
imports.push(arg.text);
|
|
1545
|
-
}
|
|
1546
|
-
} else if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "require" && node.arguments.length > 0 && ts.isStringLiteral(node.arguments[0])) {
|
|
1547
|
-
imports.push(node.arguments[0].text);
|
|
1548
|
-
}
|
|
1549
|
-
ts.forEachChild(node, visit);
|
|
1550
|
-
}
|
|
1551
|
-
visit(sourceFile);
|
|
1552
|
-
for (const ref of sourceFile.typeReferenceDirectives) {
|
|
1553
|
-
typeImports.push(ref.fileName);
|
|
1554
|
-
}
|
|
1555
|
-
const importsStartsWithExcludes = [".", "#", "node:"];
|
|
1556
|
-
const isValidImport = (imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc)) && !imp.includes("*") && !imp.includes("!");
|
|
1557
|
-
const cleanedImports = imports.filter(isValidImport).map(getBasePackageName);
|
|
1558
|
-
const cleanedTypeImports = typeImports.filter(isValidImport).map(getBasePackageName);
|
|
1559
|
-
for (const imp of cleanedImports) {
|
|
1560
|
-
importPaths[imp] = importPaths[imp] ?? [];
|
|
1561
|
-
importPaths[imp].push(filePath);
|
|
1562
|
-
}
|
|
1563
|
-
for (const imp of cleanedTypeImports) {
|
|
1564
|
-
typeImportPaths[imp] = typeImportPaths[imp] ?? [];
|
|
1565
|
-
typeImportPaths[imp].push(filePath);
|
|
1566
|
-
}
|
|
1567
|
-
return [cleanedImports, cleanedTypeImports];
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
// src/actions/deplint/getExternalImportsFromFiles.ts
|
|
1571
|
-
var internalImportPrefixes = [".", "#", "node:"];
|
|
1572
|
-
var removeInternalImports = (imports) => {
|
|
1573
|
-
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
1574
|
-
};
|
|
1575
|
-
var isDeclarationFile = (file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts");
|
|
1576
|
-
function getExternalImportsFromFiles({
|
|
1577
|
-
allFiles,
|
|
1578
|
-
distFiles,
|
|
1579
|
-
tsconfigExtends = []
|
|
1580
|
-
}) {
|
|
1581
|
-
const allImportPaths = {};
|
|
1582
|
-
const distImportPaths = {};
|
|
1583
|
-
const distTypeImportPaths = {};
|
|
1584
|
-
for (const path14 of allFiles) getImportsFromFile(path14, allImportPaths, allImportPaths).flat();
|
|
1585
|
-
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
1586
|
-
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
1587
|
-
for (const path14 of distCodeFiles) getImportsFromFile(path14, distImportPaths, distImportPaths).flat();
|
|
1588
|
-
for (const path14 of distTypeFiles) getImportsFromFile(path14, distTypeImportPaths, distTypeImportPaths).flat();
|
|
1589
|
-
const allImports = Object.keys(allImportPaths);
|
|
1590
|
-
const distImports = Object.keys(distImportPaths);
|
|
1591
|
-
const externalAllImports = removeInternalImports(allImports);
|
|
1592
|
-
const externalDistImports = removeInternalImports(distImports);
|
|
1593
|
-
const externalDistTypeImports = removeInternalImports(Object.keys(distTypeImportPaths));
|
|
1594
|
-
for (const ext of tsconfigExtends) {
|
|
1595
|
-
if (!externalAllImports.includes(ext)) externalAllImports.push(ext);
|
|
1596
|
-
}
|
|
1597
|
-
return {
|
|
1598
|
-
allImportPaths,
|
|
1599
|
-
allImports,
|
|
1600
|
-
distImportPaths,
|
|
1601
|
-
distImports,
|
|
1602
|
-
externalAllImports,
|
|
1603
|
-
externalDistImports,
|
|
1604
|
-
externalDistTypeImports
|
|
1605
|
-
};
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
1609
|
-
import { builtinModules } from "module";
|
|
1610
|
-
import chalk20 from "chalk";
|
|
1611
|
-
function isRuntimeImportListed(imp, name, dependencies, peerDependencies) {
|
|
1612
|
-
return dependencies.includes(imp) || imp === name || peerDependencies.includes(imp) || builtinModules.includes(imp);
|
|
1613
|
-
}
|
|
1614
|
-
function isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies) {
|
|
1615
|
-
return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || devDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp);
|
|
1616
|
-
}
|
|
1617
|
-
function logMissing(name, imp, importPaths) {
|
|
1618
|
-
console.log(`[${chalk20.blue(name)}] Missing dependency in package.json: ${chalk20.red(imp)}`);
|
|
1619
|
-
if (importPaths[imp]) {
|
|
1620
|
-
console.log(` ${importPaths[imp].join("\n ")}`);
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
function getUnlistedDependencies({ name, location }, {
|
|
1624
|
-
dependencies,
|
|
1625
|
-
devDependencies,
|
|
1626
|
-
peerDependencies
|
|
1627
|
-
}, {
|
|
1628
|
-
externalDistImports,
|
|
1629
|
-
externalDistTypeImports,
|
|
1630
|
-
distImportPaths
|
|
1631
|
-
}) {
|
|
1632
|
-
let unlistedDependencies = 0;
|
|
1633
|
-
for (const imp of externalDistImports) {
|
|
1634
|
-
if (!isRuntimeImportListed(imp, name, dependencies, peerDependencies)) {
|
|
1635
|
-
unlistedDependencies++;
|
|
1636
|
-
logMissing(name, imp, distImportPaths);
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
for (const imp of externalDistTypeImports) {
|
|
1640
|
-
if (!isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies)) {
|
|
1641
|
-
unlistedDependencies++;
|
|
1642
|
-
logMissing(name, imp, distImportPaths);
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
if (unlistedDependencies > 0) {
|
|
1646
|
-
const packageLocation = `${location}/package.json`;
|
|
1647
|
-
console.log(` ${chalk20.yellow(packageLocation)}
|
|
1648
|
-
`);
|
|
1649
|
-
}
|
|
1650
|
-
return unlistedDependencies;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
1654
|
-
import { builtinModules as builtinModules2 } from "module";
|
|
1655
|
-
import chalk21 from "chalk";
|
|
1656
|
-
function getUnlistedDevDependencies({ name, location }, {
|
|
1657
|
-
devDependencies,
|
|
1658
|
-
dependencies,
|
|
1659
|
-
peerDependencies
|
|
1660
|
-
}, {
|
|
1661
|
-
allImportPaths,
|
|
1662
|
-
externalAllImports,
|
|
1663
|
-
distImports
|
|
1664
|
-
}) {
|
|
1665
|
-
let unlistedDevDependencies = 0;
|
|
1666
|
-
for (const imp of externalAllImports) {
|
|
1667
|
-
if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
|
|
1668
|
-
unlistedDevDependencies++;
|
|
1669
|
-
console.log(`[${chalk21.blue(name)}] Missing devDependency in package.json: ${chalk21.red(imp)}`);
|
|
1670
|
-
if (allImportPaths[imp]) {
|
|
1671
|
-
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
if (unlistedDevDependencies > 0) {
|
|
1676
|
-
const packageLocation = `${location}/package.json`;
|
|
1677
|
-
console.log(` ${chalk21.yellow(packageLocation)}
|
|
1678
|
-
`);
|
|
1679
|
-
}
|
|
1680
|
-
return unlistedDevDependencies;
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
1684
|
-
import chalk22 from "chalk";
|
|
1685
|
-
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
1686
|
-
externalDistImports,
|
|
1687
|
-
externalDistTypeImports,
|
|
1688
|
-
externalAllImports
|
|
1689
|
-
}, exclude) {
|
|
1690
|
-
let unusedDependencies = 0;
|
|
1691
|
-
for (const dep of dependencies) {
|
|
1692
|
-
if (exclude?.has(dep)) continue;
|
|
1693
|
-
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1694
|
-
unusedDependencies++;
|
|
1695
|
-
if (externalAllImports.includes(dep)) {
|
|
1696
|
-
console.log(`[${chalk22.blue(name)}] dependency should be devDependency in package.json: ${chalk22.red(dep)}`);
|
|
1697
|
-
} else {
|
|
1698
|
-
console.log(`[${chalk22.blue(name)}] Unused dependency in package.json: ${chalk22.red(dep)}`);
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
if (unusedDependencies > 0) {
|
|
1703
|
-
const packageLocation = `${location}/package.json`;
|
|
1704
|
-
console.log(` ${chalk22.yellow(packageLocation)}
|
|
1705
|
-
`);
|
|
1706
|
-
}
|
|
1707
|
-
return unusedDependencies;
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1711
|
-
import chalk23 from "chalk";
|
|
1712
|
-
|
|
1713
|
-
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1714
|
-
import fs8 from "fs";
|
|
1715
|
-
import path7 from "path";
|
|
1716
|
-
import ts2 from "typescript";
|
|
1717
|
-
|
|
1718
|
-
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1719
|
-
import fs7 from "fs";
|
|
1720
|
-
import path6 from "path";
|
|
1721
|
-
|
|
1722
|
-
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
1723
|
-
import fs6 from "fs";
|
|
1724
|
-
import path5 from "path";
|
|
1725
|
-
function findDepPackageJson(location, dep) {
|
|
1726
|
-
let dir = location;
|
|
1727
|
-
while (true) {
|
|
1728
|
-
const candidate = path5.join(dir, "node_modules", dep, "package.json");
|
|
1729
|
-
if (fs6.existsSync(candidate)) return candidate;
|
|
1730
|
-
const parent = path5.dirname(dir);
|
|
1731
|
-
if (parent === dir) return void 0;
|
|
1732
|
-
dir = parent;
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
function getRequiredPeerDependencies(location, allDeps) {
|
|
1736
|
-
const required = /* @__PURE__ */ new Set();
|
|
1737
|
-
for (const dep of allDeps) {
|
|
1738
|
-
const depPkgPath = findDepPackageJson(location, dep);
|
|
1739
|
-
if (!depPkgPath) continue;
|
|
1740
|
-
try {
|
|
1741
|
-
const raw = fs6.readFileSync(depPkgPath, "utf8");
|
|
1742
|
-
const pkg = JSON.parse(raw);
|
|
1743
|
-
if (pkg.peerDependencies) {
|
|
1744
|
-
for (const peer of Object.keys(pkg.peerDependencies)) {
|
|
1745
|
-
required.add(peer);
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
} catch {
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
return required;
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1755
|
-
function getBinNames(location, dep) {
|
|
1756
|
-
const depPkgPath = findDepPackageJson(location, dep);
|
|
1757
|
-
if (!depPkgPath) return [];
|
|
1758
|
-
try {
|
|
1759
|
-
const raw = fs7.readFileSync(depPkgPath, "utf8");
|
|
1760
|
-
const pkg = JSON.parse(raw);
|
|
1761
|
-
if (!pkg.bin) return [];
|
|
1762
|
-
if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
|
|
1763
|
-
return Object.keys(pkg.bin);
|
|
1764
|
-
} catch {
|
|
1765
|
-
return [];
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
function tokenizeScript(script) {
|
|
1769
|
-
return script.split(/[&|;$()"`\s]+/).map((t) => t.trim()).filter(Boolean);
|
|
1770
|
-
}
|
|
1771
|
-
function getScriptReferencedPackages(location, allDeps) {
|
|
1772
|
-
const pkgPath = path6.join(location, "package.json");
|
|
1773
|
-
let scripts = {};
|
|
1774
|
-
try {
|
|
1775
|
-
const raw = fs7.readFileSync(pkgPath, "utf8");
|
|
1776
|
-
const pkg = JSON.parse(raw);
|
|
1777
|
-
scripts = pkg.scripts ?? {};
|
|
1778
|
-
} catch {
|
|
1779
|
-
return /* @__PURE__ */ new Set();
|
|
1780
|
-
}
|
|
1781
|
-
const scriptText = Object.values(scripts).join(" ");
|
|
1782
|
-
const tokens = new Set(tokenizeScript(scriptText));
|
|
1783
|
-
const binToPackage = /* @__PURE__ */ new Map();
|
|
1784
|
-
for (const dep of allDeps) {
|
|
1785
|
-
const bins = getBinNames(location, dep);
|
|
1786
|
-
for (const bin of bins) {
|
|
1787
|
-
binToPackage.set(bin, dep);
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
const referenced = /* @__PURE__ */ new Set();
|
|
1791
|
-
for (const token of tokens) {
|
|
1792
|
-
const baseName = getBasePackageName(token);
|
|
1793
|
-
if (allDeps.includes(baseName)) {
|
|
1794
|
-
referenced.add(baseName);
|
|
1795
|
-
}
|
|
1796
|
-
const pkg = binToPackage.get(token);
|
|
1797
|
-
if (pkg) {
|
|
1798
|
-
referenced.add(pkg);
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
return referenced;
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
|
-
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1805
|
-
var shellCommandFunctions = /* @__PURE__ */ new Set(["execSync", "exec"]);
|
|
1806
|
-
var directExecFunctions = /* @__PURE__ */ new Set(["spawn", "spawnSync", "execFile", "execFileSync"]);
|
|
1807
|
-
var allExecFunctions = /* @__PURE__ */ new Set([...shellCommandFunctions, ...directExecFunctions]);
|
|
1808
|
-
function getCommandTokensFromFile(filePath) {
|
|
1809
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
1810
|
-
let sourceCode;
|
|
1811
|
-
try {
|
|
1812
|
-
sourceCode = fs8.readFileSync(filePath, "utf8");
|
|
1813
|
-
} catch {
|
|
1814
|
-
return tokens;
|
|
1815
|
-
}
|
|
1816
|
-
const isMjsFile = filePath.endsWith(".mjs");
|
|
1817
|
-
const sourceFile = ts2.createSourceFile(
|
|
1818
|
-
path7.basename(filePath),
|
|
1819
|
-
sourceCode,
|
|
1820
|
-
ts2.ScriptTarget.Latest,
|
|
1821
|
-
true,
|
|
1822
|
-
isMjsFile ? ts2.ScriptKind.JS : void 0
|
|
1823
|
-
);
|
|
1824
|
-
function visit(node) {
|
|
1825
|
-
if (ts2.isCallExpression(node) && node.arguments.length > 0) {
|
|
1826
|
-
const fnName = getFunctionName(node.expression);
|
|
1827
|
-
if (fnName && allExecFunctions.has(fnName)) {
|
|
1828
|
-
const firstArg = node.arguments[0];
|
|
1829
|
-
if (ts2.isStringLiteral(firstArg) || ts2.isNoSubstitutionTemplateLiteral(firstArg)) {
|
|
1830
|
-
const value = firstArg.text;
|
|
1831
|
-
if (shellCommandFunctions.has(fnName)) {
|
|
1832
|
-
for (const token of tokenizeScript(value)) {
|
|
1833
|
-
tokens.add(token);
|
|
1834
|
-
}
|
|
1835
|
-
} else {
|
|
1836
|
-
tokens.add(value);
|
|
1837
|
-
}
|
|
1838
|
-
} else if (ts2.isTemplateExpression(firstArg)) {
|
|
1839
|
-
const head = firstArg.head.text;
|
|
1840
|
-
if (head) {
|
|
1841
|
-
for (const token of tokenizeScript(head)) {
|
|
1842
|
-
tokens.add(token);
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
ts2.forEachChild(node, visit);
|
|
1849
|
-
}
|
|
1850
|
-
visit(sourceFile);
|
|
1851
|
-
return tokens;
|
|
1852
|
-
}
|
|
1853
|
-
function getFunctionName(expr) {
|
|
1854
|
-
if (ts2.isIdentifier(expr)) {
|
|
1855
|
-
return expr.text;
|
|
1856
|
-
}
|
|
1857
|
-
if (ts2.isPropertyAccessExpression(expr) && ts2.isIdentifier(expr.name)) {
|
|
1858
|
-
return expr.name.text;
|
|
1859
|
-
}
|
|
1860
|
-
return void 0;
|
|
1861
|
-
}
|
|
1862
|
-
function getCliReferencedPackagesFromFiles(allFiles, location, allDeps) {
|
|
1863
|
-
const allTokens = /* @__PURE__ */ new Set();
|
|
1864
|
-
for (const file of allFiles) {
|
|
1865
|
-
for (const token of getCommandTokensFromFile(file)) {
|
|
1866
|
-
allTokens.add(token);
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
if (allTokens.size === 0) return /* @__PURE__ */ new Set();
|
|
1870
|
-
const binToPackage = /* @__PURE__ */ new Map();
|
|
1871
|
-
for (const dep of allDeps) {
|
|
1872
|
-
for (const bin of getBinNames(location, dep)) {
|
|
1873
|
-
binToPackage.set(bin, dep);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
const referenced = /* @__PURE__ */ new Set();
|
|
1877
|
-
for (const token of allTokens) {
|
|
1878
|
-
const baseName = getBasePackageName(token);
|
|
1879
|
-
if (allDeps.includes(baseName)) {
|
|
1880
|
-
referenced.add(baseName);
|
|
1881
|
-
}
|
|
1882
|
-
const pkg = binToPackage.get(token);
|
|
1883
|
-
if (pkg) {
|
|
1884
|
-
referenced.add(pkg);
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
return referenced;
|
|
1888
|
-
}
|
|
1889
|
-
|
|
1890
|
-
// src/actions/deplint/implicitDevDependencies.ts
|
|
1891
|
-
import fs9 from "fs";
|
|
1892
|
-
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1893
|
-
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1894
|
-
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
1895
|
-
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1896
|
-
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1897
|
-
try {
|
|
1898
|
-
const content = fs9.readFileSync(file, "utf8");
|
|
1899
|
-
return decoratorPattern.test(content);
|
|
1900
|
-
} catch {
|
|
1901
|
-
return false;
|
|
1902
|
-
}
|
|
1903
|
-
});
|
|
1904
|
-
var importPlugins = /* @__PURE__ */ new Set(["eslint-plugin-import-x", "eslint-plugin-import"]);
|
|
1905
|
-
function hasImportPlugin({ location, allDependencies }) {
|
|
1906
|
-
if (allDependencies.some((d) => importPlugins.has(d))) return true;
|
|
1907
|
-
for (const dep of allDependencies) {
|
|
1908
|
-
const pkgPath = findDepPackageJson(location, dep);
|
|
1909
|
-
if (!pkgPath) continue;
|
|
1910
|
-
try {
|
|
1911
|
-
const pkg = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
|
|
1912
|
-
const transitiveDeps = [
|
|
1913
|
-
...Object.keys(pkg.dependencies ?? {}),
|
|
1914
|
-
...Object.keys(pkg.peerDependencies ?? {})
|
|
1915
|
-
];
|
|
1916
|
-
if (transitiveDeps.some((d) => importPlugins.has(d))) return true;
|
|
1917
|
-
} catch {
|
|
1918
|
-
}
|
|
1919
|
-
}
|
|
1920
|
-
return false;
|
|
1921
|
-
}
|
|
1922
|
-
var hasVitest = ({ allDependencies }) => allDependencies.includes("vitest");
|
|
1923
|
-
var rules = [
|
|
1924
|
-
{
|
|
1925
|
-
package: "typescript",
|
|
1926
|
-
isNeeded: hasTypescriptFiles
|
|
1927
|
-
},
|
|
1928
|
-
{
|
|
1929
|
-
package: "eslint-import-resolver-typescript",
|
|
1930
|
-
isNeeded: (context) => hasTypescriptFiles(context) && context.allDependencies.includes("eslint") && hasImportPlugin(context)
|
|
1931
|
-
},
|
|
1932
|
-
{
|
|
1933
|
-
package: "tslib",
|
|
1934
|
-
isNeeded: hasDecorators
|
|
1935
|
-
},
|
|
1936
|
-
{
|
|
1937
|
-
package: "@vitest/coverage-v8",
|
|
1938
|
-
isNeeded: hasVitest
|
|
1939
|
-
}
|
|
1940
|
-
];
|
|
1941
|
-
function getImplicitDevDependencies(context) {
|
|
1942
|
-
const implicit = /* @__PURE__ */ new Set();
|
|
1943
|
-
for (const rule of rules) {
|
|
1944
|
-
if (rule.isNeeded(context)) {
|
|
1945
|
-
implicit.add(rule.package);
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
return implicit;
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1952
|
-
var allExternalImports = ({
|
|
1953
|
-
externalAllImports,
|
|
1954
|
-
externalDistImports,
|
|
1955
|
-
externalDistTypeImports
|
|
1956
|
-
}) => {
|
|
1957
|
-
return /* @__PURE__ */ new Set([
|
|
1958
|
-
...externalAllImports,
|
|
1959
|
-
...externalDistImports,
|
|
1960
|
-
...externalDistTypeImports
|
|
1961
|
-
]);
|
|
1962
|
-
};
|
|
1963
|
-
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs) {
|
|
1964
|
-
if (implicitDeps.has(dep)) return true;
|
|
1965
|
-
if (requiredPeers.has(dep)) return true;
|
|
1966
|
-
if (scriptRefs.has(dep)) return true;
|
|
1967
|
-
if (cliRefs.has(dep)) return true;
|
|
1968
|
-
if (dep.startsWith("@types/")) {
|
|
1969
|
-
const baseName = dep.replace(/^@types\//, "");
|
|
1970
|
-
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
1971
|
-
}
|
|
1972
|
-
return allImports.has(dep);
|
|
1973
|
-
}
|
|
1974
|
-
function getUnusedDevDependencies({ name, location }, {
|
|
1975
|
-
devDependencies,
|
|
1976
|
-
dependencies,
|
|
1977
|
-
peerDependencies
|
|
1978
|
-
}, sourceParams, fileContext, exclude) {
|
|
1979
|
-
const allImports = allExternalImports(sourceParams);
|
|
1980
|
-
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1981
|
-
const implicitDeps = getImplicitDevDependencies({
|
|
1982
|
-
...fileContext,
|
|
1983
|
-
allDependencies: allDeps,
|
|
1984
|
-
location
|
|
1985
|
-
});
|
|
1986
|
-
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1987
|
-
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1988
|
-
const cliRefs = getCliReferencedPackagesFromFiles(fileContext.allFiles, location, allDeps);
|
|
1989
|
-
let unusedDevDependencies = 0;
|
|
1990
|
-
for (const dep of devDependencies) {
|
|
1991
|
-
if (exclude?.has(dep)) continue;
|
|
1992
|
-
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1993
|
-
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
|
|
1994
|
-
unusedDevDependencies++;
|
|
1995
|
-
console.log(`[${chalk23.blue(name)}] Unused devDependency in package.json: ${chalk23.red(dep)}`);
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
if (unusedDevDependencies > 0) {
|
|
1999
|
-
const packageLocation = `${location}/package.json`;
|
|
2000
|
-
console.log(` ${chalk23.yellow(packageLocation)}
|
|
2001
|
-
`);
|
|
2002
|
-
}
|
|
2003
|
-
return unusedDevDependencies;
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
2007
|
-
import chalk24 from "chalk";
|
|
2008
|
-
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
|
|
2009
|
-
let unusedDependencies = 0;
|
|
2010
|
-
for (const dep of peerDependencies) {
|
|
2011
|
-
if (exclude?.has(dep)) continue;
|
|
2012
|
-
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
2013
|
-
unusedDependencies++;
|
|
2014
|
-
if (dependencies.includes(dep)) {
|
|
2015
|
-
console.log(`[${chalk24.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk24.red(dep)}`);
|
|
2016
|
-
} else {
|
|
2017
|
-
console.log(`[${chalk24.blue(name)}] Unused peerDependency in package.json: ${chalk24.red(dep)}`);
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
if (unusedDependencies > 0) {
|
|
2022
|
-
const packageLocation = `${location}/package.json`;
|
|
2023
|
-
console.log(` ${chalk24.yellow(packageLocation)}
|
|
2024
|
-
`);
|
|
2025
|
-
}
|
|
2026
|
-
return unusedDependencies;
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
2030
|
-
function logVerbose(name, location, allFiles, distFiles, tsconfigExtends) {
|
|
2031
|
-
console.info(`Checking package: ${name} at ${location}`);
|
|
2032
|
-
console.info(`All files: ${allFiles.length}, Distribution files: ${distFiles.length}`);
|
|
2033
|
-
for (const file of allFiles) {
|
|
2034
|
-
console.info(`File: ${file}`);
|
|
2035
|
-
}
|
|
2036
|
-
for (const file of distFiles) {
|
|
2037
|
-
console.info(`Distribution file: ${file}`);
|
|
2038
|
-
}
|
|
2039
|
-
for (const ext of tsconfigExtends) {
|
|
2040
|
-
console.info(`Tsconfig extends: ${ext}`);
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
function checkPackage({
|
|
2044
|
-
name,
|
|
2045
|
-
location,
|
|
2046
|
-
deps = false,
|
|
2047
|
-
devDeps = false,
|
|
2048
|
-
exclude,
|
|
2049
|
-
peerDeps = false,
|
|
2050
|
-
verbose = false
|
|
2051
|
-
}) {
|
|
2052
|
-
const { allFiles, distFiles } = findFiles(location);
|
|
2053
|
-
const tsconfigExtends = getExtendsFromTsconfigs(location);
|
|
2054
|
-
if (verbose) {
|
|
2055
|
-
logVerbose(name, location, allFiles, distFiles, tsconfigExtends);
|
|
2056
|
-
}
|
|
2057
|
-
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
2058
|
-
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
2059
|
-
const checkPeerDeps = peerDeps;
|
|
2060
|
-
const sourceParams = getExternalImportsFromFiles({
|
|
2061
|
-
allFiles,
|
|
2062
|
-
distFiles,
|
|
2063
|
-
tsconfigExtends
|
|
2064
|
-
});
|
|
2065
|
-
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
2066
|
-
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
2067
|
-
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
2068
|
-
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
2069
|
-
const fileContext = { allFiles, distFiles };
|
|
2070
|
-
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext, exclude) : 0;
|
|
2071
|
-
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
2072
|
-
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
2073
|
-
return totalErrors;
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
|
-
// src/actions/deplint/deplint.ts
|
|
2077
|
-
var deplint = async ({
|
|
2078
|
-
pkg,
|
|
2079
|
-
deps,
|
|
2080
|
-
devDeps,
|
|
2081
|
-
peerDeps,
|
|
2082
|
-
verbose,
|
|
2083
|
-
cliExclude
|
|
2084
|
-
}) => {
|
|
2085
|
-
const config2 = await loadConfig();
|
|
2086
|
-
const exclude = /* @__PURE__ */ new Set([
|
|
2087
|
-
...config2.deplint?.exclude ?? [],
|
|
2088
|
-
...cliExclude ?? []
|
|
2089
|
-
]);
|
|
2090
|
-
let totalErrors = 0;
|
|
2091
|
-
if (pkg === void 0) {
|
|
2092
|
-
const workspaces = yarnWorkspaces();
|
|
2093
|
-
console.info("Deplint Started...");
|
|
2094
|
-
for (const workspace of workspaces) {
|
|
2095
|
-
totalErrors += checkPackage({
|
|
2096
|
-
...workspace,
|
|
2097
|
-
deps,
|
|
2098
|
-
devDeps,
|
|
2099
|
-
exclude,
|
|
2100
|
-
peerDeps,
|
|
2101
|
-
verbose
|
|
2102
|
-
});
|
|
2103
|
-
}
|
|
2104
|
-
} else {
|
|
2105
|
-
const { location, name } = yarnWorkspace(pkg);
|
|
2106
|
-
console.info(`Running Deplint for ${name}`);
|
|
2107
|
-
totalErrors += checkPackage({
|
|
2108
|
-
name,
|
|
2109
|
-
location,
|
|
2110
|
-
devDeps,
|
|
2111
|
-
deps,
|
|
2112
|
-
exclude,
|
|
2113
|
-
peerDeps,
|
|
2114
|
-
verbose
|
|
2115
|
-
});
|
|
2116
|
-
}
|
|
2117
|
-
if (totalErrors > 0) {
|
|
2118
|
-
console.warn(`Deplint: Found ${chalk25.red(totalErrors)} dependency problems. ${chalk25.red("\u2716")}`);
|
|
2119
|
-
} else {
|
|
2120
|
-
console.info(`Deplint: Found no dependency problems. ${chalk25.green("\u2714")}`);
|
|
2121
|
-
}
|
|
2122
|
-
return 0;
|
|
2123
|
-
};
|
|
2124
|
-
|
|
2125
|
-
// src/actions/deploy.ts
|
|
2126
|
-
import { readFileSync as readFileSync12 } from "fs";
|
|
2127
|
-
var privatePackageExcludeList = () => {
|
|
2128
|
-
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
2129
|
-
workspace,
|
|
2130
|
-
JSON.parse(readFileSync12(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
2131
|
-
]);
|
|
2132
|
-
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
2133
|
-
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
2134
|
-
return excludeList;
|
|
2135
|
-
};
|
|
2136
|
-
var deploy = () => {
|
|
2137
|
-
const excludeList = privatePackageExcludeList();
|
|
2138
|
-
if (excludeList.length > 0) {
|
|
2139
|
-
console.log("Excluding private packages from deployment:", excludeList);
|
|
2140
|
-
}
|
|
2141
|
-
return runSteps("Deploy [Patch]", [
|
|
2142
|
-
["yarn", "workspaces foreach --all version patch --deferred"],
|
|
2143
|
-
["yarn", "xy clean"],
|
|
2144
|
-
["yarn", "xy build"],
|
|
2145
|
-
["yarn", "version apply --all"]
|
|
2146
|
-
]);
|
|
2147
|
-
};
|
|
2148
|
-
|
|
2149
|
-
// src/actions/deploy-major.ts
|
|
2150
|
-
import { readFileSync as readFileSync13 } from "fs";
|
|
2151
|
-
var privatePackageExcludeList2 = () => {
|
|
2152
|
-
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
2153
|
-
workspace,
|
|
2154
|
-
JSON.parse(readFileSync13(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
2155
|
-
]);
|
|
2156
|
-
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
2157
|
-
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
2158
|
-
return excludeList;
|
|
2159
|
-
};
|
|
2160
|
-
var deployMajor = () => {
|
|
2161
|
-
const excludeList = privatePackageExcludeList2();
|
|
2162
|
-
if (excludeList.length > 0) {
|
|
2163
|
-
console.log("Excluding private packages from deployment:", excludeList);
|
|
2164
|
-
}
|
|
2165
|
-
return runSteps("Deploy [Major]", [
|
|
2166
|
-
["yarn", "workspaces foreach --all version major --deferred"],
|
|
2167
|
-
["yarn", "xy clean"],
|
|
2168
|
-
["yarn", "xy build"],
|
|
2169
|
-
["yarn", "version apply --all"]
|
|
2170
|
-
]);
|
|
2171
|
-
};
|
|
2172
|
-
|
|
2173
|
-
// src/actions/deploy-minor.ts
|
|
2174
|
-
import { readFileSync as readFileSync14 } from "fs";
|
|
2175
|
-
var privatePackageExcludeList3 = () => {
|
|
2176
|
-
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
2177
|
-
workspace,
|
|
2178
|
-
JSON.parse(readFileSync14(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
2179
|
-
]);
|
|
2180
|
-
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
2181
|
-
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
2182
|
-
return excludeList;
|
|
2183
|
-
};
|
|
2184
|
-
var deployMinor = () => {
|
|
2185
|
-
const excludeList = privatePackageExcludeList3();
|
|
2186
|
-
if (excludeList.length > 0) {
|
|
2187
|
-
console.log("Excluding private packages from deployment:", excludeList);
|
|
2188
|
-
}
|
|
2189
|
-
return runSteps("Deploy [Minor]", [
|
|
2190
|
-
["yarn", "workspaces foreach --all version minor --deferred"],
|
|
2191
|
-
["yarn", "xy clean"],
|
|
2192
|
-
["yarn", "xy build"],
|
|
2193
|
-
["yarn", "version apply --all"]
|
|
2194
|
-
]);
|
|
2195
|
-
};
|
|
2196
|
-
|
|
2197
|
-
// src/actions/deploy-next.ts
|
|
2198
|
-
import { readFileSync as readFileSync15 } from "fs";
|
|
2199
|
-
var privatePackageExcludeList4 = () => {
|
|
2200
|
-
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
2201
|
-
workspace,
|
|
2202
|
-
JSON.parse(readFileSync15(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
2203
|
-
]);
|
|
2204
|
-
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
2205
|
-
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
2206
|
-
return excludeList;
|
|
2207
|
-
};
|
|
2208
|
-
var deployNext = () => {
|
|
2209
|
-
const excludeList = privatePackageExcludeList4();
|
|
2210
|
-
if (excludeList.length > 0) {
|
|
2211
|
-
console.log("Excluding private packages from deployment:", excludeList);
|
|
2212
|
-
}
|
|
2213
|
-
return runSteps("Deploy [Next]", [
|
|
2214
|
-
["yarn", "workspaces foreach --all version minor --deferred"],
|
|
2215
|
-
["yarn", "xy clean"],
|
|
2216
|
-
["yarn", "xy build"],
|
|
2217
|
-
["yarn", "version apply --all --prerelease"]
|
|
2218
|
-
]);
|
|
2219
|
-
};
|
|
2220
|
-
|
|
2221
|
-
// src/actions/dupdeps.ts
|
|
2222
|
-
import chalk26 from "chalk";
|
|
2223
|
-
var dupdeps = () => {
|
|
2224
|
-
console.log(chalk26.green("Checking all Dependencies for Duplicates"));
|
|
2225
|
-
const pkg = parsedPackageJSON();
|
|
2226
|
-
const allDependencies = { ...pkg?.dependencies, ...pkg?.devDependencies };
|
|
2227
|
-
const dependencies = Object.keys(allDependencies);
|
|
2228
|
-
return detectDuplicateDependencies(dependencies);
|
|
2229
|
-
};
|
|
2230
|
-
|
|
2231
|
-
// src/actions/lint.ts
|
|
2232
|
-
import chalk27 from "chalk";
|
|
2233
|
-
var lintPackage = ({
|
|
2234
|
-
pkg,
|
|
2235
|
-
fix: fix2,
|
|
2236
|
-
verbose
|
|
2237
|
-
}) => {
|
|
2238
|
-
console.log(chalk27.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2239
|
-
const start = Date.now();
|
|
2240
|
-
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2241
|
-
["yarn", [
|
|
2242
|
-
"workspace",
|
|
2243
|
-
pkg,
|
|
2244
|
-
"run",
|
|
2245
|
-
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2246
|
-
]]
|
|
2247
|
-
]);
|
|
2248
|
-
console.log(chalk27.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk27.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk27.gray("seconds")}`));
|
|
2249
|
-
return result;
|
|
2250
|
-
};
|
|
2251
|
-
var lint = ({
|
|
2252
|
-
pkg,
|
|
2253
|
-
verbose,
|
|
2254
|
-
incremental,
|
|
2255
|
-
fix: fix2
|
|
2256
|
-
} = {}) => {
|
|
2257
|
-
return pkg === void 0 ? lintAllPackages({
|
|
2258
|
-
verbose,
|
|
2259
|
-
incremental,
|
|
2260
|
-
fix: fix2
|
|
2261
|
-
}) : lintPackage({
|
|
2262
|
-
pkg,
|
|
2263
|
-
fix: fix2,
|
|
2264
|
-
verbose
|
|
2265
|
-
});
|
|
2266
|
-
};
|
|
2267
|
-
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2268
|
-
console.log(chalk27.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2269
|
-
const start = Date.now();
|
|
2270
|
-
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2271
|
-
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2272
|
-
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
2273
|
-
]);
|
|
2274
|
-
console.log(chalk27.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk27.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk27.gray("seconds")}`));
|
|
2275
|
-
return result;
|
|
2276
|
-
};
|
|
2277
|
-
|
|
2278
|
-
// src/actions/fix.ts
|
|
2279
|
-
var fix = (params) => {
|
|
2280
|
-
return lint({ ...params, fix: true });
|
|
2281
|
-
};
|
|
2282
|
-
|
|
2283
|
-
// src/actions/gen-docs.ts
|
|
2284
|
-
var genDocs = ({ pkg, incremental }) => {
|
|
2285
|
-
return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental });
|
|
2286
|
-
};
|
|
2287
|
-
var genDocsPackage = ({ pkg }) => {
|
|
2288
|
-
const steps = [["yarn", ["workspace", pkg, "run", "package-gen-docs"]]];
|
|
2289
|
-
return runSteps(`GenDocs [${pkg}]`, [...steps]);
|
|
2290
|
-
};
|
|
2291
|
-
var genDocsAll = ({ incremental }) => {
|
|
2292
|
-
const incrementalOptions = incremental ? ["--since", "-pA"] : ["-pA"];
|
|
2293
|
-
const steps = [["yarn", ["workspaces", "foreach", ...incrementalOptions, "run", "package-gen-docs"]]];
|
|
2294
|
-
return runSteps(`GenDocs [All${incremental ? "-Incremental" : ""}]`, [...steps]);
|
|
2295
|
-
};
|
|
2296
|
-
|
|
2297
|
-
// src/actions/gitignore.ts
|
|
2298
|
-
import { unlinkSync as unlinkSync4 } from "fs";
|
|
2299
|
-
import chalk28 from "chalk";
|
|
2300
|
-
var COMMENT_PREFIX = "#";
|
|
2301
|
-
var isComment = (line) => line.startsWith(COMMENT_PREFIX);
|
|
2302
|
-
var isNegation = (line) => line.startsWith("!");
|
|
2303
|
-
function parseTemplateSections(lines) {
|
|
2304
|
-
const sections = [];
|
|
2305
|
-
let current = [];
|
|
2306
|
-
for (const line of lines) {
|
|
2307
|
-
if (isComment(line)) {
|
|
2308
|
-
if (current.length > 0) {
|
|
2309
|
-
sections.push(current);
|
|
2310
|
-
}
|
|
2311
|
-
current = [line];
|
|
2312
|
-
} else {
|
|
2313
|
-
current.push(line);
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
if (current.length > 0) {
|
|
2317
|
-
sections.push(current);
|
|
2318
|
-
}
|
|
2319
|
-
return sections;
|
|
2320
|
-
}
|
|
2321
|
-
function mergeWithTemplate(existing, templateContent) {
|
|
2322
|
-
const templateLines = templateContent.split("\n").filter((line) => line.trim().length > 0);
|
|
2323
|
-
const sections = parseTemplateSections(templateLines);
|
|
2324
|
-
const existingEntries = new Set(existing.filter((line) => !isComment(line)));
|
|
2325
|
-
const templateEntries = new Set(templateLines.filter((line) => !isComment(line)));
|
|
2326
|
-
const customEntries = [...existingEntries].filter((entry) => !templateEntries.has(entry));
|
|
2327
|
-
const result = [];
|
|
2328
|
-
for (const section of sections) {
|
|
2329
|
-
for (const line of section) {
|
|
2330
|
-
result.push(line);
|
|
2331
|
-
}
|
|
2332
|
-
result.push("");
|
|
2333
|
-
}
|
|
2334
|
-
if (customEntries.length > 0) {
|
|
2335
|
-
result.push("# Custom");
|
|
2336
|
-
const sorted = [...union(customEntries, [])].toSorted((a, b) => {
|
|
2337
|
-
if (isNegation(a) && !isNegation(b)) return 1;
|
|
2338
|
-
if (!isNegation(a) && isNegation(b)) return -1;
|
|
2339
|
-
return a.localeCompare(b);
|
|
2340
|
-
});
|
|
2341
|
-
for (const entry of sorted) {
|
|
2342
|
-
result.push(entry);
|
|
2343
|
-
}
|
|
2344
|
-
result.push("");
|
|
2345
|
-
}
|
|
2346
|
-
return result;
|
|
2347
|
-
}
|
|
2348
|
-
function removePackageGitignores(cwd5) {
|
|
2349
|
-
let removed = 0;
|
|
2350
|
-
const workspaces = yarnWorkspaces();
|
|
2351
|
-
for (const { location } of workspaces) {
|
|
2352
|
-
if (location === ".") continue;
|
|
2353
|
-
const filePath = `${cwd5}/${location}/.gitignore`;
|
|
2354
|
-
try {
|
|
2355
|
-
unlinkSync4(filePath);
|
|
2356
|
-
console.log(chalk28.yellow(` Removed ${location}/.gitignore`));
|
|
2357
|
-
removed++;
|
|
2358
|
-
} catch {
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
return removed;
|
|
2362
|
-
}
|
|
2363
|
-
var gitignoreGen = gitignore;
|
|
2364
|
-
function gitignore() {
|
|
2365
|
-
console.log(chalk28.green("Generate .gitignore"));
|
|
2366
|
-
const cwd5 = INIT_CWD() ?? ".";
|
|
2367
|
-
const gitignorePath = `${cwd5}/.gitignore`;
|
|
2368
|
-
try {
|
|
2369
|
-
const templateContent = gitignoreTemplate();
|
|
2370
|
-
const existing = readNonEmptyLines(gitignorePath);
|
|
2371
|
-
const merged = mergeWithTemplate(existing, templateContent);
|
|
2372
|
-
writeLines(gitignorePath, merged);
|
|
2373
|
-
console.log(chalk28.green(" Root .gitignore updated"));
|
|
2374
|
-
const removed = removePackageGitignores(cwd5);
|
|
2375
|
-
if (removed > 0) {
|
|
2376
|
-
console.log(chalk28.green(` Removed ${removed} package .gitignore file(s)`));
|
|
2377
|
-
}
|
|
2378
|
-
return 0;
|
|
2379
|
-
} catch (ex) {
|
|
2380
|
-
const error = ex;
|
|
2381
|
-
console.error(chalk28.red(`Generate .gitignore failed: ${error.message}`));
|
|
2382
|
-
return 1;
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
|
|
2386
|
-
// src/actions/gitlint.ts
|
|
2387
|
-
import chalk29 from "chalk";
|
|
2388
|
-
import ParseGitConfig from "parse-git-config";
|
|
2389
|
-
var gitlint = () => {
|
|
2390
|
-
console.log(`
|
|
2391
|
-
Gitlint Start [${process.cwd()}]
|
|
2392
|
-
`);
|
|
2393
|
-
let valid = 0;
|
|
2394
|
-
let warnings = 0;
|
|
2395
|
-
const errors = 0;
|
|
2396
|
-
const gitConfig = ParseGitConfig.sync();
|
|
2397
|
-
const warn = (message) => {
|
|
2398
|
-
console.warn(chalk29.yellow(`Warning: ${message}`));
|
|
2399
|
-
warnings++;
|
|
2400
|
-
};
|
|
2401
|
-
if (gitConfig.core.ignorecase) {
|
|
2402
|
-
warn("Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]");
|
|
2403
|
-
} else {
|
|
2404
|
-
valid++;
|
|
2405
|
-
}
|
|
2406
|
-
if (gitConfig.core.autocrlf === false) {
|
|
2407
|
-
valid++;
|
|
2408
|
-
} else {
|
|
2409
|
-
warn("Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]");
|
|
2410
|
-
}
|
|
2411
|
-
if (gitConfig.core.eol === "lf") {
|
|
2412
|
-
valid++;
|
|
2413
|
-
} else {
|
|
2414
|
-
warn('Please set core.eol to "lf" in .git/config file [run yarn gitlint-fix]');
|
|
2415
|
-
}
|
|
2416
|
-
const resultMessages = [];
|
|
2417
|
-
if (valid > 0) {
|
|
2418
|
-
resultMessages.push(chalk29.green(`Passed: ${valid}`));
|
|
2419
|
-
}
|
|
2420
|
-
if (warnings > 0) {
|
|
2421
|
-
resultMessages.push(chalk29.yellow(`Warnings: ${warnings}`));
|
|
2422
|
-
}
|
|
2423
|
-
if (errors > 0) {
|
|
2424
|
-
resultMessages.push(chalk29.red(` Errors: ${errors}`));
|
|
2425
|
-
}
|
|
2426
|
-
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
2427
|
-
`);
|
|
2428
|
-
return warnings + errors === 0 ? 1 : 0;
|
|
2429
|
-
};
|
|
2430
|
-
|
|
2431
|
-
// src/actions/gitlint-fix.ts
|
|
2432
|
-
import { execSync as execSync3 } from "child_process";
|
|
2433
|
-
import chalk30 from "chalk";
|
|
2434
|
-
import ParseGitConfig2 from "parse-git-config";
|
|
2435
|
-
var gitlintFix = () => {
|
|
2436
|
-
console.log(`
|
|
2437
|
-
Gitlint Fix Start [${process.cwd()}]
|
|
2438
|
-
`);
|
|
2439
|
-
const gitConfig = ParseGitConfig2.sync();
|
|
2440
|
-
if (gitConfig.core.ignorecase) {
|
|
2441
|
-
execSync3("git config core.ignorecase false", { stdio: "inherit" });
|
|
2442
|
-
console.warn(chalk30.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
2443
|
-
}
|
|
2444
|
-
if (gitConfig.core.autocrlf !== false) {
|
|
2445
|
-
execSync3("git config core.autocrlf false", { stdio: "inherit" });
|
|
2446
|
-
console.warn(chalk30.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
2447
|
-
}
|
|
2448
|
-
if (gitConfig.core.eol !== "lf") {
|
|
2449
|
-
execSync3("git config core.eol lf", { stdio: "inherit" });
|
|
2450
|
-
console.warn(chalk30.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
2451
|
-
}
|
|
2452
|
-
return 1;
|
|
2453
|
-
};
|
|
2454
|
-
|
|
2455
|
-
// src/actions/knip.ts
|
|
2456
|
-
var knip = () => {
|
|
2457
|
-
return runSteps("Knip", [["yarn", ["knip", "--dependencies", "--no-exit-code"]]]);
|
|
2458
|
-
};
|
|
2459
|
-
|
|
2460
|
-
// src/actions/license.ts
|
|
2461
|
-
import chalk31 from "chalk";
|
|
2462
|
-
import { init } from "license-checker";
|
|
2463
|
-
var license = async (pkg) => {
|
|
2464
|
-
const workspaces = yarnWorkspaces();
|
|
2465
|
-
const workspaceList = workspaces.filter(({ name }) => {
|
|
2466
|
-
return pkg === void 0 || name === pkg;
|
|
2467
|
-
});
|
|
2468
|
-
const exclude = /* @__PURE__ */ new Set([
|
|
2469
|
-
"MIT",
|
|
2470
|
-
"MIT*",
|
|
2471
|
-
"ISC",
|
|
2472
|
-
"Apache-2.0",
|
|
2473
|
-
"BSD",
|
|
2474
|
-
"BSD*",
|
|
2475
|
-
"BSD-2-Clause",
|
|
2476
|
-
"BSD-3-Clause",
|
|
2477
|
-
"CC-BY-4.0",
|
|
2478
|
-
"Unlicense",
|
|
2479
|
-
"CC-BY-3.0",
|
|
2480
|
-
"CC0-1.0",
|
|
2481
|
-
"LGPL-3.0-only",
|
|
2482
|
-
"LGPL-3.0",
|
|
2483
|
-
"LGPL-3.0-or-later",
|
|
2484
|
-
"Python-2.0"
|
|
2485
|
-
]);
|
|
2486
|
-
console.log(chalk31.green("License Checker"));
|
|
2487
|
-
return (await Promise.all(
|
|
2488
|
-
workspaceList.map(({ location, name }) => {
|
|
2489
|
-
return new Promise((resolve) => {
|
|
2490
|
-
init({ production: true, start: location }, (error, packages) => {
|
|
2491
|
-
if (error) {
|
|
2492
|
-
console.error(chalk31.red(`License Checker [${name}] Error`));
|
|
2493
|
-
console.error(chalk31.gray(error));
|
|
2494
|
-
console.log("\n");
|
|
2495
|
-
resolve(1);
|
|
2496
|
-
} else {
|
|
2497
|
-
console.log(chalk31.green(`License Checker [${name}]`));
|
|
2498
|
-
let count = 0;
|
|
2499
|
-
for (const [name2, info] of Object.entries(packages)) {
|
|
2500
|
-
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
2501
|
-
for (let license2 of licenses) {
|
|
2502
|
-
if (license2) {
|
|
2503
|
-
const processedLicense = license2[0] === "(" && license2.at(-1) === ")" ? license2.slice(1, -2) : license2;
|
|
2504
|
-
const orLicenses = processedLicense.split(" OR ");
|
|
2505
|
-
let orLicenseFound = false;
|
|
2506
|
-
for (const orLicense of orLicenses) {
|
|
2507
|
-
if (exclude.has(orLicense)) {
|
|
2508
|
-
orLicenseFound = true;
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
if (!orLicenseFound) {
|
|
2512
|
-
count++;
|
|
2513
|
-
console.warn(chalk31.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
console.log("\n");
|
|
2519
|
-
resolve(count);
|
|
2520
|
-
}
|
|
2521
|
-
});
|
|
2522
|
-
});
|
|
2523
|
-
})
|
|
2524
|
-
)).reduce((prev, value) => prev || value, 0);
|
|
2525
|
-
};
|
|
2526
|
-
|
|
2527
|
-
// src/actions/npmignore-gen.ts
|
|
2528
|
-
var filename = ".npmignore";
|
|
2529
|
-
var npmignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
2530
|
-
|
|
2531
|
-
// src/actions/package/clean-outputs.ts
|
|
2532
|
-
import path8 from "path";
|
|
2533
|
-
import chalk32 from "chalk";
|
|
2534
|
-
var packageCleanOutputs = () => {
|
|
2535
|
-
const pkg = process.env.INIT_CWD ?? ".";
|
|
2536
|
-
const pkgName = process.env.npm_package_name;
|
|
2537
|
-
const folders = [path8.join(pkg, "dist"), path8.join(pkg, "build"), path8.join(pkg, "docs")];
|
|
2538
|
-
console.log(chalk32.green(`Cleaning Outputs [${pkgName}]`));
|
|
2539
|
-
for (let folder of folders) {
|
|
2540
|
-
deleteGlob(folder);
|
|
2541
|
-
}
|
|
2542
|
-
return 0;
|
|
2543
|
-
};
|
|
2544
|
-
|
|
2545
|
-
// src/actions/package/clean-typescript.ts
|
|
2546
|
-
import path9 from "path";
|
|
2547
|
-
import chalk33 from "chalk";
|
|
2548
|
-
var packageCleanTypescript = () => {
|
|
2549
|
-
const pkg = process.env.INIT_CWD ?? ".";
|
|
2550
|
-
const pkgName = process.env.npm_package_name;
|
|
2551
|
-
console.log(chalk33.green(`Cleaning Typescript [${pkgName}]`));
|
|
2552
|
-
const files = [path9.join(pkg, "*.tsbuildinfo"), path9.join(pkg, ".tsconfig.*"), path9.join(pkg, ".eslintcache")];
|
|
2553
|
-
for (let file of files) {
|
|
2554
|
-
deleteGlob(file);
|
|
2555
|
-
}
|
|
2556
|
-
return 0;
|
|
2557
|
-
};
|
|
2558
|
-
|
|
2559
|
-
// src/actions/package/clean.ts
|
|
2560
|
-
var packageClean = async () => {
|
|
2561
|
-
return (await Promise.all([packageCleanOutputs(), packageCleanTypescript()])).reduce((prev, value) => prev + value, 0);
|
|
2562
|
-
};
|
|
2563
|
-
|
|
2564
|
-
// src/actions/package/compile/compile.ts
|
|
2565
|
-
import chalk38 from "chalk";
|
|
2566
|
-
|
|
2567
|
-
// src/actions/package/compile/packageCompileTsup.ts
|
|
2568
|
-
import chalk37 from "chalk";
|
|
2569
|
-
import { build as build2, defineConfig } from "tsup";
|
|
2570
|
-
|
|
2571
|
-
// src/actions/package/compile/inputs.ts
|
|
2572
|
-
import chalk34 from "chalk";
|
|
2573
|
-
import { glob as glob2 } from "glob";
|
|
2574
|
-
var getAllInputs = (srcDir, verbose = false) => {
|
|
2575
|
-
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
2576
|
-
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
2577
|
-
if (verbose) {
|
|
2578
|
-
console.log(chalk34.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
2579
|
-
}
|
|
2580
|
-
return result;
|
|
2581
|
-
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
2582
|
-
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
2583
|
-
if (verbose) {
|
|
2584
|
-
console.log(chalk34.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
2585
|
-
}
|
|
2586
|
-
return result;
|
|
2587
|
-
})];
|
|
2588
|
-
};
|
|
2589
|
-
|
|
2590
|
-
// src/actions/package/compile/buildEntries.ts
|
|
2591
|
-
var isSpecOrStory = (entry) => {
|
|
2592
|
-
return entry.includes(".spec.") || entry.includes(".stories.") || entry.startsWith("spec/") || entry.includes("/spec/") || entry.startsWith("stories/") || entry.includes("/stories/") || entry === "spec.ts" || entry.endsWith("/spec.ts") || entry === "stories.ts" || entry.endsWith("/stories.ts");
|
|
2593
|
-
};
|
|
2594
|
-
var buildEntries = (srcDir, entryMode = "single", options, excludeSpecAndStories = true, verbose = false) => {
|
|
2595
|
-
let entries = [];
|
|
2596
|
-
switch (entryMode) {
|
|
2597
|
-
case "platform": {
|
|
2598
|
-
entries = ["index-node.ts", "index-browser.ts"];
|
|
2599
|
-
break;
|
|
2600
|
-
}
|
|
2601
|
-
case "all": {
|
|
2602
|
-
entries = (excludeSpecAndStories ? getAllInputs(srcDir).filter((entry) => !isSpecOrStory(entry)) : getAllInputs(srcDir)).filter((entry) => !entry.endsWith(".d.ts"));
|
|
2603
|
-
break;
|
|
2604
|
-
}
|
|
2605
|
-
case "custom": {
|
|
2606
|
-
entries = [];
|
|
2607
|
-
break;
|
|
2608
|
-
}
|
|
2609
|
-
default: {
|
|
2610
|
-
entries = ["index.ts"];
|
|
2611
|
-
break;
|
|
2612
|
-
}
|
|
2613
|
-
}
|
|
2614
|
-
if (typeof options !== "boolean" && Array.isArray(options?.entry)) {
|
|
2615
|
-
entries.push(...options.entry);
|
|
2616
|
-
}
|
|
2617
|
-
if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`);
|
|
2618
|
-
return entries;
|
|
2619
|
-
};
|
|
2620
|
-
|
|
2621
|
-
// src/actions/package/compile/deepMerge.ts
|
|
2622
|
-
function deepMerge(target, source) {
|
|
2623
|
-
if (!source || typeof source !== "object") return target;
|
|
2624
|
-
for (const key of Object.keys(source)) {
|
|
2625
|
-
if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
2626
|
-
if (!target[key] || typeof target[key] !== "object") {
|
|
2627
|
-
target[key] = {};
|
|
2628
|
-
}
|
|
2629
|
-
deepMerge(target[key], source[key]);
|
|
2630
|
-
} else {
|
|
2631
|
-
target[key] = source[key];
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
return target;
|
|
2635
|
-
}
|
|
2636
|
-
function deepMergeObjects(objects) {
|
|
2637
|
-
const result = {};
|
|
2638
|
-
for (const obj of objects) {
|
|
2639
|
-
deepMerge(result, obj);
|
|
2640
|
-
}
|
|
2641
|
-
return result;
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2644
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
2645
|
-
import { cwd as cwd2 } from "process";
|
|
2646
|
-
import chalk35 from "chalk";
|
|
2647
|
-
import { createProgramFromConfig } from "tsc-prog";
|
|
2648
|
-
import ts3, {
|
|
2649
|
-
DiagnosticCategory,
|
|
2650
|
-
formatDiagnosticsWithColorAndContext,
|
|
2651
|
-
getPreEmitDiagnostics,
|
|
2652
|
-
sys
|
|
2653
|
-
} from "typescript";
|
|
2654
|
-
|
|
2655
|
-
// src/actions/package/compile/getCompilerOptions.ts
|
|
2656
|
-
import { cwd } from "process";
|
|
2657
|
-
import deepmerge2 from "deepmerge";
|
|
2658
|
-
import { getTsconfig } from "get-tsconfig";
|
|
2659
|
-
var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
2660
|
-
const resolvedTsConfigCompilerOptions = getTsconfig(cwd(), fileName)?.config?.compilerOptions ?? {};
|
|
2661
|
-
return deepmerge2(resolvedTsConfigCompilerOptions, options);
|
|
2662
|
-
};
|
|
2663
|
-
|
|
2664
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
2665
|
-
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
2666
|
-
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
2667
|
-
if (verbose) {
|
|
2668
|
-
console.log(chalk35.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2669
|
-
}
|
|
2670
|
-
const configFilePath = ts3.findConfigFile(
|
|
2671
|
-
"./",
|
|
2672
|
-
// search path
|
|
2673
|
-
ts3.sys.fileExists,
|
|
2674
|
-
"tsconfig.json"
|
|
2675
|
-
);
|
|
2676
|
-
if (configFilePath === void 0) {
|
|
2677
|
-
throw new Error("Could not find tsconfig.json");
|
|
2678
|
-
}
|
|
2679
|
-
const compilerOptions = {
|
|
2680
|
-
...getCompilerOptions({
|
|
2681
|
-
removeComments: false,
|
|
2682
|
-
skipDefaultLibCheck: true,
|
|
2683
|
-
skipLibCheck: true,
|
|
2684
|
-
sourceMap: false
|
|
2685
|
-
}),
|
|
2686
|
-
...compilerOptionsParam,
|
|
2687
|
-
outDir: `${outDir}/${platform}`,
|
|
2688
|
-
emitDeclarationOnly: true,
|
|
2689
|
-
noEmit: false
|
|
2690
|
-
};
|
|
2691
|
-
console.log(chalk35.cyan(`Validating Files: ${entries.length}`));
|
|
2692
|
-
if (verbose) {
|
|
2693
|
-
for (const entry of entries) {
|
|
2694
|
-
console.log(chalk35.grey(`Validating: ${entry}`));
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
try {
|
|
2698
|
-
if (entries.length > 0) {
|
|
2699
|
-
const program = createProgramFromConfig({
|
|
2700
|
-
configFilePath,
|
|
2701
|
-
basePath: pkg ?? cwd2(),
|
|
2702
|
-
compilerOptions,
|
|
2703
|
-
files: entries.map((entry) => `${srcDir}/${entry}`),
|
|
2704
|
-
include: [`${srcDir}/**/*.*`]
|
|
2705
|
-
});
|
|
2706
|
-
const diagnostics = getPreEmitDiagnostics(program);
|
|
2707
|
-
if (diagnostics.length > 0) {
|
|
2708
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
|
|
2709
|
-
diagnostics,
|
|
2710
|
-
{
|
|
2711
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
2712
|
-
getCurrentDirectory: () => srcDir,
|
|
2713
|
-
getNewLine: () => sys.newLine
|
|
2714
|
-
}
|
|
2715
|
-
);
|
|
2716
|
-
console.error(formattedDiagnostics);
|
|
2717
|
-
}
|
|
2718
|
-
const nonEmitPatterns = [".stories.", "/stories/", "/stories.", ".spec.", "/spec/", "/spec.", ".example."];
|
|
2719
|
-
program.emit(void 0, (fileName, text, writeByteOrderMark) => {
|
|
2720
|
-
if (nonEmitPatterns.some((pattern) => fileName.includes(pattern))) {
|
|
2721
|
-
return;
|
|
2722
|
-
}
|
|
2723
|
-
ts3.sys.writeFile(fileName, text, writeByteOrderMark);
|
|
2724
|
-
});
|
|
2725
|
-
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
2726
|
-
}
|
|
2727
|
-
return 0;
|
|
2728
|
-
} finally {
|
|
2729
|
-
if (verbose) {
|
|
2730
|
-
console.log(chalk35.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
};
|
|
2734
|
-
|
|
2735
|
-
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
2736
|
-
import path10 from "path";
|
|
2737
|
-
import { cwd as cwd3 } from "process";
|
|
2738
|
-
import chalk36 from "chalk";
|
|
2739
|
-
import { rollup } from "rollup";
|
|
2740
|
-
import dts from "rollup-plugin-dts";
|
|
2741
|
-
import nodeExternals from "rollup-plugin-node-externals";
|
|
2742
|
-
var ignoredWarningCodes = /* @__PURE__ */ new Set(["EMPTY_BUNDLE", "UNRESOLVED_IMPORT"]);
|
|
2743
|
-
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
2744
|
-
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
2745
|
-
const tsconfigPath = path10.resolve(pkg, "tsconfig.json");
|
|
2746
|
-
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
2747
|
-
try {
|
|
2748
|
-
const bundle = await rollup({
|
|
2749
|
-
input: inputPath,
|
|
2750
|
-
plugins: [dts({
|
|
2751
|
-
...options,
|
|
2752
|
-
tsconfig: tsconfigPath,
|
|
2753
|
-
compilerOptions: {
|
|
2754
|
-
emitDeclarationOnly: true,
|
|
2755
|
-
noEmit: false,
|
|
2756
|
-
declarationMap: true
|
|
2757
|
-
}
|
|
2758
|
-
}), ...nodePlugIns],
|
|
2759
|
-
onwarn(warning, warn) {
|
|
2760
|
-
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
2761
|
-
return;
|
|
2762
|
-
}
|
|
2763
|
-
console.warn(chalk36.yellow(`[${warning.code}] ${warning.message}`));
|
|
2764
|
-
console.warn(chalk36.gray(inputPath));
|
|
2765
|
-
warn(warning);
|
|
2766
|
-
}
|
|
2767
|
-
});
|
|
2768
|
-
await bundle.write({
|
|
2769
|
-
file: outputPath,
|
|
2770
|
-
format: "es"
|
|
2771
|
-
});
|
|
2772
|
-
} catch (ex) {
|
|
2773
|
-
const error = ex;
|
|
2774
|
-
console.warn(chalk36.red(error));
|
|
2775
|
-
console.warn(chalk36.gray(inputPath));
|
|
2776
|
-
}
|
|
2777
|
-
if (verbose) {
|
|
2778
|
-
console.log(`Bundled declarations written to ${outputPath}`);
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
2782
|
-
if (verbose) {
|
|
2783
|
-
console.log(chalk36.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2784
|
-
console.log(`Entries: ${entries.join(", ")}`);
|
|
2785
|
-
}
|
|
2786
|
-
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
2787
|
-
const srcRoot = `${pkg}/${srcDir}/${platform}`;
|
|
2788
|
-
const entryNameToTypeName = (entry) => {
|
|
2789
|
-
const splitEntryName = entry.split(".");
|
|
2790
|
-
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
2791
|
-
return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
|
|
2792
|
-
};
|
|
2793
|
-
const compilerOptions = getCompilerOptions({
|
|
2794
|
-
removeComments: false,
|
|
2795
|
-
skipDefaultLibCheck: true,
|
|
2796
|
-
skipLibCheck: true,
|
|
2797
|
-
declarationMap: true,
|
|
2798
|
-
emitDeclarationOnly: true,
|
|
2799
|
-
noEmit: true
|
|
2800
|
-
});
|
|
2801
|
-
const entryNames = entries.map((entry) => entry.split(`${srcDir}/`).at(-1) ?? entry);
|
|
2802
|
-
await Promise.all(entryNames.map(async (entryName) => {
|
|
2803
|
-
const entryTypeName = entryNameToTypeName(entryName);
|
|
2804
|
-
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
2805
|
-
}));
|
|
2806
|
-
if (verbose) {
|
|
2807
|
-
console.log(chalk36.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2808
|
-
}
|
|
2809
|
-
return 0;
|
|
2810
|
-
};
|
|
2811
|
-
|
|
2812
|
-
// src/actions/package/compile/packageCompileTsup.ts
|
|
2813
|
-
var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = false, verbose) => {
|
|
2814
|
-
const outDir = options?.outDir ?? "dist";
|
|
2815
|
-
if (verbose) {
|
|
2816
|
-
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
2817
|
-
}
|
|
2818
|
-
if (entries.length === 0) {
|
|
2819
|
-
console.warn(chalk37.yellow(`No entries found in ${srcDir} to compile`));
|
|
2820
|
-
return 0;
|
|
2821
|
-
}
|
|
2822
|
-
if (verbose) {
|
|
2823
|
-
console.log(chalk37.gray(`buildDir [${buildDir}]`));
|
|
2824
|
-
}
|
|
2825
|
-
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
2826
|
-
if (validationResult !== 0) {
|
|
2827
|
-
console.error(chalk37.red(`Compile:Validation had ${validationResult} errors`));
|
|
2828
|
-
return validationResult;
|
|
2829
|
-
}
|
|
2830
|
-
const optionsParams = tsupOptions([{
|
|
2831
|
-
bundle: true,
|
|
2832
|
-
cjsInterop: true,
|
|
2833
|
-
clean: false,
|
|
2834
|
-
dts: false,
|
|
2835
|
-
format: ["esm"],
|
|
2836
|
-
outDir,
|
|
2837
|
-
silent: true,
|
|
2838
|
-
sourcemap: true,
|
|
2839
|
-
splitting: false,
|
|
2840
|
-
tsconfig: "tsconfig.json",
|
|
2841
|
-
...options,
|
|
2842
|
-
entry: entries.map((entry) => `${srcDir}/${entry}`)
|
|
2843
|
-
}]);
|
|
2844
|
-
const optionsResult = defineConfig(optionsParams);
|
|
2845
|
-
const optionsList = (await Promise.all(
|
|
2846
|
-
(Array.isArray(optionsResult) ? optionsResult : [optionsResult]).flatMap(async (options2) => {
|
|
2847
|
-
const result = typeof options2 === "function" ? await options2({}) : [options2];
|
|
2848
|
-
return Array.isArray(result) ? result : [result];
|
|
2849
|
-
})
|
|
2850
|
-
)).flat();
|
|
2851
|
-
if (verbose) {
|
|
2852
|
-
console.log(chalk37.cyan(`TSUP:build:start [${srcDir}]`));
|
|
2853
|
-
console.log(chalk37.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
2854
|
-
}
|
|
2855
|
-
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
2856
|
-
if (verbose) {
|
|
2857
|
-
console.log(chalk37.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
2858
|
-
}
|
|
2859
|
-
if (bundleTypes) {
|
|
2860
|
-
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
2861
|
-
}
|
|
2862
|
-
return 0;
|
|
2863
|
-
};
|
|
2864
|
-
var tsupOptions = (options = []) => {
|
|
2865
|
-
const standardLoaders = {
|
|
2866
|
-
".gif": "copy",
|
|
2867
|
-
".html": "copy",
|
|
2868
|
-
".jpg": "copy",
|
|
2869
|
-
".json": "json",
|
|
2870
|
-
".png": "copy",
|
|
2871
|
-
".svg": "text",
|
|
2872
|
-
".webp": "copy"
|
|
2873
|
-
};
|
|
2874
|
-
const standardOptions = {
|
|
2875
|
-
bundle: true,
|
|
2876
|
-
format: ["esm"],
|
|
2877
|
-
loader: standardLoaders,
|
|
2878
|
-
outExtension: ({ format }) => format === "esm" ? { js: ".mjs" } : { js: ".cjs" },
|
|
2879
|
-
skipNodeModulesBundle: true,
|
|
2880
|
-
sourcemap: true,
|
|
2881
|
-
target: "esnext"
|
|
2882
|
-
};
|
|
2883
|
-
return deepMergeObjects([standardOptions, ...options]);
|
|
2884
|
-
};
|
|
2885
|
-
var packageCompileTsup = async (config2) => {
|
|
2886
|
-
const compile2 = config2?.compile;
|
|
2887
|
-
const verbose = config2?.verbose ?? false;
|
|
2888
|
-
const outDirAsBuildDir = compile2?.outDirAsBuildDir ?? true;
|
|
2889
|
-
const bundleTypes = compile2?.bundleTypes ?? false;
|
|
2890
|
-
if (verbose) {
|
|
2891
|
-
console.log("Compiling with TSUP");
|
|
2892
|
-
}
|
|
2893
|
-
const compileForNode = compile2?.node ?? { src: {} };
|
|
2894
|
-
const compileForBrowser = compile2?.browser ?? { src: {} };
|
|
2895
|
-
const compileForNeutral = compile2?.neutral ?? { src: {} };
|
|
2896
|
-
return (await Promise.all(
|
|
2897
|
-
Object.entries(compileForNode).map(async ([srcDir, options]) => {
|
|
2898
|
-
const optionsObject = typeof options === "object" ? options : {};
|
|
2899
|
-
const inEsBuildOptions = typeof compile2?.node?.esbuildOptions === "object" ? compile2?.node?.esbuildOptions : {};
|
|
2900
|
-
const entry = buildEntries(srcDir, compile2?.entryMode, options, true, verbose);
|
|
2901
|
-
const platform = "node";
|
|
2902
|
-
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
2903
|
-
const outDir = rootOutDir + "/" + platform;
|
|
2904
|
-
return typeof srcDir === "string" ? await compileFolder(
|
|
2905
|
-
srcDir,
|
|
2906
|
-
entry,
|
|
2907
|
-
outDirAsBuildDir ? rootOutDir : "build",
|
|
2908
|
-
tsupOptions([
|
|
2909
|
-
inEsBuildOptions,
|
|
2910
|
-
compile2?.tsup?.options ?? {},
|
|
2911
|
-
typeof options === "object" ? options : {},
|
|
2912
|
-
{ platform: "node", outDir }
|
|
2913
|
-
]),
|
|
2914
|
-
bundleTypes,
|
|
2915
|
-
verbose
|
|
2916
|
-
) : 0;
|
|
2917
|
-
})
|
|
2918
|
-
)).reduce((prev, value) => prev + value, 0) + (await Promise.all(
|
|
2919
|
-
Object.entries(compileForBrowser).map(async ([srcDir, options]) => {
|
|
2920
|
-
const optionsObject = typeof options === "object" ? options : {};
|
|
2921
|
-
const inEsBuildOptions = typeof compile2?.browser?.esbuildOptions === "object" ? compile2?.browser?.esbuildOptions : {};
|
|
2922
|
-
const entry = buildEntries(srcDir, compile2?.entryMode, options, true, verbose);
|
|
2923
|
-
const platform = "browser";
|
|
2924
|
-
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
2925
|
-
const outDir = rootOutDir + "/" + platform;
|
|
2926
|
-
return typeof srcDir === "string" ? await compileFolder(
|
|
2927
|
-
srcDir,
|
|
2928
|
-
entry,
|
|
2929
|
-
outDirAsBuildDir ? rootOutDir : "build",
|
|
2930
|
-
tsupOptions([
|
|
2931
|
-
inEsBuildOptions,
|
|
2932
|
-
compile2?.tsup?.options ?? {},
|
|
2933
|
-
typeof options === "object" ? options : {},
|
|
2934
|
-
{ platform: "browser", outDir }
|
|
2935
|
-
]),
|
|
2936
|
-
bundleTypes,
|
|
2937
|
-
verbose
|
|
2938
|
-
) : 0;
|
|
2939
|
-
})
|
|
2940
|
-
)).reduce((prev, value) => prev + value, 0) + (await Promise.all(
|
|
2941
|
-
Object.entries(compileForNeutral).map(async ([srcDir, options]) => {
|
|
2942
|
-
const optionsObject = typeof options === "object" ? options : {};
|
|
2943
|
-
const inEsBuildOptions = typeof compile2?.neutral?.esbuildOptions === "object" ? compile2?.neutral?.esbuildOptions : {};
|
|
2944
|
-
const entry = buildEntries(srcDir, compile2?.entryMode, options, true, verbose);
|
|
2945
|
-
const platform = "neutral";
|
|
2946
|
-
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
2947
|
-
const outDir = rootOutDir + "/" + platform;
|
|
2948
|
-
return typeof srcDir === "string" ? await compileFolder(
|
|
2949
|
-
srcDir,
|
|
2950
|
-
entry,
|
|
2951
|
-
outDirAsBuildDir ? rootOutDir : "build",
|
|
2952
|
-
tsupOptions([
|
|
2953
|
-
inEsBuildOptions,
|
|
2954
|
-
compile2?.tsup?.options ?? {},
|
|
2955
|
-
typeof options === "object" ? options : {},
|
|
2956
|
-
{ platform: "neutral", outDir }
|
|
2957
|
-
]),
|
|
2958
|
-
bundleTypes,
|
|
2959
|
-
verbose
|
|
2960
|
-
) : 0;
|
|
2961
|
-
})
|
|
2962
|
-
)).reduce((prev, value) => prev + value, 0) + 0;
|
|
2963
|
-
};
|
|
2964
|
-
|
|
2965
|
-
// src/actions/package/compile/compile.ts
|
|
2966
|
-
var packageCompile = async (inConfig = {}) => {
|
|
2967
|
-
const pkg = process.env.INIT_CWD;
|
|
2968
|
-
console.log(chalk38.green(`Compiling ${pkg}`));
|
|
2969
|
-
const config2 = await loadConfig(inConfig);
|
|
2970
|
-
return await packageCompileTsup(config2);
|
|
2971
|
-
};
|
|
2972
|
-
|
|
2973
|
-
// src/actions/package/copy-assets.ts
|
|
2974
|
-
import path11 from "path/posix";
|
|
2975
|
-
import chalk39 from "chalk";
|
|
2976
|
-
import cpy2 from "cpy";
|
|
2977
|
-
var copyTargetAssets2 = async (target, name, location) => {
|
|
2978
|
-
try {
|
|
2979
|
-
const values = await cpy2(
|
|
2980
|
-
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
2981
|
-
`../dist/${target}`,
|
|
2982
|
-
{
|
|
2983
|
-
cwd: path11.join(location, "src"),
|
|
2984
|
-
flat: false
|
|
2985
|
-
}
|
|
2986
|
-
);
|
|
2987
|
-
if (values.length > 0) {
|
|
2988
|
-
console.log(chalk39.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
2989
|
-
}
|
|
2990
|
-
for (const value of values) {
|
|
2991
|
-
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
2992
|
-
}
|
|
2993
|
-
return 0;
|
|
2994
|
-
} catch (ex) {
|
|
2995
|
-
const error = ex;
|
|
2996
|
-
console.log(`Copy Assets Failed: ${name}: ${error.message}`);
|
|
2997
|
-
return 1;
|
|
2998
|
-
}
|
|
2999
|
-
};
|
|
3000
|
-
var packageCopyAssets = async ({ target }) => {
|
|
3001
|
-
const pkg = process.env.INIT_CWD ?? "./";
|
|
3002
|
-
const pkgName = process.env.npm_package_name ?? "Unknown";
|
|
3003
|
-
switch (target) {
|
|
3004
|
-
case "esm": {
|
|
3005
|
-
return await copyTargetAssets2("esm", pkgName, pkg);
|
|
3006
|
-
}
|
|
3007
|
-
case "cjs": {
|
|
3008
|
-
return await copyTargetAssets2("cjs", pkgName, pkg);
|
|
3009
|
-
}
|
|
3010
|
-
default: {
|
|
3011
|
-
return await copyTargetAssets2("esm", pkgName, pkg) || await copyTargetAssets2("cjs", pkgName, pkg);
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
|
-
};
|
|
3015
|
-
|
|
3016
|
-
// src/actions/package/cycle.ts
|
|
3017
|
-
import { cruise as cruise2 } from "dependency-cruiser";
|
|
3018
|
-
var packageCycle = async () => {
|
|
3019
|
-
const pkg = process.env.INIT_CWD;
|
|
3020
|
-
const pkgName = process.env.npm_package_name;
|
|
3021
|
-
const cruiseOptions = {
|
|
3022
|
-
ruleSet: {
|
|
3023
|
-
forbidden: [
|
|
3024
|
-
{
|
|
3025
|
-
name: "no-circular",
|
|
3026
|
-
severity: "error",
|
|
3027
|
-
comment: "This dependency creates a circular reference",
|
|
3028
|
-
from: {},
|
|
3029
|
-
to: { circular: true }
|
|
3030
|
-
}
|
|
3031
|
-
]
|
|
3032
|
-
},
|
|
3033
|
-
exclude: "node_modules|packages/.*/packages",
|
|
3034
|
-
validate: true,
|
|
3035
|
-
doNotFollow: { path: "node_modules|packages/.*/packages" },
|
|
3036
|
-
tsPreCompilationDeps: false,
|
|
3037
|
-
combinedDependencies: true,
|
|
3038
|
-
outputType: "err"
|
|
3039
|
-
};
|
|
3040
|
-
const target = `${pkg}/src`;
|
|
3041
|
-
console.log(`Checking for circular dependencies in ${target}...`);
|
|
3042
|
-
const result = await cruise2([target], cruiseOptions);
|
|
3043
|
-
console.log(result.output);
|
|
3044
|
-
if (result.exitCode === 0) {
|
|
3045
|
-
console.log(`${pkgName} \u2705 No dependency violations`);
|
|
3046
|
-
} else {
|
|
3047
|
-
console.error(`${pkgName} \u274C Dependency violations found`);
|
|
3048
|
-
}
|
|
3049
|
-
return result.exitCode;
|
|
3050
|
-
};
|
|
3051
|
-
|
|
3052
|
-
// src/actions/package/gen-docs.ts
|
|
3053
|
-
import { existsSync as existsSync10 } from "fs";
|
|
3054
|
-
import path12 from "path";
|
|
3055
|
-
import chalk40 from "chalk";
|
|
3056
|
-
import {
|
|
3057
|
-
Application,
|
|
3058
|
-
ArgumentsReader,
|
|
3059
|
-
TSConfigReader,
|
|
3060
|
-
TypeDocReader
|
|
3061
|
-
} from "typedoc";
|
|
3062
|
-
var ExitCodes = {
|
|
3063
|
-
CompileError: 3,
|
|
3064
|
-
ExceptionThrown: 6,
|
|
3065
|
-
NoEntryPoints: 2,
|
|
3066
|
-
Ok: 0,
|
|
3067
|
-
OptionError: 1,
|
|
3068
|
-
OutputError: 5,
|
|
3069
|
-
ValidationError: 4
|
|
3070
|
-
};
|
|
3071
|
-
var packageGenDocs = async () => {
|
|
3072
|
-
const pkg = process.env.INIT_CWD;
|
|
3073
|
-
if (pkg !== void 0 && !existsSync10(path12.join(pkg, "typedoc.json"))) {
|
|
3074
|
-
return;
|
|
3075
|
-
}
|
|
3076
|
-
const app = await Application.bootstrap({
|
|
3077
|
-
entryPointStrategy: "merge",
|
|
3078
|
-
entryPoints: [`${pkg}/src/**/*.ts`, `${pkg}/packages/*/dist/docs.json`],
|
|
3079
|
-
excludeExternals: true,
|
|
3080
|
-
json: `${pkg}/dist/docs.json`,
|
|
3081
|
-
logLevel: "Error",
|
|
3082
|
-
tsconfig: `${pkg}/tsconfig.json`
|
|
3083
|
-
});
|
|
3084
|
-
app.options.addReader(new ArgumentsReader(0));
|
|
3085
|
-
app.options.addReader(new TypeDocReader());
|
|
3086
|
-
app.options.addReader(new TSConfigReader());
|
|
3087
|
-
app.options.addReader(new ArgumentsReader(300));
|
|
3088
|
-
return await runTypeDoc(app);
|
|
3089
|
-
};
|
|
3090
|
-
var runTypeDoc = async (app) => {
|
|
3091
|
-
const pkgName = process.env.npm_package_name;
|
|
3092
|
-
if (app.options.getValue("version")) {
|
|
3093
|
-
console.log(app.toString());
|
|
3094
|
-
return ExitCodes.Ok;
|
|
3095
|
-
}
|
|
3096
|
-
if (app.options.getValue("showConfig")) {
|
|
3097
|
-
console.log(app.options.getRawValues());
|
|
3098
|
-
return ExitCodes.Ok;
|
|
3099
|
-
}
|
|
3100
|
-
if (app.logger.hasErrors()) {
|
|
3101
|
-
return ExitCodes.OptionError;
|
|
3102
|
-
}
|
|
3103
|
-
if (app.options.getValue("treatWarningsAsErrors") && app.logger.hasWarnings()) {
|
|
3104
|
-
return ExitCodes.OptionError;
|
|
3105
|
-
}
|
|
3106
|
-
if (app.options.getValue("entryPoints").length === 0) {
|
|
3107
|
-
app.logger.error("No entry points provided");
|
|
3108
|
-
return ExitCodes.NoEntryPoints;
|
|
3109
|
-
}
|
|
3110
|
-
if (app.options.getValue("watch")) {
|
|
3111
|
-
await app.convertAndWatch(async (project2) => {
|
|
3112
|
-
const out = app.options.getValue("out");
|
|
3113
|
-
if (out) {
|
|
3114
|
-
await app.generateDocs(project2, out);
|
|
3115
|
-
}
|
|
3116
|
-
const json = app.options.getValue("json");
|
|
3117
|
-
if (json) {
|
|
3118
|
-
await app.generateJson(project2, json);
|
|
3119
|
-
}
|
|
3120
|
-
if (!out && !json) {
|
|
3121
|
-
await app.generateDocs(project2, "./docs");
|
|
3122
|
-
}
|
|
3123
|
-
});
|
|
3124
|
-
return ExitCodes.Ok;
|
|
3125
|
-
}
|
|
3126
|
-
const project = await app.convert();
|
|
3127
|
-
if (!project) {
|
|
3128
|
-
return ExitCodes.CompileError;
|
|
3129
|
-
}
|
|
3130
|
-
if (app.options.getValue("treatWarningsAsErrors") && app.logger.hasWarnings()) {
|
|
3131
|
-
return ExitCodes.CompileError;
|
|
3132
|
-
}
|
|
3133
|
-
app.validate(project);
|
|
3134
|
-
if (app.logger.hasErrors()) {
|
|
3135
|
-
return ExitCodes.ValidationError;
|
|
3136
|
-
}
|
|
3137
|
-
if (app.options.getValue("treatWarningsAsErrors") && app.logger.hasWarnings()) {
|
|
3138
|
-
return ExitCodes.ValidationError;
|
|
3139
|
-
}
|
|
3140
|
-
if (app.options.getValue("emit") !== "none") {
|
|
3141
|
-
const out = app.options.getValue("out");
|
|
3142
|
-
if (out) {
|
|
3143
|
-
await app.generateDocs(project, out);
|
|
3144
|
-
}
|
|
3145
|
-
const json = app.options.getValue("json");
|
|
3146
|
-
if (json) {
|
|
3147
|
-
await app.generateJson(project, json);
|
|
3148
|
-
}
|
|
3149
|
-
if (!out && !json) {
|
|
3150
|
-
await app.generateDocs(project, "./docs");
|
|
3151
|
-
}
|
|
3152
|
-
if (app.logger.hasErrors()) {
|
|
3153
|
-
return ExitCodes.OutputError;
|
|
3154
|
-
}
|
|
3155
|
-
if (app.options.getValue("treatWarningsAsErrors") && app.logger.hasWarnings()) {
|
|
3156
|
-
return ExitCodes.OutputError;
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
console.log(chalk40.green(`${pkgName} - Ok`));
|
|
3160
|
-
return ExitCodes.Ok;
|
|
3161
|
-
};
|
|
3162
|
-
|
|
3163
|
-
// src/actions/package/lint.ts
|
|
3164
|
-
import { readdirSync as readdirSync6 } from "fs";
|
|
3165
|
-
import path13 from "path";
|
|
3166
|
-
import { cwd as cwd4 } from "process";
|
|
3167
|
-
import { pathToFileURL } from "url";
|
|
3168
|
-
import chalk41 from "chalk";
|
|
3169
|
-
import { ESLint } from "eslint";
|
|
3170
|
-
import { findUp } from "find-up";
|
|
3171
|
-
import picomatch from "picomatch";
|
|
3172
|
-
var dumpMessages = (lintResults) => {
|
|
3173
|
-
const colors = ["white", "yellow", "red"];
|
|
3174
|
-
const severity = ["none", "warning", "error"];
|
|
3175
|
-
for (const lintResult of lintResults) {
|
|
3176
|
-
if (lintResult.messages.length > 0) {
|
|
3177
|
-
console.log(chalk41.gray(`
|
|
3178
|
-
${lintResult.filePath}`));
|
|
3179
|
-
for (const message of lintResult.messages) {
|
|
3180
|
-
console.log(
|
|
3181
|
-
chalk41.gray(` ${message.line}:${message.column}`),
|
|
3182
|
-
chalk41[colors[message.severity]](` ${severity[message.severity]}`),
|
|
3183
|
-
chalk41.white(` ${message.message}`),
|
|
3184
|
-
chalk41.gray(` ${message.ruleId}`)
|
|
3185
|
-
);
|
|
3186
|
-
}
|
|
3187
|
-
}
|
|
3188
|
-
}
|
|
3189
|
-
};
|
|
3190
|
-
async function getRootESLintConfig() {
|
|
3191
|
-
const configPath = await findUp("eslint.config.mjs");
|
|
3192
|
-
if (configPath === void 0) {
|
|
3193
|
-
throw new Error("eslint.config.mjs not found in the monorepo");
|
|
3194
|
-
}
|
|
3195
|
-
return pathToFileURL(configPath);
|
|
3196
|
-
}
|
|
3197
|
-
function getFiles(dir, ignoreFolders) {
|
|
3198
|
-
const currentDirectory = cwd4();
|
|
3199
|
-
const subDirectory = dir.split(currentDirectory)[1]?.split("/")[1];
|
|
3200
|
-
if (ignoreFolders.includes(subDirectory)) return [];
|
|
3201
|
-
return readdirSync6(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
3202
|
-
const res = path13.resolve(dir, dirent.name);
|
|
3203
|
-
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
3204
|
-
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
3205
|
-
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
3206
|
-
return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [res];
|
|
3207
|
-
});
|
|
3208
|
-
}
|
|
3209
|
-
var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
3210
|
-
const pkg = process.env.INIT_CWD;
|
|
3211
|
-
const configPath = await getRootESLintConfig();
|
|
3212
|
-
const { default: eslintConfig } = await import(configPath.href);
|
|
3213
|
-
const start = Date.now();
|
|
3214
|
-
const ignoreFolders = ["node_modules", "dist", "packages", ".git", "build", ".yarn", ".vscode", ".github"];
|
|
3215
|
-
const engine = new ESLint({
|
|
3216
|
-
baseConfig: [...eslintConfig],
|
|
3217
|
-
fix: fix2,
|
|
3218
|
-
warnIgnored: false,
|
|
3219
|
-
cache
|
|
3220
|
-
});
|
|
3221
|
-
const files = getFiles(cwd4(), ignoreFolders);
|
|
3222
|
-
console.log(chalk41.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
3223
|
-
if (verbose) {
|
|
3224
|
-
for (const file of files) {
|
|
3225
|
-
console.log(chalk41.gray(` ${file}`));
|
|
3226
|
-
}
|
|
3227
|
-
}
|
|
3228
|
-
const lintResults = await engine.lintFiles(files);
|
|
3229
|
-
dumpMessages(lintResults);
|
|
3230
|
-
if (fix2) {
|
|
3231
|
-
await ESLint.outputFixes(lintResults);
|
|
3232
|
-
}
|
|
3233
|
-
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
3234
|
-
const lintTime = Date.now() - start;
|
|
3235
|
-
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
3236
|
-
console.log(chalk41.white(`Linted ${chalk41[filesCountColor](files.length)} files in ${chalk41[lintTimeColor](lintTime)}ms`));
|
|
3237
|
-
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
3238
|
-
};
|
|
3239
|
-
|
|
3240
|
-
// src/actions/package/publint.ts
|
|
3241
|
-
import { promises as fs10 } from "fs";
|
|
3242
|
-
import chalk42 from "chalk";
|
|
3243
|
-
import sortPackageJson from "sort-package-json";
|
|
3244
|
-
var customPubLint = (pkg) => {
|
|
3245
|
-
let errorCount = 0;
|
|
3246
|
-
let warningCount = 0;
|
|
3247
|
-
if (pkg.files === void 0) {
|
|
3248
|
-
console.warn(chalk42.yellow('Publint [custom]: "files" field is missing'));
|
|
3249
|
-
warningCount++;
|
|
3250
|
-
}
|
|
3251
|
-
if (pkg.main !== void 0) {
|
|
3252
|
-
console.warn(chalk42.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
3253
|
-
warningCount++;
|
|
3254
|
-
}
|
|
3255
|
-
if (pkg.sideEffects !== false) {
|
|
3256
|
-
console.warn(chalk42.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
3257
|
-
warningCount++;
|
|
3258
|
-
}
|
|
3259
|
-
if (pkg.resolutions !== void 0) {
|
|
3260
|
-
console.warn(chalk42.yellow('Publint [custom]: "resolutions" in use'));
|
|
3261
|
-
console.warn(chalk42.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
3262
|
-
warningCount++;
|
|
3263
|
-
}
|
|
3264
|
-
return [errorCount, warningCount];
|
|
3265
|
-
};
|
|
3266
|
-
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
3267
|
-
const pkgDir = process.env.INIT_CWD;
|
|
3268
|
-
const sortedPkg = sortPackageJson(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
3269
|
-
await fs10.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
3270
|
-
const pkg = JSON.parse(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
3271
|
-
console.log(chalk42.green(`Publint: ${pkg.name}`));
|
|
3272
|
-
console.log(chalk42.gray(pkgDir));
|
|
3273
|
-
const { publint: publint2 } = await import("publint");
|
|
3274
|
-
const { messages } = await publint2({
|
|
3275
|
-
level: "suggestion",
|
|
3276
|
-
pkgDir,
|
|
3277
|
-
strict
|
|
3278
|
-
});
|
|
3279
|
-
const { formatMessage } = await import("publint/utils");
|
|
3280
|
-
for (const message of messages) {
|
|
3281
|
-
switch (message.type) {
|
|
3282
|
-
case "error": {
|
|
3283
|
-
console.error(chalk42.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
3284
|
-
break;
|
|
3285
|
-
}
|
|
3286
|
-
case "warning": {
|
|
3287
|
-
console.warn(chalk42.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
3288
|
-
break;
|
|
3289
|
-
}
|
|
3290
|
-
default: {
|
|
3291
|
-
console.log(chalk42.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
3292
|
-
break;
|
|
3293
|
-
}
|
|
3294
|
-
}
|
|
3295
|
-
}
|
|
3296
|
-
const [errorCount, warningCount] = customPubLint(pkg);
|
|
3297
|
-
if (verbose) {
|
|
3298
|
-
console.log(chalk42.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
3299
|
-
}
|
|
3300
|
-
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
3301
|
-
};
|
|
3302
|
-
|
|
3303
|
-
// src/actions/package/recompile.ts
|
|
3304
|
-
var packageRecompile = async () => {
|
|
3305
|
-
return await packageClean() || await packageCompile();
|
|
3306
|
-
};
|
|
3307
|
-
|
|
3308
|
-
// src/actions/package-lint.ts
|
|
3309
|
-
import { readFileSync as readFileSync16, writeFileSync as writeFileSync6 } from "fs";
|
|
3310
|
-
import PATH10 from "path";
|
|
3311
|
-
import chalk43 from "chalk";
|
|
3312
|
-
import picomatch2 from "picomatch";
|
|
3313
|
-
function emptyResult() {
|
|
3314
|
-
return {
|
|
3315
|
-
errors: [],
|
|
3316
|
-
fixable: [],
|
|
3317
|
-
warnings: []
|
|
3318
|
-
};
|
|
3319
|
-
}
|
|
3320
|
-
function readRootPackageJson(cwd5) {
|
|
3321
|
-
const raw = readFileSync16(PATH10.resolve(cwd5, "package.json"), "utf8");
|
|
3322
|
-
return JSON.parse(raw);
|
|
3323
|
-
}
|
|
3324
|
-
function writeRootPackageJson(cwd5, pkg) {
|
|
3325
|
-
const path14 = PATH10.resolve(cwd5, "package.json");
|
|
3326
|
-
writeFileSync6(path14, `${JSON.stringify(pkg, null, 2)}
|
|
3327
|
-
`, "utf8");
|
|
3328
|
-
}
|
|
3329
|
-
function isMonorepo(pkg) {
|
|
3330
|
-
const workspaces = pkg.workspaces;
|
|
3331
|
-
return Array.isArray(workspaces) && workspaces.length > 0;
|
|
3332
|
-
}
|
|
3333
|
-
function checkPackagesFolder(workspaces) {
|
|
3334
|
-
const result = emptyResult();
|
|
3335
|
-
for (const { location, name } of workspaces) {
|
|
3336
|
-
if (location === ".") continue;
|
|
3337
|
-
if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
|
|
3338
|
-
result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
|
-
return result;
|
|
3342
|
-
}
|
|
3343
|
-
function checkRootPrivate(pkg) {
|
|
3344
|
-
const result = emptyResult();
|
|
3345
|
-
if (!pkg.private) {
|
|
3346
|
-
result.fixable.push("Root package.json must be private to prevent accidental publishing");
|
|
3347
|
-
}
|
|
3348
|
-
return result;
|
|
3349
|
-
}
|
|
3350
|
-
function fixRootPrivate(cwd5, pkg) {
|
|
3351
|
-
pkg.private = true;
|
|
3352
|
-
writeRootPackageJson(cwd5, pkg);
|
|
3353
|
-
console.log(chalk43.green(' \u2714 Fixed: set "private": true in root package.json'));
|
|
3354
|
-
}
|
|
3355
|
-
function checkNoPublishConfigOnPrivate(pkg) {
|
|
3356
|
-
const result = emptyResult();
|
|
3357
|
-
if (pkg.private && pkg.publishConfig) {
|
|
3358
|
-
result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
|
|
3359
|
-
}
|
|
3360
|
-
return result;
|
|
3361
|
-
}
|
|
3362
|
-
function fixNoPublishConfigOnPrivate(cwd5, pkg) {
|
|
3363
|
-
delete pkg.publishConfig;
|
|
3364
|
-
writeRootPackageJson(cwd5, pkg);
|
|
3365
|
-
console.log(chalk43.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
|
|
3366
|
-
}
|
|
3367
|
-
function checkDiscoverable(pkg, workspaces) {
|
|
3368
|
-
const result = emptyResult();
|
|
3369
|
-
const globs = pkg.workspaces;
|
|
3370
|
-
const matchers = globs.map((glob3) => picomatch2(glob3));
|
|
3371
|
-
const isMatch = (location) => matchers.some((m) => m(location));
|
|
3372
|
-
for (const { location, name } of workspaces) {
|
|
3373
|
-
if (location === ".") continue;
|
|
3374
|
-
if (!isMatch(location)) {
|
|
3375
|
-
result.errors.push(`${name} (${location}) is not matched by any workspace glob in package.json`);
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
return result;
|
|
3379
|
-
}
|
|
3380
|
-
function logResults(label, result, fix2) {
|
|
3381
|
-
let errors = 0;
|
|
3382
|
-
let fixed = 0;
|
|
3383
|
-
for (const error of result.errors) {
|
|
3384
|
-
console.log(chalk43.red(` \u2717 ${error}`));
|
|
3385
|
-
errors++;
|
|
3386
|
-
}
|
|
3387
|
-
for (const fixable of result.fixable) {
|
|
3388
|
-
if (fix2) {
|
|
3389
|
-
fixed++;
|
|
3390
|
-
} else {
|
|
3391
|
-
console.log(chalk43.red(` \u2717 ${fixable} (fixable)`));
|
|
3392
|
-
errors++;
|
|
3393
|
-
}
|
|
3394
|
-
}
|
|
3395
|
-
for (const warning of result.warnings) {
|
|
3396
|
-
console.log(chalk43.yellow(` \u26A0 ${warning}`));
|
|
3397
|
-
}
|
|
3398
|
-
if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
|
|
3399
|
-
console.log(chalk43.green(` \u2713 ${label}`));
|
|
3400
|
-
}
|
|
3401
|
-
return { errors, fixed };
|
|
3402
|
-
}
|
|
3403
|
-
function runChecks(entries, cwd5, pkg, fix2) {
|
|
3404
|
-
let totalErrors = 0;
|
|
3405
|
-
let totalFixed = 0;
|
|
3406
|
-
for (const entry of entries) {
|
|
3407
|
-
const result = entry.check();
|
|
3408
|
-
const log = logResults(entry.label, result, fix2);
|
|
3409
|
-
if (fix2 && entry.fix && result.fixable.length > 0) {
|
|
3410
|
-
entry.fix(cwd5, pkg);
|
|
3411
|
-
}
|
|
3412
|
-
totalErrors += log.errors;
|
|
3413
|
-
totalFixed += log.fixed;
|
|
3414
|
-
}
|
|
3415
|
-
return { errors: totalErrors, fixed: totalFixed };
|
|
3416
|
-
}
|
|
3417
|
-
function logSummary(errors, fixed) {
|
|
3418
|
-
if (fixed > 0) {
|
|
3419
|
-
console.log(chalk43.green(`
|
|
3420
|
-
Fixed ${fixed} issue(s)`));
|
|
3421
|
-
}
|
|
3422
|
-
if (errors > 0) {
|
|
3423
|
-
console.log(chalk43.red(`
|
|
3424
|
-
${errors} error(s) found`));
|
|
3425
|
-
} else if (fixed === 0) {
|
|
3426
|
-
console.log(chalk43.green("\n All checks passed"));
|
|
3427
|
-
}
|
|
3428
|
-
}
|
|
3429
|
-
function packageLintMonorepo(fix2 = false) {
|
|
3430
|
-
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
3431
|
-
let pkg;
|
|
3432
|
-
try {
|
|
3433
|
-
pkg = readRootPackageJson(cwd5);
|
|
3434
|
-
} catch {
|
|
3435
|
-
console.error(chalk43.red("Could not read package.json"));
|
|
3436
|
-
return 1;
|
|
3437
|
-
}
|
|
3438
|
-
if (!isMonorepo(pkg)) {
|
|
3439
|
-
console.log(chalk43.gray("Not a monorepo \u2014 skipping package-lint checks"));
|
|
3440
|
-
return 0;
|
|
3441
|
-
}
|
|
3442
|
-
console.log(chalk43.green("Package Lint"));
|
|
3443
|
-
const workspaces = yarnWorkspaces();
|
|
3444
|
-
const checks = [
|
|
3445
|
-
{
|
|
3446
|
-
check: () => checkRootPrivate(pkg),
|
|
3447
|
-
fix: fixRootPrivate,
|
|
3448
|
-
label: "Root package is private"
|
|
3449
|
-
},
|
|
3450
|
-
{
|
|
3451
|
-
check: () => checkNoPublishConfigOnPrivate(pkg),
|
|
3452
|
-
fix: fixNoPublishConfigOnPrivate,
|
|
3453
|
-
label: "No publishConfig on private root"
|
|
3454
|
-
},
|
|
3455
|
-
{ check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
|
|
3456
|
-
{ check: () => checkDiscoverable(pkg, workspaces), label: "All packages are discoverable from workspace globs" }
|
|
3457
|
-
];
|
|
3458
|
-
const { errors, fixed } = runChecks(checks, cwd5, pkg, fix2);
|
|
3459
|
-
logSummary(errors, fixed);
|
|
3460
|
-
return errors > 0 ? 1 : 0;
|
|
3461
|
-
}
|
|
3462
|
-
|
|
3463
|
-
// src/actions/publint.ts
|
|
3464
|
-
var publint = async ({ verbose, pkg }) => {
|
|
3465
|
-
return pkg === void 0 ? publintAll({ verbose }) : await publintPackage({ pkg, verbose });
|
|
3466
|
-
};
|
|
3467
|
-
var publintPackage = ({ pkg }) => {
|
|
3468
|
-
return runStepsAsync(`Publint [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-publint"]]]);
|
|
3469
|
-
};
|
|
3470
|
-
var publintAll = ({ verbose }) => {
|
|
3471
|
-
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
3472
|
-
return runSteps("Publint", [["yarn", ["workspaces", "foreach", "-pA", ...verboseOptions, "run", "package-publint"]]]);
|
|
3473
|
-
};
|
|
3474
|
-
|
|
3475
|
-
// src/actions/publish.ts
|
|
3476
|
-
var publish = () => {
|
|
3477
|
-
return runSteps("Publish", [["npm", ["publish", "--workspaces"]]]);
|
|
3478
|
-
};
|
|
3479
|
-
|
|
3480
|
-
// src/actions/readme-gen.ts
|
|
3481
|
-
async function readmeGen({
|
|
3482
|
-
pkg,
|
|
3483
|
-
templatePath,
|
|
3484
|
-
typedoc,
|
|
3485
|
-
verbose
|
|
3486
|
-
}) {
|
|
3487
|
-
const config2 = await loadConfig();
|
|
3488
|
-
return await generateReadmeFiles({
|
|
3489
|
-
logoLinkUrl: config2.readme?.logoLinkUrl,
|
|
3490
|
-
logoUrl: config2.readme?.logoUrl,
|
|
3491
|
-
pkg,
|
|
3492
|
-
templatePath,
|
|
3493
|
-
typedoc,
|
|
3494
|
-
verbose
|
|
3495
|
-
});
|
|
3496
|
-
}
|
|
3497
|
-
|
|
3498
|
-
// src/actions/readme-init.ts
|
|
3499
|
-
async function readmeInit({ templatePath }) {
|
|
3500
|
-
const config2 = await loadConfig();
|
|
3501
|
-
const template = applyLogoConfig(DEFAULT_README_TEMPLATE, config2.readme?.logoUrl, config2.readme?.logoLinkUrl);
|
|
3502
|
-
const resolvedTemplatePath = resolveTemplatePath(templatePath);
|
|
3503
|
-
await scaffoldTemplate(resolvedTemplatePath, template);
|
|
3504
|
-
return 0;
|
|
3505
|
-
}
|
|
3506
|
-
|
|
3507
|
-
// src/actions/rebuild.ts
|
|
3508
|
-
var rebuild = ({ target }) => {
|
|
3509
|
-
return runSteps("Rebuild", [
|
|
3510
|
-
["yarn", "xy clean"],
|
|
3511
|
-
["yarn", target ? `xy build -t ${target}` : "xy build"]
|
|
3512
|
-
]);
|
|
3513
|
-
};
|
|
3514
|
-
|
|
3515
|
-
// src/actions/recompile.ts
|
|
3516
|
-
import chalk44 from "chalk";
|
|
3517
|
-
var recompile = async ({
|
|
3518
|
-
verbose,
|
|
3519
|
-
target,
|
|
3520
|
-
pkg,
|
|
3521
|
-
incremental
|
|
3522
|
-
}) => {
|
|
3523
|
-
return pkg ? await recompilePackage({
|
|
3524
|
-
pkg,
|
|
3525
|
-
target,
|
|
3526
|
-
verbose
|
|
3527
|
-
}) : await recompileAll({
|
|
3528
|
-
incremental,
|
|
3529
|
-
target,
|
|
3530
|
-
verbose
|
|
3531
|
-
});
|
|
3532
|
-
};
|
|
3533
|
-
var recompilePackage = ({ target, pkg }) => {
|
|
3534
|
-
const targetOptions = target ? ["-t", target] : [];
|
|
3535
|
-
return runStepsAsync(
|
|
3536
|
-
`Recompile [${pkg}]`,
|
|
3537
|
-
[["yarn", ["workspace", pkg, "run", "package-recompile", ...targetOptions]]]
|
|
3538
|
-
);
|
|
3539
|
-
};
|
|
3540
|
-
var recompileAll = async ({
|
|
3541
|
-
jobs,
|
|
3542
|
-
verbose,
|
|
3543
|
-
target,
|
|
3544
|
-
incremental
|
|
3545
|
-
}) => {
|
|
3546
|
-
const start = Date.now();
|
|
3547
|
-
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
3548
|
-
const targetOptions = target ? ["-t", target] : [];
|
|
3549
|
-
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
3550
|
-
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
3551
|
-
if (jobs) {
|
|
3552
|
-
console.log(chalk44.blue(`Jobs set to [${jobs}]`));
|
|
3553
|
-
}
|
|
3554
|
-
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
3555
|
-
[
|
|
3556
|
-
"yarn",
|
|
3557
|
-
[
|
|
3558
|
-
"workspaces",
|
|
3559
|
-
"foreach",
|
|
3560
|
-
...incrementalOptions,
|
|
3561
|
-
...jobsOptions,
|
|
3562
|
-
...verboseOptions,
|
|
3563
|
-
"run",
|
|
3564
|
-
"package-clean",
|
|
3565
|
-
...targetOptions
|
|
3566
|
-
]
|
|
3567
|
-
],
|
|
3568
|
-
[
|
|
3569
|
-
"yarn",
|
|
3570
|
-
[
|
|
3571
|
-
"workspaces",
|
|
3572
|
-
"foreach",
|
|
3573
|
-
...incrementalOptions,
|
|
3574
|
-
...jobsOptions,
|
|
3575
|
-
...verboseOptions,
|
|
3576
|
-
"run",
|
|
3577
|
-
"package-compile",
|
|
3578
|
-
...targetOptions
|
|
3579
|
-
]
|
|
3580
|
-
]
|
|
3581
|
-
]);
|
|
3582
|
-
console.log(
|
|
3583
|
-
`${chalk44.gray("Recompiled in")} [${chalk44.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk44.gray("seconds")}`
|
|
3584
|
-
);
|
|
3585
|
-
return result;
|
|
3586
|
-
};
|
|
3587
|
-
|
|
3588
|
-
// src/actions/reinstall.ts
|
|
3589
|
-
import {
|
|
3590
|
-
closeSync,
|
|
3591
|
-
openSync,
|
|
3592
|
-
rmSync as rmSync3
|
|
3593
|
-
} from "fs";
|
|
3594
|
-
var reinstall = () => {
|
|
3595
|
-
console.log("Reinstall [Clear Lock File]");
|
|
3596
|
-
closeSync(openSync("./yarn.lock", "w"));
|
|
3597
|
-
console.log("Reinstall [Clear Node Modules]");
|
|
3598
|
-
const workspaces = yarnWorkspaces();
|
|
3599
|
-
const result = workspaces.map(({ location, name }) => {
|
|
3600
|
-
const dist = `${location}/node_modules`;
|
|
3601
|
-
try {
|
|
3602
|
-
rmSync3(dist, { force: true, recursive: true });
|
|
3603
|
-
return 0;
|
|
3604
|
-
} catch (ex) {
|
|
3605
|
-
const error = ex;
|
|
3606
|
-
console.error(`Reinstall [Clear Node Modules] Failed [${name}, ${error.message}]`);
|
|
3607
|
-
return 1;
|
|
3608
|
-
}
|
|
3609
|
-
}).reduce((prev, result2) => prev || result2, 0);
|
|
3610
|
-
return result || runSteps("Reinstall", [["yarn", "install --network-timeout 10000"]]);
|
|
3611
|
-
};
|
|
3612
|
-
|
|
3613
|
-
// src/actions/relint.ts
|
|
3614
|
-
import chalk45 from "chalk";
|
|
3615
|
-
var relintPackage = ({
|
|
3616
|
-
pkg,
|
|
3617
|
-
fix: fix2,
|
|
3618
|
-
verbose
|
|
3619
|
-
}) => {
|
|
3620
|
-
console.log(chalk45.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
3621
|
-
const start = Date.now();
|
|
3622
|
-
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
3623
|
-
["yarn", [
|
|
3624
|
-
"workspace",
|
|
3625
|
-
pkg,
|
|
3626
|
-
"run",
|
|
3627
|
-
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
3628
|
-
]]
|
|
3629
|
-
]);
|
|
3630
|
-
console.log(chalk45.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk45.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk45.gray("seconds")}`));
|
|
3631
|
-
return result;
|
|
3632
|
-
};
|
|
3633
|
-
var relint = ({
|
|
3634
|
-
pkg,
|
|
3635
|
-
verbose,
|
|
3636
|
-
incremental,
|
|
3637
|
-
fix: fix2
|
|
3638
|
-
} = {}) => {
|
|
3639
|
-
return pkg === void 0 ? relintAllPackages({
|
|
3640
|
-
verbose,
|
|
3641
|
-
incremental,
|
|
3642
|
-
fix: fix2
|
|
3643
|
-
}) : relintPackage({
|
|
3644
|
-
pkg,
|
|
3645
|
-
fix: fix2,
|
|
3646
|
-
verbose
|
|
3647
|
-
});
|
|
3648
|
-
};
|
|
3649
|
-
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
3650
|
-
console.log(chalk45.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
3651
|
-
const start = Date.now();
|
|
3652
|
-
const fixOptions = fix2 ? ["--fix"] : [];
|
|
3653
|
-
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
3654
|
-
["yarn", ["eslint", ...fixOptions]]
|
|
3655
|
-
]);
|
|
3656
|
-
console.log(chalk45.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk45.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk45.gray("seconds")}`));
|
|
3657
|
-
return result;
|
|
3658
|
-
};
|
|
3659
|
-
|
|
3660
|
-
// src/actions/retest.ts
|
|
3661
|
-
function isWorkspace(target) {
|
|
3662
|
-
return yarnWorkspaces().some((ws) => ws.name === target);
|
|
3663
|
-
}
|
|
3664
|
-
var retest = ({ target } = {}) => {
|
|
3665
|
-
if (target && isWorkspace(target)) {
|
|
3666
|
-
return runSteps(`Re-Test [${target}]`, [
|
|
3667
|
-
["yarn", ["workspace", target, "run", "vitest", "--clearCache"]],
|
|
3668
|
-
["yarn", ["workspace", target, "run", "vitest", "."]]
|
|
3669
|
-
]);
|
|
3670
|
-
}
|
|
3671
|
-
const path14 = target ?? ".";
|
|
3672
|
-
return runSteps("Re-Test", [
|
|
3673
|
-
["yarn", ["vitest", "--clearCache"]],
|
|
3674
|
-
["yarn", ["vitest", path14]]
|
|
3675
|
-
]);
|
|
3676
|
-
};
|
|
3677
|
-
|
|
3678
|
-
// src/actions/sonar.ts
|
|
3679
|
-
var sonar = () => {
|
|
3680
|
-
return runSteps("Sonar", [["yarn", ["eslint", "-c", "sonar.eslintrc", "."]]]);
|
|
3681
|
-
};
|
|
3682
|
-
|
|
3683
|
-
// src/actions/statics.ts
|
|
3684
|
-
import chalk46 from "chalk";
|
|
3685
|
-
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
3686
|
-
var statics = () => {
|
|
3687
|
-
console.log(chalk46.green("Check Required Static Dependencies"));
|
|
3688
|
-
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
3689
|
-
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
3690
|
-
};
|
|
3691
|
-
|
|
3692
|
-
// src/actions/test.ts
|
|
3693
|
-
function isWorkspace2(target) {
|
|
3694
|
-
return yarnWorkspaces().some((ws) => ws.name === target);
|
|
3695
|
-
}
|
|
3696
|
-
var test = ({ target } = {}) => {
|
|
3697
|
-
if (target && isWorkspace2(target)) {
|
|
3698
|
-
return runSteps(`Test [${target}]`, [["yarn", ["workspace", target, "run", "vitest", "."]]]);
|
|
3699
|
-
}
|
|
3700
|
-
const path14 = target ?? ".";
|
|
3701
|
-
return runSteps("Test", [["yarn", ["vitest", path14]]]);
|
|
3702
|
-
};
|
|
3703
|
-
|
|
3704
|
-
// src/actions/up.ts
|
|
3705
|
-
var up = () => {
|
|
3706
|
-
return runSteps("Up", [["yarn", "outdated"]]);
|
|
3707
|
-
};
|
|
3708
|
-
|
|
3709
|
-
// src/actions/updo.ts
|
|
3710
|
-
var updo = () => {
|
|
3711
|
-
return runSteps("Updo", [
|
|
3712
|
-
["yarn", "install"],
|
|
3713
|
-
["yarn", "upgrade-interactive"],
|
|
3714
|
-
["yarn", "dedupe"]
|
|
3715
|
-
]);
|
|
3716
|
-
};
|
|
3717
|
-
|
|
3718
|
-
// src/actions/upplug.ts
|
|
3719
|
-
var updateYarnPlugins = () => {
|
|
3720
|
-
return runSteps("Update Yarn Plugins", [
|
|
3721
|
-
["yarn", ["plugin", "import", "https://mskelton.dev/yarn-outdated/v3"]],
|
|
3722
|
-
["yarn", ["plugin", "import", "version"]],
|
|
3723
|
-
["yarn", ["plugin", "import", "interactive-tools"]],
|
|
3724
|
-
["yarn", ["plugin", "import", "workspace-tools"]]
|
|
3725
|
-
]);
|
|
3726
|
-
};
|
|
3727
|
-
|
|
3728
|
-
// src/actions/upyarn.ts
|
|
3729
|
-
var updateYarnVersion = () => {
|
|
3730
|
-
return runSteps("Update Yarn Version", [["yarn", ["set", "version", "latest"]]]);
|
|
3731
|
-
};
|
|
3732
|
-
|
|
3733
|
-
// src/actions/yarn3only.ts
|
|
3734
|
-
var yarn3Only = () => {
|
|
3735
|
-
const [valid, version] = isYarnVersionOrGreater(3);
|
|
3736
|
-
if (!valid) {
|
|
3737
|
-
processEx(`Invalid Yarn version [${version}]`);
|
|
3738
|
-
}
|
|
3739
|
-
return 0;
|
|
3740
|
-
};
|
|
3741
|
-
|
|
3742
|
-
// src/loadPackageConfig.ts
|
|
3743
|
-
import { readFile as readFile2 } from "fs/promises";
|
|
3744
|
-
var loadPackageConfig = async () => {
|
|
3745
|
-
const pkg = process.env.INIT_CWD;
|
|
3746
|
-
const pkgConfig = await readFile2(`${pkg}/package.json`, { encoding: "utf8" });
|
|
3747
|
-
return JSON.parse(pkgConfig);
|
|
3748
|
-
};
|
|
3749
|
-
|
|
3750
|
-
// src/xy/build/buildCommand.ts
|
|
3751
|
-
var buildCommand = {
|
|
3752
|
-
command: "build [package]",
|
|
3753
|
-
describe: "Build - Compile & Lint",
|
|
3754
|
-
builder: (yargs2) => {
|
|
3755
|
-
return yargs2.positional("package", { describe: "Specific package to build" });
|
|
3756
|
-
},
|
|
3757
|
-
handler: async (argv) => {
|
|
3758
|
-
if (argv.verbose) {
|
|
3759
|
-
console.log(`Building: ${argv.package ?? "all"}`);
|
|
3760
|
-
}
|
|
3761
|
-
process.exitCode = await build({
|
|
3762
|
-
incremental: !!argv.incremental,
|
|
3763
|
-
jobs: argv.jobs,
|
|
3764
|
-
pkg: argv.package,
|
|
3765
|
-
target: argv.target,
|
|
3766
|
-
verbose: !!argv.verbose
|
|
3767
|
-
});
|
|
3768
|
-
}
|
|
3769
|
-
};
|
|
3770
|
-
|
|
3771
|
-
// src/xy/build/compileCommand.ts
|
|
3772
|
-
var compileCommand = {
|
|
3773
|
-
command: "compile [package]",
|
|
3774
|
-
describe: "Compile with Typescript & Copy Images",
|
|
3775
|
-
builder: (yargs2) => {
|
|
3776
|
-
return yargs2.positional("package", { describe: "Specific package to compile" });
|
|
3777
|
-
},
|
|
3778
|
-
handler: (argv) => {
|
|
3779
|
-
if (argv.verbose) {
|
|
3780
|
-
console.log(`Compiling: ${argv.package ?? "all"}`);
|
|
3781
|
-
}
|
|
3782
|
-
process.exitCode = compile({
|
|
3783
|
-
incremental: !!argv.incremental,
|
|
3784
|
-
jobs: argv.jobs,
|
|
3785
|
-
pkg: argv.package,
|
|
3786
|
-
target: argv.target,
|
|
3787
|
-
verbose: !!argv.verbose
|
|
3788
|
-
});
|
|
3789
|
-
}
|
|
3790
|
-
};
|
|
3791
|
-
|
|
3792
|
-
// src/xy/build/compileOnlyCommand.ts
|
|
3793
|
-
var compileOnlyCommand = {
|
|
3794
|
-
command: "compile-only [package]",
|
|
3795
|
-
describe: "Compile with Typescript & Copy Images (No Publint)",
|
|
3796
|
-
builder: (yargs2) => {
|
|
3797
|
-
return yargs2.positional("package", { describe: "Specific package to compile" });
|
|
3798
|
-
},
|
|
3799
|
-
handler: (argv) => {
|
|
3800
|
-
if (argv.verbose) {
|
|
3801
|
-
console.log(`Compiling: ${argv.package ?? "all"}`);
|
|
3802
|
-
}
|
|
3803
|
-
process.exitCode = compile({
|
|
3804
|
-
incremental: !!argv.incremental,
|
|
3805
|
-
jobs: argv.jobs,
|
|
3806
|
-
pkg: argv.package,
|
|
3807
|
-
publint: false,
|
|
3808
|
-
target: argv.target,
|
|
3809
|
-
verbose: !!argv.verbose
|
|
3810
|
-
});
|
|
3811
|
-
}
|
|
3812
|
-
};
|
|
3813
|
-
|
|
3814
|
-
// src/xy/build/copyAssetsCommand.ts
|
|
3815
|
-
var copyAssetsCommand = {
|
|
3816
|
-
command: "copy-assets [package]",
|
|
3817
|
-
describe: "Copy Assets - Copy the assets from src to dist",
|
|
3818
|
-
builder: (yargs2) => {
|
|
3819
|
-
return yargs2.positional("package", { describe: "Specific package to copy assets" });
|
|
3820
|
-
},
|
|
3821
|
-
handler: async (argv) => {
|
|
3822
|
-
if (argv.verbose) console.log(`Copying Assets: ${argv.package ?? "all"}`);
|
|
3823
|
-
process.exitCode = await copyAssets({ target: argv.target });
|
|
3824
|
-
}
|
|
3825
|
-
};
|
|
3826
|
-
|
|
3827
|
-
// src/xy/build/rebuildCommand.ts
|
|
3828
|
-
var rebuildCommand = {
|
|
3829
|
-
command: "rebuild [package]",
|
|
3830
|
-
describe: "Rebuild - Clean, Compile & Lint",
|
|
3831
|
-
builder: (yargs2) => {
|
|
3832
|
-
return yargs2.positional("package", { describe: "Specific package to rebuild" });
|
|
3833
|
-
},
|
|
3834
|
-
handler: (argv) => {
|
|
3835
|
-
if (argv.verbose) console.log(`Rebuilding: ${argv.package ?? "all"}`);
|
|
3836
|
-
process.exitCode = rebuild({ target: argv.target });
|
|
3837
|
-
}
|
|
3838
|
-
};
|
|
3839
|
-
|
|
3840
|
-
// src/xy/build/recompileCommand.ts
|
|
3841
|
-
var recompileCommand = {
|
|
3842
|
-
command: "recompile [package]",
|
|
3843
|
-
describe: "Re-compile with Typescript & Copy Images",
|
|
3844
|
-
builder: (yargs2) => {
|
|
3845
|
-
return yargs2.positional("package", { describe: "Specific package to re-compile" });
|
|
3846
|
-
},
|
|
3847
|
-
handler: async (argv) => {
|
|
3848
|
-
if (argv.verbose) {
|
|
3849
|
-
console.log(`Re-compiling: ${argv.package ?? "all"}`);
|
|
3850
|
-
}
|
|
3851
|
-
process.exitCode = await recompile({
|
|
3852
|
-
incremental: !!argv.incremental,
|
|
3853
|
-
jobs: argv.jobs,
|
|
3854
|
-
pkg: argv.package,
|
|
3855
|
-
target: argv.target,
|
|
3856
|
-
verbose: !!argv.verbose
|
|
3857
|
-
});
|
|
3858
|
-
}
|
|
3859
|
-
};
|
|
3860
|
-
|
|
3861
|
-
// src/xy/build/index.ts
|
|
3862
|
-
var xyBuildCommands = (args) => {
|
|
3863
|
-
return args.command(buildCommand).command(compileCommand).command(compileOnlyCommand).command(recompileCommand).command(rebuildCommand).command(copyAssetsCommand);
|
|
3864
|
-
};
|
|
3865
|
-
|
|
3866
|
-
// src/xy/common/claude/cleanCommand.ts
|
|
3867
|
-
var cleanCommand = {
|
|
3868
|
-
command: "clean",
|
|
3869
|
-
describe: "Remove all Claude configuration files from the repo",
|
|
3870
|
-
handler: (argv) => {
|
|
3871
|
-
if (argv.verbose) console.log("Claude Clean");
|
|
3872
|
-
process.exitCode = claudeClean();
|
|
3873
|
-
}
|
|
3874
|
-
};
|
|
3875
|
-
|
|
3876
|
-
// src/xy/common/claude/commandsCommand.ts
|
|
3877
|
-
var commandsCommand = {
|
|
3878
|
-
command: "commands",
|
|
3879
|
-
describe: "Sync XY Labs standard Claude slash commands to .claude/commands/",
|
|
3880
|
-
handler: (argv) => {
|
|
3881
|
-
if (argv.verbose) console.log("Claude Commands");
|
|
3882
|
-
process.exitCode = claudeCommands();
|
|
3883
|
-
}
|
|
3884
|
-
};
|
|
3885
|
-
|
|
3886
|
-
// src/xy/common/claude/initCommand.ts
|
|
3887
|
-
var initCommand = {
|
|
3888
|
-
builder: (yargs2) => {
|
|
3889
|
-
return yargs2.option("force", {
|
|
3890
|
-
alias: "f",
|
|
3891
|
-
default: false,
|
|
3892
|
-
description: "Overwrite existing CLAUDE.md",
|
|
3893
|
-
type: "boolean"
|
|
3894
|
-
});
|
|
3895
|
-
},
|
|
3896
|
-
command: "init",
|
|
3897
|
-
describe: "Initialize all Claude configuration (commands, rules, settings)",
|
|
3898
|
-
handler: async (argv) => {
|
|
3899
|
-
if (argv.verbose) console.log("Claude Init");
|
|
3900
|
-
const commandsResult = claudeCommands();
|
|
3901
|
-
const rulesResult = claudeRules({ force: argv.force });
|
|
3902
|
-
const settingsResult = await claudeSettings();
|
|
3903
|
-
process.exitCode = commandsResult || rulesResult || settingsResult;
|
|
3904
|
-
}
|
|
3905
|
-
};
|
|
3906
|
-
|
|
3907
|
-
// src/xy/common/claude/rulesCommand.ts
|
|
3908
|
-
var rulesCommand = {
|
|
3909
|
-
builder: (yargs2) => {
|
|
3910
|
-
return yargs2.option("force", {
|
|
3911
|
-
alias: "f",
|
|
3912
|
-
default: false,
|
|
3913
|
-
description: "Overwrite existing CLAUDE.md",
|
|
3914
|
-
type: "boolean"
|
|
3915
|
-
});
|
|
3916
|
-
},
|
|
3917
|
-
command: "rules",
|
|
3918
|
-
describe: "Sync XY Labs standard Claude rules to .claude/rules/",
|
|
3919
|
-
handler: (argv) => {
|
|
3920
|
-
if (argv.verbose) console.log("Claude Rules");
|
|
3921
|
-
process.exitCode = claudeRules({ force: argv.force });
|
|
3922
|
-
}
|
|
3923
|
-
};
|
|
3924
|
-
|
|
3925
|
-
// src/xy/common/claude/settingsCommand.ts
|
|
3926
|
-
var settingsCommand = {
|
|
3927
|
-
command: "settings",
|
|
3928
|
-
describe: "Initialize .claude/settings.local.json with XY Labs defaults",
|
|
3929
|
-
handler: async (argv) => {
|
|
3930
|
-
if (argv.verbose) console.log("Claude Settings");
|
|
3931
|
-
process.exitCode = await claudeSettings();
|
|
3932
|
-
}
|
|
3933
|
-
};
|
|
3934
|
-
|
|
3935
|
-
// src/xy/common/claude/skillsCommand.ts
|
|
3936
|
-
var skillsCommand = {
|
|
3937
|
-
builder: (yargs2) => yargs2,
|
|
3938
|
-
command: "skills",
|
|
3939
|
-
describe: "Sync XY Labs standard Claude skills to .claude/skills/",
|
|
3940
|
-
handler: (argv) => {
|
|
3941
|
-
if (argv.verbose) console.log("Claude Skills");
|
|
3942
|
-
process.exitCode = claudeSkills();
|
|
80
|
+
runXy(args) {
|
|
81
|
+
return ["yarn", ["xy", ...args]];
|
|
3943
82
|
}
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
// src/xy/common/claude/index.ts
|
|
3947
|
-
var claudeCommand = {
|
|
3948
|
-
builder: (yargs2) => {
|
|
3949
|
-
return yargs2.command(cleanCommand).command(commandsCommand).command(initCommand).command(rulesCommand).command(settingsCommand).command(skillsCommand).demandCommand(1, "Please specify a claude subcommand");
|
|
3950
|
-
},
|
|
3951
|
-
command: "claude",
|
|
3952
|
-
describe: "Claude - Claude Code configuration utilities",
|
|
3953
|
-
handler: () => {
|
|
83
|
+
versionApply() {
|
|
84
|
+
return ["yarn", ["version", "apply", "--all"]];
|
|
3954
85
|
}
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
86
|
+
versionBump(type) {
|
|
87
|
+
if (type === "prerelease") {
|
|
88
|
+
return [
|
|
89
|
+
["yarn", "workspaces foreach --all version patch --deferred --prerelease"]
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
return [
|
|
93
|
+
["yarn", `workspaces foreach --all version ${type} --deferred`]
|
|
94
|
+
];
|
|
3964
95
|
}
|
|
3965
96
|
};
|
|
3966
97
|
|
|
3967
|
-
// src/
|
|
3968
|
-
|
|
3969
|
-
|
|
98
|
+
// src/actions/deploy.ts
|
|
99
|
+
import { readFileSync } from "fs";
|
|
100
|
+
import { runSteps } from "@xylabs/ts-scripts-common";
|
|
101
|
+
var privatePackageExcludeList = () => {
|
|
102
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
103
|
+
workspace,
|
|
104
|
+
JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
105
|
+
]);
|
|
106
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
107
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
108
|
+
return excludeList;
|
|
3970
109
|
};
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
return packagePositionalParam(yargs2);
|
|
3976
|
-
},
|
|
3977
|
-
command: "dead [package]",
|
|
3978
|
-
describe: "Dead - Check for dead code",
|
|
3979
|
-
handler: (argv) => {
|
|
3980
|
-
if (argv.verbose) console.log("Dead");
|
|
3981
|
-
process.exitCode = dead();
|
|
110
|
+
var deploy = () => {
|
|
111
|
+
const excludeList = privatePackageExcludeList();
|
|
112
|
+
if (excludeList.length > 0) {
|
|
113
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
3982
114
|
}
|
|
115
|
+
return runSteps("Deploy [Patch]", [
|
|
116
|
+
["yarn", "workspaces foreach --all version patch --deferred"],
|
|
117
|
+
["yarn", "xy clean"],
|
|
118
|
+
["yarn", "xy build"],
|
|
119
|
+
["yarn", "version apply --all"]
|
|
120
|
+
]);
|
|
3983
121
|
};
|
|
3984
122
|
|
|
3985
|
-
// src/
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
123
|
+
// src/actions/deploy-major.ts
|
|
124
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
125
|
+
import { runSteps as runSteps2 } from "@xylabs/ts-scripts-common";
|
|
126
|
+
var privatePackageExcludeList2 = () => {
|
|
127
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
128
|
+
workspace,
|
|
129
|
+
JSON.parse(readFileSync2(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
130
|
+
]);
|
|
131
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
132
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
133
|
+
return excludeList;
|
|
3996
134
|
};
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
describe: "GitIgnore - Generate root .gitignore and remove package .gitignore files",
|
|
4002
|
-
handler: (argv) => {
|
|
4003
|
-
if (argv.verbose) console.log("GitIgnore");
|
|
4004
|
-
process.exitCode = gitignore();
|
|
135
|
+
var deployMajor = () => {
|
|
136
|
+
const excludeList = privatePackageExcludeList2();
|
|
137
|
+
if (excludeList.length > 0) {
|
|
138
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
4005
139
|
}
|
|
140
|
+
return runSteps2("Deploy [Major]", [
|
|
141
|
+
["yarn", "workspaces foreach --all version major --deferred"],
|
|
142
|
+
["yarn", "xy clean"],
|
|
143
|
+
["yarn", "xy build"],
|
|
144
|
+
["yarn", "version apply --all"]
|
|
145
|
+
]);
|
|
4006
146
|
};
|
|
4007
147
|
|
|
4008
|
-
// src/
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
148
|
+
// src/actions/deploy-minor.ts
|
|
149
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
150
|
+
import { runSteps as runSteps3 } from "@xylabs/ts-scripts-common";
|
|
151
|
+
var privatePackageExcludeList3 = () => {
|
|
152
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
153
|
+
workspace,
|
|
154
|
+
JSON.parse(readFileSync3(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
155
|
+
]);
|
|
156
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
157
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
158
|
+
return excludeList;
|
|
4016
159
|
};
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
return packagePositionalParam(yargs2);
|
|
4022
|
-
},
|
|
4023
|
-
command: "license [package]",
|
|
4024
|
-
describe: "License - Check licenses of dependencies",
|
|
4025
|
-
handler: async (argv) => {
|
|
4026
|
-
if (argv.verbose) console.log(`License: ${argv.package ?? "all"}`);
|
|
4027
|
-
process.exitCode = await license();
|
|
160
|
+
var deployMinor = () => {
|
|
161
|
+
const excludeList = privatePackageExcludeList3();
|
|
162
|
+
if (excludeList.length > 0) {
|
|
163
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
4028
164
|
}
|
|
165
|
+
return runSteps3("Deploy [Minor]", [
|
|
166
|
+
["yarn", "workspaces foreach --all version minor --deferred"],
|
|
167
|
+
["yarn", "xy clean"],
|
|
168
|
+
["yarn", "xy build"],
|
|
169
|
+
["yarn", "version apply --all"]
|
|
170
|
+
]);
|
|
4029
171
|
};
|
|
4030
172
|
|
|
4031
|
-
// src/
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
173
|
+
// src/actions/deploy-next.ts
|
|
174
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
175
|
+
import { runSteps as runSteps4 } from "@xylabs/ts-scripts-common";
|
|
176
|
+
var privatePackageExcludeList4 = () => {
|
|
177
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
178
|
+
workspace,
|
|
179
|
+
JSON.parse(readFileSync4(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
180
|
+
]);
|
|
181
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
182
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
183
|
+
return excludeList;
|
|
4039
184
|
};
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
return packagePositionalParam(yargs2).option("template", {
|
|
4045
|
-
alias: "t",
|
|
4046
|
-
description: "Path to README.template.md",
|
|
4047
|
-
type: "string"
|
|
4048
|
-
}).option("typedoc", {
|
|
4049
|
-
default: false,
|
|
4050
|
-
description: "Generate TypeDoc reference sections",
|
|
4051
|
-
type: "boolean"
|
|
4052
|
-
});
|
|
4053
|
-
},
|
|
4054
|
-
aliases: ["$0"],
|
|
4055
|
-
command: "gen [package]",
|
|
4056
|
-
describe: "Generate README.md files from template",
|
|
4057
|
-
handler: async (argv) => {
|
|
4058
|
-
if (argv.verbose) console.log("Readme Gen");
|
|
4059
|
-
process.exitCode = await readmeGen({
|
|
4060
|
-
pkg: argv.package,
|
|
4061
|
-
templatePath: argv.template,
|
|
4062
|
-
typedoc: argv.typedoc,
|
|
4063
|
-
verbose: !!argv.verbose
|
|
4064
|
-
});
|
|
185
|
+
var deployNext = () => {
|
|
186
|
+
const excludeList = privatePackageExcludeList4();
|
|
187
|
+
if (excludeList.length > 0) {
|
|
188
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
4065
189
|
}
|
|
190
|
+
return runSteps4("Deploy [Next]", [
|
|
191
|
+
["yarn", "workspaces foreach --all version minor --deferred"],
|
|
192
|
+
["yarn", "xy clean"],
|
|
193
|
+
["yarn", "xy build"],
|
|
194
|
+
["yarn", "version apply --all --prerelease"]
|
|
195
|
+
]);
|
|
4066
196
|
};
|
|
4067
197
|
|
|
4068
|
-
// src/
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
alias: "t",
|
|
4073
|
-
description: "Path to README.template.md",
|
|
4074
|
-
type: "string"
|
|
4075
|
-
});
|
|
4076
|
-
},
|
|
4077
|
-
command: "init",
|
|
4078
|
-
describe: "Initialize README template and logo files",
|
|
4079
|
-
handler: async (argv) => {
|
|
4080
|
-
if (argv.verbose) console.log("Readme Init");
|
|
4081
|
-
process.exitCode = await readmeInit({
|
|
4082
|
-
templatePath: argv.template,
|
|
4083
|
-
verbose: !!argv.verbose
|
|
4084
|
-
});
|
|
4085
|
-
}
|
|
198
|
+
// src/actions/publish.ts
|
|
199
|
+
import { runSteps as runSteps5 } from "@xylabs/ts-scripts-common";
|
|
200
|
+
var publish = () => {
|
|
201
|
+
return runSteps5("Publish", [["npm", ["publish", "--workspaces"]]]);
|
|
4086
202
|
};
|
|
4087
203
|
|
|
4088
|
-
// src/
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
204
|
+
// src/actions/reinstall.ts
|
|
205
|
+
import {
|
|
206
|
+
closeSync,
|
|
207
|
+
openSync,
|
|
208
|
+
rmSync
|
|
209
|
+
} from "fs";
|
|
210
|
+
import { runSteps as runSteps6 } from "@xylabs/ts-scripts-common";
|
|
211
|
+
var reinstall = () => {
|
|
212
|
+
console.log("Reinstall [Clear Lock File]");
|
|
213
|
+
closeSync(openSync("./yarn.lock", "w"));
|
|
214
|
+
console.log("Reinstall [Clear Node Modules]");
|
|
215
|
+
const workspaces = yarnWorkspaces();
|
|
216
|
+
const result = workspaces.map(({ location, name }) => {
|
|
217
|
+
const dist = `${location}/node_modules`;
|
|
218
|
+
try {
|
|
219
|
+
rmSync(dist, { force: true, recursive: true });
|
|
220
|
+
return 0;
|
|
221
|
+
} catch (ex) {
|
|
222
|
+
const error = ex;
|
|
223
|
+
console.error(`Reinstall [Clear Node Modules] Failed [${name}, ${error.message}]`);
|
|
224
|
+
return 1;
|
|
225
|
+
}
|
|
226
|
+
}).reduce((prev, result2) => prev || result2, 0);
|
|
227
|
+
return result || runSteps6("Reinstall", [["yarn", "install --network-timeout 10000"]]);
|
|
4097
228
|
};
|
|
4098
229
|
|
|
4099
|
-
// src/
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
builder: (yargs2) => {
|
|
4104
|
-
return yargs2.positional("target", { describe: "Package name or file/folder path to test" });
|
|
4105
|
-
},
|
|
4106
|
-
handler: (argv) => {
|
|
4107
|
-
if (argv.verbose) console.log(`Re-Testing: ${argv.target ?? "all"}`);
|
|
4108
|
-
process.exitCode = retest({ target: argv.target });
|
|
4109
|
-
}
|
|
230
|
+
// src/actions/up.ts
|
|
231
|
+
import { runSteps as runSteps7 } from "@xylabs/ts-scripts-common";
|
|
232
|
+
var up = () => {
|
|
233
|
+
return runSteps7("Up", [["yarn", "outdated"]]);
|
|
4110
234
|
};
|
|
4111
235
|
|
|
4112
|
-
// src/
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
if (argv.verbose) console.log(`Testing: ${argv.target ?? "all"}`);
|
|
4121
|
-
process.exitCode = test({ target: argv.target });
|
|
4122
|
-
}
|
|
236
|
+
// src/actions/updo.ts
|
|
237
|
+
import { runSteps as runSteps8 } from "@xylabs/ts-scripts-common";
|
|
238
|
+
var updo = () => {
|
|
239
|
+
return runSteps8("Updo", [
|
|
240
|
+
["yarn", "install"],
|
|
241
|
+
["yarn", "upgrade-interactive"],
|
|
242
|
+
["yarn", "dedupe"]
|
|
243
|
+
]);
|
|
4123
244
|
};
|
|
4124
245
|
|
|
4125
|
-
// src/
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
246
|
+
// src/actions/upplug.ts
|
|
247
|
+
import { runSteps as runSteps9 } from "@xylabs/ts-scripts-common";
|
|
248
|
+
var updateYarnPlugins = () => {
|
|
249
|
+
return runSteps9("Update Yarn Plugins", [
|
|
250
|
+
["yarn", ["plugin", "import", "https://mskelton.dev/yarn-outdated/v3"]],
|
|
251
|
+
["yarn", ["plugin", "import", "version"]],
|
|
252
|
+
["yarn", ["plugin", "import", "interactive-tools"]],
|
|
253
|
+
["yarn", ["plugin", "import", "workspace-tools"]]
|
|
254
|
+
]);
|
|
4133
255
|
};
|
|
4134
256
|
|
|
4135
|
-
// src/
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
handler: (argv) => {
|
|
4140
|
-
if (argv.verbose) console.log("UpYarn");
|
|
4141
|
-
process.exitCode = updateYarnVersion();
|
|
4142
|
-
}
|
|
257
|
+
// src/actions/upyarn.ts
|
|
258
|
+
import { runSteps as runSteps10 } from "@xylabs/ts-scripts-common";
|
|
259
|
+
var updateYarnVersion = () => {
|
|
260
|
+
return runSteps10("Update Yarn Version", [["yarn", ["set", "version", "latest"]]]);
|
|
4143
261
|
};
|
|
4144
262
|
|
|
4145
|
-
// src/
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
process.exitCode = yarn3Only();
|
|
263
|
+
// src/actions/yarn3only.ts
|
|
264
|
+
import { processEx } from "@xylabs/ts-scripts-common";
|
|
265
|
+
var yarn3Only = () => {
|
|
266
|
+
const [valid, version] = isYarnVersionOrGreater(3);
|
|
267
|
+
if (!valid) {
|
|
268
|
+
processEx(`Invalid Yarn version [${version}]`);
|
|
4152
269
|
}
|
|
270
|
+
return 0;
|
|
4153
271
|
};
|
|
4154
272
|
|
|
4155
|
-
// src/
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
273
|
+
// src/actions/index.ts
|
|
274
|
+
import {
|
|
275
|
+
clean,
|
|
276
|
+
dupdeps,
|
|
277
|
+
statics
|
|
278
|
+
} from "@xylabs/ts-scripts-common";
|
|
4159
279
|
|
|
4160
280
|
// src/xy/deploy/deployCommand.ts
|
|
4161
281
|
var deployCommand = {
|
|
@@ -4213,11 +333,11 @@ var xyDeployCommands = (args) => {
|
|
|
4213
333
|
};
|
|
4214
334
|
|
|
4215
335
|
// src/xy/install/cleanCommand.ts
|
|
4216
|
-
var
|
|
336
|
+
var cleanCommand = {
|
|
4217
337
|
command: "clean [package]",
|
|
4218
338
|
describe: "Clean",
|
|
4219
|
-
builder: (
|
|
4220
|
-
return
|
|
339
|
+
builder: (yargs) => {
|
|
340
|
+
return yargs.positional("package", { describe: "Specific package to clean" });
|
|
4221
341
|
},
|
|
4222
342
|
handler: async (argv) => {
|
|
4223
343
|
if (argv.verbose) {
|
|
@@ -4282,382 +402,75 @@ var updoCommand = {
|
|
|
4282
402
|
|
|
4283
403
|
// src/xy/install/index.ts
|
|
4284
404
|
var xyInstallCommands = (args) => {
|
|
4285
|
-
return args.command(
|
|
4286
|
-
};
|
|
4287
|
-
|
|
4288
|
-
// src/xy/lint/cycleCommand.ts
|
|
4289
|
-
import chalk47 from "chalk";
|
|
4290
|
-
var cycleCommand = {
|
|
4291
|
-
command: "cycle [package]",
|
|
4292
|
-
describe: "Cycle - Check for dependency cycles",
|
|
4293
|
-
builder: (yargs2) => {
|
|
4294
|
-
return packagePositionalParam(yargs2);
|
|
4295
|
-
},
|
|
4296
|
-
handler: async (argv) => {
|
|
4297
|
-
const start = Date.now();
|
|
4298
|
-
if (argv.verbose) console.log("Cycle");
|
|
4299
|
-
process.exitCode = await cycle({ pkg: argv.package });
|
|
4300
|
-
console.log(chalk47.blue(`Finished in ${Date.now() - start}ms`));
|
|
4301
|
-
}
|
|
405
|
+
return args.command(cleanCommand).command(reinstallCommand).command(upCommand).command(updoCommand).command(staticsCommand).command(dupdepsCommand);
|
|
4302
406
|
};
|
|
4303
407
|
|
|
4304
|
-
// src/xy/
|
|
4305
|
-
import
|
|
4306
|
-
var deplintCommand = {
|
|
4307
|
-
command: "deplint [package]",
|
|
4308
|
-
describe: "Deplint - Run Deplint",
|
|
4309
|
-
builder: (yargs2) => {
|
|
4310
|
-
return packagePositionalParam(yargs2).option("deps", {
|
|
4311
|
-
alias: "d",
|
|
4312
|
-
default: false,
|
|
4313
|
-
description: "Check dependencies",
|
|
4314
|
-
type: "boolean"
|
|
4315
|
-
}).option("devDeps", {
|
|
4316
|
-
alias: "v",
|
|
4317
|
-
default: false,
|
|
4318
|
-
description: "Check devDependencies",
|
|
4319
|
-
type: "boolean"
|
|
4320
|
-
}).option("peerDeps", {
|
|
4321
|
-
alias: "p",
|
|
4322
|
-
default: false,
|
|
4323
|
-
description: "Check peerDependencies",
|
|
4324
|
-
type: "boolean"
|
|
4325
|
-
}).option("exclude", {
|
|
4326
|
-
alias: "e",
|
|
4327
|
-
description: "Package names to exclude from unused checks (comma-separated or repeated)",
|
|
4328
|
-
type: "array"
|
|
4329
|
-
});
|
|
4330
|
-
},
|
|
4331
|
-
handler: async (argv) => {
|
|
4332
|
-
if (argv.verbose) console.log("Deplint");
|
|
4333
|
-
const start = Date.now();
|
|
4334
|
-
const cliExclude = argv.exclude?.flatMap((v) => String(v).split(",")).map((v) => v.trim()).filter(Boolean);
|
|
4335
|
-
process.exitCode = await deplint({
|
|
4336
|
-
cliExclude,
|
|
4337
|
-
pkg: argv.package,
|
|
4338
|
-
deps: !!argv.deps,
|
|
4339
|
-
devDeps: !!argv.devDeps,
|
|
4340
|
-
peerDeps: !!argv.peerDeps,
|
|
4341
|
-
verbose: !!argv.verbose
|
|
4342
|
-
});
|
|
4343
|
-
console.log(chalk48.blue(`Finished in ${Date.now() - start}ms`));
|
|
4344
|
-
}
|
|
4345
|
-
};
|
|
4346
|
-
|
|
4347
|
-
// src/xy/lint/fixCommand.ts
|
|
4348
|
-
import chalk49 from "chalk";
|
|
4349
|
-
var fixCommand = {
|
|
4350
|
-
command: "fix [package]",
|
|
4351
|
-
describe: "Fix - Run Eslint w/fix",
|
|
4352
|
-
builder: (yargs2) => {
|
|
4353
|
-
return packagePositionalParam(yargs2);
|
|
4354
|
-
},
|
|
4355
|
-
handler: (argv) => {
|
|
4356
|
-
const start = Date.now();
|
|
4357
|
-
if (argv.verbose) console.log("Fix");
|
|
4358
|
-
process.exitCode = fix();
|
|
4359
|
-
console.log(chalk49.blue(`Finished in ${Date.now() - start}ms`));
|
|
4360
|
-
}
|
|
4361
|
-
};
|
|
4362
|
-
|
|
4363
|
-
// src/xy/lint/knipCommand.ts
|
|
4364
|
-
import chalk50 from "chalk";
|
|
4365
|
-
var knipCommand = {
|
|
4366
|
-
command: "knip",
|
|
4367
|
-
describe: "Knip - Run Knip",
|
|
4368
|
-
builder: (yargs2) => {
|
|
4369
|
-
return packagePositionalParam(yargs2);
|
|
4370
|
-
},
|
|
4371
|
-
handler: (argv) => {
|
|
4372
|
-
if (argv.verbose) console.log("Knip");
|
|
4373
|
-
const start = Date.now();
|
|
4374
|
-
process.exitCode = knip();
|
|
4375
|
-
console.log(chalk50.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
4376
|
-
}
|
|
4377
|
-
};
|
|
4378
|
-
|
|
4379
|
-
// src/xy/lint/lintCommand.ts
|
|
4380
|
-
import chalk51 from "chalk";
|
|
4381
|
-
var lintCommand = {
|
|
4382
|
-
command: "lint [package]",
|
|
4383
|
-
describe: "Lint - Run Eslint",
|
|
4384
|
-
builder: (yargs2) => {
|
|
4385
|
-
return packagePositionalParam(yargs2).option("fix", {
|
|
4386
|
-
alias: "f",
|
|
4387
|
-
default: false,
|
|
4388
|
-
description: "Fix fixable issues",
|
|
4389
|
-
type: "boolean"
|
|
4390
|
-
}).option("cache", {
|
|
4391
|
-
alias: "c",
|
|
4392
|
-
default: false,
|
|
4393
|
-
description: "Use caching for performance",
|
|
4394
|
-
type: "boolean"
|
|
4395
|
-
});
|
|
4396
|
-
},
|
|
4397
|
-
handler: (argv) => {
|
|
4398
|
-
if (argv.verbose) console.log("Lint");
|
|
4399
|
-
const start = Date.now();
|
|
4400
|
-
process.exitCode = argv.fix ? fix({
|
|
4401
|
-
pkg: argv.package,
|
|
4402
|
-
cache: argv.cache,
|
|
4403
|
-
verbose: !!argv.verbose
|
|
4404
|
-
}) : lint({
|
|
4405
|
-
pkg: argv.package,
|
|
4406
|
-
cache: argv.cache,
|
|
4407
|
-
verbose: !!argv.verbose
|
|
4408
|
-
});
|
|
4409
|
-
console.log(chalk51.blue(`Finished in ${Date.now() - start}ms`));
|
|
4410
|
-
}
|
|
4411
|
-
};
|
|
408
|
+
// src/xy/xy.ts
|
|
409
|
+
import { xyBase } from "@xylabs/ts-scripts-common";
|
|
4412
410
|
|
|
4413
|
-
// src/xy/
|
|
4414
|
-
var
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
default: false,
|
|
4418
|
-
description: "Auto-fix fixable issues",
|
|
4419
|
-
type: "boolean"
|
|
4420
|
-
});
|
|
4421
|
-
},
|
|
4422
|
-
command: "package-lint",
|
|
4423
|
-
describe: "Package Lint - Check monorepo package structure",
|
|
411
|
+
// src/xy/common/upplugCommand.ts
|
|
412
|
+
var upplugCommand = {
|
|
413
|
+
command: "upplug",
|
|
414
|
+
describe: "UpPlug - Update Yarn Plugins",
|
|
4424
415
|
handler: (argv) => {
|
|
4425
|
-
if (argv.verbose) console.log("
|
|
4426
|
-
process.exitCode =
|
|
4427
|
-
}
|
|
4428
|
-
};
|
|
4429
|
-
|
|
4430
|
-
// src/xy/lint/publintCommand.ts
|
|
4431
|
-
import chalk52 from "chalk";
|
|
4432
|
-
var publintCommand = {
|
|
4433
|
-
command: "publint [package]",
|
|
4434
|
-
describe: "Publint - Run Publint",
|
|
4435
|
-
builder: (yargs2) => {
|
|
4436
|
-
return packagePositionalParam(yargs2);
|
|
4437
|
-
},
|
|
4438
|
-
handler: async (argv) => {
|
|
4439
|
-
if (argv.verbose) console.log("Publint");
|
|
4440
|
-
const start = Date.now();
|
|
4441
|
-
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
4442
|
-
console.log(chalk52.blue(`Finished in ${Date.now() - start}ms`));
|
|
416
|
+
if (argv.verbose) console.log("UpPlug");
|
|
417
|
+
process.exitCode = updateYarnPlugins();
|
|
4443
418
|
}
|
|
4444
419
|
};
|
|
4445
420
|
|
|
4446
|
-
// src/xy/
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
describe: "Relint - Clean & Lint",
|
|
4451
|
-
builder: (yargs2) => {
|
|
4452
|
-
return packagePositionalParam(yargs2);
|
|
4453
|
-
},
|
|
421
|
+
// src/xy/common/upyarnCommand.ts
|
|
422
|
+
var upyarnCommand = {
|
|
423
|
+
command: "upyarn",
|
|
424
|
+
describe: "UpYarn - Update Yarn Version",
|
|
4454
425
|
handler: (argv) => {
|
|
4455
|
-
if (argv.verbose) console.log("
|
|
4456
|
-
|
|
4457
|
-
process.exitCode = relint();
|
|
4458
|
-
console.log(chalk53.blue(`Finished in ${Date.now() - start}ms`));
|
|
426
|
+
if (argv.verbose) console.log("UpYarn");
|
|
427
|
+
process.exitCode = updateYarnVersion();
|
|
4459
428
|
}
|
|
4460
429
|
};
|
|
4461
430
|
|
|
4462
|
-
// src/xy/
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
describe: "Sonar - Run Sonar Check",
|
|
4467
|
-
builder: (yargs2) => {
|
|
4468
|
-
return packagePositionalParam(yargs2);
|
|
4469
|
-
},
|
|
431
|
+
// src/xy/common/yarn3OnlyCommand.ts
|
|
432
|
+
var yarn3OnlyCommand = {
|
|
433
|
+
command: "yarn3only",
|
|
434
|
+
describe: "Yarn3Only - Check if using Yarn v3",
|
|
4470
435
|
handler: (argv) => {
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
process.exitCode = sonar();
|
|
4474
|
-
console.log(chalk54.blue(`Finished in ${Date.now() - start}ms`));
|
|
436
|
+
if (argv.verbose) console.log("Yarn 3 Check");
|
|
437
|
+
process.exitCode = yarn3Only();
|
|
4475
438
|
}
|
|
4476
439
|
};
|
|
4477
440
|
|
|
4478
|
-
// src/xy/
|
|
4479
|
-
var
|
|
4480
|
-
return args.command(
|
|
4481
|
-
};
|
|
4482
|
-
|
|
4483
|
-
// src/xy/xy.ts
|
|
4484
|
-
import chalk55 from "chalk";
|
|
4485
|
-
|
|
4486
|
-
// src/xy/xyParseOptions.ts
|
|
4487
|
-
import yargs from "yargs";
|
|
4488
|
-
import { hideBin } from "yargs/helpers";
|
|
4489
|
-
var xyParseOptions = () => {
|
|
4490
|
-
return yargs(hideBin(process.argv)).scriptName("yarn xy").middleware((argv) => {
|
|
4491
|
-
const commandName = argv._[0];
|
|
4492
|
-
if (commandName && argv._.length <= 1) {
|
|
4493
|
-
const result = tryRunLocalScript(commandName);
|
|
4494
|
-
if (result !== void 0) {
|
|
4495
|
-
process.exit(result);
|
|
4496
|
-
}
|
|
4497
|
-
}
|
|
4498
|
-
}, true).option("jobs", {
|
|
4499
|
-
alias: "j",
|
|
4500
|
-
default: void 0,
|
|
4501
|
-
description: "Max parallel jobs",
|
|
4502
|
-
type: "number"
|
|
4503
|
-
}).option("verbose", {
|
|
4504
|
-
alias: "v",
|
|
4505
|
-
default: false,
|
|
4506
|
-
description: "Run with verbose logging",
|
|
4507
|
-
type: "boolean"
|
|
4508
|
-
}).option("incremental", {
|
|
4509
|
-
alias: "i",
|
|
4510
|
-
default: false,
|
|
4511
|
-
description: "Attempt to perform the action only on changed packages",
|
|
4512
|
-
type: "boolean"
|
|
4513
|
-
}).option("profile", {
|
|
4514
|
-
alias: "p",
|
|
4515
|
-
default: false,
|
|
4516
|
-
description: "Profile action",
|
|
4517
|
-
type: "boolean"
|
|
4518
|
-
});
|
|
441
|
+
// src/xy/yarnCommands.ts
|
|
442
|
+
var xyYarnCommands = (args) => {
|
|
443
|
+
return args.command(upplugCommand).command(upyarnCommand).command(yarn3OnlyCommand);
|
|
4519
444
|
};
|
|
4520
445
|
|
|
4521
446
|
// src/xy/xy.ts
|
|
4522
447
|
var xy = async () => {
|
|
4523
|
-
|
|
4524
|
-
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
4525
|
-
console.error(chalk55.yellow(`Command not found [${chalk55.magenta(process.argv[2])}]`));
|
|
4526
|
-
console.log(chalk55.gray("Try 'yarn xy --help' for list of commands"));
|
|
4527
|
-
}).version().help().argv;
|
|
448
|
+
return await xyBase((args) => xyYarnCommands(xyInstallCommands(xyDeployCommands(args))));
|
|
4528
449
|
};
|
|
450
|
+
|
|
451
|
+
// src/index.ts
|
|
452
|
+
export * from "@xylabs/ts-scripts-common";
|
|
453
|
+
registerPackageManager(new YarnPackageManager());
|
|
4529
454
|
export {
|
|
4530
|
-
|
|
4531
|
-
DEFAULT_README_BODY,
|
|
4532
|
-
DEFAULT_README_TEMPLATE,
|
|
4533
|
-
DuplicateDetector,
|
|
4534
|
-
INIT_CWD,
|
|
4535
|
-
LEGACY_COMMANDS_PREFIX,
|
|
4536
|
-
WINDOWS_NEWLINE_REGEX,
|
|
4537
|
-
XYLABS_COMMANDS_PREFIX,
|
|
4538
|
-
XYLABS_RULES_PREFIX,
|
|
4539
|
-
XYLABS_SKILLS_PREFIX,
|
|
4540
|
-
applyLogoConfig,
|
|
4541
|
-
build,
|
|
4542
|
-
checkResult,
|
|
4543
|
-
claudeClean,
|
|
4544
|
-
claudeCommandTemplates,
|
|
4545
|
-
claudeCommands,
|
|
4546
|
-
claudeMdLocalTemplate,
|
|
4547
|
-
claudeMdProjectTemplate,
|
|
4548
|
-
claudeMdRuleTemplates,
|
|
4549
|
-
claudeRules,
|
|
4550
|
-
claudeSettings,
|
|
4551
|
-
claudeSkillTemplates,
|
|
4552
|
-
claudeSkills,
|
|
455
|
+
YarnPackageManager,
|
|
4553
456
|
clean,
|
|
4554
|
-
cleanAll,
|
|
4555
|
-
cleanDocs,
|
|
4556
|
-
cleanPackage,
|
|
4557
|
-
compile,
|
|
4558
|
-
compileAll,
|
|
4559
|
-
compilePackage,
|
|
4560
|
-
copyAssets,
|
|
4561
|
-
createBuildConfig,
|
|
4562
|
-
cycle,
|
|
4563
|
-
cycleAll,
|
|
4564
|
-
cyclePackage,
|
|
4565
|
-
dead,
|
|
4566
|
-
defaultBuildConfig,
|
|
4567
|
-
defaultReadFileSyncOptions,
|
|
4568
|
-
deleteGlob,
|
|
4569
|
-
deplint,
|
|
4570
457
|
deploy,
|
|
4571
458
|
deployMajor,
|
|
4572
459
|
deployMinor,
|
|
4573
460
|
deployNext,
|
|
4574
|
-
detectDuplicateDependencies,
|
|
4575
461
|
dupdeps,
|
|
4576
|
-
empty,
|
|
4577
|
-
fix,
|
|
4578
|
-
genDocs,
|
|
4579
|
-
genDocsAll,
|
|
4580
|
-
genDocsPackage,
|
|
4581
|
-
generateIgnoreFiles,
|
|
4582
|
-
generateReadmeFiles,
|
|
4583
|
-
gitignore,
|
|
4584
|
-
gitignoreGen,
|
|
4585
|
-
gitignoreTemplate,
|
|
4586
|
-
gitlint,
|
|
4587
|
-
gitlintFix,
|
|
4588
462
|
isYarnVersionOrGreater,
|
|
4589
|
-
knip,
|
|
4590
|
-
license,
|
|
4591
|
-
lint,
|
|
4592
|
-
lintAllPackages,
|
|
4593
|
-
lintPackage,
|
|
4594
|
-
loadConfig,
|
|
4595
|
-
loadPackageConfig,
|
|
4596
|
-
multiLineToJSONArray,
|
|
4597
|
-
notEmpty,
|
|
4598
|
-
npmignoreGen,
|
|
4599
|
-
packageClean,
|
|
4600
|
-
packageCleanOutputs,
|
|
4601
|
-
packageCleanTypescript,
|
|
4602
|
-
packageCompile,
|
|
4603
|
-
packageCompileTsc,
|
|
4604
|
-
packageCompileTsup,
|
|
4605
|
-
packageCopyAssets,
|
|
4606
|
-
packageCycle,
|
|
4607
|
-
packageGenDocs,
|
|
4608
|
-
packageLint,
|
|
4609
|
-
packageLintMonorepo,
|
|
4610
|
-
packagePublint,
|
|
4611
|
-
packageRecompile,
|
|
4612
|
-
parsedPackageJSON,
|
|
4613
|
-
processEx,
|
|
4614
|
-
publint,
|
|
4615
|
-
publintAll,
|
|
4616
|
-
publintPackage,
|
|
4617
463
|
publish,
|
|
4618
|
-
readLines,
|
|
4619
|
-
readNonEmptyLines,
|
|
4620
|
-
readmeGen,
|
|
4621
|
-
readmeInit,
|
|
4622
|
-
rebuild,
|
|
4623
|
-
recompile,
|
|
4624
|
-
recompileAll,
|
|
4625
|
-
recompilePackage,
|
|
4626
464
|
reinstall,
|
|
4627
|
-
relint,
|
|
4628
|
-
relintAllPackages,
|
|
4629
|
-
relintPackage,
|
|
4630
|
-
resolveTemplatePath,
|
|
4631
|
-
retest,
|
|
4632
|
-
runStepAsync,
|
|
4633
|
-
runSteps,
|
|
4634
|
-
runStepsAsync,
|
|
4635
|
-
runXy,
|
|
4636
|
-
runXyWithWarning,
|
|
4637
|
-
safeExit,
|
|
4638
|
-
safeExitAsync,
|
|
4639
|
-
scaffoldTemplate,
|
|
4640
|
-
sonar,
|
|
4641
465
|
statics,
|
|
4642
|
-
test,
|
|
4643
|
-
tryReadFileSync,
|
|
4644
|
-
tryRunLocalScript,
|
|
4645
|
-
tsupOptions,
|
|
4646
|
-
union,
|
|
4647
466
|
up,
|
|
4648
467
|
updateYarnPlugins,
|
|
4649
468
|
updateYarnVersion,
|
|
4650
469
|
updo,
|
|
4651
|
-
withErrnoException,
|
|
4652
|
-
withError,
|
|
4653
|
-
writeLines,
|
|
4654
470
|
xy,
|
|
4655
|
-
xyBuildCommands,
|
|
4656
|
-
xyCommonCommands,
|
|
4657
471
|
xyDeployCommands,
|
|
4658
472
|
xyInstallCommands,
|
|
4659
|
-
|
|
4660
|
-
xyParseOptions,
|
|
473
|
+
xyYarnCommands,
|
|
4661
474
|
yarn3Only,
|
|
4662
475
|
yarnWorkspace,
|
|
4663
476
|
yarnWorkspaces
|