Skip to content

Commit 6767445

Browse files
attilahkaustavghosh06
authored andcommitted
fix: #429 - Editor hanging bug (#2086)
1 parent 814722a commit 6767445

File tree

25 files changed

+130
-115
lines changed

25 files changed

+130
-115
lines changed

packages/amplify-category-analytics/lib/pinpoint-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const opn = require('opn');
1+
const open = require('open');
22
const constants = require('./constants');
33

44
function console(context) {
@@ -11,7 +11,7 @@ function console(context) {
1111
const { Id, Region } = pinpointApp;
1212
const consoleUrl =
1313
`https://${Region}.console.aws.amazon.com/pinpoint/home/?region=${Region}#/apps/${Id}/analytics/overview`;
14-
opn(consoleUrl, { wait: false });
14+
open(consoleUrl, { wait: false });
1515
} else {
1616
context.print.error('Neither analytics nor notifications is enabled in the cloud.');
1717
}

packages/amplify-category-analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"amplify-category-auth": "1.11.0",
88
"fs-extra": "^8.1.0",
99
"inquirer": "^6.5.1",
10-
"opn": "^5.3.0",
10+
"open": "^6.4.0",
1111
"uuid": "^3.3.2"
1212
},
1313
"scripts": {

packages/amplify-category-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"inquirer": "^6.5.1",
2222
"merge-graphql-schemas": "^1.7.0",
2323
"moment": "^2.24.0",
24-
"opn": "^5.3.0",
24+
"open": "^6.4.0",
2525
"ora": "^3.4.0",
2626
"uuid": "^3.3.2"
2727
},

packages/amplify-category-api/provider-utils/awscloudformation/service-walkthroughs/appSync-walkthrough.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const inquirer = require('inquirer');
22
const fs = require('fs-extra');
33
const path = require('path');
4-
const opn = require('opn');
4+
const open = require('open');
55

66
const category = 'api';
77
const serviceName = 'AppSync';
@@ -30,7 +30,7 @@ function openConsole(context) {
3030

3131
const consoleUrl =
3232
`https://console.aws.amazon.com/appsync/home?region=${Region}#/${GraphQLAPIIdOutput}/v1/queries`;
33-
opn(consoleUrl, { wait: false });
33+
open(consoleUrl, { wait: false });
3434
} else {
3535
context.print.error('AppSync API is not pushed in the cloud.');
3636
}

packages/amplify-category-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"inquirer": "^6.5.1",
2222
"lodash": "^4.17.15",
2323
"mime-types": "^2.1.24",
24-
"opn": "^5.3.0",
24+
"open": "^6.4.0",
2525
"ora": "^3.4.0",
2626
"promise-sequential": "^1.1.1",
2727
"uuid": "^3.3.2"

packages/amplify-category-auth/provider-utils/awscloudformation/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const inquirer = require('inquirer');
2-
const opn = require('opn');
2+
const open = require('open');
33
const _ = require('lodash');
44
const {
55
existsSync,
@@ -532,15 +532,15 @@ function getCognitoOutput(amplifyMeta) {
532532
async function openUserPoolConsole(context, region, userPoolId) {
533533
const userPoolConsoleUrl =
534534
`https://${region}.console.aws.amazon.com/cognito/users/?region=${region}#/pool/${userPoolId}/details`;
535-
await opn(userPoolConsoleUrl, { wait: false });
535+
await open(userPoolConsoleUrl, { wait: false });
536536
context.print.info('User Pool console:');
537537
context.print.success(userPoolConsoleUrl);
538538
}
539539

540540
async function openIdentityPoolConsole(context, region, identityPoolId) {
541541
const identityPoolConsoleUrl =
542542
`https://${region}.console.aws.amazon.com/cognito/pool/?region=${region}&id=${identityPoolId}`;
543-
await opn(identityPoolConsoleUrl, { wait: false });
543+
await open(identityPoolConsoleUrl, { wait: false });
544544
context.print.info('Identity Pool console:');
545545
context.print.success(identityPoolConsoleUrl);
546546
}

packages/amplify-category-hosting/__tests__/lib/S3AndCloudFront/s3Index.test.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
jest.mock('fs-extra');
2-
jest.mock('opn');
2+
jest.mock('open');
33

4-
jest.mock('../../../lib/S3AndCloudFront/configuration-manager');
4+
jest.mock('../../../lib/S3AndCloudFront/configuration-manager');
55
jest.mock('../../../lib/S3AndCloudFront/helpers/file-uploader');
66
jest.mock('../../../lib/S3AndCloudFront/helpers/cloudfront-manager');
77

88
const fs = require('fs-extra');
99
const path = require('path');
10-
const opn = require('opn');
10+
const open = require('open');
1111
const inquirer = require('inquirer');
1212
const mockirer = require('mockirer');
1313

@@ -74,17 +74,17 @@ describe('s3IndexModule', () => {
7474
}
7575
const mockAnswers = {
7676
environment: DEV
77-
};
77+
};
7878
let mockContext = {
7979
amplify: {
8080
pathManager: {
8181
getBackendDirPath: jest.fn(()=>{
82-
return 'mockBackendDirPath';
82+
return 'mockBackendDirPath';
8383
})
84-
},
84+
},
8585
updateamplifyMetaAfterResourceAdd: jest.fn(),
8686
getProjectMeta: jest.fn(()=>{
87-
return mockAmplifyMeta;
87+
return mockAmplifyMeta;
8888
}),
8989
readJsonFile: jest.fn(path => JSON.parse(fs.readFileSync(path))),
9090
},
@@ -105,64 +105,64 @@ describe('s3IndexModule', () => {
105105
parameters: {
106106
options: {}
107107
}
108-
};
108+
};
109109
beforeAll(() => {
110-
mockirer(inquirer, mockAnswers);
111-
fs.ensureDirSync = jest.fn();
110+
mockirer(inquirer, mockAnswers);
111+
fs.ensureDirSync = jest.fn();
112112
fs.existsSync = jest.fn(()=>{return true;})
113-
fs.writeFileSync = jest.fn();
113+
fs.writeFileSync = jest.fn();
114114
fs.readFileSync = jest.fn((filePath)=>{
115-
let result;
116-
filePath = path.normalize(filePath);
115+
let result;
116+
filePath = path.normalize(filePath);
117117
if(filePath.indexOf(templateFileName) > -1){
118118
if(filePath === INTERNAL_TEMPLATE_FILE_PATH){
119-
result = JSON.stringify(internalTemplateContents);
119+
result = JSON.stringify(internalTemplateContents);
120120
}else{
121-
result = JSON.stringify(mockTemplate);
121+
result = JSON.stringify(mockTemplate);
122122
}
123123
}else if(filePath.indexOf(parametersFileName)>-1){
124124
if(filePath === INTERNAL_PARAMETERS_FILE_PATH){
125125
result = JSON.stringify(internalParametersContents);
126126
}else{
127-
result = JSON.stringify(mockParameters);
127+
result = JSON.stringify(mockParameters);
128128
}
129129
}
130-
return result;
131-
});
130+
return result;
131+
});
132132
fileUPloader.run = jest.fn(()=>{return Promise.resolve(); });
133133
cloudFrontManager.invalidateCloudFront = jest.fn(()=>{return Promise.resolve(); });
134134

135-
});
135+
});
136136

