Add electron-builder packager (#293)

* style(.editorconfig): Add json rule to editorconfig file

* build(build): Add application images

These images need to create installers
Contains images for:
- Win
- Mac
- Linux

* fix(device): Mac is not allow excusive right to use USB

* build(npm): Add standard-version script

* chore(device): Fix comment in UhkDeviceService

* chore(release): 1.0.0-alpha.1

* ci(travis): Change travis to c language and add osx, linux build matrix

* build(build): Windows icon size must be at least 256x256

* ci(appveyor): Add temporary GH_TOKEN to test msi installer

* build(tsconfig): Optimalize tsconfigs

Needed a tsconfig.json in the shared/src library because if it not exist the code builded after the second build on mac, and travis linux. Reproduce the error:
- Delete node_modules directory
- npm i
- npm run build
- error occured (ERROR in ./shared/src/polyfills.ts
Module build failed: error while parsing tsconfig.json)
Created a new tscfonfig.json in the project root folder.
The old config files extends this root configs.

* build(tsconfig): in tsconfig-electron-main not override module version

* chore(editorconfig): Delete json rule

* style: Reformat the main package.json to apply editorconfig style
This commit is contained in:
Róbert Kiss
2017-06-05 23:34:46 +02:00
committed by László Monda
parent 6c31088da8
commit f2b358ba96
23 changed files with 295 additions and 161 deletions

View File

@@ -1,12 +1,35 @@
language: node_js
language: c
sudo: false
dist: trusty
node_js:
- '6.9.4'
env:
global:
- ELECTRON_CACHE=$HOME/.electron
matrix:
fast_finish: true
include:
- os: osx
- os: linux
env: CC=clang CXX=clang++ npm_config_clang=1
compiler: clang
cache:
directories:
- node_modules
- $HOME/.electron
- $HOME/.cache
addons:
apt:
packages:
- libgnome-keyring-dev
- libsecret-1-dev
- icnsutils
install:
- npm install -g npm@3.10.7
- nvm install
- npm install
before_script:
@@ -15,7 +38,8 @@ before_script:
- npm run lint
script:
- cd ./test-serializer && node ./test-serializer.js
- npm run test
- npm run release
cache:
directories:

12
CHANGELOG.md Normal file
View File

@@ -0,0 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="1.0.0-alpha.1"></a>
# 1.0.0-alpha.1 (2017-06-01)
### Bug Fixes
* First macro opening ([#123](https://github.com/UltimateHackingKeyboard/agent/issues/123)) ([aca22f9](https://github.com/UltimateHackingKeyboard/agent/commit/aca22f9)), closes [#121](https://github.com/UltimateHackingKeyboard/agent/issues/121)
* **device:** Mac is not allow excusive right to use USB ([6778ca9](https://github.com/UltimateHackingKeyboard/agent/commit/6778ca9))

View File

@@ -1,6 +1,8 @@
os: unstable
environment:
GH_TOKEN: #TODO Change it to the master repo access token
secure: SGC3hXXPFwK+vV8jMLJjngg93vCq0lqPaKuBLluWxhaaPR/FZgoZe1aqXIkdFDxR
matrix:
- nodejs_version: 6.9.4
@@ -21,9 +23,8 @@ install:
- npm install
test_script:
- node --version
- npm --version
- npm run build
- npm run build:test
- npm run lint
- npm run test
- npm run release

BIN
build/icon.icns Normal file

Binary file not shown.

BIN
build/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
build/icons/1024x1024.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
build/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
build/icons/16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
build/icons/24x24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
build/icons/256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
build/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
build/icons/48x48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
build/icons/512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
build/icons/64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
build/icons/96x96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -97,7 +97,13 @@ export class UhkDeviceService implements OnDestroy {
if (process.platform !== 'win32' && usbInterface.isKernelDriverActive()) {
usbInterface.detachKernelDriver();
}
usbInterface.claim();
// https://github.com/tessel/node-usb/issues/30
// Mac is not allow excusive right to use USB
if (process.platform !== 'darwin') {
usbInterface.claim();
}
this.messageIn$ = Observable.create((subscriber: Subscriber<Buffer>) => {
const inEndPoint: InEndpoint = <InEndpoint>usbInterface.endpoints[0];
console.log('Try to read');

View File

@@ -1,22 +1,6 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"../../node_modules/@types"
],
"types": [
"electron"
]
},
"extends": "../../tsconfig.json",
"files": [
"electron-main.ts"
]
}
}

View File

@@ -1,30 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"../../node_modules/@types"
],
"types": [
"node",
"jquery",
"core-js",
"select2",
"file-saver",
"electron",
"usb"
]
},
"extends": "../../tsconfig.json",
"exclude": [
"../dist",
"electron-main.ts",
"webpack.config.*"
]
}
}

