updater plugin

desktopautoupdate
filip mertens 1 year ago
parent 863af35478
commit 9c53587e20
  1. 2
      apps/remix-ide/ci/update_desktop_release_assets.ts
  2. 7
      apps/remix-ide/src/app.js
  3. 14
      apps/remix-ide/src/app/plugins/electron/appUpdaterPlugin.ts
  4. 3
      apps/remixdesktop/src/engine.ts
  5. 63
      apps/remixdesktop/src/plugins/appUpdater.ts
  6. 2
      apps/remixdesktop/src/plugins/compilerLoader.ts
  7. 2
      apps/remixdesktop/src/preload.ts

@ -23,7 +23,7 @@ async function getAllReleases() {
async function uploadReleaseAsset(release, name, file) { async function uploadReleaseAsset(release, name, file) {
const upload_url = release.upload_url const upload_url = release.upload_url
console.log(upload_url) console.log(`Uploading ${name} to ${upload_url}`)
octokit.request({ octokit.request({
method: "POST", method: "POST",
url: upload_url, url: upload_url,

@ -57,7 +57,8 @@ import { electronTemplates } from './app/plugins/electron/templatesPlugin'
import { xtermPlugin } from './app/plugins/electron/xtermPlugin' import { xtermPlugin } from './app/plugins/electron/xtermPlugin'
import { ripgrepPlugin } from './app/plugins/electron/ripgrepPlugin' import { ripgrepPlugin } from './app/plugins/electron/ripgrepPlugin'
import { compilerLoaderPlugin, compilerLoaderPluginDesktop } from './app/plugins/electron/compilerLoaderPlugin' import { compilerLoaderPlugin, compilerLoaderPluginDesktop } from './app/plugins/electron/compilerLoaderPlugin'
import { appUpdaterPlugin } from './app/plugins/electron/appUpdaterPlugin'
import {OpenAIGpt} from './app/plugins/openaigpt' import {OpenAIGpt} from './app/plugins/openaigpt'
const isElectron = require('is-electron') const isElectron = require('is-electron')
@ -377,6 +378,8 @@ class AppComponent {
this.engine.register([xterm]) this.engine.register([xterm])
const ripgrep = new ripgrepPlugin() const ripgrep = new ripgrepPlugin()
this.engine.register([ripgrep]) this.engine.register([ripgrep])
const appUpdater = new appUpdaterPlugin()
this.engine.register([appUpdater])
} }
const compilerloader = isElectron()? new compilerLoaderPluginDesktop(): new compilerLoaderPlugin() const compilerloader = isElectron()? new compilerLoaderPluginDesktop(): new compilerLoaderPlugin()
@ -500,7 +503,7 @@ class AppComponent {
await this.appManager.activatePlugin(['solidity-script', 'remix-templates']) await this.appManager.activatePlugin(['solidity-script', 'remix-templates'])
if (isElectron()){ if (isElectron()){
await this.appManager.activatePlugin(['isogit', 'electronconfig', 'electronTemplates', 'xterm', 'ripgrep']) await this.appManager.activatePlugin(['isogit', 'electronconfig', 'electronTemplates', 'xterm', 'ripgrep', 'appUpdater'])
} }
this.appManager.on( this.appManager.on(

@ -0,0 +1,14 @@
import { ElectronPlugin } from '@remixproject/engine-electron'
const profile = {
displayName: 'appUpdater',
name: 'appUpdater',
description: 'appUpdater',
}
export class appUpdaterPlugin extends ElectronPlugin {
constructor() {
console.log('appUpdaterPlugin')
super(profile)
}
}

@ -9,6 +9,7 @@ import { ConfigPlugin } from './plugins/configPlugin';
import { TemplatesPlugin } from './plugins/templates'; import { TemplatesPlugin } from './plugins/templates';
import { RipgrepPlugin } from './plugins/ripgrepPlugin'; import { RipgrepPlugin } from './plugins/ripgrepPlugin';
import { CompilerLoaderPlugin } from './plugins/compilerLoader'; import { CompilerLoaderPlugin } from './plugins/compilerLoader';
import { AppUpdaterPlugin } from './plugins/appUpdater';
const engine = new Engine() const engine = new Engine()
const appManager = new PluginManager() const appManager = new PluginManager()
@ -19,6 +20,7 @@ const configPlugin = new ConfigPlugin()
const templatesPlugin = new TemplatesPlugin() const templatesPlugin = new TemplatesPlugin()
const ripgrepPlugin = new RipgrepPlugin() const ripgrepPlugin = new RipgrepPlugin()
const compilerLoaderPlugin = new CompilerLoaderPlugin() const compilerLoaderPlugin = new CompilerLoaderPlugin()
const appUpdaterPlugin = new AppUpdaterPlugin()
engine.register(appManager) engine.register(appManager)
engine.register(fsPlugin) engine.register(fsPlugin)
@ -28,6 +30,7 @@ engine.register(configPlugin)
engine.register(templatesPlugin) engine.register(templatesPlugin)
engine.register(ripgrepPlugin) engine.register(ripgrepPlugin)
engine.register(compilerLoaderPlugin) engine.register(compilerLoaderPlugin)
engine.register(appUpdaterPlugin)
appManager.activatePlugin('electronconfig') appManager.activatePlugin('electronconfig')
appManager.activatePlugin('fs') appManager.activatePlugin('fs')

@ -1,11 +1,17 @@
import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron" import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron"
import { Profile } from "@remixproject/plugin-utils" import { Profile } from "@remixproject/plugin-utils"
import { autoUpdater } from "electron" import { autoUpdater } from "electron"
import { profile } from "node:console"
export class appUpdaterPlugin extends ElectronBasePlugin { const profile = {
displayName: 'appUpdater',
name: 'appUpdater',
description: 'appUpdater',
}
export class AppUpdaterPlugin extends ElectronBasePlugin {
constructor() { constructor() {
super(profile, clientProfile, appUpdaterPluginClient) console.log('AppUpdaterPlugin')
super(profile, clientProfile, AppUpdaterPluginClient)
this.methods = [...super.methods] this.methods = [...super.methods]
} }
} }
@ -17,23 +23,66 @@ const clientProfile: Profile = {
methods: ['checkForUpdates'], methods: ['checkForUpdates'],
} }
class appUpdaterPluginClient extends ElectronBasePluginClient { class AppUpdaterPluginClient extends ElectronBasePluginClient {
constructor(webContentsId: number, profile: Profile) { constructor(webContentsId: number, profile: Profile) {
console.log('AppUpdaterPluginClient')
super(webContentsId, profile) super(webContentsId, profile)
} }
async onActivation(): Promise<void> { async onActivation(): Promise<void> {
console.log('onActivation', 'appUpdaterPluginClient') console.log('onActivation', 'appUpdaterPluginClient')
this.onload(() => { this.onload(async () => {
console.log('onload', 'appUpdaterPluginClient') console.log('onload', 'appUpdaterPluginClient')
this.emit('loaded') this.emit('loaded')
autoUpdater.on('checking-for-update', () => {
console.log('Checking for update...');
this.call('terminal', 'log', {
type: 'log',
value: 'Checking for update...',
})
})
autoUpdater.on('update-available', (info: any) => {
console.log('Update available.', info);
this.call('terminal', 'log', {
type: 'log',
value: 'Update available.',
})
})
autoUpdater.on('update-not-available', () => {
console.log('Update not available.');
this.call('terminal', 'log', {
type: 'log',
value: 'Update not available.',
})
})
autoUpdater.on('error', (err) => {
console.log('Error in auto-updater. ' + err);
this.call('terminal', 'log', {
type: 'log',
value: 'Error in auto-updater. ' + err,
})
})
autoUpdater.on('update-downloaded', (info) => {
console.log('Update downloaded');
this.call('terminal', 'log', {
type: 'log',
value: 'Update downloaded',
})
autoUpdater.quitAndInstall();
})
await this.checkForUpdates()
}) })
}
}
async checkForUpdates(): Promise<void> { async checkForUpdates(): Promise<void> {
console.log('checkForUpdates') console.log('checkForUpdates')
this.call('terminal', 'log', {
type: 'log',
value: 'Checking for updates...',
})
autoUpdater.checkForUpdates() autoUpdater.checkForUpdates()
} }
} }
export default appUpdaterPlugin

@ -66,9 +66,7 @@ class CompilerLoaderPluginClient extends ElectronBasePluginClient {
} }
async onActivation(): Promise<void> { async onActivation(): Promise<void> {
console.log('onActivation', 'CompilerLoaderPluginClient')
this.onload(() => { this.onload(() => {
console.log('onload', 'CompilerLoaderPluginClient')
this.emit('loaded') this.emit('loaded')
}) })
} }

@ -6,7 +6,7 @@ console.log('preload.ts', new Date().toLocaleTimeString())
/* preload script needs statically defined API for each plugin */ /* preload script needs statically defined API for each plugin */
const exposedPLugins = ['fs', 'git', 'xterm', 'isogit', 'electronconfig', 'electronTemplates', 'ripgrep', 'compilerloader'] const exposedPLugins = ['fs', 'git', 'xterm', 'isogit', 'electronconfig', 'electronTemplates', 'ripgrep', 'compilerloader', 'appUpdater']
let webContentsId: number | undefined let webContentsId: number | undefined

Loading…
Cancel
Save