Closed philippfo9 closed 7 years ago
Hi, What error you are getting ? I have the following code and it is working fine It will update when ever i am restarting the app
package.json
"build": {
"appId": "com.amazon.myapp",
"icon": "resources/images/my.ico",
"asar": true,
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
}
],
"publish": {
"provider": "s3",
"bucket": "your bucket"
}
}
}
main.js
const {autoUpdater} = require("electron-updater");
app.on('ready', function() {
if(win.webContents){
if(process.mainModule.filename.indexOf('app.asar') === -1){
win.webContents.openDevTools();
console.log("It is in dev mode dont check for auto update ");
}else{
autoUpdater.checkForUpdates();
}
}
autoUpdater.on('update-downloaded',function(info) {
win.webContents.executeJavaScript("alert('New update is Available ! Once You give ok tool will restart');");
setTimeout(function() {
autoUpdater.quitAndInstall();
}, 100)
});
});
Hey, my build looks like this: "build": { "appId": "com.orderstar.kassa", "productName": "Orderstar Kassa", "icon": "build/orderstar-kassa.ico", "files": [ "www/*/", "electron/*" ], "win": { "target": "nsis",
"publish": {
"provider": "s3",
"bucket": "orderstar-release",
"path": "benutzer-win64",
"channel": "latest"
}
}
}
I made the bucket public and added AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables. If I just run it in dev mode I get:
[14:37:23.289] [error] Error: Error: Cannot find channel "latest.yml" update inf o: HttpError: 404 Not Found "method: undefined url: https://orderstar-release.s3.amazonaws.com//benutzer-win 64/latest.yml\n\nPlease double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404.\n" Headers: { "content-type": [ "application/xml" ], "date": [ "Sat, 30 Sep 2017 12:37:16 GMT" ], "server": [ "AmazonS3" ], "transfer-encoding": [ "chunked" ], "x-amz-id-2": [ "Jys2pZBLMbg5bxVHUCfmraRg6PccX5dQ3CkwziATIoYdb7IeYK9W3NP6qsjk4+qzLrrZ98VBXTY =" ], "x-amz-request-id": [ "47C769A2CEA7C6FA" ] }
Do I have to configure something else to get it running?
@philippfo9 you forgot to publish update metadata file.
But as @myfrndjk said, just use electron-builder to publish. To publish from local machine, you must explicitly pass CLI --publish=always https://www.electron.build/configuration/publish
2.8.9
I configured the autoupdater, like it is said in the documentation.
I included the electron-updater dependency, also the electron-log and the electron-publisher-s3. At first, it doesn't automatically upload to S3, although I configured the credentials at the right place. But that's not a big deal. When I install the programm and start it, I get a message in the console: 'Error in auto-updater.'
I don't get more error messages. Can you help me to get more or solve the problem at all?
Another question: Is it even possible to directly upload to S3 with the autoUpdater?
my package.json, with the publish configured:
{ "name": "Orderstar-Kassa", "version": "0.0.6", "author": { "name": "Philipp Fock" }, "homepage": "http://ionicframework.com/", "private": true, "scripts": { "dev": "nf start", "start": "ionic-app-scripts serve", "electron": "electron .", "ebuild": "build", "postinstall": "electron-builder install-app-deps", "clean": "ionic-app-scripts clean", "build": "ionic-app-scripts build", "lint": "ionic-app-scripts lint", "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve" }, "dependencies": { "@angular/common": "4.1.3", "@angular/compiler": "4.1.3", "@angular/compiler-cli": "4.1.3", "@angular/core": "4.1.3", "@angular/forms": "4.1.3", "@angular/http": "4.1.3", "@angular/platform-browser": "4.1.3", "@angular/platform-browser-dynamic": "4.1.3", "@ionic-native/core": "^4.1.0", "@ionic-native/printer": "^4.1.0", "@ionic-native/splash-screen": "3.12.1", "@ionic-native/status-bar": "3.12.1", "@ionic/storage": "2.0.1", "angular2-image-upload": "^0.6.6", "cordova": "^6.5.0", "cordova-android": "^6.2.3", "cordova-browser": "^4.1.0", "cordova-plugin-console": "^1.0.5", "cordova-plugin-device": "^1.1.4", "cordova-plugin-printer": "^0.7.3", "cordova-plugin-splashscreen": "^4.0.3", "cordova-plugin-statusbar": "^2.2.2", "cordova-plugin-whitelist": "^1.3.1", "electron-log": "^2.2.9", "electron-publisher-s3": "^19.28.3", "electron-updater": "^2.8.9", "ionic-angular": "3.5.3", "ionic-plugin-keyboard": "^2.2.1", "ionicons": "3.0.0", "lodash": "^4.17.4", "ngx-electron": "^1.0.3", "rxjs": "5.4.0", "sw-toolbox": "3.6.0", "zone.js": "0.8.12" }, "devDependencies": { "@ionic/app-scripts": "2.0.2", "@ionic/cli-plugin-cordova": "1.6.2", "@ionic/cli-plugin-ionic-angular": "1.4.1", "@types/electron": "^1.6.10", "electron": "^1.7.5", "electron-builder": "^19.22.1", "foreman": "^2.0.0", "ionic": "3.9.2", "typescript": "2.3.4" }, "description": "orderstar - more than a registrierkassensoftware", "main": "electron/electron.js", "config": { "ionic_bundler": "webpack", "ionic_webpack": "./config/webpack.config.js" }, "build": { "appId": "com.orderstar.kassa", "productName": "Orderstar Kassa", "publish": { "provider": "s3", "bucket": "orderstar-release", "path": "/benutzer-win32" }, "asar": true, "files": [ "www/*/", "electron/*" ], "win": { "target": "nsis", "icon": "build/orderstar-kassa.ico", "publish": { "provider": "s3", "bucket": "orderstar-release", "path": "/benutzer-win64" } } }, "cordova": { "plugins": { "cordova-plugin-console": {}, "cordova-plugin-device": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-whitelist": {}, "ionic-plugin-keyboard": {}, "cordova-plugin-printer": {} }, "platforms": [ "android", "browser" ] } }
My electron.js, where I use the autoupdater like in documentation. `'use strict'; const electron = require('electron'); //const electronprinter = require('electron-printer'); // Module to control application life. const { app } = electron; // Module to create native browser window. const { BrowserWindow } = electron;
const {ipcMain} = require('electron');
const log = require('electron-log'); const {autoUpdater} = require("electron-updater");
autoUpdater.logger = log; autoUpdater.logger.transports.file.level = 'info'; log.info('App starting...');
let win;
function sendStatusToWindow(text) { log.info(text); win.webContents.send('message', text); }
function createWindow() { // Create the browser window. win = new BrowserWindow({ width: 1024, height: 600 });
}
autoUpdater.on('checking-for-update', () => { sendStatusToWindow('Checking for update...'); }) autoUpdater.on('update-available', (info) => { sendStatusToWindow('Update available.'); }) autoUpdater.on('update-not-available', (info) => { sendStatusToWindow('Update not available.'); }) autoUpdater.on('error', (err) => { sendStatusToWindow('Error in auto-updater.'); }) autoUpdater.on('download-progress', (progressObj) => { let log_message = "Download speed: " + progressObj.bytesPerSecond; log_message = log_message + ' - Downloaded ' + progressObj.percent + '%'; log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')'; sendStatusToWindow(log_message); }) autoUpdater.on('update-downloaded', (info) => { sendStatusToWindow('Update downloaded; will install in 5 seconds'); });
// This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.on('ready', createWindow);
// Quit when all windows are closed. app.on('window-all-closed', () => { // On OS X it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform !== 'darwin') { app.quit(); } });
app.on('activate', () => { // On OS X it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (win === null) { createWindow(); } });
autoUpdater.on('update-downloaded', (info) => { // Wait 5 seconds, then quit and install // In your application, you don't need to wait 5 seconds. // You could call autoUpdater.quitAndInstall(); immediately setTimeout(function() { autoUpdater.quitAndInstall(); }, 1000); })
app.on('ready', function() { autoUpdater.checkForUpdates(); }); `