Skip to content

Commit a3963ac

Browse files
authored
Upgrade Electron to v11 (#592)
* Update Electron to v9.0.0-beta.9 * Update electron/extensions.js * BrowserWindow: Add enableRemoteModule option * Bump electron & node-abi version * Bump electron-devtools-installer version * Bump spectron version * Uncomment load extensions on dev * Bump electron to v9.1.0 * Bump electron to 9.3.0 * Update to electron v11 * TEMP: Comment setTouchBar * bump electron to 11.4.4 * Add allowFileAccess for loadExtension * Bump spectron to v13 * Update tests * Update electron-devtools-installer usage * Add apollo-client-devtools patch * Fix E2E test * Fix lint error * TEMP: Comment setTouchBar * Remove _setEscapeTouchBarItem patch * devtools: Hide lighthouse tab * Remove comment * Bump electron-packager and electron-installer-dmg version * Bump electron version * Disable asar for release build * Add devtools-helper & apollo-client-devtools as extra resource * Update env in E2E test * shell.openItem -> shell.openPath * Change osx-sign.identity
1 parent 6fa092c commit a3963ac

15 files changed

Lines changed: 1559 additions & 506 deletions

__e2e__/app.spec.js

Lines changed: 34 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import buildTestBundle, { bundlePath } from './buildTestBundle';
88
import createMockRNServer from './mockRNServer';
99
import autoUpdateFeed from '../auto_update.json';
1010

11-
const delay = time => new Promise(resolve => setTimeout(resolve, time));
11+
const delay = (time) => new Promise((resolve) => setTimeout(resolve, time));
1212

1313
// eslint-disable-next-line
1414
jasmine.DEFAULT_TIMEOUT_INTERVAL = 6e4;
@@ -23,6 +23,7 @@ describe('Application launch', () => {
2323
args: ['--user-dir=__e2e__/tmp', 'dist'],
2424
env: {
2525
E2E_TEST: 1,
26+
PACKAGE: 'no',
2627
},
2728
});
2829
return app.start();
@@ -83,32 +84,31 @@ describe('Application launch', () => {
8384
it("should contain Inspector monitor's component on Redux DevTools", async () => {
8485
const { client } = app;
8586

86-
const val = await client
87-
.element('//div[contains(@class, "inspector-")]')
88-
.getText();
87+
const el = await client.$('//div[contains(@class, "inspector-")]');
88+
const val = await el.getText();
8989
expect(val).not.toBeNull();
9090
});
9191

9292
it('should contain an empty actions list on Redux DevTools', async () => {
9393
const { client } = app;
9494

95-
const val = await client
96-
.element('//div[contains(@class, "actionListRows-")]')
97-
.getText();
95+
const el = await client.$('//div[contains(@class, "actionListRows-")]');
96+
const val = await el.getText();
9897
expect(val).toBe('');
9998
});
10099

101100
it('should show waiting message on React DevTools', async () => {
102101
const { client } = app;
103-
const exist = await client.isExisting(
102+
const el = await client.$(
104103
'//h2[text()="Waiting for React to connect…"]',
105104
);
105+
const exist = await el.isExisting();
106106
expect(exist).toBe(true);
107107
});
108108

109109
const customRNServerPort = 8098;
110-
const getURLFromConnection = server =>
111-
new Promise(resolve => {
110+
const getURLFromConnection = (server) =>
111+
new Promise((resolve) => {
112112
server.on('connection', (socket, req) => {
113113
resolve(req.url);
114114
});
@@ -136,12 +136,12 @@ describe('Application launch', () => {
136136
const portFile = path.join(process.env[homeEnv], '.rndebugger_port');
137137
const rndPort = fs.readFileSync(portFile, 'utf-8');
138138

139-
const sendSuccess = await new Promise(resolve => {
139+
const sendSuccess = await new Promise((resolve) => {
140140
const socket = net.createConnection({ port: rndPort }, () => {
141141
let pass;
142142
socket.setEncoding('utf-8');
143143
socket.write(JSON.stringify({ path: rndPath }));
144-
socket.on('data', data => {
144+
socket.on('data', (data) => {
145145
pass = data === 'success';
146146
socket.end();
147147
});
@@ -163,8 +163,8 @@ describe('Application launch', () => {
163163
});
164164

165165
describe('Import fake script after', () => {
166-
const getOneRequestHeaders = port =>
167-
new Promise(resolve => {
166+
const getOneRequestHeaders = (port) =>
167+
new Promise((resolve) => {
168168
const server = http.createServer((req, res) => {
169169
res.writeHead(200, { 'Content-Type': 'text/plain' });
170170
res.end('');
@@ -184,9 +184,9 @@ describe('Application launch', () => {
184184

185185
headersPromise = getOneRequestHeaders(8099);
186186

187-
await new Promise(resolve => {
188-
wss.on('connection', socket => {
189-
socket.on('message', message => {
187+
await new Promise((resolve) => {
188+
wss.on('connection', (socket) => {
189+
socket.on('message', (message) => {
190190
const data = JSON.parse(message);
191191
switch (data.replyID) {
192192
case 'createJSRuntime':
@@ -233,32 +233,25 @@ describe('Application launch', () => {
233233

234234
it('should have @@INIT action on Redux DevTools', async () => {
235235
const { client } = app;
236-
const val = await client
237-
.element('//div[contains(@class, "actionListRows-")]')
238-
.getText();
236+
const el = await client.$('//div[contains(@class, "actionListRows-")]');
237+
const val = await el.getText();
239238
expect(val).toMatch(/@@redux\/INIT/); // Last store is `RemoteDev store instance 1`
240239
});
241240

242241
let currentInstance = 'Autoselect instances'; // Default instance
243242
const wait = () => delay(750);
244-
const selectInstance = async instance => {
243+
const selectInstance = async (instance) => {
245244
const { client } = app;
246-
await client
247-
.element(`//div[text()="${currentInstance}"]`)
248-
.click()
249-
.then(wait);
245+
let el = await client.$(`//div[text()="${currentInstance}"]`);
246+
await el.click().then(wait);
250247
currentInstance = instance;
251-
return client
252-
.element(`//div[text()="${instance}"]`)
253-
.click()
254-
.then(wait);
248+
el = await client.$(`//div[text()="${instance}"]`);
249+
return el.click().then(wait);
255250
};
256-
const commit = () => {
251+
const commit = async () => {
257252
const { client } = app;
258-
client
259-
.element('//div[text()="Commit"]')
260-
.click()
261-
.then(delay(100));
253+
const el = await client.$('//div[text()="Commit"]');
254+
await el.click().then(delay(100));
262255
};
263256

264257
const expectActions = {
@@ -304,13 +297,12 @@ describe('Application launch', () => {
304297
}
305298
};
306299

307-
const checkInstance = async name => {
300+
const checkInstance = async (name) => {
308301
const { client } = app;
309302

310303
await selectInstance(name);
311-
const val = await client
312-
.element('//div[contains(@class, "actionListRows-")]')
313-
.getText();
304+
const el = await client.$('//div[contains(@class, "actionListRows-")]');
305+
const val = await el.getText();
314306
runExpectActions(name, val);
315307
await commit();
316308
};
@@ -333,7 +325,7 @@ describe('Application launch', () => {
333325
const { client } = app;
334326
const logs = await client.getRenderProcessLogs();
335327
// Print renderer process logs
336-
logs.forEach(log =>
328+
logs.forEach((log) =>
337329
console.log(
338330
`Message: ${log.message}\nSource: ${log.source}\nLevel: ${log.level}`,
339331
),
@@ -350,13 +342,10 @@ describe('Application launch', () => {
350342
});
351343

352344
it('should show apollo devtools panel', async () => {
353-
const { client } = app;
354345
expect(
355-
(
356-
await client.execute(
357-
() => window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__,
358-
)
359-
).value,
346+
await app.webContents.executeJavaScript(
347+
'window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__'
348+
),
360349
).toBeTruthy();
361350
});
362351
});

dist/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
},
1111
"author": "Jhen <developer@jhen.me>",
1212
"license": "MIT",
13+
"scripts": {
14+
"postinstall": "patch-package"
15+
},
1316
"dependencies": {
1417
"adbkit": "^2.11.0",
1518
"apollo-client-devtools": "^2.3.5",
1619
"electron-store": "^1.2.0",
20+
"patch-package": "^6.2.2",
1721
"react-devtools-core": "~4.13.3"
1822
}
1923
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/node_modules/apollo-client-devtools/shells/webextension/manifest.json b/node_modules/apollo-client-devtools/shells/webextension/manifest.json
2+
index 08cbeef..740dbb6 100755
3+
--- a/node_modules/apollo-client-devtools/shells/webextension/manifest.json
4+
+++ b/node_modules/apollo-client-devtools/shells/webextension/manifest.json
5+
@@ -11,7 +11,7 @@
6+
},
7+
"page_action": {},
8+
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
9+
- "permissions": ["storage", "tabs", "http://*/*", "https://*/*"],
10+
+ "permissions": ["storage", "tabs", "<all_urls>"],
11+
"devtools_page": "devtools-background.html",
12+
"background": {
13+
"scripts": ["dist/background.js"],

0 commit comments

Comments
 (0)