skuba 14.0.0-replace-global-vars-20251121010036 → 14.0.0-test-private-templates-20260103062459
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/eslint.js +1 -1
- package/config/jest.js +1 -0
- package/config/prettier.d.ts +4 -8
- package/config/prettier.js +2 -10
- package/jest/moduleNameMapper.js +64 -0
- package/jest/transform.js +62 -0
- package/jest/tsConfig.js +26 -0
- package/jest-preset.js +37 -0
- package/lib/api/jest/index.d.ts +15 -0
- package/lib/api/jest/index.js +59 -0
- package/lib/api/jest/index.js.map +7 -0
- package/lib/cli/adapter/eslint.js +45 -11
- package/lib/cli/adapter/eslint.js.map +2 -2
- package/lib/cli/adapter/prettier.js +67 -39
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/args.js +42 -8
- package/lib/cli/build/args.js.map +2 -2
- package/lib/cli/build/assets.js +60 -28
- package/lib/cli/build/assets.js.map +2 -2
- package/lib/cli/build/esbuild.js +45 -21
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/build/index.js +45 -21
- package/lib/cli/build/index.js.map +1 -1
- package/lib/cli/build/tsc.js +59 -22
- package/lib/cli/build/tsc.js.map +2 -2
- package/lib/cli/buildPackage/index.js +32 -8
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/analyseConfiguration.js +50 -16
- package/lib/cli/configure/analyseConfiguration.js.map +2 -2
- package/lib/cli/configure/analyseDependencies.d.ts +1 -1
- package/lib/cli/configure/analyseDependencies.js +59 -25
- package/lib/cli/configure/analyseDependencies.js.map +3 -3
- package/lib/cli/configure/analysis/diff.js +29 -5
- package/lib/cli/configure/analysis/diff.js.map +1 -1
- package/lib/cli/configure/analysis/files.js +42 -8
- package/lib/cli/configure/analysis/files.js.map +2 -2
- package/lib/cli/configure/analysis/git.js +46 -12
- package/lib/cli/configure/analysis/git.js.map +2 -2
- package/lib/cli/configure/analysis/package.d.ts +3 -2
- package/lib/cli/configure/analysis/package.js +45 -10
- package/lib/cli/configure/analysis/package.js.map +3 -3
- package/lib/cli/configure/analysis/project.js +50 -18
- package/lib/cli/configure/analysis/project.js.map +2 -2
- package/lib/cli/configure/dependencies/index.js +35 -7
- package/lib/cli/configure/dependencies/index.js.map +1 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +28 -4
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
- package/lib/cli/configure/dependencies/seekKoala.js +28 -4
- package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
- package/lib/cli/configure/dependencies/skuba.js +28 -4
- package/lib/cli/configure/dependencies/skuba.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +26 -2
- package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDive.js +29 -4
- package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +61 -33
- package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
- package/lib/cli/configure/getEntryPoint.d.ts +1 -1
- package/lib/cli/configure/getEntryPoint.js +48 -14
- package/lib/cli/configure/getEntryPoint.js.map +3 -3
- package/lib/cli/configure/getProjectType.d.ts +1 -1
- package/lib/cli/configure/getProjectType.js +35 -14
- package/lib/cli/configure/getProjectType.js.map +2 -2
- package/lib/cli/configure/index.js +84 -50
- package/lib/cli/configure/index.js.map +2 -2
- package/lib/cli/configure/modules/eslint.js +34 -10
- package/lib/cli/configure/modules/eslint.js.map +1 -1
- package/lib/cli/configure/modules/ignore.js +32 -8
- package/lib/cli/configure/modules/ignore.js.map +1 -1
- package/lib/cli/configure/modules/index.js +44 -18
- package/lib/cli/configure/modules/index.js.map +2 -2
- package/lib/cli/configure/modules/jest.d.ts +2 -0
- package/lib/cli/configure/modules/jest.js +86 -0
- package/lib/cli/configure/modules/jest.js.map +7 -0
- package/lib/cli/configure/modules/nodemon.js +28 -4
- package/lib/cli/configure/modules/nodemon.js.map +1 -1
- package/lib/cli/configure/modules/package.js +34 -10
- package/lib/cli/configure/modules/package.js.map +1 -1
- package/lib/cli/configure/modules/prettier.js +35 -11
- package/lib/cli/configure/modules/prettier.js.map +1 -1
- package/lib/cli/configure/modules/renovate.js +40 -17
- package/lib/cli/configure/modules/renovate.js.map +2 -2
- package/lib/cli/configure/modules/serverless.js +26 -2
- package/lib/cli/configure/modules/serverless.js.map +1 -1
- package/lib/cli/configure/modules/tslint.js +28 -4
- package/lib/cli/configure/modules/tslint.js.map +1 -1
- package/lib/cli/configure/processing/configFile.js +39 -3
- package/lib/cli/configure/processing/configFile.js.map +1 -1
- package/lib/cli/configure/processing/deleteFiles.js +26 -2
- package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js +27 -2
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.js +31 -6
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/loadFiles.js +26 -2
- package/lib/cli/configure/processing/loadFiles.js.map +1 -1
- package/lib/cli/configure/processing/module.js +28 -4
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.d.ts +67 -1
- package/lib/cli/configure/processing/package.js +45 -8
- package/lib/cli/configure/processing/package.js.map +3 -3
- package/lib/cli/configure/processing/prettier.js +38 -4
- package/lib/cli/configure/processing/prettier.js.map +2 -2
- package/lib/cli/configure/processing/record.js +41 -5
- package/lib/cli/configure/processing/record.js.map +2 -2
- package/lib/cli/configure/processing/typescript.js +63 -26
- package/lib/cli/configure/processing/typescript.js.map +2 -2
- package/lib/cli/configure/types.d.ts +4 -15
- package/lib/cli/configure/types.js +16 -0
- package/lib/cli/configure/types.js.map +3 -3
- package/lib/cli/format/index.js +44 -20
- package/lib/cli/format/index.js.map +1 -1
- package/lib/cli/help/index.js +30 -6
- package/lib/cli/help/index.js.map +1 -1
- package/lib/cli/init/getConfig.d.ts +1 -1
- package/lib/cli/init/getConfig.js +111 -76
- package/lib/cli/init/getConfig.js.map +3 -3
- package/lib/cli/init/git.d.ts +1 -0
- package/lib/cli/init/git.js +88 -16
- package/lib/cli/init/git.js.map +3 -3
- package/lib/cli/init/index.js +98 -67
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/init/prompts.d.ts +6 -5
- package/lib/cli/init/prompts.js +54 -27
- package/lib/cli/init/prompts.js.map +2 -2
- package/lib/cli/init/types.js +41 -7
- package/lib/cli/init/types.js.map +1 -1
- package/lib/cli/init/validation.js +30 -2
- package/lib/cli/init/validation.js.map +1 -1
- package/lib/cli/init/writePackageJson.js +42 -8
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/eslint.js +37 -3
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js +45 -11
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js +37 -3
- package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +37 -3
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +37 -3
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/github/eslint.js +26 -2
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js +45 -11
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/internal.js +26 -2
- package/lib/cli/lint/annotate/github/internal.js.map +1 -1
- package/lib/cli/lint/annotate/github/prettier.js +26 -2
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +28 -4
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/annotate/index.js +30 -6
- package/lib/cli/lint/annotate/index.js.map +1 -1
- package/lib/cli/lint/autofix.js +73 -37
- package/lib/cli/lint/autofix.js.map +1 -1
- package/lib/cli/lint/eslint.js +51 -16
- package/lib/cli/lint/eslint.js.map +3 -3
- package/lib/cli/lint/external.js +51 -19
- package/lib/cli/lint/external.js.map +2 -2
- package/lib/cli/lint/index.js +49 -25
- package/lib/cli/lint/index.js.map +1 -1
- package/lib/cli/lint/internal.js +42 -18
- package/lib/cli/lint/internal.js.map +1 -1
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +33 -8
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +45 -11
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +2 -2
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +55 -21
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +63 -32
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.d.ts +1 -1
- package/lib/cli/lint/internalLints/upgrade/index.js +53 -22
- package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +28 -4
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +30 -6
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +65 -34
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +28 -4
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +59 -23
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +28 -4
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +30 -6
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +28 -4
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +46 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +67 -29
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +34 -10
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.d.ts +0 -4
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +63 -18
- 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 +50 -15
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js +40 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.d.ts +3 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.js +133 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/upgradeNode.js +55 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/upgradeNode.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +51 -17
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +34 -10
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +44 -10
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +46 -12
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +28 -4
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +49 -15
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +34 -10
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +47 -13
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +28 -4
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +45 -11
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +2 -2
- package/lib/cli/lint/prettier.js +50 -15
- package/lib/cli/lint/prettier.js.map +3 -3
- package/lib/cli/lint/tsc.js +28 -4
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/lint/types.js +16 -0
- package/lib/cli/lint/types.js.map +3 -3
- package/lib/cli/migrate/index.d.ts +5 -0
- package/lib/cli/migrate/index.js +79 -15
- package/lib/cli/migrate/index.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/checks.d.ts +1 -14
- package/lib/cli/migrate/nodeVersion/checks.js +51 -120
- package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/index.d.ts +8 -2
- package/lib/cli/migrate/nodeVersion/index.js +239 -65
- package/lib/cli/migrate/nodeVersion/index.js.map +3 -3
- package/lib/cli/migrate/nodeVersion/upgrade.d.ts +8 -0
- package/lib/cli/migrate/nodeVersion/upgrade.js +179 -0
- package/lib/cli/migrate/nodeVersion/upgrade.js.map +7 -0
- package/lib/cli/node/index.js +57 -20
- package/lib/cli/node/index.js.map +3 -3
- package/lib/cli/release/index.js +28 -4
- package/lib/cli/release/index.js.map +1 -1
- package/lib/cli/start/index.js +50 -16
- package/lib/cli/start/index.js.map +3 -3
- package/lib/cli/test/index.js +44 -4
- package/lib/cli/test/index.js.map +2 -2
- package/lib/cli/test/reporters/github/annotations.d.ts +9 -0
- package/lib/cli/test/reporters/github/annotations.js +102 -0
- package/lib/cli/test/reporters/github/annotations.js.map +7 -0
- package/lib/cli/test/reporters/github/index.d.ts +5 -0
- package/lib/cli/test/reporters/github/index.js +74 -0
- package/lib/cli/test/reporters/github/index.js.map +7 -0
- package/lib/cli/version/index.js +30 -6
- package/lib/cli/version/index.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +46 -6
- package/lib/index.js.map +2 -2
- package/lib/skuba.js +45 -26
- package/lib/skuba.js.map +3 -3
- package/lib/utils/args.js +43 -6
- package/lib/utils/args.js.map +2 -2
- package/lib/utils/command.js +42 -4
- package/lib/utils/command.js.map +3 -3
- package/lib/utils/copy.js +57 -20
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/dir.js +72 -32
- package/lib/utils/dir.js.map +2 -2
- package/lib/utils/env.js +26 -2
- package/lib/utils/env.js.map +1 -1
- package/lib/utils/error.js +47 -10
- package/lib/utils/error.js.map +1 -1
- package/lib/utils/exec.js +61 -23
- package/lib/utils/exec.js.map +3 -3
- package/lib/utils/fs.js +40 -6
- package/lib/utils/fs.js.map +2 -2
- package/lib/utils/help.js +30 -6
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/logging.js +38 -11
- package/lib/utils/logging.js.map +1 -1
- package/lib/utils/logo.js +48 -24
- package/lib/utils/logo.js.map +1 -1
- package/lib/utils/manifest.d.ts +2 -3
- package/lib/utils/manifest.js +48 -8
- package/lib/utils/manifest.js.map +3 -3
- package/lib/utils/npmrc.js +26 -2
- package/lib/utils/npmrc.js.map +1 -1
- package/lib/utils/packageManager.js +49 -12
- package/lib/utils/packageManager.js.map +2 -2
- package/lib/utils/port.js +39 -4
- package/lib/utils/port.js.map +2 -2
- package/lib/utils/sleep.js +26 -2
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/template.d.ts +1 -1
- package/lib/utils/template.js +60 -19
- package/lib/utils/template.js.map +3 -3
- package/lib/utils/validation.js +31 -2
- package/lib/utils/validation.js.map +1 -1
- package/lib/utils/version.js +46 -9
- package/lib/utils/version.js.map +2 -2
- package/lib/utils/wait.js +32 -7
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.js +35 -10
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/function-arguments.d.js +1 -0
- package/lib/wrapper/functionHandler.js +49 -18
- package/lib/wrapper/functionHandler.js.map +2 -2
- package/lib/wrapper/http.js +43 -8
- package/lib/wrapper/http.js.map +2 -2
- package/lib/wrapper/index.js +7 -6
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js +42 -8
- package/lib/wrapper/main.js.map +3 -3
- package/lib/wrapper/requestListener.js +47 -13
- package/lib/wrapper/requestListener.js.map +2 -2
- package/lib/wrapper/server.js +28 -4
- package/lib/wrapper/server.js.map +1 -1
- package/package.json +42 -43
- package/template/base/_.prettierrc.js +1 -1
- package/template/base/_eslint.config.js +1 -1
- package/template/base/_pnpm-workspace.yaml +4 -3
- package/template/base/jest.config.ts +19 -0
- package/template/base/jest.setup.ts +3 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/.nvmrc +1 -1
- package/template/express-rest-api/package.json +8 -9
- package/template/express-rest-api/skuba.template.js +1 -1
- package/template/express-rest-api/src/app.test.ts +0 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/.nvmrc +1 -1
- package/template/greeter/package.json +4 -5
- package/template/greeter/skuba.template.js +1 -1
- package/template/greeter/src/app.test.ts +1 -3
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/.nvmrc +1 -1
- package/template/koa-rest-api/package.json +9 -11
- package/template/koa-rest-api/skuba.template.js +1 -1
- package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +0 -2
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +0 -2
- package/template/koa-rest-api/src/app.test.ts +0 -2
- package/template/koa-rest-api/src/framework/server.test.ts +2 -2
- package/template/koa-rest-api/src/framework/validation.test.ts +0 -2
- package/template/koa-rest-api/src/testing/metrics.ts +0 -2
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +7 -19
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +9 -11
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -3
- package/template/lambda-sqs-worker-cdk/infra/config.ts +2 -4
- package/template/lambda-sqs-worker-cdk/package.json +9 -9
- package/template/lambda-sqs-worker-cdk/skuba.template.js +13 -1
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +13 -22
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +0 -1
- package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +31 -33
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +2 -8
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +2 -3
- package/template/lambda-sqs-worker-cdk/src/testing/services.ts +3 -4
- package/template/oss-npm-package/.github/workflows/release.yml +1 -1
- package/template/oss-npm-package/.github/workflows/validate.yml +1 -1
- package/template/oss-npm-package/.nvmrc +1 -1
- package/template/oss-npm-package/_package.json +0 -1
- package/template/oss-npm-package/skuba.template.js +1 -1
- package/template/oss-npm-package/src/index.test.ts +0 -2
- package/template/private-npm-package/.nvmrc +1 -1
- package/template/private-npm-package/_package.json +1 -2
- package/template/private-npm-package/skuba.template.js +2 -2
- package/template/private-npm-package/src/index.test.ts +0 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.d.ts +0 -6
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.js +0 -86
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js +0 -16
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.d.ts +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js +0 -76
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.d.ts +0 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +0 -11
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +0 -34
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +0 -7
- package/lib/eslint.d.js +0 -1
- package/lib/eslint.d.js.map +0 -7
- package/template/base/vitest.config.ts +0 -25
- /package/lib/cli/lint/internalLints/upgrade/patches/{12.5.0 → 13.1.1}/index.d.ts +0 -0
- /package/lib/cli/lint/internalLints/upgrade/patches/{9.1.0 → 13.1.1}/upgradeNode.d.ts +0 -0
|
@@ -1,11 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var rewriteSrcImports_exports = {};
|
|
30
|
+
__export(rewriteSrcImports_exports, {
|
|
31
|
+
hasImportRegex: () => hasImportRegex,
|
|
32
|
+
hasJestMockRegex: () => hasJestMockRegex,
|
|
33
|
+
hasRelativeImportRegex: () => hasRelativeImportRegex,
|
|
34
|
+
hasRelativeRegisterImportRegex: () => hasRelativeRegisterImportRegex,
|
|
35
|
+
hasSkubaDiveRegisterImportRegex: () => hasSkubaDiveRegisterImportRegex,
|
|
36
|
+
hasSrcImportRegex: () => hasSrcImportRegex,
|
|
37
|
+
hasSrcSideEffectImportRegex: () => hasSrcSideEffectImportRegex,
|
|
38
|
+
isFileEmpty: () => isFileEmpty,
|
|
39
|
+
replaceSrcImport: () => replaceSrcImport,
|
|
40
|
+
replaceSrcImportWithConditionalRegisterRemoval: () => replaceSrcImportWithConditionalRegisterRemoval,
|
|
41
|
+
replaceSrcImportWithSelectiveRegisterRemoval: () => replaceSrcImportWithSelectiveRegisterRemoval,
|
|
42
|
+
rewriteSrcImports: () => rewriteSrcImports,
|
|
43
|
+
tryRewriteSrcImports: () => tryRewriteSrcImports
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(rewriteSrcImports_exports);
|
|
46
|
+
var import_path = __toESM(require("path"));
|
|
47
|
+
var import_util = require("util");
|
|
48
|
+
var import_fast_glob = require("fast-glob");
|
|
49
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
50
|
+
var import_logging = require("../../../../../../utils/logging.js");
|
|
6
51
|
const fetchFiles = async (files) => Promise.all(
|
|
7
52
|
files.map(async (file) => {
|
|
8
|
-
const contents = await
|
|
53
|
+
const contents = await import_fs_extra.default.promises.readFile(file, "utf8");
|
|
9
54
|
return {
|
|
10
55
|
file,
|
|
11
56
|
contents
|
|
@@ -28,9 +73,9 @@ const removeSelectiveRelativeImports = (contents, file, deletionSet) => contents
|
|
|
28
73
|
if (!relativePath) {
|
|
29
74
|
return match;
|
|
30
75
|
}
|
|
31
|
-
const fileDir =
|
|
32
|
-
const resolvedPath =
|
|
33
|
-
if (
|
|
76
|
+
const fileDir = import_path.default.dirname(file);
|
|
77
|
+
const resolvedPath = import_path.default.resolve(fileDir, relativePath);
|
|
78
|
+
if (import_path.default.extname(relativePath)) {
|
|
34
79
|
return deletionSet.has(resolvedPath) ? "" : match;
|
|
35
80
|
}
|
|
36
81
|
const possiblePaths = [`${resolvedPath}.ts`, `${resolvedPath}.js`];
|
|
@@ -97,7 +142,7 @@ const replaceSrcImportWithSelectiveRegisterRemoval = (contents, file, deletionSe
|
|
|
97
142
|
const tryRewriteSrcImports = async ({
|
|
98
143
|
mode
|
|
99
144
|
}) => {
|
|
100
|
-
const tsFileNames = await glob(["**/*.ts", "**/*.test.ts"], {
|
|
145
|
+
const tsFileNames = await (0, import_fast_glob.glob)(["**/*.ts", "**/*.test.ts"], {
|
|
101
146
|
ignore: [
|
|
102
147
|
"**/.git",
|
|
103
148
|
"**/node_modules",
|
|
@@ -130,7 +175,7 @@ const tryRewriteSrcImports = async ({
|
|
|
130
175
|
)
|
|
131
176
|
}));
|
|
132
177
|
const filesToDelete = new Set(
|
|
133
|
-
filesWithSkubaDiveRemoved.filter(({ afterSkubaDiveRemoval }) => isFileEmpty(afterSkubaDiveRemoval)).map(({ file }) =>
|
|
178
|
+
filesWithSkubaDiveRemoved.filter(({ afterSkubaDiveRemoval }) => isFileEmpty(afterSkubaDiveRemoval)).map(({ file }) => import_path.default.resolve(file))
|
|
134
179
|
);
|
|
135
180
|
const mapped = tsFiles.map(({ file, contents }) => ({
|
|
136
181
|
file,
|
|
@@ -149,11 +194,11 @@ const tryRewriteSrcImports = async ({
|
|
|
149
194
|
await Promise.all(
|
|
150
195
|
mapped.map(async ({ file, before, after }) => {
|
|
151
196
|
if (isFileEmpty(after)) {
|
|
152
|
-
await
|
|
197
|
+
await import_fs_extra.default.promises.unlink(file);
|
|
153
198
|
return;
|
|
154
199
|
}
|
|
155
200
|
if (before !== after) {
|
|
156
|
-
await
|
|
201
|
+
await import_fs_extra.default.promises.writeFile(file, after);
|
|
157
202
|
}
|
|
158
203
|
})
|
|
159
204
|
);
|
|
@@ -163,13 +208,13 @@ const rewriteSrcImports = async (config) => {
|
|
|
163
208
|
try {
|
|
164
209
|
return await tryRewriteSrcImports(config);
|
|
165
210
|
} catch (err) {
|
|
166
|
-
log.warn("Failed to rewrite src imports to #src");
|
|
167
|
-
log.subtle(inspect(err));
|
|
211
|
+
import_logging.log.warn("Failed to rewrite src imports to #src");
|
|
212
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
168
213
|
return { result: "skip", reason: "due to an error" };
|
|
169
214
|
}
|
|
170
215
|
};
|
|
171
|
-
export
|
|
172
|
-
|
|
216
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
217
|
+
0 && (module.exports = {
|
|
173
218
|
hasImportRegex,
|
|
174
219
|
hasJestMockRegex,
|
|
175
220
|
hasRelativeImportRegex,
|
|
@@ -183,5 +228,5 @@ export {
|
|
|
183
228
|
replaceSrcImportWithSelectiveRegisterRemoval,
|
|
184
229
|
rewriteSrcImports,
|
|
185
230
|
tryRewriteSrcImports
|
|
186
|
-
};
|
|
231
|
+
});
|
|
187
232
|
//# sourceMappingURL=rewriteSrcImports.js.map
|
|
@@ -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": "AAAA,
|
|
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\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\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AAGpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,gBAAAA,QAAG,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,wBAAwB;AAE9B,MAAM,yBAAyB;AAE/B,MAAM,kBAAkB;AAExB,MAAM,gCAAgC,CAAC,aACrC,SAAS,QAAQ,iCAAiC,EAAE;AAEtD,MAAM,+BAA+B,CAAC,aACpC,SAAS,QAAQ,gCAAgC,EAAE;AAErD,MAAM,iCAAiC,CACrC,UACA,MACA,gBAEA,SAAS,QAAQ,wBAAwB,CAAC,OAAO,iBAAyB;AACxE,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,YAAAC,QAAK,QAAQ,IAAI;AACjC,QAAM,eAAe,YAAAA,QAAK,QAAQ,SAAS,YAAY;AAEvD,MAAI,YAAAA,QAAK,QAAQ,YAAY,GAAG;AAC9B,WAAO,YAAY,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QAAQ;AAAA,IACR,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,EAAE;AAEF,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,OAAO,IAAI,OAAO,EAAE,MAAM,QAAQ,MAAM,MAAM;AAC5C,UAAI,YAAY,KAAK,GAAG;AACtB,cAAM,gBAAAD,QAAG,SAAS,OAAO,IAAI;AAC7B;AAAA,MACF;AAEA,UAAI,WAAW,OAAO;AACpB,cAAM,gBAAAA,QAAG,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,uBAAI,KAAK,uCAAuC;AAChD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["fs", "path"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var 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");
|
|
6
40
|
const fetchFiles = async (files) => Promise.all(
|
|
7
41
|
files.map(async (file) => {
|
|
8
|
-
const contents = await
|
|
42
|
+
const contents = await import_fs_extra.default.promises.readFile(file, "utf8");
|
|
9
43
|
return {
|
|
10
44
|
file,
|
|
11
45
|
contents
|
|
@@ -265,23 +299,23 @@ const tryUpdateLambdaConfigs = async ({
|
|
|
265
299
|
}) => {
|
|
266
300
|
let customCondition;
|
|
267
301
|
try {
|
|
268
|
-
const { repo } = await Git.getOwnerAndRepo({ dir: process.cwd() });
|
|
302
|
+
const { repo } = await import__.Git.getOwnerAndRepo({ dir: process.cwd() });
|
|
269
303
|
customCondition = `@seek/${repo}/source`;
|
|
270
304
|
} catch {
|
|
271
305
|
return { result: "skip", reason: "no repository name found" };
|
|
272
306
|
}
|
|
273
307
|
const [tsFileNames, webpackFileNames, serverlessFileNames] = await Promise.all([
|
|
274
|
-
glob("**/*.ts", {
|
|
308
|
+
(0, import_fast_glob.glob)("**/*.ts", {
|
|
275
309
|
ignore: [
|
|
276
310
|
"**/.git",
|
|
277
311
|
"**/node_modules",
|
|
278
312
|
"src/cli/lint/internalLints/upgrade/patches/**/*"
|
|
279
313
|
]
|
|
280
314
|
}),
|
|
281
|
-
glob("**/*webpack.config.js", {
|
|
315
|
+
(0, import_fast_glob.glob)("**/*webpack.config.js", {
|
|
282
316
|
ignore: ["**/.git", "**/node_modules"]
|
|
283
317
|
}),
|
|
284
|
-
glob("**/serverless*.y*ml", {
|
|
318
|
+
(0, import_fast_glob.glob)("**/serverless*.y*ml", {
|
|
285
319
|
ignore: ["**/.git", "**/node_modules"]
|
|
286
320
|
})
|
|
287
321
|
]);
|
|
@@ -348,7 +382,7 @@ const tryUpdateLambdaConfigs = async ({
|
|
|
348
382
|
}
|
|
349
383
|
await Promise.all(
|
|
350
384
|
filesToPatch.map(async ({ file, modified }) => {
|
|
351
|
-
await
|
|
385
|
+
await import_fs_extra.default.promises.writeFile(file, modified, "utf8");
|
|
352
386
|
})
|
|
353
387
|
);
|
|
354
388
|
return { result: "apply" };
|
|
@@ -357,13 +391,14 @@ const updateLambdaConfigs = async (config) => {
|
|
|
357
391
|
try {
|
|
358
392
|
return await tryUpdateLambdaConfigs(config);
|
|
359
393
|
} catch (err) {
|
|
360
|
-
log.warn("Failed to write configure `tsconfig.json` and `package.json`");
|
|
361
|
-
log.subtle(inspect(err));
|
|
394
|
+
import_logging.log.warn("Failed to write configure `tsconfig.json` and `package.json`");
|
|
395
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
362
396
|
return { result: "skip", reason: "due to an error" };
|
|
363
397
|
}
|
|
364
398
|
};
|
|
365
|
-
export
|
|
399
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
400
|
+
0 && (module.exports = {
|
|
366
401
|
tryUpdateLambdaConfigs,
|
|
367
402
|
updateLambdaConfigs
|
|
368
|
-
};
|
|
403
|
+
});
|
|
369
404
|
//# 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": "AAAA,
|
|
6
|
-
"names": ["modifiedBundlingContent", "modifiedResolveContent", "modifiedExportsContent", "modified"]
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,eAAoB;AACpB,qBAAoB;AAGpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;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AQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["fs", "modifiedBundlingContent", "modifiedResolveContent", "modifiedExportsContent", "modified"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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_patchRootTsconfig = require("./patchRootTsconfig.js");
|
|
25
|
+
var import_upgradeNode = require("./upgradeNode.js");
|
|
26
|
+
const patches = [
|
|
27
|
+
{
|
|
28
|
+
apply: import_upgradeNode.tryUpgradeNode,
|
|
29
|
+
description: "Upgrade Node.js version to 24 and package targets to Node.js 20"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
apply: import_patchRootTsconfig.tryPatchRootTsConfig,
|
|
33
|
+
description: "Add 'rootDir' to root tsconfig.json compilerOptions"
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
patches
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/13.1.1/index.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { tryPatchRootTsConfig } from './patchRootTsconfig.js';\nimport { tryUpgradeNode } from './upgradeNode.js';\n\nexport const patches: Patches = [\n {\n apply: tryUpgradeNode,\n description:\n 'Upgrade Node.js version to 24 and package targets to Node.js 20',\n },\n {\n apply: tryPatchRootTsConfig,\n description: \"Add 'rootDir' to root tsconfig.json compilerOptions\",\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,+BAAqC;AACrC,yBAA+B;AAExB,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var patchRootTsconfig_exports = {};
|
|
30
|
+
__export(patchRootTsconfig_exports, {
|
|
31
|
+
patchRootConfig: () => patchRootConfig,
|
|
32
|
+
tryPatchRootTsConfig: () => tryPatchRootTsConfig
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(patchRootTsconfig_exports);
|
|
35
|
+
var import_util = require("util");
|
|
36
|
+
var import_lang_json = __toESM(require("@ast-grep/lang-json"));
|
|
37
|
+
var import_napi = require("@ast-grep/napi");
|
|
38
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
39
|
+
var import_logging = require("../../../../../../utils/logging.js");
|
|
40
|
+
const patchRootConfig = async ({
|
|
41
|
+
mode
|
|
42
|
+
}) => {
|
|
43
|
+
let tsconfigFile;
|
|
44
|
+
try {
|
|
45
|
+
tsconfigFile = await import_fs_extra.default.promises.readFile("tsconfig.json", "utf8");
|
|
46
|
+
} catch {
|
|
47
|
+
return {
|
|
48
|
+
result: "skip",
|
|
49
|
+
reason: "no root tsconfig.json found"
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
(0, import_napi.registerDynamicLanguage)({ json: import_lang_json.default });
|
|
53
|
+
const tsconfig = await (0, import_napi.parseAsync)("json", tsconfigFile);
|
|
54
|
+
const ast = tsconfig.root();
|
|
55
|
+
const compilerOptionsObj = ast.find({
|
|
56
|
+
rule: {
|
|
57
|
+
pattern: {
|
|
58
|
+
context: '{"compilerOptions":}',
|
|
59
|
+
selector: "pair"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (!compilerOptionsObj) {
|
|
64
|
+
const startingBracket = ast.find({ rule: { pattern: "{" } });
|
|
65
|
+
if (!startingBracket) {
|
|
66
|
+
return {
|
|
67
|
+
result: "skip",
|
|
68
|
+
reason: "Unable to parse tsconfig.json"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const edit2 = startingBracket.replace(
|
|
72
|
+
`{
|
|
73
|
+
"compilerOptions": {
|
|
74
|
+
"rootDir": "."
|
|
75
|
+
},`
|
|
76
|
+
);
|
|
77
|
+
const newSource2 = ast.commitEdits([edit2]);
|
|
78
|
+
if (mode === "lint") {
|
|
79
|
+
return {
|
|
80
|
+
result: "apply"
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
await import_fs_extra.default.promises.writeFile("tsconfig.json", newSource2, "utf8");
|
|
84
|
+
return {
|
|
85
|
+
result: "apply"
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const rootDirOption = compilerOptionsObj.find({
|
|
89
|
+
rule: { pattern: '"rootDir"' }
|
|
90
|
+
});
|
|
91
|
+
if (rootDirOption) {
|
|
92
|
+
return {
|
|
93
|
+
result: "skip",
|
|
94
|
+
reason: "rootDir already set in tsconfig.json"
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const compilerOptionsStart = compilerOptionsObj.find({
|
|
98
|
+
rule: { pattern: "{" }
|
|
99
|
+
});
|
|
100
|
+
if (!compilerOptionsStart) {
|
|
101
|
+
return {
|
|
102
|
+
result: "skip",
|
|
103
|
+
reason: "Unable to parse tsconfig.json compilerOptions"
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const edit = compilerOptionsStart.replace(`{
|
|
107
|
+
"rootDir": ".",`);
|
|
108
|
+
const newSource = ast.commitEdits([edit]);
|
|
109
|
+
if (mode === "lint") {
|
|
110
|
+
return {
|
|
111
|
+
result: "apply"
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
await import_fs_extra.default.promises.writeFile("tsconfig.json", newSource, "utf8");
|
|
115
|
+
return {
|
|
116
|
+
result: "apply"
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const tryPatchRootTsConfig = async (config) => {
|
|
120
|
+
try {
|
|
121
|
+
return await patchRootConfig(config);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
import_logging.log.warn("Failed to patch root `tsconfig.json`");
|
|
124
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
125
|
+
return { result: "skip", reason: "due to an error" };
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
patchRootConfig,
|
|
131
|
+
tryPatchRootTsConfig
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=patchRootTsconfig.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport json from '@ast-grep/lang-json';\nimport { parseAsync, registerDynamicLanguage } from '@ast-grep/napi';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nexport const patchRootConfig: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n let tsconfigFile: string;\n try {\n tsconfigFile = await fs.promises.readFile('tsconfig.json', 'utf8');\n } catch {\n return {\n result: 'skip',\n reason: 'no root tsconfig.json found',\n };\n }\n\n registerDynamicLanguage({ json });\n const tsconfig = await parseAsync('json', tsconfigFile);\n const ast = tsconfig.root();\n\n const compilerOptionsObj = ast.find({\n rule: {\n pattern: {\n context: '{\"compilerOptions\":}',\n selector: 'pair',\n },\n },\n });\n\n if (!compilerOptionsObj) {\n const startingBracket = ast.find({ rule: { pattern: '{' } });\n\n if (!startingBracket) {\n return {\n result: 'skip',\n reason: 'Unable to parse tsconfig.json',\n };\n }\n\n const edit = startingBracket.replace(\n `{\n \"compilerOptions\": {\n \"rootDir\": \".\"\n },`,\n );\n\n const newSource = ast.commitEdits([edit]);\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await fs.promises.writeFile('tsconfig.json', newSource, 'utf8');\n\n return {\n result: 'apply',\n };\n }\n\n const rootDirOption = compilerOptionsObj.find({\n rule: { pattern: '\"rootDir\"' },\n });\n\n if (rootDirOption) {\n return {\n result: 'skip',\n reason: 'rootDir already set in tsconfig.json',\n };\n }\n\n const compilerOptionsStart = compilerOptionsObj.find({\n rule: { pattern: '{' },\n });\n\n if (!compilerOptionsStart) {\n return {\n result: 'skip',\n reason: 'Unable to parse tsconfig.json compilerOptions',\n };\n }\n\n const edit = compilerOptionsStart.replace(`{\n \"rootDir\": \".\",`);\n\n const newSource = ast.commitEdits([edit]);\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await fs.promises.writeFile('tsconfig.json', newSource, 'utf8');\n\n return {\n result: 'apply',\n };\n};\n\nexport const tryPatchRootTsConfig: PatchFunction = async (config) => {\n try {\n return await patchRootConfig(config);\n } catch (err) {\n log.warn('Failed to patch root `tsconfig.json`');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],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/B,CAAC;AAED,MAAI,eAAe;AACjB,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,uBAAuB,mBAAmB,KAAK;AAAA,IACnD,MAAM,EAAE,SAAS,IAAI;AAAA,EACvB,CAAC;AAED,MAAI,CAAC,sBAAsB;AACzB,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,OAAO,qBAAqB,QAAQ;AAAA,oBACxB;AAElB,QAAM,YAAY,IAAI,YAAY,CAAC,IAAI,CAAC;AAExC,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,gBAAAH,QAAG,SAAS,UAAU,iBAAiB,WAAW,MAAM;AAE9D,SAAO;AAAA,IACL,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,uBAAsC,OAAO,WAAW;AACnE,MAAI;AACF,WAAO,MAAM,gBAAgB,MAAM;AAAA,EACrC,SAAS,KAAK;AACZ,uBAAI,KAAK,sCAAsC;AAC/C,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["fs", "json", "edit", "newSource"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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 upgradeNode_exports = {};
|
|
20
|
+
__export(upgradeNode_exports, {
|
|
21
|
+
tryUpgradeNode: () => tryUpgradeNode
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(upgradeNode_exports);
|
|
24
|
+
var import_util = require("util");
|
|
25
|
+
var import_logging = require("../../../../../../utils/logging.js");
|
|
26
|
+
var import_migrate = require("../../../../../migrate/index.js");
|
|
27
|
+
const upgradeNode = async ({
|
|
28
|
+
mode
|
|
29
|
+
}) => {
|
|
30
|
+
if (process.env.SKIP_NODE_UPGRADE) {
|
|
31
|
+
return {
|
|
32
|
+
result: "skip",
|
|
33
|
+
reason: "SKIP_NODE_UPGRADE environment variable set"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (mode === "lint") {
|
|
37
|
+
return { result: "apply" };
|
|
38
|
+
}
|
|
39
|
+
await import_migrate.migrations.node24();
|
|
40
|
+
return { result: "apply" };
|
|
41
|
+
};
|
|
42
|
+
const tryUpgradeNode = async (config) => {
|
|
43
|
+
try {
|
|
44
|
+
return await upgradeNode(config);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
import_logging.log.warn("Failed to upgrade node version");
|
|
47
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
48
|
+
return { result: "skip", reason: "due to an error" };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
tryUpgradeNode
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=upgradeNode.js.map
|