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

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