skuba 14.0.0-esmify-skuba-20251105034821 → 14.0.0-hacky-hack-lang-json-20260109051908
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/eslint.js +1 -1
- package/config/jest.js +1 -0
- package/config/prettier.d.ts +4 -8
- package/config/prettier.js +2 -10
- package/jest/moduleNameMapper.js +64 -0
- package/jest/transform.js +62 -0
- package/jest/tsConfig.js +26 -0
- package/jest-preset.js +37 -0
- package/lib/api/jest/index.d.ts +15 -0
- package/lib/api/jest/index.js +59 -0
- package/lib/api/jest/index.js.map +7 -0
- package/lib/cli/adapter/eslint.js +45 -11
- package/lib/cli/adapter/eslint.js.map +3 -3
- package/lib/cli/adapter/prettier.js +67 -39
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/args.js +42 -8
- package/lib/cli/build/args.js.map +2 -2
- package/lib/cli/build/assets.d.ts +3 -2
- package/lib/cli/build/assets.js +60 -28
- package/lib/cli/build/assets.js.map +3 -3
- package/lib/cli/build/esbuild.d.ts +4 -2
- package/lib/cli/build/esbuild.js +64 -23
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/build/index.js +53 -21
- package/lib/cli/build/index.js.map +2 -2
- package/lib/cli/build/tsc.js +60 -24
- package/lib/cli/build/tsc.js.map +3 -3
- package/lib/cli/buildPackage/index.js +32 -8
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/analyseConfiguration.js +50 -16
- package/lib/cli/configure/analyseConfiguration.js.map +2 -2
- package/lib/cli/configure/analyseDependencies.d.ts +1 -1
- package/lib/cli/configure/analyseDependencies.js +59 -25
- package/lib/cli/configure/analyseDependencies.js.map +3 -3
- package/lib/cli/configure/analysis/diff.js +29 -5
- package/lib/cli/configure/analysis/diff.js.map +2 -2
- package/lib/cli/configure/analysis/files.js +42 -8
- package/lib/cli/configure/analysis/files.js.map +2 -2
- package/lib/cli/configure/analysis/git.js +46 -12
- package/lib/cli/configure/analysis/git.js.map +2 -2
- package/lib/cli/configure/analysis/package.d.ts +3 -2
- package/lib/cli/configure/analysis/package.js +45 -10
- package/lib/cli/configure/analysis/package.js.map +3 -3
- package/lib/cli/configure/analysis/project.js +50 -18
- package/lib/cli/configure/analysis/project.js.map +2 -2
- package/lib/cli/configure/dependencies/index.js +35 -7
- package/lib/cli/configure/dependencies/index.js.map +1 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +28 -4
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
- package/lib/cli/configure/dependencies/seekKoala.js +28 -4
- package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
- package/lib/cli/configure/dependencies/skuba.js +28 -4
- package/lib/cli/configure/dependencies/skuba.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +26 -2
- package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDive.js +29 -4
- package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +63 -32
- package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
- package/lib/cli/configure/getEntryPoint.d.ts +2 -2
- package/lib/cli/configure/getEntryPoint.js +51 -19
- package/lib/cli/configure/getEntryPoint.js.map +3 -3
- package/lib/cli/configure/getProjectType.d.ts +1 -1
- package/lib/cli/configure/getProjectType.js +36 -17
- package/lib/cli/configure/getProjectType.js.map +2 -2
- package/lib/cli/configure/index.js +91 -56
- package/lib/cli/configure/index.js.map +3 -3
- package/lib/cli/configure/modules/eslint.js +34 -10
- package/lib/cli/configure/modules/eslint.js.map +1 -1
- package/lib/cli/configure/modules/ignore.js +32 -8
- package/lib/cli/configure/modules/ignore.js.map +1 -1
- package/lib/cli/configure/modules/index.js +44 -18
- package/lib/cli/configure/modules/index.js.map +2 -2
- package/lib/cli/configure/modules/jest.d.ts +2 -0
- package/lib/cli/configure/modules/jest.js +86 -0
- package/lib/cli/configure/modules/jest.js.map +7 -0
- package/lib/cli/configure/modules/nodemon.js +28 -4
- package/lib/cli/configure/modules/nodemon.js.map +1 -1
- package/lib/cli/configure/modules/package.js +34 -10
- package/lib/cli/configure/modules/package.js.map +1 -1
- package/lib/cli/configure/modules/prettier.js +35 -11
- package/lib/cli/configure/modules/prettier.js.map +1 -1
- package/lib/cli/configure/modules/renovate.js +40 -17
- package/lib/cli/configure/modules/renovate.js.map +2 -2
- package/lib/cli/configure/modules/serverless.js +26 -2
- package/lib/cli/configure/modules/serverless.js.map +1 -1
- package/lib/cli/configure/modules/tslint.js +28 -4
- package/lib/cli/configure/modules/tslint.js.map +1 -1
- package/lib/cli/configure/processing/configFile.js +39 -3
- package/lib/cli/configure/processing/configFile.js.map +1 -1
- package/lib/cli/configure/processing/deleteFiles.js +26 -2
- package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js +27 -2
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.js +31 -6
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/loadFiles.js +26 -2
- package/lib/cli/configure/processing/loadFiles.js.map +1 -1
- package/lib/cli/configure/processing/module.js +28 -4
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.d.ts +67 -1
- package/lib/cli/configure/processing/package.js +45 -8
- package/lib/cli/configure/processing/package.js.map +3 -3
- package/lib/cli/configure/processing/prettier.js +38 -4
- package/lib/cli/configure/processing/prettier.js.map +2 -2
- package/lib/cli/configure/processing/record.js +41 -5
- package/lib/cli/configure/processing/record.js.map +2 -2
- package/lib/cli/configure/processing/typescript.js +63 -26
- package/lib/cli/configure/processing/typescript.js.map +2 -2
- package/lib/cli/configure/types.d.ts +4 -15
- package/lib/cli/configure/types.js +16 -0
- package/lib/cli/configure/types.js.map +3 -3
- package/lib/cli/format/index.js +44 -20
- package/lib/cli/format/index.js.map +2 -2
- package/lib/cli/help/index.js +30 -6
- package/lib/cli/help/index.js.map +1 -1
- package/lib/cli/init/getConfig.d.ts +2 -2
- package/lib/cli/init/getConfig.js +121 -102
- package/lib/cli/init/getConfig.js.map +3 -3
- package/lib/cli/init/git.js +51 -16
- package/lib/cli/init/git.js.map +2 -2
- package/lib/cli/init/index.js +98 -67
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/init/prompts.d.ts +13 -10
- package/lib/cli/init/prompts.js +56 -35
- package/lib/cli/init/prompts.js.map +2 -2
- package/lib/cli/init/types.d.ts +1 -1
- package/lib/cli/init/types.js +41 -7
- package/lib/cli/init/types.js.map +1 -1
- package/lib/cli/init/validation.js +30 -2
- package/lib/cli/init/validation.js.map +1 -1
- package/lib/cli/init/writePackageJson.js +42 -8
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/eslint.js +37 -3
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js +45 -11
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js +37 -3
- package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +37 -3
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +37 -3
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/github/eslint.js +26 -2
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js +45 -11
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/internal.js +26 -2
- package/lib/cli/lint/annotate/github/internal.js.map +1 -1
- package/lib/cli/lint/annotate/github/prettier.js +26 -2
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +28 -4
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/annotate/index.js +30 -6
- package/lib/cli/lint/annotate/index.js.map +1 -1
- package/lib/cli/lint/autofix.d.ts +5 -0
- package/lib/cli/lint/autofix.js +80 -40
- package/lib/cli/lint/autofix.js.map +2 -2
- package/lib/cli/lint/eslint.js +51 -16
- package/lib/cli/lint/eslint.js.map +3 -3
- package/lib/cli/lint/external.js +51 -19
- package/lib/cli/lint/external.js.map +2 -2
- package/lib/cli/lint/index.js +50 -28
- package/lib/cli/lint/index.js.map +2 -2
- package/lib/cli/lint/internal.js +44 -18
- package/lib/cli/lint/internal.js.map +2 -2
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +33 -8
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +46 -14
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +3 -3
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +55 -21
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +64 -35
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/index.d.ts +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.js +105 -41
- package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +28 -4
- 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 +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +30 -6
- 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 +65 -34
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +28 -4
- 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 +59 -23
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +28 -4
- 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 +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +30 -6
- 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 +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +28 -4
- 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 +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +67 -29
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +34 -10
- 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 +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +63 -17
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +50 -15
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js +40 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.d.ts +3 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.js +149 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/upgradeNode.js +55 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/upgradeNode.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +51 -17
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +34 -10
- 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 +44 -10
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +46 -12
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +28 -4
- 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 +49 -15
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +34 -10
- 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 +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +47 -13
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +28 -4
- 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 +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +2 -2
- package/lib/cli/lint/prettier.js +50 -15
- package/lib/cli/lint/prettier.js.map +3 -3
- package/lib/cli/lint/tsc.js +28 -4
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/lint/types.js +16 -0
- package/lib/cli/lint/types.js.map +3 -3
- package/lib/cli/migrate/index.d.ts +5 -0
- package/lib/cli/migrate/index.js +79 -15
- package/lib/cli/migrate/index.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/checks.d.ts +1 -14
- package/lib/cli/migrate/nodeVersion/checks.js +51 -120
- package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/index.d.ts +8 -2
- package/lib/cli/migrate/nodeVersion/index.js +239 -65
- package/lib/cli/migrate/nodeVersion/index.js.map +3 -3
- package/lib/cli/migrate/nodeVersion/upgrade.d.ts +8 -0
- package/lib/cli/migrate/nodeVersion/upgrade.js +179 -0
- package/lib/cli/migrate/nodeVersion/upgrade.js.map +7 -0
- package/lib/cli/node/index.js +57 -20
- package/lib/cli/node/index.js.map +3 -3
- package/lib/cli/release/index.js +28 -4
- package/lib/cli/release/index.js.map +1 -1
- package/lib/cli/start/index.js +50 -16
- package/lib/cli/start/index.js.map +3 -3
- package/lib/cli/test/index.js +44 -4
- package/lib/cli/test/index.js.map +2 -2
- package/lib/cli/test/reporters/github/annotations.d.ts +9 -0
- package/lib/cli/test/reporters/github/annotations.js +102 -0
- package/lib/cli/test/reporters/github/annotations.js.map +7 -0
- package/lib/cli/test/reporters/github/index.d.ts +5 -0
- package/lib/cli/test/reporters/github/index.js +74 -0
- package/lib/cli/test/reporters/github/index.js.map +7 -0
- package/lib/cli/version/index.js +30 -6
- package/lib/cli/version/index.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +46 -6
- package/lib/index.js.map +2 -2
- package/lib/skuba.js +45 -26
- package/lib/skuba.js.map +3 -3
- package/lib/utils/args.js +43 -6
- package/lib/utils/args.js.map +2 -2
- package/lib/utils/command.js +42 -4
- package/lib/utils/command.js.map +3 -3
- package/lib/utils/copy.js +57 -20
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/dir.js +72 -32
- package/lib/utils/dir.js.map +2 -2
- package/lib/utils/env.js +26 -2
- package/lib/utils/env.js.map +1 -1
- package/lib/utils/error.js +47 -10
- package/lib/utils/error.js.map +1 -1
- package/lib/utils/exec.d.ts +3 -2
- package/lib/utils/exec.js +62 -24
- package/lib/utils/exec.js.map +3 -3
- package/lib/utils/fs.js +40 -6
- package/lib/utils/fs.js.map +2 -2
- package/lib/utils/help.js +30 -6
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/logging.d.ts +9 -10
- package/lib/utils/logging.js +38 -11
- package/lib/utils/logging.js.map +2 -2
- package/lib/utils/logo.js +52 -25
- package/lib/utils/logo.js.map +2 -2
- package/lib/utils/manifest.d.ts +2 -3
- package/lib/utils/manifest.js +48 -8
- package/lib/utils/manifest.js.map +3 -3
- package/lib/utils/npmrc.js +26 -2
- package/lib/utils/npmrc.js.map +1 -1
- package/lib/utils/packageManager.js +49 -12
- package/lib/utils/packageManager.js.map +2 -2
- package/lib/utils/port.js +39 -4
- package/lib/utils/port.js.map +2 -2
- package/lib/utils/sleep.js +26 -2
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/template.js +55 -18
- package/lib/utils/template.js.map +3 -3
- package/lib/utils/validation.js +31 -2
- package/lib/utils/validation.js.map +1 -1
- package/lib/utils/version.js +46 -9
- package/lib/utils/version.js.map +2 -2
- package/lib/utils/wait.js +32 -7
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.d.ts +3 -3
- package/lib/utils/worker.js +35 -10
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/function-arguments.d.js +1 -0
- package/lib/wrapper/functionHandler.js +49 -18
- package/lib/wrapper/functionHandler.js.map +2 -2
- package/lib/wrapper/http.js +43 -8
- package/lib/wrapper/http.js.map +2 -2
- package/lib/wrapper/index.js +7 -6
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js +42 -8
- package/lib/wrapper/main.js.map +3 -3
- package/lib/wrapper/requestListener.js +47 -13
- package/lib/wrapper/requestListener.js.map +2 -2
- package/lib/wrapper/server.js +28 -4
- package/lib/wrapper/server.js.map +2 -2
- package/package.json +44 -45
- package/template/base/_.prettierrc.js +1 -1
- package/template/base/_eslint.config.js +1 -1
- package/template/base/_pnpm-workspace.yaml +4 -3
- package/template/base/jest.config.ts +19 -0
- package/template/base/jest.setup.ts +3 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/.nvmrc +1 -1
- package/template/express-rest-api/package.json +8 -9
- package/template/express-rest-api/skuba.template.js +1 -1
- package/template/express-rest-api/src/app.test.ts +0 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/.nvmrc +1 -1
- package/template/greeter/package.json +4 -5
- package/template/greeter/skuba.template.js +1 -1
- package/template/greeter/src/app.test.ts +1 -3
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/.nvmrc +1 -1
- package/template/koa-rest-api/package.json +9 -11
- package/template/koa-rest-api/skuba.template.js +1 -1
- package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +0 -2
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +0 -2
- package/template/koa-rest-api/src/app.test.ts +0 -2
- package/template/koa-rest-api/src/framework/server.test.ts +2 -2
- package/template/koa-rest-api/src/framework/validation.test.ts +0 -2
- package/template/koa-rest-api/src/testing/metrics.ts +0 -2
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +7 -21
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +9 -11
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -3
- package/template/lambda-sqs-worker-cdk/infra/config.ts +2 -4
- package/template/lambda-sqs-worker-cdk/package.json +9 -9
- package/template/lambda-sqs-worker-cdk/skuba.template.js +13 -1
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +13 -22
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +0 -1
- package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +31 -33
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +2 -8
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +2 -3
- package/template/lambda-sqs-worker-cdk/src/testing/services.ts +3 -4
- package/template/oss-npm-package/.github/workflows/release.yml +1 -1
- package/template/oss-npm-package/.github/workflows/validate.yml +1 -1
- package/template/oss-npm-package/.nvmrc +1 -1
- package/template/oss-npm-package/_package.json +0 -1
- package/template/oss-npm-package/skuba.template.js +1 -1
- package/template/oss-npm-package/src/index.test.ts +0 -2
- package/template/private-npm-package/.nvmrc +1 -1
- package/template/private-npm-package/_package.json +1 -2
- package/template/private-npm-package/skuba.template.js +2 -2
- package/template/private-npm-package/src/index.test.ts +0 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +0 -11
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +0 -34
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +0 -7
- package/lib/enquirer.d.js +0 -1
- package/lib/enquirer.d.js.map +0 -7
- package/lib/eslint.d.js +0 -1
- package/lib/eslint.d.js.map +0 -7
- package/template/base/vitest.config.ts +0 -25
- /package/lib/cli/lint/internalLints/upgrade/patches/{9.1.0 → 13.1.1}/index.d.ts +0 -0
- /package/lib/cli/lint/internalLints/upgrade/patches/{9.1.0 → 13.1.1}/upgradeNode.d.ts +0 -0
|
@@ -1,88 +1,235 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var nodeVersion_exports = {};
|
|
30
|
+
__export(nodeVersion_exports, {
|
|
31
|
+
nodeVersionMigration: () => nodeVersionMigration
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(nodeVersion_exports);
|
|
34
|
+
var import_util = require("util");
|
|
35
|
+
var import_fast_glob = require("fast-glob");
|
|
36
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
+
var import_semver = require("semver");
|
|
38
|
+
var import_logging = require("../../../utils/logging.js");
|
|
39
|
+
var import_project = require("../../configure/analysis/project.js");
|
|
40
|
+
var import_checks = require("./checks.js");
|
|
41
|
+
var import_upgrade = require("./upgrade.js");
|
|
11
42
|
const subPatches = ({
|
|
12
43
|
nodeVersion,
|
|
13
|
-
ECMAScriptVersion
|
|
44
|
+
ECMAScriptVersion,
|
|
45
|
+
packageECMAScriptVersion,
|
|
46
|
+
packageNodeVersion
|
|
14
47
|
}) => [
|
|
15
|
-
{ file: ".nvmrc", replace: `${nodeVersion}
|
|
16
|
-
` },
|
|
17
48
|
{
|
|
49
|
+
type: "nodejs",
|
|
50
|
+
file: ".nvmrc",
|
|
51
|
+
regex: () => /.*([0-9.]+).*/gm,
|
|
52
|
+
replace: {
|
|
53
|
+
default: {
|
|
54
|
+
captureGroup: 1,
|
|
55
|
+
string: nodeVersion,
|
|
56
|
+
version: nodeVersion
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: "nodejs",
|
|
18
62
|
files: "**/Dockerfile*",
|
|
19
63
|
regex: () => /^FROM(.*) (public.ecr.aws\/docker\/library\/)?node:([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?)(-[a-z0-9]+)?(@sha256:[a-f0-9]{64})?( .*)?$/gm,
|
|
20
|
-
replace:
|
|
64
|
+
replace: {
|
|
65
|
+
default: {
|
|
66
|
+
captureGroup: 3,
|
|
67
|
+
string: `FROM$1 $2node:${nodeVersion}$4$6`,
|
|
68
|
+
version: nodeVersion
|
|
69
|
+
}
|
|
70
|
+
}
|
|
21
71
|
},
|
|
22
72
|
{
|
|
73
|
+
type: "nodejs",
|
|
23
74
|
files: "**/Dockerfile*",
|
|
24
|
-
regex: () => /^FROM(.*) gcr.io\/distroless\/nodejs\d
|
|
25
|
-
replace:
|
|
75
|
+
regex: () => /^FROM(.*) gcr.io\/distroless\/nodejs(\d+)-debian(\d+)(@sha256:[a-f0-9]{64})?(\.[^- \n]+)?(-[^ \n]+)?( .+|)$/gm,
|
|
76
|
+
replace: {
|
|
77
|
+
default: {
|
|
78
|
+
captureGroup: 2,
|
|
79
|
+
string: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$3$6$7`,
|
|
80
|
+
version: nodeVersion
|
|
81
|
+
}
|
|
82
|
+
}
|
|
26
83
|
},
|
|
27
84
|
{
|
|
85
|
+
type: "nodejs",
|
|
28
86
|
files: "**/serverless*.y*ml",
|
|
29
|
-
regex: () => /\bnodejs\d
|
|
30
|
-
|
|
31
|
-
|
|
87
|
+
regex: () => /\bnodejs(\d+).x\b/gm,
|
|
88
|
+
replace: {
|
|
89
|
+
default: {
|
|
90
|
+
captureGroup: 1,
|
|
91
|
+
string: `nodejs${nodeVersion}.x`,
|
|
92
|
+
version: nodeVersion
|
|
93
|
+
}
|
|
94
|
+
}
|
|
32
95
|
},
|
|
33
96
|
{
|
|
97
|
+
type: "nodejs",
|
|
34
98
|
files: "**/serverless*.y*ml",
|
|
35
|
-
regex: () => /\bnode\d
|
|
36
|
-
|
|
37
|
-
|
|
99
|
+
regex: () => /\bnode(\d+)\b/gm,
|
|
100
|
+
replace: {
|
|
101
|
+
default: {
|
|
102
|
+
captureGroup: 1,
|
|
103
|
+
string: `node${nodeVersion}`,
|
|
104
|
+
version: nodeVersion
|
|
105
|
+
}
|
|
106
|
+
}
|
|
38
107
|
},
|
|
39
108
|
{
|
|
109
|
+
type: "nodejs",
|
|
40
110
|
files: "**/infra/**/*.ts",
|
|
41
|
-
regex: () => /NODEJS_\d+_X/g,
|
|
42
|
-
replace:
|
|
111
|
+
regex: () => /NODEJS_(\d+)_X/g,
|
|
112
|
+
replace: {
|
|
113
|
+
default: {
|
|
114
|
+
captureGroup: 1,
|
|
115
|
+
string: `NODEJS_${nodeVersion}_X`,
|
|
116
|
+
version: nodeVersion
|
|
117
|
+
}
|
|
118
|
+
}
|
|
43
119
|
},
|
|
44
120
|
{
|
|
121
|
+
type: "nodejs",
|
|
45
122
|
files: "**/infra/**/*.ts",
|
|
46
123
|
regex: () => /(target:\s*'node)(\d+)(.+)$/gm,
|
|
47
|
-
replace:
|
|
124
|
+
replace: {
|
|
125
|
+
default: {
|
|
126
|
+
captureGroup: 2,
|
|
127
|
+
string: `$1${nodeVersion}$3`,
|
|
128
|
+
version: nodeVersion
|
|
129
|
+
}
|
|
130
|
+
}
|
|
48
131
|
},
|
|
49
132
|
{
|
|
133
|
+
type: "nodejs",
|
|
50
134
|
files: "**/.buildkite/*",
|
|
51
|
-
regex: () => /(image: )(public.ecr.aws\/docker\/library\/)?(node:)[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?$/gm,
|
|
52
|
-
replace:
|
|
135
|
+
regex: () => /(image: )(public.ecr.aws\/docker\/library\/)?(node:)([0-9.]+)(\.[^- \n]+)?(-[^ \n]+)?$/gm,
|
|
136
|
+
replace: {
|
|
137
|
+
default: {
|
|
138
|
+
captureGroup: 4,
|
|
139
|
+
string: `$1$2$3${nodeVersion}$5$6`,
|
|
140
|
+
version: nodeVersion
|
|
141
|
+
}
|
|
142
|
+
}
|
|
53
143
|
},
|
|
54
144
|
{
|
|
145
|
+
type: "nodejs",
|
|
55
146
|
files: ".node-version*",
|
|
56
147
|
regex: () => /(\d+(?:\.\d+)*)/g,
|
|
57
|
-
replace:
|
|
148
|
+
replace: {
|
|
149
|
+
default: {
|
|
150
|
+
captureGroup: 1,
|
|
151
|
+
string: `${nodeVersion}`,
|
|
152
|
+
version: nodeVersion
|
|
153
|
+
}
|
|
154
|
+
}
|
|
58
155
|
},
|
|
59
156
|
{
|
|
157
|
+
type: "nodejs",
|
|
60
158
|
files: "**/package.json",
|
|
61
159
|
regex: () => /(["']engines["']:\s*{[\s\S]*?["']node["']:\s*["']>=)(\d+(?:\.\d+)*)(['"]\s*})/gm,
|
|
62
|
-
|
|
63
|
-
|
|
160
|
+
replace: {
|
|
161
|
+
package: {
|
|
162
|
+
string: `$1${packageNodeVersion}$3`,
|
|
163
|
+
version: packageNodeVersion,
|
|
164
|
+
captureGroup: 2
|
|
165
|
+
},
|
|
166
|
+
default: {
|
|
167
|
+
string: `$1${nodeVersion}$3`,
|
|
168
|
+
version: nodeVersion,
|
|
169
|
+
captureGroup: 2
|
|
170
|
+
}
|
|
171
|
+
}
|
|
64
172
|
},
|
|
65
173
|
{
|
|
174
|
+
type: "nodejs",
|
|
175
|
+
files: "**/docker-compose*.y*ml",
|
|
176
|
+
regex: () => /(image: )(public.ecr.aws\/docker\/library\/)?(node:)([0-9.]+)(\.[^- \n]+)?(-[^ \n]+)?$/gm,
|
|
177
|
+
replace: {
|
|
178
|
+
default: {
|
|
179
|
+
captureGroup: 4,
|
|
180
|
+
string: `$1$2$3${nodeVersion}$5$6`,
|
|
181
|
+
version: nodeVersion
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: "ecmascript",
|
|
66
187
|
files: "**/tsconfig*.json",
|
|
67
188
|
regex: () => /("target":\s*")(ES\d+)"/gim,
|
|
68
|
-
|
|
69
|
-
|
|
189
|
+
replace: {
|
|
190
|
+
package: {
|
|
191
|
+
string: `$1${packageECMAScriptVersion}"`,
|
|
192
|
+
version: packageECMAScriptVersion,
|
|
193
|
+
captureGroup: 2
|
|
194
|
+
},
|
|
195
|
+
default: {
|
|
196
|
+
string: `$1${ECMAScriptVersion}"`,
|
|
197
|
+
version: ECMAScriptVersion,
|
|
198
|
+
captureGroup: 2
|
|
199
|
+
}
|
|
200
|
+
}
|
|
70
201
|
},
|
|
71
202
|
{
|
|
203
|
+
type: "ecmascript",
|
|
72
204
|
files: "**/tsconfig*.json",
|
|
73
205
|
regex: () => /("lib":\s*\[)([\S\s]*?)(ES\d+)([\S\s]*?)(\])/gim,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
206
|
+
replace: {
|
|
207
|
+
package: {
|
|
208
|
+
string: `$1$2${packageECMAScriptVersion}$4$5`,
|
|
209
|
+
version: packageECMAScriptVersion,
|
|
210
|
+
captureGroup: 3
|
|
211
|
+
},
|
|
212
|
+
default: {
|
|
213
|
+
string: `$1$2${ECMAScriptVersion}$4$5`,
|
|
214
|
+
version: ECMAScriptVersion,
|
|
215
|
+
captureGroup: 3
|
|
216
|
+
}
|
|
217
|
+
}
|
|
81
218
|
}
|
|
82
219
|
];
|
|
220
|
+
const getTemplatedReplace = async (path, replace) => {
|
|
221
|
+
if (!replace.package) {
|
|
222
|
+
return replace.default;
|
|
223
|
+
}
|
|
224
|
+
const isPackage = await (0, import_checks.isLikelyPackage)(path);
|
|
225
|
+
if (isPackage) {
|
|
226
|
+
return replace.package;
|
|
227
|
+
}
|
|
228
|
+
return replace.default;
|
|
229
|
+
};
|
|
83
230
|
const runSubPatch = async (dir, patch) => {
|
|
84
|
-
const readFile = createDestinationFileReader(dir);
|
|
85
|
-
const paths = patch.file ? [patch.file] : await glob(patch.files ?? [], {
|
|
231
|
+
const readFile = (0, import_project.createDestinationFileReader)(dir);
|
|
232
|
+
const paths = patch.file ? [patch.file] : await (0, import_fast_glob.glob)(patch.files ?? [], {
|
|
86
233
|
cwd: dir,
|
|
87
234
|
ignore: ["**/node_modules/**"]
|
|
88
235
|
});
|
|
@@ -92,35 +239,48 @@ const runSubPatch = async (dir, patch) => {
|
|
|
92
239
|
if (!contents) {
|
|
93
240
|
return;
|
|
94
241
|
}
|
|
95
|
-
|
|
242
|
+
const regexResult = patch.regex().exec(contents);
|
|
243
|
+
if (!regexResult) {
|
|
96
244
|
return;
|
|
97
245
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
246
|
+
const templateReplace = await getTemplatedReplace(path, patch.replace);
|
|
247
|
+
if (!lessThan(
|
|
248
|
+
regexResult[templateReplace.captureGroup],
|
|
249
|
+
templateReplace.version
|
|
250
|
+
)) {
|
|
251
|
+
return;
|
|
105
252
|
}
|
|
106
253
|
await writePatchedContents({
|
|
107
254
|
path,
|
|
108
255
|
contents,
|
|
109
|
-
templated:
|
|
256
|
+
templated: templateReplace.string,
|
|
110
257
|
regex: patch.regex
|
|
111
258
|
});
|
|
112
259
|
})
|
|
113
260
|
);
|
|
114
261
|
};
|
|
262
|
+
const lessThan = (versionA, versionB) => {
|
|
263
|
+
if (versionA.toLowerCase().startsWith("es")) {
|
|
264
|
+
return Number(versionA.slice(2)) < Number(versionB.slice(2));
|
|
265
|
+
}
|
|
266
|
+
const coersedA = (0, import_semver.coerce)(versionA);
|
|
267
|
+
const coersedB = (0, import_semver.coerce)(versionB);
|
|
268
|
+
if (!coersedA || !coersedB) {
|
|
269
|
+
throw new Error(
|
|
270
|
+
`Unable to coerce versions for comparison: "${versionA}" and "${versionB}"`
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
return (0, import_semver.lt)(coersedA, coersedB);
|
|
274
|
+
};
|
|
115
275
|
const writePatchedContents = async ({
|
|
116
276
|
path,
|
|
117
277
|
contents,
|
|
118
278
|
templated,
|
|
119
279
|
regex
|
|
120
|
-
}) =>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
280
|
+
}) => {
|
|
281
|
+
const modified = contents.replaceAll(regex(), templated);
|
|
282
|
+
await import_fs_extra.default.promises.writeFile(path, modified);
|
|
283
|
+
};
|
|
124
284
|
const upgrade = async (versions, dir) => {
|
|
125
285
|
for (const subPatch of subPatches(versions)) {
|
|
126
286
|
await runSubPatch(dir, subPatch);
|
|
@@ -128,22 +288,36 @@ const upgrade = async (versions, dir) => {
|
|
|
128
288
|
};
|
|
129
289
|
const nodeVersionMigration = async ({
|
|
130
290
|
nodeVersion,
|
|
131
|
-
ECMAScriptVersion
|
|
291
|
+
ECMAScriptVersion,
|
|
292
|
+
packageNodeVersion,
|
|
293
|
+
packageECMAScriptVersion,
|
|
294
|
+
infraPackages
|
|
132
295
|
}, dir = process.cwd()) => {
|
|
133
|
-
log.ok(
|
|
296
|
+
import_logging.log.ok(
|
|
297
|
+
`Upgrading project to Node.js ${nodeVersion} and package targets to Node.js ${packageNodeVersion}`
|
|
298
|
+
);
|
|
134
299
|
try {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
300
|
+
await (0, import_upgrade.tryUpgradeInfraPackages)("format", infraPackages);
|
|
301
|
+
await upgrade(
|
|
302
|
+
{
|
|
303
|
+
nodeVersion,
|
|
304
|
+
ECMAScriptVersion,
|
|
305
|
+
packageNodeVersion,
|
|
306
|
+
packageECMAScriptVersion
|
|
307
|
+
},
|
|
308
|
+
dir
|
|
309
|
+
);
|
|
310
|
+
import_logging.log.ok(
|
|
311
|
+
`Upgraded project to Node.js ${nodeVersion} and package targets to Node.js ${packageNodeVersion}`
|
|
312
|
+
);
|
|
140
313
|
} catch (error) {
|
|
141
|
-
log.err("Failed to upgrade");
|
|
142
|
-
log.subtle(inspect(error));
|
|
314
|
+
import_logging.log.err("Failed to upgrade");
|
|
315
|
+
import_logging.log.subtle((0, import_util.inspect)(error));
|
|
143
316
|
process.exitCode = 1;
|
|
144
317
|
}
|
|
145
318
|
};
|
|
146
|
-
export
|
|
319
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
320
|
+
0 && (module.exports = {
|
|
147
321
|
nodeVersionMigration
|
|
148
|
-
};
|
|
322
|
+
});
|
|
149
323
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/migrate/nodeVersion/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../utils/logging.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\n\nimport {
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\nimport { coerce, lt } from 'semver';\n\nimport { log } from '../../../utils/logging.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\n\nimport { isLikelyPackage } from './checks.js';\nimport { tryUpgradeInfraPackages } from './upgrade.js';\n\ntype FileSelector =\n | { files: string; file?: never }\n | { file: string; files?: never };\n\ntype ReplaceOptions = {\n version: string;\n string: string;\n captureGroup: number;\n};\n\ntype SubPatch = FileSelector & {\n type: 'nodejs' | 'ecmascript';\n regex: () => RegExp;\n replace: {\n package?: ReplaceOptions;\n default: ReplaceOptions;\n };\n};\n\nconst subPatches = ({\n nodeVersion,\n ECMAScriptVersion,\n packageECMAScriptVersion,\n packageNodeVersion,\n}: Versions): SubPatch[] => [\n {\n type: 'nodejs',\n file: '.nvmrc',\n regex: () => /.*([0-9.]+).*/gm,\n replace: {\n default: {\n captureGroup: 1,\n string: nodeVersion,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/Dockerfile*',\n\n regex: () =>\n /^FROM(.*) (public.ecr.aws\\/docker\\/library\\/)?node:([0-9]+(?:\\.[0-9]+(?:\\.[0-9]+)?)?)(-[a-z0-9]+)?(@sha256:[a-f0-9]{64})?( .*)?$/gm,\n replace: {\n default: {\n captureGroup: 3,\n string: `FROM$1 $2node:${nodeVersion}$4$6`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/Dockerfile*',\n regex: () =>\n /^FROM(.*) gcr.io\\/distroless\\/nodejs(\\d+)-debian(\\d+)(@sha256:[a-f0-9]{64})?(\\.[^- \\n]+)?(-[^ \\n]+)?( .+|)$/gm,\n replace: {\n default: {\n captureGroup: 2,\n string: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$3$6$7`,\n version: nodeVersion,\n },\n },\n },\n\n {\n type: 'nodejs',\n files: '**/serverless*.y*ml',\n regex: () => /\\bnodejs(\\d+).x\\b/gm,\n replace: {\n default: {\n captureGroup: 1,\n string: `nodejs${nodeVersion}.x`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/serverless*.y*ml',\n regex: () => /\\bnode(\\d+)\\b/gm,\n replace: {\n default: {\n captureGroup: 1,\n string: `node${nodeVersion}`,\n version: nodeVersion,\n },\n },\n },\n\n {\n type: 'nodejs',\n files: '**/infra/**/*.ts',\n regex: () => /NODEJS_(\\d+)_X/g,\n replace: {\n default: {\n captureGroup: 1,\n string: `NODEJS_${nodeVersion}_X`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/infra/**/*.ts',\n regex: () => /(target:\\s*'node)(\\d+)(.+)$/gm,\n replace: {\n default: {\n captureGroup: 2,\n string: `$1${nodeVersion}$3`,\n version: nodeVersion,\n },\n },\n },\n\n {\n type: 'nodejs',\n files: '**/.buildkite/*',\n regex: () =>\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)([0-9.]+)(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n replace: {\n default: {\n captureGroup: 4,\n string: `$1$2$3${nodeVersion}$5$6`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '.node-version*',\n regex: () => /(\\d+(?:\\.\\d+)*)/g,\n replace: {\n default: {\n captureGroup: 1,\n string: `${nodeVersion}`,\n version: nodeVersion,\n },\n },\n },\n\n {\n type: 'nodejs',\n files: '**/package.json',\n regex: () =>\n /([\"']engines[\"']:\\s*{[\\s\\S]*?[\"']node[\"']:\\s*[\"']>=)(\\d+(?:\\.\\d+)*)(['\"]\\s*})/gm,\n replace: {\n package: {\n string: `$1${packageNodeVersion}$3`,\n version: packageNodeVersion,\n captureGroup: 2,\n },\n default: {\n string: `$1${nodeVersion}$3`,\n version: nodeVersion,\n captureGroup: 2,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/docker-compose*.y*ml',\n regex: () =>\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)([0-9.]+)(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n\n replace: {\n default: {\n captureGroup: 4,\n string: `$1$2$3${nodeVersion}$5$6`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'ecmascript',\n files: '**/tsconfig*.json',\n regex: () => /(\"target\":\\s*\")(ES\\d+)\"/gim,\n replace: {\n package: {\n string: `$1${packageECMAScriptVersion}\"`,\n version: packageECMAScriptVersion,\n captureGroup: 2,\n },\n default: {\n string: `$1${ECMAScriptVersion}\"`,\n version: ECMAScriptVersion,\n captureGroup: 2,\n },\n },\n },\n {\n type: 'ecmascript',\n files: '**/tsconfig*.json',\n regex: () => /(\"lib\":\\s*\\[)([\\S\\s]*?)(ES\\d+)([\\S\\s]*?)(\\])/gim,\n replace: {\n package: {\n string: `$1$2${packageECMAScriptVersion}$4$5`,\n version: packageECMAScriptVersion,\n captureGroup: 3,\n },\n default: {\n string: `$1$2${ECMAScriptVersion}$4$5`,\n version: ECMAScriptVersion,\n captureGroup: 3,\n },\n },\n },\n];\n\ntype Versions = {\n nodeVersion: string;\n ECMAScriptVersion: string;\n packageNodeVersion: string;\n packageECMAScriptVersion: string;\n};\n\nconst getTemplatedReplace = async (\n path: string,\n replace: SubPatch['replace'],\n): Promise<ReplaceOptions> => {\n if (!replace.package) {\n return replace.default;\n }\n\n const isPackage = await isLikelyPackage(path);\n\n if (isPackage) {\n return replace.package;\n }\n\n return replace.default;\n};\n\nconst runSubPatch = async (dir: string, patch: SubPatch) => {\n const readFile = createDestinationFileReader(dir);\n const paths = patch.file\n ? [patch.file]\n : await glob(patch.files ?? [], {\n cwd: dir,\n ignore: ['**/node_modules/**'],\n });\n\n await Promise.all(\n paths.map(async (path) => {\n const contents = await readFile(path);\n if (!contents) {\n return;\n }\n\n const regexResult = patch.regex().exec(contents);\n\n if (!regexResult) {\n return;\n }\n\n const templateReplace = await getTemplatedReplace(path, patch.replace);\n\n if (\n !lessThan(\n regexResult[templateReplace.captureGroup] as string,\n templateReplace.version,\n )\n ) {\n return;\n }\n\n await writePatchedContents({\n path,\n contents,\n templated: templateReplace.string,\n regex: patch.regex,\n });\n }),\n );\n};\n\nconst lessThan = (versionA: string, versionB: string) => {\n if (versionA.toLowerCase().startsWith('es')) {\n return Number(versionA.slice(2)) < Number(versionB.slice(2));\n }\n\n const coersedA = coerce(versionA);\n const coersedB = coerce(versionB);\n\n if (!coersedA || !coersedB) {\n throw new Error(\n `Unable to coerce versions for comparison: \"${versionA}\" and \"${versionB}\"`,\n );\n }\n\n return lt(coersedA, coersedB);\n};\n\nconst writePatchedContents = async ({\n path,\n contents,\n templated,\n regex,\n}: {\n path: string;\n contents: string;\n templated: string;\n regex: () => RegExp;\n}) => {\n const modified = contents.replaceAll(regex(), templated);\n await fs.promises.writeFile(path, modified);\n};\n\nconst upgrade = async (versions: Versions, dir: string) => {\n for (const subPatch of subPatches(versions)) {\n await runSubPatch(dir, subPatch);\n }\n};\n\nexport const nodeVersionMigration = async (\n {\n nodeVersion,\n ECMAScriptVersion,\n packageNodeVersion,\n packageECMAScriptVersion,\n infraPackages,\n }: {\n nodeVersion: string;\n ECMAScriptVersion: string;\n packageNodeVersion: string;\n packageECMAScriptVersion: string;\n infraPackages: Array<{ name: string; version: string }>;\n },\n dir = process.cwd(),\n) => {\n log.ok(\n `Upgrading project to Node.js ${nodeVersion} and package targets to Node.js ${packageNodeVersion}`,\n );\n\n try {\n await tryUpgradeInfraPackages('format', infraPackages);\n await upgrade(\n {\n nodeVersion,\n ECMAScriptVersion,\n packageNodeVersion,\n packageECMAScriptVersion,\n },\n dir,\n );\n\n log.ok(\n `Upgraded project to Node.js ${nodeVersion} and package targets to Node.js ${packageNodeVersion}`,\n );\n } catch (error) {\n log.err('Failed to upgrade');\n log.subtle(inspect(error));\n process.exitCode = 1;\n }\n};\n"],
|
|
5
|
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F,GAOA,MAAM,QAAQ,IAAI,MACf;AACH,qBAAI;AAAA,IACF,gCAAgC,WAAW,mCAAmC,kBAAkB;AAAA,EAClG;AAEA,MAAI;AACF,cAAM,wCAAwB,UAAU,aAAa;AACrD,UAAM;AAAA,MACJ;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAEA,uBAAI;AAAA,MACF,+BAA+B,WAAW,mCAAmC,kBAAkB;AAAA,IACjG;AAAA,EACF,SAAS,OAAO;AACd,uBAAI,IAAI,mBAAmB;AAC3B,uBAAI,WAAO,qBAAQ,KAAK,CAAC;AACzB,YAAQ,WAAW;AAAA,EACrB;AACF;",
|
|
6
|
+
"names": ["fs"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PatchReturnType } from '../../lint/internalLints/upgrade/index.js';
|
|
2
|
+
type PackageInfo = {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const upgradeInfraPackages: (mode: "lint" | "format", packages: PackageInfo[]) => Promise<PatchReturnType>;
|
|
7
|
+
export declare const tryUpgradeInfraPackages: (mode: "lint" | "format", packages: PackageInfo[]) => Promise<PatchReturnType>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var upgrade_exports = {};
|
|
30
|
+
__export(upgrade_exports, {
|
|
31
|
+
tryUpgradeInfraPackages: () => tryUpgradeInfraPackages,
|
|
32
|
+
upgradeInfraPackages: () => upgradeInfraPackages
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(upgrade_exports);
|
|
35
|
+
var import_node_util = require("node:util");
|
|
36
|
+
var import_fast_glob = require("fast-glob");
|
|
37
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
|
+
var import_semver = require("semver");
|
|
39
|
+
var import_exec = require("../../../utils/exec.js");
|
|
40
|
+
var import_logging = require("../../../utils/logging.js");
|
|
41
|
+
var import_packageManager = require("../../../utils/packageManager.js");
|
|
42
|
+
const packageVersionRegex = (packageName) => new RegExp(`"\\b${packageName}\\b"\\s*:\\s*"([^"]+)"`, "g");
|
|
43
|
+
const yamlPackageVersionRegex = (packageName) => new RegExp(`\\b${packageName}\\b:\\s*([^\\s]+)`, "g");
|
|
44
|
+
const normalizeVersionRange = (currentVersion, newVersion) => {
|
|
45
|
+
if (currentVersion.startsWith("^")) {
|
|
46
|
+
return `^${newVersion}`;
|
|
47
|
+
}
|
|
48
|
+
if (currentVersion.startsWith("~")) {
|
|
49
|
+
return `~${newVersion}`;
|
|
50
|
+
}
|
|
51
|
+
if (currentVersion.startsWith(">=") || currentVersion.startsWith(">") || currentVersion.startsWith("<=") || currentVersion.startsWith("<")) {
|
|
52
|
+
return `^${newVersion}`;
|
|
53
|
+
}
|
|
54
|
+
if (currentVersion.includes("x") || currentVersion.includes("X")) {
|
|
55
|
+
return `^${newVersion}`;
|
|
56
|
+
}
|
|
57
|
+
if (currentVersion.includes(" - ")) {
|
|
58
|
+
return `^${newVersion}`;
|
|
59
|
+
}
|
|
60
|
+
const coercedCurrent = (0, import_semver.coerce)(currentVersion);
|
|
61
|
+
if (coercedCurrent && (0, import_semver.lt)(coercedCurrent, newVersion)) {
|
|
62
|
+
return newVersion;
|
|
63
|
+
}
|
|
64
|
+
return currentVersion;
|
|
65
|
+
};
|
|
66
|
+
const upgradeInfraPackages = async (mode, packages) => {
|
|
67
|
+
const [packageJsonPaths, pnpmWorkspacePaths] = await Promise.all([
|
|
68
|
+
(0, import_fast_glob.glob)(["**/package.json"], {
|
|
69
|
+
ignore: ["**/.git", "**/node_modules"]
|
|
70
|
+
}),
|
|
71
|
+
(0, import_fast_glob.glob)("**/pnpm-workspace.yaml", {
|
|
72
|
+
ignore: ["**/.git", "**/node_modules"]
|
|
73
|
+
})
|
|
74
|
+
]);
|
|
75
|
+
if (packageJsonPaths.length === 0 && pnpmWorkspacePaths.length === 0) {
|
|
76
|
+
return {
|
|
77
|
+
result: "skip",
|
|
78
|
+
reason: "no package.json or pnpm-workspace.yaml files found"
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const [packageJsons, pnpmWorkspaces] = await Promise.all([
|
|
82
|
+
Promise.all(
|
|
83
|
+
packageJsonPaths.map(async (file) => {
|
|
84
|
+
const contents = await import_fs_extra.default.readFile(file, "utf8");
|
|
85
|
+
return {
|
|
86
|
+
file,
|
|
87
|
+
contents
|
|
88
|
+
};
|
|
89
|
+
})
|
|
90
|
+
),
|
|
91
|
+
Promise.all(
|
|
92
|
+
pnpmWorkspacePaths.map(async (file) => {
|
|
93
|
+
const contents = await import_fs_extra.default.readFile(file, "utf8");
|
|
94
|
+
return {
|
|
95
|
+
file,
|
|
96
|
+
contents
|
|
97
|
+
};
|
|
98
|
+
})
|
|
99
|
+
)
|
|
100
|
+
]);
|
|
101
|
+
const patchedPackageJsons = packageJsons.map((file) => {
|
|
102
|
+
const updated = packages.reduce((contents, packageName) => {
|
|
103
|
+
const regex = packageVersionRegex(packageName.name);
|
|
104
|
+
return contents.replaceAll(regex, (match, currentVersion) => {
|
|
105
|
+
if (currentVersion.startsWith("*") || currentVersion.startsWith("workspace:") || currentVersion.startsWith("link:") || currentVersion.startsWith("file:") || currentVersion.startsWith("catalog:")) {
|
|
106
|
+
return match;
|
|
107
|
+
}
|
|
108
|
+
const newVersion = normalizeVersionRange(
|
|
109
|
+
currentVersion,
|
|
110
|
+
packageName.version
|
|
111
|
+
);
|
|
112
|
+
return newVersion === currentVersion ? match : `"${packageName.name}":"${newVersion}"`;
|
|
113
|
+
});
|
|
114
|
+
}, file.contents);
|
|
115
|
+
return {
|
|
116
|
+
...file,
|
|
117
|
+
updated
|
|
118
|
+
};
|
|
119
|
+
}).filter(({ contents, updated }) => contents !== updated);
|
|
120
|
+
const patchedPnpmWorkspaces = pnpmWorkspaces.map((file) => {
|
|
121
|
+
const updated = packages.reduce((contents, packageName) => {
|
|
122
|
+
const regex = yamlPackageVersionRegex(packageName.name);
|
|
123
|
+
return contents.replace(regex, (match, currentVersion) => {
|
|
124
|
+
const newVersion = normalizeVersionRange(
|
|
125
|
+
currentVersion,
|
|
126
|
+
packageName.version
|
|
127
|
+
);
|
|
128
|
+
return newVersion === currentVersion ? match : `${packageName.name}: ${newVersion}`;
|
|
129
|
+
});
|
|
130
|
+
}, file.contents);
|
|
131
|
+
return {
|
|
132
|
+
...file,
|
|
133
|
+
updated
|
|
134
|
+
};
|
|
135
|
+
}).filter(({ contents, updated }) => contents !== updated);
|
|
136
|
+
if (patchedPackageJsons.length === 0 && patchedPnpmWorkspaces.length === 0) {
|
|
137
|
+
return {
|
|
138
|
+
result: "skip",
|
|
139
|
+
reason: "no package.json or pnpm-workspace.yaml files to patch"
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (mode === "lint") {
|
|
143
|
+
return {
|
|
144
|
+
result: "apply"
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
await Promise.all(
|
|
148
|
+
[...patchedPackageJsons, ...patchedPnpmWorkspaces].map(
|
|
149
|
+
async ({ file, updated }) => {
|
|
150
|
+
await import_fs_extra.default.writeFile(file, updated, "utf8");
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
const packageManager = await (0, import_packageManager.detectPackageManager)();
|
|
155
|
+
await (0, import_exec.exec)(
|
|
156
|
+
packageManager.command,
|
|
157
|
+
"install",
|
|
158
|
+
"--frozen-lockfile=false",
|
|
159
|
+
"--prefer-offline"
|
|
160
|
+
);
|
|
161
|
+
return {
|
|
162
|
+
result: "apply"
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
const tryUpgradeInfraPackages = async (mode, packages) => {
|
|
166
|
+
try {
|
|
167
|
+
return await upgradeInfraPackages(mode, packages);
|
|
168
|
+
} catch (err) {
|
|
169
|
+
import_logging.log.err("Failed to upgrade infrastructure packages");
|
|
170
|
+
import_logging.log.subtle((0, import_node_util.inspect)(err));
|
|
171
|
+
return { result: "skip", reason: "due to an error" };
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
175
|
+
0 && (module.exports = {
|
|
176
|
+
tryUpgradeInfraPackages,
|
|
177
|
+
upgradeInfraPackages
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=upgrade.js.map
|