Skip to content

Commit 9cd7022

Browse files
authored
feat!: Update node to 22 (#14079)
* feat!: Update node to 22 * use fork again * try this instead * bump sizes, sorry... * try this * try this * fix that * fix that * fix that * fix that * move lambdas to node 22 * readme * try this * Update local_publish_helpers_codebuild.sh
1 parent 60fbda2 commit 9cd7022

File tree

40 files changed

+216
-180
lines changed

40 files changed

+216
-180
lines changed

.circleci/local_publish_helpers_codebuild.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,22 @@ function generatePkgCli {
8686
cp package.json ../build/node_modules/package.json
8787

8888
if [[ "$@" =~ 'arm' ]]; then
89-
npx pkg --no-bytecode --public-packages "*" --public -t node18-linux-arm64 ../build/node_modules -o ../out/amplify-pkg-linux-arm64
89+
npx pkg --no-bytecode --public-packages "*" --public -t node22-linux-arm64 ../build/node_modules -o ../out/amplify-pkg-linux-arm64
9090
tar -czvf ../out/amplify-pkg-linux-arm64.tgz ../out/amplify-pkg-linux-arm64
9191
fi
9292

9393
if [[ "$@" =~ 'linux' ]]; then
94-
npx pkg -t node18-linux-x64 ../build/node_modules -o ../out/amplify-pkg-linux-x64
94+
npx pkg -t node22-linux-x64 ../build/node_modules -o ../out/amplify-pkg-linux-x64
9595
tar -czvf ../out/amplify-pkg-linux-x64.tgz ../out/amplify-pkg-linux-x64
9696
fi
9797

9898
if [[ "$@" =~ 'macos' ]]; then
99-
npx pkg -t node18-macos-x64 ../build/node_modules -o ../out/amplify-pkg-macos-x64
99+
npx pkg -t node22-macos-x64 ../build/node_modules -o ../out/amplify-pkg-macos-x64
100100
tar -czvf ../out/amplify-pkg-macos-x64.tgz ../out/amplify-pkg-macos-x64
101101
fi
102102

103103
if [[ "$@" =~ 'win' ]]; then
104-
npx pkg -t node18-win-x64 ../build/node_modules -o ../out/amplify-pkg-win-x64.exe
104+
npx pkg -t node22-win-x64 ../build/node_modules -o ../out/amplify-pkg-win-x64.exe
105105
tar -czvf ../out/amplify-pkg-win-x64.tgz ../out/amplify-pkg-win-x64.exe
106106
fi
107107

@@ -139,9 +139,9 @@ function verifyPkgCli {
139139
fi
140140
}
141141

142-
verifySinglePkg "amplify-pkg-linux-x64" "amplify-pkg-linux-x64.tgz" $((900 * 1024 * 1024))
143-
verifySinglePkg "amplify-pkg-macos-x64" "amplify-pkg-macos-x64.tgz" $((900 * 1024 * 1024))
144-
verifySinglePkg "amplify-pkg-win-x64.exe" "amplify-pkg-win-x64.tgz" $((890 * 1024 * 1024))
142+
verifySinglePkg "amplify-pkg-linux-x64" "amplify-pkg-linux-x64.tgz" $((930 * 1024 * 1024))
143+
verifySinglePkg "amplify-pkg-macos-x64" "amplify-pkg-macos-x64.tgz" $((930 * 1024 * 1024))
144+
verifySinglePkg "amplify-pkg-win-x64.exe" "amplify-pkg-win-x64.tgz" $((930 * 1024 * 1024))
145145
verifySinglePkg "amplify-pkg-linux-arm64" "amplify-pkg-linux-arm64.tgz" $((750 * 1024 * 1024))
146146
}
147147

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The AWS Amplify CLI is a toolchain which includes a robust feature set for simpl
4040

4141
## Install the CLI
4242

43-
- Requires Node.js® version 18 or later
43+
- Requires Node.js® version 22 or later
4444

4545
Install and configure the Amplify CLI as follows:
4646

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
"@types/yargs": "^17",
118118
"@typescript-eslint/eslint-plugin": "^5.34.0",
119119
"@typescript-eslint/parser": "^5.34.0",
120+
"@yao-pkg/pkg": "^6.2.0",
120121
"@zkochan/cmd-shim": "^5.1.0",
121122
"babel-eslint": "^10.1.0",
122123
"babel-loader": "^8.3.0",
@@ -147,7 +148,6 @@
147148
"lnk": "1.1.0",
148149
"lodash": "^4.17.21",
149150
"npm-check-updates": "^16.1.0",
150-
"pkg": "^5.8.1",
151151
"prettier": "^2.8.4",
152152
"rimraf": "^3.0.0",
153153
"ts-jest": "^29.0.0",
@@ -171,7 +171,6 @@
171171
"json5": "^2.2.3",
172172
"mysql2": "^3.9.8",
173173
"nth-check": "^2.0.1",
174-
"pkg-fetch": "^3.5.2",
175174
"undici": "^5.28.3",
176175
"tough-cookie": "^4.1.3",
177176
"semver": "^7.5.4",

packages/amplify-app/src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ async function installAmplifyCLI() {
9090
cwd: process.cwd(),
9191
env: process.env,
9292
stdio: 'inherit',
93+
shell: isWin ? true : undefined,
9394
});
9495

