skuba 10.0.0-node-22-20250213082332 → 10.0.0-node-22-20250218222641
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/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/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 +54 -104
- package/lib/cli/migrate/nodeVersion/index.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/packageJsonChecks.d.ts +4 -2
- package/lib/cli/migrate/nodeVersion/packageJsonChecks.js +59 -41
- package/lib/cli/migrate/nodeVersion/packageJsonChecks.js.map +2 -2
- package/package.json +4 -2
- package/template/greeter/package.json +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/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
|
@@ -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,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
|
|
39
|
+
var import_getNodeTypesVersion = require("./getNodeTypesVersion");
|
|
40
40
|
var import_packageJsonChecks = require("./packageJsonChecks");
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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_packageJsonChecks.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_packageJsonChecks.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_packageJsonChecks.isPatchableServerlessVersion, import_packageJsonChecks.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_packageJsonChecks.isPatchableServerlessVersion, import_packageJsonChecks.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_packageJsonChecks.isPatchableServerlessVersion, import_packageJsonChecks.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,31 +157,26 @@ 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
|
-
const { version: nodeTypesVersion, err } = await (0,
|
|
177
|
+
const { version: nodeTypesVersion, err } = await (0, import_getNodeTypesVersion.getNodeTypesVersion)(
|
|
228
178
|
nodeVersion,
|
|
229
|
-
|
|
179
|
+
defaultNodeTypesVersion
|
|
230
180
|
);
|
|
231
181
|
if (err) {
|
|
232
182
|
import_logging.log.warn(err);
|
|
@@ -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 { getNodeTypesVersion } from './getNodeTypesVersion';\nimport {\n isPatchableServerlessVersion,\n isPatchableSkubaType,\n} from './packageJsonChecks';\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 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 (err) {\n log.err('Failed to upgrade');\n log.subtle(inspect(err));\n process.exitCode = 1;\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AACpB,qBAA4C;AAE5C,iCAAoC;AACpC,+BAGO;AAcP,MAAM,aAAa,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF,M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B,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,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,KAAK;AACZ,uBAAI,IAAI,mBAAmB;AAC3B,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,YAAQ,WAAW;AAAA,EACrB;AACF;",
|
|
6
6
|
"names": ["fs"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
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>;
|
|
@@ -28,67 +28,85 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var packageJsonChecks_exports = {};
|
|
30
30
|
__export(packageJsonChecks_exports, {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
extractFromParentPackageJson: () => extractFromParentPackageJson,
|
|
32
|
+
isPatchableServerlessVersion: () => isPatchableServerlessVersion,
|
|
33
|
+
isPatchableSkubaType: () => isPatchableSkubaType
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(packageJsonChecks_exports);
|
|
35
36
|
var import_find_up = __toESM(require("find-up"));
|
|
36
37
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
|
+
var import_semver = require("semver");
|
|
39
|
+
var import_zod = require("zod");
|
|
37
40
|
var import_logging = require("../../../utils/logging");
|
|
38
41
|
const getParentPackageJson = async () => {
|
|
39
42
|
const packageJsonPath = await (0, import_find_up.default)("package.json", { cwd: process.cwd() });
|
|
40
43
|
if (!packageJsonPath) {
|
|
41
44
|
throw new Error("package.json not found");
|
|
42
45
|
}
|
|
43
|
-
return import_fs_extra.default.readFile(packageJsonPath);
|
|
46
|
+
return import_fs_extra.default.readFile(packageJsonPath, "utf-8");
|
|
44
47
|
};
|
|
45
|
-
const
|
|
46
|
-
const isSyntaxError = (error) => error instanceof SyntaxError && error.message.includes("Unexpected token");
|
|
47
|
-
const validServerlessVersion = async () => {
|
|
48
|
+
const extractFromParentPackageJson = async (schema) => {
|
|
48
49
|
const packageJson = await getParentPackageJson();
|
|
50
|
+
let rawJSON;
|
|
49
51
|
try {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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;
|
|
52
|
+
rawJSON = JSON.parse(packageJson);
|
|
53
|
+
} catch {
|
|
54
|
+
throw new Error("package.json is not valid JSON");
|
|
65
55
|
}
|
|
56
|
+
const result = schema.safeParse(rawJSON);
|
|
57
|
+
if (!result.success) {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
return result.data;
|
|
61
|
+
};
|
|
62
|
+
const isPatchableServerlessVersion = async () => {
|
|
63
|
+
const serverlessVersion = (await extractFromParentPackageJson(
|
|
64
|
+
import_zod.z.object({
|
|
65
|
+
devDependencies: import_zod.z.object({
|
|
66
|
+
serverless: import_zod.z.string()
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
))?.devDependencies.serverless;
|
|
70
|
+
if (!serverlessVersion) {
|
|
71
|
+
import_logging.log.subtle("Serverless version not found, assuming it is not a dependency");
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (!(0, import_semver.satisfies)(serverlessVersion, "4.x.x")) {
|
|
75
|
+
import_logging.log.warn(
|
|
76
|
+
"Serverless version not supported, please upgrade to 4.x to automatically update serverless files"
|
|
77
|
+
);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
import_logging.log.ok("Serverless version is supported, proceeding with migration");
|
|
66
81
|
return true;
|
|
67
82
|
};
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const isPatchableSkubaType = async () => {
|
|
84
|
+
const type = (await extractFromParentPackageJson(
|
|
85
|
+
import_zod.z.object({
|
|
86
|
+
skuba: import_zod.z.object({
|
|
87
|
+
type: import_zod.z.string()
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
))?.skuba.type;
|
|
91
|
+
if (!type) {
|
|
92
|
+
import_logging.log.warn(
|
|
93
|
+
"skuba type couldn't be found, please specify the type of project in the package.json, to ensure the correct migration is applied"
|
|
94
|
+
);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (type === "package") {
|
|
98
|
+
import_logging.log.warn(
|
|
99
|
+
"skuba type package is not supported, packages should be updated manually to ensure major runtime deprecations are intended"
|
|
100
|
+
);
|
|
101
|
+
return false;
|
|
86
102
|
}
|
|
103
|
+
import_logging.log.ok("skuba type supported, proceeding with migration");
|
|
87
104
|
return true;
|
|
88
105
|
};
|
|
89
106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
90
107
|
0 && (module.exports = {
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
extractFromParentPackageJson,
|
|
109
|
+
isPatchableServerlessVersion,
|
|
110
|
+
isPatchableSkubaType
|
|
93
111
|
});
|
|
94
112
|
//# sourceMappingURL=packageJsonChecks.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmB;AACnB,sBAAe;
|
|
4
|
+
"sourcesContent": ["import findUp from 'find-up';\nimport fs from 'fs-extra';\nimport { satisfies } from 'semver';\nimport { type ZodRawShape, z } from 'zod';\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, '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 getParentPackageJson();\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 () => {\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmB;AACnB,sBAAe;AACf,oBAA0B;AAC1B,iBAAoC;AAEpC,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,iBAAiB,OAAO;AAC7C;AAEO,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
|
3
|
-
"version": "10.0.0-node-22-
|
|
3
|
+
"version": "10.0.0-node-22-20250218222641",
|
|
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-20250218222641"
|
|
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,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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|