View File

@@ -1,90 +1,96 @@
{
"name": "uhk-agent",
"version": "1.0.0-alpha.1",
"description": "Agent is the configuration application of the Ultimate Hacking Keyboard.",
"repository": {
"type": "git",
"url": "git@github.com:UltimateHackingKeyboard/agent.git"
},
"license": "GPL-3.0",
"engines": {
"node": ">=6.9.5 <7.0.0",
"npm": ">=3.10.7 <4.0.0"
},
"devDependencies": {
"@ngrx/store-devtools": "3.2.4",
"@ngrx/store-log-monitor": "3.0.2",
"@types/core-js": "0.9.35",
"@types/electron": "^1.4.37",
"@types/file-saver": "0.0.0",
"@types/jquery": "^2.0.40",
"@types/node": "^6.0.70",
"@types/usb": "^1.1.3",
"angular2-template-loader": "0.6.2",
"copy-webpack-plugin": "^4.0.1",
"electron": "1.6.5",
"electron-rebuild": "^1.5.7",
"expose-loader": "^0.7.1",
"html-loader": "0.4.5",
"node-sass": "^4.5.2",
"npm-run-all": "4.0.2",
"path": "^0.12.7",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.3",
"stylelint": "^7.10.1",
"ts-loader": "^2.0.3",
"tslint": "~5.1.0",
"webpack": "^2.4.1",
"webpack-dev-server": "^2.4.4",
"webpack-svgstore-plugin": "4.0.0"
},
"dependencies": {
"@angular/animations": "4.0.3",
"@angular/common": "4.0.3",
"@angular/compiler": "4.0.3",
"@angular/core": "4.0.3",
"@angular/forms": "4.0.3",
"@angular/platform-browser": "4.0.3",
"@angular/platform-browser-dynamic": "4.0.3",
"@angular/router": "4.0.3",
"@ngrx/core": "1.2.0",
"@ngrx/effects": "2.0.3",
"@ngrx/store": "2.2.2",
"bootstrap": "^3.3.7",
"browser-stdout": "^1.3.0",
"buffer": "^5.0.6",
"core-js": "2.4.1",
"dragula": "^3.7.2",
"filesaver.js": "^0.2.0",
"font-awesome": "^4.6.3",
"jquery": "3.2.1",
"json-loader": "^0.5.4",
"ng2-dragula": "1.3.1",
"ng2-select2": "1.0.0-beta.10",
"rxjs": "5.3.0",
"select2": "^4.0.3",
"sudo-prompt": "^7.0.0",
"typescript": "2.2.2",
"usb": "git+https://github.com/aktary/node-usb.git",
"xml-loader": "1.2.1",
"zone.js": "0.8.5"
},
"scripts": {
"postinstall": "run-p build:usb \"symlink -- -i\" ",
"test": "cd ./test-serializer && node ./test-serializer.js",
"lint": "run-s -scn lint:ts lint:style",
"lint:ts": "tslint \"electron/**/*.ts\" \"web/**/*.ts\" \"shared/**/*.ts\" \"test-serializer/**/*.ts\"",
"lint:style": "stylelint \"electron/**/*.scss\" \"web/**/*.scss\" \"shared/**/*.scss\" --syntax scss",
"build": "run-p build:web build:electron",
"build:web": "webpack --config \"web/src/webpack.config.js\"",
"build:electron": "run-s -scn build:electron:main build:electron:app",
"build:electron:main": "webpack --config \"electron/src/webpack.config.electron-main.js\"",
"build:electron:app": "webpack --config \"electron/src/webpack.config.js\"",
"build:usb": "electron-rebuild -w usb -p",
"build:test": "webpack --config \"test-serializer/webpack.config.js\"",
"server:web": "webpack-dev-server --config \"web/src/webpack.config.js\" --content-base \"./web/dist\"",
"server:electron": "webpack --config \"electron/src/webpack.config.js\" --watch",
"electron": "electron electron/dist/electron-main.js",
"symlink": "node ./tools/symlinker"
}
"name": "uhk-agent",
"main": "electron/dist/electron-main.js",
"version": "1.0.0-alpha.1",
"description": "Agent is the configuration application of the Ultimate Hacking Keyboard.",
"repository": {
"type": "git",
"url": "git@github.com:UltimateHackingKeyboard/agent.git"
},
"license": "GPL-3.0",
"engines": {
"node": ">=6.9.5 <7.0.0",
"npm": ">=3.10.7 <4.0.0"
},
"devDependencies": {
"@ngrx/store-devtools": "3.2.4",
"@ngrx/store-log-monitor": "3.0.2",
"@types/core-js": "0.9.35",
"@types/electron": "^1.4.37",
"@types/file-saver": "0.0.0",
"@types/jquery": "^2.0.40",
"@types/node": "^6.0.70",
"@types/usb": "^1.1.3",
"angular2-template-loader": "0.6.2",
"copy-webpack-plugin": "^4.0.1",
"electron": "1.6.5",
"electron-builder": "^18.3.0",
"electron-rebuild": "^1.5.7",
"expose-loader": "^0.7.1",
"html-loader": "0.4.5",
"node-sass": "^4.5.2",
"npm-run-all": "4.0.2",
"path": "^0.12.7",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.3",
"standard-version": "^4.0.0",
"stylelint": "^7.10.1",
"ts-loader": "^2.0.3",
"tslint": "~5.1.0",
"webpack": "^2.4.1",
"webpack-dev-server": "^2.4.4",
"webpack-svgstore-plugin": "4.0.0"
},
"dependencies": {
"@angular/animations": "4.0.3",
"@angular/common": "4.0.3",
"@angular/compiler": "4.0.3",
"@angular/core": "4.0.3",
"@angular/forms": "4.0.3",
"@angular/platform-browser": "4.0.3",
"@angular/platform-browser-dynamic": "4.0.3",
"@angular/router": "4.0.3",
"@ngrx/core": "1.2.0",
"@ngrx/effects": "2.0.3",
"@ngrx/store": "2.2.2",
"bootstrap": "^3.3.7",
"browser-stdout": "^1.3.0",
"buffer": "^5.0.6",
"core-js": "2.4.1",
"dragula": "^3.7.2",
"filesaver.js": "^0.2.0",
"font-awesome": "^4.6.3",
"jquery": "3.2.1",
"json-loader": "^0.5.4",
"ng2-dragula": "1.3.1",
"ng2-select2": "1.0.0-beta.10",
"rxjs": "5.3.0",
"select2": "^4.0.3",
"sudo-prompt": "^7.0.0",
"typescript": "2.2.2",
"usb": "git+https://github.com/aktary/node-usb.git",
"xml-loader": "1.2.1",
"zone.js": "0.8.5"
},
"scripts": {
"postinstall": "run-p build:usb \"symlink -- -i\" ",
"test": "cd ./test-serializer && node ./test-serializer.js",
"lint": "run-s -scn lint:ts lint:style",
"lint:ts": "tslint \"electron/**/*.ts\" \"web/**/*.ts\" \"shared/**/*.ts\" \"test-serializer/**/*.ts\"",
"lint:style": "stylelint \"electron/**/*.scss\" \"web/**/*.scss\" \"shared/**/*.scss\" --syntax scss",
"build": "run-p build:web build:electron",
"build:web": "webpack --config \"web/src/webpack.config.js\"",
"build:electron": "run-s -scn build:electron:main build:electron:app",
"build:electron:main": "webpack --config \"electron/src/webpack.config.electron-main.js\"",
"build:electron:app": "webpack --config \"electron/src/webpack.config.js\"",
"build:usb": "electron-rebuild -w usb -p",
"build:test": "webpack --config \"test-serializer/webpack.config.js\"",
"server:web": "webpack-dev-server --config \"web/src/webpack.config.js\" --content-base \"./web/dist\"",
"server:electron": "webpack --config \"electron/src/webpack.config.js\" --watch",
"electron": "electron electron/dist/electron-main.js",
"symlink": "node ./tools/symlinker",
"standard-version": "standard-version",
"pack": "node ./scripts/release.js",
"release": "node ./scripts/release.js"
}
}

