Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.

Commit e1f9aee

Browse files
COMPARR-4315: refactoring and srvHost (#295)
* refactor: user driver's srvHost * build: bump versions of dependencies
1 parent bfc0cc5 commit e1f9aee

20 files changed

+947
-707
lines changed

.eslintrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,15 @@
77
"ecmaVersion": 2018,
88
"sourceType": "module"
99
},
10-
"extends": ["mongodb-js/node"]
10+
"extends": ["mongodb-js/node"],
11+
"rules": {
12+
"space-before-function-paren": [
13+
"error",
14+
{
15+
"anonymous": "always",
16+
"named": "never",
17+
"asyncArrow": "never"
18+
}
19+
]
20+
}
1121
}
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
name: Bug Report
33
about: Create a report to help us improve
4-
title: Bug Report:
4+
title: Bug Report
55
---
6+
67
<!--- Please note this repository's Issue Tracker is not being watched.
78
Issues are instead being tracked in our public Jira project:
89
https://jira.mongodb.org/projects/COMPASS/summary
@@ -12,25 +13,31 @@ https://jira.mongodb.org/projects/COMPASS/summary
1213
## Bug Report
1314

1415
#### Current Behavior
16+
1517
<!--- A clear and concise description of the behavior -->
1618

1719
#### Code/Gist
20+
1821
<!--- Any code, gist links, or repo links you have available that would be helpful for debugging -->
1922

23+
#### Expected Behavior/Code
2024

21-
#### Expected behavior/code
2225
<!--- A clear and concise description of what you expected to happen (or code). -->
2326

2427
#### Environment
28+
2529
<!--
2630
- node.js / npm versions: [e.g. node v10.3.0 / npm 6.7.1]
2731
- OS: [e.g. OSX 10.13.4, Windows 10]
2832
-->
33+
2934
- node.js / npm versions:
30-
- OS:
35+
- OS:
3136

3237
#### Possible Solution
38+
3339
<!--- Only if you have suggestions on a fix for the bug -->
3440

35-
#### Additional context/Screenshots
36-
<!--- Add any other context about the problem here. If applicable, add screenshots to help explain. -->>
41+
#### Additional Context/Screenshots
42+
43+
<!--- Add any other context about the problem here. If applicable, add screenshots to help explain. -->

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Feature Request
33
about: Suggest an idea for this project
4-
title: Feature Request:
4+
title: Feature Request
55
---
66

77
<!--- Please note this repository's Issue Tracker is not being watched.
@@ -14,10 +14,13 @@ https://jira.mongodb.org/projects/COMPASS/summary
1414
## Feature Request
1515

1616
## Detailed Description
17+
1718
<!--- Provide a detailed description of the change or addition you are proposing -->
1819

1920
## Context
21+
2022
<!--- Why is this change important to you? How would you use it? -->
2123

2224
## Possible Implementation
23-
<!--- Optional: suggest an idea for implementing addition or change -->>
25+
26+
<!--- Optional: suggest an idea for implementing addition or change -->

.github/ISSUE_TEMPLATE/question.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
---
2-
name: Bug Report
2+
name: Question
33
about: Create a report to help us improve
4-
title: Question:
4+
title: Question
55
---
6+
67
<!--- Provide a general summary of the issue in the Title above -->
78

89
## Question
10+
911
<!--- Provide your detailed question here -->
1012

1113
## Additional context
14+
1215
<!--- Optional: supply any additional context on what you are trying to do -->

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.tabSize": 2,
4+
"editor.insertSpaces": true,
5+
"files.trimTrailingWhitespace": true,
6+
"files.insertFinalNewline": true,
7+
"prettier.singleQuote": true,
8+
"prettier.arrowParens": "always"
9+
}

lib/connect.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const createSSHTunnel = require('./ssh-tunnel');
1616

1717
const debug = require('debug')('mongodb-connection-model:connect');
1818

19-
const needToLoadSSLFiles = model =>
19+
const needToLoadSSLFiles = (model) =>
2020
!includes(['NONE', 'UNVALIDATED'], model.sslType);
2121

