skuba 13.0.2 → 14.0.0-esmify-skuba-20251031135439
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.js +10 -2
- package/lib/cli/adapter/eslint.js +10 -46
- package/lib/cli/adapter/eslint.js.map +2 -2
- package/lib/cli/adapter/prettier.js +40 -72
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/args.js +7 -43
- package/lib/cli/build/args.js.map +2 -2
- package/lib/cli/build/assets.js +27 -62
- package/lib/cli/build/assets.js.map +2 -2
- package/lib/cli/build/esbuild.js +20 -55
- package/lib/cli/build/esbuild.js.map +3 -3
- package/lib/cli/build/index.js +20 -56
- package/lib/cli/build/index.js.map +2 -2
- package/lib/cli/build/tsc.js +24 -66
- package/lib/cli/build/tsc.js.map +2 -2
- package/lib/cli/buildPackage/index.js +7 -33
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/analyseConfiguration.js +15 -51
- package/lib/cli/configure/analyseConfiguration.js.map +2 -2
- package/lib/cli/configure/analyseDependencies.js +24 -60
- package/lib/cli/configure/analyseDependencies.js.map +3 -3
- package/lib/cli/configure/analysis/diff.js +4 -40
- package/lib/cli/configure/analysis/diff.js.map +2 -2
- package/lib/cli/configure/analysis/files.js +7 -43
- package/lib/cli/configure/analysis/files.js.map +2 -2
- package/lib/cli/configure/analysis/git.js +11 -47
- package/lib/cli/configure/analysis/git.js.map +2 -2
- package/lib/cli/configure/analysis/package.js +10 -48
- package/lib/cli/configure/analysis/package.js.map +3 -3
- package/lib/cli/configure/analysis/project.js +18 -53
- package/lib/cli/configure/analysis/project.js.map +2 -2
- package/lib/cli/configure/dependencies/index.js +5 -39
- package/lib/cli/configure/dependencies/index.js.map +1 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +3 -29
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
- package/lib/cli/configure/dependencies/seekKoala.js +3 -29
- package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
- package/lib/cli/configure/dependencies/skuba.js +3 -29
- package/lib/cli/configure/dependencies/skuba.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +1 -27
- package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDive.js +4 -32
- package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +31 -61
- package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
- package/lib/cli/configure/getEntryPoint.js +13 -49
- package/lib/cli/configure/getEntryPoint.js.map +3 -3
- package/lib/cli/configure/getProjectType.js +13 -36
- package/lib/cli/configure/getProjectType.js.map +2 -2
- package/lib/cli/configure/index.js +49 -85
- package/lib/cli/configure/index.js.map +3 -3
- package/lib/cli/configure/modules/eslint.js +9 -35
- package/lib/cli/configure/modules/eslint.js.map +1 -1
- package/lib/cli/configure/modules/ignore.js +7 -33
- package/lib/cli/configure/modules/ignore.js.map +1 -1
- package/lib/cli/configure/modules/index.js +17 -45
- package/lib/cli/configure/modules/index.js.map +2 -2
- package/lib/cli/configure/modules/nodemon.js +2 -28
- package/lib/cli/configure/modules/nodemon.js.map +1 -1
- package/lib/cli/configure/modules/package.js +9 -35
- package/lib/cli/configure/modules/package.js.map +1 -1
- package/lib/cli/configure/modules/prettier.js +10 -36
- package/lib/cli/configure/modules/prettier.js.map +1 -1
- package/lib/cli/configure/modules/renovate.js +17 -43
- package/lib/cli/configure/modules/renovate.js.map +2 -2
- package/lib/cli/configure/modules/serverless.js +1 -27
- package/lib/cli/configure/modules/serverless.js.map +1 -1
- package/lib/cli/configure/modules/tslint.js +2 -28
- package/lib/cli/configure/modules/tslint.js.map +1 -1
- package/lib/cli/configure/processing/configFile.js +4 -44
- package/lib/cli/configure/processing/configFile.js.map +1 -1
- package/lib/cli/configure/processing/deleteFiles.js +1 -27
- package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js +2 -30
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.js +6 -34
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/loadFiles.js +1 -27
- package/lib/cli/configure/processing/loadFiles.js.map +1 -1
- package/lib/cli/configure/processing/module.js +2 -28
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.js +10 -52
- package/lib/cli/configure/processing/package.js.map +3 -3
- package/lib/cli/configure/processing/prettier.js +3 -39
- package/lib/cli/configure/processing/prettier.js.map +2 -2
- package/lib/cli/configure/processing/record.js +4 -44
- package/lib/cli/configure/processing/record.js.map +2 -2
- package/lib/cli/configure/processing/typescript.js +28 -70
- package/lib/cli/configure/processing/typescript.js.map +2 -2
- package/lib/cli/configure/types.js +0 -15
- package/lib/cli/configure/types.js.map +3 -3
- package/lib/cli/format/index.js +19 -55
- package/lib/cli/format/index.js.map +2 -2
- package/lib/cli/help/index.js +5 -31
- package/lib/cli/help/index.js.map +1 -1
- package/lib/cli/init/getConfig.js +75 -107
- package/lib/cli/init/getConfig.js.map +3 -3
- package/lib/cli/init/git.js +16 -54
- package/lib/cli/init/git.js.map +3 -3
- package/lib/cli/init/index.js +66 -99
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/init/prompts.js +20 -56
- package/lib/cli/init/prompts.js.map +3 -3
- package/lib/cli/init/types.js +6 -42
- package/lib/cli/init/types.js.map +1 -1
- package/lib/cli/init/validation.js +5 -39
- package/lib/cli/init/validation.js.map +1 -1
- package/lib/cli/init/writePackageJson.js +7 -43
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/eslint.js +2 -38
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js +10 -46
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js +2 -38
- package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +2 -38
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +2 -38
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/github/eslint.js +1 -27
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js +10 -46
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/internal.js +1 -27
- package/lib/cli/lint/annotate/github/internal.js.map +1 -1
- package/lib/cli/lint/annotate/github/prettier.js +1 -27
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +3 -29
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/annotate/index.js +5 -31
- package/lib/cli/lint/annotate/index.js.map +1 -1
- package/lib/cli/lint/autofix.js +38 -78
- package/lib/cli/lint/autofix.js.map +3 -3
- package/lib/cli/lint/eslint.js +14 -52
- package/lib/cli/lint/eslint.js.map +3 -3
- package/lib/cli/lint/external.js +18 -53
- package/lib/cli/lint/external.js.map +2 -2
- package/lib/cli/lint/index.js +24 -50
- package/lib/cli/lint/index.js.map +1 -1
- package/lib/cli/lint/internal.js +17 -53
- package/lib/cli/lint/internal.js.map +2 -2
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +8 -36
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +10 -46
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +3 -3
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +20 -56
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +33 -68
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.js +21 -54
- package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +3 -29
- 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 +10 -46
- 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 +5 -31
- 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 +36 -73
- 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 -49
- 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 +3 -29
- 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 +24 -64
- 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 +3 -29
- 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 -49
- 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 +5 -31
- 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 -49
- 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 -49
- 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 +3 -29
- 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 -49
- 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 +32 -76
- 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 +9 -35
- 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 +10 -46
- 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 +28 -88
- 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 +19 -58
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +16 -52
- 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 +9 -35
- 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 +9 -45
- 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 +11 -47
- 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 +3 -29
- 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 +14 -50
- 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 +10 -46
- 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 +9 -40
- 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 +10 -46
- 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 +10 -46
- 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 +12 -48
- 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 +3 -29
- 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 +10 -46
- 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 +3 -29
- 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 +7 -33
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +1 -1
- package/lib/cli/lint/prettier.js +13 -51
- package/lib/cli/lint/prettier.js.map +3 -3
- package/lib/cli/lint/tsc.js +3 -29
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/lint/types.js +0 -15
- package/lib/cli/lint/types.js.map +3 -3
- package/lib/cli/migrate/index.js +9 -35
- package/lib/cli/migrate/index.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/checks.js +26 -68
- package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/index.js +24 -56
- package/lib/cli/migrate/nodeVersion/index.js.map +2 -2
- package/lib/cli/node/index.js +20 -60
- package/lib/cli/node/index.js.map +3 -3
- package/lib/cli/release/index.js +3 -29
- package/lib/cli/release/index.js.map +1 -1
- package/lib/cli/start/index.js +15 -51
- package/lib/cli/start/index.js.map +3 -3
- package/lib/cli/test/index.js +3 -45
- package/lib/cli/test/index.js.map +2 -2
- package/lib/cli/version/index.js +5 -31
- package/lib/cli/version/index.js.map +1 -1
- package/lib/config/prettier.d.ts +7 -0
- package/lib/index.js +4 -49
- package/lib/index.js.map +2 -2
- package/lib/skuba.js +26 -44
- package/lib/skuba.js.map +3 -3
- package/lib/{cli → src/cli}/configure/analyseDependencies.d.ts +1 -1
- package/lib/{cli → src/cli}/configure/analysis/package.d.ts +2 -3
- package/lib/{cli → src/cli}/configure/ensureTemplateCompletion.d.ts +1 -1
- package/lib/{cli → src/cli}/configure/getEntryPoint.d.ts +1 -1
- package/lib/{cli → src/cli}/configure/getProjectType.d.ts +1 -1
- package/lib/src/cli/configure/processing/package.d.ts +5 -0
- package/lib/{cli → src/cli}/configure/types.d.ts +15 -4
- package/lib/{cli → src/cli}/init/getConfig.d.ts +1 -1
- package/lib/{cli → src/cli}/init/prompts.d.ts +4 -4
- package/lib/{cli → src/cli}/lint/internalLints/upgrade/index.d.ts +1 -1
- package/lib/{index.d.ts → src/index.d.ts} +0 -1
- package/lib/src/utils/fs.d.ts +1 -0
- package/lib/{utils → src/utils}/manifest.d.ts +3 -2
- package/lib/src/utils/sleep.d.ts +5 -0
- package/lib/{utils → src/utils}/wait.d.ts +0 -4
- package/lib/{wrapper → src/wrapper}/http.d.ts +0 -6
- package/lib/src/wrapper/server.d.ts +7 -0
- package/lib/utils/args.js +8 -50
- package/lib/utils/args.js.map +2 -2
- package/lib/utils/command.js +6 -50
- package/lib/utils/command.js.map +3 -3
- package/lib/utils/copy.js +22 -64
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/dir.js +37 -84
- package/lib/utils/dir.js.map +3 -3
- package/lib/utils/env.js +1 -27
- package/lib/utils/env.js.map +1 -1
- package/lib/utils/error.js +11 -53
- package/lib/utils/error.js.map +1 -1
- package/lib/utils/exec.js +26 -70
- package/lib/utils/exec.js.map +3 -3
- package/lib/utils/fs.js +15 -0
- package/lib/utils/fs.js.map +7 -0
- package/lib/utils/help.js +5 -31
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/logging.js +13 -55
- package/lib/utils/logging.js.map +2 -2
- package/lib/utils/logo.js +23 -59
- package/lib/utils/logo.js.map +2 -2
- package/lib/utils/manifest.js +12 -60
- package/lib/utils/manifest.js.map +3 -3
- package/lib/utils/npmrc.js +1 -27
- package/lib/utils/npmrc.js.map +1 -1
- package/lib/utils/packageManager.js +14 -56
- package/lib/utils/packageManager.js.map +2 -2
- package/lib/utils/port.js +4 -42
- package/lib/utils/port.js.map +2 -2
- package/lib/utils/sleep.js +9 -0
- package/lib/utils/sleep.js.map +7 -0
- package/lib/utils/template.js +21 -68
- package/lib/utils/template.js.map +3 -3
- package/lib/utils/validation.js +6 -42
- package/lib/utils/validation.js.map +1 -1
- package/lib/utils/version.js +11 -53
- package/lib/utils/version.js.map +2 -2
- package/lib/utils/wait.js +6 -42
- package/lib/utils/wait.js.map +2 -2
- package/lib/utils/worker.js +9 -37
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/functionHandler.js +17 -50
- package/lib/wrapper/functionHandler.js.map +2 -2
- package/lib/wrapper/http.js +7 -53
- package/lib/wrapper/http.js.map +3 -3
- package/lib/wrapper/index.js +6 -6
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js +7 -43
- package/lib/wrapper/main.js.map +3 -3
- package/lib/wrapper/requestListener.js +12 -47
- package/lib/wrapper/requestListener.js.map +3 -3
- package/lib/wrapper/server.js +9 -0
- package/lib/wrapper/server.js.map +7 -0
- package/package.json +19 -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/.gantry/dev.yml +2 -2
- package/template/express-rest-api/.gantry/prod.yml +2 -2
- package/template/express-rest-api/package.json +6 -5
- 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/.gantry/dev.yml +2 -2
- package/template/koa-rest-api/.gantry/prod.yml +2 -2
- package/template/koa-rest-api/package.json +6 -5
- 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/infra/appStack.ts +1 -1
- 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/.github/workflows/release.yml +1 -1
- package/template/oss-npm-package/.github/workflows/validate.yml +1 -1
- 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/config/prettier.d.ts +0 -4
- 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/configure/processing/package.d.ts +0 -71
- 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
- /package/lib/{cli → src/cli}/adapter/eslint.d.ts +0 -0
- /package/lib/{cli → src/cli}/adapter/prettier.d.ts +0 -0
- /package/lib/{cli → src/cli}/build/args.d.ts +0 -0
- /package/lib/{cli → src/cli}/build/assets.d.ts +0 -0
- /package/lib/{cli → src/cli}/build/esbuild.d.ts +0 -0
- /package/lib/{cli → src/cli}/build/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/build/tsc.d.ts +0 -0
- /package/lib/{cli → src/cli}/buildPackage/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/analyseConfiguration.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/analysis/diff.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/analysis/files.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/analysis/git.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/analysis/project.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/dependencies/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/dependencies/seekDatadogCustomMetrics.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/dependencies/seekKoala.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/dependencies/skuba.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/dependencies/skubaDeps.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/dependencies/skubaDive.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/eslint.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/ignore.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/nodemon.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/package.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/prettier.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/renovate.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/serverless.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/modules/tslint.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/configFile.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/deleteFiles.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/javascript.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/json.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/loadFiles.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/module.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/prettier.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/record.d.ts +0 -0
- /package/lib/{cli → src/cli}/configure/processing/typescript.d.ts +0 -0
- /package/lib/{cli → src/cli}/format/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/help/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/init/git.d.ts +0 -0
- /package/lib/{cli → src/cli}/init/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/init/types.d.ts +0 -0
- /package/lib/{cli → src/cli}/init/validation.d.ts +0 -0
- /package/lib/{cli → src/cli}/init/writePackageJson.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/buildkite/eslint.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/buildkite/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/buildkite/internal.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/buildkite/prettier.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/buildkite/tsc.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/github/eslint.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/github/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/github/internal.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/github/prettier.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/github/tsc.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/annotate/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/autofix.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/eslint.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/external.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internal.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/detectBadCodeowners.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/noSkubaTemplateJs.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/patchRenovateConfig.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/refreshConfigFiles.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.0.4/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.1.0/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.0.2/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.1.1/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.3.0/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.0/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/7.3.1/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.0.0/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/9.0.1/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/9.1.0/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/prettier.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/tsc.d.ts +0 -0
- /package/lib/{cli → src/cli}/lint/types.d.ts +0 -0
- /package/lib/{cli → src/cli}/migrate/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/migrate/nodeVersion/checks.d.ts +0 -0
- /package/lib/{cli → src/cli}/migrate/nodeVersion/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/node/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/release/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/start/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/test/index.d.ts +0 -0
- /package/lib/{cli → src/cli}/version/index.d.ts +0 -0
- /package/lib/{skuba.d.ts → src/skuba.d.ts} +0 -0
- /package/lib/{utils → src/utils}/args.d.ts +0 -0
- /package/lib/{utils → src/utils}/command.d.ts +0 -0
- /package/lib/{utils → src/utils}/copy.d.ts +0 -0
- /package/lib/{utils → src/utils}/dir.d.ts +0 -0
- /package/lib/{utils → src/utils}/env.d.ts +0 -0
- /package/lib/{utils → src/utils}/error.d.ts +0 -0
- /package/lib/{utils → src/utils}/exec.d.ts +0 -0
- /package/lib/{utils → src/utils}/help.d.ts +0 -0
- /package/lib/{utils → src/utils}/logging.d.ts +0 -0
- /package/lib/{utils → src/utils}/logo.d.ts +0 -0
- /package/lib/{utils → src/utils}/npmrc.d.ts +0 -0
- /package/lib/{utils → src/utils}/packageManager.d.ts +0 -0
- /package/lib/{utils → src/utils}/port.d.ts +0 -0
- /package/lib/{utils → src/utils}/template.d.ts +0 -0
- /package/lib/{utils → src/utils}/validation.d.ts +0 -0
- /package/lib/{utils → src/utils}/version.d.ts +0 -0
- /package/lib/{utils → src/utils}/worker.d.ts +0 -0
- /package/lib/{wrapper → src/wrapper}/functionHandler.d.ts +0 -0
- /package/lib/{wrapper → src/wrapper}/index.d.ts +0 -0
- /package/lib/{wrapper → src/wrapper}/main.d.ts +0 -0
- /package/lib/{wrapper → src/wrapper}/requestListener.d.ts +0 -0
|
@@ -1,48 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 configureTsConfigForESM_exports = {};
|
|
30
|
-
__export(configureTsConfigForESM_exports, {
|
|
31
|
-
addJestModuleNameMapper: () => addJestModuleNameMapper,
|
|
32
|
-
configureTsConfigForESM: () => configureTsConfigForESM,
|
|
33
|
-
parsePackageJson: () => parsePackageJson,
|
|
34
|
-
tryConfigureTsConfigForESM: () => tryConfigureTsConfigForESM,
|
|
35
|
-
updatePackageJson: () => updatePackageJson
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(configureTsConfigForESM_exports);
|
|
38
|
-
var import_path = __toESM(require("path"));
|
|
39
|
-
var import_util = require("util");
|
|
40
|
-
var import_fast_glob = require("fast-glob");
|
|
41
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
42
|
-
var import_typescript = __toESM(require("typescript"));
|
|
43
|
-
var z = __toESM(require("zod"));
|
|
44
|
-
var import__ = require("../../../../../../index.js");
|
|
45
|
-
var import_logging = require("../../../../../../utils/logging.js");
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { inspect } from "util";
|
|
4
|
+
import { glob } from "fast-glob";
|
|
5
|
+
import fs from "fs-extra";
|
|
6
|
+
import ts from "typescript";
|
|
7
|
+
import * as z from "zod";
|
|
8
|
+
import { Git } from "../../../../../../index.js";
|
|
9
|
+
import { log } from "../../../../../../utils/logging.js";
|
|
46
10
|
const packageJsonSchema = z.looseObject({
|
|
47
11
|
imports: z.record(z.string(), z.record(z.string(), z.string())).optional()
|
|
48
12
|
});
|
|
@@ -54,12 +18,12 @@ const tsConfigSchema = z.looseObject({
|
|
|
54
18
|
}).optional()
|
|
55
19
|
});
|
|
56
20
|
const fetchFiles = async (patterns) => {
|
|
57
|
-
const files = await
|
|
21
|
+
const files = await glob(patterns, {
|
|
58
22
|
ignore: ["**/.git", "**/node_modules"]
|
|
59
23
|
});
|
|
60
24
|
return Promise.all(
|
|
61
25
|
files.map(async (file) => {
|
|
62
|
-
const contents = await
|
|
26
|
+
const contents = await fs.promises.readFile(file, "utf8");
|
|
63
27
|
return {
|
|
64
28
|
file,
|
|
65
29
|
contents
|
|
@@ -67,7 +31,7 @@ const fetchFiles = async (patterns) => {
|
|
|
67
31
|
})
|
|
68
32
|
);
|
|
69
33
|
};
|
|
70
|
-
const addJestModuleNameMapper = (contents, srcPaths) => {
|
|
34
|
+
export const addJestModuleNameMapper = (contents, srcPaths) => {
|
|
71
35
|
if (!srcPaths.length) {
|
|
72
36
|
return contents;
|
|
73
37
|
}
|
|
@@ -114,12 +78,12 @@ const addJestModuleNameMapper = (contents, srcPaths) => {
|
|
|
114
78
|
const newContents = contents.slice(0, insertionIndex) + moduleNameMapperString + contents.slice(insertionIndex);
|
|
115
79
|
return newContents;
|
|
116
80
|
}
|
|
117
|
-
|
|
81
|
+
log.warn(
|
|
118
82
|
"Could not find a suitable place to insert moduleNameMapper in jest config"
|
|
119
83
|
);
|
|
120
84
|
return contents;
|
|
121
85
|
};
|
|
122
|
-
const parsePackageJson = (contents) => {
|
|
86
|
+
export const parsePackageJson = (contents) => {
|
|
123
87
|
try {
|
|
124
88
|
const parsedJson = JSON.parse(contents);
|
|
125
89
|
return {
|
|
@@ -127,11 +91,11 @@ const parsePackageJson = (contents) => {
|
|
|
127
91
|
parsed: packageJsonSchema.parse(parsedJson)
|
|
128
92
|
};
|
|
129
93
|
} catch (error) {
|
|
130
|
-
|
|
94
|
+
log.warn(`Failed to parse package.json as JSON: ${String(error)}`);
|
|
131
95
|
return null;
|
|
132
96
|
}
|
|
133
97
|
};
|
|
134
|
-
const updatePackageJson = ({
|
|
98
|
+
export const updatePackageJson = ({
|
|
135
99
|
parsed,
|
|
136
100
|
customCondition
|
|
137
101
|
}) => {
|
|
@@ -146,7 +110,7 @@ const updatePackageJson = ({
|
|
|
146
110
|
};
|
|
147
111
|
const parseTsconfig = (file, contents) => {
|
|
148
112
|
try {
|
|
149
|
-
const parsedJson =
|
|
113
|
+
const parsedJson = ts.parseConfigFileTextToJson(file, contents);
|
|
150
114
|
const tsconfig = tsConfigSchema.parse(parsedJson.config);
|
|
151
115
|
return {
|
|
152
116
|
original: parsedJson.config,
|
|
@@ -154,7 +118,7 @@ const parseTsconfig = (file, contents) => {
|
|
|
154
118
|
srcPaths: tsconfig.compilerOptions?.paths?.["./src/*"] ?? []
|
|
155
119
|
};
|
|
156
120
|
} catch (error) {
|
|
157
|
-
|
|
121
|
+
log.warn(`Failed to parse root tsconfig.json as JSON: ${String(error)}`);
|
|
158
122
|
return null;
|
|
159
123
|
}
|
|
160
124
|
};
|
|
@@ -190,12 +154,12 @@ const updateTsConfig = ({
|
|
|
190
154
|
srcPaths
|
|
191
155
|
};
|
|
192
156
|
};
|
|
193
|
-
const tryConfigureTsConfigForESM = async ({
|
|
157
|
+
export const tryConfigureTsConfigForESM = async ({
|
|
194
158
|
mode
|
|
195
159
|
}) => {
|
|
196
160
|
let customCondition;
|
|
197
161
|
try {
|
|
198
|
-
const { repo } = await
|
|
162
|
+
const { repo } = await Git.getOwnerAndRepo({ dir: process.cwd() });
|
|
199
163
|
customCondition = `@seek/${repo}/source`;
|
|
200
164
|
} catch {
|
|
201
165
|
return { result: "skip", reason: "no repository name found" };
|
|
@@ -238,10 +202,10 @@ const tryConfigureTsConfigForESM = async ({
|
|
|
238
202
|
const match = regex.exec(p);
|
|
239
203
|
if (match?.[1] !== void 0) {
|
|
240
204
|
return [
|
|
241
|
-
|
|
205
|
+
path.join(path.dirname(file), match[1].replace(/\/?$/, ""))
|
|
242
206
|
];
|
|
243
207
|
}
|
|
244
|
-
|
|
208
|
+
log.warn(
|
|
245
209
|
`Unexpected src path format in ${file}: ${p}. Expected format like "apps/api/src/*"`
|
|
246
210
|
);
|
|
247
211
|
return [];
|
|
@@ -253,7 +217,7 @@ const tryConfigureTsConfigForESM = async ({
|
|
|
253
217
|
return { result: "skip", reason: "no src paths found" };
|
|
254
218
|
}
|
|
255
219
|
const packageJsonPatterns = allSrcPaths.map(
|
|
256
|
-
(srcPath) =>
|
|
220
|
+
(srcPath) => path.join(srcPath, "package.json")
|
|
257
221
|
);
|
|
258
222
|
const packageJsonFiles = await fetchFiles(packageJsonPatterns);
|
|
259
223
|
const parsedPackageJsonFiles = packageJsonFiles.flatMap(
|
|
@@ -264,7 +228,7 @@ const tryConfigureTsConfigForESM = async ({
|
|
|
264
228
|
);
|
|
265
229
|
parsedPackageJsonFiles.forEach(({ parsed, file }) => {
|
|
266
230
|
updatePackageJson({ parsed, customCondition });
|
|
267
|
-
const relativeTsconfigPath =
|
|
231
|
+
const relativeTsconfigPath = path.join(path.dirname(file), "tsconfig.json");
|
|
268
232
|
const relativeTsconfig = updatedTsconfigFiles.find(
|
|
269
233
|
(tsconfig) => tsconfig.file === relativeTsconfigPath
|
|
270
234
|
);
|
|
@@ -272,12 +236,12 @@ const tryConfigureTsConfigForESM = async ({
|
|
|
272
236
|
relativeTsconfig.parsed.compilerOptions ??= {};
|
|
273
237
|
relativeTsconfig.parsed.compilerOptions.rootDir ??= ".";
|
|
274
238
|
} else {
|
|
275
|
-
|
|
239
|
+
log.warn(
|
|
276
240
|
`No corresponding tsconfig.json found for package.json at ${file}. Expected at ${relativeTsconfigPath}`
|
|
277
241
|
);
|
|
278
242
|
}
|
|
279
|
-
const relativeTsconfigBuildPath =
|
|
280
|
-
|
|
243
|
+
const relativeTsconfigBuildPath = path.join(
|
|
244
|
+
path.dirname(file),
|
|
281
245
|
"tsconfig.build.json"
|
|
282
246
|
);
|
|
283
247
|
const relativeTsconfigBuild = parsedTsconfigBuildFiles.find(
|
|
@@ -287,7 +251,7 @@ const tryConfigureTsConfigForESM = async ({
|
|
|
287
251
|
relativeTsconfigBuild.parsed.compilerOptions ??= {};
|
|
288
252
|
relativeTsconfigBuild.parsed.compilerOptions.rootDir ??= "src";
|
|
289
253
|
} else {
|
|
290
|
-
|
|
254
|
+
log.warn(
|
|
291
255
|
`No corresponding tsconfig.build.json found for package.json at ${file}. Expected at ${relativeTsconfigBuildPath}`
|
|
292
256
|
);
|
|
293
257
|
}
|
|
@@ -324,7 +288,7 @@ const tryConfigureTsConfigForESM = async ({
|
|
|
324
288
|
return;
|
|
325
289
|
}
|
|
326
290
|
const updatedContents = JSON.stringify(parsed, null, 2);
|
|
327
|
-
await
|
|
291
|
+
await fs.promises.writeFile(file, updatedContents);
|
|
328
292
|
})
|
|
329
293
|
);
|
|
330
294
|
const otherFilePromises = Promise.all(
|
|
@@ -332,27 +296,19 @@ const tryConfigureTsConfigForESM = async ({
|
|
|
332
296
|
if (original === parsed) {
|
|
333
297
|
return;
|
|
334
298
|
}
|
|
335
|
-
await
|
|
299
|
+
await fs.promises.writeFile(file, parsed);
|
|
336
300
|
})
|
|
337
301
|
);
|
|
338
302
|
await Promise.all([jsonFilePromises, otherFilePromises]);
|
|
339
303
|
return { result: "apply" };
|
|
340
304
|
};
|
|
341
|
-
const configureTsConfigForESM = async (config) => {
|
|
305
|
+
export const configureTsConfigForESM = async (config) => {
|
|
342
306
|
try {
|
|
343
307
|
return await tryConfigureTsConfigForESM(config);
|
|
344
308
|
} catch (err) {
|
|
345
|
-
|
|
346
|
-
|
|
309
|
+
log.warn("Failed to write configure `tsconfig.json` and `package.json`");
|
|
310
|
+
log.subtle(inspect(err));
|
|
347
311
|
return { result: "skip", reason: "due to an error" };
|
|
348
312
|
}
|
|
349
313
|
};
|
|
350
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
351
|
-
0 && (module.exports = {
|
|
352
|
-
addJestModuleNameMapper,
|
|
353
|
-
configureTsConfigForESM,
|
|
354
|
-
parsePackageJson,
|
|
355
|
-
tryConfigureTsConfigForESM,
|
|
356
|
-
updatePackageJson
|
|
357
|
-
});
|
|
358
314
|
//# sourceMappingURL=configureTsConfigForESM.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\nimport ts from 'typescript';\nimport * as z from 'zod';\n\nimport { Git } from '../../../../../../index.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst packageJsonSchema = z.looseObject({\n imports: z.record(z.string(), z.record(z.string(), z.string())).optional(),\n});\n\ntype PackageJson = z.infer<typeof packageJsonSchema>;\n\nconst tsConfigSchema = z.looseObject({\n compilerOptions: z\n .looseObject({\n customConditions: z.array(z.string()).optional(),\n rootDir: z.string().optional(),\n paths: z\n .record(z.string(), z.union([z.array(z.string()), z.null()]))\n .optional(),\n })\n .optional(),\n});\n\ntype TsConfig = z.infer<typeof tsConfigSchema>;\n\nconst fetchFiles = async (patterns: string[]) => {\n const files = await glob(patterns, {\n ignore: ['**/.git', '**/node_modules'],\n });\n\n return 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\nexport const addJestModuleNameMapper = (\n contents: string,\n srcPaths: string[],\n) => {\n if (!srcPaths.length) {\n return contents;\n }\n const moduleNameRegex = /moduleNameMapper:\\s*\\{([\\s\\S]*?)\\}/;\n const match = moduleNameRegex.exec(contents);\n\n const srcPathArray = srcPaths.map((subfolderPath) =>\n subfolderPath === '.' || subfolderPath === './'\n ? '<rootDir>/src/$1'\n : `<rootDir>/${subfolderPath}/src/$1`,\n );\n\n const srcModuleMappers = JSON.stringify({\n '^#src/(.*)\\\\.js$': srcPathArray,\n '^#src/(.*)$': srcPathArray,\n });\n\n // strip the surrounding { } from the JSON stringify result\n const newModuleNameMapper = srcModuleMappers\n .replace(/^{/, '')\n .replace(/}$/, '');\n\n if (match?.[1] !== undefined) {\n // insert srcModuleMappers into existing moduleNameMapper\n const existingModuleMappers = match[1];\n\n const optionalComma = !/[,\\s]*$/.test(existingModuleMappers) ? '' : ',';\n const newContents = `${contents.slice(\n 0,\n match.index,\n )}moduleNameMapper: {${existingModuleMappers}${optionalComma}${newModuleNameMapper}}${contents.slice(\n match.index + match[0].length,\n )}`;\n\n return newContents;\n }\n\n // match against function calls\n\n // Match function calls like moduleNameMapper: getMapper()\n const moduleNameMapperFunctionRegex =\n /moduleNameMapper:\\s*([a-zA-Z_$][\\w$]*(?:\\([^)]*\\))?)/;\n const functionMatch = moduleNameMapperFunctionRegex.exec(contents);\n\n if (functionMatch?.[1] !== undefined) {\n const functionBody = functionMatch[1];\n const optionalComma = !/[,\\s]*$/.test(functionBody) ? '' : ',';\n const newContents = `${contents.slice(\n 0,\n functionMatch.index,\n )}moduleNameMapper: {...${functionBody}${optionalComma}${newModuleNameMapper}}${contents.slice(\n functionMatch.index + functionMatch[0].length,\n )}}`;\n\n return newContents;\n }\n\n // Add moduleNameMapper if not present\n\n const insertionPointRegex = /(\\b(jest|export\\s+default)\\b[\\s\\S]*?{)/;\n const insertionMatch = insertionPointRegex.exec(contents);\n\n if (insertionMatch?.[1] !== undefined) {\n const insertionIndex = insertionMatch.index + insertionMatch[0].length;\n const moduleNameMapperString = `\\n moduleNameMapper: {${newModuleNameMapper}},`;\n\n const newContents =\n contents.slice(0, insertionIndex) +\n moduleNameMapperString +\n contents.slice(insertionIndex);\n\n return newContents;\n }\n\n log.warn(\n 'Could not find a suitable place to insert moduleNameMapper in jest config',\n );\n return contents;\n};\n\nexport const parsePackageJson = (\n contents: string,\n): {\n original: PackageJson;\n parsed: PackageJson;\n} | null => {\n try {\n const parsedJson: unknown = JSON.parse(contents);\n return {\n original: parsedJson as PackageJson,\n parsed: packageJsonSchema.parse(parsedJson),\n };\n } catch (error) {\n log.warn(`Failed to parse package.json as JSON: ${String(error)}`);\n return null;\n }\n};\n\nexport const updatePackageJson = ({\n parsed,\n customCondition,\n}: {\n parsed: PackageJson;\n customCondition: string;\n}) => {\n parsed.imports ??= {};\n parsed.imports['#src/*'] ??= {\n [customCondition]: './src/*',\n default: './lib/*',\n };\n\n return {\n parsed,\n };\n};\n\nconst parseTsconfig = (\n file: string,\n contents: string,\n): {\n original: TsConfig;\n parsed: TsConfig;\n srcPaths: string[];\n} | null => {\n try {\n const parsedJson = ts.parseConfigFileTextToJson(file, contents);\n const tsconfig = tsConfigSchema.parse(parsedJson.config);\n\n return {\n original: parsedJson.config as TsConfig,\n parsed: tsconfig,\n srcPaths: tsconfig.compilerOptions?.paths?.['./src/*'] ?? [],\n };\n } catch (error) {\n log.warn(`Failed to parse root tsconfig.json as JSON: ${String(error)}`);\n return null;\n }\n};\n\nconst updateTsConfig = ({\n parsed,\n customCondition,\n file,\n}: {\n parsed: TsConfig;\n customCondition: string;\n file: string;\n}) => {\n if (file === 'tsconfig.json') {\n parsed.compilerOptions ??= {};\n parsed.compilerOptions.customConditions ??= [];\n\n if (\n parsed.compilerOptions.customConditions.includes(customCondition) &&\n customCondition !== '@seek/skuba/source'\n ) {\n throw new Error(\n `Custom condition ${customCondition} already exists in tsconfig.json`,\n );\n }\n\n if (!parsed.compilerOptions.customConditions.includes(customCondition)) {\n parsed.compilerOptions.customConditions.push(customCondition);\n }\n }\n\n let srcPaths: string[] = [];\n ['./src/*', 'src/*', 'src'].forEach((key) => {\n if (parsed.compilerOptions?.paths?.[key]) {\n srcPaths = parsed.compilerOptions.paths[key];\n delete parsed.compilerOptions.paths[key];\n }\n });\n\n if (\n parsed.compilerOptions?.paths &&\n Object.keys(parsed.compilerOptions.paths).length === 0\n ) {\n delete parsed.compilerOptions.paths;\n }\n\n return {\n parsed,\n srcPaths,\n };\n};\n\nexport const tryConfigureTsConfigForESM: 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 tsconfigJsonPatterns = ['**/tsconfig.json'];\n const tsconfigBuildJsonPatterns = ['**/tsconfig.build.json'];\n const jestConfigPatterns = ['**/jest.config.ts', '**/jest.config.*.ts'];\n\n const [tsconfigJsonFiles, tsconfigBuildJsonFiles, jestConfigFiles] =\n await Promise.all([\n fetchFiles(tsconfigJsonPatterns),\n fetchFiles(tsconfigBuildJsonPatterns),\n fetchFiles(jestConfigPatterns),\n ]);\n\n const parsedTsconfigFiles = tsconfigJsonFiles.flatMap(\n ({ file, contents }) => {\n const parsed = parseTsconfig(file, contents);\n return parsed ? [{ file, ...parsed }] : [];\n },\n );\n\n const parsedTsconfigBuildFiles = tsconfigBuildJsonFiles.flatMap(\n ({ file, contents }) => {\n const parsed = parseTsconfig(file, contents);\n return parsed ? [{ file, ...parsed }] : [];\n },\n );\n\n if (parsedTsconfigFiles.length === 0) {\n return { result: 'skip', reason: 'no valid tsconfig.json files found' };\n }\n\n const updatedTsconfigFiles = parsedTsconfigFiles.map(\n ({ file, parsed, original }) => ({\n file,\n original,\n ...updateTsConfig({ parsed, customCondition, file }),\n }),\n );\n\n const allSrcPaths = [\n ...new Set(\n updatedTsconfigFiles.flatMap(({ srcPaths, file }) =>\n srcPaths.flatMap((p) => {\n const regex = /(.*)src\\/?\\*?$/;\n const match = regex.exec(p);\n if (match?.[1] !== undefined) {\n return [\n path.join(path.dirname(file), match[1].replace(/\\/?$/, '')),\n ];\n }\n\n log.warn(\n `Unexpected src path format in ${file}: ${p}. Expected format like \"apps/api/src/*\"`,\n );\n return [];\n }),\n ),\n ),\n ];\n\n if (!allSrcPaths.length) {\n return { result: 'skip', reason: 'no src paths found' };\n }\n\n // Fetch all package.json paths which may be in allSrcPaths\n const packageJsonPatterns = allSrcPaths.map((srcPath) =>\n path.join(srcPath, 'package.json'),\n );\n\n const packageJsonFiles = await fetchFiles(packageJsonPatterns);\n\n const parsedPackageJsonFiles = packageJsonFiles.flatMap(\n ({ file, contents }) => {\n const parsed = parsePackageJson(contents);\n return parsed ? [{ file, ...parsed }] : [];\n },\n );\n\n parsedPackageJsonFiles.forEach(({ parsed, file }) => {\n updatePackageJson({ parsed, customCondition });\n\n const relativeTsconfigPath = path.join(path.dirname(file), 'tsconfig.json');\n\n const relativeTsconfig = updatedTsconfigFiles.find(\n (tsconfig) => tsconfig.file === relativeTsconfigPath,\n );\n\n if (relativeTsconfig) {\n relativeTsconfig.parsed.compilerOptions ??= {};\n relativeTsconfig.parsed.compilerOptions.rootDir ??= '.';\n } else {\n log.warn(\n `No corresponding tsconfig.json found for package.json at ${file}. Expected at ${relativeTsconfigPath}`,\n );\n }\n\n const relativeTsconfigBuildPath = path.join(\n path.dirname(file),\n 'tsconfig.build.json',\n );\n\n const relativeTsconfigBuild = parsedTsconfigBuildFiles.find(\n (tsconfig) => tsconfig.file === relativeTsconfigBuildPath,\n );\n\n if (relativeTsconfigBuild) {\n relativeTsconfigBuild.parsed.compilerOptions ??= {};\n relativeTsconfigBuild.parsed.compilerOptions.rootDir ??= 'src';\n } else {\n log.warn(\n `No corresponding tsconfig.build.json found for package.json at ${file}. Expected at ${relativeTsconfigBuildPath}`,\n );\n }\n });\n\n const updatedJestConfigFiles = jestConfigFiles.map(({ file, contents }) => {\n const parsed = addJestModuleNameMapper(contents, allSrcPaths);\n return { file, original: contents, parsed };\n });\n\n const hasJestConfigsChanged = updatedJestConfigFiles.some(\n ({ parsed, original }) => original !== parsed,\n );\n\n const hasRelativeTsconfigBuildsChanged = parsedTsconfigBuildFiles.some(\n ({ original, parsed }) =>\n JSON.stringify(original) !== JSON.stringify(parsed),\n );\n\n const hasPackageJsonsChanged = parsedPackageJsonFiles.some(\n ({ original, parsed }) =>\n JSON.stringify(original) !== JSON.stringify(parsed),\n );\n\n const hasRootTsconfigChanged = updatedTsconfigFiles.some(\n ({ original, parsed }) =>\n JSON.stringify(original) !== JSON.stringify(parsed),\n );\n\n if (\n mode === 'lint' &&\n (hasRootTsconfigChanged ||\n hasPackageJsonsChanged ||\n hasRelativeTsconfigBuildsChanged ||\n hasJestConfigsChanged)\n ) {\n return { result: 'apply' };\n }\n\n if (\n !hasRootTsconfigChanged &&\n !hasPackageJsonsChanged &&\n !hasRelativeTsconfigBuildsChanged &&\n !hasJestConfigsChanged\n ) {\n return { result: 'skip', reason: 'no changes required' };\n }\n\n const jsonFilePromises = Promise.all(\n [\n ...updatedTsconfigFiles,\n ...parsedTsconfigBuildFiles,\n ...parsedPackageJsonFiles,\n ].map(async ({ file, parsed, original }) => {\n if (JSON.stringify(original) === JSON.stringify(parsed)) {\n return;\n }\n const updatedContents = JSON.stringify(parsed, null, 2);\n await fs.promises.writeFile(file, updatedContents);\n }),\n );\n\n const otherFilePromises = Promise.all(\n updatedJestConfigFiles.map(async ({ file, parsed, original }) => {\n if (original === parsed) {\n return;\n }\n await fs.promises.writeFile(file, parsed);\n }),\n );\n\n await Promise.all([jsonFilePromises, otherFilePromises]);\n\n return { result: 'apply' };\n};\n\nexport const configureTsConfigForESM: PatchFunction = async (config) => {\n try {\n return await tryConfigureTsConfigForESM(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,OAAO,UAAU;AACjB,SAAS,eAAe;AAExB,SAAS,YAAY;AACrB,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,YAAY,OAAO;AAEnB,SAAS,WAAW;AACpB,SAAS,WAAW;AAGpB,MAAM,oBAAoB,EAAE,YAAY;AAAA,EACtC,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAC3E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
|
-
|
|
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_configureTsConfigForESM = require("./configureTsConfigForESM.js");
|
|
25
|
-
var import_patchApiDockerfiles = require("./patchApiDockerfiles.js");
|
|
26
|
-
var import_rewriteSrcImports = require("./rewriteSrcImports.js");
|
|
27
|
-
var import_updateLambdaConfigs = require("./updateLambdaConfigs.js");
|
|
28
|
-
const patches = [
|
|
2
|
+
import { configureTsConfigForESM } from "./configureTsConfigForESM.js";
|
|
3
|
+
import { patchApiDockerfiles } from "./patchApiDockerfiles.js";
|
|
4
|
+
import { rewriteSrcImports } from "./rewriteSrcImports.js";
|
|
5
|
+
import { updateLambdaConfigs } from "./updateLambdaConfigs.js";
|
|
6
|
+
export const patches = [
|
|
29
7
|
{
|
|
30
|
-
apply:
|
|
8
|
+
apply: rewriteSrcImports,
|
|
31
9
|
description: "Rewrite all 'src' imports to be '#src'"
|
|
32
10
|
},
|
|
33
11
|
{
|
|
34
|
-
apply:
|
|
12
|
+
apply: configureTsConfigForESM,
|
|
35
13
|
description: "Configure `tsconfig.json`, `package.json` and `jest.config.ts` to support custom conditions"
|
|
36
14
|
},
|
|
37
15
|
{
|
|
38
|
-
apply:
|
|
16
|
+
apply: updateLambdaConfigs,
|
|
39
17
|
description: "Update lambda function configurations to support custom conditions"
|
|
40
18
|
},
|
|
41
19
|
{
|
|
42
|
-
apply:
|
|
20
|
+
apply: patchApiDockerfiles,
|
|
43
21
|
description: "Patch Dockerfiles to copy `package.json`"
|
|
44
22
|
}
|
|
45
23
|
];
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
patches
|
|
49
|
-
});
|
|
50
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { configureTsConfigForESM } from './configureTsConfigForESM.js';\nimport { patchApiDockerfiles } from './patchApiDockerfiles.js';\nimport { rewriteSrcImports } from './rewriteSrcImports.js';\nimport { updateLambdaConfigs } from './updateLambdaConfigs.js';\n\nexport const patches: Patches = [\n {\n apply: rewriteSrcImports,\n description: \"Rewrite all 'src' imports to be '#src'\",\n },\n {\n apply: configureTsConfigForESM,\n description:\n 'Configure `tsconfig.json`, `package.json` and `jest.config.ts` to support custom conditions',\n },\n {\n apply: updateLambdaConfigs,\n description:\n 'Update lambda function configurations to support custom conditions',\n },\n {\n apply: patchApiDockerfiles,\n description: 'Patch Dockerfiles to copy `package.json`',\n },\n];\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAEA,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AAE7B,aAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,43 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
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 patchApiDockerfiles_exports = {};
|
|
30
|
-
__export(patchApiDockerfiles_exports, {
|
|
31
|
-
patchApiDockerfiles: () => patchApiDockerfiles
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(patchApiDockerfiles_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_logging = require("../../../../../../utils/logging.js");
|
|
2
|
+
import { inspect } from "util";
|
|
3
|
+
import { glob } from "fast-glob";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { log } from "../../../../../../utils/logging.js";
|
|
38
6
|
const fetchFiles = async (files) => Promise.all(
|
|
39
7
|
files.map(async (file) => {
|
|
40
|
-
const contents = await
|
|
8
|
+
const contents = await fs.promises.readFile(file, "utf8");
|
|
41
9
|
return {
|
|
42
10
|
file,
|
|
43
11
|
contents
|
|
@@ -94,7 +62,7 @@ ${packageJsonCopyLine}`
|
|
|
94
62
|
return newContents;
|
|
95
63
|
};
|
|
96
64
|
const tryPatchApiDockerfiles = async (config) => {
|
|
97
|
-
const dockerfilePaths = await
|
|
65
|
+
const dockerfilePaths = await glob(["**/Dockerfile*"], {
|
|
98
66
|
ignore: ["**/.git", "**/node_modules"]
|
|
99
67
|
});
|
|
100
68
|
if (dockerfilePaths.length === 0) {
|
|
@@ -129,24 +97,20 @@ const tryPatchApiDockerfiles = async (config) => {
|
|
|
129
97
|
}
|
|
130
98
|
await Promise.all(
|
|
131
99
|
dockerFilesToPatch.map(
|
|
132
|
-
({ file, contents }) =>
|
|
100
|
+
({ file, contents }) => fs.promises.writeFile(file, contents, "utf8")
|
|
133
101
|
)
|
|
134
102
|
);
|
|
135
103
|
return {
|
|
136
104
|
result: "apply"
|
|
137
105
|
};
|
|
138
106
|
};
|
|
139
|
-
const patchApiDockerfiles = async (config) => {
|
|
107
|
+
export const patchApiDockerfiles = async (config) => {
|
|
140
108
|
try {
|
|
141
109
|
return await tryPatchApiDockerfiles(config);
|
|
142
110
|
} catch (err) {
|
|
143
|
-
|
|
144
|
-
|
|
111
|
+
log.warn("Failed to patch API dockerfiles");
|
|
112
|
+
log.subtle(inspect(err));
|
|
145
113
|
return { result: "skip", reason: "due to an error" };
|
|
146
114
|
}
|
|
147
115
|
};
|
|
148
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
-
0 && (module.exports = {
|
|
150
|
-
patchApiDockerfiles
|
|
151
|
-
});
|
|
152
116
|
//# sourceMappingURL=patchApiDockerfiles.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.ts"],
|
|
4
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 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\nconst applyDockerfilePatch = (contents: string) => {\n const cmdLineRegex = /CMD\\s+\\[.*?\\]/ms;\n const cmdLineMatch = cmdLineRegex.exec(contents);\n const cmdLine = cmdLineMatch?.[0];\n\n if (!cmdLine) {\n return undefined;\n }\n\n // Extract the lib path from CMD line\n // Match patterns like \"./lib/\", \"apps/api/lib/\", \"lib/\"\n const libPathRegex = /\"([^\"]*\\/)?lib\\/[^\"]*\"/;\n const libPathMatch = libPathRegex.exec(cmdLine);\n\n if (!libPathMatch) {\n return undefined;\n }\n\n const fullPath = libPathMatch[1] || './';\n const libParentPath = fullPath.endsWith('/')\n ? fullPath.slice(0, -1)\n : fullPath;\n\n // If the path is empty or just './', the lib is in current directory\n const normalizedPath =\n libParentPath === '.' || libParentPath === '' ? '.' : libParentPath;\n\n // Try to find COPY with --from first\n const copyNodeModulesWithFromRegex =\n /^\\s*COPY\\s+--from=(\\S+)\\s+.*node_modules.*$/m;\n const copyNodeModulesWithFromMatch =\n copyNodeModulesWithFromRegex.exec(contents);\n\n // If no --from, try to find COPY without --from\n const copyNodeModulesWithoutFromRegex =\n /^\\s*COPY\\s+(?!--from).*node_modules.*$/m;\n const copyNodeModulesWithoutFromMatch =\n copyNodeModulesWithoutFromRegex.exec(contents);\n\n const copyNodeModulesMatch =\n copyNodeModulesWithFromMatch ?? copyNodeModulesWithoutFromMatch;\n const copyNodeModulesLine = copyNodeModulesMatch?.[0];\n const fromSource = copyNodeModulesWithFromMatch?.[1];\n\n if (!copyNodeModulesLine) {\n return undefined;\n }\n\n // Check if package.json is already being copied for this path\n const packageJsonPattern = normalizedPath === '.' ? '' : `${normalizedPath}/`;\n const packageJsonCopyPattern = fromSource\n ? new RegExp(\n `^\\\\s*COPY\\\\s+--from=${fromSource}\\\\s+.*${packageJsonPattern}package\\\\.json`,\n 'm',\n )\n : new RegExp(\n `^\\\\s*COPY\\\\s+(?!--from).*${packageJsonPattern}package\\\\.json`,\n 'm',\n );\n\n if (packageJsonCopyPattern.test(contents)) {\n return undefined;\n }\n\n let packageJsonCopyLine: string;\n if (fromSource) {\n packageJsonCopyLine =\n normalizedPath === '.'\n ? `COPY --from=${fromSource} /workdir/package.json package.json`\n : `COPY --from=${fromSource} /workdir/${normalizedPath}/package.json ${normalizedPath}/package.json`;\n } else {\n packageJsonCopyLine =\n normalizedPath === '.'\n ? 'COPY package.json package.json'\n : `COPY ${normalizedPath}/package.json ${normalizedPath}/package.json`;\n }\n\n const newContents = contents.replace(\n copyNodeModulesLine,\n `${copyNodeModulesLine}\\n${packageJsonCopyLine}`,\n );\n\n return newContents;\n};\n\nconst tryPatchApiDockerfiles = async (config: {\n mode: 'lint' | 'format';\n}): Promise<PatchReturnType> => {\n const dockerfilePaths = await glob(['**/Dockerfile*'], {\n ignore: ['**/.git', '**/node_modules'],\n });\n\n if (dockerfilePaths.length === 0) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles found',\n };\n }\n\n const dockerfiles = await fetchFiles(dockerfilePaths);\n\n const dockerFilesToPatch = dockerfiles.flatMap(({ file, contents }) => {\n const newContents = applyDockerfilePatch(contents);\n if (!newContents || newContents === contents) {\n return [];\n }\n\n return [\n {\n file,\n contents: newContents,\n },\n ];\n });\n\n if (dockerFilesToPatch.length === 0) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles to patch',\n };\n }\n\n if (config.mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n dockerFilesToPatch.map(({ file, contents }) =>\n fs.promises.writeFile(file, contents, 'utf8'),\n ),\n );\n\n return {\n result: 'apply',\n };\n};\n\nexport const patchApiDockerfiles: PatchFunction = async (config) => {\n try {\n return await tryPatchApiDockerfiles(config);\n } catch (err) {\n log.warn('Failed to patch API dockerfiles');\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;AAGpB,MAAM,aAAa,OAAO,UACxB,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;AAEF,MAAM,uBAAuB,CAAC,aAAqB;AACjD,QAAM,eAAe;AACrB,QAAM,eAAe,aAAa,KAAK,QAAQ;AAC/C,QAAM,UAAU,eAAe,CAAC;AAEhC,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAIA,QAAM,eAAe;AACrB,QAAM,eAAe,aAAa,KAAK,OAAO;AAE9C,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,aAAa,CAAC,KAAK;AACpC,QAAM,gBAAgB,SAAS,SAAS,GAAG,IACvC,SAAS,MAAM,GAAG,EAAE,IACpB;AAGJ,QAAM,iBACJ,kBAAkB,OAAO,kBAAkB,KAAK,MAAM;A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