From d11e35ab9ff8a1f363715184413d4d925701b6e0 Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Thu, 21 Nov 2024 16:27:40 +0100 Subject: [PATCH] Add autoupdate feature --- main.js | 10 +++++++++ package-lock.json | 56 +++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 ++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index cbc6629..9769a71 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,16 @@ +if (require('electron-squirrel-startup')) return; const { app, BrowserWindow, ipcMain, shell } = require('electron'); const path = require('path'); +// Handle events from windows squirrel installer +if (process.platform === "win32" && handleSquirrelEvent()) { + // squirrel event handled and app will exit in 1000ms, so don't do anything else + return; +} + +const { updateElectronApp } = require('update-electron-app') +updateElectronApp() + let mainWindow; let upyPackage; const ARDUINO_VID = 0x2341; diff --git a/package-lock.json b/package-lock.json index 1037b30..dcdaf28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,16 @@ { - "name": "upy-package-installer", + "name": "micropython-package-installer", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "upy-package-installer", + "name": "micropython-package-installer", "version": "1.0.0", "license": "ISC", "dependencies": { + "electron-squirrel-startup": "^1.0.1", + "update-electron-app": "^3.0.0", "upy-package": "github:arduino/upy-package" }, "devDependencies": { @@ -4177,6 +4179,30 @@ "node": ">=10" } }, + "node_modules/electron-squirrel-startup": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/electron-squirrel-startup/-/electron-squirrel-startup-1.0.1.tgz", + "integrity": "sha512-sTfFIHGku+7PsHLJ7v0dRcZNkALrV+YEozINTW8X1nM//e5O3L+rfYuvSW00lmGHnYmUjARZulD8F2V8ISI9RA==", + "license": "Apache-2.0", + "dependencies": { + "debug": "^2.2.0" + } + }, + "node_modules/electron-squirrel-startup/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/electron-squirrel-startup/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, "node_modules/electron-winstaller": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/electron-winstaller/-/electron-winstaller-5.4.0.tgz", @@ -5061,6 +5087,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/github-url-to-object": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/github-url-to-object/-/github-url-to-object-4.0.6.tgz", + "integrity": "sha512-NaqbYHMUAlPcmWFdrAB7bcxrNIiiJWJe8s/2+iOc9vlcHlwHqSGrPk+Yi3nu6ebTwgsZEa7igz+NH2vEq3gYwQ==", + "license": "MIT", + "dependencies": { + "is-url": "^1.1.0" + } + }, "node_modules/glob": { "version": "10.4.5", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", @@ -5628,6 +5663,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-url": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz", + "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==", + "license": "MIT" + }, "node_modules/is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -8752,6 +8793,17 @@ "node": ">= 0.8" } }, + "node_modules/update-electron-app": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/update-electron-app/-/update-electron-app-3.0.0.tgz", + "integrity": "sha512-Ccs46fgUEcMpSRPMNw82DFMux2MGi5tkKkEpV723JmtPNI3qAtxvTeiYkKczN2/LehA3U7JGrGr4MhraxGdRTw==", + "license": "MIT", + "dependencies": { + "github-url-to-object": "^4.0.4", + "is-url": "^1.2.4", + "ms": "^2.1.1" + } + }, "node_modules/upy-package": { "version": "1.0.0", "resolved": "git+ssh://git@github.com/arduino/upy-package.git#7e221ab8dd8c03d25724ab820487c26ba8c5cc41", diff --git a/package.json b/package.json index c296a9d..7e5a84a 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,8 @@ "electron": "^31.3.1" }, "dependencies": { + "electron-squirrel-startup": "^1.0.1", + "update-electron-app": "^3.0.0", "upy-package": "github:arduino/upy-package" } }