Skip to content

Commit

Permalink
chore: handle Gen1 usage prompt during init (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
phani-srikar authored Oct 15, 2024
1 parent 45baf1d commit be08ce1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
19 changes: 16 additions & 3 deletions packages/amplify-codegen-e2e-core/src/init/initProjectHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { nspawn as spawn, getCLIPath, singleSelect, addCITags } from '..';
import { KEY_DOWN_ARROW, AmplifyFrontend } from '../utils';
import { KEY_DOWN_ARROW, AmplifyFrontend, ExecutionContext } from '../utils';
import { amplifyRegions } from '../configure';
import { v4 as uuid } from 'uuid';

Expand Down Expand Up @@ -44,6 +44,7 @@ export function initJSProjectWithProfile(cwd: string, settings: Object = {}): Pr

return new Promise((resolve, reject) => {
const chain = spawn(getCLIPath(), cliArgs, { cwd, stripColors: true, env, disableCIDetection: s.disableCIDetection })
confirmUsingGen1Amplify(chain)
.wait('Enter a name for the project')
.sendLine(s.name)
.wait('Initialize the project with the above configuration?')
Expand Down Expand Up @@ -91,19 +92,28 @@ export function initJSProjectWithProfile(cwd: string, settings: Object = {}): Pr
});
}

export const confirmUsingGen1Amplify = (executionContext: ExecutionContext): ExecutionContext => {
return executionContext
.wait('Do you want to continue with Amplify Gen 1?')
.sendConfirmYes()
.wait('Why would you like to use Amplify Gen 1?')
.sendCarriageReturn()
}

export function initAndroidProjectWithProfile(cwd: string, settings: Object): Promise<void> {
const s = { ...defaultSettings, ...settings };

addCITags(cwd);

return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['init'], {
const chain = spawn(getCLIPath(), ['init'], {
cwd,
stripColors: true,
env: {
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
},
})
confirmUsingGen1Amplify(chain)
.wait('Enter a name for the project')
.sendLine(s.name)
.wait('Initialize the project with the above configuration?')
Expand Down Expand Up @@ -141,13 +151,14 @@ export function initIosProjectWithProfile(cwd: string, settings: Object): Promis
addCITags(cwd);

return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['init'], {
const chain = spawn(getCLIPath(), ['init'], {
cwd,
stripColors: true,
env: {
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
},
})
confirmUsingGen1Amplify(chain)
.wait('Enter a name for the project')
.sendLine(s.name)
.wait('Initialize the project with the above configuration?')
Expand Down Expand Up @@ -178,6 +189,7 @@ export function initFlutterProjectWithProfile(cwd: string, settings: Object): Pr

return new Promise((resolve, reject) => {
let chain = spawn(getCLIPath(), ['init'], { cwd, stripColors: true })
confirmUsingGen1Amplify(chain)
.wait('Enter a name for the project')
.sendLine(s.name)
.wait('Initialize the project with the above configuration?')
Expand Down Expand Up @@ -228,6 +240,7 @@ export function initProjectWithAccessKey(
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
},
})
confirmUsingGen1Amplify(chain)
.wait('Enter a name for the project')
.sendLine(s.name)
.wait('Initialize the project with the above configuration?')
Expand Down
3 changes: 2 additions & 1 deletion packages/amplify-codegen-e2e-core/src/utils/pinpoint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Pinpoint } from 'aws-sdk';
import { getCLIPath, nspawn as spawn, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW } from '..';
import { getCLIPath, nspawn as spawn, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW, confirmUsingGen1Amplify } from '..';
import _ from 'lodash';

const settings = {
Expand Down Expand Up @@ -80,6 +80,7 @@ export function initProjectForPinpoint(cwd: string): Promise<void> {
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
},
})
confirmUsingGen1Amplify(chain)
.wait('Enter a name for the project')
.sendLine(settings.name)
.wait('Initialize the project with the above configuration?')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { nspawn as spawn, getCLIPath, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW } from '@aws-amplify/amplify-codegen-e2e-core';
import { nspawn as spawn, getCLIPath, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW, confirmUsingGen1Amplify } from '@aws-amplify/amplify-codegen-e2e-core';
import fs from 'fs-extra';
import os from 'os';

Expand Down Expand Up @@ -52,6 +52,7 @@ async function initWorkflow(cwd: string, settings: { accessKeyId: string; secret
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
},
})
confirmUsingGen1Amplify(chain)
.wait('Enter a name for the project')
.sendCarriageReturn()
.wait('Initialize the project with the above configuration?')
Expand Down

0 comments on commit be08ce1

Please sign in to comment.