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

fix: hooks + hosting e2e #8743

Merged
merged 2 commits into from
Nov 8, 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 @@ -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