Skip to content

Commit be08ce1

Browse files
authored
chore: handle Gen1 usage prompt during init (#897)
1 parent 45baf1d commit be08ce1

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

packages/amplify-codegen-e2e-core/src/init/initProjectHelper.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { nspawn as spawn, getCLIPath, singleSelect, addCITags } from '..';
2-
import { KEY_DOWN_ARROW, AmplifyFrontend } from '../utils';
2+
import { KEY_DOWN_ARROW, AmplifyFrontend, ExecutionContext } from '../utils';
33
import { amplifyRegions } from '../configure';
44
import { v4 as uuid } from 'uuid';
55

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

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

95+
export const confirmUsingGen1Amplify = (executionContext: ExecutionContext): ExecutionContext => {
96+
return executionContext
97+
.wait('Do you want to continue with Amplify Gen 1?')
98+
.sendConfirmYes()
99+
.wait('Why would you like to use Amplify Gen 1?')
100+
.sendCarriageReturn()
101+
}
102+
94103
export function initAndroidProjectWithProfile(cwd: string, settings: Object): Promise<void> {
95104
const s = { ...defaultSettings, ...settings };
96105

97106
addCITags(cwd);
98107

99108
return new Promise((resolve, reject) => {
100-
spawn(getCLIPath(), ['init'], {
109+
const chain = spawn(getCLIPath(), ['init'], {
101110
cwd,
102111
stripColors: true,
103112
env: {
104113
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
105114
},
106115
})
116+
confirmUsingGen1Amplify(chain)
107117
.wait('Enter a name for the project')
108118
.sendLine(s.name)
109119
.wait('Initialize the project with the above configuration?')
@@ -141,13 +151,14 @@ export function initIosProjectWithProfile(cwd: string, settings: Object): Promis
141151
addCITags(cwd);
142152

143153
return new Promise((resolve, reject) => {
144-
spawn(getCLIPath(), ['init'], {
154+
const chain = spawn(getCLIPath(), ['init'], {
145155
cwd,
146156
stripColors: true,
147157
env: {
148158
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
149159
},
150160
})
161+
confirmUsingGen1Amplify(chain)
151162
.wait('Enter a name for the project')
152163
.sendLine(s.name)
153164
.wait('Initialize the project with the above configuration?')
@@ -178,6 +189,7 @@ export function initFlutterProjectWithProfile(cwd: string, settings: Object): Pr
178189

179190
return new Promise((resolve, reject) => {
180191
let chain = spawn(getCLIPath(), ['init'], { cwd, stripColors: true })
192+
confirmUsingGen1Amplify(chain)
181193
.wait('Enter a name for the project')
182194
.sendLine(s.name)
183195
.wait('Initialize the project with the above configuration?')
@@ -228,6 +240,7 @@ export function initProjectWithAccessKey(
228240
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
229241
},
230242
})
243+
confirmUsingGen1Amplify(chain)
231244
.wait('Enter a name for the project')
232245
.sendLine(s.name)
233246
.wait('Initialize the project with the above configuration?')

packages/amplify-codegen-e2e-core/src/utils/pinpoint.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Pinpoint } from 'aws-sdk';
2-
import { getCLIPath, nspawn as spawn, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW } from '..';
2+
import { getCLIPath, nspawn as spawn, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW, confirmUsingGen1Amplify } from '..';
33
import _ from 'lodash';
44

55
const settings = {
@@ -80,6 +80,7 @@ export function initProjectForPinpoint(cwd: string): Promise<void> {
8080
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
8181
},
8282
})
83+
confirmUsingGen1Amplify(chain)
8384
.wait('Enter a name for the project')
8485
.sendLine(settings.name)
8586
.wait('Initialize the project with the above configuration?')

packages/amplify-codegen-e2e-tests/src/init-special-cases/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path';
2-
import { nspawn as spawn, getCLIPath, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW } from '@aws-amplify/amplify-codegen-e2e-core';
2+
import { nspawn as spawn, getCLIPath, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW, confirmUsingGen1Amplify } from '@aws-amplify/amplify-codegen-e2e-core';
33
import fs from 'fs-extra';
44
import os from 'os';
55

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

0 commit comments

Comments
 (0)