From 8f2ede1045f09f7ab5d21d0bc91eb6eee6455761 Mon Sep 17 00:00:00 2001 From: Sanay Yogesh Shah Date: Wed, 23 Oct 2024 14:35:10 -0700 Subject: [PATCH 1/6] feat: templategen command e2e integration tests --- packages/amplify-migration-e2e/package.json | 1 + .../migration_templategen_e2e.test.ts | 50 ++ .../amplify-migration-e2e/src/assertions.ts | 20 +- .../amplify-migration-e2e/src/envVariables.ts | 9 + .../src/gen1ResourceDetailsFetcher.ts | 42 ++ .../src/gen2ResourceDetailsFetcher.ts | 37 ++ packages/amplify-migration-e2e/src/index.ts | 36 +- .../src/migrationReadmeParser.ts | 35 + packages/amplify-migration-e2e/src/sandbox.ts | 34 + .../amplify-migration-e2e/src/sdk_calls.ts | 12 + .../amplify-migration-e2e/src/templategen.ts | 143 ++++ .../src/updatePackageJson.ts | 2 +- yarn.lock | 623 ++++++++++++++++++ 13 files changed, 1005 insertions(+), 39 deletions(-) create mode 100644 packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts create mode 100644 packages/amplify-migration-e2e/src/envVariables.ts create mode 100644 packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts create mode 100644 packages/amplify-migration-e2e/src/gen2ResourceDetailsFetcher.ts create mode 100644 packages/amplify-migration-e2e/src/migrationReadmeParser.ts create mode 100644 packages/amplify-migration-e2e/src/sandbox.ts create mode 100644 packages/amplify-migration-e2e/src/templategen.ts diff --git a/packages/amplify-migration-e2e/package.json b/packages/amplify-migration-e2e/package.json index 7cff04e927..63c2a192b0 100644 --- a/packages/amplify-migration-e2e/package.json +++ b/packages/amplify-migration-e2e/package.json @@ -10,6 +10,7 @@ "@aws-sdk/client-appsync": "^3.666.0", "@aws-sdk/client-cloudcontrol": "^3.658.1", "@aws-sdk/client-cognito-identity": "^3.670.0", + "@aws-sdk/client-s3": "^3.674.0", "execa": "^5.1.1", "fs-extra": "^8.1.0", "lodash": "^4.17.21" diff --git a/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts b/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts new file mode 100644 index 0000000000..d0a1a1ddc0 --- /dev/null +++ b/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts @@ -0,0 +1,50 @@ +import path from 'node:path'; +import assert from 'node:assert'; +import { createNewProjectDir, npmInstall, deleteS3Bucket } from '@aws-amplify/amplify-e2e-core'; +import { assertDefaultGen1Setup } from '../assertions'; +import { setupAndPushDefaultGen1Project, runCodegenCommand, runGen2SandboxCommand, cleanupProjects } from '..'; +import { copyFunctionFile } from '../function_utils'; +import { copyGen1Schema } from '../api_utils'; +import { updatePackageDependency } from '../updatePackageJson'; +import { createS3Bucket } from '../sdk_calls'; +import { runTemplategenCommand, stackRefactor } from '../templategen'; + +void describe('Templategen E2E tests', () => { + void describe('Full Migration Templategen Flow', () => { + let projRoot: string; + let projName: string; + let bucketName: string; + + beforeEach(async () => { + const baseDir = process.env.INIT_CWD ?? process.cwd(); + projRoot = await createNewProjectDir('templategen_e2e_flow_test', path.join(baseDir, '..', '..')); + projName = `test${Math.floor(Math.random() * 1000000)}`; + bucketName = `testbucket${Math.floor(Math.random() * 1000000)}`; + }); + + afterEach(async () => { + await cleanupProjects(projRoot); + await deleteS3Bucket(bucketName); + }); + + void it('should init a project & add auth, function, storage, api with defaults & perform full migration templategen flow', async () => { + await setupAndPushDefaultGen1Project(projRoot, projName); + const { gen1StackName, gen1FunctionName, gen1Region } = await assertDefaultGen1Setup(projRoot); + await createS3Bucket(bucketName, gen1Region); + assert(gen1StackName); + await runCodegenCommand(projRoot); + await copyFunctionFile(projRoot, 'function', gen1FunctionName); + await copyGen1Schema(projRoot, projName); + + // TODO: replace below line with correct package version + await updatePackageDependency(projRoot, '@aws-amplify/backend'); + + await npmInstall(projRoot); + const gen2StackName = await runGen2SandboxCommand(projRoot); + assert(gen2StackName); + await runTemplategenCommand(projRoot, gen1StackName, gen2StackName); + // await stackRefactor(projRoot, 'auth', bucketName); + await stackRefactor(projRoot, 'storage', bucketName); + }); + }); +}); diff --git a/packages/amplify-migration-e2e/src/assertions.ts b/packages/amplify-migration-e2e/src/assertions.ts index 06d91c0b1f..2e2397b989 100644 --- a/packages/amplify-migration-e2e/src/assertions.ts +++ b/packages/amplify-migration-e2e/src/assertions.ts @@ -13,14 +13,14 @@ import { removeProperties } from '.'; import { $TSAny } from '@aws-amplify/amplify-cli-core'; import assert from 'node:assert'; -async function assertUserPool(gen1Meta: $TSAny, gen1Region: string) { +export async function assertUserPool(gen1Meta: $TSAny, gen1Region: string) { const { UserPoolId: gen1UserPoolId } = Object.keys(gen1Meta.auth).map((key) => gen1Meta.auth[key])[0].output; const cloudUserPool = await getUserPool(gen1UserPoolId, gen1Region); expect(cloudUserPool.UserPool).toBeDefined(); return { gen1UserPoolId }; } -async function assertUserPoolClients(gen1Meta: $TSAny, gen1Region: string) { +export async function assertUserPoolClients(gen1Meta: $TSAny, gen1Region: string) { const { UserPoolId: userPoolId, AppClientIDWeb: appClientIdWeb, @@ -32,7 +32,7 @@ async function assertUserPoolClients(gen1Meta: $TSAny, gen1Region: string) { return { gen1ClientIds }; } -async function assertIdentityPool(gen1Meta: $TSAny, gen1Region: string) { +export async function assertIdentityPool(gen1Meta: $TSAny, gen1Region: string) { const { IdentityPoolId: gen1IdentityPoolId } = Object.keys(gen1Meta.auth).map((key) => gen1Meta.auth[key])[0].output; const cloudIdentityPool = await getIdentityPool(gen1IdentityPoolId, gen1Region); expect(cloudIdentityPool).toBeDefined(); @@ -48,7 +48,7 @@ async function assertFunction(gen1Meta: $TSAny, gen1Region: string) { return { gen1FunctionName }; } -async function assertStorage(gen1Meta: $TSAny, gen1Region: string) { +export async function assertStorage(gen1Meta: $TSAny, gen1Region: string) { const { BucketName: gen1BucketName } = Object.keys(gen1Meta.storage).map((key) => gen1Meta.storage[key])[0].output; expect(gen1BucketName).toBeDefined(); const bucketExists = await checkIfBucketExists(gen1BucketName, gen1Region); @@ -88,6 +88,7 @@ async function assertUserPoolGroups(gen1Meta: $TSAny) { export async function assertDefaultGen1Setup(projRoot: string) { const gen1Meta = getProjectMeta(projRoot); + const gen1StackName = gen1Meta.providers.awscloudformation.StackName; const gen1Region = gen1Meta.providers.awscloudformation.Region; const { gen1UserPoolId } = await assertUserPool(gen1Meta, gen1Region); const { gen1FunctionName } = await assertFunction(gen1Meta, gen1Region); @@ -96,7 +97,16 @@ export async function assertDefaultGen1Setup(projRoot: string) { const { gen1GraphqlApiId } = await assertAPI(gen1Meta, gen1Region); const { gen1IdentityPoolId } = await assertIdentityPool(gen1Meta, gen1Region); const { gen1ClientIds } = await assertUserPoolClients(gen1Meta, gen1Region); - return { gen1UserPoolId, gen1ClientIds, gen1IdentityPoolId, gen1FunctionName, gen1BucketName, gen1GraphqlApiId, gen1Region }; + return { + gen1StackName, + gen1UserPoolId, + gen1ClientIds, + gen1IdentityPoolId, + gen1FunctionName, + gen1BucketName, + gen1GraphqlApiId, + gen1Region, + }; } export async function assertAuthWithMaxOptionsGen1Setup(projRoot: string) { diff --git a/packages/amplify-migration-e2e/src/envVariables.ts b/packages/amplify-migration-e2e/src/envVariables.ts new file mode 100644 index 0000000000..64680b1314 --- /dev/null +++ b/packages/amplify-migration-e2e/src/envVariables.ts @@ -0,0 +1,9 @@ +type EnvVariableAction = 'SET' | 'DELETE'; + +export function toggleEnvVariable(name: string, option: EnvVariableAction, value?: string) { + if (option === 'SET') { + process.env[name] = value; + } else if (option === 'DELETE') { + delete process.env[name]; + } +} diff --git a/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts b/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts new file mode 100644 index 0000000000..b1d9cbb77a --- /dev/null +++ b/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts @@ -0,0 +1,42 @@ +import path from 'path'; +import { RefactorCategory } from './templategen'; +import { getProjectMeta } from '@aws-amplify/amplify-e2e-core'; +import { assertIdentityPool, assertStorage, assertUserPool, assertUserPoolClients } from './assertions'; +import { getResourceDetails } from './sdk_calls'; + +async function getGen1AuthResourceDetails(projRoot: string) { + const gen1ProjRoot = path.join(projRoot, '.amplify', 'migration'); + const gen1Meta = getProjectMeta(gen1ProjRoot); + const gen1Region = gen1Meta.providers.awscloudformation.Region; + const { gen1UserPoolId } = await assertUserPool(gen1Meta, gen1Region); + const { gen1IdentityPoolId } = await assertIdentityPool(gen1Meta, gen1Region); + const { gen1ClientIds } = await assertUserPoolClients(gen1Meta, gen1Region); + const [gen1ClientIdWeb, gen1ClientId] = gen1ClientIds; + const gen1ResourceIds = [gen1UserPoolId, gen1IdentityPoolId, gen1ClientIdWeb]; + + const gen1ResourceDetails = await Promise.all([ + getResourceDetails('AWS::Cognito::UserPool', gen1UserPoolId, gen1Region), + getResourceDetails('AWS::Cognito::IdentityPool', gen1IdentityPoolId, gen1Region), + getResourceDetails('AWS::Cognito::UserPoolClient', `${gen1UserPoolId}|${gen1ClientIdWeb}`, gen1Region), + ]); + + return { gen1ResourceIds, gen1ResourceDetails }; +} + +async function getGen1StorageResourceDetails(projRoot: string) { + const gen1ProjRoot = path.join(projRoot, '.amplify', 'migration'); + const gen1Meta = getProjectMeta(gen1ProjRoot); + const gen1Region = gen1Meta.providers.awscloudformation.Region; + const { gen1BucketName } = await assertStorage(gen1Meta, gen1Region); + const gen1ResourceIds = [gen1BucketName]; + const gen1ResourceDetails = await getResourceDetails('AWS::S3::Bucket', gen1BucketName, gen1Region); + return { gen1ResourceIds, gen1ResourceDetails }; +} + +export async function getGen1ResourceDetails(projRoot: string, category: RefactorCategory) { + if (category === 'auth') { + return await getGen1AuthResourceDetails(projRoot); + } else { + return await getGen1StorageResourceDetails(projRoot); + } +} diff --git a/packages/amplify-migration-e2e/src/gen2ResourceDetailsFetcher.ts b/packages/amplify-migration-e2e/src/gen2ResourceDetailsFetcher.ts new file mode 100644 index 0000000000..3bddf9998b --- /dev/null +++ b/packages/amplify-migration-e2e/src/gen2ResourceDetailsFetcher.ts @@ -0,0 +1,37 @@ +import { getProjectOutputs } from './projectOutputs'; +import { getResourceDetails } from './sdk_calls'; +import { RefactorCategory } from './templategen'; + +async function getGen2AuthResourceDetails(projRoot: string) { + const gen2Meta = getProjectOutputs(projRoot); + const gen2Region = gen2Meta.auth.aws_region; + const gen2UserPoolId = gen2Meta.auth.user_pool_id; + const gen2ClientIdWeb = gen2Meta.auth.user_pool_client_id; + const gen2IdentityPoolId = gen2Meta.auth.identity_pool_id; + const gen2ResourceIds = [gen2UserPoolId, gen2IdentityPoolId, gen2ClientIdWeb]; + + const gen2ResourceDetails = await Promise.all([ + getResourceDetails('AWS::Cognito::UserPool', gen2UserPoolId, gen2Region), + getResourceDetails('AWS::Cognito::IdentityPool', gen2IdentityPoolId, gen2Region), + getResourceDetails('AWS::Cognito::UserPoolClient', `${gen2UserPoolId}|${gen2ClientIdWeb}`, gen2Region), + ]); + + return { gen2ResourceIds, gen2ResourceDetails }; +} + +async function getGen2StorageResourceDetails(projRoot: string) { + const gen2Meta = getProjectOutputs(projRoot); + const gen2Region = gen2Meta.auth.aws_region; + const gen2BucketName = gen2Meta.storage.bucket_name; + const gen2ResourceIds = [gen2BucketName]; + const gen2ResourceDetails = await getResourceDetails('AWS::S3::Bucket', gen2BucketName, gen2Region); + return { gen2ResourceIds, gen2ResourceDetails }; +} + +export async function getGen2ResourceDetails(projRoot: string, category: RefactorCategory) { + if (category === 'auth') { + return await getGen2AuthResourceDetails(projRoot); + } else { + return await getGen2StorageResourceDetails(projRoot); + } +} diff --git a/packages/amplify-migration-e2e/src/index.ts b/packages/amplify-migration-e2e/src/index.ts index 66a8c05e4e..2fd345ffda 100644 --- a/packages/amplify-migration-e2e/src/index.ts +++ b/packages/amplify-migration-e2e/src/index.ts @@ -5,7 +5,6 @@ import { addAuthWithDefault, amplifyPush, getNpxPath, - nspawn as spawn, addS3WithGuestAccess, addFunction, functionBuild, @@ -22,13 +21,15 @@ import { import path from 'node:path'; import { unset } from 'lodash'; import execa from 'execa'; +import { deleteGen2Sandbox } from './sandbox'; export * from './sdk_calls'; export * from './assertions'; export * from './projectOutputs'; export * from './updatePackageJson'; +export * from './sandbox'; -const pushTimeoutMS = 1000 * 60 * 20; // 20 minutes; +export const pushTimeoutMS = 1000 * 60 * 20; // 20 minutes; export async function setupAndPushDefaultGen1Project(projRoot: string, projName: string) { await initJSProjectWithProfile(projRoot, { name: projName, disableAmplifyAppCreation: false, includeGen2RecommendationPrompt: false }); @@ -75,37 +76,6 @@ export function runCodegenCommand(cwd: string) { } } -export async function runGen2SandboxCommand(cwd: string) { - const processResult = execa.sync(getNpxPath(), ['ampx', 'sandbox', '--once'], { - cwd, - env: { ...process.env, npm_config_user_agent: 'npm' }, - encoding: 'utf-8', - }); - if (processResult.exitCode === 0) { - const match = processResult.stdout.match(/arn:aws:cloudformation:.*:stack\/([^/]+)\//); - if (match) { - return match[1]; - } else { - throw new Error('Stack name not found in the command output'); - } - } else { - throw new Error(`Sandbox command exit code: ${processResult.exitCode}, message: ${processResult.stderr}`); - } -} - -function deleteGen2Sandbox(cwd: string) { - return spawn(getNpxPath(), ['ampx', 'sandbox', 'delete'], { - cwd, - stripColors: true, - noOutputTimeout: pushTimeoutMS, - env: { ...process.env, npm_config_user_agent: 'npm' }, - }) - .wait("Are you sure you want to delete all the resources in your sandbox environment (This can't be undone)?") - .sendConfirmYes() - .wait('Finished deleting.') - .runAsync(); -} - export async function cleanupProjects(cwd: string) { await deleteGen1Project(path.join(cwd, '.amplify', 'migration')); await deleteGen2Sandbox(cwd); diff --git a/packages/amplify-migration-e2e/src/migrationReadmeParser.ts b/packages/amplify-migration-e2e/src/migrationReadmeParser.ts new file mode 100644 index 0000000000..91277e9988 --- /dev/null +++ b/packages/amplify-migration-e2e/src/migrationReadmeParser.ts @@ -0,0 +1,35 @@ +function extractContent(readmeContent: string, startRegex: string, endRegex: string) { + const pattern = new RegExp(`${startRegex}([\\s\\S]*?)${endRegex}`, 'i'); + const match = readmeContent.match(pattern); + + if (match && match[1]) { + return match[1].trim(); + } + throw new Error('README file parsing failed to get the stack refactor commands'); +} + +function extractCommands(readmeContent: string) { + const pattern = /```([\s\S]*?)```/g; + const matches = readmeContent.matchAll(pattern); + const commands = []; + + for (const match of matches) { + if (match[1]) { + commands.push(match[1].trim()); + } + } + if (commands.length === 0) { + throw new Error('README file parsing failed to get the stack refactor commands'); + } + return commands; +} + +export function getCommandsFromReadme(readmeContent: string) { + const step1Content = extractContent(readmeContent, '### STEP 1', '#### Rollback step'); + const step2Content = extractContent(readmeContent, '### STEP 2', '#### Rollback step'); + const step3Content = extractContent(readmeContent, '### STEP 3', '#### Rollback step'); + const step1Commands = extractCommands(step1Content); + const step2commands = extractCommands(step2Content); + const step3Commands = extractCommands(step3Content); + return { step1Commands, step2commands, step3Commands }; +} diff --git a/packages/amplify-migration-e2e/src/sandbox.ts b/packages/amplify-migration-e2e/src/sandbox.ts new file mode 100644 index 0000000000..02e58b2b9e --- /dev/null +++ b/packages/amplify-migration-e2e/src/sandbox.ts @@ -0,0 +1,34 @@ +import { getNpxPath, nspawn as spawn } from '@aws-amplify/amplify-e2e-core'; +import { pushTimeoutMS } from '.'; +import execa from 'execa'; + +export async function runGen2SandboxCommand(cwd: string) { + const processResult = execa.sync(getNpxPath(), ['ampx', 'sandbox', '--once'], { + cwd, + env: { ...process.env, npm_config_user_agent: 'npm' }, + encoding: 'utf-8', + }); + if (processResult.exitCode === 0) { + const match = processResult.stdout.match(/arn:aws:cloudformation:.*:stack\/([^/]+)\//); + if (match) { + return match[1]; + } else { + throw new Error('Stack name not found in the command output'); + } + } else { + throw new Error(`Sandbox command exit code: ${processResult.exitCode}, message: ${processResult.stderr}`); + } +} + +export function deleteGen2Sandbox(cwd: string) { + return spawn(getNpxPath(), ['ampx', 'sandbox', 'delete'], { + cwd, + stripColors: true, + noOutputTimeout: pushTimeoutMS, + env: { ...process.env, npm_config_user_agent: 'npm' }, + }) + .wait("Are you sure you want to delete all the resources in your sandbox environment (This can't be undone)?") + .sendConfirmYes() + .wait('Finished deleting.') + .runAsync(); +} diff --git a/packages/amplify-migration-e2e/src/sdk_calls.ts b/packages/amplify-migration-e2e/src/sdk_calls.ts index 5b87e70639..d1d1712e29 100644 --- a/packages/amplify-migration-e2e/src/sdk_calls.ts +++ b/packages/amplify-migration-e2e/src/sdk_calls.ts @@ -1,7 +1,19 @@ import { CloudControlClient, GetResourceCommand } from '@aws-sdk/client-cloudcontrol'; import { AppSyncClient, GetDataSourceCommand } from '@aws-sdk/client-appsync'; import { CognitoIdentityClient, DescribeIdentityPoolCommand } from '@aws-sdk/client-cognito-identity'; +import { S3Client, CreateBucketCommand, BucketLocationConstraint } from '@aws-sdk/client-s3'; +export async function createS3Bucket(bucketName: string, region: string) { + const client = new S3Client({ region }); + const command = new CreateBucketCommand({ + Bucket: bucketName, + CreateBucketConfiguration: { + LocationConstraint: region as BucketLocationConstraint, + }, + }); + const response = await client.send(command); + return response; +} export async function getAppSyncDataSource(apiId: string, dataSourceName: string, region: string) { const client = new AppSyncClient({ region }); const command = new GetDataSourceCommand({ diff --git a/packages/amplify-migration-e2e/src/templategen.ts b/packages/amplify-migration-e2e/src/templategen.ts new file mode 100644 index 0000000000..751bbc9626 --- /dev/null +++ b/packages/amplify-migration-e2e/src/templategen.ts @@ -0,0 +1,143 @@ +import assert from 'node:assert'; +import execa from 'execa'; +import path from 'node:path'; +import * as fs from 'fs-extra'; +import { getNpxPath, retry, RetrySettings } from '@aws-amplify/amplify-e2e-core'; +import { runGen2SandboxCommand } from './sandbox'; +import { getCommandsFromReadme } from './migrationReadmeParser'; +import { toggleEnvVariable } from './envVariables'; +import { getGen1ResourceDetails } from './gen1ResourceDetailsFetcher'; +import { getGen2ResourceDetails } from './gen2ResourceDetailsFetcher'; + +export type RefactorCategory = 'auth' | 'storage'; + +const RETRY_CONFIG: RetrySettings = { + times: 50, + delayMS: 1000, // 1 second + timeoutMS: 1000 * 60 * 5, // 5 minutes + stopOnError: true, +}; + +const STATUS_COMPLETE = 'COMPLETE'; +const STATUS_IN_PROGRESS = 'IN_PROGRESS'; +const STATUS_FAILED = 'FAILED'; + +export function runTemplategenCommand(cwd: string, gen1StackName: string, gen2StackName: string) { + const parentDir = path.resolve(cwd, '..'); + const processResult = execa.sync( + getNpxPath(), + ['--prefix', parentDir, '@aws-amplify/migrate', 'to-gen-2', 'generate-templates', '--from', gen1StackName, '--to', gen2StackName], + { + cwd, + env: { ...process.env, npm_config_user_agent: 'npm' }, + encoding: 'utf-8', + }, + ); + + if (processResult.exitCode !== 0) { + throw new Error(`Templategen command exit code: ${processResult.exitCode}, message: ${processResult.stderr}`); + } +} + +function uncommentS3BucketLineFromBackendFile(projRoot: string) { + const backendFilePath = path.join(projRoot, 'amplify', 'backend.ts'); + const backendFileContent = fs.readFileSync(backendFilePath, 'utf8'); + const regex = /^\s*\/\/\s*(s3Bucket\.bucketName)/m; + const updatedBackendFileContent = backendFileContent.replace(regex, '$1'); + fs.writeFileSync(backendFilePath, updatedBackendFileContent); +} + +async function executeCommand(command: string, cwd?: string) { + cwd = cwd ?? process.cwd(); + const processResult = execa.sync(command, { + cwd, + env: { ...process.env, npm_config_user_agent: 'npm' }, + encoding: 'utf-8', + shell: true, + }); + if (processResult.exitCode === 0) { + return processResult.stdout; + } else { + throw new Error(`Command exit code: ${processResult.exitCode}, message: ${processResult.stderr}`); + } +} + +async function executeCreateStackRefactorCallCommand(command: string, cwd: string) { + const processResult = JSON.parse(await executeCommand(command, cwd)); + const stackRefactorId = processResult.StackRefactorId; + return stackRefactorId; +} + +async function executeStep1(cwd: string, commands: string[]) { + await executeCommand(commands[0], cwd); + await retry( + () => assertStepCompletion(commands[1]), + (status) => status.includes(STATUS_COMPLETE) && !status.includes(STATUS_IN_PROGRESS), + RETRY_CONFIG, + (status) => status.includes(STATUS_FAILED), + ); +} + +async function executeStep2(cwd: string, commands: string[]) { + await executeCommand(commands[0], cwd); + await retry( + () => assertStepCompletion(commands[1]), + (status) => status.includes(STATUS_COMPLETE) && !status.includes(STATUS_IN_PROGRESS), + RETRY_CONFIG, + (status) => status.includes(STATUS_FAILED), + ); +} + +async function executeStep3(cwd: string, commands: string[], bucketName: string) { + toggleEnvVariable('BUCKET_NAME', 'SET', bucketName); + await executeCommand(commands[1], cwd); + await executeCommand(commands[2], cwd); + const stackRefactorId = await executeCreateStackRefactorCallCommand(commands[3], cwd); + toggleEnvVariable('STACK_REFACTOR_ID', 'SET', stackRefactorId); + await retry( + () => assertRefactorStepCompletion(commands[5]), + (status) => status.includes(STATUS_COMPLETE) && !status.includes(STATUS_IN_PROGRESS), + RETRY_CONFIG, + (status) => status.includes(STATUS_FAILED), + ); + await executeCommand(commands[6], cwd); + await retry( + () => assertRefactorStepCompletion(commands[7]), + (status) => status.includes(STATUS_COMPLETE) && !status.includes(STATUS_IN_PROGRESS), + RETRY_CONFIG, + (status) => status.includes(STATUS_FAILED), + ); +} + +async function assertStepCompletion(command: string) { + const processResult = JSON.parse(await executeCommand(command)); + return processResult.Stacks[0].StackStatus; +} + +async function assertRefactorStepCompletion(command: string) { + const processResult = JSON.parse(await executeCommand(command)); + return processResult.Status; +} + +export async function stackRefactor(projRoot: string, category: RefactorCategory, bucketName: string) { + const { gen1ResourceIds, gen1ResourceDetails } = await getGen1ResourceDetails(projRoot, category); + + const readmeFilePath = path.join(projRoot, '.amplify', 'migration', 'templates', category, 'MIGRATION_README.md'); + const readmeContent = fs.readFileSync(readmeFilePath, 'utf-8'); + const { step1Commands, step2commands, step3Commands } = getCommandsFromReadme(readmeContent); + + await executeStep1(projRoot, step1Commands); + await executeStep2(projRoot, step2commands); + await executeStep3(projRoot, step3Commands, bucketName); + + if (category === 'storage') await uncommentS3BucketLineFromBackendFile(projRoot); + + await runGen2SandboxCommand(projRoot); + + toggleEnvVariable('BUCKET_NAME', 'DELETE'); + toggleEnvVariable('STACK_REFACTOR_ID', 'DELETE'); + + const { gen2ResourceIds, gen2ResourceDetails } = await getGen2ResourceDetails(projRoot, category); + assert.deepEqual(gen1ResourceIds, gen2ResourceIds); + assert.deepEqual(gen1ResourceDetails, gen2ResourceDetails); +} diff --git a/packages/amplify-migration-e2e/src/updatePackageJson.ts b/packages/amplify-migration-e2e/src/updatePackageJson.ts index 930a9cac6c..84d85013a5 100644 --- a/packages/amplify-migration-e2e/src/updatePackageJson.ts +++ b/packages/amplify-migration-e2e/src/updatePackageJson.ts @@ -2,7 +2,7 @@ import { readJsonFile } from '@aws-amplify/amplify-e2e-core'; import * as fs from 'fs-extra'; import path from 'node:path'; -export function updatePackageDependency(cwd: string, dependencyName: string, version: string) { +export function updatePackageDependency(cwd: string, dependencyName: string, version = '0.0.0-test-20241018150827') { const packageJsonPath = path.join(cwd, 'package.json'); const packageJson = readJsonFile(packageJsonPath); diff --git a/yarn.lock b/yarn.lock index 0921ecd167..13cb3bdbad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -841,6 +841,7 @@ __metadata: "@aws-sdk/client-appsync": ^3.666.0 "@aws-sdk/client-cloudcontrol": ^3.658.1 "@aws-sdk/client-cognito-identity": ^3.670.0 + "@aws-sdk/client-s3": ^3.674.0 execa: ^5.1.1 fs-extra: ^8.1.0 jest: ^29.5.0 @@ -3597,6 +3598,72 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/client-s3@npm:^3.674.0": + version: 3.677.0 + resolution: "@aws-sdk/client-s3@npm:3.677.0" + dependencies: + "@aws-crypto/sha1-browser": 5.2.0 + "@aws-crypto/sha256-browser": 5.2.0 + "@aws-crypto/sha256-js": 5.2.0 + "@aws-sdk/client-sso-oidc": 3.677.0 + "@aws-sdk/client-sts": 3.677.0 + "@aws-sdk/core": 3.677.0 + "@aws-sdk/credential-provider-node": 3.677.0 + "@aws-sdk/middleware-bucket-endpoint": 3.667.0 + "@aws-sdk/middleware-expect-continue": 3.667.0 + "@aws-sdk/middleware-flexible-checksums": 3.677.0 + "@aws-sdk/middleware-host-header": 3.667.0 + "@aws-sdk/middleware-location-constraint": 3.667.0 + "@aws-sdk/middleware-logger": 3.667.0 + "@aws-sdk/middleware-recursion-detection": 3.667.0 + "@aws-sdk/middleware-sdk-s3": 3.677.0 + "@aws-sdk/middleware-ssec": 3.667.0 + "@aws-sdk/middleware-user-agent": 3.677.0 + "@aws-sdk/region-config-resolver": 3.667.0 + "@aws-sdk/signature-v4-multi-region": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@aws-sdk/util-endpoints": 3.667.0 + "@aws-sdk/util-user-agent-browser": 3.675.0 + "@aws-sdk/util-user-agent-node": 3.677.0 + "@aws-sdk/xml-builder": 3.662.0 + "@smithy/config-resolver": ^3.0.9 + "@smithy/core": ^2.4.8 + "@smithy/eventstream-serde-browser": ^3.0.10 + "@smithy/eventstream-serde-config-resolver": ^3.0.7 + "@smithy/eventstream-serde-node": ^3.0.9 + "@smithy/fetch-http-handler": ^3.2.9 + "@smithy/hash-blob-browser": ^3.1.6 + "@smithy/hash-node": ^3.0.7 + "@smithy/hash-stream-node": ^3.1.6 + "@smithy/invalid-dependency": ^3.0.7 + "@smithy/md5-js": ^3.0.7 + "@smithy/middleware-content-length": ^3.0.9 + "@smithy/middleware-endpoint": ^3.1.4 + "@smithy/middleware-retry": ^3.0.23 + "@smithy/middleware-serde": ^3.0.7 + "@smithy/middleware-stack": ^3.0.7 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/node-http-handler": ^3.2.4 + "@smithy/protocol-http": ^4.1.4 + "@smithy/smithy-client": ^3.4.0 + "@smithy/types": ^3.5.0 + "@smithy/url-parser": ^3.0.7 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-body-length-browser": ^3.0.0 + "@smithy/util-body-length-node": ^3.0.0 + "@smithy/util-defaults-mode-browser": ^3.0.23 + "@smithy/util-defaults-mode-node": ^3.0.23 + "@smithy/util-endpoints": ^2.1.3 + "@smithy/util-middleware": ^3.0.7 + "@smithy/util-retry": ^3.0.7 + "@smithy/util-stream": ^3.1.9 + "@smithy/util-utf8": ^3.0.0 + "@smithy/util-waiter": ^3.1.6 + tslib: ^2.6.2 + checksum: 29f78f46386a07cc5f72d349a3845f388e38fa4135c14881d1ae2894ec469182d1c08f2153f60b616171c1e94db9c4090ea4c811ed3c907dced60777d00d86a3 + languageName: node + linkType: hard + "@aws-sdk/client-ssm@npm:^3.303.0": version: 3.319.0 resolution: "@aws-sdk/client-ssm@npm:3.319.0" @@ -4017,6 +4084,55 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/client-sso-oidc@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/client-sso-oidc@npm:3.677.0" + dependencies: + "@aws-crypto/sha256-browser": 5.2.0 + "@aws-crypto/sha256-js": 5.2.0 + "@aws-sdk/core": 3.677.0 + "@aws-sdk/credential-provider-node": 3.677.0 + "@aws-sdk/middleware-host-header": 3.667.0 + "@aws-sdk/middleware-logger": 3.667.0 + "@aws-sdk/middleware-recursion-detection": 3.667.0 + "@aws-sdk/middleware-user-agent": 3.677.0 + "@aws-sdk/region-config-resolver": 3.667.0 + "@aws-sdk/types": 3.667.0 + "@aws-sdk/util-endpoints": 3.667.0 + "@aws-sdk/util-user-agent-browser": 3.675.0 + "@aws-sdk/util-user-agent-node": 3.677.0 + "@smithy/config-resolver": ^3.0.9 + "@smithy/core": ^2.4.8 + "@smithy/fetch-http-handler": ^3.2.9 + "@smithy/hash-node": ^3.0.7 + "@smithy/invalid-dependency": ^3.0.7 + "@smithy/middleware-content-length": ^3.0.9 + "@smithy/middleware-endpoint": ^3.1.4 + "@smithy/middleware-retry": ^3.0.23 + "@smithy/middleware-serde": ^3.0.7 + "@smithy/middleware-stack": ^3.0.7 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/node-http-handler": ^3.2.4 + "@smithy/protocol-http": ^4.1.4 + "@smithy/smithy-client": ^3.4.0 + "@smithy/types": ^3.5.0 + "@smithy/url-parser": ^3.0.7 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-body-length-browser": ^3.0.0 + "@smithy/util-body-length-node": ^3.0.0 + "@smithy/util-defaults-mode-browser": ^3.0.23 + "@smithy/util-defaults-mode-node": ^3.0.23 + "@smithy/util-endpoints": ^2.1.3 + "@smithy/util-middleware": ^3.0.7 + "@smithy/util-retry": ^3.0.7 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + peerDependencies: + "@aws-sdk/client-sts": ^3.677.0 + checksum: 6f737277cb4eeb8d7401cfa4d4d8cb415ff950347166adc60725a6582f6e72625bbedc80bbb87061c5620897b88424526f42eed02d2f57309a663e9fa6c884cf + languageName: node + linkType: hard + "@aws-sdk/client-sso@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/client-sso@npm:3.186.0" @@ -4413,6 +4529,52 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/client-sso@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/client-sso@npm:3.677.0" + dependencies: + "@aws-crypto/sha256-browser": 5.2.0 + "@aws-crypto/sha256-js": 5.2.0 + "@aws-sdk/core": 3.677.0 + "@aws-sdk/middleware-host-header": 3.667.0 + "@aws-sdk/middleware-logger": 3.667.0 + "@aws-sdk/middleware-recursion-detection": 3.667.0 + "@aws-sdk/middleware-user-agent": 3.677.0 + "@aws-sdk/region-config-resolver": 3.667.0 + "@aws-sdk/types": 3.667.0 + "@aws-sdk/util-endpoints": 3.667.0 + "@aws-sdk/util-user-agent-browser": 3.675.0 + "@aws-sdk/util-user-agent-node": 3.677.0 + "@smithy/config-resolver": ^3.0.9 + "@smithy/core": ^2.4.8 + "@smithy/fetch-http-handler": ^3.2.9 + "@smithy/hash-node": ^3.0.7 + "@smithy/invalid-dependency": ^3.0.7 + "@smithy/middleware-content-length": ^3.0.9 + "@smithy/middleware-endpoint": ^3.1.4 + "@smithy/middleware-retry": ^3.0.23 + "@smithy/middleware-serde": ^3.0.7 + "@smithy/middleware-stack": ^3.0.7 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/node-http-handler": ^3.2.4 + "@smithy/protocol-http": ^4.1.4 + "@smithy/smithy-client": ^3.4.0 + "@smithy/types": ^3.5.0 + "@smithy/url-parser": ^3.0.7 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-body-length-browser": ^3.0.0 + "@smithy/util-body-length-node": ^3.0.0 + "@smithy/util-defaults-mode-browser": ^3.0.23 + "@smithy/util-defaults-mode-node": ^3.0.23 + "@smithy/util-endpoints": ^2.1.3 + "@smithy/util-middleware": ^3.0.7 + "@smithy/util-retry": ^3.0.7 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: ca632fecf6b58e3724cc9d83a3da5f2d360779372a4b9c77dfb1be1f56181be4a21a21e22be9319af2cc66a2c12ecc7b4706fa1c941e29fbb94b60f8d24b287d + languageName: node + linkType: hard + "@aws-sdk/client-sts@npm:3.186.3": version: 3.186.3 resolution: "@aws-sdk/client-sts@npm:3.186.3" @@ -4834,6 +4996,54 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/client-sts@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/client-sts@npm:3.677.0" + dependencies: + "@aws-crypto/sha256-browser": 5.2.0 + "@aws-crypto/sha256-js": 5.2.0 + "@aws-sdk/client-sso-oidc": 3.677.0 + "@aws-sdk/core": 3.677.0 + "@aws-sdk/credential-provider-node": 3.677.0 + "@aws-sdk/middleware-host-header": 3.667.0 + "@aws-sdk/middleware-logger": 3.667.0 + "@aws-sdk/middleware-recursion-detection": 3.667.0 + "@aws-sdk/middleware-user-agent": 3.677.0 + "@aws-sdk/region-config-resolver": 3.667.0 + "@aws-sdk/types": 3.667.0 + "@aws-sdk/util-endpoints": 3.667.0 + "@aws-sdk/util-user-agent-browser": 3.675.0 + "@aws-sdk/util-user-agent-node": 3.677.0 + "@smithy/config-resolver": ^3.0.9 + "@smithy/core": ^2.4.8 + "@smithy/fetch-http-handler": ^3.2.9 + "@smithy/hash-node": ^3.0.7 + "@smithy/invalid-dependency": ^3.0.7 + "@smithy/middleware-content-length": ^3.0.9 + "@smithy/middleware-endpoint": ^3.1.4 + "@smithy/middleware-retry": ^3.0.23 + "@smithy/middleware-serde": ^3.0.7 + "@smithy/middleware-stack": ^3.0.7 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/node-http-handler": ^3.2.4 + "@smithy/protocol-http": ^4.1.4 + "@smithy/smithy-client": ^3.4.0 + "@smithy/types": ^3.5.0 + "@smithy/url-parser": ^3.0.7 + "@smithy/util-base64": ^3.0.0 + "@smithy/util-body-length-browser": ^3.0.0 + "@smithy/util-body-length-node": ^3.0.0 + "@smithy/util-defaults-mode-browser": ^3.0.23 + "@smithy/util-defaults-mode-node": ^3.0.23 + "@smithy/util-endpoints": ^2.1.3 + "@smithy/util-middleware": ^3.0.7 + "@smithy/util-retry": ^3.0.7 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: 38f1dbf2689539cc7766b77ebb11ff5088259e427eb1e9005bbf21df5e33e088f4d176b51643ad72fe76756f527c451c68436aa4c920aa5e70fa64b7e0d46bc2 + languageName: node + linkType: hard + "@aws-sdk/client-textract@npm:3.6.1": version: 3.6.1 resolution: "@aws-sdk/client-textract@npm:3.6.1" @@ -5040,6 +5250,25 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/core@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/core@npm:3.677.0" + dependencies: + "@aws-sdk/types": 3.667.0 + "@smithy/core": ^2.4.8 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/property-provider": ^3.1.7 + "@smithy/protocol-http": ^4.1.4 + "@smithy/signature-v4": ^4.2.0 + "@smithy/smithy-client": ^3.4.0 + "@smithy/types": ^3.5.0 + "@smithy/util-middleware": ^3.0.7 + fast-xml-parser: 4.4.1 + tslib: ^2.6.2 + checksum: f0150f5fcbab6e3191d72fcaa36fbeddea9110557dad4102b315de0c466539c7a711dbddb4f4448454077e668992f9cef37f909b7f53b2061a4043d8ce8e61d6 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-cognito-identity@npm:3.382.0": version: 3.382.0 resolution: "@aws-sdk/credential-provider-cognito-identity@npm:3.382.0" @@ -5159,6 +5388,19 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-env@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/credential-provider-env@npm:3.677.0" + dependencies: + "@aws-sdk/core": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/property-provider": ^3.1.7 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 98785974be4d87a375b334bac3646315309d3b10dd5e4834aa7f2a55fab62918cce45cf1d7b0733f0762ae593b5e44c5bb0cfdb72f88526b3a72b5c648e2a387 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-http@npm:3.622.0": version: 3.622.0 resolution: "@aws-sdk/credential-provider-http@npm:3.622.0" @@ -5245,6 +5487,24 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-http@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/credential-provider-http@npm:3.677.0" + dependencies: + "@aws-sdk/core": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/fetch-http-handler": ^3.2.9 + "@smithy/node-http-handler": ^3.2.4 + "@smithy/property-provider": ^3.1.7 + "@smithy/protocol-http": ^4.1.4 + "@smithy/smithy-client": ^3.4.0 + "@smithy/types": ^3.5.0 + "@smithy/util-stream": ^3.1.9 + tslib: ^2.6.2 + checksum: db0f3374e3dab5ab169a4228e47549a409a2a7eea83648c0d8c527d8c35b1c7e0b99cc742546f887112d131f53aa4487b6afe436f0deb3d0fac4b5d20080cbf7 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-imds@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/credential-provider-imds@npm:3.186.0" @@ -5473,6 +5733,28 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-ini@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/credential-provider-ini@npm:3.677.0" + dependencies: + "@aws-sdk/core": 3.677.0 + "@aws-sdk/credential-provider-env": 3.677.0 + "@aws-sdk/credential-provider-http": 3.677.0 + "@aws-sdk/credential-provider-process": 3.677.0 + "@aws-sdk/credential-provider-sso": 3.677.0 + "@aws-sdk/credential-provider-web-identity": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/credential-provider-imds": ^3.2.4 + "@smithy/property-provider": ^3.1.7 + "@smithy/shared-ini-file-loader": ^3.1.8 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + peerDependencies: + "@aws-sdk/client-sts": ^3.677.0 + checksum: acd7bf28355461354e32c225cec3030ae5b8bcb062dbcad3f34c5f3b01cc4fb41ae5b2516ae6268a5c91713633e5ff343a3a78241ae4c190ed5b4839c3dc5576 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-node@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/credential-provider-node@npm:3.186.0" @@ -5664,6 +5946,26 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-node@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/credential-provider-node@npm:3.677.0" + dependencies: + "@aws-sdk/credential-provider-env": 3.677.0 + "@aws-sdk/credential-provider-http": 3.677.0 + "@aws-sdk/credential-provider-ini": 3.677.0 + "@aws-sdk/credential-provider-process": 3.677.0 + "@aws-sdk/credential-provider-sso": 3.677.0 + "@aws-sdk/credential-provider-web-identity": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/credential-provider-imds": ^3.2.4 + "@smithy/property-provider": ^3.1.7 + "@smithy/shared-ini-file-loader": ^3.1.8 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: ad0d7cc557bbf854384f50384ffdee3430b2f7cf404aaf3f33351a4db06bb434677be3e55e4652aef31948a872c75e136ee1ff1551ee4afa0e220610620a75d7 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-process@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/credential-provider-process@npm:3.186.0" @@ -5780,6 +6082,20 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-process@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/credential-provider-process@npm:3.677.0" + dependencies: + "@aws-sdk/core": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/property-provider": ^3.1.7 + "@smithy/shared-ini-file-loader": ^3.1.8 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 9e36eac83a38756ee135b0404fddf36ce785853772af91c40c30d94e4783d968f4695b17b62730570ab854d1ae80c67ee8d402b573a9621e6dc88c31293c0797 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-sso@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/credential-provider-sso@npm:3.186.0" @@ -5914,6 +6230,22 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-sso@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/credential-provider-sso@npm:3.677.0" + dependencies: + "@aws-sdk/client-sso": 3.677.0 + "@aws-sdk/core": 3.677.0 + "@aws-sdk/token-providers": 3.667.0 + "@aws-sdk/types": 3.667.0 + "@smithy/property-provider": ^3.1.7 + "@smithy/shared-ini-file-loader": ^3.1.8 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 926e3d857c8f40d497f368ab33c3a0528d44d982ad3aa4a4b557e24edf6aa6dc1a6ea9b407e0544de2d4acffdac5dc94262d7b33ed01b181df2a349ec7fcca42 + languageName: node + linkType: hard + "@aws-sdk/credential-provider-web-identity@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/credential-provider-web-identity@npm:3.186.0" @@ -6019,6 +6351,21 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/credential-provider-web-identity@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/credential-provider-web-identity@npm:3.677.0" + dependencies: + "@aws-sdk/core": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/property-provider": ^3.1.7 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + peerDependencies: + "@aws-sdk/client-sts": ^3.677.0 + checksum: d525fd0538c4b13bfc217493dff0a6d39448c5c8333be3434b82e900ce82fc7184ea41a64f19329615d5a7341281e9ac1836ace07863497c2ec68a65aab332b7 + languageName: node + linkType: hard + "@aws-sdk/credential-providers@npm:^3.303.0": version: 3.382.0 resolution: "@aws-sdk/credential-providers@npm:3.382.0" @@ -6358,6 +6705,21 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-bucket-endpoint@npm:3.667.0": + version: 3.667.0 + resolution: "@aws-sdk/middleware-bucket-endpoint@npm:3.667.0" + dependencies: + "@aws-sdk/types": 3.667.0 + "@aws-sdk/util-arn-parser": 3.568.0 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/protocol-http": ^4.1.4 + "@smithy/types": ^3.5.0 + "@smithy/util-config-provider": ^3.0.0 + tslib: ^2.6.2 + checksum: f688a6c3a169847e5c79e380ee44ebbe93d7a8b50a7e5d8941a49d50d4033d920f434da93ab9d82ed17a10c82479acea4a56500ccf61f2eefc9e3b3c98305303 + languageName: node + linkType: hard + "@aws-sdk/middleware-content-length@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/middleware-content-length@npm:3.186.0" @@ -6439,6 +6801,18 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-expect-continue@npm:3.667.0": + version: 3.667.0 + resolution: "@aws-sdk/middleware-expect-continue@npm:3.667.0" + dependencies: + "@aws-sdk/types": 3.667.0 + "@smithy/protocol-http": ^4.1.4 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 50be7a37df13f3bec351078272bf60279ebf80714e2ff2ab30e0799466ce1c0ca158f7d50a4514802912b62e95b84e23d91ac5605f4794a3ee5dd0884205f739 + languageName: node + linkType: hard + "@aws-sdk/middleware-flexible-checksums@npm:3.651.1": version: 3.651.1 resolution: "@aws-sdk/middleware-flexible-checksums@npm:3.651.1" @@ -6457,6 +6831,25 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-flexible-checksums@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/middleware-flexible-checksums@npm:3.677.0" + dependencies: + "@aws-crypto/crc32": 5.2.0 + "@aws-crypto/crc32c": 5.2.0 + "@aws-sdk/core": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/is-array-buffer": ^3.0.0 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/protocol-http": ^4.1.4 + "@smithy/types": ^3.5.0 + "@smithy/util-middleware": ^3.0.7 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: 145ced224a1fd63fb492e22a54e03f64c256cae42dc97d409e611017671886342f5b1447e285a242c4167b49a8ae04a45609954eed7157978fc15dd37d3ece12 + languageName: node + linkType: hard + "@aws-sdk/middleware-host-header@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/middleware-host-header@npm:3.186.0" @@ -6573,6 +6966,17 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-location-constraint@npm:3.667.0": + version: 3.667.0 + resolution: "@aws-sdk/middleware-location-constraint@npm:3.667.0" + dependencies: + "@aws-sdk/types": 3.667.0 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 5b861f8355f7bc77c4fcb7d1923e893fff370e42d49016bec61e00d08893e7293216c78a70e84c19e2812c99e52fa72b863da2995b23729726ef6d6ba4ef8012 + languageName: node + linkType: hard + "@aws-sdk/middleware-logger@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/middleware-logger@npm:3.186.0" @@ -6859,6 +7263,28 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-sdk-s3@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/middleware-sdk-s3@npm:3.677.0" + dependencies: + "@aws-sdk/core": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@aws-sdk/util-arn-parser": 3.568.0 + "@smithy/core": ^2.4.8 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/protocol-http": ^4.1.4 + "@smithy/signature-v4": ^4.2.0 + "@smithy/smithy-client": ^3.4.0 + "@smithy/types": ^3.5.0 + "@smithy/util-config-provider": ^3.0.0 + "@smithy/util-middleware": ^3.0.7 + "@smithy/util-stream": ^3.1.9 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: 79e3869df033c69488b9566ee81d77da120001fbd99af3348504017d6393aa47b0e1c7d317467c3f9a661e1c566cd3c157340ce42c5a7c59cb2085841d4caadc + languageName: node + linkType: hard + "@aws-sdk/middleware-sdk-sts@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/middleware-sdk-sts@npm:3.186.0" @@ -6992,6 +7418,17 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-ssec@npm:3.667.0": + version: 3.667.0 + resolution: "@aws-sdk/middleware-ssec@npm:3.667.0" + dependencies: + "@aws-sdk/types": 3.667.0 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 299308b77ec8610543dee4a6d337138b4b0d4b28ea19c7d545a7b2c53196e3787463edfdaf85e7b2ff7b09e43209466ea19507af4f8db344c260ce3e9978b5f3 + languageName: node + linkType: hard + "@aws-sdk/middleware-stack@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/middleware-stack@npm:3.186.0" @@ -7150,6 +7587,21 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/middleware-user-agent@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/middleware-user-agent@npm:3.677.0" + dependencies: + "@aws-sdk/core": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@aws-sdk/util-endpoints": 3.667.0 + "@smithy/core": ^2.4.8 + "@smithy/protocol-http": ^4.1.4 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 2696b7cb17798fdbec184b7a95f5fb81b723c62f3feb137c087bb946b91d0456c35f460d014cf835fde85d5a4eef8ad600f90e4ab36a42fe2575832418f084f2 + languageName: node + linkType: hard + "@aws-sdk/node-config-provider@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/node-config-provider@npm:3.186.0" @@ -7482,6 +7934,20 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/signature-v4-multi-region@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/signature-v4-multi-region@npm:3.677.0" + dependencies: + "@aws-sdk/middleware-sdk-s3": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/protocol-http": ^4.1.4 + "@smithy/signature-v4": ^4.2.0 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 8444a88677bb1a81beb57b0504bc17f9990af2b79bdc453ea21a7dd7ae30537dd3c58a67e334f55f8f1a1a913150205948926526829d46d6060c38f2128bf507 + languageName: node + linkType: hard + "@aws-sdk/signature-v4@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/signature-v4@npm:3.186.0" @@ -8307,6 +8773,18 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/util-user-agent-browser@npm:3.675.0": + version: 3.675.0 + resolution: "@aws-sdk/util-user-agent-browser@npm:3.675.0" + dependencies: + "@aws-sdk/types": 3.667.0 + "@smithy/types": ^3.5.0 + bowser: ^2.11.0 + tslib: ^2.6.2 + checksum: e4f4b63c3576cf65ac2b243921d9630a7ff198aafd98bc230669f47cf152bbba673debe8068a5460a7ef5bb2e312362e9ca8ce1872c21dfcc55c24addbd257a0 + languageName: node + linkType: hard + "@aws-sdk/util-user-agent-node@npm:3.186.0": version: 3.186.0 resolution: "@aws-sdk/util-user-agent-node@npm:3.186.0" @@ -8472,6 +8950,24 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/util-user-agent-node@npm:3.677.0": + version: 3.677.0 + resolution: "@aws-sdk/util-user-agent-node@npm:3.677.0" + dependencies: + "@aws-sdk/middleware-user-agent": 3.677.0 + "@aws-sdk/types": 3.667.0 + "@smithy/node-config-provider": ^3.1.8 + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + peerDependencies: + aws-crt: ">=1.0.0" + peerDependenciesMeta: + aws-crt: + optional: true + checksum: cd637dabdb056ff89caa972e2e09c5fa839900bfe13aa3cdd027362a71036fd00816fd11df1f316628758f0d7f85bcce9840cf446d89dadb9bc2f149cf4f62b5 + languageName: node + linkType: hard + "@aws-sdk/util-utf8-browser@npm:3.186.0, @aws-sdk/util-utf8-browser@npm:^3.0.0": version: 3.186.0 resolution: "@aws-sdk/util-utf8-browser@npm:3.186.0" @@ -8552,6 +9048,16 @@ __metadata: languageName: node linkType: hard +"@aws-sdk/xml-builder@npm:3.662.0": + version: 3.662.0 + resolution: "@aws-sdk/xml-builder@npm:3.662.0" + dependencies: + "@smithy/types": ^3.5.0 + tslib: ^2.6.2 + checksum: 19d7b9dc63e9e071fbe5608cba00e1edfc89529e76034b336bf019f4950aebaf25913bcf4545b3380a2e53df93d3914d160abe2091e97d91138efb2855649a48 + languageName: node + linkType: hard + "@babel/cli@npm:^7.10.5": version: 7.16.0 resolution: "@babel/cli@npm:7.16.0" @@ -12609,6 +13115,16 @@ __metadata: languageName: node linkType: hard +"@smithy/chunked-blob-reader-native@npm:^3.0.1": + version: 3.0.1 + resolution: "@smithy/chunked-blob-reader-native@npm:3.0.1" + dependencies: + "@smithy/util-base64": ^3.0.0 + tslib: ^2.6.2 + checksum: 26f7660d3cb5a257d1db70aaa4b0a109bf4412c3069d35b40645a045481e1633765c8a530ffdab4645bf640fdc957693fa84c6ebb15e864b7bd4be9d4e16b46c + languageName: node + linkType: hard + "@smithy/chunked-blob-reader@npm:^3.0.0": version: 3.0.0 resolution: "@smithy/chunked-blob-reader@npm:3.0.0" @@ -12618,6 +13134,15 @@ __metadata: languageName: node linkType: hard +"@smithy/chunked-blob-reader@npm:^4.0.0": + version: 4.0.0 + resolution: "@smithy/chunked-blob-reader@npm:4.0.0" + dependencies: + tslib: ^2.6.2 + checksum: 4d997cb3a828c9c76bb764586918944ba07262aed832827d2be8ba3556f436171613e80b9f35a005af8f2189fc43befdfe44e21d9bde668fb48d5443f509ae22 + languageName: node + linkType: hard + "@smithy/config-resolver@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/config-resolver@npm:2.0.1" @@ -12711,6 +13236,29 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-codec@npm:^3.1.7": + version: 3.1.7 + resolution: "@smithy/eventstream-codec@npm:3.1.7" + dependencies: + "@aws-crypto/crc32": 5.2.0 + "@smithy/types": ^3.6.0 + "@smithy/util-hex-encoding": ^3.0.0 + tslib: ^2.6.2 + checksum: 6d3e93f5906501ea278c447285a1807bf0a5f2aee4683f6f1b3340e8a11e3c929b2c6389efa470c77eb03eea17824507f03224421768928d4ac5141a5b98eeff + languageName: node + linkType: hard + +"@smithy/eventstream-serde-browser@npm:^3.0.10": + version: 3.0.11 + resolution: "@smithy/eventstream-serde-browser@npm:3.0.11" + dependencies: + "@smithy/eventstream-serde-universal": ^3.0.10 + "@smithy/types": ^3.6.0 + tslib: ^2.6.2 + checksum: d1e7007b5de4bff20f751d6751da74690c03dd4eb339055a5f4b0db6327f9d901f385f2ce100a8d3658df6714955b4403f013285294855c30dc78a50435fdf92 + languageName: node + linkType: hard + "@smithy/eventstream-serde-browser@npm:^3.0.5, @smithy/eventstream-serde-browser@npm:^3.0.7": version: 3.0.9 resolution: "@smithy/eventstream-serde-browser@npm:3.0.9" @@ -12732,6 +13280,16 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-serde-config-resolver@npm:^3.0.7": + version: 3.0.8 + resolution: "@smithy/eventstream-serde-config-resolver@npm:3.0.8" + dependencies: + "@smithy/types": ^3.6.0 + tslib: ^2.6.2 + checksum: a18f5b7cfc6f9ab79d282138452b7475cafb354d2d6d9d6d8ae7815342537bd81f6e1423aa9cb77a6006d24d6a65ef7bdc47ea823f77d4b65f440e0eec708b7b + languageName: node + linkType: hard + "@smithy/eventstream-serde-node@npm:^3.0.4, @smithy/eventstream-serde-node@npm:^3.0.6": version: 3.0.8 resolution: "@smithy/eventstream-serde-node@npm:3.0.8" @@ -12743,6 +13301,28 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-serde-node@npm:^3.0.9": + version: 3.0.10 + resolution: "@smithy/eventstream-serde-node@npm:3.0.10" + dependencies: + "@smithy/eventstream-serde-universal": ^3.0.10 + "@smithy/types": ^3.6.0 + tslib: ^2.6.2 + checksum: d67feaa889473f85459061fda50ab4742cf25f8e93557a307d3c2990620a5c5893bce477ac1d747838672b7ae65d97856245f6bbe1379de9b90cd57cf6c83e2e + languageName: node + linkType: hard + +"@smithy/eventstream-serde-universal@npm:^3.0.10": + version: 3.0.10 + resolution: "@smithy/eventstream-serde-universal@npm:3.0.10" + dependencies: + "@smithy/eventstream-codec": ^3.1.7 + "@smithy/types": ^3.6.0 + tslib: ^2.6.2 + checksum: 5f3bd8751e6ed6c2c3ea6da54dd2ecd8906de8d2606e6fb9da5f0d0500c4b5d85a1a83837cc661bcc3a058b485459b12ddcc48810b12afd8d140cc76d2516346 + languageName: node + linkType: hard + "@smithy/eventstream-serde-universal@npm:^3.0.8": version: 3.0.8 resolution: "@smithy/eventstream-serde-universal@npm:3.0.8" @@ -12792,6 +13372,18 @@ __metadata: languageName: node linkType: hard +"@smithy/hash-blob-browser@npm:^3.1.6": + version: 3.1.7 + resolution: "@smithy/hash-blob-browser@npm:3.1.7" + dependencies: + "@smithy/chunked-blob-reader": ^4.0.0 + "@smithy/chunked-blob-reader-native": ^3.0.1 + "@smithy/types": ^3.6.0 + tslib: ^2.6.2 + checksum: fda71b16b2ffdb47dd75c4568c28a712703ce987e35c646f89860668ffb0cc38c15410b6319ce077e5dc5c3e4427af9e4620281a0a491a163e2bc23c507fe610 + languageName: node + linkType: hard + "@smithy/hash-node@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/hash-node@npm:2.0.1" @@ -12827,6 +13419,17 @@ __metadata: languageName: node linkType: hard +"@smithy/hash-stream-node@npm:^3.1.6": + version: 3.1.7 + resolution: "@smithy/hash-stream-node@npm:3.1.7" + dependencies: + "@smithy/types": ^3.6.0 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: 26f1a49f9fa5486fbca97034c171f36675cffdf2fe1039cfd918a83b63d9cbb1b0cdb7c399c21f1d914f3c4df5e16754b01a755b2eadaf51c519aa183ac71ea3 + languageName: node + linkType: hard + "@smithy/invalid-dependency@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/invalid-dependency@npm:2.0.1" @@ -12876,6 +13479,17 @@ __metadata: languageName: node linkType: hard +"@smithy/md5-js@npm:^3.0.7": + version: 3.0.8 + resolution: "@smithy/md5-js@npm:3.0.8" + dependencies: + "@smithy/types": ^3.6.0 + "@smithy/util-utf8": ^3.0.0 + tslib: ^2.6.2 + checksum: 83654b7c65be77d3e170f63a5dab4b3d19bb518ca69691b0a9c257de8101a02e005bc2136074d6ab18d0a50cef746ea610527e3530c6e843b6b9529ed9b488f1 + languageName: node + linkType: hard + "@smithy/middleware-content-length@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/middleware-content-length@npm:2.0.1" @@ -13241,6 +13855,15 @@ __metadata: languageName: node linkType: hard +"@smithy/types@npm:^3.6.0": + version: 3.6.0 + resolution: "@smithy/types@npm:3.6.0" + dependencies: + tslib: ^2.6.2 + checksum: de16293da6cf6f1aa4b2ee604df245ef33688d985f27b5dae3aa69e18ed5b17baa1bc1a42412f1454c50d09a1817c8a54e7d6261c90fee230e103ff91e55174a + languageName: node + linkType: hard + "@smithy/url-parser@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/url-parser@npm:2.0.1" From 07949c43fcb60d03a07dcfabf7a1995460ad623c Mon Sep 17 00:00:00 2001 From: Sanay Yogesh Shah Date: Wed, 23 Oct 2024 14:51:54 -0700 Subject: [PATCH 2/6] fix: remove typo comments --- .../src/__tests__/migration_templategen_e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts b/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts index d0a1a1ddc0..6a9c91eed7 100644 --- a/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts +++ b/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts @@ -43,7 +43,7 @@ void describe('Templategen E2E tests', () => { const gen2StackName = await runGen2SandboxCommand(projRoot); assert(gen2StackName); await runTemplategenCommand(projRoot, gen1StackName, gen2StackName); - // await stackRefactor(projRoot, 'auth', bucketName); + await stackRefactor(projRoot, 'auth', bucketName); await stackRefactor(projRoot, 'storage', bucketName); }); }); From d8066c2405159bf5375947ae3634d98960be4d6e Mon Sep 17 00:00:00 2001 From: Sanay Yogesh Shah Date: Thu, 24 Oct 2024 01:28:07 -0700 Subject: [PATCH 3/6] fix: resolve lint errors --- .eslint-dictionary.json | 1 + packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/.eslint-dictionary.json b/.eslint-dictionary.json index 0281e5f4f0..32ce6d122d 100644 --- a/.eslint-dictionary.json +++ b/.eslint-dictionary.json @@ -388,6 +388,7 @@ "syncable", "tablename", "tailwindcss", + "templategen", "testother", "testschemadeployer", "textract", diff --git a/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts b/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts index b1d9cbb77a..4909918333 100644 --- a/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts +++ b/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts @@ -11,6 +11,7 @@ async function getGen1AuthResourceDetails(projRoot: string) { const { gen1UserPoolId } = await assertUserPool(gen1Meta, gen1Region); const { gen1IdentityPoolId } = await assertIdentityPool(gen1Meta, gen1Region); const { gen1ClientIds } = await assertUserPoolClients(gen1Meta, gen1Region); + // eslint-disable-next-line @typescript-eslint/no-unused-vars const [gen1ClientIdWeb, gen1ClientId] = gen1ClientIds; const gen1ResourceIds = [gen1UserPoolId, gen1IdentityPoolId, gen1ClientIdWeb]; From 423d6a34f6da5c89fa04abaf31f526f7f8b7d4bf Mon Sep 17 00:00:00 2001 From: Sanay Yogesh Shah Date: Thu, 24 Oct 2024 02:37:54 -0700 Subject: [PATCH 4/6] fix: resolve yarn issues --- yarn.lock | 310 ++---------------------------------------------------- 1 file changed, 7 insertions(+), 303 deletions(-) diff --git a/yarn.lock b/yarn.lock index 13cb3bdbad..ad68ead63c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3532,73 +3532,7 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/client-s3@npm:^3.25.0, @aws-sdk/client-s3@npm:^3.303.0, @aws-sdk/client-s3@npm:^3.592.0, @aws-sdk/client-s3@npm:^3.651.1": - version: 3.651.1 - resolution: "@aws-sdk/client-s3@npm:3.651.1" - dependencies: - "@aws-crypto/sha1-browser": 5.2.0 - "@aws-crypto/sha256-browser": 5.2.0 - "@aws-crypto/sha256-js": 5.2.0 - "@aws-sdk/client-sso-oidc": 3.651.1 - "@aws-sdk/client-sts": 3.651.1 - "@aws-sdk/core": 3.651.1 - "@aws-sdk/credential-provider-node": 3.651.1 - "@aws-sdk/middleware-bucket-endpoint": 3.649.0 - "@aws-sdk/middleware-expect-continue": 3.649.0 - "@aws-sdk/middleware-flexible-checksums": 3.651.1 - "@aws-sdk/middleware-host-header": 3.649.0 - "@aws-sdk/middleware-location-constraint": 3.649.0 - "@aws-sdk/middleware-logger": 3.649.0 - "@aws-sdk/middleware-recursion-detection": 3.649.0 - "@aws-sdk/middleware-sdk-s3": 3.651.1 - "@aws-sdk/middleware-ssec": 3.649.0 - "@aws-sdk/middleware-user-agent": 3.649.0 - "@aws-sdk/region-config-resolver": 3.649.0 - "@aws-sdk/signature-v4-multi-region": 3.651.1 - "@aws-sdk/types": 3.649.0 - "@aws-sdk/util-endpoints": 3.649.0 - "@aws-sdk/util-user-agent-browser": 3.649.0 - "@aws-sdk/util-user-agent-node": 3.649.0 - "@aws-sdk/xml-builder": 3.649.0 - "@smithy/config-resolver": ^3.0.6 - "@smithy/core": ^2.4.1 - "@smithy/eventstream-serde-browser": ^3.0.7 - "@smithy/eventstream-serde-config-resolver": ^3.0.4 - "@smithy/eventstream-serde-node": ^3.0.6 - "@smithy/fetch-http-handler": ^3.2.5 - "@smithy/hash-blob-browser": ^3.1.3 - "@smithy/hash-node": ^3.0.4 - "@smithy/hash-stream-node": ^3.1.3 - "@smithy/invalid-dependency": ^3.0.4 - "@smithy/md5-js": ^3.0.4 - "@smithy/middleware-content-length": ^3.0.6 - "@smithy/middleware-endpoint": ^3.1.1 - "@smithy/middleware-retry": ^3.0.16 - "@smithy/middleware-serde": ^3.0.4 - "@smithy/middleware-stack": ^3.0.4 - "@smithy/node-config-provider": ^3.1.5 - "@smithy/node-http-handler": ^3.2.0 - "@smithy/protocol-http": ^4.1.1 - "@smithy/smithy-client": ^3.3.0 - "@smithy/types": ^3.4.0 - "@smithy/url-parser": ^3.0.4 - "@smithy/util-base64": ^3.0.0 - "@smithy/util-body-length-browser": ^3.0.0 - "@smithy/util-body-length-node": ^3.0.0 - "@smithy/util-defaults-mode-browser": ^3.0.16 - "@smithy/util-defaults-mode-node": ^3.0.16 - "@smithy/util-endpoints": ^2.1.0 - "@smithy/util-middleware": ^3.0.4 - "@smithy/util-retry": ^3.0.4 - "@smithy/util-stream": ^3.1.4 - "@smithy/util-utf8": ^3.0.0 - "@smithy/util-waiter": ^3.1.3 - tslib: ^2.6.2 - checksum: 34d0058a5673896f349b63c484d4b3fccdc3e4171f89b672280630d65969c715aaefa69d9474c61d57e90af1bba68665e650b2711afaab54597864f6353e10fb - languageName: node - linkType: hard - -"@aws-sdk/client-s3@npm:^3.674.0": +"@aws-sdk/client-s3@npm:^3.25.0, @aws-sdk/client-s3@npm:^3.303.0, @aws-sdk/client-s3@npm:^3.592.0, @aws-sdk/client-s3@npm:^3.651.1, @aws-sdk/client-s3@npm:^3.674.0": version: 3.677.0 resolution: "@aws-sdk/client-s3@npm:3.677.0" dependencies: @@ -4948,7 +4882,7 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/client-sts@npm:3.670.0, @aws-sdk/client-sts@npm:^3.303.0, @aws-sdk/client-sts@npm:^3.465.0, @aws-sdk/client-sts@npm:^3.658.1": +"@aws-sdk/client-sts@npm:3.670.0": version: 3.670.0 resolution: "@aws-sdk/client-sts@npm:3.670.0" dependencies: @@ -4996,7 +4930,7 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/client-sts@npm:3.677.0": +"@aws-sdk/client-sts@npm:3.677.0, @aws-sdk/client-sts@npm:^3.303.0, @aws-sdk/client-sts@npm:^3.465.0, @aws-sdk/client-sts@npm:^3.658.1": version: 3.677.0 resolution: "@aws-sdk/client-sts@npm:3.677.0" dependencies: @@ -6690,21 +6624,6 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/middleware-bucket-endpoint@npm:3.649.0": - version: 3.649.0 - resolution: "@aws-sdk/middleware-bucket-endpoint@npm:3.649.0" - dependencies: - "@aws-sdk/types": 3.649.0 - "@aws-sdk/util-arn-parser": 3.568.0 - "@smithy/node-config-provider": ^3.1.5 - "@smithy/protocol-http": ^4.1.1 - "@smithy/types": ^3.4.0 - "@smithy/util-config-provider": ^3.0.0 - tslib: ^2.6.2 - checksum: fa8f1c3d3150c12e29256f0085c33f355e2b15f1db23b85120e7605b3ef06ec180592ebdb3c9a71ec9ef5277c74e1d3927888d642736e6825ffb7773c87f918e - languageName: node - linkType: hard - "@aws-sdk/middleware-bucket-endpoint@npm:3.667.0": version: 3.667.0 resolution: "@aws-sdk/middleware-bucket-endpoint@npm:3.667.0" @@ -6789,18 +6708,6 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/middleware-expect-continue@npm:3.649.0": - version: 3.649.0 - resolution: "@aws-sdk/middleware-expect-continue@npm:3.649.0" - dependencies: - "@aws-sdk/types": 3.649.0 - "@smithy/protocol-http": ^4.1.1 - "@smithy/types": ^3.4.0 - tslib: ^2.6.2 - checksum: 57ca93a7abab8017fbfa38c3702841d8b803b764222a84d9f9091c760888dde235c3e9a928e4d76007b290b0b4274995099b84d1af9e5306ce0a067e0c3172e7 - languageName: node - linkType: hard - "@aws-sdk/middleware-expect-continue@npm:3.667.0": version: 3.667.0 resolution: "@aws-sdk/middleware-expect-continue@npm:3.667.0" @@ -6813,24 +6720,6 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/middleware-flexible-checksums@npm:3.651.1": - version: 3.651.1 - resolution: "@aws-sdk/middleware-flexible-checksums@npm:3.651.1" - dependencies: - "@aws-crypto/crc32": 5.2.0 - "@aws-crypto/crc32c": 5.2.0 - "@aws-sdk/types": 3.649.0 - "@smithy/is-array-buffer": ^3.0.0 - "@smithy/node-config-provider": ^3.1.5 - "@smithy/protocol-http": ^4.1.1 - "@smithy/types": ^3.4.0 - "@smithy/util-middleware": ^3.0.4 - "@smithy/util-utf8": ^3.0.0 - tslib: ^2.6.2 - checksum: 8108993555e6cfe126512d63d3b120424b3457f039e07a2d9720f4c810258a7d2fbcbc61c717e76450f71c9fbe34e8f3880190f27bef30143c5ab3710991ad19 - languageName: node - linkType: hard - "@aws-sdk/middleware-flexible-checksums@npm:3.677.0": version: 3.677.0 resolution: "@aws-sdk/middleware-flexible-checksums@npm:3.677.0" @@ -6955,17 +6844,6 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/middleware-location-constraint@npm:3.649.0": - version: 3.649.0 - resolution: "@aws-sdk/middleware-location-constraint@npm:3.649.0" - dependencies: - "@aws-sdk/types": 3.649.0 - "@smithy/types": ^3.4.0 - tslib: ^2.6.2 - checksum: 6132d5d8b2eeda75d26123d364c2b217865a2c1472f80a1dc8856f152a08b912289048685ee67a53c7dd9c63f624e690f6008b7dd2780fb21706407abcb5ef6a - languageName: node - linkType: hard - "@aws-sdk/middleware-location-constraint@npm:3.667.0": version: 3.667.0 resolution: "@aws-sdk/middleware-location-constraint@npm:3.667.0" @@ -7241,28 +7119,6 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/middleware-sdk-s3@npm:3.651.1": - version: 3.651.1 - resolution: "@aws-sdk/middleware-sdk-s3@npm:3.651.1" - dependencies: - "@aws-sdk/core": 3.651.1 - "@aws-sdk/types": 3.649.0 - "@aws-sdk/util-arn-parser": 3.568.0 - "@smithy/core": ^2.4.1 - "@smithy/node-config-provider": ^3.1.5 - "@smithy/protocol-http": ^4.1.1 - "@smithy/signature-v4": ^4.1.1 - "@smithy/smithy-client": ^3.3.0 - "@smithy/types": ^3.4.0 - "@smithy/util-config-provider": ^3.0.0 - "@smithy/util-middleware": ^3.0.4 - "@smithy/util-stream": ^3.1.4 - "@smithy/util-utf8": ^3.0.0 - tslib: ^2.6.2 - checksum: 0dc2d4d75e21fcd9b32afa59f6c1912380a5c807c8f6c983c57a80205db0f511856703058fcc7e939b9813bb91d669b576483dced037042a58579be3eb018860 - languageName: node - linkType: hard - "@aws-sdk/middleware-sdk-s3@npm:3.677.0": version: 3.677.0 resolution: "@aws-sdk/middleware-sdk-s3@npm:3.677.0" @@ -7407,17 +7263,6 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/middleware-ssec@npm:3.649.0": - version: 3.649.0 - resolution: "@aws-sdk/middleware-ssec@npm:3.649.0" - dependencies: - "@aws-sdk/types": 3.649.0 - "@smithy/types": ^3.4.0 - tslib: ^2.6.2 - checksum: a600f290f4ee703ace612edbda657da88f2402627bd2a80b77621fa70208fe205add95ecde075377f74df86b2946ff1c606436289f9c61a4d544d99864f8b9b7 - languageName: node - linkType: hard - "@aws-sdk/middleware-ssec@npm:3.667.0": version: 3.667.0 resolution: "@aws-sdk/middleware-ssec@npm:3.667.0" @@ -7920,20 +7765,6 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/signature-v4-multi-region@npm:3.651.1": - version: 3.651.1 - resolution: "@aws-sdk/signature-v4-multi-region@npm:3.651.1" - dependencies: - "@aws-sdk/middleware-sdk-s3": 3.651.1 - "@aws-sdk/types": 3.649.0 - "@smithy/protocol-http": ^4.1.1 - "@smithy/signature-v4": ^4.1.1 - "@smithy/types": ^3.4.0 - tslib: ^2.6.2 - checksum: 4bd6dff552c6aaf8688aa54771133ba4b50f6f28eee6ab37cba82202a15c1d704eb2a6592d6e56705be1b6e8daf8378012cde8b67339df42ff4ec318b60a5ad1 - languageName: node - linkType: hard - "@aws-sdk/signature-v4-multi-region@npm:3.677.0": version: 3.677.0 resolution: "@aws-sdk/signature-v4-multi-region@npm:3.677.0" @@ -9038,16 +8869,6 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/xml-builder@npm:3.649.0": - version: 3.649.0 - resolution: "@aws-sdk/xml-builder@npm:3.649.0" - dependencies: - "@smithy/types": ^3.4.0 - tslib: ^2.6.2 - checksum: 4cdc8971a3472b8ec33efce82f83d754556043c750dc46c83612caaa368f3c8db287443b250ac91d8773961533fe3d2799773de7b5bf0aedeec2579973850ab7 - languageName: node - linkType: hard - "@aws-sdk/xml-builder@npm:3.662.0": version: 3.662.0 resolution: "@aws-sdk/xml-builder@npm:3.662.0" @@ -13105,16 +12926,6 @@ __metadata: languageName: node linkType: hard -"@smithy/chunked-blob-reader-native@npm:^3.0.0": - version: 3.0.0 - resolution: "@smithy/chunked-blob-reader-native@npm:3.0.0" - dependencies: - "@smithy/util-base64": ^3.0.0 - tslib: ^2.6.2 - checksum: f3cbd03baaaf33a2c44a484851e3f2902f87cbb2168abff179276b19fd137be021393551b9270f9f3135408d816a06fe84ff826d9beb576dbe53fae9cf487362 - languageName: node - linkType: hard - "@smithy/chunked-blob-reader-native@npm:^3.0.1": version: 3.0.1 resolution: "@smithy/chunked-blob-reader-native@npm:3.0.1" @@ -13125,15 +12936,6 @@ __metadata: languageName: node linkType: hard -"@smithy/chunked-blob-reader@npm:^3.0.0": - version: 3.0.0 - resolution: "@smithy/chunked-blob-reader@npm:3.0.0" - dependencies: - tslib: ^2.6.2 - checksum: cc551e4d6c711bec381d70c3074e3937ee78245bb15dd55c28c43c6c30808af1855c8df4a785a1033ded1483979ae115cf2c9decce73083346734db0d32b2fe5 - languageName: node - linkType: hard - "@smithy/chunked-blob-reader@npm:^4.0.0": version: 4.0.0 resolution: "@smithy/chunked-blob-reader@npm:4.0.0" @@ -13224,18 +13026,6 @@ __metadata: languageName: node linkType: hard -"@smithy/eventstream-codec@npm:^3.1.5": - version: 3.1.5 - resolution: "@smithy/eventstream-codec@npm:3.1.5" - dependencies: - "@aws-crypto/crc32": 5.2.0 - "@smithy/types": ^3.4.2 - "@smithy/util-hex-encoding": ^3.0.0 - tslib: ^2.6.2 - checksum: e999c74b9d3c38a67121f9096a134a55d8c4362a3a9468c8317d2dbf9a9d2e7ecf177ac0e7a5a5adfa92a51407a4d0bbf324787870d985a60ef6fae96ed4e8db - languageName: node - linkType: hard - "@smithy/eventstream-codec@npm:^3.1.7": version: 3.1.7 resolution: "@smithy/eventstream-codec@npm:3.1.7" @@ -13248,7 +13038,7 @@ __metadata: languageName: node linkType: hard -"@smithy/eventstream-serde-browser@npm:^3.0.10": +"@smithy/eventstream-serde-browser@npm:^3.0.10, @smithy/eventstream-serde-browser@npm:^3.0.5, @smithy/eventstream-serde-browser@npm:^3.0.7": version: 3.0.11 resolution: "@smithy/eventstream-serde-browser@npm:3.0.11" dependencies: @@ -13259,28 +13049,7 @@ __metadata: languageName: node linkType: hard -"@smithy/eventstream-serde-browser@npm:^3.0.5, @smithy/eventstream-serde-browser@npm:^3.0.7": - version: 3.0.9 - resolution: "@smithy/eventstream-serde-browser@npm:3.0.9" - dependencies: - "@smithy/eventstream-serde-universal": ^3.0.8 - "@smithy/types": ^3.4.2 - tslib: ^2.6.2 - checksum: f74d9754fe0de4e682c010afbce374436d8ab1ece0fcc078caa5dab87133696179f3e9821699094626032aad34ff485a40699e1860da7d377802c8dd768c9b1d - languageName: node - linkType: hard - -"@smithy/eventstream-serde-config-resolver@npm:^3.0.3, @smithy/eventstream-serde-config-resolver@npm:^3.0.4": - version: 3.0.6 - resolution: "@smithy/eventstream-serde-config-resolver@npm:3.0.6" - dependencies: - "@smithy/types": ^3.4.2 - tslib: ^2.6.2 - checksum: be8b118ef46c0e2d0f8faab3a86bb65f617e88e33205e44c8799bd9a7ce97d37957528686c1b5485e9f662d331379bbdb68fa2c65869c86568aa1387e06b9a86 - languageName: node - linkType: hard - -"@smithy/eventstream-serde-config-resolver@npm:^3.0.7": +"@smithy/eventstream-serde-config-resolver@npm:^3.0.3, @smithy/eventstream-serde-config-resolver@npm:^3.0.4, @smithy/eventstream-serde-config-resolver@npm:^3.0.7": version: 3.0.8 resolution: "@smithy/eventstream-serde-config-resolver@npm:3.0.8" dependencies: @@ -13290,18 +13059,7 @@ __metadata: languageName: node linkType: hard -"@smithy/eventstream-serde-node@npm:^3.0.4, @smithy/eventstream-serde-node@npm:^3.0.6": - version: 3.0.8 - resolution: "@smithy/eventstream-serde-node@npm:3.0.8" - dependencies: - "@smithy/eventstream-serde-universal": ^3.0.8 - "@smithy/types": ^3.4.2 - tslib: ^2.6.2 - checksum: e059d680e847b5c4759b83b0d5b2f7570648b53ffd01650dbfb04eec89084915092517c6eb59183aa019eafda7506afe808c0fb2cf2eec7c648fbf68c95fcece - languageName: node - linkType: hard - -"@smithy/eventstream-serde-node@npm:^3.0.9": +"@smithy/eventstream-serde-node@npm:^3.0.4, @smithy/eventstream-serde-node@npm:^3.0.6, @smithy/eventstream-serde-node@npm:^3.0.9": version: 3.0.10 resolution: "@smithy/eventstream-serde-node@npm:3.0.10" dependencies: @@ -13323,17 +13081,6 @@ __metadata: languageName: node linkType: hard -"@smithy/eventstream-serde-universal@npm:^3.0.8": - version: 3.0.8 - resolution: "@smithy/eventstream-serde-universal@npm:3.0.8" - dependencies: - "@smithy/eventstream-codec": ^3.1.5 - "@smithy/types": ^3.4.2 - tslib: ^2.6.2 - checksum: d3d87d3295318e8f7715fd56b0db357a96bd5ff026458578e83c775349666a587af308a2a170078900ddb8d776dd1d6d6c39e8267f72098e3943016df9ba893c - languageName: node - linkType: hard - "@smithy/fetch-http-handler@npm:^2.0.1": version: 2.0.1 resolution: "@smithy/fetch-http-handler@npm:2.0.1" @@ -13360,18 +13107,6 @@ __metadata: languageName: node linkType: hard -"@smithy/hash-blob-browser@npm:^3.1.3": - version: 3.1.5 - resolution: "@smithy/hash-blob-browser@npm:3.1.5" - dependencies: - "@smithy/chunked-blob-reader": ^3.0.0 - "@smithy/chunked-blob-reader-native": ^3.0.0 - "@smithy/types": ^3.4.2 - tslib: ^2.6.2 - checksum: 4633333ee44ff09a4df782444176e648b85f53e42767d3d3e66007019d5aa30718b70bbd49bced0bcdd33180cbe284b5366448f53bb3184498a84478794125a8 - languageName: node - linkType: hard - "@smithy/hash-blob-browser@npm:^3.1.6": version: 3.1.7 resolution: "@smithy/hash-blob-browser@npm:3.1.7" @@ -13408,17 +13143,6 @@ __metadata: languageName: node linkType: hard -"@smithy/hash-stream-node@npm:^3.1.3": - version: 3.1.5 - resolution: "@smithy/hash-stream-node@npm:3.1.5" - dependencies: - "@smithy/types": ^3.4.2 - "@smithy/util-utf8": ^3.0.0 - tslib: ^2.6.2 - checksum: 89a27d7f2d77ea6b3c98b02948922ed1cfa8fa6d26aaed04fb83468abf5e51d50f7f7bb3973dcdc478c57a7918f75fd359ac9b656e677e7d30f8ee01afd18464 - languageName: node - linkType: hard - "@smithy/hash-stream-node@npm:^3.1.6": version: 3.1.7 resolution: "@smithy/hash-stream-node@npm:3.1.7" @@ -13468,17 +13192,6 @@ __metadata: languageName: node linkType: hard -"@smithy/md5-js@npm:^3.0.4": - version: 3.0.6 - resolution: "@smithy/md5-js@npm:3.0.6" - dependencies: - "@smithy/types": ^3.4.2 - "@smithy/util-utf8": ^3.0.0 - tslib: ^2.6.2 - checksum: d15cb0012df5d3f7ac762f432c66e54b4b36c580229c8d4f216bec8697b438b9842ff78a23619e7a10ec09a3d8589d2f0498336e3969090cc82bd2bf364f3635 - languageName: node - linkType: hard - "@smithy/md5-js@npm:^3.0.7": version: 3.0.8 resolution: "@smithy/md5-js@npm:3.0.8" @@ -13846,16 +13559,7 @@ __metadata: languageName: node linkType: hard -"@smithy/types@npm:^3.3.0, @smithy/types@npm:^3.4.0, @smithy/types@npm:^3.4.2, @smithy/types@npm:^3.5.0": - version: 3.5.0 - resolution: "@smithy/types@npm:3.5.0" - dependencies: - tslib: ^2.6.2 - checksum: 298f1638b0ba3a5cef3d238219cebab21f9479e54a5de3f7dbde5f65f7a3966a9623d4bb4e3856ef67bc6139a065a149379f6374e68bef380e8bb789c592db22 - languageName: node - linkType: hard - -"@smithy/types@npm:^3.6.0": +"@smithy/types@npm:^3.3.0, @smithy/types@npm:^3.4.0, @smithy/types@npm:^3.4.2, @smithy/types@npm:^3.5.0, @smithy/types@npm:^3.6.0": version: 3.6.0 resolution: "@smithy/types@npm:3.6.0" dependencies: From b9326c076be9d1e35fa659e97fae92b3ea8732d1 Mon Sep 17 00:00:00 2001 From: Sanay Yogesh Shah Date: Thu, 24 Oct 2024 16:35:13 -0700 Subject: [PATCH 5/6] fix: add function comments for better readability --- .../__tests__/migration_codegen_e2e.test.ts | 12 ++++++++--- .../src/migrationReadmeParser.ts | 20 +++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/packages/amplify-migration-e2e/src/__tests__/migration_codegen_e2e.test.ts b/packages/amplify-migration-e2e/src/__tests__/migration_codegen_e2e.test.ts index 11a2231f87..48e2ee0277 100644 --- a/packages/amplify-migration-e2e/src/__tests__/migration_codegen_e2e.test.ts +++ b/packages/amplify-migration-e2e/src/__tests__/migration_codegen_e2e.test.ts @@ -60,8 +60,10 @@ void describe('Codegen E2E tests', () => { await runCodegenCommand(projRoot); await copyFunctionFile(projRoot, 'function', gen1FunctionName); await copyGen1Schema(projRoot, projName); + // TODO: replace below line with correct package version - await updatePackageDependency(projRoot, '@aws-amplify/backend', '0.0.0-test-20241003180022'); + await updatePackageDependency(projRoot, '@aws-amplify/backend'); + await npmInstall(projRoot); const gen2StackName = await runGen2SandboxCommand(projRoot); await assertAuthResource(projRoot, gen1UserPoolId, gen1ClientIds, gen1IdentityPoolId, gen1Region); @@ -78,8 +80,10 @@ void describe('Codegen E2E tests', () => { await runCodegenCommand(projRoot); await copyFunctionFile(projRoot, 'auth', gen1FunctionName); await removeErrorThrowsFromAuthResourceFile(projRoot); + // TODO: replace below line with correct package version - await updatePackageDependency(projRoot, '@aws-amplify/backend', '0.0.0-test-20241003180022'); + await updatePackageDependency(projRoot, '@aws-amplify/backend'); + await npmInstall(projRoot); await toggleSandboxSecrets(projRoot, 'set'); const gen2StackName = await runGen2SandboxCommand(projRoot); @@ -94,8 +98,10 @@ void describe('Codegen E2E tests', () => { projRoot, ); await runCodegenCommand(projRoot); + // TODO: replace below line with correct package version - await updatePackageDependency(projRoot, '@aws-amplify/backend', '0.0.0-test-20241003180022'); + await updatePackageDependency(projRoot, '@aws-amplify/backend'); + await npmInstall(projRoot); await runGen2SandboxCommand(projRoot); await assertAuthResource(projRoot, gen1UserPoolId, gen1ClientIds, gen1IdentityPoolId, gen1Region); diff --git a/packages/amplify-migration-e2e/src/migrationReadmeParser.ts b/packages/amplify-migration-e2e/src/migrationReadmeParser.ts index 91277e9988..510addc311 100644 --- a/packages/amplify-migration-e2e/src/migrationReadmeParser.ts +++ b/packages/amplify-migration-e2e/src/migrationReadmeParser.ts @@ -24,6 +24,26 @@ function extractCommands(readmeContent: string) { return commands; } +/** + * Sample from the README file for STEP 1: + * + * ### STEP 1: UPDATE GEN-1 AUTH STACK + * + * It is a non-disruptive update since the template only replaces resource references with their resolved values. This is a required step to execute cloudformation stack refactor later. + * + * ``` + * aws cloudformation update-stack \ + * --stack-name my-auth-stack-name \ + * --template-body file://path/to/template.json \ + * --parameters '[{"ParameterKey":"authRoleArn","ParameterValue":"arn:aws:iam::123456789012:role/my-auth-role"},{"ParameterKey":"autoVerifiedAttributes","ParameterValue":"email"},{"ParameterKey":"allowUnauthenticatedIdentities","ParameterValue":"false"},{"ParameterKey":"smsVerificationMessage","ParameterValue":"Your verification code is {####}"}]' \ + * --capabilities CAPABILITY_NAMED_IAM --tags '[]' + * ``` + * + * ``` + * aws cloudformation describe-stacks \ + * --stack-name my-auth-stack-name + * ``` + */ export function getCommandsFromReadme(readmeContent: string) { const step1Content = extractContent(readmeContent, '### STEP 1', '#### Rollback step'); const step2Content = extractContent(readmeContent, '### STEP 2', '#### Rollback step'); From b28e1014fa504a64624b444c916fde099102071e Mon Sep 17 00:00:00 2001 From: Sanay Yogesh Shah Date: Tue, 29 Oct 2024 14:06:48 -0700 Subject: [PATCH 6/6] refactor: modify setting and deleting env vars, remove unnecessary comments --- .../src/__tests__/migration_codegen_e2e.test.ts | 13 ++----------- .../src/__tests__/migration_templategen_e2e.test.ts | 9 +++------ packages/amplify-migration-e2e/src/envVariables.ts | 13 ++++++------- .../src/gen1ResourceDetailsFetcher.ts | 3 +-- packages/amplify-migration-e2e/src/templategen.ts | 11 +++++------ 5 files changed, 17 insertions(+), 32 deletions(-) diff --git a/packages/amplify-migration-e2e/src/__tests__/migration_codegen_e2e.test.ts b/packages/amplify-migration-e2e/src/__tests__/migration_codegen_e2e.test.ts index 48e2ee0277..bebae7abe7 100644 --- a/packages/amplify-migration-e2e/src/__tests__/migration_codegen_e2e.test.ts +++ b/packages/amplify-migration-e2e/src/__tests__/migration_codegen_e2e.test.ts @@ -1,6 +1,6 @@ import path from 'node:path'; import assert from 'node:assert'; -import { createNewProjectDir, npmInstall } from '@aws-amplify/amplify-e2e-core'; +import { createNewProjectDir, generateRandomShortId, npmInstall } from '@aws-amplify/amplify-e2e-core'; import { createGen2Renderer } from '@aws-amplify/amplify-gen2-codegen'; import { copyFunctionFile } from '../function_utils'; import { copyGen1Schema } from '../api_utils'; @@ -46,7 +46,7 @@ void describe('Codegen E2E tests', () => { beforeEach(async () => { const baseDir = process.env.INIT_CWD ?? process.cwd(); projRoot = await createNewProjectDir('codegen_e2e_flow_test', path.join(baseDir, '..', '..')); - projName = `test${Math.floor(Math.random() * 1000000)}`; + projName = `test${generateRandomShortId()}`; }); afterEach(async () => { @@ -60,10 +60,7 @@ void describe('Codegen E2E tests', () => { await runCodegenCommand(projRoot); await copyFunctionFile(projRoot, 'function', gen1FunctionName); await copyGen1Schema(projRoot, projName); - - // TODO: replace below line with correct package version await updatePackageDependency(projRoot, '@aws-amplify/backend'); - await npmInstall(projRoot); const gen2StackName = await runGen2SandboxCommand(projRoot); await assertAuthResource(projRoot, gen1UserPoolId, gen1ClientIds, gen1IdentityPoolId, gen1Region); @@ -80,10 +77,7 @@ void describe('Codegen E2E tests', () => { await runCodegenCommand(projRoot); await copyFunctionFile(projRoot, 'auth', gen1FunctionName); await removeErrorThrowsFromAuthResourceFile(projRoot); - - // TODO: replace below line with correct package version await updatePackageDependency(projRoot, '@aws-amplify/backend'); - await npmInstall(projRoot); await toggleSandboxSecrets(projRoot, 'set'); const gen2StackName = await runGen2SandboxCommand(projRoot); @@ -98,10 +92,7 @@ void describe('Codegen E2E tests', () => { projRoot, ); await runCodegenCommand(projRoot); - - // TODO: replace below line with correct package version await updatePackageDependency(projRoot, '@aws-amplify/backend'); - await npmInstall(projRoot); await runGen2SandboxCommand(projRoot); await assertAuthResource(projRoot, gen1UserPoolId, gen1ClientIds, gen1IdentityPoolId, gen1Region); diff --git a/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts b/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts index 6a9c91eed7..e1b521ed4e 100644 --- a/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts +++ b/packages/amplify-migration-e2e/src/__tests__/migration_templategen_e2e.test.ts @@ -1,6 +1,6 @@ import path from 'node:path'; import assert from 'node:assert'; -import { createNewProjectDir, npmInstall, deleteS3Bucket } from '@aws-amplify/amplify-e2e-core'; +import { createNewProjectDir, npmInstall, deleteS3Bucket, generateRandomShortId } from '@aws-amplify/amplify-e2e-core'; import { assertDefaultGen1Setup } from '../assertions'; import { setupAndPushDefaultGen1Project, runCodegenCommand, runGen2SandboxCommand, cleanupProjects } from '..'; import { copyFunctionFile } from '../function_utils'; @@ -18,8 +18,8 @@ void describe('Templategen E2E tests', () => { beforeEach(async () => { const baseDir = process.env.INIT_CWD ?? process.cwd(); projRoot = await createNewProjectDir('templategen_e2e_flow_test', path.join(baseDir, '..', '..')); - projName = `test${Math.floor(Math.random() * 1000000)}`; - bucketName = `testbucket${Math.floor(Math.random() * 1000000)}`; + projName = `test${generateRandomShortId()}`; + bucketName = `testbucket${generateRandomShortId()}`; }); afterEach(async () => { @@ -35,10 +35,7 @@ void describe('Templategen E2E tests', () => { await runCodegenCommand(projRoot); await copyFunctionFile(projRoot, 'function', gen1FunctionName); await copyGen1Schema(projRoot, projName); - - // TODO: replace below line with correct package version await updatePackageDependency(projRoot, '@aws-amplify/backend'); - await npmInstall(projRoot); const gen2StackName = await runGen2SandboxCommand(projRoot); assert(gen2StackName); diff --git a/packages/amplify-migration-e2e/src/envVariables.ts b/packages/amplify-migration-e2e/src/envVariables.ts index 64680b1314..f31d295dfa 100644 --- a/packages/amplify-migration-e2e/src/envVariables.ts +++ b/packages/amplify-migration-e2e/src/envVariables.ts @@ -1,9 +1,8 @@ -type EnvVariableAction = 'SET' | 'DELETE'; - -export function toggleEnvVariable(name: string, option: EnvVariableAction, value?: string) { - if (option === 'SET') { +export const envVariable = { + set: (name: string, value: string): void => { process.env[name] = value; - } else if (option === 'DELETE') { + }, + delete: (name: string): void => { delete process.env[name]; - } -} + }, +}; diff --git a/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts b/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts index 4909918333..bd6e49cd40 100644 --- a/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts +++ b/packages/amplify-migration-e2e/src/gen1ResourceDetailsFetcher.ts @@ -11,8 +11,7 @@ async function getGen1AuthResourceDetails(projRoot: string) { const { gen1UserPoolId } = await assertUserPool(gen1Meta, gen1Region); const { gen1IdentityPoolId } = await assertIdentityPool(gen1Meta, gen1Region); const { gen1ClientIds } = await assertUserPoolClients(gen1Meta, gen1Region); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [gen1ClientIdWeb, gen1ClientId] = gen1ClientIds; + const gen1ClientIdWeb = gen1ClientIds[0]; const gen1ResourceIds = [gen1UserPoolId, gen1IdentityPoolId, gen1ClientIdWeb]; const gen1ResourceDetails = await Promise.all([ diff --git a/packages/amplify-migration-e2e/src/templategen.ts b/packages/amplify-migration-e2e/src/templategen.ts index 751bbc9626..664e226c34 100644 --- a/packages/amplify-migration-e2e/src/templategen.ts +++ b/packages/amplify-migration-e2e/src/templategen.ts @@ -5,7 +5,7 @@ import * as fs from 'fs-extra'; import { getNpxPath, retry, RetrySettings } from '@aws-amplify/amplify-e2e-core'; import { runGen2SandboxCommand } from './sandbox'; import { getCommandsFromReadme } from './migrationReadmeParser'; -import { toggleEnvVariable } from './envVariables'; +import { envVariable } from './envVariables'; import { getGen1ResourceDetails } from './gen1ResourceDetailsFetcher'; import { getGen2ResourceDetails } from './gen2ResourceDetailsFetcher'; @@ -89,11 +89,11 @@ async function executeStep2(cwd: string, commands: string[]) { } async function executeStep3(cwd: string, commands: string[], bucketName: string) { - toggleEnvVariable('BUCKET_NAME', 'SET', bucketName); + envVariable.set('BUCKET_NAME', bucketName); await executeCommand(commands[1], cwd); await executeCommand(commands[2], cwd); const stackRefactorId = await executeCreateStackRefactorCallCommand(commands[3], cwd); - toggleEnvVariable('STACK_REFACTOR_ID', 'SET', stackRefactorId); + envVariable.set('STACK_REFACTOR_ID', stackRefactorId); await retry( () => assertRefactorStepCompletion(commands[5]), (status) => status.includes(STATUS_COMPLETE) && !status.includes(STATUS_IN_PROGRESS), @@ -107,6 +107,8 @@ async function executeStep3(cwd: string, commands: string[], bucketName: string) RETRY_CONFIG, (status) => status.includes(STATUS_FAILED), ); + envVariable.delete('BUCKET_NAME'); + envVariable.delete('STACK_REFACTOR_ID'); } async function assertStepCompletion(command: string) { @@ -134,9 +136,6 @@ export async function stackRefactor(projRoot: string, category: RefactorCategory await runGen2SandboxCommand(projRoot); - toggleEnvVariable('BUCKET_NAME', 'DELETE'); - toggleEnvVariable('STACK_REFACTOR_ID', 'DELETE'); - const { gen2ResourceIds, gen2ResourceDetails } = await getGen2ResourceDetails(projRoot, category); assert.deepEqual(gen1ResourceIds, gen2ResourceIds); assert.deepEqual(gen1ResourceDetails, gen2ResourceDetails);