skuba 14.0.0-migrate-to-inquirer-20251031055743 → 14.0.0-replace-global-vars-20251117052457
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/prettier.d.ts +8 -4
- package/config/prettier.js +10 -2
- package/lib/cli/adapter/eslint.js +11 -45
- package/lib/cli/adapter/eslint.js.map +3 -3
- package/lib/cli/adapter/prettier.js +39 -67
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/args.js +8 -42
- package/lib/cli/build/args.js.map +2 -2
- package/lib/cli/build/assets.d.ts +3 -2
- package/lib/cli/build/assets.js +28 -60
- package/lib/cli/build/assets.js.map +3 -3
- package/lib/cli/build/esbuild.js +21 -45
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/build/index.js +21 -55
- package/lib/cli/build/index.js.map +3 -3
- package/lib/cli/build/tsc.js +23 -61
- package/lib/cli/build/tsc.js.map +3 -3
- package/lib/cli/buildPackage/index.js +8 -32
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/analyseConfiguration.js +16 -50
- package/lib/cli/configure/analyseConfiguration.js.map +2 -2
- package/lib/cli/configure/analyseDependencies.d.ts +1 -1
- package/lib/cli/configure/analyseDependencies.js +25 -59
- package/lib/cli/configure/analyseDependencies.js.map +3 -3
- package/lib/cli/configure/analysis/diff.js +5 -39
- package/lib/cli/configure/analysis/diff.js.map +3 -3
- package/lib/cli/configure/analysis/files.js +8 -42
- package/lib/cli/configure/analysis/files.js.map +2 -2
- package/lib/cli/configure/analysis/git.js +12 -46
- package/lib/cli/configure/analysis/git.js.map +2 -2
- package/lib/cli/configure/analysis/package.d.ts +2 -3
- package/lib/cli/configure/analysis/package.js +10 -45
- package/lib/cli/configure/analysis/package.js.map +3 -3
- package/lib/cli/configure/analysis/project.js +18 -50
- package/lib/cli/configure/analysis/project.js.map +2 -2
- package/lib/cli/configure/dependencies/index.js +7 -35
- package/lib/cli/configure/dependencies/index.js.map +1 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +4 -28
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
- package/lib/cli/configure/dependencies/seekKoala.js +4 -28
- package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
- package/lib/cli/configure/dependencies/skuba.js +4 -28
- package/lib/cli/configure/dependencies/skuba.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +2 -26
- package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDive.js +4 -29
- 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 +35 -60
- package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
- package/lib/cli/configure/getEntryPoint.d.ts +1 -1
- package/lib/cli/configure/getEntryPoint.js +14 -48
- package/lib/cli/configure/getEntryPoint.js.map +3 -3
- package/lib/cli/configure/getProjectType.d.ts +1 -1
- package/lib/cli/configure/getProjectType.js +14 -35
- package/lib/cli/configure/getProjectType.js.map +2 -2
- package/lib/cli/configure/index.js +50 -84
- package/lib/cli/configure/index.js.map +3 -3
- package/lib/cli/configure/modules/eslint.js +10 -34
- package/lib/cli/configure/modules/eslint.js.map +1 -1
- package/lib/cli/configure/modules/ignore.js +8 -32
- package/lib/cli/configure/modules/ignore.js.map +1 -1
- package/lib/cli/configure/modules/index.js +18 -44
- package/lib/cli/configure/modules/index.js.map +2 -2
- package/lib/cli/configure/modules/nodemon.js +4 -28
- package/lib/cli/configure/modules/nodemon.js.map +1 -1
- package/lib/cli/configure/modules/package.js +10 -34
- package/lib/cli/configure/modules/package.js.map +1 -1
- package/lib/cli/configure/modules/prettier.js +11 -35
- package/lib/cli/configure/modules/prettier.js.map +1 -1
- package/lib/cli/configure/modules/renovate.js +17 -40
- package/lib/cli/configure/modules/renovate.js.map +2 -2
- package/lib/cli/configure/modules/serverless.js +2 -26
- package/lib/cli/configure/modules/serverless.js.map +1 -1
- package/lib/cli/configure/modules/tslint.js +4 -28
- package/lib/cli/configure/modules/tslint.js.map +1 -1
- package/lib/cli/configure/processing/configFile.js +3 -39
- package/lib/cli/configure/processing/configFile.js.map +1 -1
- package/lib/cli/configure/processing/deleteFiles.js +2 -26
- package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js +2 -27
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.js +6 -31
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/loadFiles.js +2 -26
- package/lib/cli/configure/processing/loadFiles.js.map +1 -1
- package/lib/cli/configure/processing/module.js +4 -28
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.d.ts +1 -67
- package/lib/cli/configure/processing/package.js +8 -45
- package/lib/cli/configure/processing/package.js.map +3 -3
- package/lib/cli/configure/processing/prettier.js +4 -38
- package/lib/cli/configure/processing/prettier.js.map +2 -2
- package/lib/cli/configure/processing/record.js +5 -41
- package/lib/cli/configure/processing/record.js.map +2 -2
- package/lib/cli/configure/processing/typescript.js +26 -63
- package/lib/cli/configure/processing/typescript.js.map +2 -2
- package/lib/cli/configure/types.d.ts +15 -4
- package/lib/cli/configure/types.js +0 -16
- package/lib/cli/configure/types.js.map +3 -3
- package/lib/cli/format/index.js +20 -54
- package/lib/cli/format/index.js.map +3 -3
- package/lib/cli/help/index.js +6 -30
- package/lib/cli/help/index.js.map +1 -1
- package/lib/cli/init/getConfig.d.ts +1 -1
- package/lib/cli/init/getConfig.js +89 -118
- package/lib/cli/init/getConfig.js.map +3 -3
- package/lib/cli/init/git.js +16 -51
- package/lib/cli/init/git.js.map +2 -2
- package/lib/cli/init/index.js +67 -98
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/init/prompts.js +21 -42
- package/lib/cli/init/prompts.js.map +1 -1
- package/lib/cli/init/types.js +7 -41
- package/lib/cli/init/types.js.map +1 -1
- package/lib/cli/init/validation.js +2 -30
- package/lib/cli/init/validation.js.map +1 -1
- package/lib/cli/init/writePackageJson.js +8 -42
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/eslint.js +3 -37
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js +11 -45
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js +3 -37
- package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +3 -37
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +3 -37
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/github/eslint.js +2 -26
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js +11 -45
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/internal.js +2 -26
- package/lib/cli/lint/annotate/github/internal.js.map +1 -1
- package/lib/cli/lint/annotate/github/prettier.js +2 -26
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +4 -28
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/annotate/index.js +6 -30
- package/lib/cli/lint/annotate/index.js.map +1 -1
- package/lib/cli/lint/autofix.js +37 -73
- package/lib/cli/lint/autofix.js.map +1 -1
- package/lib/cli/lint/eslint.js +16 -51
- package/lib/cli/lint/eslint.js.map +3 -3
- package/lib/cli/lint/external.js +19 -51
- package/lib/cli/lint/external.js.map +2 -2
- package/lib/cli/lint/index.js +26 -52
- package/lib/cli/lint/index.js.map +2 -2
- package/lib/cli/lint/internal.js +20 -52
- package/lib/cli/lint/internal.js.map +3 -3
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +8 -33
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +12 -48
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +3 -3
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +21 -55
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +33 -66
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/index.d.ts +1 -1
- package/lib/cli/lint/internalLints/upgrade/index.js +23 -56
- package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +4 -28
- 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 +11 -45
- 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 +6 -30
- 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 +37 -65
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +11 -46
- 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 +4 -28
- 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 +23 -59
- 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 +4 -28
- 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 +11 -46
- 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 +6 -30
- 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 +11 -46
- 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 +11 -46
- 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 +4 -28
- 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 +11 -46
- 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 +29 -67
- 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 +10 -34
- 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 +11 -45
- 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.d.ts +4 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +18 -63
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +15 -50
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js +11 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.d.ts +5 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js +72 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +17 -51
- 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 +10 -34
- 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 +10 -44
- 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 +12 -46
- 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 +4 -28
- 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 +15 -49
- 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 +11 -45
- 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 +10 -39
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +11 -45
- 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 +11 -45
- 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 +13 -47
- 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 +4 -28
- 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 +11 -45
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +4 -28
- 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 +8 -32
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +1 -1
- package/lib/cli/lint/prettier.js +15 -50
- package/lib/cli/lint/prettier.js.map +3 -3
- package/lib/cli/lint/tsc.js +4 -28
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/lint/types.js +0 -16
- package/lib/cli/lint/types.js.map +3 -3
- package/lib/cli/migrate/index.js +10 -34
- package/lib/cli/migrate/index.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/checks.js +24 -61
- package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/index.js +25 -55
- package/lib/cli/migrate/nodeVersion/index.js.map +2 -2
- package/lib/cli/node/index.js +20 -57
- package/lib/cli/node/index.js.map +3 -3
- package/lib/cli/release/index.js +4 -28
- package/lib/cli/release/index.js.map +1 -1
- package/lib/cli/start/index.js +16 -50
- package/lib/cli/start/index.js.map +3 -3
- package/lib/cli/test/index.js +4 -44
- package/lib/cli/test/index.js.map +2 -2
- package/lib/cli/version/index.js +6 -30
- package/lib/cli/version/index.js.map +1 -1
- package/lib/eslint.d.js +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +6 -46
- package/lib/index.js.map +2 -2
- package/lib/skuba.js +26 -45
- package/lib/skuba.js.map +3 -3
- package/lib/utils/args.js +6 -43
- package/lib/utils/args.js.map +2 -2
- package/lib/utils/command.js +4 -42
- package/lib/utils/command.js.map +3 -3
- package/lib/utils/copy.js +20 -57
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/dir.js +32 -72
- package/lib/utils/dir.js.map +2 -2
- package/lib/utils/env.js +2 -26
- package/lib/utils/env.js.map +1 -1
- package/lib/utils/error.js +10 -47
- package/lib/utils/error.js.map +1 -1
- package/lib/utils/exec.d.ts +3 -2
- package/lib/utils/exec.js +24 -62
- package/lib/utils/exec.js.map +3 -3
- package/lib/utils/fs.js +6 -40
- package/lib/utils/fs.js.map +3 -3
- package/lib/utils/help.js +6 -30
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/logging.d.ts +9 -10
- package/lib/utils/logging.js +11 -48
- package/lib/utils/logging.js.map +3 -3
- package/lib/utils/logo.js +28 -59
- package/lib/utils/logo.js.map +3 -3
- package/lib/utils/manifest.d.ts +3 -2
- package/lib/utils/manifest.js +8 -48
- package/lib/utils/manifest.js.map +3 -3
- package/lib/utils/npmrc.js +2 -26
- package/lib/utils/npmrc.js.map +1 -1
- package/lib/utils/packageManager.js +12 -49
- package/lib/utils/packageManager.js.map +2 -2
- package/lib/utils/port.js +4 -39
- package/lib/utils/port.js.map +2 -2
- package/lib/utils/sleep.js +2 -26
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/template.js +18 -55
- package/lib/utils/template.js.map +3 -3
- package/lib/utils/validation.js +2 -31
- package/lib/utils/validation.js.map +1 -1
- package/lib/utils/version.js +9 -46
- package/lib/utils/version.js.map +2 -2
- package/lib/utils/wait.js +7 -32
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.d.ts +3 -3
- package/lib/utils/worker.js +10 -35
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/function-arguments.d.js +0 -1
- package/lib/wrapper/functionHandler.js +18 -49
- package/lib/wrapper/functionHandler.js.map +2 -2
- package/lib/wrapper/http.d.ts +0 -6
- package/lib/wrapper/http.js +8 -51
- package/lib/wrapper/http.js.map +3 -3
- package/lib/wrapper/index.js +6 -7
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js +8 -42
- package/lib/wrapper/main.js.map +3 -3
- package/lib/wrapper/requestListener.js +13 -46
- package/lib/wrapper/requestListener.js.map +3 -3
- package/lib/wrapper/server.d.ts +7 -0
- package/lib/wrapper/server.js +11 -0
- package/lib/wrapper/server.js.map +7 -0
- package/package.json +17 -24
- package/template/base/_.prettierrc.js +1 -1
- package/template/base/_eslint.config.js +1 -1
- package/template/base/_pnpm-workspace.yaml +3 -2
- package/template/base/vitest.config.ts +25 -0
- package/template/express-rest-api/package.json +2 -1
- package/template/express-rest-api/skuba.template.js +1 -1
- package/template/express-rest-api/src/app.test.ts +1 -0
- package/template/greeter/package.json +4 -3
- package/template/greeter/skuba.template.js +1 -1
- package/template/greeter/src/app.test.ts +3 -1
- package/template/koa-rest-api/package.json +2 -1
- package/template/koa-rest-api/skuba.template.js +1 -1
- package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +2 -0
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +2 -0
- package/template/koa-rest-api/src/app.test.ts +2 -0
- package/template/koa-rest-api/src/framework/server.test.ts +2 -2
- package/template/koa-rest-api/src/framework/validation.test.ts +2 -0
- package/template/koa-rest-api/src/testing/metrics.ts +2 -0
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +15 -3
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +11 -9
- package/template/lambda-sqs-worker-cdk/package.json +6 -5
- package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -1
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +22 -13
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +1 -0
- package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +33 -31
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +8 -2
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +3 -2
- package/template/lambda-sqs-worker-cdk/src/testing/services.ts +4 -3
- package/template/oss-npm-package/_package.json +1 -0
- package/template/oss-npm-package/skuba.template.js +1 -1
- package/template/oss-npm-package/src/index.test.ts +2 -0
- package/template/private-npm-package/_package.json +1 -0
- package/template/private-npm-package/skuba.template.js +1 -1
- package/template/private-npm-package/src/index.test.ts +2 -0
- package/config/jest.js +0 -1
- package/jest/moduleNameMapper.js +0 -64
- package/jest/transform.js +0 -62
- package/jest/tsConfig.js +0 -26
- package/jest-preset.js +0 -37
- package/lib/api/jest/index.d.ts +0 -15
- package/lib/api/jest/index.js +0 -59
- package/lib/api/jest/index.js.map +0 -7
- package/lib/cli/configure/modules/jest.d.ts +0 -2
- package/lib/cli/configure/modules/jest.js +0 -86
- package/lib/cli/configure/modules/jest.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.d.ts +0 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +0 -144
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +0 -7
- package/lib/cli/test/reporters/github/annotations.d.ts +0 -9
- package/lib/cli/test/reporters/github/annotations.js +0 -102
- package/lib/cli/test/reporters/github/annotations.js.map +0 -7
- package/lib/cli/test/reporters/github/index.d.ts +0 -5
- package/lib/cli/test/reporters/github/index.js +0 -74
- package/lib/cli/test/reporters/github/index.js.map +0 -7
- package/template/base/jest.config.ts +0 -19
- package/template/base/jest.setup.ts +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nexport const fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.promises.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\nexport const hasSkubaDiveRegisterImportRegex =\n /import\\s+['\"](?:skuba-dive\\/register)(?:\\.js)?['\"];?\\s*/gm;\n\nexport const hasRelativeRegisterImportRegex =\n /import\\s+['\"](\\.\\.?\\/.*?register)(?:\\.js)?['\"];?\\s*/gm;\n\nexport const hasRelativeImportRegex =\n /import\\s+['\"](\\.\\.?\\/[^'\"]*?)(?:\\.js)?['\"];?\\s*/gm;\n\nexport const hasSrcImportRegex =\n /import\\s+(?:type\\s+(?:\\{[^}]*\\}|\\*\\s+as\\s+\\w+)|\\{[^}]*\\}|\\*\\s+as\\s+\\w+|\\w+(?:\\s*,\\s*\\{[^}]*\\})?)\\s+from\\s+['\"]src\\/[^'\"]*['\"]/gm;\n\nexport const hasSrcSideEffectImportRegex =\n /import\\s+['\"]src\\/[^'\"]*['\"];?\\s*/gm;\n\nexport const hasImportRegex = /import\\(\\s*[\"']src\\/[^'\"]*[\"']\\s*\\)/gm;\n\nexport const hasJestMockRegex = /jest\\.(mock|doMock)\\(\\s*[\"']src\\/[^'\"]*[\"']/gm;\n\nconst multiLineCommentRegex = /\\/\\*[\\s\\S]*?\\*\\//g;\n\nconst singleLineCommentRegex = /\\/\\/.*$/gm;\n\nconst whitespaceRegex = /\\s/g;\n\nconst removeSkubaDiveRegisterImport = (contents: string) =>\n contents.replace(hasSkubaDiveRegisterImportRegex, '');\n\nconst removeRelativeRegisterImport = (contents: string) =>\n contents.replace(hasRelativeRegisterImportRegex, '');\n\nconst removeSelectiveRelativeImports = (\n contents: string,\n file: string,\n deletionSet: Set<string>,\n): string =>\n contents.replace(hasRelativeImportRegex, (match, relativePath: string) => {\n if (!relativePath) {\n return match;\n }\n\n const fileDir = path.dirname(file);\n const resolvedPath = path.resolve(fileDir, relativePath);\n\n if (path.extname(relativePath)) {\n return deletionSet.has(resolvedPath) ? '' : match;\n }\n\n const possiblePaths = [`${resolvedPath}.ts`, `${resolvedPath}.js`];\n const shouldRemove = possiblePaths.some((possiblePath) =>\n deletionSet.has(possiblePath),\n );\n\n return shouldRemove ? '' : match;\n });\n\nexport const isFileEmpty = (contents: string): boolean =>\n contents\n .replace(multiLineCommentRegex, '')\n .replace(singleLineCommentRegex, '')\n .replace(whitespaceRegex, '').length === 0;\n\nexport const replaceSrcImport = (contents: string) => {\n const combinedSrcRegex = new RegExp(\n [\n hasSrcImportRegex.source,\n hasSrcSideEffectImportRegex.source,\n hasImportRegex.source,\n hasJestMockRegex.source,\n ].join('|'),\n 'gm',\n );\n\n const withReplacedSrcImports = contents.replace(combinedSrcRegex, (match) =>\n match.replace(/(['\"])src\\//g, '$1#src/'),\n );\n\n return removeSkubaDiveRegisterImport(withReplacedSrcImports);\n};\n\nexport const replaceSrcImportWithConditionalRegisterRemoval = (\n contents: string,\n shouldRemoveRelativeRegister: boolean,\n) => {\n const combinedSrcRegex = new RegExp(\n [\n hasSrcImportRegex.source,\n hasSrcSideEffectImportRegex.source,\n hasImportRegex.source,\n hasJestMockRegex.source,\n ].join('|'),\n 'gm',\n );\n\n const withReplacedSrcImports = contents.replace(combinedSrcRegex, (match) =>\n match.replace(/(['\"])src\\//g, '$1#src/'),\n );\n\n const withoutSkubaDive = removeSkubaDiveRegisterImport(\n withReplacedSrcImports,\n );\n\n return shouldRemoveRelativeRegister\n ? removeRelativeRegisterImport(withoutSkubaDive)\n : withoutSkubaDive;\n};\n\nexport const replaceSrcImportWithSelectiveRegisterRemoval = (\n contents: string,\n file: string,\n deletionSet: Set<string>,\n) => {\n const combinedSrcRegex = new RegExp(\n [\n hasSrcImportRegex.source,\n hasSrcSideEffectImportRegex.source,\n hasImportRegex.source,\n hasJestMockRegex.source,\n ].join('|'),\n 'gm',\n );\n\n const withReplacedSrcImports = contents.replace(combinedSrcRegex, (match) =>\n match.replace(/(['\"])src\\//g, '$1#src/'),\n );\n\n const withoutSkubaDive = removeSkubaDiveRegisterImport(\n withReplacedSrcImports,\n );\n\n return removeSelectiveRelativeImports(withoutSkubaDive, file, deletionSet);\n};\n\nexport const tryRewriteSrcImports: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const tsFileNames = await glob(['**/*.ts', '**/*.test.ts'], {\n ignore: [\n '**/.git',\n '**/node_modules',\n 'src/cli/lint/internalLints/upgrade/patches/**/*',\n ],\n });\n\n if (!tsFileNames.length) {\n return {\n result: 'skip',\n reason: 'no .ts or test.ts files found',\n };\n }\n\n const tsFiles = await fetchFiles(tsFileNames);\n\n const filesWithSkubaDiveRemoved = tsFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n afterSkubaDiveRemoval: removeSkubaDiveRegisterImport(\n contents.replace(\n new RegExp(\n [\n hasSrcImportRegex.source,\n hasSrcSideEffectImportRegex.source,\n hasImportRegex.source,\n hasJestMockRegex.source,\n ].join('|'),\n 'gm',\n ),\n (match) => match.replace(/(['\"])src\\//g, '$1#src/'),\n ),\n ),\n }));\n\n const filesToDelete = new Set(\n filesWithSkubaDiveRemoved\n .filter(({ afterSkubaDiveRemoval }) => isFileEmpty(afterSkubaDiveRemoval))\n .map(({ file }) => path.resolve(file)),\n );\n\n const mapped = tsFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: replaceSrcImportWithSelectiveRegisterRemoval(\n contents,\n file,\n filesToDelete,\n ),\n }));\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n mapped.map(async ({ file, before, after }) => {\n if (isFileEmpty(after)) {\n await fs.promises.unlink(file);\n return;\n }\n\n if (before !== after) {\n await fs.promises.writeFile(file, after);\n }\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const rewriteSrcImports: PatchFunction = async (config) => {\n try {\n return await tryRewriteSrcImports(config);\n } catch (err) {\n log.warn('Failed to rewrite src imports to #src');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,eAAe;AAExB,SAAS,YAAY;AACrB,OAAO,QAAQ;AAEf,SAAS,WAAW;AAGb,MAAM,aAAa,OAAO,UAC/B,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,GAAG,SAAS,SAAS,MAAM,MAAM;AAExD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEK,MAAM,kCACX;AAEK,MAAM,iCACX;AAEK,MAAM,yBACX;AAEK,MAAM,oBACX;AAEK,MAAM,8BACX;AAEK,MAAM,iBAAiB;AAEvB,MAAM,mBAAmB;AAEhC,MAAM,w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-
|
|
4
|
-
|
|
5
|
-
|
|
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 updateLambdaConfigs_exports = {};
|
|
30
|
-
__export(updateLambdaConfigs_exports, {
|
|
31
|
-
tryUpdateLambdaConfigs: () => tryUpdateLambdaConfigs,
|
|
32
|
-
updateLambdaConfigs: () => updateLambdaConfigs
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(updateLambdaConfigs_exports);
|
|
35
|
-
var import_util = require("util");
|
|
36
|
-
var import_fast_glob = require("fast-glob");
|
|
37
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
|
-
var import__ = require("../../../../../../index.js");
|
|
39
|
-
var import_logging = require("../../../../../../utils/logging.js");
|
|
1
|
+
import { inspect } from "util";
|
|
2
|
+
import { glob } from "fast-glob";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { Git } from "../../../../../../index.js";
|
|
5
|
+
import { log } from "../../../../../../utils/logging.js";
|
|
40
6
|
const fetchFiles = async (files) => Promise.all(
|
|
41
7
|
files.map(async (file) => {
|
|
42
|
-
const contents = await
|
|
8
|
+
const contents = await fs.promises.readFile(file, "utf8");
|
|
43
9
|
return {
|
|
44
10
|
file,
|
|
45
11
|
contents
|
|
@@ -299,23 +265,23 @@ const tryUpdateLambdaConfigs = async ({
|
|
|
299
265
|
}) => {
|
|
300
266
|
let customCondition;
|
|
301
267
|
try {
|
|
302
|
-
const { repo } = await
|
|
268
|
+
const { repo } = await Git.getOwnerAndRepo({ dir: process.cwd() });
|
|
303
269
|
customCondition = `@seek/${repo}/source`;
|
|
304
270
|
} catch {
|
|
305
271
|
return { result: "skip", reason: "no repository name found" };
|
|
306
272
|
}
|
|
307
273
|
const [tsFileNames, webpackFileNames, serverlessFileNames] = await Promise.all([
|
|
308
|
-
|
|
274
|
+
glob("**/*.ts", {
|
|
309
275
|
ignore: [
|
|
310
276
|
"**/.git",
|
|
311
277
|
"**/node_modules",
|
|
312
278
|
"src/cli/lint/internalLints/upgrade/patches/**/*"
|
|
313
279
|
]
|
|
314
280
|
}),
|
|
315
|
-
|
|
281
|
+
glob("**/*webpack.config.js", {
|
|
316
282
|
ignore: ["**/.git", "**/node_modules"]
|
|
317
283
|
}),
|
|
318
|
-
|
|
284
|
+
glob("**/serverless*.y*ml", {
|
|
319
285
|
ignore: ["**/.git", "**/node_modules"]
|
|
320
286
|
})
|
|
321
287
|
]);
|
|
@@ -382,7 +348,7 @@ const tryUpdateLambdaConfigs = async ({
|
|
|
382
348
|
}
|
|
383
349
|
await Promise.all(
|
|
384
350
|
filesToPatch.map(async ({ file, modified }) => {
|
|
385
|
-
await
|
|
351
|
+
await fs.promises.writeFile(file, modified, "utf8");
|
|
386
352
|
})
|
|
387
353
|
);
|
|
388
354
|
return { result: "apply" };
|
|
@@ -391,14 +357,13 @@ const updateLambdaConfigs = async (config) => {
|
|
|
391
357
|
try {
|
|
392
358
|
return await tryUpdateLambdaConfigs(config);
|
|
393
359
|
} catch (err) {
|
|
394
|
-
|
|
395
|
-
|
|
360
|
+
log.warn("Failed to write configure `tsconfig.json` and `package.json`");
|
|
361
|
+
log.subtle(inspect(err));
|
|
396
362
|
return { result: "skip", reason: "due to an error" };
|
|
397
363
|
}
|
|
398
364
|
};
|
|
399
|
-
|
|
400
|
-
0 && (module.exports = {
|
|
365
|
+
export {
|
|
401
366
|
tryUpdateLambdaConfigs,
|
|
402
367
|
updateLambdaConfigs
|
|
403
|
-
}
|
|
368
|
+
};
|
|
404
369
|
//# sourceMappingURL=updateLambdaConfigs.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.ts"],
|
|
4
4
|
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { Git } from '../../../../../../index.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.promises.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\n/**\n * Find a block delimited by braces and return its content and position\n * @param content The text to search in\n * @param pattern The regex pattern to match (should match up to the opening brace)\n * @returns Object containing the matched content and indices, or undefined if not found\n */\nconst findBracedBlock = (\n content: string,\n pattern: RegExp,\n):\n | {\n content: string;\n startIndex: number;\n endIndex: number;\n matchIndex: number;\n }\n | undefined => {\n const match = pattern.exec(content);\n if (!match) {\n return undefined;\n }\n\n // Find the matching closing brace\n let braceCount = 1;\n const startIndex = match.index + match[0].length;\n let endIndex = startIndex;\n\n while (braceCount > 0 && endIndex < content.length) {\n if (content[endIndex] === '{') {\n braceCount++;\n } else if (content[endIndex] === '}') {\n braceCount--;\n }\n endIndex++;\n }\n\n if (braceCount !== 0) {\n return undefined;\n }\n\n return {\n content: content.slice(startIndex, endIndex - 1),\n startIndex,\n endIndex,\n matchIndex: match.index,\n };\n};\n\n/**\n * Find and replace all braced blocks matching a pattern\n * @param content The text to search in\n * @param pattern The regex pattern to match (should be global and match up to the opening brace)\n * @param replacer Function that receives the block content and returns the replacement, or undefined to skip\n * @returns The modified content, or undefined if no changes were made\n */\nconst replaceAllBracedBlocks = (\n content: string,\n pattern: RegExp,\n replacer: (blockContent: string) => string | undefined,\n): string | undefined => {\n let modified = content;\n let hasChanges = false;\n let match: RegExpExecArray | null;\n let offset = 0;\n\n while ((match = pattern.exec(content)) !== null) {\n const adjustedIndex = match.index + offset;\n\n // Find the matching closing brace\n let braceCount = 1;\n const startIndex = adjustedIndex + match[0].length;\n let endIndex = startIndex;\n\n while (braceCount > 0 && endIndex < modified.length) {\n if (modified[endIndex] === '{') {\n braceCount++;\n } else if (modified[endIndex] === '}') {\n braceCount--;\n }\n endIndex++;\n }\n\n if (braceCount !== 0) {\n continue;\n }\n\n const blockContent = modified.slice(startIndex, endIndex - 1);\n const replacement = replacer(blockContent);\n\n if (replacement === undefined) {\n continue;\n }\n\n // Replace this block\n const before = modified.slice(0, adjustedIndex);\n const after = modified.slice(endIndex);\n const fullReplacement = `${match[0].slice(0, -1)}{${replacement}}`;\n modified = `${before}${fullReplacement}${after}`;\n\n // Adjust offset for next iteration\n offset += fullReplacement.length - (endIndex - adjustedIndex);\n hasChanges = true;\n }\n\n return hasChanges ? modified : undefined;\n};\n\nconst patchCdkTsFile = ({\n contents,\n customCondition,\n}: {\n contents: string;\n customCondition: string;\n}):\n | {\n original: string;\n modified: string;\n }\n | undefined => {\n if (\n !contents.includes('aws_lambda_nodejs.NodejsFunction') &&\n !contents.includes('NodejsFunction')\n ) {\n return undefined;\n }\n\n const modified = replaceAllBracedBlocks(\n contents,\n /bundling:\\s*\\{/g,\n (bundlingContent) => {\n // Check if --conditions already exists\n if (bundlingContent.includes('--conditions')) {\n return undefined;\n }\n\n // Find esbuildArgs block within bundling\n const esbuildArgsBlock = findBracedBlock(\n bundlingContent,\n /esbuildArgs\\s*:\\s*\\{/,\n );\n\n if (esbuildArgsBlock) {\n const argsContent = esbuildArgsBlock.content.trim();\n const separator = argsContent ? ', ' : '';\n const newArgsContent = `'--conditions': '${customCondition}'${separator}${argsContent}`;\n\n const modifiedBundlingContent = `${bundlingContent.slice(0, esbuildArgsBlock.matchIndex)}esbuildArgs: {${newArgsContent}}${bundlingContent.slice(esbuildArgsBlock.endIndex)}`;\n\n return modifiedBundlingContent;\n }\n\n // Add new esbuildArgs property\n const modifiedBundlingContent = bundlingContent.trimStart();\n return `\\n esbuildArgs: { '--conditions': '${customCondition}' },\\n ${modifiedBundlingContent}`;\n },\n );\n\n if (!modified) {\n return undefined;\n }\n\n return {\n original: contents,\n modified,\n };\n};\n\nconst patchWebpackConfigFile = ({\n contents,\n customCondition,\n}: {\n contents: string;\n customCondition: string;\n}):\n | {\n original: string;\n modified: string;\n }\n | undefined => {\n // Find module.exports block\n const exportsBlock = findBracedBlock(contents, /module\\.exports\\s*=\\s*\\{/);\n if (!exportsBlock) {\n return undefined;\n }\n\n const exportsContent = exportsBlock.content;\n\n // Check if resolve.conditionNames already has our custom condition\n if (exportsContent.includes(customCondition)) {\n return undefined;\n }\n\n // Find resolve block within module.exports\n const resolveBlock = findBracedBlock(exportsContent, /resolve\\s*:\\s*\\{/);\n\n if (resolveBlock) {\n const resolveContent = resolveBlock.content;\n\n // Find conditionNames array within resolve\n const conditionNamesMatch = /conditionNames\\s*:\\s*\\[([^\\]]*)\\]/s.exec(\n resolveContent,\n );\n\n if (conditionNamesMatch?.[1] !== undefined) {\n // Add custom condition to existing conditionNames array\n const existingConditions = conditionNamesMatch[1].trim();\n const separator = existingConditions ? ', ' : '';\n const newConditionNames = `conditionNames: ['${customCondition}'${separator}${existingConditions}]`;\n\n const modifiedResolveContent = `${resolveContent.slice(0, conditionNamesMatch.index)}${newConditionNames}${resolveContent.slice(conditionNamesMatch.index + conditionNamesMatch[0].length)}`;\n\n const modifiedExportsContent = `${exportsContent.slice(0, resolveBlock.matchIndex)}resolve: {${modifiedResolveContent}}${exportsContent.slice(resolveBlock.endIndex)}`;\n\n const modified = `${contents.slice(0, exportsBlock.startIndex)}${modifiedExportsContent}${contents.slice(exportsBlock.endIndex)}`;\n\n return {\n original: contents,\n modified,\n };\n }\n\n // Add conditionNames property to resolve block\n const modifiedResolveContent = resolveContent.trimStart();\n const newResolveContent = `\\n conditionNames: ['${customCondition}', '...'],\\n ${modifiedResolveContent}`;\n\n const modifiedExportsContent = `${exportsContent.slice(0, resolveBlock.matchIndex)}resolve: {${newResolveContent}}${exportsContent.slice(resolveBlock.endIndex)}`;\n\n const modified = `${contents.slice(0, exportsBlock.startIndex)}${modifiedExportsContent}${contents.slice(exportsBlock.endIndex)}`;\n\n return {\n original: contents,\n modified,\n };\n }\n\n // Add resolve property with conditionNames to module.exports\n const modifiedExportsContent = exportsContent.trimStart();\n const newExportsContent = `\\n resolve: {\\n conditionNames: ['${customCondition}', '...'],\\n },\\n ${modifiedExportsContent}`;\n\n const modified = `${contents.slice(0, exportsBlock.startIndex)}${newExportsContent}${contents.slice(exportsBlock.endIndex)}`;\n\n return {\n original: contents,\n modified,\n };\n};\n\nconst patchServerlessEsbuildFile = ({\n contents,\n customCondition,\n}: {\n contents: string;\n customCondition: string;\n}):\n | {\n original: string;\n modified: string;\n }\n | undefined => {\n // Check if custom condition already exists\n if (contents.includes(customCondition)) {\n return undefined;\n }\n\n // Check for serverless-esbuild plugin or build.esbuild or custom.esbuild configuration\n if (\n !contents.includes('serverless-esbuild') &&\n !contents.includes('build:') &&\n !contents.includes('custom:')\n ) {\n return undefined;\n }\n\n // Match esbuild: blocks with nested configuration (not inline \"esbuild: false\")\n // This matches any level of indentation, not just directly under build/custom\n const esbuildBlockRegex = /^(\\s*)(esbuild:)\\s*\\n((?:\\1\\s+.+\\n)+)/gm;\n\n let match;\n let modified = contents;\n let hasChanges = false;\n\n // Reset regex lastIndex for multiple matches\n esbuildBlockRegex.lastIndex = 0;\n\n while ((match = esbuildBlockRegex.exec(contents)) !== null) {\n const [fullMatch, baseIndent, esbuildLabel, esbuildContent] = match;\n\n // Check if esbuild is disabled (esbuild: false)\n if (/esbuild:\\s*false/.exec(fullMatch)) {\n continue;\n }\n\n // Check if conditions already exists in this block\n if (esbuildContent?.includes('conditions:')) {\n continue;\n }\n\n // Determine indentation (should be baseIndent + 2 spaces for YAML)\n const conditionsIndent = `${baseIndent} `;\n const arrayItemIndent = `${conditionsIndent} `;\n\n // Build the new esbuild block with conditions added\n const newEsbuildBlock = `${baseIndent}${esbuildLabel}\\n${conditionsIndent}conditions:\\n${arrayItemIndent}- '${customCondition}'\\n${esbuildContent}`;\n\n // Replace in the modified content\n modified = modified.replace(fullMatch, newEsbuildBlock);\n hasChanges = true;\n }\n\n if (!hasChanges) {\n return undefined;\n }\n\n return {\n original: contents,\n modified,\n };\n};\n\nconst patchServerlessFile = ({\n contents,\n customCondition,\n}: {\n contents: string;\n customCondition: string;\n}):\n | {\n original: string;\n modified: string;\n }\n | undefined => {\n if (contents.includes('esbuild')) {\n return patchServerlessEsbuildFile({\n contents,\n customCondition,\n });\n }\n\n if (contents.includes('serverless-webpack')) {\n return undefined;\n }\n\n // patch package patterns for serverless framework\n if (contents.includes('package.json')) {\n return undefined;\n }\n\n // Match package: blocks with patterns: arrays (allow other properties in between)\n const packageBlockRegex = /^(\\s*)(patterns:)\\s*\\n((?:\\1\\s+-\\s+.+\\n)*)/gm;\n\n let match;\n let modified = contents;\n let hasChanges = false;\n\n // Reset regex lastIndex for multiple matches\n packageBlockRegex.lastIndex = 0;\n\n while ((match = packageBlockRegex.exec(contents)) !== null) {\n const [fullMatch, patternsIndent, patternsLabel, patternsContent] = match;\n\n // Check if package.json already exists in this block\n if (patternsContent?.includes('package.json')) {\n continue;\n }\n\n // Add package.json to the patterns list\n const arrayItemIndent = `${patternsIndent} `;\n const newPatternsBlock = `${patternsIndent}${patternsLabel}\\n${patternsContent}${arrayItemIndent}- 'package.json'\\n`;\n\n // Replace in the modified content\n modified = modified.replace(fullMatch, newPatternsBlock);\n hasChanges = true;\n }\n\n // Also match package: blocks with include: arrays (allow other properties in between)\n const packageIncludeBlockRegex =\n /^(\\s*)(include:)\\s*\\n((?:\\1\\s+-\\s+.+\\n)*)/gm;\n\n // Reset regex lastIndex for multiple matches\n packageIncludeBlockRegex.lastIndex = 0;\n\n while ((match = packageIncludeBlockRegex.exec(contents)) !== null) {\n const [fullMatch, includeIndent, includeLabel, includeContent] = match;\n\n // Check if package.json already exists in this block\n if (includeContent?.includes('package.json')) {\n continue;\n }\n\n // Add package.json to the include list\n const arrayItemIndent = `${includeIndent} `;\n const newIncludeBlock = `${includeIndent}${includeLabel}\\n${includeContent}${arrayItemIndent}- 'package.json'\\n`;\n\n // Replace in the modified content\n modified = modified.replace(fullMatch, newIncludeBlock);\n hasChanges = true;\n }\n\n if (!hasChanges) {\n return undefined;\n }\n\n return {\n original: contents,\n modified,\n };\n};\n\nexport const tryUpdateLambdaConfigs: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n let customCondition: string;\n try {\n const { repo } = await Git.getOwnerAndRepo({ dir: process.cwd() });\n customCondition = `@seek/${repo}/source`;\n } catch {\n return { result: 'skip', reason: 'no repository name found' };\n }\n\n const [tsFileNames, webpackFileNames, serverlessFileNames] =\n await Promise.all([\n glob('**/*.ts', {\n ignore: [\n '**/.git',\n '**/node_modules',\n 'src/cli/lint/internalLints/upgrade/patches/**/*',\n ],\n }),\n glob('**/*webpack.config.js', {\n ignore: ['**/.git', '**/node_modules'],\n }),\n glob('**/serverless*.y*ml', {\n ignore: ['**/.git', '**/node_modules'],\n }),\n ]);\n\n if (\n !tsFileNames.length &&\n !webpackFileNames.length &&\n !serverlessFileNames.length\n ) {\n return {\n result: 'skip',\n reason: 'no .ts or webpack config files or .yml files found',\n };\n }\n\n const [tsFiles, webpackFiles, serverlessFiles] = await Promise.all([\n fetchFiles(tsFileNames),\n fetchFiles(webpackFileNames),\n fetchFiles(serverlessFileNames),\n ]);\n\n const filesToPatch = [\n ...tsFiles.flatMap(({ file, contents }) => {\n const patched = patchCdkTsFile({\n contents,\n customCondition,\n });\n if (patched && patched.modified !== patched.original) {\n return {\n file,\n original: patched.original,\n modified: patched.modified,\n };\n }\n return [];\n }),\n ...webpackFiles.flatMap(({ file, contents }) => {\n const patched = patchWebpackConfigFile({\n contents,\n customCondition,\n });\n if (patched && patched.modified !== patched.original) {\n return {\n file,\n original: patched.original,\n modified: patched.modified,\n };\n }\n return [];\n }),\n ...serverlessFiles.flatMap(({ file, contents }) => {\n const patched = patchServerlessFile({\n contents,\n customCondition,\n });\n if (patched && patched.modified !== patched.original) {\n return {\n file,\n original: patched.original,\n modified: patched.modified,\n };\n }\n return [];\n }),\n ];\n\n if (!filesToPatch.length) {\n return { result: 'skip', reason: 'no lambda configurations to patch' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await Promise.all(\n filesToPatch.map(async ({ file, modified }) => {\n await fs.promises.writeFile(file, modified, 'utf8');\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const updateLambdaConfigs: PatchFunction = async (config) => {\n try {\n return await tryUpdateLambdaConfigs(config);\n } catch (err) {\n log.warn('Failed to write configure `tsconfig.json` and `package.json`');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAExB,SAAS,YAAY;AACrB,OAAO,QAAQ;AAEf,SAAS,WAAW;AACpB,SAAS,WAAW;AAGpB,MAAM,aAAa,OAAO,UAC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AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["modifiedBundlingContent", "modifiedResolveContent", "modifiedExportsContent", "modified"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { rewriteGlobalVars } from "./rewriteGlobalVars.js";
|
|
2
|
+
const patches = [
|
|
3
|
+
{
|
|
4
|
+
apply: rewriteGlobalVars,
|
|
5
|
+
description: "Replace __dirname and __filename with import.meta equivalents"
|
|
6
|
+
}
|
|
7
|
+
];
|
|
8
|
+
export {
|
|
9
|
+
patches
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.5.0/index.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { rewriteGlobalVars } from './rewriteGlobalVars.js';\n\nexport const patches: Patches = [\n {\n apply: rewriteGlobalVars,\n description:\n 'Replace __dirname and __filename with import.meta equivalents',\n },\n];\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,yBAAyB;AAE3B,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { inspect } from "util";
|
|
2
|
+
import { glob } from "fast-glob";
|
|
3
|
+
import { fs } from "memfs";
|
|
4
|
+
import { log } from "../../../../../../utils/logging.js";
|
|
5
|
+
import { fetchFiles } from "../12.4.1/rewriteSrcImports.js";
|
|
6
|
+
const hasDirNameRegex = /__dirname\b/;
|
|
7
|
+
const hasFileNameRegex = /__filename\b/;
|
|
8
|
+
const removeGlobalVars = (contents) => contents.replace(hasDirNameRegex, "import.meta.dirname").replace(hasFileNameRegex, "import.meta.filename");
|
|
9
|
+
const tryRewriteGlobalVars = async ({
|
|
10
|
+
mode
|
|
11
|
+
}) => {
|
|
12
|
+
const fileNames = await glob(
|
|
13
|
+
["**/*.ts", "**/*.test.ts", "**/*.js", "**/*.test.js"],
|
|
14
|
+
{
|
|
15
|
+
ignore: [
|
|
16
|
+
"**/.git",
|
|
17
|
+
"**/node_modules",
|
|
18
|
+
"src/cli/lint/internalLints/upgrade/patches/**/*"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
if (!fileNames.length) {
|
|
23
|
+
return {
|
|
24
|
+
result: "skip",
|
|
25
|
+
reason: "no .ts or test.ts files found"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const tsFiles = await fetchFiles(fileNames);
|
|
29
|
+
const filesWithGlobalVarsRemoved = tsFiles.map(({ file, contents }) => ({
|
|
30
|
+
file,
|
|
31
|
+
before: contents,
|
|
32
|
+
after: removeGlobalVars(contents)
|
|
33
|
+
}));
|
|
34
|
+
const hasChanges = filesWithGlobalVarsRemoved.some(
|
|
35
|
+
({ before, after }) => before !== after
|
|
36
|
+
);
|
|
37
|
+
if (!hasChanges) {
|
|
38
|
+
return {
|
|
39
|
+
result: "skip",
|
|
40
|
+
reason: "no global variables found to replace"
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (mode === "lint") {
|
|
44
|
+
return {
|
|
45
|
+
result: "apply"
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
await Promise.all(
|
|
49
|
+
filesWithGlobalVarsRemoved.map(async ({ file, before, after }) => {
|
|
50
|
+
if (before !== after) {
|
|
51
|
+
await fs.promises.writeFile(file, after);
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
return { result: "apply" };
|
|
56
|
+
};
|
|
57
|
+
const rewriteGlobalVars = async (config) => {
|
|
58
|
+
try {
|
|
59
|
+
return await tryRewriteGlobalVars(config);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
log.warn("Failed to replace global variables with import.meta equivalents");
|
|
62
|
+
log.subtle(inspect(err));
|
|
63
|
+
return { result: "skip", reason: "due to an error" };
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
hasDirNameRegex,
|
|
68
|
+
hasFileNameRegex,
|
|
69
|
+
rewriteGlobalVars,
|
|
70
|
+
tryRewriteGlobalVars
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=rewriteGlobalVars.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport { fs } from 'memfs';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\nimport { fetchFiles } from '../12.4.1/rewriteSrcImports.js';\n\nexport const hasDirNameRegex = /__dirname\\b/;\nexport const hasFileNameRegex = /__filename\\b/;\n\n// TODO: leave a comment doesn't work for this but it's our repos anyways so should be ok\n// const __dirname = fileURLToPath(new URL('.', import.meta.url));\n// const root = path.resolve(__dirname, '..', '..');\n\n// TODO: is this efficient?\nconst removeGlobalVars = (contents: string) =>\n contents\n .replace(hasDirNameRegex, 'import.meta.dirname')\n .replace(hasFileNameRegex, 'import.meta.filename');\n\n// TODO: explain why we need these fallbacks\n// export function dirname(importMeta: ImportMeta) {\n// const file = filename(importMeta);\n// return file !== '' ? pathDirname(file) : '';\n// }\n\n// export function filename(importMeta: ImportMeta) {\n// return importMeta.url ? fileURLToPath(importMeta.url) : '';\n// }\n\nexport const tryRewriteGlobalVars: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n // Todo: can this be reused from rewriteSrcImports?\n const fileNames = await glob(\n ['**/*.ts', '**/*.test.ts', '**/*.js', '**/*.test.js'],\n {\n ignore: [\n '**/.git',\n '**/node_modules',\n 'src/cli/lint/internalLints/upgrade/patches/**/*',\n ],\n },\n );\n\n if (!fileNames.length) {\n return {\n result: 'skip',\n reason: 'no .ts or test.ts files found',\n };\n }\n\n const tsFiles = await fetchFiles(fileNames);\n\n const filesWithGlobalVarsRemoved = tsFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: removeGlobalVars(contents),\n }));\n\n const hasChanges = filesWithGlobalVarsRemoved.some(\n ({ before, after }) => before !== after,\n );\n\n if (!hasChanges) {\n return {\n result: 'skip',\n reason: 'no global variables found to replace',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n filesWithGlobalVarsRemoved.map(async ({ file, before, after }) => {\n if (before !== after) {\n await fs.promises.writeFile(file, after);\n }\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const rewriteGlobalVars: PatchFunction = async (config) => {\n try {\n return await tryRewriteGlobalVars(config);\n } catch (err) {\n log.warn('Failed to replace global variables with import.meta equivalents');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAExB,SAAS,YAAY;AACrB,SAAS,UAAU;AAEnB,SAAS,WAAW;AAEpB,SAAS,kBAAkB;AAEpB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAOhC,MAAM,mBAAmB,CAAC,aACxB,SACG,QAAQ,iBAAiB,qBAAqB,EAC9C,QAAQ,kBAAkB,sBAAsB;AAY9C,MAAM,uBAAsC,OAAO;AAAA,EACxD;AACF,MAAgC;AAE9B,QAAM,YAAY,MAAM;AAAA,IACtB,CAAC,WAAW,gBAAgB,WAAW,cAAc;AAAA,IACrD;AAAA,MACE,QAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,UAAU,QAAQ;AACrB,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,UAAU,MAAM,WAAW,SAAS;AAE1C,QAAM,6BAA6B,QAAQ,IAAI,CAAC,EAAE,MAAM,SAAS,OAAO;AAAA,IACtE;AAAA,IACA,QAAQ;AAAA,IACR,OAAO,iBAAiB,QAAQ;AAAA,EAClC,EAAE;AAEF,QAAM,aAAa,2BAA2B;AAAA,IAC5C,CAAC,EAAE,QAAQ,MAAM,MAAM,WAAW;AAAA,EACpC;AAEA,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,2BAA2B,IAAI,OAAO,EAAE,MAAM,QAAQ,MAAM,MAAM;AAChE,UAAI,WAAW,OAAO;AACpB,cAAM,GAAG,SAAS,UAAU,MAAM,KAAK;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,oBAAmC,OAAO,WAAW;AAChE,MAAI;AACF,WAAO,MAAM,qBAAqB,MAAM;AAAA,EAC1C,SAAS,KAAK;AACZ,QAAI,KAAK,iEAAiE;AAC1E,QAAI,OAAO,QAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,48 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 addEmptyExports_exports = {};
|
|
30
|
-
__export(addEmptyExports_exports, {
|
|
31
|
-
tryAddEmptyExports: () => tryAddEmptyExports
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(addEmptyExports_exports);
|
|
34
|
-
var import_path = __toESM(require("path"));
|
|
35
|
-
var import_util = require("util");
|
|
36
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
-
var import_logging = require("../../../../../../utils/logging.js");
|
|
38
|
-
var import_package = require("../../../../../configure/analysis/package.js");
|
|
39
|
-
var import_project = require("../../../../../configure/analysis/project.js");
|
|
40
|
-
var import_prettier = require("../../../../../configure/processing/prettier.js");
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { inspect } from "util";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { log } from "../../../../../../utils/logging.js";
|
|
5
|
+
import { getDestinationManifest } from "../../../../../configure/analysis/package.js";
|
|
6
|
+
import { createDestinationFileReader } from "../../../../../configure/analysis/project.js";
|
|
7
|
+
import { formatPrettier } from "../../../../../configure/processing/prettier.js";
|
|
41
8
|
const JEST_SETUP_FILES = ["jest.setup.ts", "jest.setup.int.ts"];
|
|
42
9
|
const addEmptyExports = async (mode) => {
|
|
43
|
-
const manifest = await
|
|
44
|
-
const destinationRoot =
|
|
45
|
-
const readDestinationFile =
|
|
10
|
+
const manifest = await getDestinationManifest();
|
|
11
|
+
const destinationRoot = path.dirname(manifest.path);
|
|
12
|
+
const readDestinationFile = createDestinationFileReader(destinationRoot);
|
|
46
13
|
const addEmptyExport = async (filename) => {
|
|
47
14
|
const inputFile = await readDestinationFile(filename);
|
|
48
15
|
if (!inputFile || // The file appears to have an import or export so it should be compatible
|
|
@@ -54,11 +21,11 @@ const addEmptyExports = async (mode) => {
|
|
|
54
21
|
if (mode === "lint") {
|
|
55
22
|
return "apply";
|
|
56
23
|
}
|
|
57
|
-
const data = await
|
|
24
|
+
const data = await formatPrettier([inputFile, "export {}"].join("\n\n"), {
|
|
58
25
|
parser: "typescript"
|
|
59
26
|
});
|
|
60
|
-
const filepath =
|
|
61
|
-
await
|
|
27
|
+
const filepath = path.join(destinationRoot, filename);
|
|
28
|
+
await fs.promises.writeFile(filepath, data);
|
|
62
29
|
return "apply";
|
|
63
30
|
};
|
|
64
31
|
const results = await Promise.all(JEST_SETUP_FILES.map(addEmptyExport));
|
|
@@ -68,13 +35,12 @@ const tryAddEmptyExports = async ({ mode }) => {
|
|
|
68
35
|
try {
|
|
69
36
|
return { result: await addEmptyExports(mode) };
|
|
70
37
|
} catch (err) {
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
log.warn("Failed to convert Jest setup files to isolated modules.");
|
|
39
|
+
log.subtle(inspect(err));
|
|
73
40
|
return { result: "skip", reason: "due to an error" };
|
|
74
41
|
}
|
|
75
42
|
};
|
|
76
|
-
|
|
77
|
-
0 && (module.exports = {
|
|
43
|
+
export {
|
|
78
44
|
tryAddEmptyExports
|
|
79
|
-
}
|
|
45
|
+
};
|
|
80
46
|
//# sourceMappingURL=addEmptyExports.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport { getDestinationManifest } from '../../../../../configure/analysis/package.js';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project.js';\nimport { formatPrettier } from '../../../../../configure/processing/prettier.js';\nimport type { PatchFunction } from '../../index.js';\n\nconst JEST_SETUP_FILES = ['jest.setup.ts', 'jest.setup.int.ts'];\n\nconst addEmptyExports = async (mode: 'format' | 'lint') => {\n const manifest = await getDestinationManifest();\n\n const destinationRoot = path.dirname(manifest.path);\n\n const readDestinationFile = createDestinationFileReader(destinationRoot);\n\n const addEmptyExport = async (filename: string) => {\n const inputFile = await readDestinationFile(filename);\n\n if (\n !inputFile ||\n // The file appears to have an import or export so it should be compatible\n // with isolated modules. This is a very naive check that we don't want to\n // overcomplicate because it is invoked before many skuba commands.\n inputFile.includes('import ') ||\n inputFile.includes('export ')\n ) {\n return 'skip';\n }\n\n if (mode === 'lint') {\n return 'apply';\n }\n\n const data = await formatPrettier([inputFile, 'export {}'].join('\\n\\n'), {\n parser: 'typescript',\n });\n\n const filepath = path.join(destinationRoot, filename);\n\n await fs.promises.writeFile(filepath, data);\n\n return 'apply';\n };\n\n const results = await Promise.all(JEST_SETUP_FILES.map(addEmptyExport));\n return results.every((result) => result === 'skip') ? 'skip' : 'apply';\n};\n\n/**\n * Tries to add an empty `export {}` statement to the bottom of Jest setup files\n * for compliance with TypeScript isolated modules.\n */\nexport const tryAddEmptyExports: PatchFunction = async ({ mode }) => {\n try {\n return { result: await addEmptyExports(mode) };\n } catch (err) {\n log.warn('Failed to convert Jest setup files to isolated mod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ACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,50 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __exports = {};
|
|
20
|
-
__export(__exports, {
|
|
21
|
-
patches: () => patches
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(__exports);
|
|
24
|
-
var import_patchRenovateConfig = require("../../../patchRenovateConfig.js");
|
|
25
|
-
var import_addEmptyExports = require("./addEmptyExports.js");
|
|
26
|
-
var import_patchDockerfile = require("./patchDockerfile.js");
|
|
27
|
-
var import_patchServerListener = require("./patchServerListener.js");
|
|
1
|
+
import { tryPatchRenovateConfig } from "../../../patchRenovateConfig.js";
|
|
2
|
+
import { tryAddEmptyExports } from "./addEmptyExports.js";
|
|
3
|
+
import { tryPatchDockerfile } from "./patchDockerfile.js";
|
|
4
|
+
import { tryPatchServerListener } from "./patchServerListener.js";
|
|
28
5
|
const patches = [
|
|
29
6
|
{
|
|
30
|
-
apply:
|
|
7
|
+
apply: tryAddEmptyExports,
|
|
31
8
|
description: "Add empty exports to Jest files for compliance with TypeScript isolated modules"
|
|
32
9
|
},
|
|
33
10
|
{
|
|
34
|
-
apply:
|
|
11
|
+
apply: tryPatchRenovateConfig,
|
|
35
12
|
description: "Update Renovate config to support private SEEK packages"
|
|
36
13
|
},
|
|
37
14
|
{
|
|
38
|
-
apply:
|
|
15
|
+
apply: tryPatchDockerfile,
|
|
39
16
|
description: "Upgrade Node.js Distroless Docker image to -debian12 variant"
|
|
40
17
|
},
|
|
41
18
|
{
|
|
42
|
-
apply:
|
|
19
|
+
apply: tryPatchServerListener,
|
|
43
20
|
description: "Add keepAliveTimeout to server listener"
|
|
44
21
|
}
|
|
45
22
|
];
|
|
46
|
-
|
|
47
|
-
0 && (module.exports = {
|
|
23
|
+
export {
|
|
48
24
|
patches
|
|
49
|
-
}
|
|
25
|
+
};
|
|
50
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/index.ts"],
|
|
4
4
|
"sourcesContent": ["import { tryPatchRenovateConfig } from '../../../patchRenovateConfig.js';\nimport type { Patches } from '../../index.js';\n\nimport { tryAddEmptyExports } from './addEmptyExports.js';\nimport { tryPatchDockerfile } from './patchDockerfile.js';\nimport { tryPatchServerListener } from './patchServerListener.js';\n\nexport const patches: Patches = [\n {\n apply: tryAddEmptyExports,\n description:\n 'Add empty exports to Jest files for compliance with TypeScript isolated modules',\n },\n {\n apply: tryPatchRenovateConfig,\n description: 'Update Renovate config to support private SEEK packages',\n },\n {\n apply: tryPatchDockerfile,\n description: 'Upgrade Node.js Distroless Docker image to -debian12 variant',\n },\n {\n apply: tryPatchServerListener,\n description: 'Add keepAliveTimeout to server listener',\n },\n];\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,SAAS,8BAA8B;AAGvC,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AAEhC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|