]> Repos - mime-chat/commitdiff
add electron-update to background.ts auto_update
authorriqo <hernandeze2@xavier.edu>
Tue, 13 Apr 2021 13:41:40 +0000 (08:41 -0500)
committerriqo <hernandeze2@xavier.edu>
Tue, 13 Apr 2021 13:41:40 +0000 (08:41 -0500)
.gitlab-ci.yml
package.json
src/background.ts
yarn.lock

index 2deff91e3949b489104736e5d74e2f9df6570230..fe8056b435b292238cabe1cc2e8222b27dd674f8 100644 (file)
@@ -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
index 956284fe30d784ee6206f37451e97761aa861bcb..5e70fc9156c97462536b77e25729d5c0ab6c390d 100644 (file)
@@ -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",
index 1613f6330af361bd60e73340f9890179cfce5169..abb19614080bbfe3d979c97cb10c7576fbc619de 100644 (file)
@@ -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)
+// }
index 8d5a2cfd61ef84f61630987fcdb12036a37ae560..68771b8ede72e9969fdb35ac35507a199d10c847 100644 (file)
--- 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"