Skip to content

Commit

Permalink
fix(amplify-cli): promise not resolving in lts/dubnium (#1028)
Browse files Browse the repository at this point in the history
* fix(cli): resolve proper promise chain

promise not awaited, resulting aws-exports not generating.

fix #1051

* Update remove.js
  • Loading branch information
roychoo authored and UnleashedMind committed Mar 22, 2019
1 parent cf8b0be commit 8a966be
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
if (channelName) {
await pinpointHelper.ensurePinpointApp(context);
await notificationManager.enableChannel(context, channelName);
multiEnvManager.writeData(context);
await multiEnvManager.writeData(context);
}
} else {
context.print.info('All the available notification channels have already been enabled.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {

await pinpointHelper.ensurePinpointApp(context);
await notificationManager.configureChannel(context, channelName);
multiEnvManager.writeData(context);
await multiEnvManager.writeData(context);

return context;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
if (channelName !== PinpointApp) {
await pinpointHelper.ensurePinpointApp(context);
await notificationManager.disableChannel(context, channelName);
multiEnvManager.writeData(context);
await multiEnvManager.writeData(context);
} else if (pinpointHelper.isAnalyticsAdded(context)) {
context.print.error('Execution aborted.');
context.print.info('You have an analytics resource in your backend tied to the Amazon Pinpoint resource');
Expand All @@ -54,7 +54,7 @@ module.exports = {
if (answer.deletePinpointApp) {
await pinpointHelper.deletePinpointApp(context);
context.print.info('The Pinpoint application has been successfully deleted.');
multiEnvManager.writeData(context);
await multiEnvManager.writeData(context);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function initEnv(context) {
if (pinpointNotificationsMeta) {
// remove this line after init and init-push are separated.
await pushChanges(context, pinpointNotificationsMeta);
writeData(context);
await writeData(context);
}
return pinpointNotificationsMeta;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ async function pushChanges(context, pinpointNotificationsMeta) {
await sequential(tasks);
}

function writeData(context) {
async function writeData(context) {
const categoryMeta = context.exeInfo.amplifyMeta[constants.CategoryName];
let pinpointMeta;
if (categoryMeta) {
Expand Down Expand Up @@ -213,7 +213,7 @@ function writeData(context) {
writeBackendConfig(pinpointMeta, context.amplify.pathManager.getCurrentBackendConfigFilePath());
writeAmplifyMeta(categoryMeta, context.amplify.pathManager.getAmplifyMetaFilePath());
writeAmplifyMeta(categoryMeta, context.amplify.pathManager.getCurentAmplifyMetaFilePath());
context.amplify.onCategoryOutputsChange(context);
await context.amplify.onCategoryOutputsChange(context);
}

function writeTeamProviderInfo(pinpointMeta, context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const fs = require('fs');
const pathManager = require('./path-manager');
const { getResourceOutputs } = require('./get-resource-outputs');

function onCategoryOutputsChange(context) {
async function onCategoryOutputsChange(context) {
const projectConfigFilePath = pathManager.getProjectConfigFilePath();
const projectConfig = JSON.parse(fs.readFileSync(projectConfigFilePath));
if (projectConfig.frontend) {
const frontendPlugins = context.amplify.getFrontendPlugins(context);
const frontendHandlerModule =
require(frontendPlugins[projectConfig.frontend]);
frontendHandlerModule.createFrontendConfigs(context, getResourceOutputs());
await frontendHandlerModule.createFrontendConfigs(context, getResourceOutputs());
}

const pluginNames = Object.keys(context.amplify.getCategoryPlugins(context));
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-cli/src/lib/initialize-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function initializeEnv(context) {
await sequential(providerPushTasks);
}
// Generate AWS exports/configurtion file
context.amplify.onCategoryOutputsChange(context);
await context.amplify.onCategoryOutputsChange(context);
context.print.success('Initialized your environment successfully.');
} catch (e) {
spinner.fail('There was an error initializing your environment.');
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-codegen/src/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function add(context, apiId = null) {
apiDetails.apiKey = await selectAPIKey(apiDetails.apiKeys);
}

updateAmplifyMeta(context, apiDetails);
await updateAmplifyMeta(context, apiDetails);
break;
} catch (e) {
apiDetailSpinner.fail();
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-codegen/src/utils/updateAmplifyMeta.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

module.exports = (context, apiDetails) => {
module.exports = async (context, apiDetails) => {
const fs = context.filesystem;

const appsyncMetadata = {
Expand Down Expand Up @@ -35,6 +35,6 @@ module.exports = (context, apiDetails) => {
currentAmplifyMeta.api[apiDetails.name] = appsyncMetadata;
fs.write(currentAmplifyMetaFilePath, currentAmplifyMeta);

context.amplify.onCategoryOutputsChange(context);
await context.amplify.onCategoryOutputsChange(context);
context.print.success(`Successfully added API ${apiDetails.name} to your Amplify project`);
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function createAmplifyConfig(context, amplifyResources) {
}
}

function createAWSExports(context, amplifyResources) {
async function createAWSExports(context, amplifyResources) {
const { serviceResourceMapping } = amplifyResources;
const configOutput = {};

Expand Down Expand Up @@ -60,11 +60,11 @@ function createAWSExports(context, amplifyResources) {
default: break;
}
});
generateAWSExportsFile(context, configOutput);
await generateAWSExportsFile(context, configOutput);
return context;
}

function generateAWSExportsFile(context, configOutput) {
async function generateAWSExportsFile(context, configOutput) {
const { amplify } = context;
const pluginDir = __dirname;
const projectPath = context.exeInfo ?
Expand All @@ -90,7 +90,7 @@ function generateAWSExportsFile(context, configOutput) {

// copy over the files
const forceOverwrite = true;
return amplify.copyBatch(context, copyJobs, options, forceOverwrite);
await amplify.copyBatch(context, copyJobs, options, forceOverwrite);
}

function getCognitoConfig(cognitoResources, projectRegion) {
Expand Down

0 comments on commit 8a966be

Please sign in to comment.