diff --git a/packages/amplify-gen2-migration-e2e-system/src/core/app.ts b/packages/amplify-gen2-migration-e2e-system/src/core/app.ts index 55c7f34beef..428c40efdf2 100644 --- a/packages/amplify-gen2-migration-e2e-system/src/core/app.ts +++ b/packages/amplify-gen2-migration-e2e-system/src/core/app.ts @@ -2,7 +2,7 @@ import execa from 'execa'; import fs from 'fs-extra'; import path from 'path'; import os from 'os'; -import { getCLIPath, initJSProjectWithProfile } from '@aws-amplify/amplify-e2e-core'; +import { getCLIPath, initJSProjectWithProfile, amplifyPullNonInteractive } from '@aws-amplify/amplify-e2e-core'; import { Logger, LogLevel } from './logger'; import { Git } from './git'; import * as snapshot from './snapshot'; @@ -276,6 +276,11 @@ export class App { await this.testGen2(); await this.testSharedData(); + + await this.git.checkout(this.gen1BranchName, false); + await amplifyPullNonInteractive(this.targetAppPath, { appId: this.getAmplifyAppId(), envName: this.envName }); + await this.decommission(); + await this.testGen2(); } /** @@ -301,6 +306,13 @@ export class App { this.removeGitignoreLine('amplify_outputs*'); } + /** + * Run `amplify gen2-migration decommission` to tear down the Gen1 environment. + */ + public async decommission(): Promise { + await this.runMigrationStep('decommission'); + } + /** * Run `amplify gen2-migration refactor`. */ @@ -460,6 +472,16 @@ export class App { return JSON.parse(fs.readFileSync(configPath, 'utf-8')) as MigrationConfig; } + private getAmplifyAppId(): string { + const tpiPath = path.join(this.targetAppPath, 'amplify', 'team-provider-info.json'); + const tpi = JSON.parse(fs.readFileSync(tpiPath, 'utf-8')) as Record>>; + const appId = tpi[this.envName]?.awscloudformation?.AmplifyAppId; + if (!appId) { + throw new Error(`AmplifyAppId not found in team-provider-info.json for env ${this.envName}`); + } + return appId; + } + private async runAmplify(args: string[], options?: { stdio?: 'inherit' }): Promise { const originalCwd = process.cwd(); process.chdir(this.targetAppPath);