Skip to content

Commit 6ce4143

Browse files
author
Akos Kitta
committed
[ci]: Made various changes for the electron app:
- Support for multiple electron targe per platform. - Removed packager CLI. Changed the logic we calculate the app name. - Fixed various OS-specific tests: stubbed `os`. - Restructured the final ZIP formats for Windows and Linux. - Added packager tests. - Switched from `@grpc/grpc-js` to native `grpc`. - Updated the version from 0.0.5 to 0.0.6. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent d54a699 commit 6ce4143

30 files changed

+2564
-991
lines changed

arduino-debugger-extension/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "arduino-debugger-extension",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "An extension for debugging Arduino programs",
55
"license": "MIT",
66
"engines": {
7-
"node": ">=10.10.0"
7+
"node": ">=10.11.0 <12"
88
},
99
"dependencies": {
1010
"@theia/debug": "next",
11-
"arduino-ide-extension": "0.0.5",
11+
"arduino-ide-extension": "0.0.6",
1212
"cdt-gdb-adapter": "^0.0.14",
1313
"vscode-debugadapter": "^1.26.0",
1414
"vscode-debugprotocol": "^1.26.0"

arduino-ide-extension/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "arduino-ide-extension",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "An extension for Theia building the Arduino IDE",
55
"license": "MIT",
66
"engines": {
7-
"node": ">=10.10.0"
7+
"node": ">=10.11.0 <12"
88
},
99
"scripts": {
1010
"prepare": "yarn download-cli && yarn generate-protocol && yarn download-ls && yarn run clean && yarn run build",
@@ -19,7 +19,6 @@
1919
"test:watch": "mocha --watch --watch-files lib \"./lib/test/**/*.test.js\""
2020
},
2121
"dependencies": {
22-
"@grpc/grpc-js": "^0.6.18",
2322
"@theia/application-package": "next",
2423
"@theia/core": "next",
2524
"@theia/cpp": "next",
@@ -37,19 +36,21 @@
3736
"@types/dateformat": "^3.0.1",
3837
"@types/deepmerge": "^2.2.0",
3938
"@types/glob": "^5.0.35",
40-
"@types/google-protobuf": "^3.7.1",
39+
"@types/google-protobuf": "^3.7.2",
4140
"@types/js-yaml": "^3.12.2",
4241
"@types/lodash.debounce": "^4.0.6",
4342
"@types/ps-tree": "^1.1.0",
4443
"@types/react-select": "^3.0.0",
44+
"@types/sinon": "^7.5.2",
4545
"@types/which": "^1.3.1",
4646
"ajv": "^6.5.3",
4747
"css-element-queries": "^1.2.0",
4848
"dateformat": "^3.0.3",
4949
"deepmerge": "^4.2.2",
5050
"fuzzy": "^0.1.3",
5151
"glob": "^7.1.6",
52-
"google-protobuf": "^3.11.0",
52+
"google-protobuf": "^3.11.4",
53+
"grpc": "^1.24.2",
5354
"lodash.debounce": "^4.0.8",
5455
"js-yaml": "^3.13.1",
5556
"p-queue": "^5.0.0",
@@ -79,6 +80,7 @@
7980
"ncp": "^2.0.0",
8081
"protoc": "1.0.4",
8182
"shelljs": "^0.8.3",
83+
"sinon": "^9.0.1",
8284
"temp": "^0.9.1",
8385
"uuid": "^3.2.1",
8486
"yargs": "^11.1.0"

arduino-ide-extension/scripts/generate-protocol.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ ${protos.join(' ')}`).code !== 0) {
8686
shell.exit(1);
8787
}
8888

89-
const { patch } = require('./patch-grpc-js');
90-
patch([out])
9189
shell.echo('Done.');
9290

9391
})();

arduino-ide-extension/scripts/patch-grpc-js.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

arduino-ide-extension/src/node/config-service-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
22
import * as yaml from 'js-yaml';
3-
import * as grpc from '@grpc/grpc-js';
3+
import * as grpc from 'grpc';
44
import * as deepmerge from 'deepmerge';
55
import { injectable, inject, named } from 'inversify';
66
import URI from '@theia/core/lib/common/uri';

arduino-ide-extension/src/node/core-client-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as grpc from '@grpc/grpc-js';
1+
import * as grpc from 'grpc';
22
import { inject, injectable } from 'inversify';
33
import { ToolOutputServiceServer } from '../common/protocol';
44
import { GrpcClientProvider } from './grpc-client-provider';
@@ -35,7 +35,7 @@ export class CoreClientProvider extends GrpcClientProvider<CoreClientProvider.Cl
3535
}
3636

3737
protected async createClient(port: string | number): Promise<CoreClientProvider.Client> {
38-
const client = new ArduinoCoreClient(`localhost:${port}`, grpc.credentials.createInsecure());
38+
const client = new ArduinoCoreClient(`localhost:${port}`, grpc.credentials.createInsecure(), this.channelOptions);
3939
const initReq = new InitReq();
4040
initReq.setLibraryManagerOnly(false);
4141
const initResp = await new Promise<InitResp>(resolve => {

arduino-ide-extension/src/node/grpc-client-provider.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as grpc from 'grpc';
12
import { inject, injectable, postConstruct } from 'inversify';
23
import { ILogger } from '@theia/core/lib/common/logger';
34
import { MaybePromise } from '@theia/core/lib/common/types';
@@ -68,4 +69,11 @@ export abstract class GrpcClientProvider<C> {
6869

6970
protected abstract close(client: C): void;
7071

72+
protected get channelOptions(): grpc.CallOptions {
73+
return {
74+
'grpc.max_send_message_length': 512 * 1024 * 1024,
75+
'grpc.max_receive_message_length': 512 * 1024 * 1024
76+
};
77+
}
78+
7179
}

arduino-ide-extension/src/node/monitor/monitor-client-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as grpc from '@grpc/grpc-js';
1+
import * as grpc from 'grpc';
22
import { injectable } from 'inversify';
33
import { MonitorClient } from '../cli-protocol/monitor/monitor_grpc_pb';
44
import { GrpcClientProvider } from '../grpc-client-provider';
@@ -7,7 +7,7 @@ import { GrpcClientProvider } from '../grpc-client-provider';
77
export class MonitorClientProvider extends GrpcClientProvider<MonitorClient> {
88

99
createClient(port: string | number): MonitorClient {
10-
return new MonitorClient(`localhost:${port}`, grpc.credentials.createInsecure());
10+
return new MonitorClient(`localhost:${port}`, grpc.credentials.createInsecure(), this.channelOptions);
1111
}
1212

1313
close(client: MonitorClient): void {

arduino-ide-extension/src/node/monitor/monitor-service-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ClientDuplexStream } from '@grpc/grpc-js';
1+
import { ClientDuplexStream } from 'grpc';
22
import { TextDecoder, TextEncoder } from 'util';
33
import { injectable, inject, named } from 'inversify';
44
import { Struct } from 'google-protobuf/google/protobuf/struct_pb';

arduino-ide-extension/src/test/browser/boards-service-client-impl.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { expect } from 'chai';
2+
import * as sinon from 'sinon';
3+
import * as os from '@theia/core/lib/common/os';
24
import { Container, injectable } from 'inversify';
35
import { Event } from '@theia/core/lib/common/event';
46
import { ILogger } from '@theia/core/lib/common/logger';
@@ -26,18 +28,23 @@ describe('boards-service-client-impl', () => {
2628
const guessed = AvailableBoard.State.guessed;
2729
const incomplete = AvailableBoard.State.incomplete;
2830

31+
let stub: sinon.SinonStub;
32+
2933
let server: MockBoardsService;
3034
let client: BoardsServiceClientImpl;
31-
// let storage: MockStorageService;
3235

3336
beforeEach(() => {
37+
stub = sinon.stub(os, 'isOSX').value(true);
3438
const container = init();
3539
server = container.get(MockBoardsService);
3640
client = container.get(BoardsServiceClientImpl);
37-
// storage = container.get(MockStorageService);
3841
server.setClient(client);
3942
});
4043

44+
afterEach(() => {
45+
stub.reset();
46+
});
47+
4148
it('should have no available boards by default', () => {
4249
expect(client.availableBoards).to.have.length(0);
4350
});

azure-pipelines.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,9 @@ jobs:
4545
RELEASE_TAG: $(Release.Tag)
4646
condition: or(in(variables['Agent.OS'], 'Windows_NT'), in(variables['Build.Reason'], 'Manual', 'Schedule'))
4747
displayName: Package
48-
- bash: |
49-
export ARDUINO_POC_NAME=$(./electron/packager/cli name)
50-
echo "##vso[task.setvariable variable=ArduinoPoC.AppName]$ARDUINO_POC_NAME"
51-
env:
52-
RELEASE_TAG: $(Release.Tag)
53-
condition: or(in(variables['Agent.OS'], 'Windows_NT'), in(variables['Build.Reason'], 'Manual', 'Schedule'))
54-
displayName: '[Config] Use - ARDUINO_POC_NAME env'
5548
- task: PublishBuildArtifacts@1
5649
inputs:
57-
pathtoPublish: electron/build/dist/$(ArduinoPoC.AppName)
50+
pathtoPublish: electron/build/dist/build-artifacts
5851
artifactName: 'Arduino Pro IDE - Applications'
5952
condition: or(in(variables['Agent.OS'], 'Windows_NT'), in(variables['Build.Reason'], 'Manual', 'Schedule'))
6053
displayName: Publish
@@ -77,7 +70,7 @@ jobs:
7770
assets: |
7871
gh-release/Arduino Pro IDE - Applications/*.zip
7972
gh-release/Arduino Pro IDE - Applications/*.dmg
80-
gh-release/Arduino Pro IDE - Applications/*.tar.xz
73+
gh-release/Arduino Pro IDE - Applications/*.AppImage
8174
target: $(Build.SourceVersion)
8275
action: Edit
8376
tagSource: auto

browser-app/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "browser-app",
4-
"version": "0.0.5",
4+
"version": "0.0.6",
55
"license": "MIT",
66
"dependencies": {
77
"@theia/core": "next",
@@ -20,8 +20,8 @@
2020
"@theia/process": "next",
2121
"@theia/terminal": "next",
2222
"@theia/workspace": "next",
23-
"arduino-ide-extension": "0.0.5",
24-
"arduino-debugger-extension": "0.0.5"
23+
"arduino-ide-extension": "0.0.6",
24+
"arduino-debugger-extension": "0.0.6"
2525
},
2626
"devDependencies": {
2727
"@theia/cli": "next"

electron-app/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"private": true,
33
"name": "electron-app",
4-
"version": "0.0.5",
4+
"version": "0.0.6",
55
"license": "MIT",
6+
"main": "src-gen/frontend/electron-main.js",
67
"dependencies": {
78
"@theia/core": "next",
89
"@theia/cpp": "next",
@@ -21,8 +22,8 @@
2122
"@theia/process": "next",
2223
"@theia/terminal": "next",
2324
"@theia/workspace": "next",
24-
"arduino-ide-extension": "0.0.5",
25-
"arduino-debugger-extension": "0.0.5"
25+
"arduino-ide-extension": "0.0.6",
26+
"arduino-debugger-extension": "0.0.6"
2627
},
2728
"devDependencies": {
2829
"@theia/cli": "next"
71.6 KB
Loading

electron/build/scripts/arduino-pro-ide-electron-main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const os = require('os');
22
const path = require('path');
33

4+
// To be able to propagate the `process.versions.electron` to the backend main, so that we can load natives correctly.
5+
process.env.THEIA_ELECTRON_VERSION = process.versions.electron;
6+
47
process.env.THEIA_DEFAULT_PLUGINS = `local-dir:${path.resolve(__dirname, '..', 'plugins')}`;
58
process.env.THEIA_PLUGINS = [
69
process.env.THEIA_PLUGINS,
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//@ts-check
2+
// Patches the `src-gen/backend/main.js` so that the forked backend process has the `process.versions.electron` in the bundled electron app.
3+
// https://github.com/eclipse-theia/theia/issues/7358#issue-583306096
4+
5+
const args = process.argv.slice(2);
6+
if (!args.length) {
7+
console.error(`Expected an argument pointing to the app folder. An app folder is where you have the package.json and src-gen folder.`);
8+
process.exit(1);
9+
}
10+
if (args.length > 1) {
11+
console.error(`Expected exactly one argument pointing to the app folder. Got multiple instead: ${JSON.stringify(args)}`);
12+
process.exit(1);
13+
}
14+
const arg = args.shift();
15+
if (!arg) {
16+
console.error('App path was not specified.');
17+
process.exit(1);
18+
}
19+
20+
const fs = require('fs');
21+
const path = require('path');
22+
const appPath = path.resolve((path.isAbsolute(arg) ? path.join(process.cwd(), arg) : arg));
23+
if (!fs.existsSync(appPath)) {
24+
console.error(`${appPath} does not exist.`);
25+
process.exit(1);
26+
}
27+
28+
if (!fs.lstatSync(appPath).isDirectory()) {
29+
console.error(`${appPath} is not a directory.`);
30+
process.exit(1);
31+
}
32+
33+
const patched = path.join(appPath, 'src-gen', 'backend', 'original-main.js');
34+
if (fs.existsSync(patched)) {
35+
console.error(`Already patched. ${patched} already exists.`);
36+
process.exit(1);
37+
}
38+
39+
const toPatch = path.join(appPath, 'src-gen', 'backend', 'main.js');
40+
if (fs.existsSync(patched)) {
41+
console.error(`Cannot patch. ${toPatch} does not exist.`);
42+
process.exit(1);
43+
}
44+
45+
console.log(`⏱️ >>> Patching ${toPatch}...`);
46+
47+
const originalContent = fs.readFileSync(toPatch, { encoding: 'utf8' });
48+
const patchedContent = `if (typeof process.versions.electron === 'undefined' && typeof process.env.THEIA_ELECTRON_VERSION === 'string') {
49+
process.versions.electron = process.env.THEIA_ELECTRON_VERSION;
50+
}
51+
require('./original-main');
52+
`
53+
54+
fs.writeFileSync(patched, originalContent);
55+
fs.writeFileSync(toPatch, patchedContent);
56+
57+
console.log(`👌 <<< Patched ${toPatch}. Original 'main.js' is now at ${patched}.`);

electron/build/template-package.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
},
1313
"devDependencies": {
1414
"@theia/cli": "next",
15-
"electron-builder": "^21.2.0"
15+
"electron-builder": "^22.4.1"
1616
},
1717
"scripts": {
18-
"build": "yarn download:plugins && theia build --mode development",
19-
"build:release": "yarn download:plugins && theia build --mode development",
18+
"build": "yarn download:plugins && theia build --mode development && yarn patch:main",
19+
"build:release": "yarn download:plugins && theia build --mode production && yarn patch:main",
2020
"package": "electron-builder --publish=never",
21-
"package:preview": "electron-builder --dir",
22-
"download:plugins": "theia download:plugins"
21+
"download:plugins": "theia download:plugins",
22+
"patch:main": "node ./scripts/patch-backend-main ."
2323
},
2424
"engines": {
25-
"node": ">=10.10.0"
25+
"node": ">=10.11.0 <12"
2626
},
2727
"repository": {
2828
"type": "git",
@@ -80,9 +80,17 @@
8080
},
8181
"linux": {
8282
"target": [
83-
"zip"
83+
{
84+
"target": "zip"
85+
},
86+
{
87+
"target": "AppImage",
88+
"arch": "armv7l"
89+
}
8490
],
85-
"artifactName": "${productName}-${env.ARDUINO_VERSION}-${os}.${ext}"
91+
"category": "Development",
92+
"icon": "resources/icons",
93+
"artifactName": "${productName}-${env.ARDUINO_VERSION}-${os}-${arch}.${ext}"
8694
},
8795
"dmg": {
8896
"icon": "resources/icon.icns",

0 commit comments

Comments
 (0)