111
scripts/release.js Normal file
View File

@@ -0,0 +1,111 @@
'use strict';
const TEST_BUILD = true; // set true if you would like to test on your local machince
if (!process.env.CI && !TEST_BUILD) {
console.error('Create release only on CI server')
process.exit(1)
}
let branchName = ''
let pullRequestNr = ''
let gitTag = ''
let repoName = ''
if (process.env.TRAVIS) {
branchName = process.env.TRAVIS_BRANCH
pullRequestNr = process.env.TRAVIS_PULL_REQUEST
gitTag = process.env.TRAVIS_TAG
repoName = process.env.TRAVIS_REPO_SLUG
} else if (process.env.APPVEYOR) {
branchName = process.env.APPVEYOR_REPO_BRANCH
pullRequestNr = process.env.APPVEYOR_PULL_REQUEST_NUMBER
gitTag = process.env.APPVEYOR_REPO_TAG_NAME
repoName = process.env.APPVEYOR_REPO_NAME
}
console.log({ branchName, pullRequestNr, gitTag, repoName })
// TODO(Robi): Remove the comment after success tests
const isReleaseCommit = TEST_BUILD || branchName === gitTag //&& repoName === 'ert78gb/electron-playground'
if (!isReleaseCommit) {
console.log('It is not a release task. Skipping publish.')
process.exit(0)
}
const fs = require('fs-extra')
const cp = require('child_process')
const path = require('path')
const builder = require("electron-builder")
const Platform = builder.Platform
let sha = ''
if (process.env.TRAVIS) {
sha = process.env.TRAVIS_COMMIT
} else if (process.env.APPVEYOR) {
sha = process.env.APPVEYOR_REPO_COMMIT
}
let target = ''
if (process.platform === 'darwin') {
target = Platform.MAC.createTarget()
} else if (process.platform === 'win32') {
target = Platform.WINDOWS.createTarget()
} else if (process.platform === 'linux') {
target = Platform.LINUX.createTarget()
} else {
console.error(`I dunno how to publish a release for ${process.platform} :(`)
process.exit(1)
}
if (process.platform === 'darwin') {
// TODO: Remove comment when macOS certificates boughted and exported
//require('./setup-macos-keychain').registerKeyChain()
}
let version = ''
if (TEST_BUILD || gitTag) {
version = gitTag
builder.build({
dir: true,
targets: target,
appMetadata: {
main: 'electron/dist/electron-main.js',
name: 'UHK Agent',
author: {
name: 'Ultimate Gaget Laboratories'
},
},
config: {
appId: 'com.ultimategadgetlabs.uhk.agent',
productName: 'UHK Agent',
mac: {
category: 'public.app-category.utilities',
},
publish: 'github',
files: [
'!**/*',
'electron/dist/**/*',
'node_modules/**/*'
]
},
})
.then(() => {
console.log('Packing success.')
})
.catch((error) => {
console.error(`${error}`)
process.exit(1)
})
}
else {
console.log('No git tag')
// TODO: Need it?
version = sha.substr(0, 8)
process.exit(1)
}

