skuba 10.0.0-node-22-20250213082332 → 10.0.0-node-22-20250218232801
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/init/index.js +2 -2
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/{10.0.0 → 9.1.0}/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/{10.0.0 → 9.1.0}/upgradeNode.js +5 -1
- package/lib/cli/lint/internalLints/upgrade/patches/{10.0.0 → 9.1.0}/upgradeNode.js.map +3 -3
- package/lib/cli/migrate/index.js +10 -2
- package/lib/cli/migrate/index.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/checks.d.ts +5 -0
- package/lib/cli/migrate/nodeVersion/checks.js +128 -0
- package/lib/cli/migrate/nodeVersion/checks.js.map +7 -0
- package/lib/cli/migrate/nodeVersion/getNodeTypesVersion.d.ts +6 -0
- package/lib/cli/migrate/nodeVersion/getNodeTypesVersion.js +73 -0
- package/lib/cli/migrate/nodeVersion/getNodeTypesVersion.js.map +7 -0
- package/lib/cli/migrate/nodeVersion/index.d.ts +2 -1
- package/lib/cli/migrate/nodeVersion/index.js +60 -107
- package/lib/cli/migrate/nodeVersion/index.js.map +2 -2
- package/package.json +4 -2
- package/template/greeter/package.json +1 -1
- package/template/koa-rest-api/Dockerfile.dev-deps +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +1 -1
- package/lib/cli/migrate/nodeVersion/getNode22TypesVersion.d.ts +0 -6
- package/lib/cli/migrate/nodeVersion/getNode22TypesVersion.js +0 -50
- package/lib/cli/migrate/nodeVersion/getNode22TypesVersion.js.map +0 -7
- package/lib/cli/migrate/nodeVersion/packageJsonChecks.d.ts +0 -2
- package/lib/cli/migrate/nodeVersion/packageJsonChecks.js +0 -94
- package/lib/cli/migrate/nodeVersion/packageJsonChecks.js.map +0 -7
- /package/lib/cli/lint/internalLints/upgrade/patches/{10.0.0 → 9.1.0}/index.d.ts +0 -0
- /package/lib/cli/lint/internalLints/upgrade/patches/{10.0.0 → 9.1.0}/index.js +0 -0
- /package/lib/cli/lint/internalLints/upgrade/patches/{10.0.0 → 9.1.0}/upgradeNode.d.ts +0 -0
package/lib/cli/init/index.js
CHANGED
|
@@ -102,8 +102,8 @@ const init = async (args = process.argv.slice(2)) => {
|
|
|
102
102
|
import_logging.log.newline();
|
|
103
103
|
await (0, import_git2.initialiseRepo)(destinationDir, templateData);
|
|
104
104
|
const [manifest, packageManagerConfig] = await Promise.all([
|
|
105
|
-
(0, import_manifest.getConsumerManifest)(),
|
|
106
|
-
(0, import_packageManager.detectPackageManager)()
|
|
105
|
+
(0, import_manifest.getConsumerManifest)(destinationDir),
|
|
106
|
+
(0, import_packageManager.detectPackageManager)(destinationDir)
|
|
107
107
|
]);
|
|
108
108
|
if (!manifest) {
|
|
109
109
|
throw new Error("Repository doesn't contain a package.json file.");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/index.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { commitAllChanges } from '../../api/git';\nimport { hasDebugFlag } from '../../utils/args';\nimport { copyFiles, createEjsRenderer } from '../../utils/copy';\nimport { createInclusionFilter } from '../../utils/dir';\nimport { createExec, ensureCommands } from '../../utils/exec';\nimport { createLogger, log } from '../../utils/logging';\nimport { showLogoAndVersionInfo } from '../../utils/logo';\nimport { getConsumerManifest } from '../../utils/manifest';\nimport { detectPackageManager } from '../../utils/packageManager';\nimport {\n BASE_TEMPLATE_DIR,\n ensureTemplateConfigDeletion,\n} from '../../utils/template';\nimport { runPrettier } from '../adapter/prettier';\nimport { tryPatchRenovateConfig } from '../lint/internalLints/patchRenovateConfig';\n\nimport { getConfig } from './getConfig';\nimport { initialiseRepo } from './git';\nimport type { Input } from './types';\nimport { writePackageJson } from './writePackageJson';\n\nexport const init = async (args = process.argv.slice(2)) => {\n const opts: Input = {\n debug: hasDebugFlag(args),\n };\n\n const skubaVersionInfo = await showLogoAndVersionInfo();\n\n const {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete,\n templateData,\n templateName,\n type,\n } = await getConfig();\n\n await ensureCommands(packageManager);\n\n const include = await createInclusionFilter([\n path.join(destinationDir, '.gitignore'),\n path.join(BASE_TEMPLATE_DIR, '_.gitignore'),\n ]);\n\n const processors = [createEjsRenderer(templateData)];\n\n await copyFiles({\n sourceRoot: BASE_TEMPLATE_DIR,\n destinationRoot: destinationDir,\n include,\n // prefer template-specific files\n overwrite: false,\n processors,\n // base template has files like _eslint.config.js\n stripUnderscorePrefix: true,\n });\n\n await copyFiles({\n sourceRoot: destinationDir,\n destinationRoot: destinationDir,\n include,\n processors,\n });\n\n await Promise.all([\n templateComplete\n ? ensureTemplateConfigDeletion(destinationDir)\n : Promise.resolve(),\n\n writePackageJson({\n cwd: destinationDir,\n entryPoint,\n template: templateName,\n type,\n version: skubaVersionInfo.local,\n }),\n ]);\n\n const exec = createExec({\n cwd: destinationDir,\n stdio: 'pipe',\n streamStdio: packageManager,\n });\n\n log.newline();\n await initialiseRepo(destinationDir, templateData);\n\n const [manifest, packageManagerConfig] = await Promise.all([\n getConsumerManifest(),\n detectPackageManager(),\n ]);\n\n if (!manifest) {\n throw new Error(\"Repository doesn't contain a package.json file.\");\n }\n\n // Patch in a baseline Renovate preset based on the configured Git owner.\n await tryPatchRenovateConfig({\n mode: 'format',\n dir: destinationDir,\n manifest,\n packageManager: packageManagerConfig,\n });\n\n const skubaSlug = `skuba@${skubaVersionInfo.local}`;\n\n let depsInstalled = false;\n try {\n // The `-D` shorthand is portable across our package managers.\n await exec(packageManager, 'add', '-D', skubaSlug);\n\n // Templating can initially leave certain files in an unformatted state;\n // consider a Markdown table with columns sized based on content length.\n await runPrettier('format', createLogger(opts.debug), destinationDir);\n\n depsInstalled = true;\n } catch (err) {\n log.warn(inspect(err));\n }\n\n await commitAllChanges({\n dir: destinationDir,\n message: `Clone ${templateName}`,\n });\n\n const logGitHubRepoCreation = () => {\n log.plain(\n 'Next, create an empty',\n log.bold(`${templateData.orgName}/${templateData.repoName}`),\n 'repository:',\n );\n log.ok('https://github.com/new');\n };\n\n if (!depsInstalled) {\n log.newline();\n log.warn(log.bold('\u2717 Failed to install dependencies.'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, resume initialisation:');\n log.ok('cd', destinationDir);\n // The `-D` shorthand is portable across our package managers.\n log.ok(packageManager, 'add', '-D', skubaSlug);\n log.ok(packageManager, 'run', 'format');\n log.ok('git add --all');\n log.ok('git commit --message', `'Pin ${skubaSlug}'`);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n process.exitCode = 1;\n return;\n }\n\n log.newline();\n log.ok(log.bold('\u2714 Project initialised!'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, push your local changes:');\n log.ok('cd', destinationDir);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,iBAAiC;AACjC,kBAA6B;AAC7B,kBAA6C;AAC7C,iBAAsC;AACtC,kBAA2C;AAC3C,qBAAkC;AAClC,kBAAuC;AACvC,sBAAoC;AACpC,4BAAqC;AACrC,sBAGO;AACP,sBAA4B;AAC5B,iCAAuC;AAEvC,uBAA0B;AAC1B,IAAAA,cAA+B;AAE/B,8BAAiC;AAE1B,MAAM,OAAO,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAC1D,QAAM,OAAc;AAAA,IAClB,WAAO,0BAAa,IAAI;AAAA,EAC1B;AAEA,QAAM,mBAAmB,UAAM,oCAAuB;AAEtD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,UAAM,4BAAU;AAEpB,YAAM,4BAAe,cAAc;AAEnC,QAAM,UAAU,UAAM,kCAAsB;AAAA,IAC1C,YAAAC,QAAK,KAAK,gBAAgB,YAAY;AAAA,IACtC,YAAAA,QAAK,KAAK,mCAAmB,aAAa;AAAA,EAC5C,CAAC;AAED,QAAM,aAAa,KAAC,+BAAkB,YAAY,CAAC;AAEnD,YAAM,uBAAU;AAAA,IACd,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB;AAAA;AAAA,IAEA,WAAW;AAAA,IACX;AAAA;AAAA,IAEA,uBAAuB;AAAA,EACzB,CAAC;AAED,YAAM,uBAAU;AAAA,IACd,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,QAAQ,IAAI;AAAA,IAChB,uBACI,8CAA6B,cAAc,IAC3C,QAAQ,QAAQ;AAAA,QAEpB,0CAAiB;AAAA,MACf,KAAK;AAAA,MACL;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA,SAAS,iBAAiB;AAAA,IAC5B,CAAC;AAAA,EACH,CAAC;AAED,QAAM,WAAO,wBAAW;AAAA,IACtB,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,EACf,CAAC;AAED,qBAAI,QAAQ;AACZ,YAAM,4BAAe,gBAAgB,YAAY;AAEjD,QAAM,CAAC,UAAU,oBAAoB,IAAI,MAAM,QAAQ,IAAI;AAAA,QACzD,qCAAoB;AAAA,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { commitAllChanges } from '../../api/git';\nimport { hasDebugFlag } from '../../utils/args';\nimport { copyFiles, createEjsRenderer } from '../../utils/copy';\nimport { createInclusionFilter } from '../../utils/dir';\nimport { createExec, ensureCommands } from '../../utils/exec';\nimport { createLogger, log } from '../../utils/logging';\nimport { showLogoAndVersionInfo } from '../../utils/logo';\nimport { getConsumerManifest } from '../../utils/manifest';\nimport { detectPackageManager } from '../../utils/packageManager';\nimport {\n BASE_TEMPLATE_DIR,\n ensureTemplateConfigDeletion,\n} from '../../utils/template';\nimport { runPrettier } from '../adapter/prettier';\nimport { tryPatchRenovateConfig } from '../lint/internalLints/patchRenovateConfig';\n\nimport { getConfig } from './getConfig';\nimport { initialiseRepo } from './git';\nimport type { Input } from './types';\nimport { writePackageJson } from './writePackageJson';\n\nexport const init = async (args = process.argv.slice(2)) => {\n const opts: Input = {\n debug: hasDebugFlag(args),\n };\n\n const skubaVersionInfo = await showLogoAndVersionInfo();\n\n const {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete,\n templateData,\n templateName,\n type,\n } = await getConfig();\n\n await ensureCommands(packageManager);\n\n const include = await createInclusionFilter([\n path.join(destinationDir, '.gitignore'),\n path.join(BASE_TEMPLATE_DIR, '_.gitignore'),\n ]);\n\n const processors = [createEjsRenderer(templateData)];\n\n await copyFiles({\n sourceRoot: BASE_TEMPLATE_DIR,\n destinationRoot: destinationDir,\n include,\n // prefer template-specific files\n overwrite: false,\n processors,\n // base template has files like _eslint.config.js\n stripUnderscorePrefix: true,\n });\n\n await copyFiles({\n sourceRoot: destinationDir,\n destinationRoot: destinationDir,\n include,\n processors,\n });\n\n await Promise.all([\n templateComplete\n ? ensureTemplateConfigDeletion(destinationDir)\n : Promise.resolve(),\n\n writePackageJson({\n cwd: destinationDir,\n entryPoint,\n template: templateName,\n type,\n version: skubaVersionInfo.local,\n }),\n ]);\n\n const exec = createExec({\n cwd: destinationDir,\n stdio: 'pipe',\n streamStdio: packageManager,\n });\n\n log.newline();\n await initialiseRepo(destinationDir, templateData);\n\n const [manifest, packageManagerConfig] = await Promise.all([\n getConsumerManifest(destinationDir),\n detectPackageManager(destinationDir),\n ]);\n\n if (!manifest) {\n throw new Error(\"Repository doesn't contain a package.json file.\");\n }\n\n // Patch in a baseline Renovate preset based on the configured Git owner.\n await tryPatchRenovateConfig({\n mode: 'format',\n dir: destinationDir,\n manifest,\n packageManager: packageManagerConfig,\n });\n\n const skubaSlug = `skuba@${skubaVersionInfo.local}`;\n\n let depsInstalled = false;\n try {\n // The `-D` shorthand is portable across our package managers.\n await exec(packageManager, 'add', '-D', skubaSlug);\n\n // Templating can initially leave certain files in an unformatted state;\n // consider a Markdown table with columns sized based on content length.\n await runPrettier('format', createLogger(opts.debug), destinationDir);\n\n depsInstalled = true;\n } catch (err) {\n log.warn(inspect(err));\n }\n\n await commitAllChanges({\n dir: destinationDir,\n message: `Clone ${templateName}`,\n });\n\n const logGitHubRepoCreation = () => {\n log.plain(\n 'Next, create an empty',\n log.bold(`${templateData.orgName}/${templateData.repoName}`),\n 'repository:',\n );\n log.ok('https://github.com/new');\n };\n\n if (!depsInstalled) {\n log.newline();\n log.warn(log.bold('\u2717 Failed to install dependencies.'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, resume initialisation:');\n log.ok('cd', destinationDir);\n // The `-D` shorthand is portable across our package managers.\n log.ok(packageManager, 'add', '-D', skubaSlug);\n log.ok(packageManager, 'run', 'format');\n log.ok('git add --all');\n log.ok('git commit --message', `'Pin ${skubaSlug}'`);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n process.exitCode = 1;\n return;\n }\n\n log.newline();\n log.ok(log.bold('\u2714 Project initialised!'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, push your local changes:');\n log.ok('cd', destinationDir);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,iBAAiC;AACjC,kBAA6B;AAC7B,kBAA6C;AAC7C,iBAAsC;AACtC,kBAA2C;AAC3C,qBAAkC;AAClC,kBAAuC;AACvC,sBA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AErE,uBAAI,QAAQ;AACZ,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,qBAAI,QAAQ;AACZ,qBAAI,GAAG,mBAAI,KAAK,6BAAwB,CAAC;AAEzC,qBAAI,QAAQ;AACZ,wBAAsB;AAEtB,qBAAI,QAAQ;AACZ,qBAAI,MAAM,gCAAgC;AAC1C,qBAAI,GAAG,MAAM,cAAc;AAC3B,qBAAI,GAAG,kCAAkC,aAAa,aAAa,EAAE;AAErE,qBAAI,QAAQ;AACd;",
|
|
6
6
|
"names": ["import_git", "path"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/9.1.0/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { Patches } from '../..';\n\nimport { tryUpgradeNode } from './upgradeNode';\n\nexport const patches: Patches = [\n {\n apply: tryUpgradeNode,\n description: 'Upgrade Node.js to version 22',\n },\n];\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAA+B;AAExB,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
@@ -36,7 +36,11 @@ const upgradeNode = async ({
|
|
|
36
36
|
if (mode === "lint") {
|
|
37
37
|
return { result: "apply" };
|
|
38
38
|
}
|
|
39
|
-
await (0, import_nodeVersion.nodeVersionMigration)({
|
|
39
|
+
await (0, import_nodeVersion.nodeVersionMigration)({
|
|
40
|
+
nodeVersion: 22,
|
|
41
|
+
ECMAScriptVersion: "ES2024",
|
|
42
|
+
defaultNodeTypesVersion: "22.9.0"
|
|
43
|
+
});
|
|
40
44
|
return { result: "apply" };
|
|
41
45
|
};
|
|
42
46
|
const tryUpgradeNode = async (config) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/
|
|
4
|
-
"sourcesContent": ["import { inspect } from 'util';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\nimport { nodeVersionMigration } from '../../../../../migrate/nodeVersion';\n\nconst upgradeNode: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n if (process.env.SKIP_NODE_UPGRADE) {\n return {\n result: 'skip',\n reason: 'SKIP_NODE_UPGRADE environment variable set',\n };\n }\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await nodeVersionMigration({
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAGxB,qBAAoB;AACpB,yBAAqC;AAErC,MAAM,cAA6B,OAAO;AAAA,EACxC;AACF,MAAgC;AAC9B,MAAI,QAAQ,IAAI,mBAAmB;AACjC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AACA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,YAAM,yCAAqB,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\nimport { nodeVersionMigration } from '../../../../../migrate/nodeVersion';\n\nconst upgradeNode: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n if (process.env.SKIP_NODE_UPGRADE) {\n return {\n result: 'skip',\n reason: 'SKIP_NODE_UPGRADE environment variable set',\n };\n }\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await nodeVersionMigration({\n nodeVersion: 22,\n ECMAScriptVersion: 'ES2024',\n defaultNodeTypesVersion: '22.9.0',\n });\n\n return { result: 'apply' };\n};\n\nexport const tryUpgradeNode: PatchFunction = async (config) => {\n try {\n return await upgradeNode(config);\n } catch (err) {\n log.warn('Failed to upgrade node version');\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,kBAAwB;AAGxB,qBAAoB;AACpB,yBAAqC;AAErC,MAAM,cAA6B,OAAO;AAAA,EACxC;AACF,MAAgC;AAC9B,MAAI,QAAQ,IAAI,mBAAmB;AACjC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AACA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,YAAM,yCAAqB;AAAA,IACzB,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B,CAAC;AAED,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,iBAAgC,OAAO,WAAW;AAC7D,MAAI;AACF,WAAO,MAAM,YAAY,MAAM;AAAA,EACjC,SAAS,KAAK;AACZ,uBAAI,KAAK,gCAAgC;AACzC,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/migrate/index.js
CHANGED
|
@@ -24,8 +24,16 @@ module.exports = __toCommonJS(migrate_exports);
|
|
|
24
24
|
var import_logging = require("../../utils/logging");
|
|
25
25
|
var import_nodeVersion = require("./nodeVersion");
|
|
26
26
|
const migrations = {
|
|
27
|
-
node20: () => (0, import_nodeVersion.nodeVersionMigration)({
|
|
28
|
-
|
|
27
|
+
node20: () => (0, import_nodeVersion.nodeVersionMigration)({
|
|
28
|
+
nodeVersion: 20,
|
|
29
|
+
ECMAScriptVersion: "ES2023",
|
|
30
|
+
defaultNodeTypesVersion: "20.14.8"
|
|
31
|
+
}),
|
|
32
|
+
node22: () => (0, import_nodeVersion.nodeVersionMigration)({
|
|
33
|
+
nodeVersion: 22,
|
|
34
|
+
ECMAScriptVersion: "ES2024",
|
|
35
|
+
defaultNodeTypesVersion: "22.9.0"
|
|
36
|
+
})
|
|
29
37
|
};
|
|
30
38
|
const logAvailableMigrations = () => {
|
|
31
39
|
import_logging.log.ok("Available migrations:");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/migrate/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { log } from '../../utils/logging';\n\nimport { nodeVersionMigration } from './nodeVersion';\n\nconst migrations: Record<string, () => Promise<void>> = {\n node20: () =>\n nodeVersionMigration({
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AAEpB,yBAAqC;AAErC,MAAM,aAAkD;AAAA,EACtD,QAAQ,UACN,yCAAqB,
|
|
4
|
+
"sourcesContent": ["import { log } from '../../utils/logging';\n\nimport { nodeVersionMigration } from './nodeVersion';\n\nconst migrations: Record<string, () => Promise<void>> = {\n node20: () =>\n nodeVersionMigration({\n nodeVersion: 20,\n ECMAScriptVersion: 'ES2023',\n defaultNodeTypesVersion: '20.14.8',\n }),\n node22: () =>\n nodeVersionMigration({\n nodeVersion: 22,\n ECMAScriptVersion: 'ES2024',\n defaultNodeTypesVersion: '22.9.0',\n }),\n};\n\nconst logAvailableMigrations = () => {\n log.ok('Available migrations:');\n Object.keys(migrations).forEach((migration) => {\n log.ok(`- ${migration}`);\n });\n};\n\nexport const migrate = async (args = process.argv.slice(2)) => {\n if (!args[0]) {\n log.err('Provide a migration to run.');\n logAvailableMigrations();\n process.exitCode = 1;\n return;\n }\n\n if (args.includes('--help') || args.includes('-h') || args[0] === 'help') {\n logAvailableMigrations();\n return;\n }\n\n const migration = migrations[args[0]];\n\n if (!migration) {\n log.err(`Migration \"${args[0]}\" is not a valid option.`);\n logAvailableMigrations();\n process.exitCode = 1;\n return;\n }\n\n await migration();\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AAEpB,yBAAqC;AAErC,MAAM,aAAkD;AAAA,EACtD,QAAQ,UACN,yCAAqB;AAAA,IACnB,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B,CAAC;AAAA,EACH,QAAQ,UACN,yCAAqB;AAAA,IACnB,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B,CAAC;AACL;AAEA,MAAM,yBAAyB,MAAM;AACnC,qBAAI,GAAG,uBAAuB;AAC9B,SAAO,KAAK,UAAU,EAAE,QAAQ,CAAC,cAAc;AAC7C,uBAAI,GAAG,KAAK,SAAS,EAAE;AAAA,EACzB,CAAC;AACH;AAEO,MAAM,UAAU,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAC7D,MAAI,CAAC,KAAK,CAAC,GAAG;AACZ,uBAAI,IAAI,6BAA6B;AACrC,2BAAuB;AACvB,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,MAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,MAAM,QAAQ;AACxE,2BAAuB;AACvB;AAAA,EACF;AAEA,QAAM,YAAY,WAAW,KAAK,CAAC,CAAC;AAEpC,MAAI,CAAC,WAAW;AACd,uBAAI,IAAI,cAAc,KAAK,CAAC,CAAC,0BAA0B;AACvD,2BAAuB;AACvB,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,QAAM,UAAU;AAClB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ZodRawShape, z } from 'zod';
|
|
2
|
+
export declare const extractFromParentPackageJson: <T extends ZodRawShape>(schema: z.ZodObject<T>) => Promise<z.infer<typeof schema> | undefined>;
|
|
3
|
+
export declare const isPatchableServerlessVersion: () => Promise<boolean>;
|
|
4
|
+
export declare const isPatchableSkubaType: () => Promise<boolean>;
|
|
5
|
+
export declare const isPatchableNodeVersion: (targetNodeVersion: number) => Promise<boolean>;
|
|
@@ -0,0 +1,128 @@
|
|
|
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 checks_exports = {};
|
|
30
|
+
__export(checks_exports, {
|
|
31
|
+
extractFromParentPackageJson: () => extractFromParentPackageJson,
|
|
32
|
+
isPatchableNodeVersion: () => isPatchableNodeVersion,
|
|
33
|
+
isPatchableServerlessVersion: () => isPatchableServerlessVersion,
|
|
34
|
+
isPatchableSkubaType: () => isPatchableSkubaType
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(checks_exports);
|
|
37
|
+
var import_find_up = __toESM(require("find-up"));
|
|
38
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
39
|
+
var import_semver = require("semver");
|
|
40
|
+
var import_zod = require("zod");
|
|
41
|
+
var import_logging = require("../../../utils/logging");
|
|
42
|
+
const getParentFile = async (file) => {
|
|
43
|
+
const path = await (0, import_find_up.default)(file, { cwd: process.cwd() });
|
|
44
|
+
if (!path) {
|
|
45
|
+
throw new Error(`${file} not found`);
|
|
46
|
+
}
|
|
47
|
+
return import_fs_extra.default.readFile(path, "utf-8");
|
|
48
|
+
};
|
|
49
|
+
const extractFromParentPackageJson = async (schema) => {
|
|
50
|
+
const packageJson = await getParentFile("package.json");
|
|
51
|
+
let rawJSON;
|
|
52
|
+
try {
|
|
53
|
+
rawJSON = JSON.parse(packageJson);
|
|
54
|
+
} catch {
|
|
55
|
+
throw new Error("package.json is not valid JSON");
|
|
56
|
+
}
|
|
57
|
+
const result = schema.safeParse(rawJSON);
|
|
58
|
+
if (!result.success) {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
return result.data;
|
|
62
|
+
};
|
|
63
|
+
const isPatchableServerlessVersion = async () => {
|
|
64
|
+
const serverlessVersion = (await extractFromParentPackageJson(
|
|
65
|
+
import_zod.z.object({
|
|
66
|
+
devDependencies: import_zod.z.object({
|
|
67
|
+
serverless: import_zod.z.string()
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
))?.devDependencies.serverless;
|
|
71
|
+
if (!serverlessVersion) {
|
|
72
|
+
import_logging.log.subtle("Serverless version not found, assuming it is not a dependency");
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (!(0, import_semver.satisfies)(serverlessVersion, "4.x.x")) {
|
|
76
|
+
import_logging.log.warn(
|
|
77
|
+
"Serverless version not supported, please upgrade to 4.x to automatically update serverless files"
|
|
78
|
+
);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
import_logging.log.ok("Serverless version is supported, proceeding with migration");
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
const isPatchableSkubaType = async () => {
|
|
85
|
+
const type = (await extractFromParentPackageJson(
|
|
86
|
+
import_zod.z.object({
|
|
87
|
+
skuba: import_zod.z.object({
|
|
88
|
+
type: import_zod.z.string()
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
))?.skuba.type;
|
|
92
|
+
if (!type) {
|
|
93
|
+
import_logging.log.warn(
|
|
94
|
+
"skuba type couldn't be found, please specify the type of project in the package.json, to ensure the correct migration is applied"
|
|
95
|
+
);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (type === "package") {
|
|
99
|
+
import_logging.log.warn(
|
|
100
|
+
"skuba type package is not supported, packages should be updated manually to ensure major runtime deprecations are intended"
|
|
101
|
+
);
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
import_logging.log.ok("skuba type supported, proceeding with migration");
|
|
105
|
+
return true;
|
|
106
|
+
};
|
|
107
|
+
const isPatchableNodeVersion = async (targetNodeVersion) => {
|
|
108
|
+
const currentNodeVersion = await getParentFile(".nvmrc");
|
|
109
|
+
const coercedTargetVersion = (0, import_semver.coerce)(targetNodeVersion.toString())?.version;
|
|
110
|
+
const coercedCurrentVersion = (0, import_semver.coerce)(currentNodeVersion)?.version;
|
|
111
|
+
const isNodeVersionValid = coercedTargetVersion && coercedCurrentVersion && (0, import_semver.lte)(coercedCurrentVersion, coercedTargetVersion);
|
|
112
|
+
if (!isNodeVersionValid) {
|
|
113
|
+
import_logging.log.warn(
|
|
114
|
+
`Node version in .nvmrc is higher than the target version ${coercedTargetVersion}, please ensure the target version is greater than the current version ${coercedCurrentVersion}`
|
|
115
|
+
);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
import_logging.log.ok("Valid node version found, proceeding with migration");
|
|
119
|
+
return true;
|
|
120
|
+
};
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
extractFromParentPackageJson,
|
|
124
|
+
isPatchableNodeVersion,
|
|
125
|
+
isPatchableServerlessVersion,
|
|
126
|
+
isPatchableSkubaType
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/migrate/nodeVersion/checks.ts"],
|
|
4
|
+
"sourcesContent": ["import findUp from 'find-up';\nimport fs from 'fs-extra';\nimport { coerce, lte, satisfies } from 'semver';\nimport { type ZodRawShape, z } from 'zod';\n\nimport { log } from '../../../utils/logging';\n\nconst getParentFile = async (file: string) => {\n const path = await findUp(file, { cwd: process.cwd() });\n if (!path) {\n throw new Error(`${file} not found`);\n }\n return fs.readFile(path, 'utf-8');\n};\n\nexport const extractFromParentPackageJson = async <T extends ZodRawShape>(\n schema: z.ZodObject<T>,\n): Promise<z.infer<typeof schema> | undefined> => {\n const packageJson = await getParentFile('package.json');\n let rawJSON;\n try {\n rawJSON = JSON.parse(packageJson) as unknown;\n } catch {\n throw new Error('package.json is not valid JSON');\n }\n const result = schema.safeParse(rawJSON);\n if (!result.success) {\n return undefined;\n }\n\n return result.data;\n};\n\nexport const isPatchableServerlessVersion = async (): Promise<boolean> => {\n const serverlessVersion = (\n await extractFromParentPackageJson(\n z.object({\n devDependencies: z.object({\n serverless: z.string(),\n }),\n }),\n )\n )?.devDependencies.serverless;\n\n if (!serverlessVersion) {\n log.subtle('Serverless version not found, assuming it is not a dependency');\n return true;\n }\n\n if (!satisfies(serverlessVersion, '4.x.x')) {\n log.warn(\n 'Serverless version not supported, please upgrade to 4.x to automatically update serverless files',\n );\n return false;\n }\n\n log.ok('Serverless version is supported, proceeding with migration');\n return true;\n};\n\nexport const isPatchableSkubaType = async (): Promise<boolean> => {\n const type = (\n await extractFromParentPackageJson(\n z.object({\n skuba: z.object({\n type: z.string(),\n }),\n }),\n )\n )?.skuba.type;\n\n if (!type) {\n log.warn(\n \"skuba type couldn't be found, please specify the type of project in the package.json, to ensure the correct migration is applied\",\n );\n return false;\n }\n if (type === 'package') {\n log.warn(\n 'skuba type package is not supported, packages should be updated manually to ensure major runtime deprecations are intended',\n );\n return false;\n }\n\n log.ok('skuba type supported, proceeding with migration');\n return true;\n};\n\nexport const isPatchableNodeVersion = async (\n targetNodeVersion: number,\n): Promise<boolean> => {\n const currentNodeVersion = await getParentFile('.nvmrc');\n\n const coercedTargetVersion = coerce(targetNodeVersion.toString())?.version;\n const coercedCurrentVersion = coerce(currentNodeVersion)?.version;\n\n const isNodeVersionValid =\n coercedTargetVersion &&\n coercedCurrentVersion &&\n lte(coercedCurrentVersion, coercedTargetVersion);\n\n if (!isNodeVersionValid) {\n log.warn(\n `Node version in .nvmrc is higher than the target version ${coercedTargetVersion}, please ensure the target version is greater than the current version ${coercedCurrentVersion}`,\n );\n return false;\n }\n\n log.ok('Valid node version found, proceeding with migration');\n return true;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmB;AACnB,sBAAe;AACf,oBAAuC;AACvC,iBAAoC;AAEpC,qBAAoB;AAEpB,MAAM,gBAAgB,OAAO,SAAiB;AAC5C,QAA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F;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,qBAAI,GAAG,iDAAiD;AACxD,SAAO;AACT;AAEO,MAAM,yBAAyB,OACpC,sBACqB;AACrB,QAAM,qBAAqB,MAAM,cAAc,QAAQ;AAEvD,QAAM,2BAAuB,sBAAO,kBAAkB,SAAS,CAAC,GAAG;AACnE,QAAM,4BAAwB,sBAAO,kBAAkB,GAAG;AAE1D,QAAM,qBACJ,wBACA,6BACA,mBAAI,uBAAuB,oBAAoB;AAEjD,MAAI,CAAC,oBAAoB;AACvB,uBAAI;AAAA,MACF,4DAA4D,oBAAoB,0EAA0E,qBAAqB;AAAA,IACjL;AACA,WAAO;AAAA,EACT;AAEA,qBAAI,GAAG,qDAAqD;AAC5D,SAAO;AACT;",
|
|
6
|
+
"names": ["findUp", "fs"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 getNodeTypesVersion_exports = {};
|
|
30
|
+
__export(getNodeTypesVersion_exports, {
|
|
31
|
+
getNodeTypesVersion: () => getNodeTypesVersion
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(getNodeTypesVersion_exports);
|
|
34
|
+
var import_npm_registry_fetch = __toESM(require("npm-registry-fetch"));
|
|
35
|
+
var import_semver = require("semver");
|
|
36
|
+
var import_zod = require("zod");
|
|
37
|
+
const NpmFetchResponse = import_zod.z.record(
|
|
38
|
+
import_zod.z.string(),
|
|
39
|
+
import_zod.z.object({
|
|
40
|
+
name: import_zod.z.string(),
|
|
41
|
+
version: import_zod.z.string(),
|
|
42
|
+
deprecated: import_zod.z.string().optional()
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
const getNodeTypesVersion = async (major, defaultVersion) => {
|
|
46
|
+
try {
|
|
47
|
+
const response = await import_npm_registry_fetch.default.json("@types/node", {
|
|
48
|
+
headers: {
|
|
49
|
+
Accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const parsedVersion = NpmFetchResponse.safeParse(response);
|
|
53
|
+
if (!parsedVersion.success) {
|
|
54
|
+
throw new Error("Failed to parse response");
|
|
55
|
+
}
|
|
56
|
+
const version = Object.values(parsedVersion.data).filter(
|
|
57
|
+
(v) => (0, import_semver.valid)(v.version) && (0, import_semver.satisfies)(v.version, `${major}.x.x`) && !v.deprecated
|
|
58
|
+
).reduce((a, b) => (0, import_semver.gt)(a.version, b.version) ? a : b).version;
|
|
59
|
+
return {
|
|
60
|
+
version
|
|
61
|
+
};
|
|
62
|
+
} catch {
|
|
63
|
+
return {
|
|
64
|
+
version: defaultVersion,
|
|
65
|
+
err: "Failed to fetch latest version, using fallback version"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
getNodeTypesVersion
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=getNodeTypesVersion.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/migrate/nodeVersion/getNodeTypesVersion.ts"],
|
|
4
|
+
"sourcesContent": ["import npmFetch from 'npm-registry-fetch';\nimport { gt, satisfies, valid } from 'semver';\nimport { z } from 'zod';\n\ntype VersionResult = {\n version: string;\n err?: string;\n};\n\nconst NpmFetchResponse = z.record(\n z.string(),\n z.object({\n name: z.string(),\n version: z.string(),\n deprecated: z.string().optional(),\n }),\n);\n\nexport const getNodeTypesVersion = async (\n major: number,\n defaultVersion: string,\n): Promise<VersionResult> => {\n try {\n const response = await npmFetch.json('@types/node', {\n headers: {\n Accept:\n 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*',\n },\n });\n\n const parsedVersion = NpmFetchResponse.safeParse(response);\n if (!parsedVersion.success) {\n throw new Error('Failed to parse response');\n }\n\n const version = Object.values(parsedVersion.data)\n .filter(\n (v) =>\n valid(v.version) &&\n satisfies(v.version, `${major}.x.x`) &&\n !v.deprecated,\n )\n .reduce((a, b) => (gt(a.version, b.version) ? a : b)).version;\n\n return {\n version,\n };\n } catch {\n return {\n version: defaultVersion,\n err: 'Failed to fetch latest version, using fallback version',\n };\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAqB;AACrB,oBAAqC;AACrC,iBAAkB;AAOlB,MAAM,mBAAmB,aAAE;AAAA,EACzB,aAAE,OAAO;AAAA,EACT,aAAE,OAAO;AAAA,IACP,MAAM,aAAE,OAAO;AAAA,IACf,SAAS,aAAE,OAAO;AAAA,IAClB,YAAY,aAAE,OAAO,EAAE,SAAS;AAAA,EAClC,CAAC;AACH;AAEO,MAAM,sBAAsB,OACjC,OACA,mBAC2B;AAC3B,MAAI;AACF,UAAM,WAAW,MAAM,0BAAAA,QAAS,KAAK,eAAe;AAAA,MAClD,SAAS;AAAA,QACP,QACE;AAAA,MACJ;AAAA,IACF,CAAC;AAED,UAAM,gBAAgB,iBAAiB,UAAU,QAAQ;AACzD,QAAI,CAAC,cAAc,SAAS;AAC1B,YAAM,IAAI,MAAM,0BAA0B;AAAA,IAC5C;AAEA,UAAM,UAAU,OAAO,OAAO,cAAc,IAAI,EAC7C;AAAA,MACC,CAAC,UACC,qBAAM,EAAE,OAAO,SACf,yBAAU,EAAE,SAAS,GAAG,KAAK,MAAM,KACnC,CAAC,EAAE;AAAA,IACP,EACC,OAAO,CAAC,GAAG,UAAO,kBAAG,EAAE,SAAS,EAAE,OAAO,IAAI,IAAI,CAAE,EAAE;AAExD,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,MACL,SAAS;AAAA,MACT,KAAK;AAAA,IACP;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["npmFetch"]
|
|
7
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare const nodeVersionMigration: ({ nodeVersion, ECMAScriptVersion, }: {
|
|
1
|
+
export declare const nodeVersionMigration: ({ nodeVersion, ECMAScriptVersion, defaultNodeTypesVersion, }: {
|
|
2
2
|
nodeVersion: number;
|
|
3
3
|
ECMAScriptVersion: string;
|
|
4
|
+
defaultNodeTypesVersion: string;
|
|
4
5
|
}, dir?: string) => Promise<void>;
|
|
@@ -36,100 +36,91 @@ var import_fast_glob = require("fast-glob");
|
|
|
36
36
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
37
|
var import_logging = require("../../../utils/logging");
|
|
38
38
|
var import_project = require("../../configure/analysis/project");
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
var import_checks = require("./checks");
|
|
40
|
+
var import_getNodeTypesVersion = require("./getNodeTypesVersion");
|
|
41
|
+
const subPatches = ({
|
|
42
|
+
nodeVersion,
|
|
43
|
+
nodeTypesVersion,
|
|
44
|
+
ECMAScriptVersion
|
|
45
|
+
}) => [
|
|
46
|
+
{ file: ".nvmrc", replace: `${nodeVersion}
|
|
47
|
+
` },
|
|
45
48
|
{
|
|
46
|
-
id: "Dockerfile-1",
|
|
47
49
|
files: "**/Dockerfile*",
|
|
48
|
-
|
|
49
|
-
replace:
|
|
50
|
+
regex: /^FROM(.*) (public.ecr.aws\/docker\/library\/)?node:([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?)(-[a-z0-9]+)?(@sha256:[a-f0-9]{64})?( .*)?$/gm,
|
|
51
|
+
replace: `FROM$1 $2node:${nodeVersion}$4$6`
|
|
50
52
|
},
|
|
51
53
|
{
|
|
52
|
-
id: "Dockerfile-2",
|
|
53
54
|
files: "**/Dockerfile*",
|
|
54
|
-
|
|
55
|
-
replace:
|
|
55
|
+
regex: /^FROM(.*) gcr.io\/distroless\/nodejs\d+-debian(\d+)(@sha256:[a-f0-9]{64})?(\.[^- \n]+)?(-[^ \n]+)?( .+|)$/gm,
|
|
56
|
+
replace: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$2$4$5$6`
|
|
56
57
|
},
|
|
57
58
|
{
|
|
58
|
-
id: "serverless",
|
|
59
59
|
files: "**/serverless*.y*ml",
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
regex: /nodejs\d+.x/gm,
|
|
61
|
+
tests: [import_checks.isPatchableServerlessVersion],
|
|
62
|
+
replace: `nodejs${nodeVersion}.x`
|
|
62
63
|
},
|
|
63
64
|
[
|
|
64
65
|
{
|
|
65
|
-
id: "cdk-1",
|
|
66
66
|
files: "**/infra/**/*.ts",
|
|
67
|
-
|
|
68
|
-
replace:
|
|
67
|
+
regex: /NODEJS_\d+_X/g,
|
|
68
|
+
replace: `NODEJS_${nodeVersion}_X`
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
id: "cdk-2",
|
|
72
71
|
files: "**/infra/**/*.ts",
|
|
73
|
-
|
|
74
|
-
replace:
|
|
72
|
+
regex: /(target:\s*'node)(\d+)(.+)$/gm,
|
|
73
|
+
replace: `$1${nodeVersion}$3`
|
|
75
74
|
}
|
|
76
75
|
],
|
|
77
76
|
{
|
|
78
|
-
id: "buildkite",
|
|
79
77
|
files: "**/.buildkite/*",
|
|
80
|
-
|
|
81
|
-
replace:
|
|
78
|
+
regex: /(image: )(public.ecr.aws\/docker\/library\/)?(node:)[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?$/gm,
|
|
79
|
+
replace: `$1$2$3${nodeVersion}$5`
|
|
82
80
|
},
|
|
83
81
|
{
|
|
84
|
-
id: "node-version",
|
|
85
82
|
files: ".node-version*",
|
|
86
|
-
|
|
87
|
-
replace:
|
|
83
|
+
regex: /(v)?\d+\.\d+\.\d+(.+)?/gm,
|
|
84
|
+
replace: `$1${nodeVersion}$2`
|
|
88
85
|
},
|
|
89
86
|
[
|
|
90
87
|
{
|
|
91
|
-
id: "package-json-1",
|
|
92
88
|
files: "**/package.json",
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
regex: /(\\?"@types\/node\\?": \\?")(\^)?[0-9.]+(\\?(",?)\\?n?)/gm,
|
|
90
|
+
tests: [import_checks.isPatchableServerlessVersion],
|
|
91
|
+
replace: `$1$2${nodeTypesVersion}$4`
|
|
95
92
|
},
|
|
96
93
|
{
|
|
97
|
-
id: "package-json-2",
|
|
98
94
|
files: "**/package.json",
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
regex: /(\\?"engines\\?":\s*{\\?n?[^}]*\\?"node\\?":\s*\\?">=)(\d+)\\?("[^}]*})(?![^}]*\\?"skuba\\?":\s*{\\?n?[^}]*\\?"type\\?":\s*\\?"package\\?")/gm,
|
|
96
|
+
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
97
|
+
replace: `$1${nodeVersion}$3`
|
|
101
98
|
}
|
|
102
99
|
],
|
|
103
100
|
[
|
|
104
101
|
{
|
|
105
|
-
id: "tsconfig-target",
|
|
106
102
|
files: "**/tsconfig*.json",
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
regex: /("target":\s*")(ES\d+)"/gim,
|
|
104
|
+
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
105
|
+
replace: `$1${ECMAScriptVersion}"`
|
|
109
106
|
},
|
|
110
107
|
{
|
|
111
|
-
id: "tsconfig-lib",
|
|
112
108
|
files: "**/tsconfig*.json",
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
regex: /("lib":\s*\[)([\S\s]*?)(ES\d+)([\S\s]*?)(\])/gim,
|
|
110
|
+
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
111
|
+
replace: `$1$2${ECMAScriptVersion}$4$5`
|
|
115
112
|
}
|
|
116
113
|
],
|
|
117
114
|
{
|
|
118
|
-
id: "docker-compose",
|
|
119
115
|
files: "**/docker-compose*.y*ml",
|
|
120
|
-
|
|
121
|
-
replace:
|
|
116
|
+
regex: /(image: )(public.ecr.aws\/docker\/library\/)?(node:)[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?$/gm,
|
|
117
|
+
replace: `$1$2$3${nodeVersion}$5`
|
|
122
118
|
}
|
|
123
119
|
];
|
|
124
|
-
const
|
|
125
|
-
const runSubPatch = async ({ nodeVersion, nodeTypesVersion, ECMAScriptVersion }, dir, patch) => {
|
|
120
|
+
const runSubPatch = async (dir, patch) => {
|
|
126
121
|
if (Array.isArray(patch)) {
|
|
127
122
|
for (const subPatch of patch) {
|
|
128
|
-
await runSubPatch(
|
|
129
|
-
{ nodeVersion, nodeTypesVersion, ECMAScriptVersion },
|
|
130
|
-
dir,
|
|
131
|
-
subPatch
|
|
132
|
-
);
|
|
123
|
+
await runSubPatch(dir, subPatch);
|
|
133
124
|
}
|
|
134
125
|
return;
|
|
135
126
|
}
|
|
@@ -144,56 +135,20 @@ const runSubPatch = async ({ nodeVersion, nodeTypesVersion, ECMAScriptVersion },
|
|
|
144
135
|
if (!contents) {
|
|
145
136
|
return;
|
|
146
137
|
}
|
|
147
|
-
if (patch.
|
|
138
|
+
if (patch.regex && !patch.regex.test(contents)) {
|
|
148
139
|
return;
|
|
149
140
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (!
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (patch.id === "package-json-1") {
|
|
157
|
-
if (!await (0, import_packageJsonChecks.validServerlessVersion)()) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
return await writePatchedContents({
|
|
161
|
-
path,
|
|
162
|
-
contents: unPinnedContents,
|
|
163
|
-
templated: patch.replace.replaceAll(
|
|
164
|
-
"<%- version %>",
|
|
165
|
-
nodeTypesVersion
|
|
166
|
-
),
|
|
167
|
-
test: patch.test
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (patch.id.includes("tsconfig")) {
|
|
171
|
-
if (!await (0, import_packageJsonChecks.validServerlessVersion)() || !await (0, import_packageJsonChecks.validSkubaType)()) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
return await writePatchedContents({
|
|
175
|
-
path,
|
|
176
|
-
contents: unPinnedContents,
|
|
177
|
-
templated: patch.replace.replaceAll(
|
|
178
|
-
"<%- version %>",
|
|
179
|
-
ECMAScriptVersion
|
|
180
|
-
),
|
|
181
|
-
test: patch.test
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if (patch.id === "package-json-2") {
|
|
185
|
-
if (!await (0, import_packageJsonChecks.validServerlessVersion)() || !await (0, import_packageJsonChecks.validSkubaType)()) {
|
|
141
|
+
if (patch.tests) {
|
|
142
|
+
const results = await Promise.all(patch.tests.map((test) => test()));
|
|
143
|
+
if (!results.every(Boolean)) {
|
|
186
144
|
return;
|
|
187
145
|
}
|
|
188
146
|
}
|
|
189
147
|
await writePatchedContents({
|
|
190
148
|
path,
|
|
191
|
-
contents
|
|
192
|
-
templated: patch.replace
|
|
193
|
-
|
|
194
|
-
nodeVersion.toString()
|
|
195
|
-
),
|
|
196
|
-
test: patch.test
|
|
149
|
+
contents,
|
|
150
|
+
templated: patch.replace,
|
|
151
|
+
regex: patch.regex
|
|
197
152
|
});
|
|
198
153
|
})
|
|
199
154
|
);
|
|
@@ -202,40 +157,38 @@ const writePatchedContents = async ({
|
|
|
202
157
|
path,
|
|
203
158
|
contents,
|
|
204
159
|
templated,
|
|
205
|
-
|
|
160
|
+
regex
|
|
206
161
|
}) => await import_fs_extra.default.promises.writeFile(
|
|
207
162
|
path,
|
|
208
|
-
|
|
163
|
+
regex ? contents.replaceAll(regex, templated) : templated
|
|
209
164
|
);
|
|
210
|
-
const upgrade = async (
|
|
165
|
+
const upgrade = async (versions, dir) => {
|
|
211
166
|
await Promise.all(
|
|
212
|
-
subPatches.map(
|
|
213
|
-
(subPatch) => runSubPatch(
|
|
214
|
-
{ nodeVersion, nodeTypesVersion, ECMAScriptVersion },
|
|
215
|
-
dir,
|
|
216
|
-
subPatch
|
|
217
|
-
)
|
|
218
|
-
)
|
|
167
|
+
subPatches(versions).map((subPatch) => runSubPatch(dir, subPatch))
|
|
219
168
|
);
|
|
220
169
|
};
|
|
221
170
|
const nodeVersionMigration = async ({
|
|
222
171
|
nodeVersion,
|
|
223
|
-
ECMAScriptVersion
|
|
172
|
+
ECMAScriptVersion,
|
|
173
|
+
defaultNodeTypesVersion
|
|
224
174
|
}, dir = process.cwd()) => {
|
|
225
175
|
import_logging.log.ok(`Upgrading to Node.js ${nodeVersion}`);
|
|
226
176
|
try {
|
|
227
|
-
|
|
177
|
+
if (!await (0, import_checks.isPatchableNodeVersion)(nodeVersion)) {
|
|
178
|
+
throw new Error("Node version is not patchable");
|
|
179
|
+
}
|
|
180
|
+
const { version: nodeTypesVersion, err } = await (0, import_getNodeTypesVersion.getNodeTypesVersion)(
|
|
228
181
|
nodeVersion,
|
|
229
|
-
|
|
182
|
+
defaultNodeTypesVersion
|
|
230
183
|
);
|
|
231
184
|
if (err) {
|
|
232
185
|
import_logging.log.warn(err);
|
|
233
186
|
}
|
|
234
187
|
await upgrade({ nodeVersion, nodeTypesVersion, ECMAScriptVersion }, dir);
|
|
235
188
|
import_logging.log.ok("Upgraded to Node.js", nodeVersion);
|
|
236
|
-
} catch (
|
|
189
|
+
} catch (error) {
|
|
237
190
|
import_logging.log.err("Failed to upgrade");
|
|
238
|
-
import_logging.log.subtle((0, import_util.inspect)(
|
|
191
|
+
import_logging.log.subtle((0, import_util.inspect)(error));
|
|
239
192
|
process.exitCode = 1;
|
|
240
193
|
}
|
|
241
194
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/migrate/nodeVersion/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../utils/logging';\nimport { createDestinationFileReader } from '../../configure/analysis/project';\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AACpB,qBAA4C;AAE5C,
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../utils/logging';\nimport { createDestinationFileReader } from '../../configure/analysis/project';\n\nimport {\n isPatchableNodeVersion,\n isPatchableServerlessVersion,\n isPatchableSkubaType,\n} from './checks';\nimport { getNodeTypesVersion } from './getNodeTypesVersion';\n\ntype FileSelector =\n | { files: string; file?: never }\n | { file: string; files?: never };\n\ntype SubPatch = FileSelector & {\n tests?: Array<() => Promise<boolean>>;\n regex?: RegExp;\n replace: string;\n};\n\ntype SubPatches = SubPatch | SubPatch[];\n\nconst subPatches = ({\n nodeVersion,\n nodeTypesVersion,\n ECMAScriptVersion,\n}: Versions): SubPatches[] => [\n { file: '.nvmrc', replace: `${nodeVersion}\\n` },\n {\n files: '**/Dockerfile*',\n\n regex:\n /^FROM(.*) (public.ecr.aws\\/docker\\/library\\/)?node:([0-9]+(?:\\.[0-9]+(?:\\.[0-9]+)?)?)(-[a-z0-9]+)?(@sha256:[a-f0-9]{64})?( .*)?$/gm,\n replace: `FROM$1 $2node:${nodeVersion}$4$6`,\n },\n {\n files: '**/Dockerfile*',\n regex:\n /^FROM(.*) gcr.io\\/distroless\\/nodejs\\d+-debian(\\d+)(@sha256:[a-f0-9]{64})?(\\.[^- \\n]+)?(-[^ \\n]+)?( .+|)$/gm,\n replace: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$2$4$5$6`,\n },\n {\n files: '**/serverless*.y*ml',\n regex: /nodejs\\d+.x/gm,\n tests: [isPatchableServerlessVersion],\n replace: `nodejs${nodeVersion}.x`,\n },\n [\n {\n files: '**/infra/**/*.ts',\n regex: /NODEJS_\\d+_X/g,\n replace: `NODEJS_${nodeVersion}_X`,\n },\n {\n files: '**/infra/**/*.ts',\n regex: /(target:\\s*'node)(\\d+)(.+)$/gm,\n replace: `$1${nodeVersion}$3`,\n },\n ],\n {\n files: '**/.buildkite/*',\n regex:\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)[0-9.]+(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n replace: `$1$2$3${nodeVersion}$5`,\n },\n {\n files: '.node-version*',\n regex: /(v)?\\d+\\.\\d+\\.\\d+(.+)?/gm,\n replace: `$1${nodeVersion}$2`,\n },\n [\n {\n files: '**/package.json',\n regex: /(\\\\?\"@types\\/node\\\\?\": \\\\?\")(\\^)?[0-9.]+(\\\\?(\",?)\\\\?n?)/gm,\n tests: [isPatchableServerlessVersion],\n replace: `$1$2${nodeTypesVersion}$4`,\n },\n {\n files: '**/package.json',\n regex:\n /(\\\\?\"engines\\\\?\":\\s*{\\\\?n?[^}]*\\\\?\"node\\\\?\":\\s*\\\\?\">=)(\\d+)\\\\?(\"[^}]*})(?![^}]*\\\\?\"skuba\\\\?\":\\s*{\\\\?n?[^}]*\\\\?\"type\\\\?\":\\s*\\\\?\"package\\\\?\")/gm,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1${nodeVersion}$3`,\n },\n ],\n [\n {\n files: '**/tsconfig*.json',\n regex: /(\"target\":\\s*\")(ES\\d+)\"/gim,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1${ECMAScriptVersion}\"`,\n },\n {\n files: '**/tsconfig*.json',\n regex: /(\"lib\":\\s*\\[)([\\S\\s]*?)(ES\\d+)([\\S\\s]*?)(\\])/gim,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1$2${ECMAScriptVersion}$4$5`,\n },\n ],\n {\n files: '**/docker-compose*.y*ml',\n regex:\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)[0-9.]+(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n\n replace: `$1$2$3${nodeVersion}$5`,\n },\n];\n\ntype Versions = {\n nodeVersion: number;\n nodeTypesVersion: string;\n ECMAScriptVersion: string;\n};\n\nconst runSubPatch = async (dir: string, patch: SubPatches) => {\n if (Array.isArray(patch)) {\n for (const subPatch of patch) {\n await runSubPatch(dir, subPatch);\n }\n return;\n }\n const readFile = createDestinationFileReader(dir);\n const paths = patch.file\n ? [patch.file]\n : await glob(patch.files ?? [], { cwd: dir });\n\n await Promise.all(\n paths.map(async (path) => {\n if (path.includes('node_modules')) {\n return;\n }\n const contents = await readFile(path);\n if (!contents) {\n return;\n }\n\n if (patch.regex && !patch.regex.test(contents)) {\n return;\n }\n\n if (patch.tests) {\n const results = await Promise.all(patch.tests.map((test) => test()));\n if (!results.every(Boolean)) {\n return;\n }\n }\n\n await writePatchedContents({\n path,\n contents,\n templated: patch.replace,\n regex: patch.regex,\n });\n }),\n );\n};\n\nconst writePatchedContents = async ({\n path,\n contents,\n templated,\n regex,\n}: {\n path: string;\n contents: string;\n templated: string;\n regex?: RegExp;\n}) =>\n await fs.promises.writeFile(\n path,\n regex ? contents.replaceAll(regex, templated) : templated,\n );\n\nconst upgrade = async (versions: Versions, dir: string) => {\n await Promise.all(\n subPatches(versions).map((subPatch) => runSubPatch(dir, subPatch)),\n );\n};\n\nexport const nodeVersionMigration = async (\n {\n nodeVersion,\n ECMAScriptVersion,\n defaultNodeTypesVersion,\n }: {\n nodeVersion: number;\n ECMAScriptVersion: string;\n defaultNodeTypesVersion: string;\n },\n dir = process.cwd(),\n) => {\n log.ok(`Upgrading to Node.js ${nodeVersion}`);\n try {\n if (!(await isPatchableNodeVersion(nodeVersion))) {\n throw new Error('Node version is not patchable');\n }\n\n const { version: nodeTypesVersion, err } = await getNodeTypesVersion(\n nodeVersion,\n defaultNodeTypesVersion,\n );\n if (err) {\n log.warn(err);\n }\n await upgrade({ nodeVersion, nodeTypesVersion, ECMAScriptVersion }, dir);\n log.ok('Upgraded to Node.js', nodeVersion);\n } catch (error) {\n log.err('Failed to upgrade');\n log.subtle(inspect(error));\n process.exitCode = 1;\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;A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AAM,gBAAAA,QAAG,SAAS;AAAA,EAChB;AAAA,EACA,QAAQ,SAAS,WAAW,OAAO,SAAS,IAAI;AAClD;AAEF,MAAM,UAAU,OAAO,UAAoB,QAAgB;AACzD,QAAM,QAAQ;AAAA,IACZ,WAAW,QAAQ,EAAE,IAAI,CAAC,aAAa,YAAY,KAAK,QAAQ,CAAC;AAAA,EACnE;AACF;AAEO,MAAM,uBAAuB,OAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF,GAKA,MAAM,QAAQ,IAAI,MACf;AACH,qBAAI,GAAG,wBAAwB,WAAW,EAAE;AAC5C,MAAI;AACF,QAAI,CAAE,UAAM,sCAAuB,WAAW,GAAI;AAChD,YAAM,IAAI,MAAM,+BAA+B;AAAA,IACjD;AAEA,UAAM,EAAE,SAAS,kBAAkB,IAAI,IAAI,UAAM;AAAA,MAC/C;AAAA,MACA;AAAA,IACF;AACA,QAAI,KAAK;AACP,yBAAI,KAAK,GAAG;AAAA,IACd;AACA,UAAM,QAAQ,EAAE,aAAa,kBAAkB,kBAAkB,GAAG,GAAG;AACvE,uBAAI,GAAG,uBAAuB,WAAW;AAAA,EAC3C,SAAS,OAAO;AACd,uBAAI,IAAI,mBAAmB;AAC3B,uBAAI,WAAO,qBAAQ,KAAK,CAAC;AACzB,YAAQ,WAAW;AAAA,EACrB;AACF;",
|
|
6
6
|
"names": ["fs"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skuba",
|
|
3
|
-
"version": "10.0.0-node-22-
|
|
3
|
+
"version": "10.0.0-node-22-20250218232801",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "SEEK development toolkit for backend applications and packages",
|
|
6
6
|
"homepage": "https://github.com/seek-oss/skuba#readme",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"lodash.mergewith": "^4.6.2",
|
|
83
83
|
"minimist": "^1.2.6",
|
|
84
84
|
"normalize-package-data": "^7.0.0",
|
|
85
|
+
"npm-registry-fetch": "^18.0.2",
|
|
85
86
|
"npm-run-path": "^4.0.1",
|
|
86
87
|
"npm-which": "^3.0.1",
|
|
87
88
|
"picomatch": "^4.0.0",
|
|
@@ -99,7 +100,7 @@
|
|
|
99
100
|
"typescript": "~5.7.0",
|
|
100
101
|
"validate-npm-package-name": "^6.0.0",
|
|
101
102
|
"zod": "^3.22.4",
|
|
102
|
-
"eslint-config-skuba": "5.1.0-node-22-
|
|
103
|
+
"eslint-config-skuba": "5.1.0-node-22-20250218232801"
|
|
103
104
|
},
|
|
104
105
|
"devDependencies": {
|
|
105
106
|
"@changesets/cli": "2.27.12",
|
|
@@ -114,6 +115,7 @@
|
|
|
114
115
|
"@types/lodash.mergewith": "4.6.9",
|
|
115
116
|
"@types/minimist": "1.2.5",
|
|
116
117
|
"@types/module-alias": "2.0.4",
|
|
118
|
+
"@types/npm-registry-fetch": "8.0.7",
|
|
117
119
|
"@types/npm-which": "3.0.3",
|
|
118
120
|
"@types/picomatch": "3.0.2",
|
|
119
121
|
"@types/semver": "7.5.8",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# syntax=docker/dockerfile:1.13
|
|
2
2
|
|
|
3
|
-
FROM public.ecr.aws/docker/library/node:
|
|
3
|
+
FROM public.ecr.aws/docker/library/node:22-alpine AS dev-deps
|
|
4
4
|
|
|
5
5
|
RUN --mount=type=bind,source=package.json,target=package.json \
|
|
6
6
|
corepack enable pnpm && corepack install
|
|
@@ -1,50 +0,0 @@
|
|
|
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 getNode22TypesVersion_exports = {};
|
|
20
|
-
__export(getNode22TypesVersion_exports, {
|
|
21
|
-
getNode22TypesVersion: () => getNode22TypesVersion
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(getNode22TypesVersion_exports);
|
|
24
|
-
const getNode22TypesVersion = async (major, defaultVersion) => {
|
|
25
|
-
try {
|
|
26
|
-
const response = await fetch("https://registry.npmjs.org/@types/node");
|
|
27
|
-
if (!response.ok)
|
|
28
|
-
throw new Error(`Failed to fetch: ${response.statusText}`);
|
|
29
|
-
const json = await response.json();
|
|
30
|
-
const versions = Object.keys(json.versions).filter((v) => v.startsWith(`${major}.`)).sort((a, b) => b.localeCompare(a, void 0, { numeric: true }));
|
|
31
|
-
const latestVersion = versions[0];
|
|
32
|
-
const versionRegex = /(22\.\d+\.\d+)/;
|
|
33
|
-
if (!latestVersion || !versionRegex.test(latestVersion)) {
|
|
34
|
-
throw new Error("No version found");
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
version: versionRegex.exec(latestVersion)?.[0] ?? defaultVersion
|
|
38
|
-
};
|
|
39
|
-
} catch {
|
|
40
|
-
return {
|
|
41
|
-
version: defaultVersion,
|
|
42
|
-
err: "Failed to fetch latest version, using fallback version"
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
getNode22TypesVersion
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=getNode22TypesVersion.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/cli/migrate/nodeVersion/getNode22TypesVersion.ts"],
|
|
4
|
-
"sourcesContent": ["type VersionResult = {\n version: string;\n err?: string;\n};\n\nexport const getNode22TypesVersion = async (\n major: number,\n defaultVersion: string,\n): Promise<VersionResult> => {\n try {\n const response = await fetch('https://registry.npmjs.org/@types/node');\n if (!response.ok)\n throw new Error(`Failed to fetch: ${response.statusText}`);\n\n const json = (await response.json()) as {\n versions: Record<string, unknown>;\n };\n const versions = Object.keys(json.versions)\n .filter((v) => v.startsWith(`${major}.`))\n .sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));\n\n const latestVersion = versions[0];\n const versionRegex = /(22\\.\\d+\\.\\d+)/;\n\n if (!latestVersion || !versionRegex.test(latestVersion)) {\n throw new Error('No version found');\n }\n\n return {\n version: versionRegex.exec(latestVersion)?.[0] ?? defaultVersion,\n };\n } catch {\n return {\n version: defaultVersion,\n err: 'Failed to fetch latest version, using fallback version',\n };\n }\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,wBAAwB,OACnC,OACA,mBAC2B;AAC3B,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,wCAAwC;AACrE,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,oBAAoB,SAAS,UAAU,EAAE;AAE3D,UAAM,OAAQ,MAAM,SAAS,KAAK;AAGlC,UAAM,WAAW,OAAO,KAAK,KAAK,QAAQ,EACvC,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,GAAG,CAAC,EACvC,KAAK,CAAC,GAAG,MAAM,EAAE,cAAc,GAAG,QAAW,EAAE,SAAS,KAAK,CAAC,CAAC;AAElE,UAAM,gBAAgB,SAAS,CAAC;AAChC,UAAM,eAAe;AAErB,QAAI,CAAC,iBAAiB,CAAC,aAAa,KAAK,aAAa,GAAG;AACvD,YAAM,IAAI,MAAM,kBAAkB;AAAA,IACpC;AAEA,WAAO;AAAA,MACL,SAAS,aAAa,KAAK,aAAa,IAAI,CAAC,KAAK;AAAA,IACpD;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,MACL,SAAS;AAAA,MACT,KAAK;AAAA,IACP;AAAA,EACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
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 packageJsonChecks_exports = {};
|
|
30
|
-
__export(packageJsonChecks_exports, {
|
|
31
|
-
validServerlessVersion: () => validServerlessVersion,
|
|
32
|
-
validSkubaType: () => validSkubaType
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(packageJsonChecks_exports);
|
|
35
|
-
var import_find_up = __toESM(require("find-up"));
|
|
36
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
-
var import_logging = require("../../../utils/logging");
|
|
38
|
-
const getParentPackageJson = async () => {
|
|
39
|
-
const packageJsonPath = await (0, import_find_up.default)("package.json", { cwd: process.cwd() });
|
|
40
|
-
if (!packageJsonPath) {
|
|
41
|
-
throw new Error("package.json not found");
|
|
42
|
-
}
|
|
43
|
-
return import_fs_extra.default.readFile(packageJsonPath);
|
|
44
|
-
};
|
|
45
|
-
const isTypeError = (error) => error instanceof TypeError && error.message.includes("Cannot read properties of undefined");
|
|
46
|
-
const isSyntaxError = (error) => error instanceof SyntaxError && error.message.includes("Unexpected token");
|
|
47
|
-
const validServerlessVersion = async () => {
|
|
48
|
-
const packageJson = await getParentPackageJson();
|
|
49
|
-
try {
|
|
50
|
-
const serverlessVersion = JSON.parse(packageJson.toString()).devDependencies.serverless;
|
|
51
|
-
if (!serverlessVersion) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
if (!serverlessVersion.startsWith("4")) {
|
|
55
|
-
import_logging.log.warn(
|
|
56
|
-
"Serverless version not supported, please upgrade to 4.x to automatically update serverless files"
|
|
57
|
-
);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
} catch (error) {
|
|
61
|
-
if (isTypeError(error) || isSyntaxError(error)) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
};
|
|
68
|
-
const validSkubaType = async () => {
|
|
69
|
-
const packageJson = await getParentPackageJson();
|
|
70
|
-
try {
|
|
71
|
-
const type = JSON.parse(packageJson.toString()).skuba.type;
|
|
72
|
-
if (!type) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
if (type === "package") {
|
|
76
|
-
import_logging.log.warn(
|
|
77
|
-
"skuba type package is not supported, packages should be updated manually to ensure major runtime deprecations are intended"
|
|
78
|
-
);
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if (isTypeError(error) || isSyntaxError(error)) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
-
0 && (module.exports = {
|
|
91
|
-
validServerlessVersion,
|
|
92
|
-
validSkubaType
|
|
93
|
-
});
|
|
94
|
-
//# sourceMappingURL=packageJsonChecks.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/cli/migrate/nodeVersion/packageJsonChecks.ts"],
|
|
4
|
-
"sourcesContent": ["import findUp from 'find-up';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../utils/logging';\n\nconst getParentPackageJson = async () => {\n const packageJsonPath = await findUp('package.json', { cwd: process.cwd() });\n if (!packageJsonPath) {\n throw new Error('package.json not found');\n }\n return fs.readFile(packageJsonPath);\n};\n\nconst isTypeError = (error: unknown): error is TypeError =>\n error instanceof TypeError &&\n error.message.includes('Cannot read properties of undefined');\n\nconst isSyntaxError = (error: unknown): error is SyntaxError =>\n error instanceof SyntaxError && error.message.includes('Unexpected token');\n\nexport const validServerlessVersion = async (): Promise<boolean> => {\n const packageJson = await getParentPackageJson();\n\n try {\n const serverlessVersion = (\n JSON.parse(packageJson.toString()) as {\n devDependencies: Record<string, string>;\n }\n ).devDependencies.serverless;\n if (!serverlessVersion) {\n return true;\n }\n\n if (!serverlessVersion.startsWith('4')) {\n log.warn(\n 'Serverless version not supported, please upgrade to 4.x to automatically update serverless files',\n );\n return false;\n }\n } catch (error) {\n if (isTypeError(error) || isSyntaxError(error)) {\n return true;\n }\n throw error;\n }\n return true;\n};\n\nexport const validSkubaType = async () => {\n const packageJson = await getParentPackageJson();\n\n try {\n const type = (\n JSON.parse(packageJson.toString()) as {\n skuba: Record<string, string>;\n }\n ).skuba.type;\n if (!type) {\n return true;\n }\n\n if (type === 'package') {\n log.warn(\n 'skuba type package is not supported, packages should be updated manually to ensure major runtime deprecations are intended',\n );\n return false;\n }\n } catch (error) {\n if (isTypeError(error) || isSyntaxError(error)) {\n return true;\n }\n throw error;\n }\n return true;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmB;AACnB,sBAAe;AAEf,qBAAoB;AAEpB,MAAM,uBAAuB,YAAY;AACvC,QAAM,kBAAkB,UAAM,eAAAA,SAAO,gBAAgB,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AAC3E,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAAI,MAAM,wBAAwB;AAAA,EAC1C;AACA,SAAO,gBAAAC,QAAG,SAAS,eAAe;AACpC;AAEA,MAAM,cAAc,CAAC,UACnB,iBAAiB,aACjB,MAAM,QAAQ,SAAS,qCAAqC;AAE9D,MAAM,gBAAgB,CAAC,UACrB,iBAAiB,eAAe,MAAM,QAAQ,SAAS,kBAAkB;AAEpE,MAAM,yBAAyB,YAA8B;AAClE,QAAM,cAAc,MAAM,qBAAqB;AAE/C,MAAI;AACF,UAAM,oBACJ,KAAK,MAAM,YAAY,SAAS,CAAC,EAGjC,gBAA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