skuba 14.0.0-esmify-skuba-20251031141102 → 14.0.0-esmify-skuba-20251105034821
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/config/prettier.d.ts +8 -0
- package/lib/cli/adapter/eslint.js +4 -2
- package/lib/cli/adapter/eslint.js.map +1 -1
- package/lib/cli/adapter/prettier.js +8 -4
- package/lib/cli/adapter/prettier.js.map +1 -1
- package/lib/cli/build/args.js +4 -2
- package/lib/cli/build/args.js.map +1 -1
- package/lib/cli/build/assets.js +6 -3
- package/lib/cli/build/assets.js.map +1 -1
- package/lib/cli/build/esbuild.js +5 -3
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/build/index.js +4 -2
- package/lib/cli/build/index.js.map +1 -1
- package/lib/cli/build/tsc.js +10 -5
- package/lib/cli/build/tsc.js.map +1 -1
- package/lib/cli/buildPackage/index.js +4 -2
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/analyseConfiguration.js +4 -2
- package/lib/cli/configure/analyseConfiguration.js.map +1 -1
- package/lib/cli/configure/analyseDependencies.js +4 -2
- package/lib/cli/configure/analyseDependencies.js.map +1 -1
- package/lib/cli/configure/analysis/diff.js +4 -2
- package/lib/cli/configure/analysis/diff.js.map +1 -1
- package/lib/cli/configure/analysis/files.js +4 -2
- package/lib/cli/configure/analysis/files.js.map +1 -1
- package/lib/cli/configure/analysis/git.js +4 -2
- package/lib/cli/configure/analysis/git.js.map +1 -1
- package/lib/cli/configure/analysis/package.js +6 -3
- package/lib/cli/configure/analysis/package.js.map +1 -1
- package/lib/cli/configure/analysis/project.js +6 -3
- package/lib/cli/configure/analysis/project.js.map +1 -1
- package/lib/cli/configure/dependencies/index.js +12 -6
- package/lib/cli/configure/dependencies/index.js.map +1 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +4 -2
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
- package/lib/cli/configure/dependencies/seekKoala.js +4 -2
- package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
- package/lib/cli/configure/dependencies/skuba.js +4 -2
- package/lib/cli/configure/dependencies/skuba.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +4 -2
- package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDive.js +6 -3
- package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +4 -2
- package/lib/cli/configure/ensureTemplateCompletion.js.map +1 -1
- package/lib/cli/configure/getEntryPoint.js +4 -2
- package/lib/cli/configure/getEntryPoint.js.map +1 -1
- package/lib/cli/configure/getProjectType.js +4 -2
- package/lib/cli/configure/getProjectType.js.map +1 -1
- package/lib/cli/configure/index.js +4 -2
- package/lib/cli/configure/index.js.map +1 -1
- package/lib/cli/configure/modules/eslint.js +4 -2
- package/lib/cli/configure/modules/eslint.js.map +1 -1
- package/lib/cli/configure/modules/ignore.js +4 -2
- package/lib/cli/configure/modules/ignore.js.map +1 -1
- package/lib/cli/configure/modules/index.js +4 -2
- package/lib/cli/configure/modules/index.js.map +1 -1
- package/lib/cli/configure/modules/nodemon.js +4 -2
- package/lib/cli/configure/modules/nodemon.js.map +1 -1
- package/lib/cli/configure/modules/package.js +4 -2
- package/lib/cli/configure/modules/package.js.map +1 -1
- package/lib/cli/configure/modules/prettier.js +4 -2
- package/lib/cli/configure/modules/prettier.js.map +1 -1
- package/lib/cli/configure/modules/renovate.js +6 -3
- package/lib/cli/configure/modules/renovate.js.map +1 -1
- package/lib/cli/configure/modules/serverless.js +4 -2
- package/lib/cli/configure/modules/serverless.js.map +1 -1
- package/lib/cli/configure/modules/tslint.js +4 -2
- package/lib/cli/configure/modules/tslint.js.map +1 -1
- package/lib/cli/configure/processing/configFile.js +8 -4
- package/lib/cli/configure/processing/configFile.js.map +1 -1
- package/lib/cli/configure/processing/deleteFiles.js +4 -2
- package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js +6 -3
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.js +6 -3
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/loadFiles.js +4 -2
- package/lib/cli/configure/processing/loadFiles.js.map +1 -1
- package/lib/cli/configure/processing/module.js +4 -2
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.js +10 -5
- package/lib/cli/configure/processing/package.js.map +1 -1
- package/lib/cli/configure/processing/prettier.js +4 -2
- package/lib/cli/configure/processing/prettier.js.map +1 -1
- package/lib/cli/configure/processing/record.js +8 -4
- package/lib/cli/configure/processing/record.js.map +1 -1
- package/lib/cli/configure/processing/typescript.js +10 -5
- package/lib/cli/configure/processing/typescript.js.map +1 -1
- package/lib/cli/configure/types.js +0 -1
- package/lib/cli/format/index.js +4 -2
- package/lib/cli/format/index.js.map +1 -1
- package/lib/cli/help/index.js +4 -2
- package/lib/cli/help/index.js.map +1 -1
- package/lib/cli/init/getConfig.js +12 -6
- package/lib/cli/init/getConfig.js.map +1 -1
- package/lib/cli/init/git.js +6 -3
- package/lib/cli/init/git.js.map +1 -1
- package/lib/cli/init/index.js +4 -2
- package/lib/cli/init/index.js.map +1 -1
- package/lib/cli/init/prompts.js +10 -5
- package/lib/cli/init/prompts.js.map +1 -1
- package/lib/cli/init/types.js +4 -2
- package/lib/cli/init/types.js.map +1 -1
- package/lib/cli/init/validation.js +12 -6
- package/lib/cli/init/validation.js.map +1 -1
- package/lib/cli/init/writePackageJson.js +4 -2
- package/lib/cli/init/writePackageJson.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/eslint.js +4 -2
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js +4 -2
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js +4 -2
- package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +4 -2
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +4 -2
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/github/eslint.js +4 -2
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js +4 -2
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/internal.js +4 -2
- package/lib/cli/lint/annotate/github/internal.js.map +1 -1
- package/lib/cli/lint/annotate/github/prettier.js +4 -2
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +4 -2
- package/lib/cli/lint/annotate/github/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/index.js +4 -2
- package/lib/cli/lint/annotate/index.js.map +1 -1
- package/lib/cli/lint/autofix.js +8 -4
- package/lib/cli/lint/autofix.js.map +1 -1
- package/lib/cli/lint/eslint.js +6 -3
- package/lib/cli/lint/eslint.js.map +1 -1
- package/lib/cli/lint/external.js +6 -3
- package/lib/cli/lint/external.js.map +1 -1
- package/lib/cli/lint/index.js +4 -2
- package/lib/cli/lint/index.js.map +1 -1
- package/lib/cli/lint/internal.js +4 -2
- package/lib/cli/lint/internal.js.map +1 -1
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +6 -3
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +4 -2
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +1 -1
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +4 -2
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +1 -1
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +8 -4
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +8 -4
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +12 -6
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +28 -14
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +1 -1
- package/lib/cli/lint/prettier.js +6 -3
- package/lib/cli/lint/prettier.js.map +1 -1
- package/lib/cli/lint/tsc.js +4 -2
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/lint/types.js +0 -1
- package/lib/cli/migrate/index.js +4 -2
- package/lib/cli/migrate/index.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/checks.js +10 -5
- package/lib/cli/migrate/nodeVersion/checks.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/index.js +4 -2
- package/lib/cli/migrate/nodeVersion/index.js.map +1 -1
- package/lib/cli/node/index.js +6 -3
- package/lib/cli/node/index.js.map +1 -1
- package/lib/cli/release/index.js +4 -2
- package/lib/cli/release/index.js.map +1 -1
- package/lib/cli/start/index.js +4 -2
- package/lib/cli/start/index.js.map +1 -1
- package/lib/cli/test/index.js +4 -2
- package/lib/cli/test/index.js.map +1 -1
- package/lib/cli/version/index.js +4 -2
- package/lib/cli/version/index.js.map +1 -1
- package/lib/enquirer.d.js +0 -1
- package/lib/eslint.d.js +0 -1
- package/lib/index.js +10 -5
- package/lib/index.js.map +1 -1
- package/lib/skuba.js +0 -1
- package/lib/skuba.js.map +1 -1
- package/lib/utils/args.js +10 -5
- package/lib/utils/args.js.map +1 -1
- package/lib/utils/command.js +12 -6
- package/lib/utils/command.js.map +1 -1
- package/lib/utils/copy.js +10 -5
- package/lib/utils/copy.js.map +1 -1
- package/lib/utils/dir.js +16 -8
- package/lib/utils/dir.js.map +1 -1
- package/lib/utils/env.js +4 -2
- package/lib/utils/env.js.map +1 -1
- package/lib/utils/error.js +10 -5
- package/lib/utils/error.js.map +1 -1
- package/lib/utils/exec.js +12 -6
- package/lib/utils/exec.js.map +1 -1
- package/lib/utils/fs.js +4 -2
- package/lib/utils/fs.js.map +1 -1
- package/lib/utils/help.js +4 -2
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/logging.js +10 -5
- package/lib/utils/logging.js.map +1 -1
- package/lib/utils/logo.js +4 -2
- package/lib/utils/logo.js.map +1 -1
- package/lib/utils/manifest.js +16 -8
- package/lib/utils/manifest.js.map +1 -1
- package/lib/utils/npmrc.js +4 -2
- package/lib/utils/npmrc.js.map +1 -1
- package/lib/utils/packageManager.js +10 -5
- package/lib/utils/packageManager.js.map +1 -1
- package/lib/utils/port.js +6 -3
- package/lib/utils/port.js.map +1 -1
- package/lib/utils/sleep.js +4 -2
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/template.js +20 -10
- package/lib/utils/template.js.map +1 -1
- package/lib/utils/validation.js +14 -7
- package/lib/utils/validation.js.map +1 -1
- package/lib/utils/version.js +10 -5
- package/lib/utils/version.js.map +1 -1
- package/lib/utils/wait.js +6 -3
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.js +6 -3
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/function-arguments.d.js +0 -1
- package/lib/wrapper/functionHandler.js +4 -2
- package/lib/wrapper/functionHandler.js.map +1 -1
- package/lib/wrapper/http.js +6 -3
- package/lib/wrapper/http.js.map +1 -1
- package/lib/wrapper/index.js +0 -1
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js +4 -2
- package/lib/wrapper/main.js.map +1 -1
- package/lib/wrapper/requestListener.js +4 -2
- package/lib/wrapper/requestListener.js.map +1 -1
- package/lib/wrapper/server.js +4 -2
- package/lib/wrapper/server.js.map +1 -1
- package/package.json +4 -4
- package/template/greeter/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/package.json +2 -2
- package/lib/config/prettier.d.ts +0 -7
- /package/lib/{src/cli → cli}/adapter/eslint.d.ts +0 -0
- /package/lib/{src/cli → cli}/adapter/prettier.d.ts +0 -0
- /package/lib/{src/cli → cli}/build/args.d.ts +0 -0
- /package/lib/{src/cli → cli}/build/assets.d.ts +0 -0
- /package/lib/{src/cli → cli}/build/esbuild.d.ts +0 -0
- /package/lib/{src/cli → cli}/build/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/build/tsc.d.ts +0 -0
- /package/lib/{src/cli → cli}/buildPackage/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/analyseConfiguration.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/analyseDependencies.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/analysis/diff.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/analysis/files.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/analysis/git.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/analysis/package.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/analysis/project.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/dependencies/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/dependencies/seekDatadogCustomMetrics.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/dependencies/seekKoala.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/dependencies/skuba.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/dependencies/skubaDeps.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/dependencies/skubaDive.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/ensureTemplateCompletion.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/getEntryPoint.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/getProjectType.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/eslint.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/ignore.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/nodemon.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/package.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/prettier.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/renovate.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/serverless.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/modules/tslint.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/configFile.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/deleteFiles.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/javascript.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/json.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/loadFiles.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/module.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/package.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/prettier.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/record.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/processing/typescript.d.ts +0 -0
- /package/lib/{src/cli → cli}/configure/types.d.ts +0 -0
- /package/lib/{src/cli → cli}/format/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/help/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/init/getConfig.d.ts +0 -0
- /package/lib/{src/cli → cli}/init/git.d.ts +0 -0
- /package/lib/{src/cli → cli}/init/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/init/prompts.d.ts +0 -0
- /package/lib/{src/cli → cli}/init/types.d.ts +0 -0
- /package/lib/{src/cli → cli}/init/validation.d.ts +0 -0
- /package/lib/{src/cli → cli}/init/writePackageJson.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/buildkite/eslint.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/buildkite/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/buildkite/internal.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/buildkite/prettier.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/buildkite/tsc.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/github/eslint.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/github/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/github/internal.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/github/prettier.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/github/tsc.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/annotate/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/autofix.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/eslint.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/external.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internal.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/detectBadCodeowners.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/noSkubaTemplateJs.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/patchRenovateConfig.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/refreshConfigFiles.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/10.0.4/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/10.1.0/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.0.2/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.1.1/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.3.0/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.4.0/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.4.1/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/7.3.1/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/8.0.0/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/8.2.1/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/9.0.1/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/9.1.0/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/prettier.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/tsc.d.ts +0 -0
- /package/lib/{src/cli → cli}/lint/types.d.ts +0 -0
- /package/lib/{src/cli → cli}/migrate/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/migrate/nodeVersion/checks.d.ts +0 -0
- /package/lib/{src/cli → cli}/migrate/nodeVersion/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/node/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/release/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/start/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/test/index.d.ts +0 -0
- /package/lib/{src/cli → cli}/version/index.d.ts +0 -0
- /package/lib/{src/index.d.ts → index.d.ts} +0 -0
- /package/lib/{src/skuba.d.ts → skuba.d.ts} +0 -0
- /package/lib/{src/utils → utils}/args.d.ts +0 -0
- /package/lib/{src/utils → utils}/command.d.ts +0 -0
- /package/lib/{src/utils → utils}/copy.d.ts +0 -0
- /package/lib/{src/utils → utils}/dir.d.ts +0 -0
- /package/lib/{src/utils → utils}/env.d.ts +0 -0
- /package/lib/{src/utils → utils}/error.d.ts +0 -0
- /package/lib/{src/utils → utils}/exec.d.ts +0 -0
- /package/lib/{src/utils → utils}/fs.d.ts +0 -0
- /package/lib/{src/utils → utils}/help.d.ts +0 -0
- /package/lib/{src/utils → utils}/logging.d.ts +0 -0
- /package/lib/{src/utils → utils}/logo.d.ts +0 -0
- /package/lib/{src/utils → utils}/manifest.d.ts +0 -0
- /package/lib/{src/utils → utils}/npmrc.d.ts +0 -0
- /package/lib/{src/utils → utils}/packageManager.d.ts +0 -0
- /package/lib/{src/utils → utils}/port.d.ts +0 -0
- /package/lib/{src/utils → utils}/sleep.d.ts +0 -0
- /package/lib/{src/utils → utils}/template.d.ts +0 -0
- /package/lib/{src/utils → utils}/validation.d.ts +0 -0
- /package/lib/{src/utils → utils}/version.d.ts +0 -0
- /package/lib/{src/utils → utils}/wait.d.ts +0 -0
- /package/lib/{src/utils → utils}/worker.d.ts +0 -0
- /package/lib/{src/wrapper → wrapper}/functionHandler.d.ts +0 -0
- /package/lib/{src/wrapper → wrapper}/http.d.ts +0 -0
- /package/lib/{src/wrapper → wrapper}/index.d.ts +0 -0
- /package/lib/{src/wrapper → wrapper}/main.d.ts +0 -0
- /package/lib/{src/wrapper → wrapper}/requestListener.d.ts +0 -0
- /package/lib/{src/wrapper → wrapper}/server.d.ts +0 -0
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/github/prettier.ts"],
|
|
4
4
|
"sourcesContent": ["import type { PrettierOutput } from '../../../adapter/prettier.js';\n\nimport type * as GitHub from '@skuba-lib/api/github';\n\nexport const createPrettierAnnotations = (\n prettier: PrettierOutput,\n): GitHub.Annotation[] =>\n prettier.result.errored.map((result) => {\n const message =\n result.err instanceof Error ? result.err.message : result.err;\n\n return {\n annotation_level: 'failure',\n start_line: 1,\n end_line: 1,\n path: result.filepath,\n message:\n typeof message === 'string' || message instanceof Error\n ? String(message)\n : 'This file has not been formatted.',\n title: 'Prettier',\n };\n });\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAIO,MAAM,4BAA4B,CACvC,aAEA,SAAS,OAAO,QAAQ,IAAI,CAAC,WAAW;AACtC,QAAM,UACJ,OAAO,eAAe,QAAQ,OAAO,IAAI,UAAU,OAAO;AAE5D,SAAO;AAAA,IACL,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,MAAM,OAAO;AAAA,IACb,SACE,OAAO,YAAY,YAAY,mBAAmB,QAC9C,OAAO,OAAO,IACd;AAAA,IACN,OAAO;AAAA,EACT;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { stripVTControlCharacters as stripAnsi } from "util";
|
|
3
2
|
const tscOutputRegex = /([^\s].*)[\(:](\d+)[,:](\d+)(?:\):\s+|\s+-\s+)(error|warning|info)\s+TS(\d+)\s*:\s*([\s\S]*?)(?=\n\S)(?=\n\D)/g;
|
|
4
3
|
const annotationLevelMap = {
|
|
@@ -6,7 +5,7 @@ const annotationLevelMap = {
|
|
|
6
5
|
warning: "warning",
|
|
7
6
|
info: "notice"
|
|
8
7
|
};
|
|
9
|
-
|
|
8
|
+
const createTscAnnotations = (tscOk, tscOutputStream) => {
|
|
10
9
|
if (tscOk) {
|
|
11
10
|
return [];
|
|
12
11
|
}
|
|
@@ -24,4 +23,7 @@ export const createTscAnnotations = (tscOk, tscOutputStream) => {
|
|
|
24
23
|
} : []
|
|
25
24
|
);
|
|
26
25
|
};
|
|
26
|
+
export {
|
|
27
|
+
createTscAnnotations
|
|
28
|
+
};
|
|
27
29
|
//# sourceMappingURL=tsc.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/github/tsc.ts"],
|
|
4
4
|
"sourcesContent": ["import { stripVTControlCharacters as stripAnsi } from 'util';\n\nimport type { StreamInterceptor } from '../../../lint/external.js';\n\nimport type * as GitHub from '@skuba-lib/api/github';\n\ntype TscLevel = 'error' | 'warning' | 'info';\n\n/**\n * Matches the `tsc \u2502` prefix on each `tsc` log.\n */\n\n/**\n * Matches regular and pretty `tsc` output.\n *\n * For example, given the following input string:\n *\n * ```console\n * src/skuba.ts:43:7 - error TS2769: No overload matches this call.\n * Overload 1 of 2, '(obj: LogContext, msg?: string | undefined, ...args: any[]): void', gave the following error.\n * Argument of type 'unknown' is not assignable to parameter of type 'LogContext'.\n * Overload 2 of 2, '(msg?: string | undefined, ...args: any[]): void', gave the following error.\n * Argument of type 'unknown' is not assignable to parameter of type 'string | undefined'.\n * Type 'unknown' is not assignable to type 'string'.\n * ```\n *\n * This pattern will produce the following matches:\n *\n * 1. src/skuba.ts\n * 2. 43\n * 3. 7\n * 4. error\n * 5. 2769\n * 6. No overload matches this call [...] not assignable to type 'string'.\n */\nconst tscOutputRegex =\n /([^\\s].*)[\\(:](\\d+)[,:](\\d+)(?:\\):\\s+|\\s+-\\s+)(error|warning|info)\\s+TS(\\d+)\\s*:\\s*([\\s\\S]*?)(?=\\n\\S)(?=\\n\\D)/g;\n\nconst annotationLevelMap: Record<\n TscLevel,\n GitHub.Annotation['annotation_level']\n> = {\n error: 'failure',\n warning: 'warning',\n info: 'notice',\n};\n\nexport const createTscAnnotations = (\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n): GitHub.Annotation[] => {\n if (tscOk) {\n return [];\n }\n\n const matches = stripAnsi(tscOutputStream.output()).matchAll(tscOutputRegex);\n return Array.from(matches).flatMap<GitHub.Annotation>((match) =>\n match?.length === 7 && match[1] && match[4] && match[5] && match[6]\n ? {\n annotation_level: annotationLevelMap[match[4] as TscLevel],\n path: match[1],\n start_line: Number(match[2]),\n end_line: Number(match[2]),\n start_column: Number(match[3]),\n end_column: Number(match[3]),\n message: match[6].trim(),\n title: `tsc (TS${match[5]})`,\n }\n : [],\n );\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,SAAS,4BAA4B,iBAAiB;AAmCtD,MAAM,iBACJ;AAEF,MAAM,qBAGF;AAAA,EACF,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AACR;AAEO,MAAM,uBAAuB,CAClC,OACA,oBACwB;AACxB,MAAI,OAAO;AACT,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,UAAU,UAAU,gBAAgB,OAAO,CAAC,EAAE,SAAS,cAAc;AAC3E,SAAO,MAAM,KAAK,OAAO,EAAE;AAAA,IAA2B,CAAC,UACrD,OAAO,WAAW,KAAK,MAAM,CAAC,KAAK,MAAM,CAAC,KAAK,MAAM,CAAC,KAAK,MAAM,CAAC,IAC9D;AAAA,MACE,kBAAkB,mBAAmB,MAAM,CAAC,CAAa;AAAA,MACzD,MAAM,MAAM,CAAC;AAAA,MACb,YAAY,OAAO,MAAM,CAAC,CAAC;AAAA,MAC3B,UAAU,OAAO,MAAM,CAAC,CAAC;AAAA,MACzB,cAAc,OAAO,MAAM,CAAC,CAAC;AAAA,MAC7B,YAAY,OAAO,MAAM,CAAC,CAAC;AAAA,MAC3B,SAAS,MAAM,CAAC,EAAE,KAAK;AAAA,MACvB,OAAO,UAAU,MAAM,CAAC,CAAC;AAAA,IAC3B,IACA,CAAC;AAAA,EACP;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { createBuildkiteAnnotations } from "./buildkite/index.js";
|
|
3
2
|
import { createGitHubAnnotations } from "./github/index.js";
|
|
4
|
-
|
|
3
|
+
const createAnnotations = async (internal, eslint, prettier, tscOk, tscOutputStream) => {
|
|
5
4
|
await Promise.all([
|
|
6
5
|
createGitHubAnnotations(internal, eslint, prettier, tscOk, tscOutputStream),
|
|
7
6
|
createBuildkiteAnnotations(
|
|
@@ -13,4 +12,7 @@ export const createAnnotations = async (internal, eslint, prettier, tscOk, tscOu
|
|
|
13
12
|
)
|
|
14
13
|
]);
|
|
15
14
|
};
|
|
15
|
+
export {
|
|
16
|
+
createAnnotations
|
|
17
|
+
};
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/lint/annotate/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ESLintOutput } from '../../../cli/adapter/eslint.js';\nimport type { PrettierOutput } from '../../../cli/adapter/prettier.js';\nimport type { StreamInterceptor } from '../external.js';\nimport type { InternalLintResult } from '../internal.js';\n\nimport { createBuildkiteAnnotations } from './buildkite/index.js';\nimport { createGitHubAnnotations } from './github/index.js';\n\nexport const createAnnotations = async (\n internal: InternalLintResult,\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n): Promise<void> => {\n await Promise.all([\n createGitHubAnnotations(internal, eslint, prettier, tscOk, tscOutputStream),\n createBuildkiteAnnotations(\n internal,\n eslint,\n prettier,\n tscOk,\n tscOutputStream,\n ),\n ]);\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAKA,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AAEjC,MAAM,oBAAoB,OAC/B,UACA,QACA,UACA,OACA,oBACkB;AAClB,QAAM,QAAQ,IAAI;AAAA,IAChB,wBAAwB,UAAU,QAAQ,UAAU,OAAO,eAAe;AAAA,IAC1E;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/lint/autofix.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import { simpleGit } from "simple-git";
|
|
4
3
|
import { isCiEnv } from "../../utils/env.js";
|
|
@@ -14,13 +13,13 @@ import * as Git from "@skuba-lib/api/git";
|
|
|
14
13
|
import * as GitHub from "@skuba-lib/api/github";
|
|
15
14
|
const RENOVATE_DEFAULT_PREFIX = "renovate";
|
|
16
15
|
const AUTOFIX_COMMIT_MESSAGE = "Run `skuba format`";
|
|
17
|
-
|
|
16
|
+
const AUTOFIX_IGNORE_FILES_BASE = [
|
|
18
17
|
{
|
|
19
18
|
path: "Dockerfile-incunabulum",
|
|
20
19
|
state: "added"
|
|
21
20
|
}
|
|
22
21
|
];
|
|
23
|
-
|
|
22
|
+
const AUTOFIX_IGNORE_FILES_NPMRC = [
|
|
24
23
|
{
|
|
25
24
|
path: ".npmrc",
|
|
26
25
|
state: "added"
|
|
@@ -74,7 +73,7 @@ const getIgnores = async (dir) => {
|
|
|
74
73
|
}
|
|
75
74
|
return AUTOFIX_IGNORE_FILES_BASE;
|
|
76
75
|
};
|
|
77
|
-
|
|
76
|
+
const autofix = async (params) => {
|
|
78
77
|
const dir = process.cwd();
|
|
79
78
|
if (!params.eslint && !params.prettier && !params.internal) {
|
|
80
79
|
return;
|
|
@@ -148,4 +147,9 @@ export const autofix = async (params) => {
|
|
|
148
147
|
log.subtle(inspect(err));
|
|
149
148
|
}
|
|
150
149
|
};
|
|
150
|
+
export {
|
|
151
|
+
AUTOFIX_IGNORE_FILES_BASE,
|
|
152
|
+
AUTOFIX_IGNORE_FILES_NPMRC,
|
|
153
|
+
autofix
|
|
154
|
+
};
|
|
151
155
|
//# sourceMappingURL=autofix.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/autofix.ts"],
|
|
4
4
|
"sourcesContent": ["import { inspect } from 'util';\n\nimport { simpleGit } from 'simple-git';\n\nimport { isCiEnv } from '../../utils/env.js';\nimport { createLogger, log } from '../../utils/logging.js';\nimport { hasNpmrcSecret } from '../../utils/npmrc.js';\nimport { throwOnTimeout } from '../../utils/wait.js';\nimport { runESLint } from '../adapter/eslint.js';\nimport { runPrettier } from '../adapter/prettier.js';\nimport { createDestinationFileReader } from '../configure/analysis/project.js';\n\nimport { internalLint } from './internal.js';\nimport type { Input } from './types.js';\n\nimport * as Buildkite from '@skuba-lib/api/buildkite';\nimport * as Git from '@skuba-lib/api/git';\nimport * as GitHub from '@skuba-lib/api/github';\n\nconst RENOVATE_DEFAULT_PREFIX = 'renovate';\n\nconst AUTOFIX_COMMIT_MESSAGE = 'Run `skuba format`';\n\nexport const AUTOFIX_IGNORE_FILES_BASE: Git.ChangedFile[] = [\n {\n path: 'Dockerfile-incunabulum',\n state: 'added',\n },\n];\n\nexport const AUTOFIX_IGNORE_FILES_NPMRC: Git.ChangedFile[] = [\n {\n path: '.npmrc',\n state: 'added',\n },\n {\n path: '.npmrc',\n state: 'modified',\n },\n];\n\nconst shouldPush = async ({\n currentBranch,\n dir,\n}: {\n currentBranch?: string;\n dir: string;\n}) => {\n if (!isCiEnv()) {\n // We're not running in a CI environment so we don't need to push autofixes.\n // Ideally we'd drive this off of repository write permissions, but that is\n // non-trivial to infer without attempting an actual write.\n return false;\n }\n\n const isDefaultBuildkiteBranch =\n currentBranch &&\n [process.env.BUILDKITE_PIPELINE_DEFAULT_BRANCH, 'master', 'main'].includes(\n currentBranch,\n );\n\n const isProtectedGitHubBranch = process.env.GITHUB_REF_PROTECTED === 'true';\n\n if (isDefaultBuildkiteBranch || isProtectedGitHubBranch) {\n // The current branch is a protected branch.\n // We respect GitHub Flow; avoid pushing directly to the default branch.\n return false;\n }\n\n if (currentBranch?.startsWith(RENOVATE_DEFAULT_PREFIX)) {\n try {\n await GitHub.getPullRequestNumber();\n } catch {\n const warning =\n 'An autofix is available, but it was not pushed because an open pull request for this Renovate branch could not be found. If a pull request has since been created, retry the lint step to push the fix.';\n log.warn(warning);\n try {\n await Buildkite.annotate(Buildkite.md.terminal(warning));\n } catch {}\n\n return false;\n }\n }\n\n let headCommitMessage;\n try {\n headCommitMessage = await Git.getHeadCommitMessage({ dir });\n } catch {}\n\n if (headCommitMessage?.startsWith(AUTOFIX_COMMIT_MESSAGE)) {\n // Short circuit when the head commit appears to be one of our autofixes.\n // Repeating the same operation is unlikely to correct outstanding issues.\n return false;\n }\n\n // Allow the push attempt to go ahead if our guards have been cleared.\n return true;\n};\n\nconst getIgnores = async (dir: string): Promise<Git.ChangedFile[]> => {\n const contents = await createDestinationFileReader(dir)('.npmrc');\n\n // If an .npmrc has secrets, we need to ignore it\n if (hasNpmrcSecret(contents ?? '')) {\n return [...AUTOFIX_IGNORE_FILES_BASE, ...AUTOFIX_IGNORE_FILES_NPMRC];\n }\n\n return AUTOFIX_IGNORE_FILES_BASE;\n};\n\ninterface AutofixParameters {\n debug: Input['debug'];\n\n eslint: boolean;\n prettier: boolean;\n internal: boolean;\n\n eslintConfigFile?: string;\n}\n\nexport const autofix = async (params: AutofixParameters): Promise<void> => {\n const dir = process.cwd();\n\n if (!params.eslint && !params.prettier && !params.internal) {\n return;\n }\n\n let currentBranch;\n try {\n currentBranch = await Git.currentBranch({ dir });\n } catch {}\n\n if (!(await shouldPush({ currentBranch, dir }))) {\n return;\n }\n\n try {\n log.newline();\n\n log.warn(\n `Attempting to autofix issues (${[\n params.internal ? 'skuba' : undefined,\n params.internal || params.eslint ? 'ESLint' : undefined,\n 'Prettier', // Prettier is always run\n ]\n .filter((s) => s !== undefined)\n .join(', ')})...`,\n );\n\n const logger = createLogger({ debug: params.debug });\n\n if (params.internal) {\n await internalLint('format');\n }\n\n if (params.internal || params.eslint) {\n await runESLint('format', logger, params.eslintConfigFile);\n }\n\n // Unconditionally re-run Prettier; reaching here means we have pre-existing\n // format violations or may have created new ones through ESLint/internal fixes.\n await runPrettier('format', logger);\n\n if (process.env.GITHUB_ACTIONS) {\n // GitHub runners have Git installed locally\n const ref = await Git.commitAllChanges({\n dir,\n message: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: await getIgnores(dir),\n });\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n await throwOnTimeout(simpleGit().push(), { s: 30 });\n log.warn(`Pushed fix commit ${ref}.`);\n return;\n }\n\n // Other CI Environments, use GitHub API\n if (!currentBranch) {\n log.warn('Could not determine the current branch.');\n log.warn(\n 'Please propagate BUILDKITE_BRANCH, GITHUB_HEAD_REF, GITHUB_REF_NAME, or the .git directory to your container.',\n );\n return;\n }\n\n const ref = await throwOnTimeout(\n GitHub.uploadAllFileChanges({\n branch: currentBranch,\n dir,\n messageHeadline: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: await getIgnores(dir),\n }),\n { s: 30 },\n );\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n log.warn(`Pushed fix commit ${ref}.`);\n } catch (err) {\n log.warn(log.bold('Failed to push fix commit.'));\n log.warn(\n log.bold(\n 'Does your CI environment have write access to your Git repository?',\n ),\n );\n log.subtle(inspect(err));\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAExB,SAAS,iBAAiB;AAE1B,SAAS,eAAe;AACxB,SAAS,cAAc,WAAW;AAClC,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,mCAAmC;AAE5C,SAAS,oBAAoB;AAG7B,YAAY,eAAe;AAC3B,YAAY,SAAS;AACrB,YAAY,YAAY;AAExB,MAAM,0BAA0B;AAEhC,MAAM,yBAAyB;AAExB,MAAM,4BAA+C;AAAA,EAC1D;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACF;AAEO,MAAM,6BAAgD;AAAA,EAC3D;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,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AAK;AACR,aAAO,IAAI,KAAK,wBAAwB;AAAA,IAC1C;AAEA,QAAI,KAAK,qBAAqB,GAAG,GAAG;AAAA,EACtC,SAAS,KAAK;AACZ,QAAI,KAAK,IAAI,KAAK,4BAA4B,CAAC;AAC/C,QAAI;AAAA,MACF,IAAI;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,QAAI,OAAO,QAAQ,GAAG,CAAC;AAAA,EACzB;AACF;",
|
|
6
6
|
"names": ["ref"]
|
|
7
7
|
}
|
package/lib/cli/lint/eslint.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { isMainThread } from "worker_threads";
|
|
4
3
|
import chalk from "chalk";
|
|
@@ -6,12 +5,12 @@ import { createLogger } from "../../utils/logging.js";
|
|
|
6
5
|
import { execWorkerThread, postWorkerOutput } from "../../utils/worker.js";
|
|
7
6
|
import { runESLint } from "../adapter/eslint.js";
|
|
8
7
|
const LOG_PREFIX = chalk.magenta("ESLint \u2502");
|
|
9
|
-
|
|
8
|
+
const runESLintInCurrentThread = ({ debug, eslintConfigFile }) => runESLint(
|
|
10
9
|
"lint",
|
|
11
10
|
createLogger({ debug, prefixes: [LOG_PREFIX] }),
|
|
12
11
|
eslintConfigFile
|
|
13
12
|
);
|
|
14
|
-
|
|
13
|
+
const runESLintInWorkerThread = (input) => execWorkerThread(
|
|
15
14
|
path.posix.join(import.meta.dirname, "eslint.js"),
|
|
16
15
|
input
|
|
17
16
|
);
|
|
@@ -21,4 +20,8 @@ if (!isMainThread) {
|
|
|
21
20
|
createLogger({ debug: false, prefixes: [LOG_PREFIX] })
|
|
22
21
|
);
|
|
23
22
|
}
|
|
23
|
+
export {
|
|
24
|
+
runESLintInCurrentThread,
|
|
25
|
+
runESLintInWorkerThread
|
|
26
|
+
};
|
|
24
27
|
//# sourceMappingURL=eslint.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/eslint.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\nimport { isMainThread } from 'worker_threads';\n\nimport chalk from 'chalk';\n\nimport { createLogger } from '../../utils/logging.js';\nimport { execWorkerThread, postWorkerOutput } from '../../utils/worker.js';\nimport { type ESLintOutput, runESLint } from '../adapter/eslint.js';\n\nimport type { Input } from './types.js';\n\nconst LOG_PREFIX = chalk.magenta('ESLint \u2502');\n\nexport const runESLintInCurrentThread = ({ debug, eslintConfigFile }: Input) =>\n runESLint(\n 'lint',\n createLogger({ debug, prefixes: [LOG_PREFIX] }),\n eslintConfigFile,\n );\n\nexport const runESLintInWorkerThread = (input: Input) =>\n execWorkerThread<Input, ESLintOutput>(\n path.posix.join(import.meta.dirname, 'eslint.js'),\n input,\n );\n\nif (!isMainThread) {\n postWorkerOutput(\n runESLintInCurrentThread,\n createLogger({ debug: false, prefixes: [LOG_PREFIX] }),\n );\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,oBAAoB;AAE7B,OAAO,WAAW;AAElB,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,wBAAwB;AACnD,SAA4B,iBAAiB;AAI7C,MAAM,aAAa,MAAM,QAAQ,iBAAY;AAEtC,MAAM,2BAA2B,CAAC,EAAE,OAAO,iBAAiB,MACjE;AAAA,EACE;AAAA,EACA,aAAa,EAAE,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC;AAAA,EAC9C;AACF;AAEK,MAAM,0BAA0B,CAAC,UACtC;AAAA,EACE,KAAK,MAAM,KAAK,YAAY,SAAS,WAAW;AAAA,EAChD;AACF;AAEF,IAAI,CAAC,cAAc;AACjB;AAAA,IACE;AAAA,IACA,aAAa,EAAE,OAAO,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC;AAAA,EACvD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/lint/external.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import stream from "stream";
|
|
3
2
|
import { runESLintInCurrentThread, runESLintInWorkerThread } from "./eslint.js";
|
|
4
3
|
import {
|
|
@@ -7,7 +6,7 @@ import {
|
|
|
7
6
|
} from "./prettier.js";
|
|
8
7
|
import { runTscInNewProcess } from "./tsc.js";
|
|
9
8
|
const tscPrefixRegex = /^(.*?tsc\s+│.*?\s)/gm;
|
|
10
|
-
|
|
9
|
+
class StreamInterceptor extends stream.Transform {
|
|
11
10
|
chunks = [];
|
|
12
11
|
output() {
|
|
13
12
|
return Buffer.concat(this.chunks).toString().replace(tscPrefixRegex, "");
|
|
@@ -44,7 +43,7 @@ const selectLintFunction = (input) => {
|
|
|
44
43
|
const isSerial = input.debug || input.serial;
|
|
45
44
|
return isSerial ? lintSerially : lintConcurrently;
|
|
46
45
|
};
|
|
47
|
-
|
|
46
|
+
const externalLint = async (input) => {
|
|
48
47
|
const lint = selectLintFunction(input);
|
|
49
48
|
const tscOutputStream = new StreamInterceptor();
|
|
50
49
|
tscOutputStream.pipe(input.tscOutputStream ?? process.stdout);
|
|
@@ -56,4 +55,8 @@ export const externalLint = async (input) => {
|
|
|
56
55
|
tscOutputStream
|
|
57
56
|
};
|
|
58
57
|
};
|
|
58
|
+
export {
|
|
59
|
+
StreamInterceptor,
|
|
60
|
+
externalLint
|
|
61
|
+
};
|
|
59
62
|
//# sourceMappingURL=external.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/external.ts"],
|
|
4
4
|
"sourcesContent": ["import stream from 'stream';\n\nimport { runESLintInCurrentThread, runESLintInWorkerThread } from './eslint.js';\nimport {\n runPrettierInCurrentThread,\n runPrettierInWorkerThread,\n} from './prettier.js';\nimport { runTscInNewProcess } from './tsc.js';\nimport type { Input } from './types.js';\n\nconst tscPrefixRegex = /^(.*?tsc\\s+\u2502.*?\\s)/gm;\n\nexport class StreamInterceptor extends stream.Transform {\n private chunks: Uint8Array[] = [];\n\n public output() {\n return Buffer.concat(this.chunks).toString().replace(tscPrefixRegex, '');\n }\n\n _transform(\n chunk: Uint8Array,\n _encoding: BufferEncoding,\n callback: stream.TransformCallback,\n ) {\n this.chunks.push(chunk);\n\n callback(null, chunk);\n }\n}\n\nconst lintConcurrently = async ({ tscOutputStream, ...input }: Input) => {\n const [eslint, prettier, tscOk] = await Promise.all([\n runESLintInWorkerThread(input),\n runPrettierInWorkerThread(input),\n runTscInNewProcess({ ...input, tscOutputStream }),\n ]);\n\n return { eslint, prettier, tscOk };\n};\n\n/**\n * Run linting tools `--serial`ly for resource-constrained environments.\n *\n * Note that we still run ESLint and Prettier in worker threads as a\n * counterintuitive optimisation. Memory can be more readily freed on worker\n * thread exit, which isn't as easy with a monolithic main thread.\n */\nconst lintSerially = async ({ tscOutputStream, ...input }: Input) => {\n const eslint = await runESLintInWorkerThread(input);\n const prettier = await runPrettierInWorkerThread(input);\n const tscOk = await runTscInNewProcess({ ...input, tscOutputStream });\n\n return { eslint, prettier, tscOk };\n};\n\nconst lintSeriallyWithoutWorkerThreads = async (input: Input) => {\n const eslint = await runESLintInCurrentThread(input);\n const prettier = await runPrettierInCurrentThread(input);\n const tscOk = await runTscInNewProcess(input);\n\n return { eslint, prettier, tscOk };\n};\n\nconst selectLintFunction = (input: Input) => {\n if (!input.workerThreads) {\n return lintSeriallyWithoutWorkerThreads;\n }\n\n // `--debug` implies `--serial`.\n const isSerial = input.debug || input.serial;\n\n return isSerial ? lintSerially : lintConcurrently;\n};\n\nexport const externalLint = async (input: Input) => {\n const lint = selectLintFunction(input);\n\n const tscOutputStream = new StreamInterceptor();\n tscOutputStream.pipe(input.tscOutputStream ?? process.stdout);\n\n const { eslint, prettier, tscOk } = await lint({ ...input, tscOutputStream });\n\n return {\n eslint,\n prettier,\n tscOk,\n tscOutputStream,\n };\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA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SAAS,MAAM;AAEtC,SAAO,WAAW,eAAe;AACnC;AAEO,MAAM,eAAe,OAAO,UAAiB;AAClD,QAAM,OAAO,mBAAmB,KAAK;AAErC,QAAM,kBAAkB,IAAI,kBAAkB;AAC9C,kBAAgB,KAAK,MAAM,mBAAmB,QAAQ,MAAM;AAE5D,QAAM,EAAE,QAAQ,UAAU,MAAM,IAAI,MAAM,KAAK,EAAE,GAAG,OAAO,gBAAgB,CAAC;AAE5E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/lint/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import { hasDebugFlag, hasSerialFlag } from "../../utils/args.js";
|
|
4
3
|
import { log } from "../../utils/logging.js";
|
|
@@ -8,7 +7,7 @@ import { createAnnotations } from "./annotate/index.js";
|
|
|
8
7
|
import { autofix } from "./autofix.js";
|
|
9
8
|
import { externalLint } from "./external.js";
|
|
10
9
|
import { internalLint } from "./internal.js";
|
|
11
|
-
|
|
10
|
+
const lint = async (args = process.argv.slice(2), tscWriteable = void 0, workerThreads = true) => {
|
|
12
11
|
const opts = {
|
|
13
12
|
debug: hasDebugFlag(args),
|
|
14
13
|
serial: hasSerialFlag(args),
|
|
@@ -54,4 +53,7 @@ export const lint = async (args = process.argv.slice(2), tscWriteable = void 0,
|
|
|
54
53
|
internal: internal.fixable
|
|
55
54
|
});
|
|
56
55
|
};
|
|
56
|
+
export {
|
|
57
|
+
lint
|
|
58
|
+
};
|
|
57
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { Writable } from 'stream';\nimport { inspect } from 'util';\n\nimport { hasDebugFlag, hasSerialFlag } from '../../utils/args.js';\nimport { log } from '../../utils/logging.js';\nimport { detectPackageManager } from '../../utils/packageManager.js';\nimport { throwOnTimeout } from '../../utils/wait.js';\n\nimport { createAnnotations } from './annotate/index.js';\nimport { autofix } from './autofix.js';\nimport { externalLint } from './external.js';\nimport { internalLint } from './internal.js';\nimport type { Input } from './types.js';\n\nexport const lint = async (\n args = process.argv.slice(2),\n tscWriteable: Writable | undefined = undefined,\n workerThreads = true,\n) => {\n const opts: Input = {\n debug: hasDebugFlag(args),\n serial: hasSerialFlag(args),\n tscOutputStream: tscWriteable,\n workerThreads,\n };\n\n const { eslint, prettier, tscOk, tscOutputStream } = await externalLint(opts);\n const internal = await internalLint('lint', opts);\n\n try {\n await throwOnTimeout(\n createAnnotations(internal, eslint, prettier, tscOk, tscOutputStream),\n { s: 30 },\n );\n } catch (err) {\n log.warn('Failed to annotate lint results.');\n log.subtle(inspect(err));\n }\n\n if (!internal.ok || !eslint.ok || !prettier.ok || !tscOk) {\n process.exitCode = 1;\n\n const tools = [\n ...(internal.ok ? [] : ['skuba']),\n ...(eslint.ok ? [] : ['ESLint']),\n ...(prettier.ok ? [] : ['Prettier']),\n ...(tscOk ? [] : ['tsc']),\n ];\n\n log.err(`${tools.join(', ')} found issues that require triage.`);\n\n if (internal.fixable || eslint.fixable || !prettier.ok) {\n const packageManager = await detectPackageManager();\n log.newline();\n log.warn(\n `Try running ${log.bold(\n packageManager.print.exec,\n 'skuba',\n 'format',\n )} to fix them.`,\n );\n }\n }\n\n await autofix({\n debug: opts.debug,\n eslint: eslint.fixable,\n prettier: !prettier.ok,\n internal: internal.fixable,\n });\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AACA,SAAS,eAAe;AAExB,SAAS,cAAc,qBAAqB;AAC5C,SAAS,WAAW;AACpB,SAAS,4BAA4B;AACrC,SAAS,sBAAsB;AAE/B,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,oBAAo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AAAA,IACZ,QAAQ,OAAO;AAAA,IACf,UAAU,CAAC,SAAS;AAAA,IACpB,UAAU,SAAS;AAAA,EACrB,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/lint/internal.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import chalk from "chalk";
|
|
4
3
|
import { childLogger, createLogger } from "../../utils/logging.js";
|
|
@@ -51,7 +50,7 @@ const selectLintFunction = (input) => {
|
|
|
51
50
|
const isSerial = input?.debug || input?.serial;
|
|
52
51
|
return isSerial ? lintSerially : lintConcurrently;
|
|
53
52
|
};
|
|
54
|
-
|
|
53
|
+
const internalLint = async (mode, input) => {
|
|
55
54
|
const start = process.hrtime.bigint();
|
|
56
55
|
const logger = createLogger({
|
|
57
56
|
debug: input?.debug ?? false,
|
|
@@ -79,4 +78,7 @@ const combineResults = (results) => results.reduce(
|
|
|
79
78
|
}),
|
|
80
79
|
{ ok: true, fixable: false }
|
|
81
80
|
);
|
|
81
|
+
export {
|
|
82
|
+
internalLint
|
|
83
|
+
};
|
|
82
84
|
//# sourceMappingURL=internal.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/internal.ts"],
|
|
4
4
|
"sourcesContent": ["import { inspect } from 'util';\n\nimport chalk from 'chalk';\n\nimport { type Logger, childLogger, createLogger } from '../../utils/logging.js';\n\nimport { tryDetectBadCodeowners } from './internalLints/detectBadCodeowners.js';\nimport { noSkubaTemplateJs } from './internalLints/noSkubaTemplateJs.js';\nimport { tryRefreshConfigFiles } from './internalLints/refreshConfigFiles.js';\nimport { upgradeSkuba } from './internalLints/upgrade/index.js';\nimport type { Input } from './types.js';\n\nexport type InternalLintResult = {\n ok: boolean;\n fixable: boolean;\n annotations?: Array<{\n start_line?: number;\n end_line?: number;\n path: string;\n message: string;\n }>;\n};\n\nconst lints: Array<\n Array<{\n name: string;\n lint: (\n mode: 'format' | 'lint',\n logger: Logger,\n additionalFlags: string[],\n ) => Promise<InternalLintResult>;\n }>\n> = [\n // Run upgradeSkuba first, in particular before refreshConfigFiles, for npmrc handling\n [{ name: 'upgrade-skuba', lint: upgradeSkuba }],\n [\n { name: 'no-skuba-template-js', lint: noSkubaTemplateJs },\n { name: 'refresh-config-files', lint: tryRefreshConfigFiles },\n { name: 'detect-bad-codeowners', lint: tryDetectBadCodeowners },\n ],\n];\n\nconst lintSerially = async (\n mode: 'format' | 'lint',\n logger: Logger,\n additionalFlags: string[],\n) => {\n const results: InternalLintResult[] = [];\n for (const lintGroup of lints) {\n for (const { lint, name } of lintGroup) {\n results.push(\n await lint(\n mode,\n childLogger(logger, { suffixes: [chalk.dim(name)] }),\n additionalFlags,\n ),\n );\n }\n }\n return results;\n};\n\nconst lintConcurrently = async (\n mode: 'format' | 'lint',\n logger: Logger,\n additionalFlags: string[],\n) => {\n const results: InternalLintResult[] = [];\n\n for (const lintGroup of lints) {\n results.push(\n ...(await Promise.all(\n lintGroup.map(async ({ name, lint }) =>\n lint(\n mode,\n childLogger(logger, { suffixes: [chalk.dim(name)] }),\n additionalFlags,\n ),\n ),\n )),\n );\n }\n\n return results;\n};\n\nconst selectLintFunction = (input?: Input) => {\n const isSerial = input?.debug || input?.serial;\n return isSerial ? lintSerially : lintConcurrently;\n};\n\nexport const internalLint = async (\n mode: 'format' | 'lint',\n input?: Input,\n): Promise<InternalLintResult> => {\n const start = process.hrtime.bigint();\n const logger = createLogger({\n debug: input?.debug ?? false,\n prefixes: [...(mode === 'lint' ? [chalk.blueBright('skuba \u2502')] : [])],\n });\n\n try {\n const lint = selectLintFunction(input);\n const results = await lint(mode, logger, input?.additionalFlags ?? []);\n const result = combineResults(results);\n const end = process.hrtime.bigint();\n logger.plain(`Processed skuba lints in ${logger.timing(start, end)}.`);\n return result;\n } catch (err) {\n logger.err(logger.bold('Failed to run skuba lints.'));\n logger.subtle(inspect(err));\n\n process.exitCode = 1;\n\n return { ok: false, fixable: false, annotations: [] };\n }\n};\n\nconst combineResults = (results: InternalLintResult[]): InternalLintResult =>\n results.reduce(\n (cur, next) => ({\n ok: cur.ok && next.ok,\n fixable: cur.fixable || next.fixable,\n annotations: [...(cur.annotations ?? []), ...(next.annotations ?? [])],\n }),\n { ok: true, fixable: false },\n );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAExB,OAAO,WAAW;AAElB,SAAsB,aAAa,oBAAoB;AAEvD,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAc7B,MAAM,QASF;AAAA;AAAA,EAEF,CAAC,EAAE,MAAM,iBAAiB,MAAM,aAAa,CAAC;AAAA,EAC9C;AAAA,IACE,EAAE,MAAM,wBAAwB,MAAM,kBAAkB;AAAA,IACxD,EAAE,MAAM,wBAAwB,MAAM,sBAAsB;AAAA,IAC5D,EAAE,MAAM,yBAAyB,MAAM,uBAAuB;AAAA,EAChE;AACF;AAEA,MAAM,eAAe,OACnB,MACA,QACA,oBACG;AACH,QAAM,UAAgC,CAAC;AACvC,aAAW,aAAa,OAAO;AAC7B,eAAW,EAAE,MAAM,KAAK,KAAK,WAAW;AACtC,cAAQ;AAAA,QACN,MAAM;AAAA,UACJ;AAAA,UACA,YAAY,QAAQ,EAAE,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC;AAAA,UACnD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,mBAAmB,OACvB,MACA,QACA,oBACG;AACH,QAAM,UAAgC,CAAC;AAEvC,aAAW,aAAa,OAAO;AAC7B,YAAQ;AAAA,MACN,GAAI,MAAM,QAAQ;AAAA,QAChB,UAAU;AAAA,UAAI,OAAO,EAAE,MAAM,KAAK,MAChC;AAAA,YACE;AAAA,YACA,YAAY,QAAQ,EAA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names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import { Git } from "../../../index.js";
|
|
4
3
|
import { createDestinationFileReader } from "../../configure/analysis/project.js";
|
|
5
|
-
|
|
4
|
+
const detectBadCodeowners = async (logger) => {
|
|
6
5
|
const gitRoot = await Git.findRoot({ dir: process.cwd() });
|
|
7
6
|
const reader = createDestinationFileReader(gitRoot ?? process.cwd());
|
|
8
7
|
const annotations = (await Promise.all(
|
|
@@ -30,7 +29,7 @@ export const detectBadCodeowners = async (logger) => {
|
|
|
30
29
|
annotations
|
|
31
30
|
};
|
|
32
31
|
};
|
|
33
|
-
|
|
32
|
+
const tryDetectBadCodeowners = async (_mode, logger) => {
|
|
34
33
|
try {
|
|
35
34
|
return await detectBadCodeowners(logger);
|
|
36
35
|
} catch (err) {
|
|
@@ -43,4 +42,8 @@ export const tryDetectBadCodeowners = async (_mode, logger) => {
|
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
44
|
};
|
|
45
|
+
export {
|
|
46
|
+
detectBadCodeowners,
|
|
47
|
+
tryDetectBadCodeowners
|
|
48
|
+
};
|
|
46
49
|
//# sourceMappingURL=detectBadCodeowners.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/lint/internalLints/detectBadCodeowners.ts"],
|
|
4
4
|
"sourcesContent": ["import { inspect } from 'util';\n\nimport { Git } from '../../../index.js';\nimport type { Logger } from '../../../utils/logging.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\nimport type { InternalLintResult } from '../internal.js';\n\nexport const detectBadCodeowners = async (\n logger: Logger,\n): Promise<InternalLintResult> => {\n const gitRoot = await Git.findRoot({ dir: process.cwd() });\n const reader = createDestinationFileReader(gitRoot ?? process.cwd());\n\n const annotations = (\n await Promise.all(\n ['.github/CODEOWNERS', 'CODEOWNERS', 'docs/CODEOWNERS'].map(\n async (filename) => {\n const lines = (await reader(filename))?.split('\\n');\n\n if (lines?.some((line) => line.startsWith('- '))) {\n return [\n {\n message:\n 'CODEOWNERS file has a line starting with `- `. This is probably an autoformatting mistake, where your editor thinks this file is a markdown file and is trying to format a list item. Did you mean to use `*` instead?',\n path: filename,\n },\n ];\n }\n\n return [];\n },\n ),\n )\n )\n .flat()\n .toSorted((a, b) => a.path.localeCompare(b.path));\n\n annotations.forEach(({ path, message }) => {\n logger.warn(`${path}: ${message}`);\n });\n\n return {\n ok: annotations.length === 0,\n fixable: false,\n annotations,\n };\n};\n\nexport const tryDetectBadCodeowners = async (\n _mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n try {\n return await detectBadCodeowners(logger);\n } catch (err) {\n logger.warn('Failed to detect bad CODEOWNERS.');\n logger.subtle(inspect(err));\n\n return {\n ok: false,\n fixable: false,\n annotations: [],\n };\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAExB,SAAS,WAAW;AAEpB,SAAS,mCAAmC;AAGrC,MAAM,sBAAsB,OACjC,WACgC;AAChC,QAAM,UAAU,MAAM,IAAI,SAAS,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AACzD,QAAM,SAAS,4BAA4B,WAAW,QAAQ,IAAI,CAAC;AAEnE,QAAM,eACJ,MAAM,QAAQ;AAAA,IACZ,CAAC,sBAAsB,cAAc,iBAAiB,EAAE;AAAA,MACtD,OAAO,aAAa;AAClB,cAAM,SAAS,MAAM,OAAO,QAAQ,IAAI,MAAM,IAAI;AAElD,YAAI,OAAO,KAAK,CAAC,SAAS,KAAK,WAAW,IAAI,CAAC,GAAG;AAChD,iBAAO;AAAA,YACL;AAAA,cACE,SACE;AAAA,cACF,MAAM;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF,GAEC,KAAK,EACL,SAAS,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAElD,cAAY,QAAQ,CAAC,EAAE,MAAM,QAAQ,MAAM;AACzC,WAAO,KAAK,GAAG,IAAI,KAAK,OAAO,EAAE;AAAA,EACnC,CAAC;AAED,SAAO;AAAA,IACL,IAAI,YAAY,WAAW;AAAA,IAC3B,SAAS;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,OACpC,OACA,WACgC;AAChC,MAAI;AACF,WAAO,MAAM,oBAAoB,MAAM;AAAA,EACzC,SAAS,KAAK;AACZ,WAAO,KAAK,kCAAkC;AAC9C,WAAO,OAAO,QAAQ,GAAG,CAAC;AAE1B,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { pathExists } from "../../../utils/fs.js";
|
|
4
3
|
import { getConsumerManifest } from "../../../utils/manifest.js";
|
|
5
4
|
import { detectPackageManager } from "../../../utils/packageManager.js";
|
|
6
|
-
|
|
5
|
+
const noSkubaTemplateJs = async (_mode, logger) => {
|
|
7
6
|
const [manifest, packageManager] = await Promise.all([
|
|
8
7
|
getConsumerManifest(),
|
|
9
8
|
detectPackageManager()
|
|
@@ -36,4 +35,7 @@ export const noSkubaTemplateJs = async (_mode, logger) => {
|
|
|
36
35
|
}
|
|
37
36
|
return { ok: true, fixable: false };
|
|
38
37
|
};
|
|
38
|
+
export {
|
|
39
|
+
noSkubaTemplateJs
|
|
40
|
+
};
|
|
39
41
|
//# sourceMappingURL=noSkubaTemplateJs.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/lint/internalLints/noSkubaTemplateJs.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\n\nimport { pathExists } from '../../../utils/fs.js';\nimport type { Logger } from '../../../utils/logging.js';\nimport { getConsumerManifest } from '../../../utils/manifest.js';\nimport { detectPackageManager } from '../../../utils/packageManager.js';\nimport type { InternalLintResult } from '../internal.js';\n\nexport const noSkubaTemplateJs = async (\n _mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n const [manifest, packageManager] = await Promise.all([\n getConsumerManifest(),\n detectPackageManager(),\n ]);\n\n if (!manifest) {\n // This will throw elsewhere\n return { ok: true, fixable: false };\n }\n\n const templateConfigPath = path.join(\n path.dirname(manifest.path),\n 'skuba.template.js',\n );\n\n if (await pathExists(templateConfigPath)) {\n logger.err(\n `Template is incomplete; run ${logger.bold(\n packageManager.print.exec,\n 'skuba',\n 'configure',\n )}. ${logger.dim('no-skuba-template-js')}`,\n );\n\n return {\n ok: false,\n fixable: false,\n annotations: [\n {\n path: 'skuba.template.js',\n message: `Template is incomplete; run ${packageManager.print.exec} skuba configure.`,\n },\n ],\n };\n }\n\n return { ok: true, fixable: false };\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,SAAS,kBAAkB;AAE3B,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AAG9B,MAAM,oBAAoB,OAC/B,OACA,WACgC;AAChC,QAAM,CAAC,UAAU,cAAc,IAAI,MAAM,QAAQ,IAAI;AAAA,IACnD,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,EACvB,CAAC;AAED,MAAI,CAAC,UAAU;AAEb,WAAO,EAAE,IAAI,MAAM,SAAS,MAAM;AAAA,EACpC;AAEA,QAAM,qBAAqB,KAAK;AAAA,IAC9B,KAAK,QAAQ,SAAS,IAAI;AAAA,IAC1B;AAAA,EACF;AAEA,MAAI,MAAM,WAAW,kBAAkB,GAAG;AACxC,WAAO;AAAA,MACL,+BAA+B,OAAO;AAAA,QACpC,eAAe,MAAM;AAAA,QACrB;AAAA,QACA;AAAA,MACF,CAAC,KAAK,OAAO,IAAI,sBAAsB,CAAC;AAAA,IAC1C;AAEA,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,QACX;AAAA,UACE,MAAM;AAAA,UACN,SAAS,+BAA+B,eAAe,MAAM,IAAI;AAAA,QACnE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,IAAI,MAAM,SAAS,MAAM;AACpC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { inspect } from "util";
|
|
4
3
|
import fs from "fs-extra";
|
|
@@ -97,7 +96,7 @@ const patchRenovateConfig = async (mode, dir) => {
|
|
|
97
96
|
});
|
|
98
97
|
return { result: "apply" };
|
|
99
98
|
};
|
|
100
|
-
|
|
99
|
+
const tryPatchRenovateConfig = (async ({
|
|
101
100
|
mode,
|
|
102
101
|
dir = process.cwd()
|
|
103
102
|
}) => {
|
|
@@ -113,4 +112,7 @@ export const tryPatchRenovateConfig = (async ({
|
|
|
113
112
|
return { result: "skip", reason: "due to an error" };
|
|
114
113
|
}
|
|
115
114
|
});
|
|
115
|
+
export {
|
|
116
|
+
tryPatchRenovateConfig
|
|
117
|
+
};
|
|
116
118
|
//# sourceMappingURL=patchRenovateConfig.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/lint/internalLints/patchRenovateConfig.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\nimport * as fleece from 'golden-fleece';\nimport * as z from 'zod/v4';\n\nimport { log } from '../../../utils/logging.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\nimport { RENOVATE_CONFIG_FILENAMES } from '../../configure/modules/renovate.js';\nimport { formatPrettier } from '../../configure/processing/prettier.js';\n\nimport type { PatchFunction, PatchReturnType } from './upgrade/index.js';\n\nimport * as Git from '@skuba-lib/api/git';\n\nconst EXISTING_REPO_PRESET_REGEX = /(github|local)>(seek-jobs|seekasia)\\//;\n\ntype RenovateFiletype = 'json' | 'json5';\n\ntype RenovatePreset =\n | 'local>seekasia/renovate-config'\n | 'local>seek-jobs/renovate-config';\n\nconst renovateConfigSchema = z.object({\n extends: z.array(z.string()),\n});\n\nconst ownerToRenovatePreset = (owner: string): RenovatePreset | undefined => {\n const lowercaseOwner = owner.toLowerCase();\n\n switch (lowercaseOwner) {\n case 'seekasia':\n return 'local>seekasia/renovate-config';\n\n case 'seek-jobs':\n return 'local>seek-jobs/renovate-config';\n\n default:\n return;\n }\n};\n\ntype PatchFile = (props: {\n filepath: string;\n input: string;\n presetToAdd: RenovatePreset;\n}) => Promise<void>;\n\nconst patchJson: PatchFile = async ({ filepath, input, presetToAdd }) => {\n const json: unknown = JSON.parse(input);\n\n const config = renovateConfigSchema.safeParse(json);\n\n if (!config.success) {\n return;\n }\n\n config.data.extends.unshift(presetToAdd);\n\n await fs.promises.writeFile(\n filepath,\n await formatPrettier(JSON.stringify(config.data), { parser: 'json' }),\n );\n\n return;\n};\n\nconst patchJson5: PatchFile = async ({ filepath, input, presetToAdd }) => {\n const json: unknown = fleece.evaluate(input);\n\n const config = renovateConfigSchema.safeParse(json);\n\n if (!config.success) {\n return;\n }\n\n config.data.extends.unshift(presetToAdd);\n\n await fs.promises.writeFile(\n filepath,\n await formatPrettier(fleece.patch(input, config.data), { parser: 'json5' }),\n );\n\n return;\n};\n\nconst patchByFiletype: Record<RenovateFiletype, PatchFile> = {\n json: patchJson,\n json5: patchJson5,\n};\n\nconst patchRenovateConfig = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const { owner } = await Git.getOwnerAndRepo({ dir });\n\n const presetToAdd = ownerToRenovatePreset(owner);\n\n if (!presetToAdd) {\n return {\n result: 'skip',\n reason: 'owner does not map to a SEEK preset',\n };\n }\n\n const maybeConfigs = await Promise.all(\n RENOVATE_CONFIG_FILENAMES.map(async (filepath) => ({\n input: await readFile(filepath),\n filepath,\n })),\n );\n\n const config = maybeConfigs.find((maybeConfig) => Boolean(maybeConfig.input));\n if (!config?.input) {\n return { result: 'skip', reason: 'no config found' };\n }\n\n if (\n // The file appears to mention the baseline preset for the configured Git\n // owner. This is a naive check for simplicity.\n config.input.includes(presetToAdd) ||\n // Ignore any renovate configuration which already extends a SEEK-Jobs or seekasia config\n EXISTING_REPO_PRESET_REGEX.exec(config.input)\n ) {\n return {\n result: 'skip',\n reason: 'config already has a SEEK preset',\n };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const filetype: RenovateFiletype = config.filepath\n .toLowerCase()\n .endsWith('.json5')\n ? 'json5'\n : 'json';\n\n const patchFile = patchByFiletype[filetype];\n\n await patchFile({\n filepath: path.resolve(dir, config.filepath),\n input: config.input,\n presetToAdd,\n });\n\n return { result: 'apply' };\n};\n\nexport const tryPatchRenovateConfig = (async ({\n mode,\n dir = process.cwd(),\n}) => {\n try {\n // In a monorepo we may be invoked within a subdirectory, but we are working\n // with Renovate config that should be relative to the repository root.\n const gitRoot = await Git.findRoot({ dir });\n if (!gitRoot) {\n return { result: 'skip', reason: 'no Git root found' };\n }\n\n return await patchRenovateConfig(mode, gitRoot);\n } catch (err) {\n log.warn('Failed to patch Renovate config.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n}) satisfies PatchFunction;\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,eAAe;AAExB,OAAO,QAAQ;AACf,YAAY,YAAY;AACxB,YAAY,OAAO;AAEnB,SAAS,WAAW;AACpB,SAAS,mCAAmC;AAC5C,SAAS,iCAAiC;AAC1C,SAAS,sBAAsB;AAI/B,YAAY,SAAS;AAErB,MAAM,6BAA6B;AAQnC,MAAM,uB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AI,OAAO,QAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { inspect, stripVTControlCharacters as stripAnsi } from "util";
|
|
4
3
|
import fs from "fs-extra";
|
|
@@ -22,7 +21,7 @@ const OLD_IGNORE_WARNING = `# Ignore .npmrc. This is no longer managed by skuba
|
|
|
22
21
|
`;
|
|
23
22
|
const removeOldWarning = (contents) => contents.includes(OLD_IGNORE_WARNING) ? `${contents.replace(OLD_IGNORE_WARNING, "").trim()}
|
|
24
23
|
` : contents;
|
|
25
|
-
|
|
24
|
+
const REFRESHABLE_CONFIG_FILES = [
|
|
26
25
|
{
|
|
27
26
|
name: ".gitignore",
|
|
28
27
|
type: "ignore",
|
|
@@ -40,7 +39,7 @@ export const REFRESHABLE_CONFIG_FILES = [
|
|
|
40
39
|
additionalMapping: removeOldWarning
|
|
41
40
|
}
|
|
42
41
|
];
|
|
43
|
-
|
|
42
|
+
const refreshConfigFiles = async (mode, logger) => {
|
|
44
43
|
const [manifest, gitRoot, workspaceRoot, currentWorkspaceProjectRoot] = await Promise.all([
|
|
45
44
|
getDestinationManifest(),
|
|
46
45
|
Git.findRoot({ dir: process.cwd() }),
|
|
@@ -130,7 +129,7 @@ export const refreshConfigFiles = async (mode, logger) => {
|
|
|
130
129
|
)
|
|
131
130
|
};
|
|
132
131
|
};
|
|
133
|
-
|
|
132
|
+
const tryRefreshConfigFiles = async (mode, logger) => {
|
|
134
133
|
try {
|
|
135
134
|
return await refreshConfigFiles(mode, logger);
|
|
136
135
|
} catch (err) {
|
|
@@ -143,4 +142,9 @@ export const tryRefreshConfigFiles = async (mode, logger) => {
|
|
|
143
142
|
};
|
|
144
143
|
}
|
|
145
144
|
};
|
|
145
|
+
export {
|
|
146
|
+
REFRESHABLE_CONFIG_FILES,
|
|
147
|
+
refreshConfigFiles,
|
|
148
|
+
tryRefreshConfigFiles
|
|
149
|
+
};
|
|
146
150
|
//# sourceMappingURL=refreshConfigFiles.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/lint/internalLints/refreshConfigFiles.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\nimport { inspect, stripVTControlCharacters as stripAnsi } from 'util';\n\nimport fs from 'fs-extra';\n\nimport { Git } from '../../../index.js';\nimport {\n findCurrentWorkspaceProjectRoot,\n findWorkspaceRoot,\n} from '../../../utils/dir.js';\nimport type { Logger } from '../../../utils/logging.js';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../utils/packageManager.js';\nimport { readBaseTemplateFile } from '../../../utils/template.js';\nimport { getDestinationManifest } from '../../configure/analysis/package.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\nimport { mergeWithConfigFile } from '../../configure/processing/configFile.js';\nimport type { InternalLintResult } from '../internal.js';\n\ntype ConditionOptions = {\n packageManager: PackageManagerConfig;\n isInWorkspaceRoot: boolean;\n};\n\ntype RefreshableConfigFile = {\n name: string;\n type: 'ignore' | 'pnpm-workspace';\n additionalMapping?: (\n s: string,\n packageManager: PackageManagerConfig,\n ) => string;\n if?: (options: ConditionOptions) => boolean;\n};\n\nconst OLD_IGNORE_WARNING = `# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.\n# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.\n# You can use \\`skuba format\\` to generate the file or otherwise commit an empty file.\n# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.\n.npmrc\n`;\n\nconst removeOldWarning = (contents: string) =>\n contents.includes(OLD_IGNORE_WARNING)\n ? `${contents.replace(OLD_IGNORE_WARNING, '').trim()}\\n`\n : contents;\n\nexport const REFRESHABLE_CONFIG_FILES: RefreshableConfigFile[] = [\n {\n name: '.gitignore',\n type: 'ignore',\n additionalMapping: removeOldWarning,\n },\n { name: '.prettierignore', type: 'ignore' },\n {\n name: 'pnpm-workspace.yaml',\n type: 'pnpm-workspace',\n if: ({ packageManager, isInWorkspaceRoot }) =>\n isInWorkspaceRoot && packageManager.command === 'pnpm',\n },\n {\n name: '.dockerignore',\n type: 'ignore',\n additionalMapping: removeOldWarning,\n },\n];\n\nexport const refreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n) => {\n const [manifest, gitRoot, workspaceRoot, currentWorkspaceProjectRoot] =\n await Promise.all([\n getDestinationManifest(),\n Git.findRoot({ dir: process.cwd() }),\n findWorkspaceRoot(),\n findCurrentWorkspaceProjectRoot(),\n ]);\n\n const destinationRoot = path.dirname(manifest.path);\n\n const readDestinationFile = createDestinationFileReader(destinationRoot);\n\n const refreshConfigFile = async (\n {\n name: filename,\n type: fileType,\n additionalMapping = (s) => s,\n if: condition = () => true,\n }: RefreshableConfigFile,\n conditionOptions: ConditionOptions,\n ) => {\n if (!condition(conditionOptions)) {\n return { needsChange: false };\n }\n\n const maybeReadPackageJson = async (type: RefreshableConfigFile['type']) =>\n type === 'pnpm-workspace'\n ? await readDestinationFile('package.json')\n : undefined;\n\n const [inputFile, templateFile, isGitIgnored, packageJson] =\n await Promise.all([\n readDestinationFile(filename),\n readBaseTemplateFile(`_${filename}`),\n gitRoot\n ? Git.isFileGitIgnored({\n gitRoot,\n absolutePath: path.join(destinationRoot, filename),\n })\n : false,\n maybeReadPackageJson(fileType),\n ]);\n\n // If the file is gitignored and doesn't exist, don't make it\n if (inputFile === undefined && isGitIgnored) {\n return { needsChange: false };\n }\n\n const data = additionalMapping(\n inputFile\n ? mergeWithConfigFile(templateFile, fileType, packageJson)(inputFile)\n : templateFile,\n packageManager,\n );\n\n const filepath = path.join(destinationRoot, filename);\n\n if (mode === 'format') {\n if (data === inputFile) {\n return { needsChange: false };\n }\n\n await fs.writeFile(filepath, data);\n return {\n needsChange: false,\n msg: `Refreshed ${logger.bold(filename)}.`,\n filename,\n };\n }\n\n if (data !== inputFile) {\n return {\n needsChange: true,\n msg: `The ${logger.bold(\n filename,\n )} file is out of date. Run \\`${logger.bold(\n packageManager.print.exec,\n 'skuba',\n 'format',\n )}\\` to update it.`,\n filename,\n };\n }\n\n return { needsChange: false };\n };\n\n const packageManager = await detectPackageManager(destinationRoot);\n\n const results = await Promise.all(\n REFRESHABLE_CONFIG_FILES.map((conf) =>\n refreshConfigFile(conf, {\n packageManager,\n isInWorkspaceRoot: workspaceRoot === currentWorkspaceProjectRoot,\n }),\n ),\n );\n\n // Log after for reproducible test output ordering\n results.forEach((result) => {\n if (result.msg) {\n logger.warn(result.msg);\n }\n });\n\n const anyNeedChanging = results.some(({ needsChange }) => needsChange);\n\n return {\n ok: !anyNeedChanging,\n fixable: anyNeedChanging,\n annotations: results.flatMap(({ needsChange, filename, msg }) =>\n needsChange && msg\n ? [\n {\n path: filename,\n message: stripAnsi(msg),\n },\n ]\n : [],\n ),\n };\n};\n\nexport const tryRefreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n try {\n return await refreshConfigFiles(mode, logger);\n } catch (err) {\n logger.warn('Failed to refresh config files.');\n logger.subtle(inspect(err));\n\n return {\n ok: false,\n fixable: false,\n annotations: [],\n };\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,SAAS,4BAA4B,iBAAiB;AAE/D,OAAO,QAAQ;AAEf,SAAS,WAAW;AACpB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,mCAAmC;AAC5C,SAAS,2BAA2B;AAkBpC,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAO3B,MAAM,mBAAmB,CAAC,aACxB,SAAS,SAAS,k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W;AAErE,SAAO;AAAA,IACL,IAAI,CAAC;AAAA,IACL,SAAS;AAAA,IACT,aAAa,QAAQ;AAAA,MAAQ,CAAC,EAAE,aAAa,UAAU,IAAI,MACzD,eAAe,MACX;AAAA,QACE;AAAA,UACE,MAAM;AAAA,UACN,SAAS,UAAU,GAAG;AAAA,QACxB;AAAA,MACF,IACA,CAAC;AAAA,IACP;AAAA,EACF;AACF;AAEO,MAAM,wBAAwB,OACnC,MACA,WACgC;AAChC,MAAI;AACF,WAAO,MAAM,mBAAmB,MAAM,MAAM;AAAA,EAC9C,SAAS,KAAK;AACZ,WAAO,KAAK,iCAAiC;AAC7C,WAAO,OAAO,QAAQ,GAAG,CAAC;AAE1B,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import fs from "fs-extra";
|
|
4
3
|
import { gte, sort } from "semver";
|
|
@@ -33,7 +32,7 @@ const resolvePatches = async (version) => {
|
|
|
33
32
|
}
|
|
34
33
|
throw new Error(`Could not resolve patches for ${version}`);
|
|
35
34
|
};
|
|
36
|
-
|
|
35
|
+
const upgradeSkuba = async (mode, logger, additionalFlags = []) => {
|
|
37
36
|
const [currentVersion, manifest, packageManager] = await Promise.all([
|
|
38
37
|
getSkubaVersion(),
|
|
39
38
|
getConsumerManifest(),
|
|
@@ -116,4 +115,7 @@ export const upgradeSkuba = async (mode, logger, additionalFlags = []) => {
|
|
|
116
115
|
fixable: false
|
|
117
116
|
};
|
|
118
117
|
};
|
|
118
|
+
export {
|
|
119
|
+
upgradeSkuba
|
|
120
|
+
};
|
|
119
121
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/internalLints/upgrade/index.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../../utils/logging.js';\nimport { getConsumerManifest } from '../../../../utils/manifest.js';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../../utils/packageManager.js';\nimport { getSkubaVersion } from '../../../../utils/version.js';\nimport { formatPackage } from '../../../configure/processing/package.js';\nimport type { ReadResult } from '../../../configure/types.js';\nimport type { SkubaPackageJson } from '../../../init/writePackageJson.js';\nimport type { InternalLintResult } from '../../internal.js';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\n\nexport type PatchConfig = {\n mode: 'format' | 'lint';\n manifest: ReadResult;\n packageManager: PackageManagerConfig;\n dir?: string;\n};\n\nexport type PatchFunction = (config: PatchConfig) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await fs.readdir(path.join(import.meta.dirname, 'patches'), {\n withFileTypes: true,\n });\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.flatMap((patch) =>\n // Is a directory rather than a JavaScript source file\n patch.isDirectory() &&\n // Has been added since the last patch run on the project\n gte(patch.name, manifestVersion)\n ? patch.name\n : [],\n ),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n additionalFlags: string[] = [],\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest, packageManager] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n detectPackageManager(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = additionalFlags.includes('--force-apply-all-patches')\n ? '1.0.0'\n : (manifest.packageJson.skuba as SkubaPackageJson).version;\n\n // We are up to date, skip patches\n if (gte(manifestVersion, currentVersion)) {\n return { ok: true, fixable: false };\n }\n\n const patches = await getPatches(manifestVersion);\n // No patches to apply even if version out of date. Early exit to avoid unnecessary commits.\n if (patches.length === 0) {\n return { ok: true, fixable: false };\n }\n\n if (mode === 'lint') {\n const results = await Promise.all(\n patches.map(\n async ({ apply }) =>\n await apply({\n mode,\n manifest,\n packageManager,\n }),\n ),\n );\n\n // No patches are applicable. Early exit to avoid unnecessary commits.\n if (results.every(({ result }) => result === 'skip')) {\n return { ok: true, fixable: false };\n }\n\n logger.warn(\n `skuba has patches to apply. Run ${logger.bold(\n packageManager.print.exec,\n 'skuba',\n 'format',\n )} to run them.`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: [\n {\n // package.json as likely skuba version has changed\n // TODO: locate the \"skuba\": {} config in the package.json and annotate on the version property\n path: manifest.path,\n message: `skuba has patches to apply. Run ${packageManager.print.exec} skuba format to run them.`,\n },\n ],\n };\n }\n\n logger.plain('Updating skuba...');\n\n // Run these in series in case a subsequent patch relies on a previous patch\n for (const { apply, description } of patches) {\n const result = await apply({\n mode,\n manifest,\n packageManager,\n });\n logger.newline();\n if (result.result === 'skip') {\n logger.plain(\n `Patch skipped: ${description}${\n result.reason ? ` - ${result.reason}` : ''\n }`,\n );\n } else {\n logger.plain(`Patch applied: ${description}`);\n }\n }\n\n const updatedManifest = await getConsumerManifest();\n if (!updatedManifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n updatedManifest.packageJson.skuba ??= { version: currentVersion };\n updatedManifest.packageJson.skuba.version = currentVersion;\n\n const updatedPackageJson = await formatPackage(updatedManifest.packageJson);\n\n await fs.writeFile(updatedManifest.path, updatedPackageJson);\n logger.newline();\n logger.plain('skuba update complete.');\n logger.newline();\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,OAAO,QAAQ;AACf,SAAS,KAAK,YAAY;AAG1B,SAAS,2BAA2B;AACpC;AAAA,EAEE;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAuB9B,MAAM,aAAa,OAAO,oBAA8C;AACtE,QAAM,UAAU,MAAM,GAAG,QAAQ,KAAK,KAAK,YAAY,SAAS,SAAS,GAAG;AAAA,IAC1E,eAAe;AAAA,EACjB,CAAC;AAID,QAAM,oBAAoB;AAAA,IACxB,QAAQ;AAAA,MAAQ,CAAC;AAAA;AAAA,QAEf,MAAM,YAAY;AAAA,QAElB,IAAI,MAAM,MAAM,eAAe,IAC3B,MAAM,OACN,CAAC;AAAA;AAAA,IACP;AAAA,EACF;AAEA,UAAQ,MAAM,QAAQ,IAAI,kBAAkB,IAAI,cAAc,CAAC,GAAG,KAAK;AACzE;AAEA,MAAM,iBAAiB,CAAC,MAAM,IAAI;AAIlC,MAAM,iBAAiB,OAAO,YAAsC;AAClE,aAAW,aAAa,gBAAgB;AACtC,QAAI;AAEF,cAAQ,MAAM,OAAO,aAAa,OAAO,UAAU,SAAS,KAAK;AAAA,IACnE,QAAQ;AAAA,IAER;AAAA,EACF;AACA,QAAM,IAAI,MAAM,iCAAiC,OAAO,EAAE;AAC5D;AAEO,MAAM,eAAe,OAC1B,MACA,QACA,kBAA4B,CAAC,MACG;AAChC,QAAM,CAAC,gBAAgB,UAAU,cAAc,IAAI,MAAM,QAAQ,IAAI;AAAA,IACnE,gBAAgB;AAAA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ACD,WAAO,QAAQ;AACf,QAAI,OAAO,WAAW,QAAQ;AAC5B,aAAO;AAAA,QACL,kBAAkB,WAAW,GAC3B,OAAO,SAAS,MAAM,OAAO,MAAM,KAAK,EAC1C;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO,MAAM,kBAAkB,WAAW,EAAE;AAAA,IAC9C;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM,oBAAoB;AAClD,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AAEA,kBAAgB,YAAY,UAAU,EAAE,SAAS,eAAe;AAChE,kBAAgB,YAAY,MAAM,UAAU;AAE5C,QAAM,qBAAqB,MAAM,cAAc,gBAAgB,WAAW;AAE1E,QAAM,GAAG,UAAU,gBAAgB,MAAM,kBAAkB;AAC3D,SAAO,QAAQ;AACf,SAAO,MAAM,wBAAwB;AACrC,SAAO,QAAQ;AAEf,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { tryRemoveYarnIgnoreOptionalFlags } from "./removeYarnIgnoreOptionalFlags.js";
|
|
3
|
-
|
|
2
|
+
const patches = [
|
|
4
3
|
{
|
|
5
4
|
apply: tryRemoveYarnIgnoreOptionalFlags,
|
|
6
5
|
description: "Remove yarn --ignore-optional flags in Dockerfiles"
|
|
7
6
|
}
|
|
8
7
|
];
|
|
8
|
+
export {
|
|
9
|
+
patches
|
|
10
|
+
};
|
|
9
11
|
//# sourceMappingURL=index.js.map
|