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: init override test fix #8768

Merged
merged 1 commit into from
Nov 10, 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
15 changes: 15 additions & 0 deletions packages/amplify-e2e-core/src/categories/hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ export function amplifyPushWithUpdate(cwd: string): Promise<void> {
});
}

export function amplifyPublishWithUpdate(cwd: string): Promise<void> {
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<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['publish'], { cwd, stripColors: true }).run((err: Error) => {
Expand Down
7 changes: 4 additions & 3 deletions packages/amplify-e2e-tests/src/__tests__/hostingPROD.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-e2e-tests/src/__tests__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down