Skip to content

Commit

Permalink
macOS auto update support (#445)
Browse files Browse the repository at this point in the history
* auto update support for macOS

* skip manual check for macOS
  • Loading branch information
mbektas authored Apr 22, 2022
1 parent d366d33 commit ba6a891
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ jobs:
tag: v${{ steps.package-info.outputs.version}}
overwrite: true

- name: Upload macOS App as Release asset
if: matrix.cfg.platform == 'mac' && steps.release-exists.outputs.result == 'true'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.JLAB_APP_TOKEN }}
file: dist/JupyterLab.zip
asset_name: JupyterLab-macOS.zip
tag: v${{ steps.package-info.outputs.version}}
overwrite: true

- name: Upload Windows Installer as Release asset
if: matrix.cfg.platform == 'win' && steps.release-exists.outputs.result == 'true'
uses: svenstaro/upload-release-action@v2
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
"mac": {
"category": "public.app-category.productivity",
"target": [
"dmg"
"dmg",
"zip"
],
"icon": "dist-resources/icon.icns",
"entitlements": "build/entitlements.plist",
Expand Down Expand Up @@ -158,7 +159,7 @@
"url": "https://github.com/jupyterlab/jupyterlab-desktop/issues"
},
"homepage": "https://github.com/jupyterlab/jupyterlab-desktop#readme",
"repository": "github:jupyterlab/jupyterlab",
"repository": "https://github.com/jupyterlab/jupyterlab-desktop",
"license": "BSD-3-Clause",
"devDependencies": {
"@types/ejs": "^3.1.0",
Expand Down Expand Up @@ -303,6 +304,7 @@
"react": "^17.0.1",
"react-dom": "^17.0.1",
"semver": "^7.3.4",
"update-electron-app": "^2.0.1",
"which": "^2.0.2",
"winreg": "^1.2.4",
"yargs": "^16.2.0"
Expand Down
5 changes: 4 additions & 1 deletion src/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ export class JupyterApplication implements IApplication, IStatefulService {
);
}

if (this._applicationState.checkForUpdatesAutomatically) {
if (
process.platform !== 'darwin' &&
this._applicationState.checkForUpdatesAutomatically
) {
setTimeout(() => {
this._checkForUpdates('on-new-version');
}, 5000);
Expand Down
26 changes: 25 additions & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, dialog, WebContents } from 'electron';
import { app, autoUpdater, BrowserWindow, dialog, WebContents } from 'electron';

const Bottle = require('bottlejs');
import log from 'electron-log';
Expand All @@ -11,6 +11,30 @@ import { AddressInfo, createServer } from 'net';
import { appConfig, getAppDir, isDevMode } from './utils';
import { execSync } from 'child_process';

autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : 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();
});
});

autoUpdater.on('error', message => {
log.error('There was a problem updating the application');
log.error(message);
});

if (process.platform === 'darwin') {
require('update-electron-app')();
}

async function getFreePort(): Promise<number> {
return new Promise<number>(resolve => {
const getPort = () => {
Expand Down
32 changes: 32 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3677,6 +3677,11 @@ electron-builder@^23.0.2:
update-notifier "^5.1.0"
yargs "^17.0.1"

electron-is-dev@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-0.3.0.tgz#14e6fda5c68e9e4ecbeff9ccf037cbd7c05c5afe"
integrity sha1-FOb9pcaOnk7L7/nM8DfL18BcWv4=

electron-log@^4.3.2:
version "4.4.3"
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-4.4.3.tgz#01c7f776e0b424b4958662ca7a043344a5fa645f"
Expand Down Expand Up @@ -4335,6 +4340,13 @@ get-symbol-description@^1.0.0:
call-bind "^1.0.2"
get-intrinsic "^1.1.1"

github-url-to-object@^4.0.4:
version "4.0.6"
resolved "https://registry.yarnpkg.com/github-url-to-object/-/github-url-to-object-4.0.6.tgz#5ea8701dc8c336b8d582dc3fa5bf964165c3b365"
integrity sha512-NaqbYHMUAlPcmWFdrAB7bcxrNIiiJWJe8s/2+iOc9vlcHlwHqSGrPk+Yi3nu6ebTwgsZEa7igz+NH2vEq3gYwQ==
dependencies:
is-url "^1.1.0"

glob-parent@^5.0.0, glob-parent@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
Expand Down Expand Up @@ -4896,6 +4908,11 @@ is-typedarray@^1.0.0:
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=

is-url@^1.1.0, is-url@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52"
integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==

is-weakref@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2"
Expand Down Expand Up @@ -5478,6 +5495,11 @@ ms@2.1.2:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

ms@^2.1.1:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

nanoid@^3.1.23, nanoid@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35"
Expand Down Expand Up @@ -7122,6 +7144,16 @@ universalify@^2.0.0:
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==

update-electron-app@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/update-electron-app/-/update-electron-app-2.0.1.tgz#229dbeb4534f51ec949e6a46ae1ac32f68a17eed"
integrity sha512-e4xEner89UZZaBGYJbYlMdL1uUrC0VjOsTAL2N4opPjzFtn+j7mdsJJsnyXZzUVeLY+8tuCX4XEsUM98oBHmZg==
dependencies:
electron-is-dev "^0.3.0"
github-url-to-object "^4.0.4"
is-url "^1.2.4"
ms "^2.1.1"

update-notifier@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-5.1.0.tgz#4ab0d7c7f36a231dd7316cf7729313f0214d9ad9"
Expand Down

0 comments on commit ba6a891

Please sign in to comment.