mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-16 21:59:28 +00:00
Add updates check
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
"css-element-queries": "^1.2.0",
|
||||
"dateformat": "^3.0.3",
|
||||
"deepmerge": "2.0.1",
|
||||
"electron-updater": "^4.6.1",
|
||||
"fuzzy": "^0.1.3",
|
||||
"glob": "^7.1.6",
|
||||
"google-protobuf": "^3.11.4",
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { Command, CommandContribution, CommandRegistry } from "@theia/core";
|
||||
import { injectable, inject } from "inversify";
|
||||
import { CancellationToken } from "electron-updater";
|
||||
import { IDEUpdater } from "./ide-updater";
|
||||
|
||||
// IDEUpdaterCommands register commands used to verify if there
|
||||
// are new IDE updates, download them, and install them.
|
||||
@injectable()
|
||||
export class IDEUpdaterCommands implements CommandContribution {
|
||||
private readonly cancellationToken = new CancellationToken();
|
||||
|
||||
constructor(
|
||||
@inject(IDEUpdater) private readonly updater: IDEUpdater
|
||||
) {
|
||||
}
|
||||
|
||||
registerCommands(registry: CommandRegistry): void {
|
||||
registry.registerCommand(IDEUpdaterCommands.CHECK_FOR_UPDATES, {
|
||||
execute: this.checkForUpdates,
|
||||
});
|
||||
registry.registerCommand(IDEUpdaterCommands.DOWNLOAD_UPDATE, {
|
||||
execute: this.downloadUpdate,
|
||||
})
|
||||
registry.registerCommand(IDEUpdaterCommands.STOP_DOWNLOAD, {
|
||||
execute: this.stopDownload,
|
||||
})
|
||||
registry.registerCommand(IDEUpdaterCommands.INSTALL_UPDATE, {
|
||||
execute: this.quitAndInstall,
|
||||
})
|
||||
}
|
||||
|
||||
checkForUpdates() {
|
||||
this.updater.checkForUpdates();
|
||||
}
|
||||
|
||||
downloadUpdate() {
|
||||
this.updater.downloadUpdate(this.cancellationToken);
|
||||
}
|
||||
|
||||
stopDownload() {
|
||||
this.cancellationToken.cancel();
|
||||
}
|
||||
|
||||
quitAndInstall() {
|
||||
this.updater.quitAndInstall();
|
||||
}
|
||||
}
|
||||
export namespace IDEUpdaterCommands {
|
||||
export const CHECK_FOR_UPDATES: Command = {
|
||||
id: 'arduino-ide-check-for-updates',
|
||||
};
|
||||
export const DOWNLOAD_UPDATE: Command = {
|
||||
id: 'arduino-ide-download-update',
|
||||
};
|
||||
export const STOP_DOWNLOAD: Command = {
|
||||
id: 'arduino-ide-stop-download',
|
||||
};
|
||||
export const INSTALL_UPDATE: Command = {
|
||||
id: 'arduino-ide-install-update',
|
||||
};
|
||||
}
|
||||
74
arduino-ide-extension/src/browser/ide-updater/ide-updater.ts
Normal file
74
arduino-ide-extension/src/browser/ide-updater/ide-updater.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { injectable } from "@theia/core/shared/inversify";
|
||||
import { Emitter } from "@theia/core/shared/vscode-languageserver-protocol";
|
||||
import { AllPublishOptions } from "builder-util-runtime";
|
||||
import {
|
||||
AppUpdater,
|
||||
AppImageUpdater,
|
||||
MacUpdater,
|
||||
NsisUpdater,
|
||||
UpdateInfo,
|
||||
ProgressInfo,
|
||||
CancellationToken
|
||||
} from "electron-updater";
|
||||
|
||||
// IDEUpdater TODO docs
|
||||
@injectable()
|
||||
export class IDEUpdater {
|
||||
private updater: AppUpdater;
|
||||
|
||||
protected readonly checkingForUpdateEmitter = new Emitter<void>();
|
||||
protected readonly updateAvailableEmitter = new Emitter<UpdateInfo>();
|
||||
protected readonly updateNotAvailableEmitter = new Emitter<UpdateInfo>();
|
||||
protected readonly downloadProgressEmitter = new Emitter<ProgressInfo>();
|
||||
protected readonly downloadFinishedEmitter = new Emitter<UpdateInfo>();
|
||||
protected readonly errorEmitter = new Emitter<Error>();
|
||||
|
||||
readonly onCheckingForUpdate = this.checkingForUpdateEmitter.event;
|
||||
readonly onUpdateAvailable = this.updateAvailableEmitter.event;
|
||||
readonly onUpdateNotAvailable = this.updateNotAvailableEmitter.event;
|
||||
readonly onDownloadProgressChanged = this.downloadProgressEmitter.event;
|
||||
readonly onDownloadFinished = this.downloadFinishedEmitter.event;
|
||||
readonly onError = this.errorEmitter.event;
|
||||
|
||||
constructor() {
|
||||
const options: AllPublishOptions = {
|
||||
provider: "s3",
|
||||
bucket: "",
|
||||
region: "",
|
||||
acl: "public-read",
|
||||
endpoint: "https://{service}.{region}.amazonaws.com",
|
||||
channel: "",
|
||||
}
|
||||
// TODO: Search S3 bucket name for the two channels
|
||||
// https://downloads.arduino.cc/arduino-ide/arduino-ide_2.0.0-rc2_Linux_64bit.zip
|
||||
// https://downloads.arduino.cc/arduino-ide/nightly/arduino-ide_nightly-latest_Linux_64bit.zip
|
||||
|
||||
if (process.platform === "win32") {
|
||||
this.updater = new NsisUpdater(options)
|
||||
} else if (process.platform === "darwin") {
|
||||
this.updater = new MacUpdater(options)
|
||||
} else {
|
||||
this.updater = new AppImageUpdater(options)
|
||||
}
|
||||
this.updater.autoDownload = false;
|
||||
|
||||
this.updater.on("checking-for-update", this.checkingForUpdateEmitter.fire);
|
||||
this.updater.on("update-available", this.updateAvailableEmitter.fire);
|
||||
this.updater.on("update-not-available", this.updateNotAvailableEmitter.fire);
|
||||
this.updater.on("download-progress", this.downloadFinishedEmitter.fire);
|
||||
this.updater.on("update-downloaded", this.downloadFinishedEmitter.fire);
|
||||
this.updater.on("error", this.errorEmitter.fire);
|
||||
}
|
||||
|
||||
checkForUpdates() {
|
||||
this.updater.checkForUpdates();
|
||||
}
|
||||
|
||||
downloadUpdate(cancellationToken?: CancellationToken) {
|
||||
this.updater.downloadUpdate(cancellationToken);
|
||||
}
|
||||
|
||||
quitAndInstall() {
|
||||
this.updater.quitAndInstall();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user