Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"@types/jest": "^29.0.0",
"@types/js-yaml": "^4.0.0",
"@types/node": "^20.9.0",
"@types/yargs": "^17",
"@typescript-eslint/eslint-plugin": "^5.34.0",
"@typescript-eslint/parser": "^5.34.0",
"@yao-pkg/pkg": "^6.2.0",
Expand Down
13 changes: 11 additions & 2 deletions packages/amplify-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@
"@aws-cdk/cloudformation-diff": "~2.68.0",
"@aws-sdk/client-amplify": "^3.624.0",
"@aws-sdk/client-cloudformation": "^3.624.0",
"@aws-sdk/client-cloudwatch-events": "^3.624.0",
"@aws-sdk/client-cognito-identity": "^3.624.0",
"@aws-sdk/client-cognito-identity-provider": "^3.624.0",
"@aws-sdk/client-lambda": "^3.624.0",
"@aws-sdk/client-s3": "^3.624.0",
"@aws-sdk/client-sts": "^3.624.0",
"amplify-codegen": "^4.10.3",
"amplify-dotnet-function-runtime-provider": "2.1.6",
"amplify-go-function-runtime-provider": "2.3.53",
Expand All @@ -94,6 +99,7 @@
"hidefile": "^3.0.0",
"ini": "^1.3.5",
"inquirer": "^7.3.3",
"kleur": "^4.1.5",
"lodash": "^4.17.21",
"node-fetch": "^2.6.7",
"ora": "^4.0.3",
Expand All @@ -102,12 +108,15 @@
"semver": "^7.5.4",
"tar-fs": "^2.1.1",
"treeify": "^1.1.0",
"unzipper": "^0.10.14",
"update-notifier": "^5.1.0",
"uuid": "^8.3.2",
"which": "^2.0.2"
"which": "^2.0.2",
"yargs": "^17.7.2"
},
"devDependencies": {
"@aws-amplify/amplify-function-plugin-interface": "1.12.1",
"@aws-sdk/client-cloudwatch-events": "^3.624.0",
"@aws-sdk/client-cognito-identity-provider": "^3.624.0",
"@aws-sdk/client-lambda": "^3.624.0",
"@aws-sdk/client-s3": "^3.624.0",
Expand All @@ -128,7 +137,7 @@
"cloudform-types": "^4.2.0",
"jest": "^29.7.0",
"nock": "^13.5.0",
"typescript": "^4.9.5"
"typescript": "^5.4.5"
},
"jest": {
"collectCoverageFrom": [
Expand Down
15 changes: 14 additions & 1 deletion packages/amplify-cli/src/commands/gen2-migration/_step.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { $TSContext } from '@aws-amplify/amplify-cli-core';
import { Argv, CommandModule } from 'yargs';

export abstract class AmplifyMigrationStep implements CommandModule {
abstract readonly command: string;
abstract readonly describe: string;

export abstract class AmplifyMigrationStep {
constructor(private readonly context: $TSContext) {}

public abstract validate(): Promise<void>;

public abstract execute(): Promise<void>;

public abstract rollback(): Promise<void>;

builder = (yargs: Argv): Argv => {
return yargs.version(false);
};

handler = async (): Promise<void> => {
await this.validate();
await this.execute();
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Argv, CommandModule } from 'yargs';

export type Gen2CommandOptions = Record<string, never>;

/**
* Command that starts Gen2 migration.
*/
export class Gen2Command implements CommandModule {
/**
* @inheritDoc
*/
readonly command: string;

/**
* @inheritDoc
*/
readonly describe: string;

constructor(private readonly subCommands: CommandModule[]) {
this.command = 'migration';
this.describe = 'Migrates an Amplify Gen1 app to a Gen2 app';
}

builder = (yargs: Argv): Argv => {
return yargs.version(false).command(this.subCommands).strictCommands().recommendCommands();
};
handler = (): Promise<void> => {
// CommandModule requires handler implementation. But this is never called if top level command
// is configured to require subcommand.
// Help is printed by default in that case before ever attempting to call handler.
throw new Error(`Top level gen2 handler should never be called`);
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { CommandModule } from 'yargs';
import { Gen2Command } from './gen2_command';
import { AmplifyMigrationGenerateStep } from '../generate';
import { $TSContext } from '@aws-amplify/amplify-cli-core';

export const createGen2Command = (): CommandModule => {
const gen2GenerateCommand = new AmplifyMigrationGenerateStep({} as $TSContext);

return new Gen2Command([gen2GenerateCommand]);
};
Loading
Loading