Skip to content

Commit 71fced3

Browse files
committed
chore(compass-shell): Update electron dev environment to match current compass better
1 parent 95b3f1e commit 71fced3

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

packages/compass-shell/electron/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ if ( process.defaultApp || /[\\/]electron-prebuilt[\\/]/.test(process.execPath)
1616
function createWindow() {
1717
// Create the browser window.
1818
mainWindow = new BrowserWindow({
19-
width: 1024, height: 768, show: false
19+
width: 1024,
20+
height: 768,
21+
show: false,
22+
webPreferences: {
23+
nodeIntegration: true,
24+
},
2025
});
2126

2227
// and load the index.html of the app.

packages/compass-shell/electron/renderer/index.js

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,41 @@ render(CompassShellPlugin);
5858
// mongoclient is. For that reason we can use a mocked one, this avoid
5959
// the dependency to keytar:
6060
//
61-
const localUri = 'mongodb://localhost:27017/test';
62-
MongoClient.connect(localUri, { useNewUrlParser: true, useUnifiedTopology: true }, (error, client) => {
63-
const dataService = { client: { client } };
64-
appRegistry.emit('data-service-initialized', dataService);
65-
appRegistry.emit('data-service-connected', error, dataService);
66-
67-
if (error) {
68-
console.error('Unable to connect to', localUri, error);
69-
return;
70-
}
71-
72-
console.info('Connected to', localUri);
61+
const connectionOptions = {
62+
url: 'mongodb://localhost:27020/test?readPreference=primary&ssl=false',
63+
options: {
64+
useNewUrlParser: true,
65+
useUnifiedTopology: true,
66+
connectWithNoPrimary: true,
67+
sslValidate: false,
68+
},
69+
};
7370

74-
appRegistry.emit('data-service-initialized', dataService);
75-
appRegistry.emit('data-service-connected', error, dataService);
76-
});
71+
MongoClient.connect(
72+
connectionOptions.url,
73+
connectionOptions.options,
74+
(error, client) => {
75+
const dataService = {
76+
client: { client },
77+
getConnectionOptions() {
78+
return connectionOptions;
79+
},
80+
};
81+
82+
appRegistry.emit('data-service-initialized', dataService);
83+
appRegistry.emit('data-service-connected', error, dataService);
84+
85+
if (error) {
86+
console.error('Unable to connect to', connectionOptions.url, error);
87+
return;
88+
}
89+
90+
console.info('Connected to', connectionOptions.url);
91+
92+
appRegistry.emit('data-service-initialized', dataService);
93+
appRegistry.emit('data-service-connected', error, dataService);
94+
}
95+
);
7796

7897
if (module.hot) {
7998
module.hot.accept('plugin', () => render(CompassShellPlugin));

packages/compass-shell/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-shell/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"cross-env": "^5.0.1",
9494
"css-loader": "^0.28.1",
9595
"debug": "^3.0.1",
96-
"electron": "^3.1.13",
96+
"electron": "^6.1.7",
9797
"electron-packager": "^8.7.0",
9898
"electron-rebuild": "^1.10.0",
9999
"enzyme": "^3.11.0",

0 commit comments

Comments
 (0)