Skip to content

Commit f8b4137

Browse files
committed
feat(amplify-gen2-migration-e2e-system): add decommission step to
E2E migration flow Wire `gen2-migration decommission` into `App.migrate()` so the E2E system exercises the full migration lifecycle including Gen1 teardown. After the final `testSharedData()`, the flow checks out the Gen1 branch, runs `amplifyPullNonInteractive` to restore `amplify-meta.json` (which is gitignored and missing after branch switch), then runs `decommission` and verifies the Gen2 app still works via `testGen2()`. The `decommission()` method follows the same pattern as the existing `refactor()` — delegates to `runMigrationStep()` with no extra args. The `amplifyPullNonInteractive` call reads the appId from `team-provider-info.json` (which is tracked in git). Apps with `skipRefactor=true` are unaffected since the new calls live after the early return in `migrate()`. E2E runs confirmed the wiring works: `backend-only` and `store-locator` completed the full flow including decommission and post-decommission `testGen2`. --- Prompt: Add decommission step to E2E migration flow after refactor, followed by testGen2() to verify the Gen2 app is self-contained after Gen1 teardown. Run E2Es on all 9 apps in parallel.
1 parent e4bab36 commit f8b4137

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

  • packages/amplify-gen2-migration-e2e-system/src/core

packages/amplify-gen2-migration-e2e-system/src/core/app.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import execa from 'execa';
22
import fs from 'fs-extra';
33
import path from 'path';
44
import os from 'os';
5-
import { getCLIPath, initJSProjectWithProfile } from '@aws-amplify/amplify-e2e-core';
5+
import { getCLIPath, initJSProjectWithProfile, amplifyPullNonInteractive } from '@aws-amplify/amplify-e2e-core';
66
import { Logger, LogLevel } from './logger';
77
import { Git } from './git';
88
import * as snapshot from './snapshot';
@@ -276,6 +276,11 @@ export class App {
276276
await this.testGen2();
277277

278278
await this.testSharedData();
279+
280+
await this.git.checkout(this.gen1BranchName, false);
281+
await amplifyPullNonInteractive(this.targetAppPath, { appId: this.getAmplifyAppId(), envName: this.envName });
282+
await this.decommission();
283+
await this.testGen2();
279284
}
280285

281286
/**
@@ -301,6 +306,13 @@ export class App {
301306
this.removeGitignoreLine('amplify_outputs*');
302307
}
303308

309+
/**
310+
* Run `amplify gen2-migration decommission` to tear down the Gen1 environment.
311+
*/
312+
public async decommission(): Promise<void> {
313+
await this.runMigrationStep('decommission');
314+
}
315+
304316
/**
305317
* Run `amplify gen2-migration refactor`.
306318
*/
@@ -460,6 +472,16 @@ export class App {
460472
return JSON.parse(fs.readFileSync(configPath, 'utf-8')) as MigrationConfig;
461473
}
462474

475+
private getAmplifyAppId(): string {
476+
const tpiPath = path.join(this.targetAppPath, 'amplify', 'team-provider-info.json');
477+
const tpi = JSON.parse(fs.readFileSync(tpiPath, 'utf-8')) as Record<string, Record<string, Record<string, string>>>;
478+
const appId = tpi[this.envName]?.awscloudformation?.AmplifyAppId;
479+
if (!appId) {
480+
throw new Error(`AmplifyAppId not found in team-provider-info.json for env ${this.envName}`);
481+
}
482+
return appId;
483+
}
484+
463485
private async runAmplify(args: string[], options?: { stdio?: 'inherit' }): Promise<void> {
464486
const originalCwd = process.cwd();
465487
process.chdir(this.targetAppPath);

0 commit comments

Comments
 (0)