137137
beforeEach(() => {
138-
fs.ensureDirSync.mockClear();
139-
fs.writeFileSync.mockClear();
138+
fs.ensureDirSync.mockClear();
139+
fs.writeFileSync.mockClear();
140140
});
141141

142142
test('enable', async () => {
143-
await s3IndexModule.enable(mockContext);
144-
expect(configManager.init).toBeCalled();
143+
await s3IndexModule.enable(mockContext);
144+
expect(configManager.init).toBeCalled();
145145
expect(mockContext.amplify.updateamplifyMetaAfterResourceAdd).toBeCalled();
146146
});
147147

148148
test('configure', async () => {
149-
await s3IndexModule.configure(mockContext);
150-
expect(configManager.configure).toBeCalled();
149+
await s3IndexModule.configure(mockContext);
150+
expect(configManager.configure).toBeCalled();
151151
});
152152

153153
test('publish', async () => {
154-
await s3IndexModule.publish(mockContext, {distributionDirPath: 'dist'});
155-
expect(fileUPloader.run).toBeCalled();
156-
expect(cloudFrontManager.invalidateCloudFront).toBeCalled();
157-
expect(opn).toBeCalled();
154+
await s3IndexModule.publish(mockContext, {distributionDirPath: 'dist'});
155+
expect(fileUPloader.run).toBeCalled();
156+
expect(cloudFrontManager.invalidateCloudFront).toBeCalled();
157+
expect(open).toBeCalled();
158158
});
159159

160160
test('console', async () => {
161-
await s3IndexModule.console(mockContext);
162-
expect(opn).toBeCalled();
161+
await s3IndexModule.console(mockContext);
162+
expect(open).toBeCalled();
163163
});
164164

165165
test('migrate', async () => {
166-
await s3IndexModule.migrate(mockContext);
166+
await s3IndexModule.migrate(mockContext);
167167
});
168-
})
168+
})

packages/amplify-category-hosting/lib/S3AndCloudFront/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const fs = require('fs-extra');
22
const inquirer = require('inquirer');
33
const path = require('path');
4-
const opn = require('opn');
4+
const open = require('open');
55
const chalk = require('chalk');
66
const configManager = require('./configuration-manager');
77
const fileUPloader = require('./helpers/file-uploader');
@@ -130,7 +130,7 @@ function publish(context, args) {
130130
const { WebsiteURL } = context.exeInfo.serviceMeta.output;
131131
context.print.info('Your app is published successfully.');
132132
context.print.info(chalk.green(WebsiteURL));
133-
opn(WebsiteURL, { wait: false });
133+
open(WebsiteURL, { wait: false });
134134
}
135135
})
136136
.catch((e) => {
@@ -145,7 +145,7 @@ function console(context) {
145145
const consoleUrl =
146146
`https://s3.console.aws.amazon.com/s3/buckets/${bucket}/?region=${region}&tab=overview`;
147147
context.print.info(chalk.green(consoleUrl));
148-
opn(consoleUrl, { wait: false });
148+
open(consoleUrl, { wait: false });
149149
}
150150

151151
async function migrate(context) {

packages/amplify-category-hosting/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"mime-types": "^2.1.24",
1919
"minimatch": "^3.0.4",
2020
"moment": "^2.24.0",
21-
"opn": "^5.3.0",
21+
"open": "^6.4.0",
2222
"ora": "^3.4.0",
2323
"promise-sequential": "^1.1.1"
2424
},

packages/amplify-category-notifications/lib/pinpoint-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const opn = require('opn');
1+
const open = require('open');
22
const ora = require('ora');
33
const inquirer = require('inquirer');
44

@@ -221,7 +221,7 @@ function console(context) {
221221
const { Id, Region } = pinpointApp;
222222
const consoleUrl =
223223
`https://${Region}.console.aws.amazon.com/pinpoint/home/?region=${Region}#/apps/${Id}/settings`;
224-
opn(consoleUrl, { wait: false });
224+
open(consoleUrl, { wait: false });
225225
} else {
226226
context.print.error('Neither notifications nor analytics is enabled in the cloud.');
227227
}

0 commit comments

Comments
 (0)