Add 'New update available' dialog to the electron version (#299)

* build(tsconfig): Rename root tsconfig.json -> tsconfig.base.json

* feat(auto-update): Add update dialog

When new update available than new message will visible of the top of the screen with 2 buttons 'Update' and 'Close'.
- Update button: Update the application (close and restart)
- Close button: Hide the updatePanel

* fix(auto-update): Add types to the event methods

* style: Add comma after SafeStylePipe import

I forgot add the comma when I rebased the branch

* fix(auto-update): Use electron-is-dev package to detect dev build

I removed the isDev() function from the shared util library because it is electron specific code.

* ci: Change osx_image: xcode8.3

Recommended after the last travis upgrade

* feat(auto-update): Add auto update settings page and save config save on electron platform

* ci: Fix osx image

* ci: Upgrade the electron builder -> 19.6.1

The builder now use the 2 package.json structure and build only
the necessary dependencies.
This commit is contained in:
Róbert Kiss
2017-06-22 14:22:54 +02:00
committed by László Monda
parent 2598109f8c
commit 121807a65a
49 changed files with 1028 additions and 129 deletions

View File

@@ -1,111 +1,129 @@
'use strict';
const jsonfile = require('jsonfile');
const TEST_BUILD = false; // 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)
console.error('Create release only on CI server');
process.exit(1);
}
let branchName = ''
let pullRequestNr = ''
let gitTag = ''
let repoName = ''
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
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
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 })
console.log({branchName, pullRequestNr, gitTag, repoName});
// TODO(Robi): Remove the comment after success tests
const isReleaseCommit = TEST_BUILD || branchName === gitTag && repoName === 'UltimateHackingKeyboard/agent'
const isReleaseCommit = TEST_BUILD || branchName === gitTag && repoName === 'UltimateHackingKeyboard/agent';
if (!isReleaseCommit) {
console.log('It is not a release task. Skipping publish.')
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
const fs = require('fs-extra');
const cp = require('child_process');
const path = require('path');
const builder = require("electron-builder");
const Platform = builder.Platform;
const electron_build_folder = path.join(__dirname, '../electron/dist');
let sha = ''
let sha = '';
if (process.env.TRAVIS) {
sha = process.env.TRAVIS_COMMIT
sha = process.env.TRAVIS_COMMIT;
} else if (process.env.APPVEYOR) {
sha = process.env.APPVEYOR_REPO_COMMIT
sha = process.env.APPVEYOR_REPO_COMMIT;
}
let target = ''
let target = '';
let artifactName = 'UHK.Agent-${version}-${os}';
if (process.platform === 'darwin') {
target = Platform.MAC.createTarget()
target = Platform.MAC.createTarget();
artifactName += '.${ext}';
} else if (process.platform === 'win32') {
target = Platform.WINDOWS.createTarget()
target = Platform.WINDOWS.createTarget();
artifactName += '-${arch}.${ext}';
} else if (process.platform === 'linux') {
target = Platform.LINUX.createTarget()
target = Platform.LINUX.createTarget();
artifactName += '.${ext}';
} else {
console.error(`I dunno how to publish a release for ${process.platform} :(`)
process.exit(1)
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()
//require('./setup-macos-keychain').registerKeyChain();
}
let version = ''
let version = '';
if (TEST_BUILD || gitTag) {
version = gitTag
const jsonVersion = require('../package.json').version;
version = gitTag;
updateVersionNumberIn2rndPackageJson(jsonVersion);
builder.build({
dir: true,
targets: target,
appMetadata: {
main: 'electron/dist/electron-main.js',
main: 'electron-main.js',
name: 'UHK Agent',
author: {
name: 'Ultimate Gaget Laboratories'
name: 'Ultimate Gadget Laboratories'
},
version: jsonVersion
},
config: {
directories: {
app: electron_build_folder
},
appId: 'com.ultimategadgetlabs.uhk.agent',
productName: 'UHK Agent',
mac: {
category: 'public.app-category.utilities',
category: 'public.app-category.utilities'
},
publish: 'github',
artifactName,
files: [
'!**/*',
'electron/dist/**/*',
'node_modules/**/*'
'**/*'
]
},
})
.then(() => {
console.log('Packing success.')
console.log('Packing success.');
})
.catch((error) => {
console.error(`${error}`)
process.exit(1)
console.error(`${error}`);
process.exit(1);
})
}
else {
console.log('No git tag')
console.log('No git tag');
// TODO: Need it?
version = sha.substr(0, 8)
process.exit(1)
version = sha.substr(0, 8);
process.exit(1);
}
function updateVersionNumberIn2rndPackageJson(version) {
const jsonPath = path.join(__dirname,'../electron/dist/package.json');
const json = require(jsonPath);
json.version = version;
jsonfile.writeFileSync(jsonPath, json, {spaces: 2})
}