From: riqo Date: Tue, 13 Apr 2021 13:41:40 +0000 (-0500) Subject: add electron-update to background.ts X-Git-Tag: v0.9.1~1^2 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=662fc591c3fe9d924add68ff5eeb1429ead38ce8;p=mime-chat add electron-update to background.ts --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2deff91..fe8056b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,7 @@ upload: when: never # Do not run this job when a tag is created manually - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when when commits are pushed to the default branch script: - - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "./dist/${WIN_BINARY}" "${PACKAGE_REGISTRY_URL}/${WIN_BINARY}"' + - 'curl --header "JOB-TOKEN: $CI_DEPLOY_PASSWORD" --upload-file "./dist/${WIN_BINARY}" "${PACKAGE_REGISTRY_URL}/${WIN_BINARY}"' auto-release-master: image: registry.gitlab.com/gitlab-org/release-cli diff --git a/package.json b/package.json index 956284f..5e70fc9 100644 --- a/package.json +++ b/package.json @@ -9,29 +9,27 @@ }, "main": "./src/background.ts", "scripts": { - "dev": "yarn electron:serve", + "dev": "vue-cli-service electron:serve", "serve": "vue-cli-service serve", - "build": "vue-cli-service build", + "build": "electron-builder --win", "test:unit": "vue-cli-service test:unit", "lint": "vue-cli-service lint", "electron:build": "vue-cli-service electron:build", "electron:serve": "vue-cli-service electron:serve", "postinstall": "electron-builder install-app-deps", "postuninstal": "electron-builder install-app-deps", - "dist":"electron-builder --publish always", - "dev": "vue-cli-service electron:serve", - "build": "electron-builder --win" + "dist": "electron-builder --publish always" }, "repository": { - "type" : "git", - "url" : "https://gitlab.com/crimata/electron-app.git", + "type": "git", + "url": "https://gitlab.com/crimata/electron-app.git", "release": "latest" }, "build": { "artifactName": "${productName}-${version}.${ext}", "publish": { - "provider": "generic", - "url": "https://gitlab.com/api/v4/projects/25637892/jobs/artifacts/master/raw/dist?job=build" + "provider": "generic", + "url": "https://gitlab.com/api/v4/projects/25637892/jobs/artifacts/master/raw/dist?job=build" }, "win": { "target": [ @@ -84,6 +82,7 @@ "@wasm-tool/wasm-pack-plugin": "^1.3.1", "electron": "^9.0.0", "electron-devtools-installer": "^3.1.0", + "electron-log": "^4.3.4", "eslint": "^6.7.2", "eslint-plugin-vue": "^7.0.0-0", "lint-staged": "^9.5.0", diff --git a/src/background.ts b/src/background.ts index 1613f63..abb1961 100644 --- a/src/background.ts +++ b/src/background.ts @@ -5,7 +5,9 @@ "use strict"; -import { protocol, autoUpdater, dialog } from "electron"; +import { protocol, dialog } from "electron"; +const { autoUpdater } = require('electron-updater') +const log = require("electron-log") import { initApp } from './background/init'; // Scheme must be registered before the app is ready @@ -16,31 +18,55 @@ protocol.registerSchemesAsPrivileged([ // Load environment variable const isDev = require('electron-is-dev'); + + +// setTimeout(function () { +// autoUpdater.checkForUpdatesAndNotify() +// }, 10000) + +// Check for an update every 2min. +// setInterval(() => { +// autoUpdater.checkForUpdatesAndNotify() +// }, 120000) + // NOTE Program Begins Here (async () => { + autoUpdater.requestHeaders = { 'PRIVATE-TOKEN': 'seMF_apn237iUw8puG9a' } + autoUpdater.logger = log; + + // Check for an update 10sec after Program Starts + setTimeout(function () { + autoUpdater.checkForUpdatesAndNotify() + }, 10000) + + // Check for an update every 2min. + setInterval(() => { + autoUpdater.checkForUpdatesAndNotify() + }, 120000) console.log('Starting Crimata electron app.'); initApp(isDev); })(); -// Auto app updates. -if (!isDev) { - autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { - const dialogOpts = { - type: 'info', - buttons: ['Restart', 'Later'], - title: 'Application Update', - message: releaseName, - detail: 'A new version has been downloaded. Restart the application to apply the updates.' - } - - dialog.showMessageBox(dialogOpts).then((returnValue) => { - if (returnValue.response === 0) autoUpdater.quitAndInstall() - }) - }) - setInterval(() => { - autoUpdater.checkForUpdates() - }, 5000) -} \ No newline at end of file +// Auto app updates. +// if (!isDev) { +// autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { +// const dialogOpts = { +// type: 'info', +// buttons: ['Restart', 'Later'], +// title: 'Application Update', +// message: releaseName, +// detail: 'A new version has been downloaded. Restart the application to apply the updates.' +// } +// +// dialog.showMessageBox(dialogOpts).then((returnValue) => { +// if (returnValue.response === 0) autoUpdater.quitAndInstall() +// }) +// }) +// +// setInterval(() => { +// autoUpdater.checkForUpdates() +// }, 5000) +// } diff --git a/yarn.lock b/yarn.lock index 8d5a2cf..68771b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5121,6 +5121,11 @@ electron-is-dev@^2.0.0: resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-2.0.0.tgz#833487a069b8dad21425c67a19847d9064ab19bd" integrity sha512-3X99K852Yoqu9AcW50qz3ibYBWY79/pBhlMCab8ToEWS48R0T9tyxRiQhwylE7zQdXrMnx2JKqUJyMPmt5FBqA== +electron-log@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-4.3.4.tgz#97e991dcd653e759e14eb2ae5d6ba4440f50afd8" + integrity sha512-Cd6xZ9if2J4NG+PNoi3cARAYoanbM4ddpod0faaL5LIhmwuSdxP9XH95C9SgTpHMqklbg8u3CFh1yqiaqo2Bng== + electron-publish@22.9.1: version "22.9.1" resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-22.9.1.tgz#7cc76ac4cc53efd29ee31c1e5facb9724329068e"