mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-05 19:56:34 +00:00
Fixed the electron
build.
- Switched from `grpc` to `@grpc/grpc-js`. - Use electron `4.x` due to `@grpc/grpc-js`. - Enabled the build on Azure Pipelines. - From now on, the TS/JS generation is manual. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
ba995e6869
commit
6f584bf5d6
@ -4,6 +4,7 @@
|
||||
"description": "An extension for Theia building the Arduino IDE",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^0.4.0",
|
||||
"@theia/core": "next",
|
||||
"@theia/editor": "next",
|
||||
"@theia/filesystem": "next",
|
||||
@ -14,8 +15,8 @@
|
||||
"p-queue": "^5.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"generate-protoc": "./scripts/generate-protoc.sh",
|
||||
"prepare": "yarn run clean && yarn generate-protoc && yarn run build",
|
||||
"generate-protoc": "./scripts/generate-protoc.sh && node ./scripts/patch-grpc-js.js",
|
||||
"prepare": "yarn run clean && yarn run build",
|
||||
"clean": "rimraf lib",
|
||||
"lint": "tslint -c ./tslint.json --project ./tsconfig.json",
|
||||
"build": "tsc && cp -rf src/node/cli-protocol lib/node && yarn lint",
|
||||
|
25
arduino-ide-extension/scripts/patch-grpc-js.js
Normal file
25
arduino-ide-extension/scripts/patch-grpc-js.js
Normal file
@ -0,0 +1,25 @@
|
||||
// Use `@grpc/grpc-js` instead of `grpc` at runtime.
|
||||
// https://github.com/grpc/grpc-node/issues/624
|
||||
(() => {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const roots = ['src']; // XXX: patch the `lib` instead?
|
||||
console.info("🔧 >>> Patching code. Switching from 'grpc' to '@grpc/grpc-js'...");
|
||||
for (const root of roots) {
|
||||
const cliProtocolPath = path.resolve(__dirname, '..', root, 'node', 'cli-protocol');
|
||||
for (const fileName of fs.readdirSync(cliProtocolPath)) {
|
||||
const filePath = path.resolve(cliProtocolPath, fileName);
|
||||
let content = fs.readFileSync(filePath, { encoding: 'utf8' });
|
||||
if (content.indexOf("require('grpc')") !== -1) {
|
||||
console.info(`Updated require('grpc') to require('@grpc/grpc-js') in ${filePath}.`);
|
||||
fs.writeFileSync(filePath, content.replace("require('grpc')", "require('@grpc/grpc-js')"));
|
||||
}
|
||||
content = fs.readFileSync(filePath, { 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 ${filePath}.`);
|
||||
fs.writeFileSync(filePath, content.replace('import * as grpc from "grpc"', 'import * as grpc from "@grpc/grpc-js"'));
|
||||
}
|
||||
}
|
||||
}
|
||||
console.info('👌 <<< Done. The code has been patched.');
|
||||
})();
|
@ -3,7 +3,7 @@
|
||||
|
||||
/* tslint:disable */
|
||||
|
||||
import * as grpc from "grpc";
|
||||
import * as grpc from "@grpc/grpc-js";
|
||||
import * as commands_pb from "./commands_pb";
|
||||
import * as common_pb from "./common_pb";
|
||||
import * as board_pb from "./board_pb";
|
||||
|
@ -19,7 +19,7 @@
|
||||
//
|
||||
//
|
||||
'use strict';
|
||||
var grpc = require('grpc');
|
||||
var grpc = require('@grpc/grpc-js');
|
||||
var commands_pb = require('./commands_pb.js');
|
||||
var common_pb = require('./common_pb.js');
|
||||
var board_pb = require('./board_pb.js');
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { inject, injectable } from 'inversify';
|
||||
import * as grpc from 'grpc';
|
||||
import * as grpc from '@grpc/grpc-js';
|
||||
import { ArduinoCoreClient } from './cli-protocol/commands_grpc_pb';
|
||||
import { InitResp, InitReq, Configuration, UpdateIndexReq, UpdateIndexResp } from './cli-protocol/commands_pb';
|
||||
import { WorkspaceServiceExt } from '../browser/workspace-service-ext';
|
||||
|
@ -1,16 +0,0 @@
|
||||
import * as grpc from "grpc";
|
||||
import * as jspb from "google-protobuf";
|
||||
|
||||
export type GrpcMethod<Req, Resp> = (request: Req, callback: (error: grpc.ServiceError | null, response: Resp) => void) => grpc.ClientUnaryCall
|
||||
|
||||
export function promisify<M extends GrpcMethod<Req, Resp>, Req, Resp extends jspb.Message>(m: M, req: Req): Promise<Resp> {
|
||||
return new Promise<Resp>((resolve, reject) => {
|
||||
m(req, (err, resp) => {
|
||||
if (!!err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(resp);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
82
azure-pipelines.yml
Normal file
82
azure-pipelines.yml
Normal file
@ -0,0 +1,82 @@
|
||||
trigger:
|
||||
batch: true
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- electron # TODO: remove this!
|
||||
|
||||
pr:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
- job: Build
|
||||
strategy:
|
||||
matrix:
|
||||
linux:
|
||||
imageName: 'ubuntu-16.04'
|
||||
mac:
|
||||
imageName: 'macos-10.13'
|
||||
windows:
|
||||
imageName: 'vs2017-win2016'
|
||||
pool:
|
||||
vmImage: $(imageName)
|
||||
steps:
|
||||
- task: UsePythonVersion@0
|
||||
inputs:
|
||||
versionSpec: '2.7'
|
||||
architecture: 'x64'
|
||||
displayName: '[Config] Use - Python 2.7'
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '10.x'
|
||||
displayName: '[Config] Use - Node.js 10.x'
|
||||
- script: yarn
|
||||
displayName: Build
|
||||
env:
|
||||
GITHUB_TOKEN: $(Personal.GitHub.Token)
|
||||
- bash: |
|
||||
yarn --cwd ./electron/packager/
|
||||
yarn --cwd ./electron/packager/ package
|
||||
displayName: Package
|
||||
env:
|
||||
GITHUB_TOKEN: $(Personal.GitHub.Token)
|
||||
RELEASE_TAG: $(Release.Tag)
|
||||
- bash: |
|
||||
export ARDUINO_POC_NAME=$(./electron/packager/cli name)
|
||||
echo "##vso[task.setvariable variable=ArduinoPoC.AppName]$ARDUINO_POC_NAME"
|
||||
env:
|
||||
RELEASE_TAG: $(Release.Tag)
|
||||
displayName: '[Config] Use - ARDUINO_POC_NAME env'
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: electron/build/dist/$(ArduinoPoC.AppName)
|
||||
artifactName: 'Arduino-PoC - Applications'
|
||||
displayName: Publish
|
||||
- job: Release
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
dependsOn:
|
||||
- Build
|
||||
condition: and(in(variables['Build.Reason'], 'Manual', 'Schedule'), startsWith(variables['Release.Tag'], 'v'))
|
||||
steps:
|
||||
- task: DownloadBuildArtifacts@0
|
||||
displayName: Download
|
||||
inputs:
|
||||
artifactName: 'Arduino-PoC - Applications'
|
||||
downloadPath: 'gh-release'
|
||||
- task: GithubRelease@0
|
||||
inputs:
|
||||
gitHubConnection: personal-access-token-service-connection
|
||||
repositoryName: bcmi-labs/arduino-editor
|
||||
assets: |
|
||||
gh-release/Arduino-PoC - Applications/*.zip
|
||||
gh-release/Arduino-PoC - Applications/*.dmg
|
||||
gh-release/Arduino-PoC - Applications/*.tar.xz
|
||||
target: $(Build.SourceVersion)
|
||||
action: Edit
|
||||
tagSource: auto
|
||||
tag: $(Release.Tag)
|
||||
assetUploadMode: delete
|
||||
isDraft: true
|
||||
addChangeLog: false
|
||||
displayName: Release
|
@ -34,7 +34,7 @@ One can create a GitHub release draft, tag the source, and upload the artifacts
|
||||
|
||||
### Publishing the Release Draft:
|
||||
One has to manually publish the GitHub release.
|
||||
- Go to the [release page](https://github.com/TypeFox/arduino-poc/releases) of the arduino-poc repository.
|
||||
- Go to the [release page](https://github.com/bcmi-labs/arduino-editor.git/releases) of the `arduino-editor` repository.
|
||||
- Select your release draft.
|
||||
- Click on `Edit`.
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
"main": "src-gen/frontend/electron-main.js",
|
||||
"author": "TypeFox",
|
||||
"dependencies": {
|
||||
"google-protobuf": "^3.5.0",
|
||||
"arduino-ide-extension": "file:../working-copy/arduino-ide-extension"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -22,9 +23,14 @@
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/TypeFox/arduino-poc.git"
|
||||
},
|
||||
"// Notes:" : [
|
||||
"The `electronVersion` version was pinned for `@grpc/grpc-js` -> Node.js version constraints.",
|
||||
"`google-protobuf` was declared as it is not picked up by the `electron-builder` as a runtime dependency."
|
||||
],
|
||||
"build": {
|
||||
"productName": "Arduino-PoC",
|
||||
"appId": "arduino.PoC",
|
||||
"electronVersion": "4.0.0",
|
||||
"asar": false,
|
||||
"directories": {
|
||||
"buildResources": "resources"
|
||||
@ -55,6 +61,12 @@
|
||||
"artifactName": "${productName}-${env.ARDUINO_VERSION}-${os}.${ext}",
|
||||
"darkModeSupport": true
|
||||
},
|
||||
"linux": {
|
||||
"target": [
|
||||
"tar.xz"
|
||||
],
|
||||
"artifactName": "${productName}-${env.ARDUINO_VERSION}-${os}.${ext}"
|
||||
},
|
||||
"dmg": {
|
||||
"icon": "resources/icon.icns",
|
||||
"iconSize": 128,
|
||||
|
@ -18,6 +18,9 @@ const yargs = require('yargs');
|
||||
} else if (platform === 'win32') {
|
||||
ext = 'zip';
|
||||
os = 'win';
|
||||
} else if (platform === 'linux') {
|
||||
ext = 'tar.xz';
|
||||
os = 'linux';
|
||||
} else {
|
||||
process.stderr.write(`Unexpected platform: ${platform}.`);
|
||||
process.exit(1);
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "arduino-poc",
|
||||
"version": "0.0.1",
|
||||
"description": "A proof-of-concent demonstrating an Arduino IDE built using Theia",
|
||||
"description": "A PoC demonstrating an Arduino IDE built using Eclipse Theia",
|
||||
"main": "index.js",
|
||||
"repository": "https://github.com/TypeFox/arduino-poc.git",
|
||||
"repository": "https://github.com/bcmi-labs/arduino-editor.git",
|
||||
"author": "Christian Weichel <christian.weichel@typefox.io>",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
|
12
yarn.lock
12
yarn.lock
@ -25,6 +25,13 @@
|
||||
dependencies:
|
||||
regenerator-runtime "^0.13.2"
|
||||
|
||||
"@grpc/grpc-js@^0.4.0":
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-0.4.0.tgz#b20a6abf1346ce7fd696a042f83d10c94e143881"
|
||||
integrity sha512-UbGDPnstJamJrSiHzCSwSavIX260IfLOZLRJYDqRKJA/jmVZa3hPMWDjhFrcCKDq2MLc/O/nauFED3r4khcZrA==
|
||||
dependencies:
|
||||
semver "^6.0.0"
|
||||
|
||||
"@lerna/add@3.13.3":
|
||||
version "3.13.3"
|
||||
resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.13.3.tgz#f4c1674839780e458f0426d4f7b6d0a77b9a2ae9"
|
||||
@ -9738,6 +9745,11 @@ self-closing-tags@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
|
||||
integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==
|
||||
|
||||
semver@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.0.0.tgz#05e359ee571e5ad7ed641a6eec1e547ba52dea65"
|
||||
integrity sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==
|
||||
|
||||
semver@~5.3.0:
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
|
||||
|
Loading…
x
Reference in New Issue
Block a user