diff --git a/packages/amplify-e2e-core/src/categories/hosting.ts b/packages/amplify-e2e-core/src/categories/hosting.ts index cc7b13c5ec2..bea05eefecc 100644 --- a/packages/amplify-e2e-core/src/categories/hosting.ts +++ b/packages/amplify-e2e-core/src/categories/hosting.ts @@ -129,6 +129,21 @@ export function amplifyPushWithUpdate(cwd: string): Promise { }); } +export function amplifyPublishWithUpdate(cwd: string): Promise { + return new Promise((resolve, reject) => { + spawn(getCLIPath(), ['publish'], { cwd, stripColors: true }) + .wait('Are you sure you want to continue?') + .sendCarriageReturn() + .run((err: Error) => { + if (!err) { + resolve(); + } else { + reject(err); + } + }); + }); +} + export function amplifyPublishWithoutUpdate(cwd: string): Promise { return new Promise((resolve, reject) => { spawn(getCLIPath(), ['publish'], { cwd, stripColors: true }).run((err: Error) => { diff --git a/packages/amplify-e2e-tests/src/__tests__/hostingPROD.test.ts b/packages/amplify-e2e-tests/src/__tests__/hostingPROD.test.ts index a090e62d245..1824a422509 100644 --- a/packages/amplify-e2e-tests/src/__tests__/hostingPROD.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/hostingPROD.test.ts @@ -1,5 +1,5 @@ import { CloudFront } from 'aws-sdk'; -import { amplifyPublishWithoutUpdate, createReactTestProject, resetBuildCommand } from 'amplify-e2e-core'; +import { amplifyPublishWithoutUpdate, amplifyPublishWithUpdate, createReactTestProject, resetBuildCommand } from 'amplify-e2e-core'; import { initJSProjectWithProfile, deleteProject, deleteS3Bucket } from 'amplify-e2e-core'; import { addPRODHosting, removePRODCloudFront, removeHosting, amplifyPushWithoutCodegen } from 'amplify-e2e-core'; @@ -45,7 +45,8 @@ describe('amplify add hosting', () => { it('publish successfully', async () => { let error; try { - await amplifyPublishWithoutUpdate(projRoot); + // root stack updated + await amplifyPublishWithUpdate(projRoot); } catch (err) { error = err; } @@ -56,7 +57,7 @@ describe('amplify add hosting', () => { const currentBuildCommand = resetBuildCommand(projRoot, ''); let error; try { - await amplifyPublishWithoutUpdate(projRoot); + await amplifyPublishWithUpdate(projRoot); } catch (err) { error = err; } diff --git a/packages/amplify-e2e-tests/src/__tests__/init.test.ts b/packages/amplify-e2e-tests/src/__tests__/init.test.ts index 7ba2f0c16f8..b1ad904e980 100644 --- a/packages/amplify-e2e-tests/src/__tests__/init.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/init.test.ts @@ -29,8 +29,8 @@ describe('amplify init', () => { }); afterEach(async () => { - // await deleteProject(projRoot); - // deleteProjectDir(projRoot); + await deleteProject(projRoot); + deleteProjectDir(projRoot); }); it('should pull sandbox and download schema', async () => { diff --git a/packages/amplify-provider-awscloudformation/src/initializer.ts b/packages/amplify-provider-awscloudformation/src/initializer.ts index dcc02e4822a..11bea2b5197 100644 --- a/packages/amplify-provider-awscloudformation/src/initializer.ts +++ b/packages/amplify-provider-awscloudformation/src/initializer.ts @@ -183,9 +183,9 @@ export const storeRootStackTemplate = async (context: $TSContext, template?: Tem // generate template again as the folder structure was not created when root stack was initiaized if (template === undefined) { template = await transformRootStack(context); - await prePushCfnTemplateModifier(template); } - + // apply Modifiers + await prePushCfnTemplateModifier(template); // RootStack deployed to backend/awscloudformation/build const projectRoot = pathManager.findProjectRoot(); const rootStackBackendBuildDir = pathManager.getRootStackBuildDirPath(projectRoot); diff --git a/packages/amplify-provider-awscloudformation/src/override-manager/transform-resource.ts b/packages/amplify-provider-awscloudformation/src/override-manager/transform-resource.ts index 9f2d0e2eb4b..945800d5644 100644 --- a/packages/amplify-provider-awscloudformation/src/override-manager/transform-resource.ts +++ b/packages/amplify-provider-awscloudformation/src/override-manager/transform-resource.ts @@ -22,9 +22,14 @@ export async function transformResourceWithOverrides(context: $TSContext, resour printer.info('Overrides functionality is not impleented for this category'); } } else { - if (FeatureFlags.getBoolean('overrides.project')) { - await storeRootStackTemplate(context); - } + const template = await transformRootStack(context); + await prePushCfnTemplateModifier(template); + // RootStack deployed to backend/awscloudformation/build + const projectRoot = pathManager.findProjectRoot(); + const rootStackBackendBuildDir = pathManager.getRootStackBuildDirPath(projectRoot); + fs.ensureDirSync(rootStackBackendBuildDir); + const rootStackBackendFilePath = path.join(rootStackBackendBuildDir, rootStackFileName); + JSONUtilities.writeJson(rootStackBackendFilePath, template); } } catch (err) { return;