2222
const loadOptions = (model, done) => {
@@ -29,17 +29,17 @@ const loadOptions = (model, done) => {
2929
const tasks = {};
3030
const opts = clone(model.driverOptions, true);
3131

32-
Object.keys(opts).map(key => {
32+
Object.keys(opts).map((key) => {
3333
if (key.indexOf('ssl') === -1) {
3434
return;
3535
}
3636

3737
if (Array.isArray(opts[key])) {
38-
opts[key].forEach(value => {
38+
opts[key].forEach((value) => {
3939
if (typeof value === 'string') {
40-
tasks[key] = cb =>
40+
tasks[key] = (cb) =>
4141
async.parallel(
42-
opts[key].map(k => fs.readFile.bind(null, k)),
42+
opts[key].map((k) => fs.readFile.bind(null, k)),
4343
cb
4444
);
4545
}
@@ -62,7 +62,7 @@ const loadOptions = (model, done) => {
6262
return done(err);
6363
}
6464

65-
Object.keys(res).map(key => {
65+
Object.keys(res).map((key) => {
6666
opts[key] = res[key];
6767
});
6868

@@ -92,7 +92,7 @@ const validateURL = (model, done) => {
9292
});
9393
};
9494

95-
const getStatusStateString = evt => {
95+
const getStatusStateString = (evt) => {
9696
if (!evt) {
9797
return 'UNKNOWN';
9898
}
@@ -147,7 +147,7 @@ const getTasks = (model, setupListeners) => {
147147
}
148148
};
149149

150-
ctx.skip = reason => {
150+
ctx.skip = (reason) => {
151151
state.emit('status', { message, skipped: true, reason });
152152

153153
if (cb) {
@@ -169,7 +169,7 @@ const getTasks = (model, setupListeners) => {
169169
* TODO (imlucas) dns.lookup() model.hostname and model.sshTunnelHostname to check for typos
170170
*/
171171
assign(tasks, {
172-
'Load SSL files': cb => {
172+
'Load SSL files': (cb) => {
173173
const ctx = status('Load SSL files', cb);
174174

175175
if (!needToLoadSSLFiles(model)) {
@@ -183,7 +183,7 @@ const getTasks = (model, setupListeners) => {
183183
});
184184

185185
assign(tasks, {
186-
'Create SSH Tunnel': cb => {
186+
'Create SSH Tunnel': (cb) => {
187187
const ctx = status('Create SSH Tunnel', cb);
188188

189189
if (model.sshTunnel === 'NONE') {
@@ -195,7 +195,7 @@ const getTasks = (model, setupListeners) => {
195195
});
196196

197197
assign(tasks, {
198-
'Connect to MongoDB': cb => {
198+
'Connect to MongoDB': (cb) => {
199199
const ctx = status('Connect to MongoDB');
200200

201201
// @note: Durran:
@@ -285,7 +285,7 @@ const connect = (model, setupListeners, done) => {
285285
}
286286

287287
if (!isFunction(done)) {
288-
done = err => {
288+
done = (err) => {
289289
if (err) {
290290
throw err;
291291
}
@@ -297,13 +297,13 @@ const connect = (model, setupListeners, done) => {
297297
'mongodb-connection-model:connect:status'
298298
);
299299

300-
tasks.state.on('status', evt => {
300+
tasks.state.on('status', (evt) => {
301301
logTaskStatus('%s [%s]', evt.message, getStatusStateString(evt));
302302
});
303303

304304
logTaskStatus('Connecting...');
305305

306-
async.series(tasks, err => {
306+
async.series(tasks, (err) => {
307307
if (err) {
308308
logTaskStatus('Error connecting:', err);
309309

lib/connection-collection.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ try {
1515
const electron = require('electron');
1616

1717
appName = electron.remote ? electron.remote.app.getName() : undefined;
18-
basepath = electron.remote ? electron.remote.app.getPath('userData') : undefined;
18+
basepath = electron.remote
19+
? electron.remote.app.getPath('userData')
20+
: undefined;
1921
} catch (e) {
2022
/* eslint no-console: 0 */
2123
console.log('Could not load electron', e.message);
@@ -40,15 +42,15 @@ module.exports = Collection.extend(storageMixin, {
4042
indexes: ['name'],
4143
maxLength: 10,
4244
_prune() {
43-
const recentConnections = this.filter(model => !model.isFavorite);
45+
const recentConnections = this.filter((model) => !model.isFavorite);
4446

4547
if (recentConnections.length > this.maxLength) {
4648
// if there is no space anymore, remove the oldest recent connection first.
4749
const toRemove = this.remove(
4850
recentConnections.slice(0, recentConnections.length - this.maxLength)
4951
);
5052

51-
each(toRemove, model => model.destroy());
53+
each(toRemove, (model) => model.destroy());
5254
}
5355
},
5456
add(models, options) {

lib/extended-model.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ try {
1313
const electron = require('electron');
1414

1515
appName = electron.remote ? electron.remote.app.getName() : undefined;
16-
basepath = electron.remote ? electron.remote.app.getPath('userData') : undefined;
16+
basepath = electron.remote
17+
? electron.remote.app.getPath('userData')
18+
: undefined;
1719
} catch (e) {
1820
/* eslint no-console: 0 */
1921
console.log('Could not load electron', e.message);
@@ -83,12 +85,13 @@ const ExtendedConnection = Connection.extend(storageMixin, {
8385
*
8486
* @returns {Function} callback
8587
*/
86-
ExtendedConnection.from = (url, callback) => Connection.from(url, (error, c) => {
87-
if (error) {
88-
return callback(error);
89-
}
88+
ExtendedConnection.from = (url, callback) =>
89+
Connection.from(url, (error, c) => {
90+
if (error) {
91+
return callback(error);
92+
}
9093

91-
callback(null, new ExtendedConnection(c.getAttributes({ props: true })));
92-
});
94+
callback(null, new ExtendedConnection(c.getAttributes({ props: true })));
95+
});
9396

9497
module.exports = ExtendedConnection;

lib/local-port-generator.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
module.exports = () => {
1212
const startPort = 29170;
1313
const endPort = 29899;
14-
const randomPort = (Math.random() * (endPort - startPort + 1) + startPort).toString();
14+
const randomPort = (
15+
Math.random() * (endPort - startPort + 1) +
16+
startPort
17+
).toString();
1518

1619
return parseInt(randomPort, 10);
1720
};

0 commit comments

Comments
 (0)