[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>
This commit is contained in:
Akos Kitta
2020-03-23 11:49:48 +01:00
parent d54a69935e
commit 6ce4143d49
30 changed files with 2549 additions and 976 deletions

View File

@@ -1,10 +1,10 @@
{
"name": "arduino-ide-extension",
"version": "0.0.5",
"version": "0.0.6",
"description": "An extension for Theia building the Arduino IDE",
"license": "MIT",
"engines": {
"node": ">=10.10.0"
"node": ">=10.11.0 <12"
},
"scripts": {
"prepare": "yarn download-cli && yarn generate-protocol && yarn download-ls && yarn run clean && yarn run build",
@@ -19,7 +19,6 @@
"test:watch": "mocha --watch --watch-files lib \"./lib/test/**/*.test.js\""
},
"dependencies": {
"@grpc/grpc-js": "^0.6.18",
"@theia/application-package": "next",
"@theia/core": "next",
"@theia/cpp": "next",
@@ -37,11 +36,12 @@
"@types/dateformat": "^3.0.1",
"@types/deepmerge": "^2.2.0",
"@types/glob": "^5.0.35",
"@types/google-protobuf": "^3.7.1",
"@types/google-protobuf": "^3.7.2",
"@types/js-yaml": "^3.12.2",
"@types/lodash.debounce": "^4.0.6",
"@types/ps-tree": "^1.1.0",
"@types/react-select": "^3.0.0",
"@types/sinon": "^7.5.2",
"@types/which": "^1.3.1",
"ajv": "^6.5.3",
"css-element-queries": "^1.2.0",
@@ -49,7 +49,8 @@
"deepmerge": "^4.2.2",
"fuzzy": "^0.1.3",
"glob": "^7.1.6",
"google-protobuf": "^3.11.0",
"google-protobuf": "^3.11.4",
"grpc": "^1.24.2",
"lodash.debounce": "^4.0.8",
"js-yaml": "^3.13.1",
"p-queue": "^5.0.0",
@@ -79,6 +80,7 @@
"ncp": "^2.0.0",
"protoc": "1.0.4",
"shelljs": "^0.8.3",
"sinon": "^9.0.1",
"temp": "^0.9.1",
"uuid": "^3.2.1",
"yargs": "^11.1.0"

View File

@@ -86,8 +86,6 @@ ${protos.join(' ')}`).code !== 0) {
shell.exit(1);
}
const { patch } = require('./patch-grpc-js');
patch([out])
shell.echo('Done.');
})();

View File

@@ -1,38 +0,0 @@
// Use `@grpc/grpc-js` instead of `grpc` at runtime.
// https://github.com/grpc/grpc-node/issues/624
// https://github.com/grpc/grpc-node/issues/931
const fs = require('fs');
const path = require('path');
module.exports.patch = function (roots = [path.join(__dirname, '..', 'src', 'node')]) {
console.info('🔧 <<< Patching code...');
patch(roots);
console.info('👌 <<< Done. The code has been patched.');
};
function patch(paths) {
for (const p of paths) {
const exist = fs.existsSync(p);
if (exist) {
const stat = fs.statSync(p);
if (stat.isDirectory()) {
console.info(`🔧 >>> Scanning code in ${p}...`);
patch(fs.readdirSync(p).map(name => path.join(p, name)));
} else {
let content = fs.readFileSync(p, { encoding: 'utf8' });
if (content.indexOf("require('grpc')") !== -1) {
console.info(`Updated require('grpc') to require('@grpc/grpc-js') in ${p}.`);
fs.writeFileSync(p, content.replace("require('grpc')", "require('@grpc/grpc-js')"));
}
content = fs.readFileSync(p, { encoding: 'utf8' });
if (content.indexOf('import * as grpc from "grpc"') !== -1) {
console.info(`Updated import * as grpc from "grpc" to import * as grpc from "@grpc/grpc-js" in ${p}.`);
fs.writeFileSync(p, content.replace('import * as grpc from "grpc"', 'import * as grpc from "@grpc/grpc-js"'));
}
}
} else {
console.warn(`${p} does not exist. Skipping.`);
}
}
}

View File

@@ -1,6 +1,6 @@
import * as path from 'path';
import * as yaml from 'js-yaml';
import * as grpc from '@grpc/grpc-js';
import * as grpc from 'grpc';
import * as deepmerge from 'deepmerge';
import { injectable, inject, named } from 'inversify';
import URI from '@theia/core/lib/common/uri';

View File

@@ -1,4 +1,4 @@
import * as grpc from '@grpc/grpc-js';
import * as grpc from 'grpc';
import { inject, injectable } from 'inversify';
import { ToolOutputServiceServer } from '../common/protocol';
import { GrpcClientProvider } from './grpc-client-provider';
@@ -35,7 +35,7 @@ export class CoreClientProvider extends GrpcClientProvider<CoreClientProvider.Cl
}
protected async createClient(port: string | number): Promise<CoreClientProvider.Client> {
const client = new ArduinoCoreClient(`localhost:${port}`, grpc.credentials.createInsecure());
const client = new ArduinoCoreClient(`localhost:${port}`, grpc.credentials.createInsecure(), this.channelOptions);
const initReq = new InitReq();
initReq.setLibraryManagerOnly(false);
const initResp = await new Promise<InitResp>(resolve => {

View File

@@ -1,3 +1,4 @@
import * as grpc from 'grpc';
import { inject, injectable, postConstruct } from 'inversify';
import { ILogger } from '@theia/core/lib/common/logger';
import { MaybePromise } from '@theia/core/lib/common/types';
@@ -68,4 +69,11 @@ export abstract class GrpcClientProvider<C> {
protected abstract close(client: C): void;
protected get channelOptions(): grpc.CallOptions {
return {
'grpc.max_send_message_length': 512 * 1024 * 1024,
'grpc.max_receive_message_length': 512 * 1024 * 1024
};
}
}

View File

@@ -1,4 +1,4 @@
import * as grpc from '@grpc/grpc-js';
import * as grpc from 'grpc';
import { injectable } from 'inversify';
import { MonitorClient } from '../cli-protocol/monitor/monitor_grpc_pb';
import { GrpcClientProvider } from '../grpc-client-provider';
@@ -7,7 +7,7 @@ import { GrpcClientProvider } from '../grpc-client-provider';
export class MonitorClientProvider extends GrpcClientProvider<MonitorClient> {
createClient(port: string | number): MonitorClient {
return new MonitorClient(`localhost:${port}`, grpc.credentials.createInsecure());
return new MonitorClient(`localhost:${port}`, grpc.credentials.createInsecure(), this.channelOptions);
}
close(client: MonitorClient): void {

View File

@@ -1,4 +1,4 @@
import { ClientDuplexStream } from '@grpc/grpc-js';
import { ClientDuplexStream } from 'grpc';
import { TextDecoder, TextEncoder } from 'util';
import { injectable, inject, named } from 'inversify';
import { Struct } from 'google-protobuf/google/protobuf/struct_pb';

View File

@@ -1,4 +1,6 @@
import { expect } from 'chai';
import * as sinon from 'sinon';
import * as os from '@theia/core/lib/common/os';
import { Container, injectable } from 'inversify';
import { Event } from '@theia/core/lib/common/event';
import { ILogger } from '@theia/core/lib/common/logger';
@@ -26,18 +28,23 @@ describe('boards-service-client-impl', () => {
const guessed = AvailableBoard.State.guessed;
const incomplete = AvailableBoard.State.incomplete;
let stub: sinon.SinonStub;
let server: MockBoardsService;
let client: BoardsServiceClientImpl;
// let storage: MockStorageService;
beforeEach(() => {
stub = sinon.stub(os, 'isOSX').value(true);
const container = init();
server = container.get(MockBoardsService);
client = container.get(BoardsServiceClientImpl);
// storage = container.get(MockStorageService);
server.setClient(client);
});
afterEach(() => {
stub.reset();
});
it('should have no available boards by default', () => {
expect(client.availableBoards).to.have.length(0);
});