Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Update node to 22 #14079

Draft
wants to merge 14 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/local_publish_helpers_codebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ function generatePkgCli {
cp package.json ../build/node_modules/package.json

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

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

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

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

Expand Down Expand Up @@ -141,7 +141,7 @@ function verifyPkgCli {

verifySinglePkg "amplify-pkg-linux-x64" "amplify-pkg-linux-x64.tgz" $((900 * 1024 * 1024))
verifySinglePkg "amplify-pkg-macos-x64" "amplify-pkg-macos-x64.tgz" $((900 * 1024 * 1024))
verifySinglePkg "amplify-pkg-win-x64.exe" "amplify-pkg-win-x64.tgz" $((890 * 1024 * 1024))
verifySinglePkg "amplify-pkg-win-x64.exe" "amplify-pkg-win-x64.tgz" $((900 * 1024 * 1024))
verifySinglePkg "amplify-pkg-linux-arm64" "amplify-pkg-linux-arm64.tgz" $((750 * 1024 * 1024))
}

Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The AWS Amplify CLI is a toolchain which includes a robust feature set for simpl

## Install the CLI

- Requires Node.js® version 18 or later
- Requires Node.js® version 22 or later

Install and configure the Amplify CLI as follows:

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"@types/yargs": "^17",
"@typescript-eslint/eslint-plugin": "^5.34.0",
"@typescript-eslint/parser": "^5.34.0",
"@yao-pkg/pkg": "^6.2.0",
"@zkochan/cmd-shim": "^5.1.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.3.0",
Expand Down Expand Up @@ -147,7 +148,6 @@
"lnk": "1.1.0",
"lodash": "^4.17.21",
"npm-check-updates": "^16.1.0",
"pkg": "^5.8.1",
"prettier": "^2.8.4",
"rimraf": "^3.0.0",
"ts-jest": "^29.0.0",
Expand All @@ -171,7 +171,6 @@
"json5": "^2.2.3",
"mysql2": "^3.9.8",
"nth-check": "^2.0.1",
"pkg-fetch": "^3.5.2",
"undici": "^5.28.3",
"tough-cookie": "^4.1.3",
"semver": "^7.5.4",
Expand Down
8 changes: 7 additions & 1 deletion packages/amplify-app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ async function installAmplifyCLI() {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
shell: isWin ? true : undefined,
});

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

