diff --git a/packages/amplify-cli/sample-headless-scripts/headless_pull.sh b/packages/amplify-cli/sample-headless-scripts/headless_pull.sh new file mode 100644 index 00000000000..c9737f3d0f9 --- /dev/null +++ b/packages/amplify-cli/sample-headless-scripts/headless_pull.sh @@ -0,0 +1,36 @@ +!/bin/bash + +set -e +IFS='|' + +REACTCONFIG="{\ +\"SourceDir\":\"src\",\ +\"DistributionDir\":\"build\",\ +\"BuildCommand\":\"npm run-script build\",\ +\"StartCommand\":\"npm run-script start\"\ +}" +AWSCLOUDFORMATIONCONFIG="{\ +\"configLevel\":\"project\",\ +\"useProfile\":true,\ +\"profileName\":\"default\",\ +}" +AMPLIFY="{\ +\"projectName\":\"headlessProjectName\",\ +\"defaultEditor\":\"code\"\ +}" +FRONTEND="{\ +\"frontend\":\"javascript\",\ +\"framework\":\"react\",\ +\"config\":$REACTCONFIG\ +}" +PROVIDERS="{\ +\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\ +}" + +amplify pull \ +--appId myappId \ +--envName mydevabc \ +--amplify $AMPLIFY \ +--frontend $FRONTEND \ +--providers $PROVIDERS \ +--noUpdateBackend diff --git a/packages/amplify-cli/src/attach-backend.ts b/packages/amplify-cli/src/attach-backend.ts index 405ef20a1cc..15a050108d9 100644 --- a/packages/amplify-cli/src/attach-backend.ts +++ b/packages/amplify-cli/src/attach-backend.ts @@ -75,8 +75,10 @@ const onSuccess = async (context: $TSContext): Promise => { await postPullCodegen(context); if (!inputParams.yes) { - const shouldKeepAmplifyDir = context.exeInfo.existingLocalEnvInfo?.noUpdateBackend - ? !context.exeInfo.existingLocalEnvInfo.noUpdateBackend + const noUpdateBackend = context.exeInfo.existingLocalEnvInfo?.noUpdateBackend || inputParams.noUpdateBackend; + + const shouldKeepAmplifyDir = noUpdateBackend + ? !noUpdateBackend : await context.amplify.confirmPrompt('Do you plan on modifying this backend?', true); if (shouldKeepAmplifyDir) {