Skip to content

Commit

Permalink
fix: hooks + hosting e2e (#8743)
Browse files Browse the repository at this point in the history
* fix: hooks + hosting e2e

* fix: address comments
  • Loading branch information
akshbhu authored Nov 8, 2021
1 parent 14c5241 commit 1fd787b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export * from './transform-resource';
export const transformRootStack = async (context: $TSContext): Promise<Template> => {
try {
const resourceName = 'awscloudformation';
return new AmplifyRootStackTransform(resourceName).transform(context);
const rootStack = new AmplifyRootStackTransform(resourceName);
return await rootStack.transform(context);
} catch (error) {
throw new Error(error);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { $TSContext, FeatureFlags, IAmplifyResource } from 'amplify-cli-core';
import { $TSContext, FeatureFlags, IAmplifyResource, JSONUtilities, pathManager } from 'amplify-cli-core';
import { printer } from 'amplify-prompts';
import { transformRootStack } from '.';
import * as fs from 'fs-extra';
import { prePushCfnTemplateModifier } from '../pre-push-cfn-processor/pre-push-cfn-modifier';
import * as path from 'path';
import { rootStackFileName } from '../push-resources';
import { storeRootStackTemplate } from '../initializer';
/**
*
* @param context
Expand All @@ -15,13 +20,13 @@ export async function transformResourceWithOverrides(context: $TSContext, resour
if (resource) {
const { transformCategoryStack } = await import(`@aws-amplify/amplify-category-${resource.category}`);
if (transformCategoryStack) {
return transformCategoryStack(context, resource);
return await transformCategoryStack(context, resource);
} else {
printer.info('Overrides functionality is not impleented for this category');
}
} else {
if (FeatureFlags.getBoolean('overrides.project')) {
await transformRootStack(context);
await storeRootStackTemplate(context);
}
}
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export async function run(context: $TSContext, resourceDefinition: $TSObject, re
try {
await updateCloudFormationNestedStack(context, nestedStack, resourcesToBeCreated, resourcesToBeUpdated);
if (FeatureFlags.getBoolean('Overrides.project')) {
storeRootStackTemplate(context, nestedStack);
await storeRootStackTemplate(context, nestedStack);
// if the only root stack updates, function is called with empty resources . this fn copies amplifyMeta and backend Config to #current-cloud-backend
context.amplify.updateamplifyMetaAfterPush([]);
}
Expand Down Expand Up @@ -710,8 +710,8 @@ async function updateCloudFormationNestedStack(
const backEndDir = pathManager.getBackendDirPath();
const projectRoot = pathManager.findProjectRoot();
const rootStackFilePath = path.join(pathManager.getRootStackBuildDirPath(projectRoot), rootStackFileName);
// deploy new nested stack to disk
JSONUtilities.writeJson(rootStackFilePath, nestedStack);
// deploy preprocess nested stack to disk
await storeRootStackTemplate(context, nestedStack);
const transformedStackPath = await preProcessCFNTemplate(rootStackFilePath);
const cfnItem = await new Cloudformation(context, generateUserAgentAction(resourcesToBeCreated, resourcesToBeUpdated));
const providerDirectory = path.normalize(path.join(backEndDir, providerName));
Expand Down Expand Up @@ -1185,7 +1185,7 @@ export async function generateAndUploadRootStack(context: $TSContext, destinatio
const projectDetails = context.amplify.getProjectDetails();
const nestedStack = await formNestedStack(context, projectDetails);

JSONUtilities.writeJson(destinationPath, nestedStack);
await storeRootStackTemplate(context, nestedStack);

// upload the nested stack
const s3Client = await S3.getInstance(context);
Expand Down

0 comments on commit 1fd787b

Please sign in to comment.