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: remove OAuth prompt from pull and new env #6739

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ async function updateConfigOnEnvInit(context, category, service) {
if (hostedUIProviderMeta) {
currentEnvSpecificValues = getOAuthProviderKeys(currentEnvSpecificValues, resourceParams);
}

const isPullingOrNewEnv = context.input.command === 'pull' || context.input.command === 'env';
// don't ask for env_specific params when creating a new env or pulling
srvcMetaData.inputs = srvcMetaData.inputs.filter(
input => ENV_SPECIFIC_PARAMS.includes(input.key) && !Object.keys(currentEnvSpecificValues).includes(input.key),
input => ENV_SPECIFIC_PARAMS.includes(input.key) && !Object.keys(currentEnvSpecificValues).includes(input.key) && !isPullingOrNewEnv,
);

const serviceWalkthroughSrc = `${__dirname}/service-walkthroughs/${serviceWalkthroughFilename}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function authConfigPull(projectRootDirPath: string, params: { appId: stri
if (params[key]) pullCommand.push(...[`--${key}`, JSON.stringify(params[key])]);
});
const s = { ...defaultSettings, ...settings };
const { FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, GOOGLE_APP_ID, GOOGLE_APP_SECRET, AMAZON_APP_ID, AMAZON_APP_SECRET } = getSocialProviders();
return new Promise((resolve, reject) => {
spawn(util.getCLIPath(), pullCommand, { cwd: projectRootDirPath, stripColors: true })
.wait('Select the authentication method you want to use:')
Expand All @@ -82,18 +81,6 @@ export function authConfigPull(projectRootDirPath: string, params: { appId: stri
.sendLine(s.startCmd)
.wait('Do you plan on modifying this backend?')
.sendLine('y')
.wait('Enter your Facebook App ID for your OAuth flow:')
.sendLine(FACEBOOK_APP_ID)
.wait('Enter your Facebook App Secret for your OAuth flow:')
.sendLine(FACEBOOK_APP_SECRET)
.wait('Enter your Google Web Client ID for your OAuth flow:')
.sendLine(GOOGLE_APP_ID)
.wait('Enter your Google Web Client Secret for your OAuth flow:')
.sendLine(GOOGLE_APP_SECRET)
.wait('Enter your Amazon App ID for your OAuth flow:')
.sendLine(AMAZON_APP_ID)
.wait('Enter your Amazon App Secret for your OAuth flow:')
.sendLine(AMAZON_APP_SECRET)
.wait('Successfully pulled backend environment dev from the cloud.')
.run((err: Error) => {
if (!err) {
Expand Down
13 changes: 0 additions & 13 deletions packages/amplify-e2e-tests/src/environment/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export function pullEnvironment(cwd: string): Promise<void> {
}

export function addEnvironmentHostedUI(cwd: string, settings: { envName: string }): Promise<void> {
const { FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, GOOGLE_APP_ID, GOOGLE_APP_SECRET, AMAZON_APP_ID, AMAZON_APP_SECRET } = getSocialProviders();
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['env', 'add'], { cwd, stripColors: true })
.wait('Do you want to use an existing environment?')
Expand All @@ -147,18 +146,6 @@ export function addEnvironmentHostedUI(cwd: string, settings: { envName: string
.sendCarriageReturn()
.wait('Please choose the profile you want to use')
.sendCarriageReturn()
.wait('Enter your Facebook App ID for your OAuth flow:')
.sendLine(FACEBOOK_APP_ID)
.wait('Enter your Facebook App Secret for your OAuth flow:')
.sendLine(FACEBOOK_APP_SECRET)
.wait('Enter your Google Web Client ID for your OAuth flow:')
.sendLine(GOOGLE_APP_ID)
.wait('Enter your Google Web Client Secret for your OAuth flow:')
.sendLine(GOOGLE_APP_SECRET)
.wait('Enter your Amazon App ID for your OAuth flow:')
.sendLine(AMAZON_APP_ID)
.wait('Enter your Amazon App Secret for your OAuth flow:')
.sendLine(AMAZON_APP_SECRET)
.wait('Try "amplify add api" to create a backend API and then "amplify publish" to deploy everything')
.run((err: Error) => {
if (!err) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const path = require('path');
const fs = require('fs-extra');
const _ = require('lodash');
const hostedUIProviderCredsField = 'hostedUIProviderCreds';

function getResourceDirPath(context, category, resource) {
const { projectPath } = context.migrationInfo || context.amplify.getEnvInfo();
Expand Down Expand Up @@ -39,7 +41,11 @@ function loadResourceParameters(context, category, resource) {
parameters = context.amplify.readJsonFile(parametersFilePath);
}
const envSpecificParams = context.amplify.loadEnvResourceParameters(context, category, resource);
return { ...parameters, ...envSpecificParams };
let resourceParameters = { ...parameters, ...envSpecificParams };
if (category === 'auth' && parameters && parameters.hostedUI && !resourceParameters[hostedUIProviderCredsField]) {
resourceParameters = _.set(resourceParameters, hostedUIProviderCredsField, '[]');
}
return resourceParameters;
}

module.exports = {
Expand Down