9596
amplifyCLIInstall.on('exit', (code) => {
@@ -352,7 +353,12 @@ async function createJSHelperFiles() {
352353
console.log(`${emoji.get('white_check_mark')} Successfully added helper npm run scripts to your package.json.`);
353354

354355
return new Promise((resolve, reject) => {
355-
const npmInstall = spawn(npm, ['install', '--only=dev'], { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
356+
const npmInstall = spawn(npm, ['install', '--only=dev'], {
357+
cwd: process.cwd(),
358+
env: process.env,
359+
stdio: 'inherit',
360+
shell: isWin ? true : undefined,
361+
});
356362

357363
npmInstall.on('exit', (code) => {
358364
if (code === 0) {

packages/amplify-app/src/scripts/amplify-modelgen.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ console.log('Running codegen...');
77
run();
88

99
async function run() {
10-
const amplify = process.env.AMPLIFY_PATH ? process.env.AMPLIFY_PATH : /^win/.test(process.platform) ? 'amplify.cmd' : 'amplify';
11-
const modelGen = spawn(amplify, ['codegen', 'model'], { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
10+
const isWindows = /^win/.test(process.platform);
11+
const amplify = process.env.AMPLIFY_PATH ? process.env.AMPLIFY_PATH : isWindows ? 'amplify.cmd' : 'amplify';
12+
const modelGen = spawn(amplify, ['codegen', 'model'], {
13+
cwd: process.cwd(),
14+
env: process.env,
15+
stdio: 'inherit',
16+
shell: isWindows ? true : undefined,
17+
});
1218

1319
modelGen.on('exit', (code) => {
1420
if (code === 0) {

packages/amplify-app/src/scripts/amplify-push.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const ini = require('ini');
55
const { spawn } = require('child_process');
66
const inquirer = require('inquirer');
77

8-
const amplify = process.env.AMPLIFY_PATH ? process.env.AMPLIFY_PATH : /^win/.test(process.platform) ? 'amplify.cmd' : 'amplify';
8+
const isWindows = /^win/.test(process.platform);
9+
const amplify = process.env.AMPLIFY_PATH ? process.env.AMPLIFY_PATH : isWindows ? 'amplify.cmd' : 'amplify';
910
const dotAWSDirPath = path.normalize(path.join(os.homedir(), '.aws'));
1011
const configFilePath = path.join(dotAWSDirPath, 'config');
1112
run();
@@ -50,7 +51,12 @@ async function getValidProfile(profileToUse) {
5051
}
5152

5253
async function configureProfile() {
53-
const amplifyConfigure = spawn(amplify, ['configure'], { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
54+
const amplifyConfigure = spawn(amplify, ['configure'], {
55+
cwd: process.cwd(),
56+
env: process.env,
57+
stdio: 'inherit',
58+
shell: isWindows ? true : undefined,
59+
});
5460

5561
return new Promise((resolve, reject) => {
5662
amplifyConfigure.on('exit', (code) => {
@@ -124,11 +130,17 @@ async function run() {
124130
cwd: process.cwd(),
125131
env: process.env,
126132
stdio: 'inherit',
133+
shell: isWindows ? true : undefined,
127134
});
128135
} else {
129136
// just push
130137

131-
cloudPush = spawn(amplify, ['push', '--yes'], { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
138+
cloudPush = spawn(amplify, ['push', '--yes'], {
139+
cwd: process.cwd(),
140+
env: process.env,
141+
stdio: 'inherit',
142+
shell: isWindows ? true : undefined,
143+
});
132144
}
133145

134146
cloudPush.on('exit', (code) => {

packages/amplify-category-analytics/src/provider-utils/awscloudformation/cloudformation-templates/pinpoint-cloudformation-template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
}
261261
},
262262
"Handler": "index.handler",
263-
"Runtime": "nodejs18.x",
263+
"Runtime": "nodejs22.x",
264264
"Timeout": 300,
265265
"Role": {
266266
"Fn::GetAtt": ["LambdaExecutionRole", "Arn"]

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/cloudformation-templates/CreateAuthChallenge.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
}
105105
},
106106
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
107-
"Runtime": "nodejs18.x",
107+
"Runtime": "nodejs22.x",
108108
"Timeout": 25
109109
}
110110
},

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/cloudformation-templates/CustomMessage.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
}
122122
},
123123
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
124-
"Runtime": "nodejs18.x",
124+
"Runtime": "nodejs22.x",
125125
"Timeout": 25
126126
}
127127
},

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/cloudformation-templates/DefineAuthChallenge.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898
},
9999
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
100-
"Runtime": "nodejs18.x",
100+
"Runtime": "nodejs22.x",
101101
"Timeout": 25
102102
}
103103
},

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/cloudformation-templates/PostAuthentication.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898
},
9999
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
100-
"Runtime": "nodejs18.x",
100+
"Runtime": "nodejs22.x",
101101
"Timeout": 25
102102
}
103103
},

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/cloudformation-templates/PostConfirmation.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
}
105105
},
106106
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
107-
"Runtime": "nodejs18.x",
107+
"Runtime": "nodejs22.x",
108108
"Timeout": 25
109109
}
110110
},

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/cloudformation-templates/PreAuthentication.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898
},
9999
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
100-
"Runtime": "nodejs18.x",
100+
"Runtime": "nodejs22.x",
101101
"Timeout": 25
102102
}
103103
},

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/cloudformation-templates/PreSignup.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
}
112112
},
113113
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
114-
"Runtime": "nodejs18.x",
114+
"Runtime": "nodejs22.x",
115115
"Timeout": 25
116116
}
117117
},

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/cloudformation-templates/PreTokenGeneration.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898
},
9999
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
100-
"Runtime": "nodejs18.x",
100+
"Runtime": "nodejs22.x",
101101
"Timeout": 25
102102
}
103103
},

packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/cloudformation-templates/VerifyAuthChallengeResponse.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
}
106106
},
107107
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
108-
"Runtime": "nodejs18.x",
108+
"Runtime": "nodejs22.x",
109109
"Timeout": 25
110110
}
111111
},

packages/amplify-category-auth/resources/adminAuth/admin-queries-function-template.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
}
6666
},
6767
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
68-
"Runtime": "nodejs18.x",
68+
"Runtime": "nodejs22.x",
6969
"Timeout": 25
7070
}
7171
},

packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/auth-stack-builder/__snapshots__/auth-stack-transform.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ async function createOrUpdateDomain(inputDomainName, userPoolId) {
872872
"Arn",
873873
],
874874
},
875-
"Runtime": "nodejs18.x",
875+
"Runtime": "nodejs22.x",
876876
"Timeout": 300,
877877
},
878878
"Type": "AWS::Lambda::Function",
@@ -1147,7 +1147,7 @@ async function deleteIdentityProvider(providerName, userPoolId) {
11471147
"Arn",
11481148
],
11491149
},
1150-
"Runtime": "nodejs18.x",
1150+
"Runtime": "nodejs22.x",
11511151
"Timeout": 300,
11521152
},
11531153
"Type": "AWS::Lambda::Function",

packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/__snapshots__/generate-auth-trigger-template.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ async function handleEvent(event) {
196196
"Arn",
197197
],
198198
},
199-
"Runtime": "nodejs18.x",
199+
"Runtime": "nodejs22.x",
200200
},
201201
"Type": "AWS::Lambda::Function",
202202
},

packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-stack-builder/auth-cognito-stack-builder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
676676
},
677677
handler: 'index.handler',
678678
role: cdk.Fn.getAtt('UserPoolClientRole', 'Arn').toString(),
679-
runtime: 'nodejs18.x',
679+
runtime: 'nodejs22.x',
680680
timeout: 300,
681681
});
682682

@@ -760,7 +760,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
760760
},
761761
handler: 'index.handler',
762762
role: cdk.Fn.getAtt('UserPoolClientRole', 'Arn').toString(),
763-
runtime: 'nodejs18.x',
763+
runtime: 'nodejs22.x',
764764
timeout: 300,
765765
});
766766

