skuba 14.0.0-esmify-skuba-20251031140551 → 14.0.0-esmify-skuba-20251105032119
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/lib/cli/adapter/eslint.js +4 -2
- package/lib/cli/adapter/eslint.js.map +1 -1
- package/lib/cli/adapter/prettier.js +8 -4
- package/lib/cli/adapter/prettier.js.map +1 -1
- package/lib/cli/build/args.js +4 -2
- package/lib/cli/build/args.js.map +1 -1
- package/lib/cli/build/assets.js +6 -3
- package/lib/cli/build/assets.js.map +1 -1
- package/lib/cli/build/esbuild.js +5 -3
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/build/index.js +4 -2
- package/lib/cli/build/index.js.map +1 -1
- package/lib/cli/build/tsc.js +10 -5
- package/lib/cli/build/tsc.js.map +1 -1
- package/lib/cli/buildPackage/index.js +4 -2
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/analyseConfiguration.js +4 -2
- package/lib/cli/configure/analyseConfiguration.js.map +1 -1
- package/lib/cli/configure/analyseDependencies.js +4 -2
- package/lib/cli/configure/analyseDependencies.js.map +1 -1
- package/lib/cli/configure/analysis/diff.js +4 -2
- package/lib/cli/configure/analysis/diff.js.map +1 -1
- package/lib/cli/configure/analysis/files.js +4 -2
- package/lib/cli/configure/analysis/files.js.map +1 -1
- package/lib/cli/configure/analysis/git.js +4 -2
- package/lib/cli/configure/analysis/git.js.map +1 -1
- package/lib/cli/configure/analysis/package.js +6 -3
- package/lib/cli/configure/analysis/package.js.map +1 -1
- package/lib/cli/configure/analysis/project.js +6 -3
- package/lib/cli/configure/analysis/project.js.map +1 -1
- package/lib/cli/configure/dependencies/index.js +12 -6
- package/lib/cli/configure/dependencies/index.js.map +1 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +4 -2
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
- package/lib/cli/configure/dependencies/seekKoala.js +4 -2
- package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
- package/lib/cli/configure/dependencies/skuba.js +4 -2
- package/lib/cli/configure/dependencies/skuba.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +4 -2
- package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDive.js +6 -3
- package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +4 -2
- package/lib/cli/configure/ensureTemplateCompletion.js.map +1 -1
- package/lib/cli/configure/getEntryPoint.js +4 -2
- package/lib/cli/configure/getEntryPoint.js.map +1 -1
- package/lib/cli/configure/getProjectType.js +4 -2
- package/lib/cli/configure/getProjectType.js.map +1 -1
- package/lib/cli/configure/index.js +4 -2
- package/lib/cli/configure/index.js.map +1 -1
- package/lib/cli/configure/modules/eslint.js +4 -2
- package/lib/cli/configure/modules/eslint.js.map +1 -1
- package/lib/cli/configure/modules/ignore.js +4 -2
- package/lib/cli/configure/modules/ignore.js.map +1 -1
- package/lib/cli/configure/modules/index.js +4 -2
- package/lib/cli/configure/modules/index.js.map +1 -1
- package/lib/cli/configure/modules/nodemon.js +4 -2
- package/lib/cli/configure/modules/nodemon.js.map +1 -1
- package/lib/cli/configure/modules/package.js +4 -2
- package/lib/cli/configure/modules/package.js.map +1 -1
- package/lib/cli/configure/modules/prettier.js +4 -2
- package/lib/cli/configure/modules/prettier.js.map +1 -1
- package/lib/cli/configure/modules/renovate.js +6 -3
- package/lib/cli/configure/modules/renovate.js.map +1 -1
- package/lib/cli/configure/modules/serverless.js +4 -2
- package/lib/cli/configure/modules/serverless.js.map +1 -1
- package/lib/cli/configure/modules/tslint.js +4 -2
- package/lib/cli/configure/modules/tslint.js.map +1 -1
- package/lib/cli/configure/processing/configFile.js +8 -4
- package/lib/cli/configure/processing/configFile.js.map +1 -1
- package/lib/cli/configure/processing/deleteFiles.js +4 -2
- package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js +6 -3
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.js +6 -3
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/loadFiles.js +4 -2
- package/lib/cli/configure/processing/loadFiles.js.map +1 -1
- package/lib/cli/configure/processing/module.js +4 -2
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.js +10 -5
- package/lib/cli/configure/processing/package.js.map +1 -1
- package/lib/cli/configure/processing/prettier.js +4 -2
- package/lib/cli/configure/processing/prettier.js.map +1 -1
- package/lib/cli/configure/processing/record.js +8 -4
- package/lib/cli/configure/processing/record.js.map +1 -1
- package/lib/cli/configure/processing/typescript.js +10 -5
- package/lib/cli/configure/processing/typescript.js.map +1 -1
- package/lib/cli/configure/types.js +0 -1
- package/lib/cli/format/index.js +4 -2
- package/lib/cli/format/index.js.map +1 -1
- package/lib/cli/help/index.js +4 -2
- package/lib/cli/help/index.js.map +1 -1
- package/lib/cli/init/getConfig.js +12 -6
- package/lib/cli/init/getConfig.js.map +1 -1
- package/lib/cli/init/git.js +6 -3
- package/lib/cli/init/git.js.map +1 -1
- package/lib/cli/init/index.js +4 -2
- package/lib/cli/init/index.js.map +1 -1
- package/lib/cli/init/prompts.js +10 -5
- package/lib/cli/init/prompts.js.map +1 -1
- package/lib/cli/init/types.js +4 -2
- package/lib/cli/init/types.js.map +1 -1
- package/lib/cli/init/validation.js +12 -6
- package/lib/cli/init/validation.js.map +1 -1
- package/lib/cli/init/writePackageJson.js +4 -2
- package/lib/cli/init/writePackageJson.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/eslint.js +4 -2
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js +4 -2
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js +4 -2
- package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +4 -2
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +4 -2
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/github/eslint.js +4 -2
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js +4 -2
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/internal.js +4 -2
- package/lib/cli/lint/annotate/github/internal.js.map +1 -1
- package/lib/cli/lint/annotate/github/prettier.js +4 -2
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +4 -2
- package/lib/cli/lint/annotate/github/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/index.js +4 -2
- package/lib/cli/lint/annotate/index.js.map +1 -1
- package/lib/cli/lint/autofix.js +8 -4
- package/lib/cli/lint/autofix.js.map +1 -1
- package/lib/cli/lint/eslint.js +6 -3
- package/lib/cli/lint/eslint.js.map +1 -1
- package/lib/cli/lint/external.js +6 -3
- package/lib/cli/lint/external.js.map +1 -1
- package/lib/cli/lint/index.js +4 -2
- package/lib/cli/lint/index.js.map +1 -1
- package/lib/cli/lint/internal.js +4 -2
- package/lib/cli/lint/internal.js.map +1 -1
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +6 -3
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +4 -2
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +1 -1
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +4 -2
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +1 -1
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +8 -4
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +8 -4
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +12 -6
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +28 -14
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +1 -1
- package/lib/cli/lint/prettier.js +6 -3
- package/lib/cli/lint/prettier.js.map +1 -1
- package/lib/cli/lint/tsc.js +4 -2
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/lint/types.js +0 -1
- package/lib/cli/migrate/index.js +4 -2
- package/lib/cli/migrate/index.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/checks.js +10 -5
- package/lib/cli/migrate/nodeVersion/checks.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/index.js +4 -2
- package/lib/cli/migrate/nodeVersion/index.js.map +1 -1
- package/lib/cli/node/index.js +6 -3
- package/lib/cli/node/index.js.map +1 -1
- package/lib/cli/release/index.js +4 -2
- package/lib/cli/release/index.js.map +1 -1
- package/lib/cli/start/index.js +4 -2
- package/lib/cli/start/index.js.map +1 -1
- package/lib/cli/test/index.js +4 -2
- package/lib/cli/test/index.js.map +1 -1
- package/lib/cli/version/index.js +4 -2
- package/lib/cli/version/index.js.map +1 -1
- package/lib/enquirer.d.js +0 -1
- package/lib/eslint.d.js +0 -1
- package/lib/index.js +10 -5
- package/lib/index.js.map +1 -1
- package/lib/skuba.js +0 -1
- package/lib/skuba.js.map +1 -1
- package/lib/utils/args.js +10 -5
- package/lib/utils/args.js.map +1 -1
- package/lib/utils/command.js +12 -6
- package/lib/utils/command.js.map +1 -1
- package/lib/utils/copy.js +10 -5
- package/lib/utils/copy.js.map +1 -1
- package/lib/utils/dir.js +16 -8
- package/lib/utils/dir.js.map +1 -1
- package/lib/utils/env.js +4 -2
- package/lib/utils/env.js.map +1 -1
- package/lib/utils/error.js +10 -5
- package/lib/utils/error.js.map +1 -1
- package/lib/utils/exec.js +12 -6
- package/lib/utils/exec.js.map +1 -1
- package/lib/utils/fs.js +4 -2
- package/lib/utils/fs.js.map +1 -1
- package/lib/utils/help.js +4 -2
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/logging.js +10 -5
- package/lib/utils/logging.js.map +1 -1
- package/lib/utils/logo.js +4 -2
- package/lib/utils/logo.js.map +1 -1
- package/lib/utils/manifest.js +16 -8
- package/lib/utils/manifest.js.map +1 -1
- package/lib/utils/npmrc.js +4 -2
- package/lib/utils/npmrc.js.map +1 -1
- package/lib/utils/packageManager.js +10 -5
- package/lib/utils/packageManager.js.map +1 -1
- package/lib/utils/port.js +6 -3
- package/lib/utils/port.js.map +1 -1
- package/lib/utils/sleep.js +4 -2
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/template.js +20 -10
- package/lib/utils/template.js.map +1 -1
- package/lib/utils/validation.js +14 -7
- package/lib/utils/validation.js.map +1 -1
- package/lib/utils/version.js +10 -5
- package/lib/utils/version.js.map +1 -1
- package/lib/utils/wait.js +6 -3
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.js +6 -3
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/function-arguments.d.js +0 -1
- package/lib/wrapper/functionHandler.js +4 -2
- package/lib/wrapper/functionHandler.js.map +1 -1
- package/lib/wrapper/http.js +6 -3
- package/lib/wrapper/http.js.map +1 -1
- package/lib/wrapper/index.js +0 -1
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js +4 -2
- package/lib/wrapper/main.js.map +1 -1
- package/lib/wrapper/requestListener.js +4 -2
- package/lib/wrapper/requestListener.js.map +1 -1
- package/lib/wrapper/server.js +4 -2
- package/lib/wrapper/server.js.map +1 -1
- package/package.json +4 -4
- package/template/greeter/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/package.json +2 -2
|
@@ -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": "
|
|
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,CAAC;AAID,MAAM,iBAAiB,EAAE,YAAY;AAAA,EACnC,iBAAiB,EACd,YAAY;AAAA,IACX,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,IAC/C,SAAS,EAAE,OAAO,EAAE,SAAS;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AAQ,QAAQ,QAAQ,sBAAsB;AAAA,EACzD;AAEA,QAAM,mBAAmB,QAAQ;AAAA,IAC/B;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,IACL,EAAE,IAAI,OAAO,EAAE,MAAM,QAAQ,SAAS,MAAM;AAC1C,UAAI,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,MAAM,GAAG;AACvD;AAAA,MACF;AACA,YAAM,kBAAkB,KAAK,UAAU,QAAQ,MAAM,CAAC;AACtD,YAAM,GAAG,SAAS,UAAU,MAAM,eAAe;AAAA,IACnD,CAAC;AAAA,EACH;AAEA,QAAM,oBAAoB,QAAQ;AAAA,IAChC,uBAAuB,IAAI,OAAO,EAAE,MAAM,QAAQ,SAAS,MAAM;AAC/D,UAAI,aAAa,QAAQ;AACvB;AAAA,MACF;AACA,YAAM,GAAG,SAAS,UAAU,MAAM,MAAM;AAAA,IAC1C,CAAC;AAAA,EACH;AAEA,QAAM,QAAQ,IAAI,CAAC,kBAAkB,iBAAiB,CAAC;AAEvD,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,0BAAyC,OAAO,WAAW;AACtE,MAAI;AACF,WAAO,MAAM,2BAA2B,MAAM;AAAA,EAChD,SAAS,KAAK;AACZ,QAAI,KAAK,8DAA8D;AACvE,QAAI,OAAO,QAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { configureTsConfigForESM } from "./configureTsConfigForESM.js";
|
|
3
2
|
import { patchApiDockerfiles } from "./patchApiDockerfiles.js";
|
|
4
3
|
import { rewriteSrcImports } from "./rewriteSrcImports.js";
|
|
5
4
|
import { updateLambdaConfigs } from "./updateLambdaConfigs.js";
|
|
6
|
-
|
|
5
|
+
const patches = [
|
|
7
6
|
{
|
|
8
7
|
apply: rewriteSrcImports,
|
|
9
8
|
description: "Rewrite all 'src' imports to be '#src'"
|
|
@@ -21,4 +20,7 @@ export const patches = [
|
|
|
21
20
|
description: "Patch Dockerfiles to copy `package.json`"
|
|
22
21
|
}
|
|
23
22
|
];
|
|
23
|
+
export {
|
|
24
|
+
patches
|
|
25
|
+
};
|
|
24
26
|
//# 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,MAAM,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,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import { glob } from "fast-glob";
|
|
4
3
|
import fs from "fs-extra";
|
|
@@ -104,7 +103,7 @@ const tryPatchApiDockerfiles = async (config) => {
|
|
|
104
103
|
result: "apply"
|
|
105
104
|
};
|
|
106
105
|
};
|
|
107
|
-
|
|
106
|
+
const patchApiDockerfiles = async (config) => {
|
|
108
107
|
try {
|
|
109
108
|
return await tryPatchApiDockerfiles(config);
|
|
110
109
|
} catch (err) {
|
|
@@ -113,4 +112,7 @@ export const patchApiDockerfiles = async (config) => {
|
|
|
113
112
|
return { result: "skip", reason: "due to an error" };
|
|
114
113
|
}
|
|
115
114
|
};
|
|
115
|
+
export {
|
|
116
|
+
patchApiDockerfiles
|
|
117
|
+
};
|
|
116
118
|
//# 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": "
|
|
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,KAA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
3
2
|
import { inspect } from "util";
|
|
4
3
|
import { glob } from "fast-glob";
|
|
@@ -13,13 +12,13 @@ const fetchFiles = async (files) => Promise.all(
|
|
|
13
12
|
};
|
|
14
13
|
})
|
|
15
14
|
);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const hasSkubaDiveRegisterImportRegex = /import\s+['"](?:skuba-dive\/register)(?:\.js)?['"];?\s*/gm;
|
|
16
|
+
const hasRelativeRegisterImportRegex = /import\s+['"](\.\.?\/.*?register)(?:\.js)?['"];?\s*/gm;
|
|
17
|
+
const hasRelativeImportRegex = /import\s+['"](\.\.?\/[^'"]*?)(?:\.js)?['"];?\s*/gm;
|
|
18
|
+
const hasSrcImportRegex = /import\s+(?:type\s+(?:\{[^}]*\}|\*\s+as\s+\w+)|\{[^}]*\}|\*\s+as\s+\w+|\w+(?:\s*,\s*\{[^}]*\})?)\s+from\s+['"]src\/[^'"]*['"]/gm;
|
|
19
|
+
const hasSrcSideEffectImportRegex = /import\s+['"]src\/[^'"]*['"];?\s*/gm;
|
|
20
|
+
const hasImportRegex = /import\(\s*["']src\/[^'"]*["']\s*\)/gm;
|
|
21
|
+
const hasJestMockRegex = /jest\.(mock|doMock)\(\s*["']src\/[^'"]*["']/gm;
|
|
23
22
|
const multiLineCommentRegex = /\/\*[\s\S]*?\*\//g;
|
|
24
23
|
const singleLineCommentRegex = /\/\/.*$/gm;
|
|
25
24
|
const whitespaceRegex = /\s/g;
|
|
@@ -40,8 +39,8 @@ const removeSelectiveRelativeImports = (contents, file, deletionSet) => contents
|
|
|
40
39
|
);
|
|
41
40
|
return shouldRemove ? "" : match;
|
|
42
41
|
});
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const isFileEmpty = (contents) => contents.replace(multiLineCommentRegex, "").replace(singleLineCommentRegex, "").replace(whitespaceRegex, "").length === 0;
|
|
43
|
+
const replaceSrcImport = (contents) => {
|
|
45
44
|
const combinedSrcRegex = new RegExp(
|
|
46
45
|
[
|
|
47
46
|
hasSrcImportRegex.source,
|
|
@@ -57,7 +56,7 @@ export const replaceSrcImport = (contents) => {
|
|
|
57
56
|
);
|
|
58
57
|
return removeSkubaDiveRegisterImport(withReplacedSrcImports);
|
|
59
58
|
};
|
|
60
|
-
|
|
59
|
+
const replaceSrcImportWithConditionalRegisterRemoval = (contents, shouldRemoveRelativeRegister) => {
|
|
61
60
|
const combinedSrcRegex = new RegExp(
|
|
62
61
|
[
|
|
63
62
|
hasSrcImportRegex.source,
|
|
@@ -76,7 +75,7 @@ export const replaceSrcImportWithConditionalRegisterRemoval = (contents, shouldR
|
|
|
76
75
|
);
|
|
77
76
|
return shouldRemoveRelativeRegister ? removeRelativeRegisterImport(withoutSkubaDive) : withoutSkubaDive;
|
|
78
77
|
};
|
|
79
|
-
|
|
78
|
+
const replaceSrcImportWithSelectiveRegisterRemoval = (contents, file, deletionSet) => {
|
|
80
79
|
const combinedSrcRegex = new RegExp(
|
|
81
80
|
[
|
|
82
81
|
hasSrcImportRegex.source,
|
|
@@ -95,7 +94,7 @@ export const replaceSrcImportWithSelectiveRegisterRemoval = (contents, file, del
|
|
|
95
94
|
);
|
|
96
95
|
return removeSelectiveRelativeImports(withoutSkubaDive, file, deletionSet);
|
|
97
96
|
};
|
|
98
|
-
|
|
97
|
+
const tryRewriteSrcImports = async ({
|
|
99
98
|
mode
|
|
100
99
|
}) => {
|
|
101
100
|
const tsFileNames = await glob(["**/*.ts", "**/*.test.ts"], {
|
|
@@ -160,7 +159,7 @@ export const tryRewriteSrcImports = async ({
|
|
|
160
159
|
);
|
|
161
160
|
return { result: "apply" };
|
|
162
161
|
};
|
|
163
|
-
|
|
162
|
+
const rewriteSrcImports = async (config) => {
|
|
164
163
|
try {
|
|
165
164
|
return await tryRewriteSrcImports(config);
|
|
166
165
|
} catch (err) {
|
|
@@ -169,4 +168,19 @@ export const rewriteSrcImports = async (config) => {
|
|
|
169
168
|
return { result: "skip", reason: "due to an error" };
|
|
170
169
|
}
|
|
171
170
|
};
|
|
171
|
+
export {
|
|
172
|
+
hasImportRegex,
|
|
173
|
+
hasJestMockRegex,
|
|
174
|
+
hasRelativeImportRegex,
|
|
175
|
+
hasRelativeRegisterImportRegex,
|
|
176
|
+
hasSkubaDiveRegisterImportRegex,
|
|
177
|
+
hasSrcImportRegex,
|
|
178
|
+
hasSrcSideEffectImportRegex,
|
|
179
|
+
isFileEmpty,
|
|
180
|
+
replaceSrcImport,
|
|
181
|
+
replaceSrcImportWithConditionalRegisterRemoval,
|
|
182
|
+
replaceSrcImportWithSelectiveRegisterRemoval,
|
|
183
|
+
rewriteSrcImports,
|
|
184
|
+
tryRewriteSrcImports
|
|
185
|
+
};
|
|
172
186
|
//# sourceMappingURL=rewriteSrcImports.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.ts"],
|
|
4
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": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,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;AAEK,MAAM,kCACX;AAEK,MAAM,iCACX;AAEK,MAAM,yBACX;AAEK,MAAM,oBACX;AAEK,MAAM,8BACX;AAEK,MAAM,iBAAiB;AAEvB,MA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|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import { glob } from "fast-glob";
|
|
4
3
|
import fs from "fs-extra";
|
|
@@ -261,7 +260,7 @@ ${includeContent}${arrayItemIndent}- 'package.json'
|
|
|
261
260
|
modified
|
|
262
261
|
};
|
|
263
262
|
};
|
|
264
|
-
|
|
263
|
+
const tryUpdateLambdaConfigs = async ({
|
|
265
264
|
mode
|
|
266
265
|
}) => {
|
|
267
266
|
let customCondition;
|
|
@@ -354,7 +353,7 @@ export const tryUpdateLambdaConfigs = async ({
|
|
|
354
353
|
);
|
|
355
354
|
return { result: "apply" };
|
|
356
355
|
};
|
|
357
|
-
|
|
356
|
+
const updateLambdaConfigs = async (config) => {
|
|
358
357
|
try {
|
|
359
358
|
return await tryUpdateLambdaConfigs(config);
|
|
360
359
|
} catch (err) {
|
|
@@ -363,4 +362,8 @@ export const updateLambdaConfigs = async (config) => {
|
|
|
363
362
|
return { result: "skip", reason: "due to an error" };
|
|
364
363
|
}
|
|
365
364
|
};
|
|
365
|
+
export {
|
|
366
|
+
tryUpdateLambdaConfigs,
|
|
367
|
+
updateLambdaConfigs
|
|
368
|
+
};
|
|
366
369
|
//# sourceMappingURL=updateLambdaConfigs.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.ts"],
|
|
4
4
|
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { Git } from '../../../../../../index.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.promises.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\n/**\n * Find a block delimited by braces and return its content and position\n * @param content The text to search in\n * @param pattern The regex pattern to match (should match up to the opening brace)\n * @returns Object containing the matched content and indices, or undefined if not found\n */\nconst findBracedBlock = (\n content: string,\n pattern: RegExp,\n):\n | {\n content: string;\n startIndex: number;\n endIndex: number;\n matchIndex: number;\n }\n | undefined => {\n const match = pattern.exec(content);\n if (!match) {\n return undefined;\n }\n\n // Find the matching closing brace\n let braceCount = 1;\n const startIndex = match.index + match[0].length;\n let endIndex = startIndex;\n\n while (braceCount > 0 && endIndex < content.length) {\n if (content[endIndex] === '{') {\n braceCount++;\n } else if (content[endIndex] === '}') {\n braceCount--;\n }\n endIndex++;\n }\n\n if (braceCount !== 0) {\n return undefined;\n }\n\n return {\n content: content.slice(startIndex, endIndex - 1),\n startIndex,\n endIndex,\n matchIndex: match.index,\n };\n};\n\n/**\n * Find and replace all braced blocks matching a pattern\n * @param content The text to search in\n * @param pattern The regex pattern to match (should be global and match up to the opening brace)\n * @param replacer Function that receives the block content and returns the replacement, or undefined to skip\n * @returns The modified content, or undefined if no changes were made\n */\nconst replaceAllBracedBlocks = (\n content: string,\n pattern: RegExp,\n replacer: (blockContent: string) => string | undefined,\n): string | undefined => {\n let modified = content;\n let hasChanges = false;\n let match: RegExpExecArray | null;\n let offset = 0;\n\n while ((match = pattern.exec(content)) !== null) {\n const adjustedIndex = match.index + offset;\n\n // Find the matching closing brace\n let braceCount = 1;\n const startIndex = adjustedIndex + match[0].length;\n let endIndex = startIndex;\n\n while (braceCount > 0 && endIndex < modified.length) {\n if (modified[endIndex] === '{') {\n braceCount++;\n } else if (modified[endIndex] === '}') {\n braceCount--;\n }\n endIndex++;\n }\n\n if (braceCount !== 0) {\n continue;\n }\n\n const blockContent = modified.slice(startIndex, endIndex - 1);\n const replacement = replacer(blockContent);\n\n if (replacement === undefined) {\n continue;\n }\n\n // Replace this block\n const before = modified.slice(0, adjustedIndex);\n const after = modified.slice(endIndex);\n const fullReplacement = `${match[0].slice(0, -1)}{${replacement}}`;\n modified = `${before}${fullReplacement}${after}`;\n\n // Adjust offset for next iteration\n offset += fullReplacement.length - (endIndex - adjustedIndex);\n hasChanges = true;\n }\n\n return hasChanges ? modified : undefined;\n};\n\nconst patchCdkTsFile = ({\n contents,\n customCondition,\n}: {\n contents: string;\n customCondition: string;\n}):\n | {\n original: string;\n modified: string;\n }\n | undefined => {\n if (\n !contents.includes('aws_lambda_nodejs.NodejsFunction') &&\n !contents.includes('NodejsFunction')\n ) {\n return undefined;\n }\n\n const modified = replaceAllBracedBlocks(\n contents,\n /bundling:\\s*\\{/g,\n (bundlingContent) => {\n // Check if --conditions already exists\n if (bundlingContent.includes('--conditions')) {\n return undefined;\n }\n\n // Find esbuildArgs block within bundling\n const esbuildArgsBlock = findBracedBlock(\n bundlingContent,\n /esbuildArgs\\s*:\\s*\\{/,\n );\n\n if (esbuildArgsBlock) {\n const argsContent = esbuildArgsBlock.content.trim();\n const separator = argsContent ? ', ' : '';\n const newArgsContent = `'--conditions': '${customCondition}'${separator}${argsContent}`;\n\n const modifiedBundlingContent = `${bundlingContent.slice(0, esbuildArgsBlock.matchIndex)}esbuildArgs: {${newArgsContent}}${bundlingContent.slice(esbuildArgsBlock.endIndex)}`;\n\n return modifiedBundlingContent;\n }\n\n // Add new esbuildArgs property\n const modifiedBundlingContent = bundlingContent.trimStart();\n return `\\n esbuildArgs: { '--conditions': '${customCondition}' },\\n ${modifiedBundlingContent}`;\n },\n );\n\n if (!modified) {\n return undefined;\n }\n\n return {\n original: contents,\n modified,\n };\n};\n\nconst patchWebpackConfigFile = ({\n contents,\n customCondition,\n}: {\n contents: string;\n customCondition: string;\n}):\n | {\n original: string;\n modified: string;\n }\n | undefined => {\n // Find module.exports block\n const exportsBlock = findBracedBlock(contents, /module\\.exports\\s*=\\s*\\{/);\n if (!exportsBlock) {\n return undefined;\n }\n\n const exportsContent = exportsBlock.content;\n\n // Check if resolve.conditionNames already has our custom condition\n if (exportsContent.includes(customCondition)) {\n return undefined;\n }\n\n // Find resolve block within module.exports\n const resolveBlock = findBracedBlock(exportsContent, /resolve\\s*:\\s*\\{/);\n\n if (resolveBlock) {\n const resolveContent = resolveBlock.content;\n\n // Find conditionNames array within resolve\n const conditionNamesMatch = /conditionNames\\s*:\\s*\\[([^\\]]*)\\]/s.exec(\n resolveContent,\n );\n\n if (conditionNamesMatch?.[1] !== undefined) {\n // Add custom condition to existing conditionNames array\n const existingConditions = conditionNamesMatch[1].trim();\n const separator = existingConditions ? ', ' : '';\n const newConditionNames = `conditionNames: ['${customCondition}'${separator}${existingConditions}]`;\n\n const modifiedResolveContent = `${resolveContent.slice(0, conditionNamesMatch.index)}${newConditionNames}${resolveContent.slice(conditionNamesMatch.index + conditionNamesMatch[0].length)}`;\n\n const modifiedExportsContent = `${exportsContent.slice(0, resolveBlock.matchIndex)}resolve: {${modifiedResolveContent}}${exportsContent.slice(resolveBlock.endIndex)}`;\n\n const modified = `${contents.slice(0, exportsBlock.startIndex)}${modifiedExportsContent}${contents.slice(exportsBlock.endIndex)}`;\n\n return {\n original: contents,\n modified,\n };\n }\n\n // Add conditionNames property to resolve block\n const modifiedResolveContent = resolveContent.trimStart();\n const newResolveContent = `\\n conditionNames: ['${customCondition}', '...'],\\n ${modifiedResolveContent}`;\n\n const modifiedExportsContent = `${exportsContent.slice(0, resolveBlock.matchIndex)}resolve: {${newResolveContent}}${exportsContent.slice(resolveBlock.endIndex)}`;\n\n const modified = `${contents.slice(0, exportsBlock.startIndex)}${modifiedExportsContent}${contents.slice(exportsBlock.endIndex)}`;\n\n return {\n original: contents,\n modified,\n };\n }\n\n // Add resolve property with conditionNames to module.exports\n const modifiedExportsContent = exportsContent.trimStart();\n const newExportsContent = `\\n resolve: {\\n conditionNames: ['${customCondition}', '...'],\\n },\\n ${modifiedExportsContent}`;\n\n const modified = `${contents.slice(0, exportsBlock.startIndex)}${newExportsContent}${contents.slice(exportsBlock.endIndex)}`;\n\n return {\n original: contents,\n modified,\n };\n};\n\nconst patchServerlessEsbuildFile = ({\n contents,\n customCondition,\n}: {\n contents: string;\n customCondition: string;\n}):\n | {\n original: string;\n modified: string;\n }\n | undefined => {\n // Check if custom condition already exists\n if (contents.includes(customCondition)) {\n return undefined;\n }\n\n // Check for serverless-esbuild plugin or build.esbuild or custom.esbuild configuration\n if (\n !contents.includes('serverless-esbuild') &&\n !contents.includes('build:') &&\n !contents.includes('custom:')\n ) {\n return undefined;\n }\n\n // Match esbuild: blocks with nested configuration (not inline \"esbuild: false\")\n // This matches any level of indentation, not just directly under build/custom\n const esbuildBlockRegex = /^(\\s*)(esbuild:)\\s*\\n((?:\\1\\s+.+\\n)+)/gm;\n\n let match;\n let modified = contents;\n let hasChanges = false;\n\n // Reset regex lastIndex for multiple matches\n esbuildBlockRegex.lastIndex = 0;\n\n while ((match = esbuildBlockRegex.exec(contents)) !== null) {\n const [fullMatch, baseIndent, esbuildLabel, esbuildContent] = match;\n\n // Check if esbuild is disabled (esbuild: false)\n if (/esbuild:\\s*false/.exec(fullMatch)) {\n continue;\n }\n\n // Check if conditions already exists in this block\n if (esbuildContent?.includes('conditions:')) {\n continue;\n }\n\n // Determine indentation (should be baseIndent + 2 spaces for YAML)\n const conditionsIndent = `${baseIndent} `;\n const arrayItemIndent = `${conditionsIndent} `;\n\n // Build the new esbuild block with conditions added\n const newEsbuildBlock = `${baseIndent}${esbuildLabel}\\n${conditionsIndent}conditions:\\n${arrayItemIndent}- '${customCondition}'\\n${esbuildContent}`;\n\n // Replace in the modified content\n modified = modified.replace(fullMatch, newEsbuildBlock);\n hasChanges = true;\n }\n\n if (!hasChanges) {\n return undefined;\n }\n\n return {\n original: contents,\n modified,\n };\n};\n\nconst patchServerlessFile = ({\n contents,\n customCondition,\n}: {\n contents: string;\n customCondition: string;\n}):\n | {\n original: string;\n modified: string;\n }\n | undefined => {\n if (contents.includes('esbuild')) {\n return patchServerlessEsbuildFile({\n contents,\n customCondition,\n });\n }\n\n if (contents.includes('serverless-webpack')) {\n return undefined;\n }\n\n // patch package patterns for serverless framework\n if (contents.includes('package.json')) {\n return undefined;\n }\n\n // Match package: blocks with patterns: arrays (allow other properties in between)\n const packageBlockRegex = /^(\\s*)(patterns:)\\s*\\n((?:\\1\\s+-\\s+.+\\n)*)/gm;\n\n let match;\n let modified = contents;\n let hasChanges = false;\n\n // Reset regex lastIndex for multiple matches\n packageBlockRegex.lastIndex = 0;\n\n while ((match = packageBlockRegex.exec(contents)) !== null) {\n const [fullMatch, patternsIndent, patternsLabel, patternsContent] = match;\n\n // Check if package.json already exists in this block\n if (patternsContent?.includes('package.json')) {\n continue;\n }\n\n // Add package.json to the patterns list\n const arrayItemIndent = `${patternsIndent} `;\n const newPatternsBlock = `${patternsIndent}${patternsLabel}\\n${patternsContent}${arrayItemIndent}- 'package.json'\\n`;\n\n // Replace in the modified content\n modified = modified.replace(fullMatch, newPatternsBlock);\n hasChanges = true;\n }\n\n // Also match package: blocks with include: arrays (allow other properties in between)\n const packageIncludeBlockRegex =\n /^(\\s*)(include:)\\s*\\n((?:\\1\\s+-\\s+.+\\n)*)/gm;\n\n // Reset regex lastIndex for multiple matches\n packageIncludeBlockRegex.lastIndex = 0;\n\n while ((match = packageIncludeBlockRegex.exec(contents)) !== null) {\n const [fullMatch, includeIndent, includeLabel, includeContent] = match;\n\n // Check if package.json already exists in this block\n if (includeContent?.includes('package.json')) {\n continue;\n }\n\n // Add package.json to the include list\n const arrayItemIndent = `${includeIndent} `;\n const newIncludeBlock = `${includeIndent}${includeLabel}\\n${includeContent}${arrayItemIndent}- 'package.json'\\n`;\n\n // Replace in the modified content\n modified = modified.replace(fullMatch, newIncludeBlock);\n hasChanges = true;\n }\n\n if (!hasChanges) {\n return undefined;\n }\n\n return {\n original: contents,\n modified,\n };\n};\n\nexport const tryUpdateLambdaConfigs: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n let customCondition: string;\n try {\n const { repo } = await Git.getOwnerAndRepo({ dir: process.cwd() });\n customCondition = `@seek/${repo}/source`;\n } catch {\n return { result: 'skip', reason: 'no repository name found' };\n }\n\n const [tsFileNames, webpackFileNames, serverlessFileNames] =\n await Promise.all([\n glob('**/*.ts', {\n ignore: [\n '**/.git',\n '**/node_modules',\n 'src/cli/lint/internalLints/upgrade/patches/**/*',\n ],\n }),\n glob('**/*webpack.config.js', {\n ignore: ['**/.git', '**/node_modules'],\n }),\n glob('**/serverless*.y*ml', {\n ignore: ['**/.git', '**/node_modules'],\n }),\n ]);\n\n if (\n !tsFileNames.length &&\n !webpackFileNames.length &&\n !serverlessFileNames.length\n ) {\n return {\n result: 'skip',\n reason: 'no .ts or webpack config files or .yml files found',\n };\n }\n\n const [tsFiles, webpackFiles, serverlessFiles] = await Promise.all([\n fetchFiles(tsFileNames),\n fetchFiles(webpackFileNames),\n fetchFiles(serverlessFileNames),\n ]);\n\n const filesToPatch = [\n ...tsFiles.flatMap(({ file, contents }) => {\n const patched = patchCdkTsFile({\n contents,\n customCondition,\n });\n if (patched && patched.modified !== patched.original) {\n return {\n file,\n original: patched.original,\n modified: patched.modified,\n };\n }\n return [];\n }),\n ...webpackFiles.flatMap(({ file, contents }) => {\n const patched = patchWebpackConfigFile({\n contents,\n customCondition,\n });\n if (patched && patched.modified !== patched.original) {\n return {\n file,\n original: patched.original,\n modified: patched.modified,\n };\n }\n return [];\n }),\n ...serverlessFiles.flatMap(({ file, contents }) => {\n const patched = patchServerlessFile({\n contents,\n customCondition,\n });\n if (patched && patched.modified !== patched.original) {\n return {\n file,\n original: patched.original,\n modified: patched.modified,\n };\n }\n return [];\n }),\n ];\n\n if (!filesToPatch.length) {\n return { result: 'skip', reason: 'no lambda configurations to patch' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await Promise.all(\n filesToPatch.map(async ({ file, modified }) => {\n await fs.promises.writeFile(file, modified, 'utf8');\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const updateLambdaConfigs: PatchFunction = async (config) => {\n try {\n return await tryUpdateLambdaConfigs(config);\n } catch (err) {\n log.warn('Failed to write configure `tsconfig.json` and `package.json`');\n log.subtle(inspect(err));\n return { result: 'skip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QAAQ,QAAQ;AAC3B;AAEO,MAAM,sBAAqC,OAAO,WAAW;AAClE,MAAI;AACF,WAAO,MAAM,uBAAuB,MAAM;AAAA,EAC5C,SAAS,KAAK;AACZ,QAAI,KAAK,8DAA8D;AACvE,QAAI,OAAO,QAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": ["modifiedBundlingContent", "modifiedResolveContent", "modifiedExportsContent", "modified"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { inspect } from "util";
|
|
4
3
|
import fs from "fs-extra";
|
|
@@ -32,7 +31,7 @@ const addEmptyExports = async (mode) => {
|
|
|
32
31
|
const results = await Promise.all(JEST_SETUP_FILES.map(addEmptyExport));
|
|
33
32
|
return results.every((result) => result === "skip") ? "skip" : "apply";
|
|
34
33
|
};
|
|
35
|
-
|
|
34
|
+
const tryAddEmptyExports = async ({ mode }) => {
|
|
36
35
|
try {
|
|
37
36
|
return { result: await addEmptyExports(mode) };
|
|
38
37
|
} catch (err) {
|
|
@@ -41,4 +40,7 @@ export const tryAddEmptyExports = async ({ mode }) => {
|
|
|
41
40
|
return { result: "skip", reason: "due to an error" };
|
|
42
41
|
}
|
|
43
42
|
};
|
|
43
|
+
export {
|
|
44
|
+
tryAddEmptyExports
|
|
45
|
+
};
|
|
44
46
|
//# sourceMappingURL=addEmptyExports.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport { getDestinationManifest } from '../../../../../configure/analysis/package.js';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project.js';\nimport { formatPrettier } from '../../../../../configure/processing/prettier.js';\nimport type { PatchFunction } from '../../index.js';\n\nconst JEST_SETUP_FILES = ['jest.setup.ts', 'jest.setup.int.ts'];\n\nconst addEmptyExports = async (mode: 'format' | 'lint') => {\n const manifest = await getDestinationManifest();\n\n const destinationRoot = path.dirname(manifest.path);\n\n const readDestinationFile = createDestinationFileReader(destinationRoot);\n\n const addEmptyExport = async (filename: string) => {\n const inputFile = await readDestinationFile(filename);\n\n if (\n !inputFile ||\n // The file appears to have an import or export so it should be compatible\n // with isolated modules. This is a very naive check that we don't want to\n // overcomplicate because it is invoked before many skuba commands.\n inputFile.includes('import ') ||\n inputFile.includes('export ')\n ) {\n return 'skip';\n }\n\n if (mode === 'lint') {\n return 'apply';\n }\n\n const data = await formatPrettier([inputFile, 'export {}'].join('\\n\\n'), {\n parser: 'typescript',\n });\n\n const filepath = path.join(destinationRoot, filename);\n\n await fs.promises.writeFile(filepath, data);\n\n return 'apply';\n };\n\n const results = await Promise.all(JEST_SETUP_FILES.map(addEmptyExport));\n return results.every((result) => result === 'skip') ? 'skip' : 'apply';\n};\n\n/**\n * Tries to add an empty `export {}` statement to the bottom of Jest setup files\n * for compliance with TypeScript isolated modules.\n */\nexport const tryAddEmptyExports: PatchFunction = async ({ mode }) => {\n try {\n return { result: await addEmptyExports(mode) };\n } catch (err) {\n log.warn('Failed to convert Jest setup files to isolated modules.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,eAAe;AAExB,OAAO,QAAQ;AAEf,SAAS,WAAW;AACpB,SAAS,8BAA8B;AACvC,SAAS,mCAAmC;AAC5C,SAAS,sBAAsB;AAG/B,MAAM,mBAAmB,CAAC,iBAAiB,mBAAmB;AAE9D,MAAM,kBAAkB,OAAO,SAA4B;AACzD,QAAM,WAAW,MAAM,uBAAuB;AAE9C,QAAM,kBAAkB,KAAK,QAAQ,SAAS,IAAI;AAElD,QAAM,sBAAsB,4BAA4B,eAAe;AAEvE,QAAM,iBAAiB,OAAO,aAAqB;AACjD,UAAM,YAAY,MAAM,oBAAoB,QAAQ;AAEpD,QACE,CAAC;AAAA;AAAA;AAAA,IAID,UAAU,SAAS,SAAS,KAC5B,UAAU,SAAS,SAAS,GAC5B;AACA,aAAO;AAAA,IACT;AAEA,QAAI,SAAS,QAAQ;AACnB,aAAO;AAAA,IACT;AAEA,UAAM,OAAO,MAAM,eAAe,CAAC,WAAW,WAAW,EAAE,KAAK,MAAM,GAAG;AAAA,MACvE,QAAQ;AAAA,IACV,CAAC;AAED,UAAM,WAAW,KAAK,KAAK,iBAAiB,QAAQ;AAEpD,UAAM,GAAG,SAAS,UAAU,UAAU,IAAI;AAE1C,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,MAAM,QAAQ,IAAI,iBAAiB,IAAI,cAAc,CAAC;AACtE,SAAO,QAAQ,MAAM,CAAC,WAAW,WAAW,MAAM,IAAI,SAAS;AACjE;AAMO,MAAM,qBAAoC,OAAO,EAAE,KAAK,MAAM;AACnE,MAAI;AACF,WAAO,EAAE,QAAQ,MAAM,gBAAgB,IAAI,EAAE;AAAA,EAC/C,SAAS,KAAK;AACZ,QAAI,KAAK,yDAAyD;AAClE,QAAI,OAAO,QAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { tryPatchRenovateConfig } from "../../../patchRenovateConfig.js";
|
|
3
2
|
import { tryAddEmptyExports } from "./addEmptyExports.js";
|
|
4
3
|
import { tryPatchDockerfile } from "./patchDockerfile.js";
|
|
5
4
|
import { tryPatchServerListener } from "./patchServerListener.js";
|
|
6
|
-
|
|
5
|
+
const patches = [
|
|
7
6
|
{
|
|
8
7
|
apply: tryAddEmptyExports,
|
|
9
8
|
description: "Add empty exports to Jest files for compliance with TypeScript isolated modules"
|
|
@@ -21,4 +20,7 @@ export const patches = [
|
|
|
21
20
|
description: "Add keepAliveTimeout to server listener"
|
|
22
21
|
}
|
|
23
22
|
];
|
|
23
|
+
export {
|
|
24
|
+
patches
|
|
25
|
+
};
|
|
24
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/index.ts"],
|
|
4
4
|
"sourcesContent": ["import { tryPatchRenovateConfig } from '../../../patchRenovateConfig.js';\nimport type { Patches } from '../../index.js';\n\nimport { tryAddEmptyExports } from './addEmptyExports.js';\nimport { tryPatchDockerfile } from './patchDockerfile.js';\nimport { tryPatchServerListener } from './patchServerListener.js';\n\nexport const patches: Patches = [\n {\n apply: tryAddEmptyExports,\n description:\n 'Add empty exports to Jest files for compliance with TypeScript isolated modules',\n },\n {\n apply: tryPatchRenovateConfig,\n description: 'Update Renovate config to support private SEEK packages',\n },\n {\n apply: tryPatchDockerfile,\n description: 'Upgrade Node.js Distroless Docker image to -debian12 variant',\n },\n {\n apply: tryPatchServerListener,\n description: 'Add keepAliveTimeout to server listener',\n },\n];\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,SAAS,8BAA8B;AAGvC,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AAEhC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import fs from "fs-extra";
|
|
4
3
|
import { log } from "../../../../../../utils/logging.js";
|
|
@@ -23,7 +22,7 @@ const patchDockerfile = async (mode, dir) => {
|
|
|
23
22
|
await fs.promises.writeFile(DOCKERFILE_FILENAME, patched);
|
|
24
23
|
return { result: "apply" };
|
|
25
24
|
};
|
|
26
|
-
|
|
25
|
+
const tryPatchDockerfile = async ({
|
|
27
26
|
mode,
|
|
28
27
|
dir = process.cwd()
|
|
29
28
|
}) => {
|
|
@@ -35,4 +34,7 @@ export const tryPatchDockerfile = async ({
|
|
|
35
34
|
return { result: "skip", reason: "due to an error" };
|
|
36
35
|
}
|
|
37
36
|
};
|
|
37
|
+
export {
|
|
38
|
+
tryPatchDockerfile
|
|
39
|
+
};
|
|
38
40
|
//# sourceMappingURL=patchDockerfile.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.ts"],
|
|
4
4
|
"sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst DOCKERFILE_FILENAME = 'Dockerfile';\n\nconst NON_DEBIAN_REGEX = /gcr.io\\/distroless\\/nodejs:(18|20)/g;\nconst DEBIAN_REGEX = /gcr.io\\/distroless\\/nodejs(18|20)-debian11/g;\nconst VERSION_DEBIAN_REPLACE = 'gcr.io/distroless/nodejs$1-debian12';\n\nconst patchDockerfile = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const maybeDockerfile = await readFile(DOCKERFILE_FILENAME);\n\n if (!maybeDockerfile) {\n return { result: 'skip', reason: 'no Dockerfile found' };\n }\n\n const patched = maybeDockerfile\n .replaceAll(NON_DEBIAN_REGEX, VERSION_DEBIAN_REPLACE)\n .replaceAll(DEBIAN_REGEX, VERSION_DEBIAN_REPLACE);\n\n if (patched === maybeDockerfile) {\n return { result: 'skip' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await fs.promises.writeFile(DOCKERFILE_FILENAME, patched);\n\n return { result: 'apply' };\n};\n\nexport const tryPatchDockerfile: PatchFunction = async ({\n mode,\n dir = process.cwd(),\n}) => {\n try {\n return await patchDockerfile(mode, dir);\n } catch (err) {\n log.warn('Failed to patch Dockerfile.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAExB,OAAO,QAAQ;AAEf,SAAS,WAAW;AACpB,SAAS,mCAAmC;AAG5C,MAAM,sBAAsB;AAE5B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAE/B,MAAM,kBAAkB,OACtB,MACA,QAC6B;AAC7B,QAAM,WAAW,4BAA4B,GAAG;AAEhD,QAAM,kBAAkB,MAAM,SAAS,mBAAmB;AAE1D,MAAI,CAAC,iBAAiB;AACpB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,sBAAsB;AAAA,EACzD;AAEA,QAAM,UAAU,gBACb,WAAW,kBAAkB,sBAAsB,EACnD,WAAW,cAAc,sBAAsB;AAElD,MAAI,YAAY,iBAAiB;AAC/B,WAAO,EAAE,QAAQ,OAAO;AAAA,EAC1B;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,GAAG,SAAS,UAAU,qBAAqB,OAAO;AAExD,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,qBAAoC,OAAO;AAAA,EACtD;AAAA,EACA,MAAM,QAAQ,IAAI;AACpB,MAAM;AACJ,MAAI;AACF,WAAO,MAAM,gBAAgB,MAAM,GAAG;AAAA,EACxC,SAAS,KAAK;AACZ,QAAI,KAAK,6BAA6B;AACtC,QAAI,OAAO,QAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import fs from "fs-extra";
|
|
4
3
|
import { log } from "../../../../../../utils/logging.js";
|
|
@@ -43,7 +42,7 @@ const patchServerListener = async (mode, dir) => {
|
|
|
43
42
|
);
|
|
44
43
|
return { result: "apply" };
|
|
45
44
|
};
|
|
46
|
-
|
|
45
|
+
const tryPatchServerListener = async ({
|
|
47
46
|
mode,
|
|
48
47
|
dir = process.cwd()
|
|
49
48
|
}) => {
|
|
@@ -55,4 +54,7 @@ export const tryPatchServerListener = async ({
|
|
|
55
54
|
return { result: "skip", reason: "due to an error" };
|
|
56
55
|
}
|
|
57
56
|
};
|
|
57
|
+
export {
|
|
58
|
+
tryPatchServerListener
|
|
59
|
+
};
|
|
58
60
|
//# sourceMappingURL=patchServerListener.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.ts"],
|
|
4
4
|
"sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project.js';\nimport { formatPrettier } from '../../../../../configure/processing/prettier.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst SERVER_LISTENER_FILENAME = 'src/listen.ts';\n\nconst KEEP_ALIVE_CODE = `\n// Gantry ALB default idle timeout is 30 seconds\n// https://nodejs.org/docs/latest-v20.x/api/http.html#serverkeepalivetimeout\n// Node default is 5 seconds\n// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout\n// AWS recommends setting an application timeout larger than the load balancer\nlistener.keepAliveTimeout = 31000;\n`;\n\nconst patchServerListener = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n let listener = await readFile(SERVER_LISTENER_FILENAME);\n if (!listener) {\n return { result: 'skip', reason: 'no listener file found' };\n }\n\n if (listener.includes('keepAliveTimeout')) {\n return { result: 'skip', reason: 'keepAliveTimeout already configured' };\n }\n\n if (listener.includes('\\napp.listen(')) {\n listener = listener.replace(\n '\\napp.listen(',\n '\\nconst listener = app.listen(',\n );\n }\n\n if (!listener.includes('\\nconst listener = app.listen(')) {\n return { result: 'skip', reason: 'no server listener found' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n listener = `${listener}${KEEP_ALIVE_CODE}`;\n\n await fs.promises.writeFile(\n SERVER_LISTENER_FILENAME,\n await formatPrettier(listener, {\n parser: 'typescript',\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const tryPatchServerListener: PatchFunction = async ({\n mode,\n dir = process.cwd(),\n}) => {\n try {\n return await patchServerListener(mode, dir);\n } catch (err) {\n log.warn('Failed to patch server listener.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAExB,OAAO,QAAQ;AAEf,SAAS,WAAW;AACpB,SAAS,mCAAmC;AAC5C,SAAS,sBAAsB;AAG/B,MAAM,2BAA2B;AAEjC,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASxB,MAAM,sBAAsB,OAC1B,MACA,QAC6B;AAC7B,QAAM,WAAW,4BAA4B,GAAG;AAEhD,MAAI,WAAW,MAAM,SAAS,wBAAwB;AACtD,MAAI,CAAC,UAAU;AACb,WAAO,EAAE,QAAQ,QAAQ,QAAQ,yBAAyB;AAAA,EAC5D;AAEA,MAAI,SAAS,SAAS,kBAAkB,GAAG;AACzC,WAAO,EAAE,QAAQ,QAAQ,QAAQ,sCAAsC;AAAA,EACzE;AAEA,MAAI,SAAS,SAAS,eAAe,GAAG;AACtC,eAAW,SAAS;AAAA,MAClB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,SAAS,gCAAgC,GAAG;AACxD,WAAO,EAAE,QAAQ,QAAQ,QAAQ,2BAA2B;AAAA,EAC9D;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,aAAW,GAAG,QAAQ,GAAG,eAAe;AAExC,QAAM,GAAG,SAAS;AAAA,IAChB;AAAA,IACA,MAAM,eAAe,UAAU;AAAA,MAC7B,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,yBAAwC,OAAO;AAAA,EAC1D;AAAA,EACA,MAAM,QAAQ,IAAI;AACpB,MAAM;AACJ,MAAI;AACF,WAAO,MAAM,oBAAoB,MAAM,GAAG;AAAA,EAC5C,SAAS,KAAK;AACZ,QAAI,KAAK,kCAAkC;AAC3C,QAAI,OAAO,QAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { tryPatchPnpmPackageManager } from "./patchPnpmPackageManager.js";
|
|
3
|
-
|
|
2
|
+
const patches = [
|
|
4
3
|
{
|
|
5
4
|
apply: tryPatchPnpmPackageManager,
|
|
6
5
|
description: "Ensure the pnpm package manager version specified in package.json is used in Dockerfiles"
|
|
7
6
|
}
|
|
8
7
|
];
|
|
8
|
+
export {
|
|
9
|
+
patches
|
|
10
|
+
};
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/8.0.0/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { tryPatchPnpmPackageManager } from './patchPnpmPackageManager.js';\n\nexport const patches: Patches = [\n {\n apply: tryPatchPnpmPackageManager,\n description:\n 'Ensure the pnpm package manager version specified in package.json is used in Dockerfiles',\n },\n];\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAEA,SAAS,kCAAkC;AAEpC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { inspect } from "util";
|
|
3
2
|
import fg from "fast-glob";
|
|
4
3
|
import fs from "fs-extra";
|
|
@@ -99,7 +98,7 @@ $2`
|
|
|
99
98
|
}
|
|
100
99
|
return { result: "apply" };
|
|
101
100
|
};
|
|
102
|
-
|
|
101
|
+
const tryPatchPnpmPackageManager = async (config) => {
|
|
103
102
|
try {
|
|
104
103
|
return await patchPnpmPackageManager(config);
|
|
105
104
|
} catch (err) {
|
|
@@ -108,4 +107,7 @@ export const tryPatchPnpmPackageManager = async (config) => {
|
|
|
108
107
|
return { result: "skip", reason: "due to an error" };
|
|
109
108
|
}
|
|
110
109
|
};
|
|
110
|
+
export {
|
|
111
|
+
tryPatchPnpmPackageManager
|
|
112
|
+
};
|
|
111
113
|
//# sourceMappingURL=patchPnpmPackageManager.js.map
|