diff --git a/.circleci/local_publish_helpers_codebuild.sh b/.circleci/local_publish_helpers_codebuild.sh index 1ca8b1e68f9..03de4ba0d77 100644 --- a/.circleci/local_publish_helpers_codebuild.sh +++ b/.circleci/local_publish_helpers_codebuild.sh @@ -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 @@ -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)) } diff --git a/Readme.md b/Readme.md index 04cb431843e..81be0ad8709 100644 --- a/Readme.md +++ b/Readme.md @@ -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: diff --git a/package.json b/package.json index 752c9de3dfd..fad610a14c6 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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", diff --git a/packages/amplify-app/src/index.js b/packages/amplify-app/src/index.js index 8db7ff296f7..c63ad33f36d 100644 --- a/packages/amplify-app/src/index.js +++ b/packages/amplify-app/src/index.js @@ -90,6 +90,7 @@ async function installAmplifyCLI() { cwd: process.cwd(), env: process.env, stdio: 'inherit', + shell: isWin ? true : undefined, }); amplifyCLIInstall.on('exit', (code) => { @@ -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, + }); npmInstall.on('exit', (code) => { if (code === 0) { diff --git a/packages/amplify-app/src/scripts/amplify-modelgen.js b/packages/amplify-app/src/scripts/amplify-modelgen.js index 405b041706c..a38a17a798f 100644 --- a/packages/amplify-app/src/scripts/amplify-modelgen.js +++ b/packages/amplify-app/src/scripts/amplify-modelgen.js @@ -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) { diff --git a/packages/amplify-app/src/scripts/amplify-push.js b/packages/amplify-app/src/scripts/amplify-push.js index 291b69c02c2..4a62cf0118f 100644 --- a/packages/amplify-app/src/scripts/amplify-push.js +++ b/packages/amplify-app/src/scripts/amplify-push.js @@ -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(); @@ -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) => { @@ -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) => { diff --git a/packages/amplify-category-analytics/src/provider-utils/awscloudformation/cloudformation-templates/pinpoint-cloudformation-template.json b/packages/amplify-category-analytics/src/provider-utils/awscloudformation/cloudformation-templates/pinpoint-cloudformation-template.json index 831a67192fb..0b7400f7a5f 100644 --- a/packages/amplify-category-analytics/src/provider-utils/awscloudformation/cloudformation-templates/pinpoint-cloudformation-template.json +++ b/packages/amplify-category-analytics/src/provider-utils/awscloudformation/cloudformation-templates/pinpoint-cloudformation-template.json @@ -260,7 +260,7 @@ } }, "Handler": "index.handler", - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, "Role": { "Fn::GetAtt": ["LambdaExecutionRole", "Arn"] diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/cloudformation-templates/CreateAuthChallenge.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/cloudformation-templates/CreateAuthChallenge.json.ejs index 507536ba076..2570032a32d 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/cloudformation-templates/CreateAuthChallenge.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/cloudformation-templates/CreateAuthChallenge.json.ejs @@ -104,7 +104,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/cloudformation-templates/CustomMessage.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/cloudformation-templates/CustomMessage.json.ejs index b10532f1c1d..fe532ec338f 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/cloudformation-templates/CustomMessage.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/cloudformation-templates/CustomMessage.json.ejs @@ -121,7 +121,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/cloudformation-templates/DefineAuthChallenge.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/cloudformation-templates/DefineAuthChallenge.json.ejs index f90e55519b2..f0e74871678 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/cloudformation-templates/DefineAuthChallenge.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/cloudformation-templates/DefineAuthChallenge.json.ejs @@ -97,7 +97,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/cloudformation-templates/PostAuthentication.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/cloudformation-templates/PostAuthentication.json.ejs index f90e55519b2..f0e74871678 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/cloudformation-templates/PostAuthentication.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/cloudformation-templates/PostAuthentication.json.ejs @@ -97,7 +97,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/cloudformation-templates/PostConfirmation.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/cloudformation-templates/PostConfirmation.json.ejs index 7ee69224f1c..6679c8bc51f 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/cloudformation-templates/PostConfirmation.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/cloudformation-templates/PostConfirmation.json.ejs @@ -104,7 +104,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/cloudformation-templates/PreAuthentication.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/cloudformation-templates/PreAuthentication.json.ejs index 8eacef5872f..83d74d100bf 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/cloudformation-templates/PreAuthentication.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/cloudformation-templates/PreAuthentication.json.ejs @@ -97,7 +97,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/cloudformation-templates/PreSignup.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/cloudformation-templates/PreSignup.json.ejs index ec45f8b168d..32cfb89ebc8 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/cloudformation-templates/PreSignup.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/cloudformation-templates/PreSignup.json.ejs @@ -111,7 +111,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/cloudformation-templates/PreTokenGeneration.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/cloudformation-templates/PreTokenGeneration.json.ejs index 8eacef5872f..83d74d100bf 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/cloudformation-templates/PreTokenGeneration.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/cloudformation-templates/PreTokenGeneration.json.ejs @@ -97,7 +97,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/cloudformation-templates/VerifyAuthChallengeResponse.json.ejs b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/cloudformation-templates/VerifyAuthChallengeResponse.json.ejs index d28fece4559..455350f73ff 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/cloudformation-templates/VerifyAuthChallengeResponse.json.ejs +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/cloudformation-templates/VerifyAuthChallengeResponse.json.ejs @@ -105,7 +105,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/resources/adminAuth/admin-queries-function-template.json.ejs b/packages/amplify-category-auth/resources/adminAuth/admin-queries-function-template.json.ejs index 0c619ea2a85..b9abe978c8b 100644 --- a/packages/amplify-category-auth/resources/adminAuth/admin-queries-function-template.json.ejs +++ b/packages/amplify-category-auth/resources/adminAuth/admin-queries-function-template.json.ejs @@ -65,7 +65,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-auth/src/__tests__/commands/update.test.ts b/packages/amplify-category-auth/src/__tests__/commands/update.test.ts index 96536044453..d0090df1c0f 100644 --- a/packages/amplify-category-auth/src/__tests__/commands/update.test.ts +++ b/packages/amplify-category-auth/src/__tests__/commands/update.test.ts @@ -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); diff --git a/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/auth-stack-builder/__snapshots__/auth-stack-transform.test.ts.snap b/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/auth-stack-builder/__snapshots__/auth-stack-transform.test.ts.snap index 75d5b2751b0..aa1fd1a4c4e 100644 --- a/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/auth-stack-builder/__snapshots__/auth-stack-transform.test.ts.snap +++ b/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/auth-stack-builder/__snapshots__/auth-stack-transform.test.ts.snap @@ -872,7 +872,7 @@ async function createOrUpdateDomain(inputDomainName, userPoolId) { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, }, "Type": "AWS::Lambda::Function", @@ -1147,7 +1147,7 @@ async function deleteIdentityProvider(providerName, userPoolId) { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, }, "Type": "AWS::Lambda::Function", diff --git a/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/__snapshots__/generate-auth-trigger-template.test.ts.snap b/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/__snapshots__/generate-auth-trigger-template.test.ts.snap index 9927083f0ae..91df4cdd9dc 100644 --- a/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/__snapshots__/generate-auth-trigger-template.test.ts.snap +++ b/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/__snapshots__/generate-auth-trigger-template.test.ts.snap @@ -196,7 +196,7 @@ async function handleEvent(event) { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", }, "Type": "AWS::Lambda::Function", }, diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-stack-builder/auth-cognito-stack-builder.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-stack-builder/auth-cognito-stack-builder.ts index a0a8d4ed8fe..9a3864a389b 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-stack-builder/auth-cognito-stack-builder.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-stack-builder/auth-cognito-stack-builder.ts @@ -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, }); @@ -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, }); @@ -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); @@ -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); diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts index 24c5f856909..711fdf85480 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts @@ -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'; @@ -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 }), code: lambda.Code.fromInline(triggerCode), handler: 'index.handler', }); diff --git a/packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/mapStack.test.ts.snap b/packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/mapStack.test.ts.snap index 6036c70833d..89a3fe57d4f 100644 --- a/packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/mapStack.test.ts.snap +++ b/packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/mapStack.test.ts.snap @@ -180,7 +180,7 @@ exports.handler = async function (event, context) { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, }, "Type": "AWS::Lambda::Function", @@ -525,7 +525,7 @@ exports.handler = async function (event, context) { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, }, "Type": "AWS::Lambda::Function", diff --git a/packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/placeIndexStack.test.ts.snap b/packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/placeIndexStack.test.ts.snap index bc67fdf2289..f3a21f7993a 100644 --- a/packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/placeIndexStack.test.ts.snap +++ b/packages/amplify-category-geo/src/__tests__/service-stacks/__snapshots__/placeIndexStack.test.ts.snap @@ -188,7 +188,7 @@ exports.handler = async function (event, context) { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, }, "Type": "AWS::Lambda::Function", @@ -541,7 +541,7 @@ exports.handler = async function (event, context) { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, }, "Type": "AWS::Lambda::Function", diff --git a/packages/amplify-category-geo/src/service-stacks/geofenceCollectionStack.ts b/packages/amplify-category-geo/src/service-stacks/geofenceCollectionStack.ts index ab9c34fce61..e6eddfd6ddc 100644 --- a/packages/amplify-category-geo/src/service-stacks/geofenceCollectionStack.ts +++ b/packages/amplify-category-geo/src/service-stacks/geofenceCollectionStack.ts @@ -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'; @@ -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); diff --git a/packages/amplify-category-geo/src/service-stacks/mapStack.ts b/packages/amplify-category-geo/src/service-stacks/mapStack.ts index 90afc6963d7..342be00bfc6 100644 --- a/packages/amplify-category-geo/src/service-stacks/mapStack.ts +++ b/packages/amplify-category-geo/src/service-stacks/mapStack.ts @@ -3,7 +3,6 @@ import * as iam from 'aws-cdk-lib/aws-iam'; import * as lambda from 'aws-cdk-lib/aws-lambda'; import { CfnResource, Duration, Fn } from 'aws-cdk-lib'; import { Effect } from 'aws-cdk-lib/aws-iam'; -import { Runtime } from 'aws-cdk-lib/aws-lambda'; import { Construct } from 'constructs'; import * as fs from 'fs-extra'; import { MapParameters } from '../service-utils/mapParams'; @@ -94,7 +93,7 @@ export class MapStack extends BaseStack { const customMapLambda = new lambda.Function(this, 'CustomMapLambda', { code: lambda.Code.fromInline(customMapLambdaCode), handler: 'index.handler', - runtime: Runtime.NODEJS_18_X, + runtime: new lambda.Runtime('nodejs22.x', lambda.RuntimeFamily.NODEJS, { supportsInlineCode: true }), timeout: Duration.seconds(300), }); customMapLambda.addToRolePolicy(geoCreateMapStatement); diff --git a/packages/amplify-category-geo/src/service-stacks/placeIndexStack.ts b/packages/amplify-category-geo/src/service-stacks/placeIndexStack.ts index 3b840f4f6a5..90c60825527 100644 --- a/packages/amplify-category-geo/src/service-stacks/placeIndexStack.ts +++ b/packages/amplify-category-geo/src/service-stacks/placeIndexStack.ts @@ -4,7 +4,6 @@ import * as lambda from 'aws-cdk-lib/aws-lambda'; import { CfnResource, Duration, Fn } from 'aws-cdk-lib'; import { Effect } from 'aws-cdk-lib/aws-iam'; import * as fs from 'fs-extra'; -import { Runtime } from 'aws-cdk-lib/aws-lambda'; import { Construct } from 'constructs'; import { PlaceIndexParameters } from '../service-utils/placeIndexParams'; import { AccessType } from '../service-utils/resourceParams'; @@ -94,7 +93,7 @@ export class PlaceIndexStack extends BaseStack { const customPlaceIndexLambda = new lambda.Function(this, 'CustomPlaceIndexLambda', { code: lambda.Code.fromInline(customPlaceIndexLambdaCode), handler: 'index.handler', - runtime: Runtime.NODEJS_18_X, + runtime: new lambda.Runtime('nodejs22.x', lambda.RuntimeFamily.NODEJS, { supportsInlineCode: true }), timeout: Duration.seconds(300), }); customPlaceIndexLambda.addToRolePolicy(geoCreateIndexStatement); diff --git a/packages/amplify-category-interactions/src/provider-utils/awscloudformation/cloudformation-templates/lex-cloudformation-template.json.ejs b/packages/amplify-category-interactions/src/provider-utils/awscloudformation/cloudformation-templates/lex-cloudformation-template.json.ejs index f61a29010ea..90d170da1a8 100644 --- a/packages/amplify-category-interactions/src/provider-utils/awscloudformation/cloudformation-templates/lex-cloudformation-template.json.ejs +++ b/packages/amplify-category-interactions/src/provider-utils/awscloudformation/cloudformation-templates/lex-cloudformation-template.json.ejs @@ -66,7 +66,7 @@ }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, "Environment": {"Variables" : { "ENV": {"Ref": "env"}}}, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300 } }, diff --git a/packages/amplify-category-predictions/src/provider-utils/awscloudformation/assets/identifyCFNGenerate.js b/packages/amplify-category-predictions/src/provider-utils/awscloudformation/assets/identifyCFNGenerate.js index 0aa32f9d8cc..e5bf851b572 100644 --- a/packages/amplify-category-predictions/src/provider-utils/awscloudformation/assets/identifyCFNGenerate.js +++ b/packages/amplify-category-predictions/src/provider-utils/awscloudformation/assets/identifyCFNGenerate.js @@ -534,7 +534,7 @@ const generateLambdaAccessForRekognition = (identifyCFNFile, functionName, s3Res }, }, Handler: 'index.handler', - Runtime: 'nodejs18.x', + Runtime: 'nodejs22.x', Timeout: 300, Role: { 'Fn::GetAtt': ['CollectionsLambdaExecutionRole', 'Arn'], diff --git a/packages/amplify-category-predictions/src/provider-utils/awscloudformation/cloudformation-templates/identify-template.json.ejs b/packages/amplify-category-predictions/src/provider-utils/awscloudformation/cloudformation-templates/identify-template.json.ejs index 9fdd60daaed..6e886be46b7 100644 --- a/packages/amplify-category-predictions/src/provider-utils/awscloudformation/cloudformation-templates/identify-template.json.ejs +++ b/packages/amplify-category-predictions/src/provider-utils/awscloudformation/cloudformation-templates/identify-template.json.ejs @@ -354,7 +354,7 @@ } }, "Handler": "index.handler", - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, "Role": { "Fn::GetAtt": [ diff --git a/packages/amplify-category-predictions/src/provider-utils/awscloudformation/triggers/s3/lambda-cloudformation-template.json.ejs b/packages/amplify-category-predictions/src/provider-utils/awscloudformation/triggers/s3/lambda-cloudformation-template.json.ejs index 087e57ba5ea..3c44c86061d 100644 --- a/packages/amplify-category-predictions/src/provider-utils/awscloudformation/triggers/s3/lambda-cloudformation-template.json.ejs +++ b/packages/amplify-category-predictions/src/provider-utils/awscloudformation/triggers/s3/lambda-cloudformation-template.json.ejs @@ -69,7 +69,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 900 } }, diff --git a/packages/amplify-category-storage/resources/triggers/dynamoDB/lambda-cloudformation-template.json.ejs b/packages/amplify-category-storage/resources/triggers/dynamoDB/lambda-cloudformation-template.json.ejs index 433c2c3842f..63a39977a29 100644 --- a/packages/amplify-category-storage/resources/triggers/dynamoDB/lambda-cloudformation-template.json.ejs +++ b/packages/amplify-category-storage/resources/triggers/dynamoDB/lambda-cloudformation-template.json.ejs @@ -52,7 +52,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-category-storage/resources/triggers/s3/lambda-cloudformation-template.json.ejs b/packages/amplify-category-storage/resources/triggers/s3/lambda-cloudformation-template.json.ejs index 433c2c3842f..63a39977a29 100644 --- a/packages/amplify-category-storage/resources/triggers/s3/lambda-cloudformation-template.json.ejs +++ b/packages/amplify-category-storage/resources/triggers/s3/lambda-cloudformation-template.json.ejs @@ -52,7 +52,7 @@ } }, "Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 25 } }, diff --git a/packages/amplify-cli-npm/index.ts b/packages/amplify-cli-npm/index.ts index 266bc77f889..2f5d33fe57a 100644 --- a/packages/amplify-cli-npm/index.ts +++ b/packages/amplify-cli-npm/index.ts @@ -16,4 +16,4 @@ export const install = async (): Promise => { return binary.install(); }; -// force version bump to 12.14.0 +// force version bump to 13.0.0 diff --git a/packages/amplify-cli/src/__tests__/amplify-exception-handler.test.ts b/packages/amplify-cli/src/__tests__/amplify-exception-handler.test.ts index 49d9efb2711..b3cb1e0f289 100644 --- a/packages/amplify-cli/src/__tests__/amplify-exception-handler.test.ts +++ b/packages/amplify-cli/src/__tests__/amplify-exception-handler.test.ts @@ -35,6 +35,7 @@ describe('test exception handler', () => { init(contextMock); }); it('error handler should call usageData emitError', async () => { + const originalExitCode = process.exitCode; const amplifyError = new AmplifyError('NotImplementedError', { message: 'Test Not implemented', resolution: 'Test Not implemented', @@ -42,9 +43,12 @@ describe('test exception handler', () => { await handleException(amplifyError); expect(contextMock.usageData.emitError).toHaveBeenCalledWith(amplifyError); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }); it('error handler should send error report', async () => { + const originalExitCode = process.exitCode; const amplifyError = new AmplifyError('NotImplementedError', { message: 'Test Not implemented', resolution: 'Test Not implemented', @@ -53,9 +57,12 @@ describe('test exception handler', () => { expect(reportErrorMock).toHaveBeenCalledWith(contextMock, amplifyError); expect(processExit).toHaveBeenCalledWith(1); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }); it('error handler should print error', async () => { + const originalExitCode = process.exitCode; const amplifyError = new AmplifyError('NotImplementedError', { message: 'Test Not implemented(message)', details: 'Test Not implemented(details)', @@ -69,9 +76,12 @@ describe('test exception handler', () => { expect(printerMock.info).toHaveBeenNthCalledWith(1, `Resolution: ${amplifyError.resolution}`); expect(printerMock.info).toHaveBeenLastCalledWith('Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/'); expect(printerMock.debug).toHaveBeenCalledWith(amplifyError.stack); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }); it('error handler should handle encountered errors gracefully', async () => { + const originalExitCode = process.exitCode; const amplifyError = new AmplifyError('NotImplementedError', { message: 'Test Not implemented(message)', details: 'Test Not implemented(details)', @@ -87,9 +97,12 @@ describe('test exception handler', () => { expect(printerMock.info).toHaveBeenLastCalledWith('Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/'); expect(printerMock.debug).toHaveBeenCalledWith(amplifyError.stack); expect(printerMock.error).toHaveBeenCalledWith('Failed to report error: MockTestError'); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }); it('error handler should handle nodejs file permission errors for log files', async () => { + const originalExitCode = process.exitCode; const code = 'EACCES'; const path = '/user/name/.amplify/path/to/log'; const nodeJSError = new Error(`permission denied, open ${path}`) as NodeJS.ErrnoException; @@ -102,9 +115,12 @@ describe('test exception handler', () => { new AmplifyError('FileSystemPermissionsError', { message: `permission denied, open ${path}` }), ); expect(printerMock.info).toHaveBeenCalledWith(`Resolution: Try running 'sudo chown -R $(whoami):$(id -gn) ~/.amplify' to fix this`); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }); it('error handler should handle nodejs file permission errors for ~/.aws/amplify files', async () => { + const originalExitCode = process.exitCode; const code = 'EACCES'; const path = '/user/name/.aws/amplify/someFile'; const nodeJSError = new Error(`permission denied, open ${path}`) as NodeJS.ErrnoException; @@ -117,9 +133,12 @@ describe('test exception handler', () => { new AmplifyError('FileSystemPermissionsError', { message: `permission denied, open ${path}` }), ); expect(printerMock.info).toHaveBeenCalledWith(`Resolution: Try running 'sudo chown -R $(whoami):$(id -gn) ~/.aws/amplify' to fix this`); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }); it('error handler should handle nodejs file permission errors for amplify project', async () => { + const originalExitCode = process.exitCode; const code = 'EACCES'; const path = '/user/name/workspace/amplify/path/to/manifest'; const nodeJSError = new Error(`permission denied, open ${path}`) as NodeJS.ErrnoException; @@ -135,9 +154,12 @@ describe('test exception handler', () => { expect(printerMock.info).toHaveBeenCalledWith( `Resolution: Try running 'sudo chown -R $(whoami):$(id -gn) ' to fix this`, ); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }); it('error handler should handle nodejs file permission errors for other files', async () => { + const originalExitCode = process.exitCode; const code = 'EACCES'; const path = '/usr/name/.aws/config'; const nodeJSError = new Error(`permission denied, open ${path}`) as NodeJS.ErrnoException; @@ -151,6 +173,8 @@ describe('test exception handler', () => { ); // different resolution based on the file path compared to last test expect(printerMock.info).toHaveBeenCalledWith(`Resolution: Try running 'sudo chown -R $(whoami):$(id -gn) ${path}' to fix this`); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }); }); diff --git a/packages/amplify-cli/src/__tests__/test-aborting.test.ts b/packages/amplify-cli/src/__tests__/test-aborting.test.ts index c70225cc9f1..9bdd009cd57 100644 --- a/packages/amplify-cli/src/__tests__/test-aborting.test.ts +++ b/packages/amplify-cli/src/__tests__/test-aborting.test.ts @@ -111,6 +111,7 @@ describe('test SIGINT with execute', () => { jest.mock('@aws-amplify/amplify-environment-parameters'); + const originalExitCode = process.exitCode; setTimeout(() => { process.emit('SIGINT', 'SIGINT'); process.exitCode = 2; @@ -124,6 +125,8 @@ describe('test SIGINT with execute', () => { expect(mockContext.usageData.emitError).toHaveBeenCalledTimes(0); expect(mockContext.usageData.emitSuccess).toHaveBeenCalledTimes(0); expect(mockExit).toBeCalledWith(2); + // Setting exitCode back to original, see https://github.com/jestjs/jest/issues/9324#issuecomment-1808090455 + process.exitCode = originalExitCode; }, 10000); }); diff --git a/packages/amplify-cli/src/index.ts b/packages/amplify-cli/src/index.ts index 6dfe0674fa0..5cbc5d02d49 100644 --- a/packages/amplify-cli/src/index.ts +++ b/packages/amplify-cli/src/index.ts @@ -257,4 +257,4 @@ export const executeAmplifyCommand = async (context: Context): Promise => } }; -// bump version to 12.14.0 +// bump version to 13.0.0 diff --git a/packages/amplify-cli/src/project-config-version-check.ts b/packages/amplify-cli/src/project-config-version-check.ts index 3c0b77e2e13..4b3fb6d0f47 100644 --- a/packages/amplify-cli/src/project-config-version-check.ts +++ b/packages/amplify-cli/src/project-config-version-check.ts @@ -11,11 +11,11 @@ import Resource from 'cloudform-types/types/resource'; import Lambda from 'cloudform-types/types/lambda'; // See https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html. -const previousLambdaRuntimeVersions = ['nodejs8.10', 'nodejs10.x', 'nodejs12.x']; -// Note. It's safe to auto migrate existing lambdas above to nodejs16.x by replacing runtime -// as they bundle AWS SDK v2. This mechanism isn't viable to upgrade to nodejs18.x -// as that version bundles AWS SDK v3 which is not compatible. -const lambdaRuntimeVersion = 'nodejs16.x'; +const previousLambdaRuntimeVersions = ['nodejs18.x']; +// Note. It's safe to auto migrate existing lambdas above to nodejs22.x by replacing runtime +// as they bundle AWS SDK v3. This mechanism isn't viable for version before nodejs18.x +// as those versions bundles AWS SDK v2 which is not compatible. +const lambdaRuntimeVersion = 'nodejs22.x'; export async function checkProjectConfigVersion(context: Context): Promise { const { constants } = context.amplify; diff --git a/packages/amplify-e2e-tests/src/__tests__/migration/node.function.test.ts b/packages/amplify-e2e-tests/src/__tests__/migration/node.function.test.ts index 1cd3c89024f..28ab002482e 100644 --- a/packages/amplify-e2e-tests/src/__tests__/migration/node.function.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/migration/node.function.test.ts @@ -56,7 +56,7 @@ describe('nodejs version migration tests', () => { ); let authStackContent = fs.readFileSync(authStackFileName).toString(); - authStackContent = authStackContent.replace('nodejs16.x', 'nodejs10.x'); + authStackContent = authStackContent.replace('nodejs22.x', 'nodejs18.x'); fs.writeFileSync(authStackFileName, authStackContent, 'utf-8'); @@ -71,7 +71,7 @@ describe('nodejs version migration tests', () => { ); let functionStackContent = fs.readFileSync(functionStackFileName).toString(); - functionStackContent = functionStackContent.replace(/nodejs\d{1,2}\.x/, 'nodejs10.x'); + functionStackContent = functionStackContent.replace(/nodejs\d{1,2}\.x/, 'nodejs18.x'); fs.writeFileSync(functionStackFileName, functionStackContent, 'utf-8'); @@ -83,7 +83,7 @@ describe('nodejs version migration tests', () => { functionStackContent = fs.readFileSync(functionStackFileName).toString(); expect(projectConfigContent.indexOf('3.1')).toBeGreaterThan(0); - expect(functionStackContent.indexOf('nodejs16.x')).toBeGreaterThan(0); + expect(functionStackContent.indexOf('nodejs22.x')).toBeGreaterThan(0); }); const amplifyNodeMigrationAndPush = async (cwd: string): Promise => { diff --git a/packages/amplify-e2e-tests/src/aws-exports/awsExports.ts b/packages/amplify-e2e-tests/src/aws-exports/awsExports.ts index 3f9372a93a5..60d2cdd8b9c 100644 --- a/packages/amplify-e2e-tests/src/aws-exports/awsExports.ts +++ b/packages/amplify-e2e-tests/src/aws-exports/awsExports.ts @@ -1,5 +1,8 @@ import * as fs from 'fs-extra'; import * as path from 'path'; +import { transformSync } from '@babel/core'; +import babelTransformEsmToCjs from '@babel/plugin-transform-modules-commonjs'; +import { Module } from 'module'; export function getAWSExportsPath(projRoot: string): string { return path.join(projRoot, 'src', 'aws-exports.js'); @@ -7,10 +10,16 @@ export function getAWSExportsPath(projRoot: string): string { export function getAWSExports(projectRoot: string) { const awsExportsPath = getAWSExportsPath(projectRoot); - // From Jest 25, ESM modules can only be loaded with mjs extension and Jest takes over - // require, that's why we need to copy the file. - const awsExportsMJSPath = awsExportsPath.replace('.js', '.mjs'); - fs.copySync(awsExportsPath, awsExportsMJSPath, { overwrite: true }); - const localRequire = require('esm')(module); - return localRequire(awsExportsMJSPath); + const fileContents = fs.readFileSync(awsExportsPath, 'utf-8'); + // transpile the file contents to CommonJS + const { code } = transformSync(fileContents, { + plugins: [babelTransformEsmToCjs], + configFile: false, + babelrc: false, + }); + const mod = new Module('aws-exports.js'); + // @ts-expect-error This is private api. + mod._compile(code, 'aws-exports.js'); + mod.paths = [projectRoot]; + return mod.exports; } diff --git a/packages/amplify-nodejs-function-runtime-provider/src/index.ts b/packages/amplify-nodejs-function-runtime-provider/src/index.ts index 0fa25f833cc..291483e48e6 100644 --- a/packages/amplify-nodejs-function-runtime-provider/src/index.ts +++ b/packages/amplify-nodejs-function-runtime-provider/src/index.ts @@ -15,7 +15,7 @@ export const functionRuntimeContributorFactory: FunctionRuntimeContributorFactor runtime: { name: 'NodeJS', value: 'nodejs', - cloudTemplateValue: 'nodejs18.x', + cloudTemplateValue: 'nodejs22.x', defaultHandler: 'index.handler', layerExecutablePath: 'nodejs', layerDefaultFiles: [ diff --git a/packages/amplify-provider-awscloudformation/resources/update-idp-roles-cfn.json b/packages/amplify-provider-awscloudformation/resources/update-idp-roles-cfn.json index ebe7d192dbf..0ea04d65d1b 100644 --- a/packages/amplify-provider-awscloudformation/resources/update-idp-roles-cfn.json +++ b/packages/amplify-provider-awscloudformation/resources/update-idp-roles-cfn.json @@ -85,7 +85,7 @@ } }, "Handler": "index.handler", - "Runtime": "nodejs18.x", + "Runtime": "nodejs22.x", "Timeout": 300, "Role": { "Fn::GetAtt": ["UpdateRolesWithIDPFunctionRole", "Arn"] diff --git a/yarn.lock b/yarn.lock index f13780f6380..ce510c11cf1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5236,17 +5236,6 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:7.18.2": - version: 7.18.2 - resolution: "@babel/generator@npm:7.18.2" - dependencies: - "@babel/types": ^7.18.2 - "@jridgewell/gen-mapping": ^0.3.0 - jsesc: ^2.5.1 - checksum: 96d8ddf60091ca7cb43df251451c8a56383f32ce02bcb26503d9b2c703922ccd8a993936a9d6798dede4f5e2a0c939f383abb888d27d6c5dca27afd323dc85f8 - languageName: node - linkType: hard - "@babel/generator@npm:^7.14.0, @babel/generator@npm:^7.23.0, @babel/generator@npm:^7.7.2": version: 7.23.0 resolution: "@babel/generator@npm:7.23.0" @@ -5476,14 +5465,14 @@ __metadata: languageName: node linkType: hard -"@babel/helper-string-parser@npm:^7.18.10, @babel/helper-string-parser@npm:^7.22.5": +"@babel/helper-string-parser@npm:^7.22.5": version: 7.22.5 resolution: "@babel/helper-string-parser@npm:7.22.5" checksum: 6b0ff8af724377ec41e5587fffa7605198da74cb8e7d8d48a36826df0c0ba210eb9fedb3d9bef4d541156e0bd11040f021945a6cbb731ccec4aefb4affa17aa4 languageName: node linkType: hard -"@babel/helper-validator-identifier@npm:^7.16.7, @babel/helper-validator-identifier@npm:^7.18.6, @babel/helper-validator-identifier@npm:^7.22.20": +"@babel/helper-validator-identifier@npm:^7.16.7, @babel/helper-validator-identifier@npm:^7.22.20": version: 7.22.20 resolution: "@babel/helper-validator-identifier@npm:7.22.20" checksum: dcad63db345fb110e032de46c3688384b0008a42a4845180ce7cd62b1a9c0507a1bed727c4d1060ed1a03ae57b4d918570259f81724aaac1a5b776056f37504e @@ -5531,15 +5520,6 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:7.18.4": - version: 7.18.4 - resolution: "@babel/parser@npm:7.18.4" - bin: - parser: ./bin/babel-parser.js - checksum: baaab10525399f532d8bb2668c0c27b727c6e9440c65595dd6bdc15d33efcb63d99c3b07562396e94badbc0e0f443a59c34f6b07c9a42732fa38a60e06c4666a - languageName: node - linkType: hard - "@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.22.15, @babel/parser@npm:^7.23.0, @babel/parser@npm:^7.7.0": version: 7.23.0 resolution: "@babel/parser@npm:7.23.0" @@ -6686,18 +6666,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:7.19.0": - version: 7.19.0 - resolution: "@babel/types@npm:7.19.0" - dependencies: - "@babel/helper-string-parser": ^7.18.10 - "@babel/helper-validator-identifier": ^7.18.6 - to-fast-properties: ^2.0.0 - checksum: 36b9360aa2d29fe515963b7c7014de3d66eb8c17315d00c65d82ab46b44482d5ba898aa3b5bc84887e6304b5456f2dbfe46e21851ca514f98106d8d47fbc3a0f - languageName: node - linkType: hard - -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.12.6, @babel/types@npm:^7.16.7, @babel/types@npm:^7.16.8, @babel/types@npm:^7.18.2, @babel/types@npm:^7.18.6, @babel/types@npm:^7.20.0, @babel/types@npm:^7.21.5, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.7.0, @babel/types@npm:^7.8.3": +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.12.6, @babel/types@npm:^7.16.7, @babel/types@npm:^7.16.8, @babel/types@npm:^7.18.6, @babel/types@npm:^7.20.0, @babel/types@npm:^7.21.5, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.7.0, @babel/types@npm:^7.8.3": version: 7.23.0 resolution: "@babel/types@npm:7.23.0" dependencies: @@ -11329,6 +11298,48 @@ __metadata: languageName: node linkType: hard +"@yao-pkg/pkg-fetch@npm:3.5.18": + version: 3.5.18 + resolution: "@yao-pkg/pkg-fetch@npm:3.5.18" + dependencies: + https-proxy-agent: ^5.0.0 + node-fetch: ^2.6.6 + picocolors: ^1.1.0 + progress: ^2.0.3 + semver: ^7.3.5 + tar-fs: ^2.1.1 + yargs: ^16.2.0 + bin: + pkg-fetch: lib-es5/bin.js + checksum: f63f728965d404d429a3c11c09f7655b6adce54cc5a2094b0507e206d9c5fd6e6dd0950ae1e7ad5db36d195f40e5437b026592a93c92149c35dd49f09fc6f57a + languageName: node + linkType: hard + +"@yao-pkg/pkg@npm:^6.2.0": + version: 6.2.0 + resolution: "@yao-pkg/pkg@npm:6.2.0" + dependencies: + "@babel/generator": ^7.23.0 + "@babel/parser": ^7.23.0 + "@babel/types": ^7.23.0 + "@yao-pkg/pkg-fetch": 3.5.18 + into-stream: ^6.0.0 + minimist: ^1.2.6 + multistream: ^4.1.0 + picocolors: ^1.1.0 + picomatch: ^4.0.2 + prebuild-install: ^7.1.1 + resolve: ^1.22.0 + stream-meter: ^1.0.4 + tar: ^7.4.3 + tinyglobby: ^0.2.9 + unzipper: ^0.12.3 + bin: + pkg: lib-es5/bin.js + checksum: 5fc37c105ae06b2ae4bd4566f6c74020d2dd9cb0cf841cad4a909396850cd3e30766585e9b9e1af56cce690152661ddf72d99e6f3ef4332ab639cc222744f74b + languageName: node + linkType: hard + "@yarnpkg/lockfile@npm:^1.1.0": version: 1.1.0 resolution: "@yarnpkg/lockfile@npm:1.1.0" @@ -11650,6 +11661,7 @@ __metadata: "@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 @@ -11682,7 +11694,6 @@ __metadata: lodash: ^4.17.21 node-gyp: ^9.3.1 npm-check-updates: ^16.1.0 - pkg: ^5.8.1 prettier: ^2.8.4 rimraf: ^3.0.0 strip-ansi: ^6.0.0 @@ -13218,7 +13229,7 @@ __metadata: languageName: node linkType: hard -"bluebird@npm:^3.5.5": +"bluebird@npm:^3.5.5, bluebird@npm:~3.7.2": version: 3.7.2 resolution: "bluebird@npm:3.7.2" checksum: 680de03adc54ff925eaa6c7bb9a47a0690e8b5de60f4792604aae8ed618c65e6b63a7893b57ca924beaf53eee69c5af4f8314148c08124c550fe1df1add897d2 @@ -16174,6 +16185,15 @@ __metadata: languageName: node linkType: hard +"duplexer2@npm:~0.1.4": + version: 0.1.4 + resolution: "duplexer2@npm:0.1.4" + dependencies: + readable-stream: ^2.0.2 + checksum: 0765a4cc6fe6d9615d43cc6dbccff6f8412811d89a6f6aa44828ca9422a0a469625ce023bf81cee68f52930dbedf9c5716056ff264ac886612702d134b5e39b4 + languageName: node + linkType: hard + "duplexer@npm:^0.1.1, duplexer@npm:^0.1.2": version: 0.1.2 resolution: "duplexer@npm:0.1.2" @@ -17522,6 +17542,18 @@ __metadata: languageName: node linkType: hard +"fdir@npm:^6.4.2": + version: 6.4.3 + resolution: "fdir@npm:6.4.3" + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + checksum: d13c10120e9625adf21d8d80481586200759928c19405a816b77dd28eaeb80e7c59c5def3e2941508045eb06d34eb47fad865ccc8bf98e6ab988bb0ed160fb6f + languageName: node + linkType: hard + "fecha@npm:^4.2.0": version: 4.2.1 resolution: "fecha@npm:4.2.1" @@ -18532,7 +18564,7 @@ __metadata: languageName: node linkType: hard -"graceful-fs@npm:^4.1.11, graceful-fs@npm:^4.1.15, graceful-fs@npm:^4.1.2, graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.11, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.9, graceful-fs@npm:~4.2.9": +"graceful-fs@npm:^4.1.11, graceful-fs@npm:^4.1.15, graceful-fs@npm:^4.1.2, graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.11, graceful-fs@npm:^4.2.2, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.9, graceful-fs@npm:~4.2.9": version: 4.2.11 resolution: "graceful-fs@npm:4.2.11" checksum: 386d011a553e02bc594ac2ca0bd6d9e4c22d7fa8cfbfc448a6d148c59ea881b092db9dbe3547ae4b88e55f1b01f7c4a2ecc53b310c042793e63aa44cf6c257f2 @@ -19931,15 +19963,6 @@ __metadata: languageName: node linkType: hard -"is-core-module@npm:2.9.0": - version: 2.9.0 - resolution: "is-core-module@npm:2.9.0" - dependencies: - has: ^1.0.3 - checksum: 056fe4c5f9f383dc1c1b0dc3250c300880b9b1e17e1885077d64a1667926ecc11ba696776597616bfd2fd7f87c7476c01b127a0c842b4821bee2414d0e296e6e - languageName: node - linkType: hard - "is-core-module@npm:^2.1.0, is-core-module@npm:^2.11.0, is-core-module@npm:^2.12.0, is-core-module@npm:^2.2.0, is-core-module@npm:^2.5.0, is-core-module@npm:^2.8.1": version: 2.12.0 resolution: "is-core-module@npm:2.12.0" @@ -23225,10 +23248,10 @@ __metadata: languageName: node linkType: hard -"napi-build-utils@npm:^1.0.1": - version: 1.0.2 - resolution: "napi-build-utils@npm:1.0.2" - checksum: 37fd2cd0ff2ad20073ce78d83fd718a740d568b225924e753ae51cb69d68f330c80544d487e5e5bd18e28702ed2ca469c2424ad948becd1862c1b0209542b2e9 +"napi-build-utils@npm:^2.0.0": + version: 2.0.0 + resolution: "napi-build-utils@npm:2.0.0" + checksum: 5833aaeb5cc5c173da47a102efa4680a95842c13e0d9cc70428bd3ee8d96bb2172f8860d2811799b5daa5cbeda779933601492a2028a6a5351c6d0fcf6de83db languageName: node linkType: hard @@ -24826,10 +24849,10 @@ __metadata: languageName: node linkType: hard -"picocolors@npm:^1.0.0, picocolors@npm:^1.0.1": - version: 1.0.1 - resolution: "picocolors@npm:1.0.1" - checksum: c63cdad2bf812ef0d66c8db29583802355d4ca67b9285d846f390cc15c2f6ccb94e8cb7eb6a6e97fc5990a6d3ad4ae42d86c84d3146e667c739a4234ed50d400 +"picocolors@npm:^1.0.0, picocolors@npm:^1.0.1, picocolors@npm:^1.1.0": + version: 1.1.1 + resolution: "picocolors@npm:1.1.1" + checksum: e2e3e8170ab9d7c7421969adaa7e1b31434f789afb9b3f115f6b96d91945041ac3ceb02e9ec6fe6510ff036bcc0bf91e69a1772edc0b707e12b19c0f2d6bcf58 languageName: node linkType: hard @@ -24840,6 +24863,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^4.0.2": + version: 4.0.2 + resolution: "picomatch@npm:4.0.2" + checksum: 7c51f3ad2bb42c776f49ebf964c644958158be30d0a510efd5a395e8d49cb5acfed5b82c0c5b365523ce18e6ab85013c9ebe574f60305892ec3fa8eee8304ccc + languageName: node + linkType: hard + "pify@npm:5.0.0, pify@npm:^5.0.0": version: 5.0.0 resolution: "pify@npm:5.0.0" @@ -24884,24 +24914,6 @@ __metadata: languageName: node linkType: hard -"pkg-fetch@npm:^3.5.2": - version: 3.5.2 - resolution: "pkg-fetch@npm:3.5.2" - dependencies: - chalk: ^4.1.2 - fs-extra: ^9.1.0 - https-proxy-agent: ^5.0.0 - node-fetch: ^2.6.6 - progress: ^2.0.3 - semver: ^7.3.5 - tar-fs: ^2.1.1 - yargs: ^16.2.0 - bin: - pkg-fetch: lib-es5/bin.js - checksum: 8105cf28178e0b325417a9dee6ec0f0f124ba7fe3608d8ad86628ef2f2a12d1490550a007d5be42e34f0c8573dcb9655737b4d07a177ce4ee278e762ccb42b9e - languageName: node - linkType: hard - "pkg-up@npm:^3.1.0": version: 3.1.0 resolution: "pkg-up@npm:3.1.0" @@ -24911,35 +24923,6 @@ __metadata: languageName: node linkType: hard -"pkg@npm:^5.8.1": - version: 5.8.1 - resolution: "pkg@npm:5.8.1" - dependencies: - "@babel/generator": 7.18.2 - "@babel/parser": 7.18.4 - "@babel/types": 7.19.0 - chalk: ^4.1.2 - fs-extra: ^9.1.0 - globby: ^11.1.0 - into-stream: ^6.0.0 - is-core-module: 2.9.0 - minimist: ^1.2.6 - multistream: ^4.1.0 - pkg-fetch: 3.4.2 - prebuild-install: 7.1.1 - resolve: ^1.22.0 - stream-meter: ^1.0.4 - peerDependencies: - node-notifier: ">=9.0.1" - peerDependenciesMeta: - node-notifier: - optional: true - bin: - pkg: lib-es5/bin.js - checksum: cd8498674d47ab4776e8938beb9c483820ae644964b3dfb0a3b5d2aa5c58752bd766a19422cfce933984638a3405c0e557554102af7f6b96cfb49f2b928b13a3 - languageName: node - linkType: hard - "plist@npm:^3.0.5": version: 3.0.5 resolution: "plist@npm:3.0.5" @@ -25798,16 +25781,16 @@ __metadata: languageName: node linkType: hard -"prebuild-install@npm:7.1.1": - version: 7.1.1 - resolution: "prebuild-install@npm:7.1.1" +"prebuild-install@npm:^7.1.1": + version: 7.1.3 + resolution: "prebuild-install@npm:7.1.3" dependencies: detect-libc: ^2.0.0 expand-template: ^2.0.3 github-from-package: 0.0.0 minimist: ^1.2.3 mkdirp-classic: ^0.5.3 - napi-build-utils: ^1.0.1 + napi-build-utils: ^2.0.0 node-abi: ^3.3.0 pump: ^3.0.0 rc: ^1.2.7 @@ -25816,7 +25799,7 @@ __metadata: tunnel-agent: ^0.6.0 bin: prebuild-install: bin.js - checksum: 6dc70f36b0f4adcb2fe0ed38d874ab28b571fb1a9725d769e8ba3f64a15831e58462de09f3e6e64569bcc4a3e03b9328b56faa0d45fe10ae1574478814536c76 + checksum: 25919a42b52734606a4036ab492d37cfe8b601273d8dfb1fa3c84e141a0a475e7bad3ab848c741d2f810cef892fcf6059b8c7fe5b29f98d30e0c29ad009bedff languageName: node linkType: hard @@ -26643,9 +26626,9 @@ __metadata: languageName: node linkType: hard -"readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.1, readable-stream@npm:^2.0.5, readable-stream@npm:^2.1.4, readable-stream@npm:~2.3.6": - version: 2.3.7 - resolution: "readable-stream@npm:2.3.7" +"readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.1, readable-stream@npm:^2.0.2, readable-stream@npm:^2.0.5, readable-stream@npm:^2.1.4, readable-stream@npm:~2.3.6": + version: 2.3.8 + resolution: "readable-stream@npm:2.3.8" dependencies: core-util-is: ~1.0.0 inherits: ~2.0.3 @@ -26654,7 +26637,7 @@ __metadata: safe-buffer: ~5.1.1 string_decoder: ~1.1.1 util-deprecate: ~1.0.1 - checksum: 1708755e6cf9daff6ff60fa5b4575636472289c5b95d38058a91f94732b8d024a940a0d4d955639195ce42c22cab16973ee8fea8deedd24b5fec3dd596465f86 + checksum: 7efdb01f3853bc35ac62ea25493567bf588773213f5f4a79f9c365e1ad13bab845ac0dae7bc946270dc40c3929483228415e92a3fc600cc7e4548992f41ee3fa languageName: node linkType: hard @@ -29091,6 +29074,16 @@ __metadata: languageName: node linkType: hard +"tinyglobby@npm:^0.2.9": + version: 0.2.10 + resolution: "tinyglobby@npm:0.2.10" + dependencies: + fdir: ^6.4.2 + picomatch: ^4.0.2 + checksum: ce946135d39b8c0e394e488ad59f4092e8c4ecd675ef1bcd4585c47de1b325e61ec6adfbfbe20c3c2bfa6fd674c5b06de2a2e65c433f752ae170aff11793e5ef + languageName: node + linkType: hard + "title-case@npm:^3.0.3": version: 3.0.3 resolution: "title-case@npm:3.0.3" @@ -29924,6 +29917,19 @@ __metadata: languageName: node linkType: hard +"unzipper@npm:^0.12.3": + version: 0.12.3 + resolution: "unzipper@npm:0.12.3" + dependencies: + bluebird: ~3.7.2 + duplexer2: ~0.1.4 + fs-extra: ^11.2.0 + graceful-fs: ^4.2.2 + node-int64: ^0.4.0 + checksum: 4cae2ad23bfd47011d5f8a6d61fb1dc0e4b5008bc3896e6f3d5ab946a64e9482714992a988128bce541440aa646e16e5e5c9bf35e49097edbaf833e7f814d36d + languageName: node + linkType: hard + "upath@npm:2.0.1, upath@npm:^2.0.1": version: 2.0.1 resolution: "upath@npm:2.0.1"