View File

@@ -0,0 +1,20 @@
'use strict'
const cp = require('child_process')
const path = require('path')
function registerKeyChain() {
const encryptedFile = path.join(__dirname, '../certs/developer-id-cert.p12.enc')
const decryptedFile = path.join(__dirname, '../certs/developer-id-cert.p12')
cp.execSync(`openssl aes-256-cbc -K $encrypted_04061b49eb95_key -iv $encrypted_04061b49eb95_iv -in ${encryptedFile} -out ${decryptedFile} -d`)
const keyChain = 'mac-build.keychain'
cp.execSync(`security create-keychain -p travis ${keyChain}`)
cp.execSync(`security default-keychain -s ${keyChain}`)
cp.execSync(`security unlock-keychain -p travis ${keyChain}`)
cp.execSync(`security set-keychain-settings -t 3600 -u ${keyChain}`)
cp.execSync(`security import ${decryptedFile} -k ${keyChain} -P $KEY_PASSWORD -T /usr/bin/codesign`)
}
module.exports.registerKeyChain = registerKeyChain

13
tsconfig.json Normal file
View File

@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}

View File

@@ -1,27 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"../../node_modules/@types"
],
"types": [
"node",
"jquery",
"core-js",
"select2",
"file-saver"
]
},
"extends": "../../tsconfig.json",
"exclude": [
"node_modules",
"config-serializer"
]
}
}