return new Promise((resolve, reject) => {
const npmInstall = spawn(npm, ['install', '--only=dev'], { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
const npmInstall = spawn(npm, ['install', '--only=dev'], {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
shell: isWin ? true : undefined,
Copy link
Member Author

@sobolk sobolk Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using shell: true is required in latest versions of node (all LTS lines) to run .cmd files on Windows.

});

npmInstall.on('exit', (code) => {
if (code === 0) {
Expand Down
10 changes: 8 additions & 2 deletions packages/amplify-app/src/scripts/amplify-modelgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ console.log('Running codegen...');
run();

async function run() {
const amplify = process.env.AMPLIFY_PATH ? process.env.AMPLIFY_PATH : /^win/.test(process.platform) ? 'amplify.cmd' : 'amplify';
const modelGen = spawn(amplify, ['codegen', 'model'], { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
const isWindows = /^win/.test(process.platform);
const amplify = process.env.AMPLIFY_PATH ? process.env.AMPLIFY_PATH : isWindows ? 'amplify.cmd' : 'amplify';
const modelGen = spawn(amplify, ['codegen', 'model'], {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
shell: isWindows ? true : undefined,
});

modelGen.on('exit', (code) => {
if (code === 0) {
Expand Down
18 changes: 15 additions & 3 deletions packages/amplify-app/src/scripts/amplify-push.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const ini = require('ini');
const { spawn } = require('child_process');
const inquirer = require('inquirer');

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

async function configureProfile() {
const amplifyConfigure = spawn(amplify, ['configure'], { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
const amplifyConfigure = spawn(amplify, ['configure'], {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
shell: isWindows ? true : undefined,
});

return new Promise((resolve, reject) => {
amplifyConfigure.on('exit', (code) => {
Expand Down Expand Up @@ -124,11 +130,17 @@ async function run() {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
shell: isWindows ? true : undefined,
});
} else {
// just push

cloudPush = spawn(amplify, ['push', '--yes'], { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
cloudPush = spawn(amplify, ['push', '--yes'], {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
shell: isWindows ? true : undefined,
});
}

cloudPush.on('exit', (code) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
}
},
"Handler": "index.handler",
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 300,
"Role": {
"Fn::GetAtt": ["LambdaExecutionRole", "Arn"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
}
},
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 25
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ describe('auth update:', () => {
});
});
it('update run method should detect presence of dependent resource and print a message', async () => {
const originalExitCode = process.exitCode;
await update.run(mockContext);
expect(printer.info).toBeCalledWith(messages.dependenciesExists);
// Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455
process.exitCode = originalExitCode;
});
it('serviceSelectionPrompt should still be called even when warning displayed for existing resource', async () => {
await update.run(mockContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ async function createOrUpdateDomain(inputDomainName, userPoolId) {
"Arn",
],
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 300,
},
"Type": "AWS::Lambda::Function",
Expand Down Expand Up @@ -1147,7 +1147,7 @@ async function deleteIdentityProvider(providerName, userPoolId) {
"Arn",
],
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 300,
},
"Type": "AWS::Lambda::Function",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async function handleEvent(event) {
"Arn",
],
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
},
"Type": "AWS::Lambda::Function",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
handler: 'index.handler',
role: cdk.Fn.getAtt('UserPoolClientRole', 'Arn').toString(),
runtime: 'nodejs18.x',
runtime: 'nodejs22.x',
timeout: 300,
});

Expand Down Expand Up @@ -760,7 +760,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
handler: 'index.handler',
role: cdk.Fn.getAtt('UserPoolClientRole', 'Arn').toString(),
runtime: 'nodejs18.x',
runtime: 'nodejs22.x',
timeout: 300,
});

Expand Down Expand Up @@ -906,7 +906,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
handler: 'index.handler',
role: cdk.Fn.getAtt('MFALambdaRole', 'Arn').toString(),
runtime: 'nodejs18.x',
runtime: 'nodejs22.x',
timeout: 300,
});
this.mfaLambda.addDependency(this.mfaLambdaRole);
Expand Down Expand Up @@ -1047,7 +1047,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
handler: 'index.handler',
role: cdk.Fn.getAtt('OpenIdLambdaRole', 'Arn').toString(),
runtime: 'nodejs18.x',
runtime: 'nodejs22.x',
timeout: 300,
});
this.openIdLambda.addDependency(this.openIdLambdaRole);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import { $TSAny, AmplifyFault, JSONUtilities, pathManager, getPermissionsBoundaryArn } from '@aws-amplify/amplify-cli-core';
import { $TSAny, AmplifyFault, getPermissionsBoundaryArn, JSONUtilities, pathManager } from '@aws-amplify/amplify-cli-core';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { RuntimeFamily } from 'aws-cdk-lib/aws-lambda';
import * as cdk from 'aws-cdk-lib';
import { CustomResource } from 'aws-cdk-lib';
import { v4 as uuid } from 'uuid';
Expand Down Expand Up @@ -152,7 +153,7 @@ const createCustomResource = (
): void => {
const triggerCode = fs.readFileSync(authTriggerAssetFilePath, 'utf-8');
const authTriggerFn = new lambda.Function(stack, 'authTriggerFn', {
runtime: lambda.Runtime.NODEJS_18_X,
runtime: new lambda.Runtime('nodejs22.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code: lambda.Code.fromInline(triggerCode),
handler: 'index.handler',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ exports.handler = async function (event, context) {
"Arn",
],
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 300,
},
"Type": "AWS::Lambda::Function",
Expand Down Expand Up @@ -525,7 +525,7 @@ exports.handler = async function (event, context) {
"Arn",
],
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 300,
},
"Type": "AWS::Lambda::Function",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ exports.handler = async function (event, context) {
"Arn",
],
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 300,
},
"Type": "AWS::Lambda::Function",
Expand Down Expand Up @@ -541,7 +541,7 @@ exports.handler = async function (event, context) {
"Arn",
],
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs22.x",
"Timeout": 300,
},
"Type": "AWS::Lambda::Function",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Duration, Fn } from 'aws-cdk-lib';
import { Effect } from 'aws-cdk-lib/aws-iam';
import * as fs from 'fs-extra';
import _ from 'lodash';
import { Runtime } from 'aws-cdk-lib/aws-lambda';
import { Construct } from 'constructs';
import { customGeofenceCollectionLambdaCodePath } from '../service-utils/constants';
import { BaseStack, TemplateMappings } from './baseStack';
Expand Down Expand Up @@ -94,7 +93,7 @@ export class GeofenceCollectionStack extends BaseStack {
const customGeofenceCollectionLambda = new lambda.Function(this, 'CustomGeofenceCollectionLambda', {
code: lambda.Code.fromInline(customGeofenceCollectionLambdaCode),
handler: 'index.handler',
runtime: Runtime.NODEJS_18_X,
runtime: new lambda.Runtime('nodejs22.x', lambda.RuntimeFamily.NODEJS, { supportsInlineCode: true }),
timeout: Duration.seconds(300),
});
customGeofenceCollectionLambda.addToRolePolicy(geoCreateCollectionStatement);
Expand Down
Loading
Loading