skuba 0.0.0-master-20231002013336 → 0.0.0-master-20240206001217
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/README.md +3 -3
- package/jest/transform.test.ts +3 -1
- package/lib/api/jest/index.d.ts +3 -3
- package/lib/api/jest/index.js +19 -1
- package/lib/api/jest/index.js.map +2 -2
- package/lib/api/net/compose.js +2 -1
- package/lib/api/net/compose.js.map +2 -2
- package/lib/cli/adapter/prettier.d.ts +1 -1
- package/lib/cli/adapter/prettier.js +11 -10
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/index.js +0 -2
- package/lib/cli/build/index.js.map +2 -2
- package/lib/cli/buildPackage.js +0 -2
- package/lib/cli/buildPackage.js.map +2 -2
- package/lib/cli/configure/analyseConfiguration.d.ts +2 -0
- package/lib/cli/configure/analyseConfiguration.js.map +2 -2
- package/lib/cli/configure/getEntryPoint.js +1 -1
- package/lib/cli/configure/getEntryPoint.js.map +2 -2
- package/lib/cli/configure/getProjectType.d.ts +1 -1
- package/lib/cli/configure/getProjectType.js +6 -3
- package/lib/cli/configure/getProjectType.js.map +2 -2
- package/lib/cli/configure/index.js +11 -12
- package/lib/cli/configure/index.js.map +2 -2
- package/lib/cli/configure/modules/index.js +0 -2
- package/lib/cli/configure/modules/index.js.map +2 -2
- package/lib/cli/configure/modules/package.d.ts +1 -1
- package/lib/cli/configure/modules/package.js +2 -1
- package/lib/cli/configure/modules/package.js.map +2 -2
- package/lib/cli/configure/patchRenovateConfig.d.ts +2 -1
- package/lib/cli/configure/patchRenovateConfig.js +36 -21
- package/lib/cli/configure/patchRenovateConfig.js.map +2 -2
- package/lib/cli/configure/types.d.ts +2 -0
- package/lib/cli/configure/types.js.map +1 -1
- package/lib/cli/configure/upgrade/index.d.ts +15 -0
- package/lib/cli/configure/upgrade/index.js +130 -0
- package/lib/cli/configure/upgrade/index.js.map +7 -0
- package/lib/cli/configure/{addEmptyExports.d.ts → upgrade/patches/7.3.1/addEmptyExports.d.ts} +2 -2
- package/lib/cli/configure/{addEmptyExports.js → upgrade/patches/7.3.1/addEmptyExports.js} +15 -11
- package/lib/cli/configure/upgrade/patches/7.3.1/addEmptyExports.js.map +7 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/index.d.ts +2 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/index.js +55 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/index.js.map +7 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.d.ts +2 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js +94 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js.map +7 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.d.ts +2 -0
- package/lib/cli/configure/{patchDockerfile.js → upgrade/patches/7.3.1/patchDockerfile.js} +18 -12
- package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.js.map +7 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.d.ts +2 -0
- package/lib/cli/configure/{patchServerListener.js → upgrade/patches/7.3.1/patchServerListener.js} +18 -14
- package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.js.map +7 -0
- package/lib/cli/format.js +7 -14
- package/lib/cli/format.js.map +2 -2
- package/lib/cli/init/getConfig.d.ts +7 -5
- package/lib/cli/init/getConfig.js +61 -34
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/init/git.d.ts +2 -1
- package/lib/cli/init/git.js +2 -9
- package/lib/cli/init/git.js.map +2 -2
- package/lib/cli/init/index.d.ts +1 -1
- package/lib/cli/init/index.js +19 -10
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/init/prompts.d.ts +26 -3
- package/lib/cli/init/prompts.js +10 -2
- package/lib/cli/init/prompts.js.map +2 -2
- package/lib/cli/init/types.d.ts +120 -27
- package/lib/cli/init/types.js +30 -35
- package/lib/cli/init/types.js.map +2 -2
- package/lib/cli/init/writePackageJson.d.ts +6 -0
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/index.d.ts +2 -1
- package/lib/cli/lint/annotate/buildkite/index.js +5 -3
- package/lib/cli/lint/annotate/buildkite/index.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/internal.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/internal.js +45 -0
- package/lib/cli/lint/annotate/buildkite/internal.js.map +7 -0
- package/lib/cli/lint/annotate/github/index.d.ts +2 -1
- package/lib/cli/lint/annotate/github/index.js +4 -2
- package/lib/cli/lint/annotate/github/index.js.map +2 -2
- package/lib/cli/lint/annotate/github/internal.d.ts +3 -0
- package/lib/cli/lint/annotate/github/internal.js +36 -0
- package/lib/cli/lint/annotate/github/internal.js.map +7 -0
- package/lib/cli/lint/annotate/index.d.ts +4 -3
- package/lib/cli/lint/annotate/index.js +9 -3
- package/lib/cli/lint/annotate/index.js.map +2 -2
- package/lib/cli/lint/autofix.d.ts +3 -1
- package/lib/cli/lint/autofix.js +36 -59
- package/lib/cli/lint/autofix.js.map +3 -3
- package/lib/cli/lint/external.d.ts +6 -1
- package/lib/cli/lint/external.js +6 -29
- package/lib/cli/lint/external.js.map +2 -2
- package/lib/cli/lint/index.d.ts +2 -1
- package/lib/cli/lint/index.js +46 -14
- package/lib/cli/lint/index.js.map +2 -2
- package/lib/cli/lint/internal.d.ts +12 -1
- package/lib/cli/lint/internal.js +55 -19
- package/lib/cli/lint/internal.js.map +3 -3
- package/lib/cli/lint/internalLints/deleteFiles.d.ts +3 -0
- package/lib/cli/lint/internalLints/deleteFiles.js +102 -0
- package/lib/cli/lint/internalLints/deleteFiles.js.map +7 -0
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.d.ts +3 -0
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +75 -0
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +7 -0
- package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +11 -0
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +147 -0
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +7 -0
- package/lib/cli/test/index.js +0 -2
- package/lib/cli/test/index.js.map +2 -2
- package/lib/skuba.d.ts +1 -1
- package/lib/skuba.js.map +1 -1
- package/lib/utils/error.d.ts +30 -10
- package/lib/utils/error.js +10 -20
- package/lib/utils/error.js.map +2 -2
- package/lib/utils/exec.d.ts +2 -1
- package/lib/utils/exec.js +3 -2
- package/lib/utils/exec.js.map +2 -2
- package/lib/utils/logging.d.ts +2 -0
- package/lib/utils/logging.js +1 -0
- package/lib/utils/logging.js.map +2 -2
- package/lib/utils/logo.js +6 -10
- package/lib/utils/logo.js.map +3 -3
- package/lib/utils/manifest.d.ts +4 -4
- package/lib/utils/manifest.js +10 -10
- package/lib/utils/manifest.js.map +2 -2
- package/lib/utils/npmrc.d.ts +1 -0
- package/lib/utils/npmrc.js +29 -0
- package/lib/utils/npmrc.js.map +7 -0
- package/lib/utils/packageManager.d.ts +24 -0
- package/lib/utils/packageManager.js +97 -0
- package/lib/utils/packageManager.js.map +7 -0
- package/lib/utils/template.d.ts +46 -13
- package/lib/utils/template.js +17 -15
- package/lib/utils/template.js.map +2 -2
- package/lib/utils/worker.d.ts +1 -0
- package/lib/wrapper/http.d.ts +1 -0
- package/package.json +50 -47
- package/template/base/_.dockerignore +0 -1
- package/template/base/_.eslintignore +1 -0
- package/template/base/_.gitignore +1 -1
- package/template/base/_.npmrc +8 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +16 -12
- package/template/express-rest-api/.gantry/dev.yml +3 -0
- package/template/express-rest-api/.nvmrc +1 -1
- package/template/express-rest-api/Dockerfile +6 -12
- package/template/express-rest-api/Dockerfile.dev-deps +8 -7
- package/template/express-rest-api/README.md +12 -12
- package/template/express-rest-api/docker-compose.yml +0 -10
- package/template/express-rest-api/gantry.apply.yml +5 -0
- package/template/express-rest-api/gantry.build.yml +1 -2
- package/template/express-rest-api/package.json +4 -4
- package/template/express-rest-api/skuba.template.js +1 -0
- package/template/greeter/.buildkite/pipeline.yml +15 -11
- package/template/greeter/.nvmrc +1 -1
- package/template/greeter/Dockerfile +8 -7
- package/template/greeter/README.md +9 -9
- package/template/greeter/docker-compose.yml +0 -10
- package/template/greeter/package.json +3 -3
- package/template/greeter/skuba.template.js +1 -0
- package/template/koa-rest-api/.buildkite/pipeline.yml +16 -12
- package/template/koa-rest-api/.gantry/dev.yml +3 -0
- package/template/koa-rest-api/.nvmrc +1 -1
- package/template/koa-rest-api/Dockerfile +6 -12
- package/template/koa-rest-api/Dockerfile.dev-deps +8 -7
- package/template/koa-rest-api/README.md +12 -12
- package/template/koa-rest-api/docker-compose.yml +0 -10
- package/template/koa-rest-api/gantry.apply.yml +5 -0
- package/template/koa-rest-api/gantry.build.yml +1 -2
- package/template/koa-rest-api/package.json +10 -8
- package/template/koa-rest-api/skuba.template.js +1 -0
- package/template/koa-rest-api/src/app.test.ts +8 -4
- package/template/koa-rest-api/src/framework/validation.test.ts +48 -15
- package/template/koa-rest-api/src/framework/validation.ts +31 -8
- package/template/koa-rest-api/src/testing/types.ts +16 -4
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +25 -18
- package/template/lambda-sqs-worker/.nvmrc +1 -1
- package/template/lambda-sqs-worker/Dockerfile +8 -8
- package/template/lambda-sqs-worker/README.md +14 -14
- package/template/lambda-sqs-worker/_.npmrc +12 -0
- package/template/lambda-sqs-worker/docker-compose.yml +0 -15
- package/template/lambda-sqs-worker/package.json +6 -7
- package/template/lambda-sqs-worker/serverless.yml +5 -2
- package/template/lambda-sqs-worker/skuba.template.js +1 -0
- package/template/lambda-sqs-worker/src/framework/validation.test.ts +1 -1
- package/template/lambda-sqs-worker/src/hooks.ts +1 -2
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +46 -21
- package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
- package/template/lambda-sqs-worker-cdk/Dockerfile +11 -9
- package/template/lambda-sqs-worker-cdk/cdk.json +12 -6
- package/template/lambda-sqs-worker-cdk/docker-compose.yml +0 -15
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +1590 -228
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +23 -3
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +128 -15
- package/template/lambda-sqs-worker-cdk/package.json +9 -7
- package/template/lambda-sqs-worker-cdk/shared/context-types.ts +1 -0
- package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -0
- package/template/lambda-sqs-worker-cdk/src/app.ts +14 -1
- package/template/lambda-sqs-worker-cdk/src/postHook.ts +154 -0
- package/template/lambda-sqs-worker-cdk/src/preHook.ts +95 -0
- package/template/oss-npm-package/.github/workflows/release.yml +10 -7
- package/template/oss-npm-package/.github/workflows/validate.yml +10 -7
- package/template/oss-npm-package/.nvmrc +1 -1
- package/template/oss-npm-package/.releaserc +16 -0
- package/template/oss-npm-package/README.md +18 -18
- package/template/oss-npm-package/_package.json +3 -2
- package/template/oss-npm-package/skuba.template.js +1 -0
- package/template/private-npm-package/.nvmrc +1 -1
- package/template/private-npm-package/.releaserc +16 -0
- package/template/private-npm-package/README.md +18 -18
- package/template/private-npm-package/_package.json +3 -3
- package/template/private-npm-package/skuba.template.js +1 -0
- package/lib/cli/configure/addEmptyExports.js.map +0 -7
- package/lib/cli/configure/modules/tsconfig.d.ts +0 -2
- package/lib/cli/configure/modules/tsconfig.js +0 -87
- package/lib/cli/configure/modules/tsconfig.js.map +0 -7
- package/lib/cli/configure/patchDockerfile.d.ts +0 -1
- package/lib/cli/configure/patchDockerfile.js.map +0 -7
- package/lib/cli/configure/patchServerListener.d.ts +0 -3
- package/lib/cli/configure/patchServerListener.js.map +0 -7
- package/lib/cli/configure/refreshIgnoreFiles.d.ts +0 -3
- package/lib/cli/configure/refreshIgnoreFiles.js +0 -78
- package/lib/cli/configure/refreshIgnoreFiles.js.map +0 -7
|
@@ -33,6 +33,7 @@ const DEFAULT_PACKAGE_FILES = [
|
|
|
33
33
|
];
|
|
34
34
|
const packageModule = async ({
|
|
35
35
|
entryPoint,
|
|
36
|
+
packageManager,
|
|
36
37
|
type
|
|
37
38
|
}) => {
|
|
38
39
|
const version = await (0, import_version.getSkubaVersion)();
|
|
@@ -92,7 +93,7 @@ const packageModule = async ({
|
|
|
92
93
|
outputData.scripts.prerelease,
|
|
93
94
|
outputData.scripts.release ?? "skuba release"
|
|
94
95
|
].filter((script) => typeof script === "string").map(
|
|
95
|
-
(script) => script.replace(/^smt build$/,
|
|
96
|
+
(script) => script.replace(/^smt build$/, `${packageManager.runSilent} build`).replace(/^smt /, "skuba ").trim()
|
|
96
97
|
).filter(Boolean).join(" && ");
|
|
97
98
|
if (outputData.scripts.build === "skuba build-package") {
|
|
98
99
|
outputData.main = "./lib-commonjs/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/configure/modules/package.ts"],
|
|
4
|
-
"sourcesContent": ["import { getSkubaVersion } from '../../../utils/version';\nimport { deleteFiles } from '../processing/deleteFiles';\nimport { withPackage } from '../processing/package';\nimport { merge } from '../processing/record';\nimport type { Module, Options } from '../types';\n\nconst DEFAULT_PACKAGE_FILES = [\n 'lib*/**/*.d.ts',\n 'lib*/**/*.js',\n 'lib*/**/*.js.map',\n 'lib*/**/*.json',\n];\n\nexport const packageModule = async ({\n entryPoint,\n type,\n}: Options): Promise<Module> => {\n const version = await getSkubaVersion();\n\n const initialData = {\n private: type !== 'package',\n\n scripts: {\n build: type === 'package' ? 'skuba build-package' : 'skuba build',\n format: 'skuba format',\n lint: 'skuba lint',\n ...(type === 'package' ? {} : { start: 'skuba start' }),\n test: 'skuba test --coverage',\n 'test:watch': 'skuba test --watch',\n },\n skuba: {\n entryPoint,\n template: null,\n type,\n version,\n },\n };\n\n const recurringData = {\n skuba: {\n entryPoint,\n type,\n version,\n },\n };\n\n return {\n ...deleteFiles('.npmignore', 'package-lock.json'),\n\n 'package.json': (inputFile) =>\n withPackage((inputData) => {\n const outputData = merge(\n inputData,\n 'skuba' in inputData ? recurringData : initialData,\n );\n\n outputData.license ??= 'UNLICENSED';\n outputData.scripts ??= {};\n\n // Workspaces can only be enabled in private projects\n if (outputData.workspaces && !outputData.private) {\n outputData.private = true;\n }\n\n delete outputData.scripts.commit;\n delete outputData.scripts['format:check'];\n delete outputData.scripts['lint:build'];\n delete outputData.scripts['lint:compile'];\n delete outputData.scripts['lint:eslint'];\n delete outputData.scripts['lint:prettier'];\n delete outputData.scripts['lint:tslint'];\n delete outputData.scripts['test:build'];\n delete outputData.scripts['test:jest'];\n delete outputData.typings;\n\n if (type === 'package') {\n outputData.files = (\n outputData.files ?? DEFAULT_PACKAGE_FILES\n ).flatMap((filePattern) =>\n filePattern === 'lib' ? DEFAULT_PACKAGE_FILES : [filePattern],\n );\n\n outputData.version ??= '0.0.0-semantically-released';\n\n // User-defined pre- and post-scripts are confusing and dropped by e.g.\n // Yarn 2.\n outputData.scripts.release = [\n outputData.scripts.prepublish,\n outputData.scripts.prerelease,\n outputData.scripts.release ?? 'skuba release',\n ]\n .filter((script): script is string => typeof script === 'string')\n .map((script) =>\n script\n .replace(/^smt build$/,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAgC;AAChC,yBAA4B;AAC5B,qBAA4B;AAC5B,oBAAsB;AAGtB,MAAM,wBAAwB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,gBAAgB,OAAO;AAAA,EAClC;AAAA,EACA;AACF,MAAgC;AAC9B,QAAM,UAAU,UAAM,gCAAgB;AAEtC,QAAM,cAAc;AAAA,IAClB,SAAS,SAAS;AAAA,IAElB,SAAS;AAAA,MACP,OAAO,SAAS,YAAY,wBAAwB;AAAA,MAC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D;AAAA,UAAI,CAAC,WACJ,OACG,QAAQ,eAAe,
|
|
4
|
+
"sourcesContent": ["import { getSkubaVersion } from '../../../utils/version';\nimport { deleteFiles } from '../processing/deleteFiles';\nimport { withPackage } from '../processing/package';\nimport { merge } from '../processing/record';\nimport type { Module, Options } from '../types';\n\nconst DEFAULT_PACKAGE_FILES = [\n 'lib*/**/*.d.ts',\n 'lib*/**/*.js',\n 'lib*/**/*.js.map',\n 'lib*/**/*.json',\n];\n\nexport const packageModule = async ({\n entryPoint,\n packageManager,\n type,\n}: Options): Promise<Module> => {\n const version = await getSkubaVersion();\n\n const initialData = {\n private: type !== 'package',\n\n scripts: {\n build: type === 'package' ? 'skuba build-package' : 'skuba build',\n format: 'skuba format',\n lint: 'skuba lint',\n ...(type === 'package' ? {} : { start: 'skuba start' }),\n test: 'skuba test --coverage',\n 'test:watch': 'skuba test --watch',\n },\n skuba: {\n entryPoint,\n template: null,\n type,\n version,\n },\n };\n\n const recurringData = {\n skuba: {\n entryPoint,\n type,\n version,\n },\n };\n\n return {\n ...deleteFiles('.npmignore', 'package-lock.json'),\n\n 'package.json': (inputFile) =>\n withPackage((inputData) => {\n const outputData = merge(\n inputData,\n 'skuba' in inputData ? recurringData : initialData,\n );\n\n outputData.license ??= 'UNLICENSED';\n outputData.scripts ??= {};\n\n // Workspaces can only be enabled in private projects\n if (outputData.workspaces && !outputData.private) {\n outputData.private = true;\n }\n\n delete outputData.scripts.commit;\n delete outputData.scripts['format:check'];\n delete outputData.scripts['lint:build'];\n delete outputData.scripts['lint:compile'];\n delete outputData.scripts['lint:eslint'];\n delete outputData.scripts['lint:prettier'];\n delete outputData.scripts['lint:tslint'];\n delete outputData.scripts['test:build'];\n delete outputData.scripts['test:jest'];\n delete outputData.typings;\n\n if (type === 'package') {\n outputData.files = (\n outputData.files ?? DEFAULT_PACKAGE_FILES\n ).flatMap((filePattern) =>\n filePattern === 'lib' ? DEFAULT_PACKAGE_FILES : [filePattern],\n );\n\n outputData.version ??= '0.0.0-semantically-released';\n\n // User-defined pre- and post-scripts are confusing and dropped by e.g.\n // Yarn 2.\n outputData.scripts.release = [\n outputData.scripts.prepublish,\n outputData.scripts.prerelease,\n outputData.scripts.release ?? 'skuba release',\n ]\n .filter((script): script is string => typeof script === 'string')\n .map((script) =>\n script\n .replace(/^smt build$/, `${packageManager.runSilent} build`)\n .replace(/^smt /, 'skuba ')\n .trim(),\n )\n .filter(Boolean)\n .join(' && ');\n\n // Align with the required syntax for package.json#/paths\n if (outputData.scripts.build === 'skuba build-package') {\n outputData.main = './lib-commonjs/index.js';\n outputData.module = './lib-es2015/index.js';\n outputData.types = './lib-types/index.d.ts';\n } else {\n outputData.main = './lib/index.js';\n outputData.module = './lib/index.js';\n outputData.types = './lib/index.d.ts';\n }\n\n delete outputData.scripts.prepublish;\n delete outputData.scripts.prerelease;\n }\n\n return outputData;\n })(inputFile),\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAgC;AAChC,yBAA4B;AAC5B,qBAA4B;AAC5B,oBAAsB;AAGtB,MAAM,wBAAwB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,gBAAgB,OAAO;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACF,MAAgC;AAC9B,QAAM,UAAU,UAAM,gCAAgB;AAEtC,QAAM,cAAc;AAAA,IAClB,SAAS,SAAS;AAAA,IAElB,SAAS;AAAA,MACP,OAAO,SAAS,YAAY,wBAAwB;AAAA,MACpD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,GAAI,SAAS,YAAY,CAAC,IAAI,EAAE,OAAO,cAAc;AAAA,MACrD,MAAM;AAAA,MACN,cAAc;AAAA,IAChB;AAAA,IACA,OAAO;AAAA,MACL;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,gBAAgB;AAAA,IACpB,O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AA,QACrB,OAAO;AACL,qBAAW,OAAO;AAClB,qBAAW,SAAS;AACpB,qBAAW,QAAQ;AAAA,QACrB;AAEA,eAAO,WAAW,QAAQ;AAC1B,eAAO,WAAW,QAAQ;AAAA,MAC5B;AAEA,aAAO;AAAA,IACT,CAAC,EAAE,SAAS;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PatchReturnType } from './upgrade';
|
|
2
|
+
export declare const tryPatchRenovateConfig: (mode: 'format' | 'lint', dir?: string) => Promise<PatchReturnType>;
|
|
@@ -35,7 +35,7 @@ var import_path = __toESM(require("path"));
|
|
|
35
35
|
var import_util = require("util");
|
|
36
36
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
37
|
var fleece = __toESM(require("golden-fleece"));
|
|
38
|
-
var
|
|
38
|
+
var import_zod = require("zod");
|
|
39
39
|
var Git = __toESM(require("../../api/git"));
|
|
40
40
|
var import_logging = require("../../utils/logging");
|
|
41
41
|
var import_project = require("./analysis/project");
|
|
@@ -46,8 +46,8 @@ const RENOVATE_PRESETS = [
|
|
|
46
46
|
"local>seek-jobs/renovate-config"
|
|
47
47
|
];
|
|
48
48
|
const EXISTING_REPO_PRESET_REGEX = /(github|local)>(seek-jobs|seekasia)\//;
|
|
49
|
-
const
|
|
50
|
-
extends:
|
|
49
|
+
const renovateConfigSchema = import_zod.z.object({
|
|
50
|
+
extends: import_zod.z.array(import_zod.z.string())
|
|
51
51
|
});
|
|
52
52
|
const ownerToRenovatePreset = (owner) => {
|
|
53
53
|
const lowercaseOwner = owner.toLowerCase();
|
|
@@ -61,26 +61,28 @@ const ownerToRenovatePreset = (owner) => {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
const patchJson = async ({ filepath, input, presetToAdd }) => {
|
|
64
|
-
const
|
|
65
|
-
|
|
64
|
+
const json = JSON.parse(input);
|
|
65
|
+
const config = renovateConfigSchema.safeParse(json);
|
|
66
|
+
if (!config.success) {
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
|
-
config.extends.unshift(presetToAdd);
|
|
69
|
+
config.data.extends.unshift(presetToAdd);
|
|
69
70
|
await import_fs_extra.default.promises.writeFile(
|
|
70
71
|
filepath,
|
|
71
|
-
await (0, import_prettier.formatPrettier)(JSON.stringify(config), { parser: "json" })
|
|
72
|
+
await (0, import_prettier.formatPrettier)(JSON.stringify(config.data), { parser: "json" })
|
|
72
73
|
);
|
|
73
74
|
return;
|
|
74
75
|
};
|
|
75
76
|
const patchJson5 = async ({ filepath, input, presetToAdd }) => {
|
|
76
|
-
const
|
|
77
|
-
|
|
77
|
+
const json = fleece.evaluate(input);
|
|
78
|
+
const config = renovateConfigSchema.safeParse(json);
|
|
79
|
+
if (!config.success) {
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
|
-
config.extends.unshift(presetToAdd);
|
|
82
|
+
config.data.extends.unshift(presetToAdd);
|
|
81
83
|
await import_fs_extra.default.promises.writeFile(
|
|
82
84
|
filepath,
|
|
83
|
-
await (0, import_prettier.formatPrettier)(fleece.patch(input, config), { parser: "json5" })
|
|
85
|
+
await (0, import_prettier.formatPrettier)(fleece.patch(input, config.data), { parser: "json5" })
|
|
84
86
|
);
|
|
85
87
|
return;
|
|
86
88
|
};
|
|
@@ -88,12 +90,15 @@ const patchByFiletype = {
|
|
|
88
90
|
json: patchJson,
|
|
89
91
|
json5: patchJson5
|
|
90
92
|
};
|
|
91
|
-
const patchRenovateConfig = async (dir) => {
|
|
93
|
+
const patchRenovateConfig = async (mode, dir) => {
|
|
92
94
|
const readFile = (0, import_project.createDestinationFileReader)(dir);
|
|
93
95
|
const { owner } = await Git.getOwnerAndRepo({ dir });
|
|
94
96
|
const presetToAdd = ownerToRenovatePreset(owner);
|
|
95
97
|
if (!presetToAdd) {
|
|
96
|
-
return
|
|
98
|
+
return {
|
|
99
|
+
result: "skip",
|
|
100
|
+
reason: "owner does not map to a SEEK preset"
|
|
101
|
+
};
|
|
97
102
|
}
|
|
98
103
|
const maybeConfigs = await Promise.all(
|
|
99
104
|
import_renovate.RENOVATE_CONFIG_FILENAMES.map(async (filepath) => ({
|
|
@@ -102,15 +107,22 @@ const patchRenovateConfig = async (dir) => {
|
|
|
102
107
|
}))
|
|
103
108
|
);
|
|
104
109
|
const config = maybeConfigs.find((maybeConfig) => Boolean(maybeConfig.input));
|
|
110
|
+
if (!config?.input) {
|
|
111
|
+
return { result: "skip", reason: "no config found" };
|
|
112
|
+
}
|
|
105
113
|
if (
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
// owner. This is a very naive check that we don't want to overcomplicate
|
|
109
|
-
// because it is invoked before each skuba format and lint.
|
|
114
|
+
// The file appears to mention the baseline preset for the configured Git
|
|
115
|
+
// owner. This is a naive check for simplicity.
|
|
110
116
|
config.input.includes(presetToAdd) || // Ignore any renovate configuration which already extends a SEEK-Jobs or seekasia config
|
|
111
117
|
EXISTING_REPO_PRESET_REGEX.exec(config.input)
|
|
112
118
|
) {
|
|
113
|
-
return
|
|
119
|
+
return {
|
|
120
|
+
result: "skip",
|
|
121
|
+
reason: "config already has a SEEK preset"
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (mode === "lint") {
|
|
125
|
+
return { result: "apply" };
|
|
114
126
|
}
|
|
115
127
|
const filetype = config.filepath.toLowerCase().endsWith(".json5") ? "json5" : "json";
|
|
116
128
|
const patchFile = patchByFiletype[filetype];
|
|
@@ -119,16 +131,19 @@ const patchRenovateConfig = async (dir) => {
|
|
|
119
131
|
input: config.input,
|
|
120
132
|
presetToAdd
|
|
121
133
|
});
|
|
134
|
+
return { result: "apply" };
|
|
122
135
|
};
|
|
123
|
-
const tryPatchRenovateConfig = async (dir = process.cwd()) => {
|
|
136
|
+
const tryPatchRenovateConfig = async (mode, dir = process.cwd()) => {
|
|
124
137
|
try {
|
|
125
138
|
const gitRoot = await Git.findRoot({ dir });
|
|
126
|
-
if (gitRoot) {
|
|
127
|
-
|
|
139
|
+
if (!gitRoot) {
|
|
140
|
+
return { result: "skip", reason: "no Git root found" };
|
|
128
141
|
}
|
|
142
|
+
return await patchRenovateConfig(mode, gitRoot);
|
|
129
143
|
} catch (err) {
|
|
130
144
|
import_logging.log.warn("Failed to patch Renovate config.");
|
|
131
145
|
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
146
|
+
return { result: "skip", reason: "due to an error" };
|
|
132
147
|
}
|
|
133
148
|
};
|
|
134
149
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/configure/patchRenovateConfig.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\nimport * as fleece from 'golden-fleece';\nimport { z } from 'zod';\n\nimport * as Git from '../../api/git';\nimport { log } from '../../utils/logging';\n\nimport { createDestinationFileReader } from './analysis/project';\nimport { RENOVATE_CONFIG_FILENAMES } from './modules/renovate';\nimport { formatPrettier } from './processing/prettier';\nimport type { PatchFunction, PatchReturnType } from './upgrade';\n\nconst RENOVATE_PRESETS = [\n 'local>seekasia/renovate-config',\n 'local>seek-jobs/renovate-config',\n] as const;\n\nconst EXISTING_REPO_PRESET_REGEX = /(github|local)>(seek-jobs|seekasia)\\//;\n\ntype RenovateFiletype = 'json' | 'json5';\n\ntype RenovatePreset = (typeof RENOVATE_PRESETS)[number];\n\nconst renovateConfigSchema = z.object({\n extends: z.array(z.string()),\n});\n\nconst ownerToRenovatePreset = (owner: string): RenovatePreset | undefined => {\n const lowercaseOwner = owner.toLowerCase();\n\n switch (lowercaseOwner) {\n case 'seekasia':\n return 'local>seekasia/renovate-config';\n\n case 'seek-jobs':\n return 'local>seek-jobs/renovate-config';\n\n default:\n return;\n }\n};\n\ntype PatchFile = (props: {\n filepath: string;\n input: string;\n presetToAdd: RenovatePreset;\n}) => Promise<void>;\n\nconst patchJson: PatchFile = async ({ filepath, input, presetToAdd }) => {\n const json: unknown = JSON.parse(input);\n\n const config = renovateConfigSchema.safeParse(json);\n\n if (!config.success) {\n return;\n }\n\n config.data.extends.unshift(presetToAdd);\n\n await fs.promises.writeFile(\n filepath,\n await formatPrettier(JSON.stringify(config.data), { parser: 'json' }),\n );\n\n return;\n};\n\nconst patchJson5: PatchFile = async ({ filepath, input, presetToAdd }) => {\n const json: unknown = fleece.evaluate(input);\n\n const config = renovateConfigSchema.safeParse(json);\n\n if (!config.success) {\n return;\n }\n\n config.data.extends.unshift(presetToAdd);\n\n await fs.promises.writeFile(\n filepath,\n await formatPrettier(fleece.patch(input, config.data), { parser: 'json5' }),\n );\n\n return;\n};\n\nconst patchByFiletype: Record<RenovateFiletype, PatchFile> = {\n json: patchJson,\n json5: patchJson5,\n};\n\nconst patchRenovateConfig = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const { owner } = await Git.getOwnerAndRepo({ dir });\n\n const presetToAdd = ownerToRenovatePreset(owner);\n\n if (!presetToAdd) {\n return {\n result: 'skip',\n reason: 'owner does not map to a SEEK preset',\n };\n }\n\n const maybeConfigs = await Promise.all(\n RENOVATE_CONFIG_FILENAMES.map(async (filepath) => ({\n input: await readFile(filepath),\n filepath,\n })),\n );\n\n const config = maybeConfigs.find((maybeConfig) => Boolean(maybeConfig.input));\n if (!config?.input) {\n return { result: 'skip', reason: 'no config found' };\n }\n\n if (\n // The file appears to mention the baseline preset for the configured Git\n // owner. This is a naive check for simplicity.\n config.input.includes(presetToAdd) ||\n // Ignore any renovate configuration which already extends a SEEK-Jobs or seekasia config\n EXISTING_REPO_PRESET_REGEX.exec(config.input)\n ) {\n return {\n result: 'skip',\n reason: 'config already has a SEEK preset',\n };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const filetype: RenovateFiletype = config.filepath\n .toLowerCase()\n .endsWith('.json5')\n ? 'json5'\n : 'json';\n\n const patchFile = patchByFiletype[filetype];\n\n await patchFile({\n filepath: path.resolve(dir, config.filepath),\n input: config.input,\n presetToAdd,\n });\n\n return { result: 'apply' };\n};\n\nexport const tryPatchRenovateConfig = (async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n // In a monorepo we may be invoked within a subdirectory, but we are working\n // with Renovate config that should be relative to the repository root.\n const gitRoot = await Git.findRoot({ dir });\n if (!gitRoot) {\n return { result: 'skip', reason: 'no Git root found' };\n }\n\n return await patchRenovateConfig(mode, gitRoot);\n } catch (err) {\n log.warn('Failed to patch Renovate config.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n}) satisfies PatchFunction;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAAe;AACf,aAAwB;AACxB,iBAAkB;AAElB,UAAqB;AACrB,qBAAoB;AAEpB,qBAA4C;AAC5C,sBAA0C;AAC1C,sBAA+B;AAG/B,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AACF;AAEA,MAAM,6BAA6B;AAMnC,MAAM,uBAAuB,aAAE,OAAO;AAAA,EACpC,SAAS,aAAE,MAAM,aAAE,OAAO,CAAC;AAC7B,CAAC;AAED,MAAM,wBAAwB,CAAC,UAA8C;AAC3E,QAAM,iBAAiB,MAAM,YAAY;AAEzC,UAAQ,gBAAgB;AAAA,IACtB,KAAK;AACH,aAAO;AAAA,IAET,KAAK;AACH,aAAO;AAAA,IAET;AACE;AAAA,EACJ;AACF;AAQA,MAAM,YAAuB,OAAO,EAAE,UAAU,OAAO,YAAY,MAAM;AACvE,QAAM,OAAgB,KAAK,MAAM,KAAK;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AAClB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AAEA;AAAA;AAAA;AAAA,IAGE,OAAO,MAAM,SAAS,WAAW;AAAA,IAEjC,2BAA2B,KAAK,OAAO,KAAK;AAAA,IAC5C;AACA,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,WAA6B,OAAO,SACvC,YAAY,EACZ,SAAS,QAAQ,IAChB,UACA;AAEJ,QAAM,YAAY,gBAAgB,QAAQ;AAE1C,QAAM,UAAU;AAAA,IACd,UAAU,YAAAC,QAAK,QAAQ,KAAK,OAAO,QAAQ;AAAA,IAC3C,OAAO,OAAO;AAAA,IACd;AAAA,EACF,CAAC;AAED,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,yBAA0B,OACrC,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AAGF,UAAM,UAAU,MAAM,IAAI,SAAS,EAAE,IAAI,CAAC;AAC1C,QAAI,CAAC,SAAS;AACZ,aAAO,EAAE,QAAQ,QAAQ,QAAQ,oBAAoB;AAAA,IACvD;AAEA,WAAO,MAAM,oBAAoB,MAAM,OAAO;AAAA,EAChD,SAAS,KAAK;AACZ,uBAAI,KAAK,kCAAkC;AAC3C,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": ["fs", "path"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PackageJson as TypeFestPackageJson } from 'type-fest';
|
|
2
2
|
import type { ProjectType } from '../../utils/manifest';
|
|
3
|
+
import type { PackageManagerConfig } from '../../utils/packageManager';
|
|
3
4
|
export type { TsConfigJson } from 'type-fest';
|
|
4
5
|
export type PackageJson = TypeFestPackageJson & Record<string, unknown>;
|
|
5
6
|
export interface DependencySet {
|
|
@@ -22,5 +23,6 @@ export interface Options {
|
|
|
22
23
|
destinationRoot: string;
|
|
23
24
|
entryPoint: string;
|
|
24
25
|
firstRun: boolean;
|
|
26
|
+
packageManager: PackageManagerConfig;
|
|
25
27
|
type: ProjectType;
|
|
26
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/configure/types.ts"],
|
|
4
|
-
"sourcesContent": ["import type { PackageJson as TypeFestPackageJson } from 'type-fest';\n\nimport type { ProjectType } from '../../utils/manifest';\n\nexport type { TsConfigJson } from 'type-fest';\n\nexport type PackageJson = TypeFestPackageJson & Record<string, unknown>;\n\nexport interface DependencySet {\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n type: ProjectType;\n}\n\nexport type DependencyDiff = Record<\n string,\n { operation: string; version: string }\n>;\n\ntype FileProcessor = (\n file: string | undefined,\n files: Files,\n initialFiles: Readonly<Files>,\n) => Promise<string | undefined> | string | undefined;\n\nexport type FileDiff = Record<\n string,\n { data: string | undefined; operation: string }\n>;\n\nexport type Files = Record<string, string | undefined>;\n\nexport type Module = Record<string, FileProcessor>;\n\nexport interface Options {\n destinationRoot: string;\n entryPoint: string;\n firstRun: boolean;\n type: ProjectType;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type { PackageJson as TypeFestPackageJson } from 'type-fest';\n\nimport type { ProjectType } from '../../utils/manifest';\nimport type { PackageManagerConfig } from '../../utils/packageManager';\n\nexport type { TsConfigJson } from 'type-fest';\n\nexport type PackageJson = TypeFestPackageJson & Record<string, unknown>;\n\nexport interface DependencySet {\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n type: ProjectType;\n}\n\nexport type DependencyDiff = Record<\n string,\n { operation: string; version: string }\n>;\n\ntype FileProcessor = (\n file: string | undefined,\n files: Files,\n initialFiles: Readonly<Files>,\n) => Promise<string | undefined> | string | undefined;\n\nexport type FileDiff = Record<\n string,\n { data: string | undefined; operation: string }\n>;\n\nexport type Files = Record<string, string | undefined>;\n\nexport type Module = Record<string, FileProcessor>;\n\nexport interface Options {\n destinationRoot: string;\n entryPoint: string;\n firstRun: boolean;\n packageManager: PackageManagerConfig;\n type: ProjectType;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Logger } from '../../../utils/logging';
|
|
2
|
+
import type { InternalLintResult } from '../../lint/internal';
|
|
3
|
+
export type Patches = Patch[];
|
|
4
|
+
export type Patch = {
|
|
5
|
+
apply: PatchFunction;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
export type PatchReturnType = {
|
|
9
|
+
result: 'apply';
|
|
10
|
+
} | {
|
|
11
|
+
result: 'skip';
|
|
12
|
+
reason?: string;
|
|
13
|
+
};
|
|
14
|
+
export type PatchFunction = (mode: 'format' | 'lint') => Promise<PatchReturnType>;
|
|
15
|
+
export declare const upgradeSkuba: (mode: 'lint' | 'format', logger: Logger) => Promise<InternalLintResult>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var upgrade_exports = {};
|
|
30
|
+
__export(upgrade_exports, {
|
|
31
|
+
upgradeSkuba: () => upgradeSkuba
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(upgrade_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_fs_extra = require("fs-extra");
|
|
36
|
+
var import_semver = require("semver");
|
|
37
|
+
var import_manifest = require("../../../utils/manifest");
|
|
38
|
+
var import_packageManager = require("../../../utils/packageManager");
|
|
39
|
+
var import_version = require("../../../utils/version");
|
|
40
|
+
var import_package = require("../processing/package");
|
|
41
|
+
const getPatches = async (manifestVersion) => {
|
|
42
|
+
const patches = await (0, import_fs_extra.readdir)(import_path.default.join(__dirname, "patches"));
|
|
43
|
+
const patchesForVersion = (0, import_semver.sort)(
|
|
44
|
+
patches.filter((filename) => (0, import_semver.gte)(filename, manifestVersion))
|
|
45
|
+
);
|
|
46
|
+
return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();
|
|
47
|
+
};
|
|
48
|
+
const fileExtensions = ["js", "ts"];
|
|
49
|
+
const resolvePatches = async (version) => {
|
|
50
|
+
for (const extension of fileExtensions) {
|
|
51
|
+
try {
|
|
52
|
+
return (await import(`./patches/${version}/index.${extension}`)).patches;
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Could not resolve patches for ${version}`);
|
|
57
|
+
};
|
|
58
|
+
const upgradeSkuba = async (mode, logger) => {
|
|
59
|
+
const [currentVersion, manifest] = await Promise.all([
|
|
60
|
+
(0, import_version.getSkubaVersion)(),
|
|
61
|
+
(0, import_manifest.getConsumerManifest)()
|
|
62
|
+
]);
|
|
63
|
+
if (!manifest) {
|
|
64
|
+
throw new Error("Could not find a package json for this project");
|
|
65
|
+
}
|
|
66
|
+
manifest.packageJson.skuba ??= { version: "1.0.0" };
|
|
67
|
+
const manifestVersion = manifest.packageJson.skuba.version;
|
|
68
|
+
if ((0, import_semver.gte)(manifestVersion, currentVersion)) {
|
|
69
|
+
return { ok: true, fixable: false };
|
|
70
|
+
}
|
|
71
|
+
const patches = await getPatches(manifestVersion);
|
|
72
|
+
if (patches.length === 0) {
|
|
73
|
+
return { ok: true, fixable: false };
|
|
74
|
+
}
|
|
75
|
+
if (mode === "lint") {
|
|
76
|
+
const results = await Promise.all(
|
|
77
|
+
patches.map(async ({ apply }) => await apply(mode))
|
|
78
|
+
);
|
|
79
|
+
if (results.every(({ result }) => result === "skip")) {
|
|
80
|
+
return { ok: true, fixable: false };
|
|
81
|
+
}
|
|
82
|
+
const packageManager = await (0, import_packageManager.detectPackageManager)();
|
|
83
|
+
logger.warn(
|
|
84
|
+
`skuba has patches to apply. Run ${logger.bold(
|
|
85
|
+
packageManager.exec,
|
|
86
|
+
"skuba",
|
|
87
|
+
"format"
|
|
88
|
+
)} to run them. ${logger.dim("skuba-patches")}`
|
|
89
|
+
);
|
|
90
|
+
return {
|
|
91
|
+
ok: false,
|
|
92
|
+
fixable: true,
|
|
93
|
+
annotations: [
|
|
94
|
+
{
|
|
95
|
+
// package.json as likely skuba version has changed
|
|
96
|
+
// TODO: locate the "skuba": {} config in the package.json and annotate on the version property
|
|
97
|
+
path: manifest.path,
|
|
98
|
+
message: `skuba has patches to apply. Run ${packageManager.exec} skuba format to run them.`
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
logger.plain("Updating skuba...");
|
|
104
|
+
for (const { apply, description } of patches) {
|
|
105
|
+
const result = await apply(mode);
|
|
106
|
+
logger.newline();
|
|
107
|
+
if (result.result === "skip") {
|
|
108
|
+
logger.plain(
|
|
109
|
+
`Patch skipped: ${description}${result.reason ? ` - ${result.reason}` : ""}`
|
|
110
|
+
);
|
|
111
|
+
} else {
|
|
112
|
+
logger.plain(`Patch applied: ${description}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
manifest.packageJson.skuba.version = currentVersion;
|
|
116
|
+
const updatedPackageJson = await (0, import_package.formatPackage)(manifest.packageJson);
|
|
117
|
+
await (0, import_fs_extra.writeFile)(manifest.path, updatedPackageJson);
|
|
118
|
+
logger.newline();
|
|
119
|
+
logger.plain("skuba update complete.");
|
|
120
|
+
logger.newline();
|
|
121
|
+
return {
|
|
122
|
+
ok: true,
|
|
123
|
+
fixable: false
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
128
|
+
upgradeSkuba
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/configure/upgrade/index.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport { readdir, writeFile } from 'fs-extra';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../utils/logging';\nimport { getConsumerManifest } from '../../../utils/manifest';\nimport { detectPackageManager } from '../../../utils/packageManager';\nimport { getSkubaVersion } from '../../../utils/version';\nimport type { SkubaPackageJson } from '../../init/writePackageJson';\nimport type { InternalLintResult } from '../../lint/internal';\nimport { formatPackage } from '../processing/package';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\nexport type PatchFunction = (\n mode: 'format' | 'lint',\n) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await readdir(path.join(__dirname, 'patches'));\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.filter((filename) => gte(filename, manifestVersion)),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = (manifest.packageJson.skuba as SkubaPackageJson)\n .version;\n\n // We are up to date, skip patches\n if (gte(manifestVersion, currentVersion)) {\n return { ok: true, fixable: false };\n }\n\n const patches = await getPatches(manifestVersion);\n // No patches to apply even if version out of date. Early exit to avoid unnecessary commits.\n if (patches.length === 0) {\n return { ok: true, fixable: false };\n }\n\n if (mode === 'lint') {\n const results = await Promise.all(\n patches.map(async ({ apply }) => await apply(mode)),\n );\n\n // No patches are applicable. Early exit to avoid unnecessary commits.\n if (results.every(({ result }) => result === 'skip')) {\n return { ok: true, fixable: false };\n }\n\n const packageManager = await detectPackageManager();\n\n logger.warn(\n `skuba has patches to apply. Run ${logger.bold(\n packageManager.exec,\n 'skuba',\n 'format',\n )} to run them. ${logger.dim('skuba-patches')}`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: [\n {\n // package.json as likely skuba version has changed\n // TODO: locate the \"skuba\": {} config in the package.json and annotate on the version property\n path: manifest.path,\n message: `skuba has patches to apply. Run ${packageManager.exec} skuba format to run them.`,\n },\n ],\n };\n }\n\n logger.plain('Updating skuba...');\n\n // Run these in series in case a subsequent patch relies on a previous patch\n for (const { apply, description } of patches) {\n const result = await apply(mode);\n logger.newline();\n if (result.result === 'skip') {\n logger.plain(\n `Patch skipped: ${description}${\n result.reason ? ` - ${result.reason}` : ''\n }`,\n );\n } else {\n logger.plain(`Patch applied: ${description}`);\n }\n }\n\n (manifest.packageJson.skuba as SkubaPackageJson).version = currentVersion;\n\n const updatedPackageJson = await formatPackage(manifest.packageJson);\n\n await writeFile(manifest.path, updatedPackageJson);\n logger.newline();\n logger.plain('skuba update complete.');\n logger.newline();\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAmC;AACnC,oBAA0B;AAG1B,sBAAoC;AACpC,4BAAqC;AACrC,qBAAgC;AAGhC,qBAA8B;AAc9B,MAAM,aAAa,OAAO,oBAA8C;AACtE,QAAM,UAAU,UAAM,yBAAQ,YAAAA,QAAK,KAAK,WAAW,SAAS,CAAC;AAI7D,QAAM,wBAAoB;AAAA,IACxB,QAAQ,OAAO,CAAC,iBAAa,mBAAI,UAAU,eAAe,CAAC;AAAA,EAC7D;AAEA,U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ACF,CAAC,iBAAiB,OAAO,IAAI,eAAe,CAAC;AAAA,IAC/C;AAEA,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,QACX;AAAA;AAAA;AAAA,UAGE,MAAM,SAAS;AAAA,UACf,SAAS,mCAAmC,eAAe,IAAI;AAAA,QACjE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,MAAM,mBAAmB;AAGhC,aAAW,EAAE,OAAO,YAAY,KAAK,SAAS;AAC5C,UAAM,SAAS,MAAM,MAAM,IAAI;AAC/B,WAAO,QAAQ;AACf,QAAI,OAAO,WAAW,QAAQ;AAC5B,aAAO;AAAA,QACL,kBAAkB,WAAW,GAC3B,OAAO,SAAS,MAAM,OAAO,MAAM,KAAK,EAC1C;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO,MAAM,kBAAkB,WAAW,EAAE;AAAA,IAC9C;AAAA,EACF;AAEA,EAAC,SAAS,YAAY,MAA2B,UAAU;AAE3D,QAAM,qBAAqB,UAAM,8BAAc,SAAS,WAAW;AAEnE,YAAM,2BAAU,SAAS,MAAM,kBAAkB;AACjD,SAAO,QAAQ;AACf,SAAO,MAAM,wBAAwB;AACrC,SAAO,QAAQ;AAEf,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
|
|
6
|
+
"names": ["path"]
|
|
7
|
+
}
|
package/lib/cli/configure/{addEmptyExports.d.ts → upgrade/patches/7.3.1/addEmptyExports.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PatchFunction } from '../..';
|
|
2
2
|
/**
|
|
3
3
|
* Tries to add an empty `export {}` statement to the bottom of Jest setup files
|
|
4
4
|
* for compliance with TypeScript isolated modules.
|
|
5
5
|
*/
|
|
6
|
-
export declare const tryAddEmptyExports:
|
|
6
|
+
export declare const tryAddEmptyExports: PatchFunction;
|
|
@@ -28,19 +28,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var addEmptyExports_exports = {};
|
|
30
30
|
__export(addEmptyExports_exports, {
|
|
31
|
-
JEST_SETUP_FILES: () => JEST_SETUP_FILES,
|
|
32
31
|
tryAddEmptyExports: () => tryAddEmptyExports
|
|
33
32
|
});
|
|
34
33
|
module.exports = __toCommonJS(addEmptyExports_exports);
|
|
35
34
|
var import_path = __toESM(require("path"));
|
|
36
35
|
var import_util = require("util");
|
|
37
36
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
|
-
var import_logging = require("
|
|
39
|
-
var import_package = require("
|
|
40
|
-
var import_project = require("
|
|
41
|
-
var import_prettier = require("
|
|
37
|
+
var import_logging = require("../../../../../utils/logging");
|
|
38
|
+
var import_package = require("../../../analysis/package");
|
|
39
|
+
var import_project = require("../../../analysis/project");
|
|
40
|
+
var import_prettier = require("../../../processing/prettier");
|
|
42
41
|
const JEST_SETUP_FILES = ["jest.setup.ts", "jest.setup.int.ts"];
|
|
43
|
-
const addEmptyExports = async () => {
|
|
42
|
+
const addEmptyExports = async (mode) => {
|
|
44
43
|
const manifest = await (0, import_package.getDestinationManifest)();
|
|
45
44
|
const destinationRoot = import_path.default.dirname(manifest.path);
|
|
46
45
|
const readDestinationFile = (0, import_project.createDestinationFileReader)(destinationRoot);
|
|
@@ -50,27 +49,32 @@ const addEmptyExports = async () => {
|
|
|
50
49
|
// with isolated modules. This is a very naive check that we don't want to
|
|
51
50
|
// overcomplicate because it is invoked before many skuba commands.
|
|
52
51
|
inputFile.includes("import ") || inputFile.includes("export ")) {
|
|
53
|
-
return;
|
|
52
|
+
return "skip";
|
|
53
|
+
}
|
|
54
|
+
if (mode === "lint") {
|
|
55
|
+
return "apply";
|
|
54
56
|
}
|
|
55
57
|
const data = await (0, import_prettier.formatPrettier)([inputFile, "export {}"].join("\n\n"), {
|
|
56
58
|
parser: "typescript"
|
|
57
59
|
});
|
|
58
60
|
const filepath = import_path.default.join(destinationRoot, filename);
|
|
59
61
|
await import_fs_extra.default.promises.writeFile(filepath, data);
|
|
62
|
+
return "apply";
|
|
60
63
|
};
|
|
61
|
-
await Promise.all(JEST_SETUP_FILES.map(addEmptyExport));
|
|
64
|
+
const results = await Promise.all(JEST_SETUP_FILES.map(addEmptyExport));
|
|
65
|
+
return results.every((result) => result === "skip") ? "skip" : "apply";
|
|
62
66
|
};
|
|
63
|
-
const tryAddEmptyExports = async () => {
|
|
67
|
+
const tryAddEmptyExports = async (mode) => {
|
|
64
68
|
try {
|
|
65
|
-
await addEmptyExports();
|
|
69
|
+
return { result: await addEmptyExports(mode) };
|
|
66
70
|
} catch (err) {
|
|
67
71
|
import_logging.log.warn("Failed to convert Jest setup files to isolated modules.");
|
|
68
72
|
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
73
|
+
return { result: "skip", reason: "due to an error" };
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
76
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
77
|
0 && (module.exports = {
|
|
73
|
-
JEST_SETUP_FILES,
|
|
74
78
|
tryAddEmptyExports
|
|
75
79
|
});
|
|
76
80
|
//# sourceMappingURL=addEmptyExports.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/addEmptyExports.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction } from '../..';\nimport { log } from '../../../../../utils/logging';\nimport { getDestinationManifest } from '../../../analysis/package';\nimport { createDestinationFileReader } from '../../../analysis/project';\nimport { formatPrettier } from '../../../processing/prettier';\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 (\n mode: 'format' | 'lint',\n) => {\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAAuC;AACvC,qBAA4C;AAC5C,sBAA+B;AAE/B,MAAM,mBAAmB,CAAC,iBAAiB,mBAAmB;AAE9D,MAAM,kBAAkB,OAAO,SAA4B;AACzD,QAAM,WAAW,UAAM,uCAAuB;AAE9C,QAAM,kBAAkB,YAAAA,QAAK,QAAQ,SAAS,IAAI;AAElD,QAAM,0BAAsB,4CAA4B,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,UAAM,gCAAe,CAAC,WAAW,WAAW,EAAE,KAAK,MAAM,GAAG;AAAA,MACvE,QAAQ;AAAA,IACV,CAAC;AAED,UAAM,WAAW,YAAAA,QAAK,KAAK,iBAAiB,QAAQ;AAEpD,UAAM,gBAAAC,QAAG,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,OAC/C,SACG;AACH,MAAI;AACF,WAAO,EAAE,QAAQ,MAAM,gBAAgB,IAAI,EAAE;AAAA,EAC/C,SAAS,KAAK;AACZ,uBAAI,KAAK,yDAAyD;AAClE,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["path", "fs"]
|
|
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 __exports = {};
|
|
20
|
+
__export(__exports, {
|
|
21
|
+
patches: () => patches
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(__exports);
|
|
24
|
+
var import_patchRenovateConfig = require("../../../patchRenovateConfig");
|
|
25
|
+
var import_addEmptyExports = require("./addEmptyExports");
|
|
26
|
+
var import_moveNpmrcOutOfGitignoreManagedSection = require("./moveNpmrcOutOfGitignoreManagedSection");
|
|
27
|
+
var import_patchDockerfile = require("./patchDockerfile");
|
|
28
|
+
var import_patchServerListener = require("./patchServerListener");
|
|
29
|
+
const patches = [
|
|
30
|
+
{
|
|
31
|
+
apply: import_addEmptyExports.tryAddEmptyExports,
|
|
32
|
+
description: "Add empty exports to Jest files for compliance with TypeScript isolated modules"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
apply: import_patchRenovateConfig.tryPatchRenovateConfig,
|
|
36
|
+
description: "Update Renovate config to support private SEEK packages"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
apply: import_patchDockerfile.tryPatchDockerfile,
|
|
40
|
+
description: "Upgrade Node.js Distroless Docker image to -debian12 variant"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
apply: import_patchServerListener.tryPatchServerListener,
|
|
44
|
+
description: "Add keepAliveTimeout to server listener"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
apply: import_moveNpmrcOutOfGitignoreManagedSection.tryMoveNpmrcOutOfGitignoreManagedSection,
|
|
48
|
+
description: "Move .npmrc out of the .gitignore managed section"
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
patches
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/index.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Patches } from '../..';\nimport { tryPatchRenovateConfig } from '../../../patchRenovateConfig';\n\nimport { tryAddEmptyExports } from './addEmptyExports';\nimport { tryMoveNpmrcOutOfGitignoreManagedSection } from './moveNpmrcOutOfGitignoreManagedSection';\nimport { tryPatchDockerfile } from './patchDockerfile';\nimport { tryPatchServerListener } from './patchServerListener';\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 apply: tryMoveNpmrcOutOfGitignoreManagedSection,\n description: 'Move .npmrc out of the .gitignore managed section',\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iCAAuC;AAEvC,6BAAmC;AACnC,mDAAyD;AACzD,6BAAmC;AACnC,iCAAuC;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;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|