Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add init prompts for Gen2 #13849

Merged
merged 50 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
592abd1
feat: add warning to init
Jul 9, 2024
d0a26e0
feat: add prompt to init
Jul 10, 2024
365eab4
feat: only prompt on new project
Jul 10, 2024
631a252
feat: add guide to Gen2
Jul 10, 2024
c0c4e3e
refactor: change to use process exit
Jul 10, 2024
5d53a55
Update packages/amplify-cli/src/init-steps/preInitMigrationWarning.ts
0618 Jul 10, 2024
49a9f01
refactor: rename to gen2Recommendation
Jul 10, 2024
0d3a057
refactor: combine gen2Recommendation to preInitSetup
Jul 10, 2024
cadc06f
feat: remove goodbye message
Jul 10, 2024
39f8b34
test: fix init.test
Jul 10, 2024
e4330c3
test: add unit test for preInitSetup
Jul 10, 2024
08e896a
chore: rename to getPreInitSetup
Jul 10, 2024
22cff01
feat: change verbiage
Jul 10, 2024
85cd59a
chore: update unit test
Jul 10, 2024
f12fe7a
feat: add whyContinueWithGen1 to stack metadata
Jul 10, 2024
bad9430
fix: verify verify_versions_match
Jul 11, 2024
ad48c8d
fix: verify verify_versions_match
Jul 11, 2024
2378a19
feat: bump versions
Jul 11, 2024
ad3ab5e
feat: bump versions
Jul 12, 2024
cac0e9d
feat: bump versions
Jul 12, 2024
dfba32e
chore: rename to recommendGen2
Jul 12, 2024
aa1850c
chore: rename to recommendGen2 in test
Jul 12, 2024
fba0211
revert .sh format
Jul 15, 2024
1e8e25b
chore: rename and not export preInitSetup
Jul 15, 2024
3d1bb59
fix: export gen2Recommandation and preInitSetup for test
Jul 15, 2024
c20f939
Merge branch 'dev' into add-init-promps
Aug 5, 2024
7ecde5c
fix: set inital answer for pick
Aug 7, 2024
e67d7cc
Merge branch 'dev' into add-init-promps
Aug 8, 2024
d8fa624
Revert "fix: set inital answer for pick"
Aug 8, 2024
1d671cf
Revert "Revert "fix: set inital answer for pick""
Aug 8, 2024
6fc0979
fix: preInitSetup.test
Aug 8, 2024
71b204c
fix: e2e test by adding isCI
Aug 12, 2024
20157e7
chore: upgrade node-pty
Aug 13, 2024
203d1ca
Merge branch 'dev' into add-init-promps
Aug 14, 2024
66ae2a1
Revert "fix: e2e test by adding isCI"
Aug 14, 2024
d94ed5e
test: add prompt to e2e
Aug 14, 2024
ea7b9de
fix: set default value for whyContinueWithGen1
Aug 14, 2024
faa0859
fix: projectConfig undefined and remove default choice
Aug 17, 2024
c540b9c
fix: preInitSetup.test.ts
Aug 17, 2024
bbeec57
fix: add default choice back
Aug 17, 2024
bb73c4b
fix: remove prompts from migration test
Aug 19, 2024
13b81af
test: move new prompt from v12
Sep 2, 2024
eeb6f71
test: move new prompt from initJSProjectWithProfile
Sep 3, 2024
4e7fd0c
Revert "test: move new prompt from initJSProjectWithProfile"
Sep 3, 2024
57342e6
test: move new prompts from initJSProjectWithProfile
Sep 3, 2024
9d92f56
chore: change recommendGen2
Sep 8, 2024
7548ef8
test: fix preInitSetup unit test
Sep 8, 2024
fc21886
test: add includeGen2RecommendationPrompt
Sep 8, 2024
fd5f0d7
test: add includeGen2RecommendationPrompt to migration-2
Sep 8, 2024
808c795
test: remove prompts from initAndroidProjectWithProfileV12
Sep 8, 2024
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
3 changes: 2 additions & 1 deletion packages/amplify-cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { initProviders } from '../init-steps/s2-initProviders';
import { scaffoldProjectHeadless } from '../init-steps/s8-scaffoldHeadless';
import { onHeadlessSuccess, onSuccess } from '../init-steps/s9-onSuccess';
import { checkForNestedProject } from './helpers/projectUtils';
import { gen2Recommendation } from '../init-steps/gen2Recommendation';

const constructExeInfo = (context: $TSContext): void => {
context.exeInfo = {
Expand All @@ -22,7 +23,7 @@ const constructExeInfo = (context: $TSContext): void => {
const runStrategy = (quickstart: boolean) =>
quickstart
? [preInitSetup, analyzeProjectHeadless, scaffoldProjectHeadless, onHeadlessSuccess]
: [preInitSetup, analyzeProject, initFrontend, initProviders, onSuccess, postInitSetup];
: [gen2Recommendation, preInitSetup, analyzeProject, initFrontend, initProviders, onSuccess, postInitSetup];

/**
* entry point for the init command
Expand Down
34 changes: 34 additions & 0 deletions packages/amplify-cli/src/init-steps/gen2Recommendation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { $TSContext } from '@aws-amplify/amplify-cli-core';
import { printer, prompter } from '@aws-amplify/amplify-prompts';
import { isNewProject } from './s0-analyzeProject';

export const gen2Recommendation = async (context: $TSContext): Promise<$TSContext> => {
if (!isNewProject(context)) {
return context;
}
printer.warn(
`AWS Amplify recommends using Amplify Gen 2 for new projects. Learn how to get started at https://docs.amplify.aws/react/start/quickstart/`,
awsluja marked this conversation as resolved.
Show resolved Hide resolved
);

const continueWithGen1 = await prompter.confirmContinue('Do you want to continue with Amplify Gen 1?');

if (!continueWithGen1) {
printer.info('Exiting the Amplify Gen1 project creation flow. 👋');
printer.blankLine();
printer.info('To create a new Amplify Gen2 project, 🫱 https://docs.amplify.aws/');
process.exit(0);
}

const whyContinueWithGen1 = await prompter.pick('Why would you like to use Amplify Gen 1?', [
'I am a current Gen 1 user',
'Gen 2 is missing features I need from Gen 1',
'I find the Gen 1 CLI easier to use',
'Prefer not to answer',
]);

context.exeInfo.projectConfig = {
whyContinueWithGen1,
};

return context;
};
3 changes: 2 additions & 1 deletion packages/amplify-cli/src/init-steps/s0-analyzeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const analyzeProject = async (context: $TSContext): Promise<$TSContext> =
const setProjectConfig = (context: $TSContext, projectName: string): void => {
context.exeInfo.isNewProject = isNewProject(context);
context.exeInfo.projectConfig = {
...context.exeInfo.projectConfig,
awsluja marked this conversation as resolved.
Show resolved Hide resolved
projectName,
version: amplifyCLIConstants.CURRENT_PROJECT_CONFIG_VERSION,
};
Expand Down Expand Up @@ -325,7 +326,7 @@ const isNewEnv = (envName: string): boolean => {
return !allEnvs.includes(envName);
};

const isNewProject = (context: $TSContext): boolean => {
export const isNewProject = (context: $TSContext): boolean => {
let newProject = true;
const projectPath = process.cwd();
const projectConfigFilePath = context.amplify.pathManager.getProjectConfigFilePath(projectPath);
Expand Down
Loading