@@ -906,7 +906,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
906906
},
907907
handler: 'index.handler',
908908
role: cdk.Fn.getAtt('MFALambdaRole', 'Arn').toString(),
909-
runtime: 'nodejs18.x',
909+
runtime: 'nodejs22.x',
910910
timeout: 300,
911911
});
912912
this.mfaLambda.addDependency(this.mfaLambdaRole);
@@ -1047,7 +1047,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
10471047
},
10481048
handler: 'index.handler',
10491049
role: cdk.Fn.getAtt('OpenIdLambdaRole', 'Arn').toString(),
1050-
runtime: 'nodejs18.x',
1050+
runtime: 'nodejs22.x',
10511051
timeout: 300,
10521052
});
10531053
this.openIdLambda.addDependency(this.openIdLambdaRole);

packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as path from 'path';
22
import * as fs from 'fs-extra';
3-
import { $TSAny, AmplifyFault, JSONUtilities, pathManager, getPermissionsBoundaryArn } from '@aws-amplify/amplify-cli-core';
3+
import { $TSAny, AmplifyFault, getPermissionsBoundaryArn, JSONUtilities, pathManager } from '@aws-amplify/amplify-cli-core';
44
import * as iam from 'aws-cdk-lib/aws-iam';
55
import * as lambda from 'aws-cdk-lib/aws-lambda';
6+
import { RuntimeFamily } from 'aws-cdk-lib/aws-lambda';
67
import * as cdk from 'aws-cdk-lib';
78
import { CustomResource } from 'aws-cdk-lib';
89
import { v4 as uuid } from 'uuid';
@@ -152,7 +153,7 @@ const createCustomResource = (
152153
): void => {
153154
const triggerCode = fs.readFileSync(authTriggerAssetFilePath, 'utf-8');
154155
const authTriggerFn = new lambda.Function(stack, 'authTriggerFn', {
155-
runtime: lambda.Runtime.NODEJS_18_X,
156+
runtime: new lambda.Runtime('nodejs22.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }),
156157
code: lambda.Code.fromInline(triggerCode),
157158
handler: 'index.handler',
158159
});

packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/mapStack.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ exports.handler = async function (event, context) {
180180
"Arn",
181181
],
182182
},
183-
"Runtime": "nodejs18.x",
183+
"Runtime": "nodejs22.x",
184184
"Timeout": 300,
185185
},
186186
"Type": "AWS::Lambda::Function",
@@ -525,7 +525,7 @@ exports.handler = async function (event, context) {
525525
"Arn",
526526
],
527527
},
528-
"Runtime": "nodejs18.x",
528+
"Runtime": "nodejs22.x",
529529
"Timeout": 300,
530530
},
531531
"Type": "AWS::Lambda::Function",

packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/placeIndexStack.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ exports.handler = async function (event, context) {
188188
"Arn",
189189
],
190190
},
191-
"Runtime": "nodejs18.x",
191+
"Runtime": "nodejs22.x",
192192
"Timeout": 300,
193193
},
194194
"Type": "AWS::Lambda::Function",
@@ -541,7 +541,7 @@ exports.handler = async function (event, context) {
541541
"Arn",
542542
],
543543
},
544-
"Runtime": "nodejs18.x",
544+
"Runtime": "nodejs22.x",
545545
"Timeout": 300,
546546
},
547547
"Type": "AWS::Lambda::Function",

packages/amplify-category-geo/src/service-stacks/geofenceCollectionStack.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Duration, Fn } from 'aws-cdk-lib';
55
import { Effect } from 'aws-cdk-lib/aws-iam';
66
import * as fs from 'fs-extra';
77
import _ from 'lodash';
8-
import { Runtime } from 'aws-cdk-lib/aws-lambda';
98
import { Construct } from 'constructs';
109
import { customGeofenceCollectionLambdaCodePath } from '../service-utils/constants';
1110
import { BaseStack, TemplateMappings } from './baseStack';
@@ -94,7 +93,7 @@ export class GeofenceCollectionStack extends BaseStack {
9493
const customGeofenceCollectionLambda = new lambda.Function(this, 'CustomGeofenceCollectionLambda', {
9594
code: lambda.Code.fromInline(customGeofenceCollectionLambdaCode),
9695
handler: 'index.handler',
97-
runtime: Runtime.NODEJS_18_X,
96+
runtime: new lambda.Runtime('nodejs22.x', lambda.RuntimeFamily.NODEJS, { supportsInlineCode: true }),
9897
timeout: Duration.seconds(300),
9998
});
10099
customGeofenceCollectionLambda.addToRolePolicy(geoCreateCollectionStatement);

0 commit comments

Comments
 (0)