Closed enahum closed 8 years ago
That`s because you need check for updates manually.
On electron you have the auto-updater
module, so basically check for the updates with the checkForUpdates
method and the squirrel events will work fine.
The documentation isn`t good so here is the snipset for check for the updates:
function setupUpdater() {
var autoUpdater = require('auto-updater')
autoUpdater.setFeedUrl(YOUR_URL)
autoUpdater.on('update-downloaded', function() {
autoUpdater.quitAndInstall()
})
autoUpdater.checkForUpdates()
}
Just change it to new electron 0.35
@enahum Are you still have this problem? My app works fine for auto update on windows 10, and thanks for your advice on electron issues list.
@leonardoxh Actually im using the checkForUpdates() method from the auto-updater module in electron 0.35.0 and it does actually update the app, and yes I still have this problem @plrthink I can´t make it work for some reason.
Here a the code snippet:
var app = require('electron').app,
BrowserWindow = require('electron').BrowserWindow,
NativeImage = require('electron').nativeImage,
updater = require('electron').autoUpdater,
ipc = require('electron').ipcMain;
updater.setFeedURL(url.resolve(config.oauth, 'version/chatDesktop/' + version + '/' + platform));
app.checkVersion = function(triggerManually) {
manualCheck = triggerManually;
updater.checkForUpdates();
};
updater.on('error', function(err) {
var msg = "An error has occurred while checking for updates " + err.message;
if(manualCheck) {
if (splashWindow) {
splashWindow.webContents.send('update-error', msg);
} else if (mainWindow) {
mainWindow.webContents.send('update-error', msg);
}
}
});
updater.on('checking-for-update', function() {
console.log('checking-for-update');
});
updater.on('update-available', function() {
if(splashWindow) {
updateAvailable = true;
isValid = true;
splashWindow.close();
}
});
updater.on('update-not-available', function() {
if (mainWindow && manualCheck) {
mainWindow.webContents.send('no-update');
} else if(splashWindow) {
isValid = true;
splashWindow.close();
}
});
updater.on('update-downloaded', function() {
if(splashWindow) {
splashWindow.webContents.send('update-ready');
} else if (mainWindow) {
mainWindow.webContents.send('update-ready');
}
updateReady = true;
});
ipc.on('install', function() {
updateAvailable = false;
updateReady = false;
updater.quitAndInstall();
});
I think the next step is use this section of readme to create the sortcuts and etc
https://github.com/atom/grunt-electron-installer#handling-squirrel-events
@leonardoxh Already have it, thats why I´m saying that the events are not triggered, actually the only one that is fired is the --squirrel-firstrun, meaning that in this code:
var handleStartupEvent = function() {
var logger = require('./logger')(module);
if (process.platform !== 'win32') {
return false;
}
app.setAppUserModelId('com.squirrel.ZBox.ZBox');
var squirrelCommand = process.argv[1];
switch (squirrelCommand) {
case '--squirrel-firstrun':
createShortcut();
break;
case '--squirrel-install':
case '--squirrel-updated':
deleteShortcut();
createShortcut();
app.quit();
return true;
case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers
// Always quit when done
deleteShortcut();
app.quit();
return true;
case '--squirrel-obsolete':
// This is called on the outgoing version of your app before
// we update to the new version - it's the opposite of
// --squirrel-updated
app.quit();
return true;
}
if(!squirrelCommand) {
logger.warn('NO SQUIRREL EVENT EXECUTED');
}
};
if (handleStartupEvent()) {
return;
}
no other event (or argument) is being sent with squirrel Updater.exe
Hm, ok does your url return the correct files?
The same URL needs return the files by the calling name like RELEASE file, the nupackage file and the setup file ?
The updates need change the version name on the package.json (it's soo borring to test this)
For example on my spring serverside my URL looks like:
/api/version/{platform}/{path:.+}
Where platform is the file directory and the path is the filename, the path is sent by squirrel.
Always your URL will be the set url on electron + the file
Thats exactly my scenario, the url actually gets a 302 to the RELEASES file hosted in amazon S3
On Wednesday, 2 December 2015, Leonardo Rossetto notifications@github.com wrote:
For example on my spring serverside my URL looks like:
/api/version/{platform}/{path:.+}
Where platform is the file directory and the path is the filename, the path is sent by electron
— Reply to this email directly or view it on GitHub https://github.com/atom/grunt-electron-installer/issues/84#issuecomment-161272363 .
@enahum I am also serving my updates on s3. I just set the feed url for windows directly to s3 like "https://s3.cn-north-1.amazonaws.com.cn/xxx/downloads/v0.3.0/", and put all the file generated by this package except the MSI installer there. Actually I doesn't find this by myself, I'm following you explanation in this issue. And this works for me. I can get auto update for my app.
Don't get me wrong guys, the auto update does work my app gets updated, the thing is that when i get an update, it gets installed then it will reopen the new version BUT the actual squirrel events are empty so I can't handle them.
@enahum Oh, I think you can use electron dialog
module to check whether the event fires. I use that to notify uses when update gets downloaded and it did pop a dialog.
ok definitely I think i'm not being clear, the problem is that when the app is Spawn with Updater.exe after installation, update or uninstall I do not get the squirrelCommand as an argument.
Those arguments supose to be:
The only one I get is --squirrel-firstrun after that one the squirrelCommand is always undefined
So, the way this works is:
--squirrel-install
--squirrel-firstrun
My psychic debugger is saying that your hooks are actually running, it's just hard to see because Update.exe always captures the output.
@enahum do you still have any issue? Feel free to reopen if so.
@plrthink @enahum @havenchyk would someone be able to give me an outline of how update checking works for Windows (or if I can use Mac OSX logic on Windows) ? I've been stuck on this for about a week now :cry: This is my understanding so far (by the way, assume I've already setup grunt-electron-installer and have an installer up and running):
--squirrel-update
.--squirrel-update
is one of the arguments in the command line when running Update.exe, then call update.jsautoUpdater
module such as setFeedURL and checkForUpdates@mzmousa
I'm using electron-squirrel-startup to handle squirrel events and it works well for me.
And your autoUpdaterFeedURL
should be set to the directory which contains your Setup.exe, .nupkg file and RELEASES file.
Hope this would help you.
@plrthink
If I want to update my without autoUpdater
this can work by doing ./Update.exe --update="https://releasesURL/
. This works fine for me. However, I would like some clarification on the process of using autoUpdater
.
I add the line if (require ('electron-squirrel-startup)) return;
to the top of my app. Then after requiring the autoUpdater
module from electron, where do I place the lines autoUpdater.setFeedURL(...)
and autoUpdater.checkForUpdates()
? Do they go right after the line for electron-squirrel-startup
?
Yeah, and autoUpdater.checkForUpdates()
should be called after app is ready.
@plrthink
Thanks! Also, on a side note, I've come across this issue in electron-squirrel-startup
here. Have you come across it before? It seems the issue is with the module cornerstone
:(
Edit: the node package cornerstone
seems to be missing from github. Maybe electron-squirrel-startup
doesn't work anymore?
@plrthink @enahum Did you get autoUpdate work now ? After I called autoUpdater.quitAndInstall(), my app will quit and reopen with new version. But when I close my app and double click that same .exe file my old version got opened. Any comments on why this is happening ?
@apple0723 why are you clicking the same .exe file? If your app is version 1.0.0, squirrel will make a folder called 1.0.0 in your AppData/Local/MyAppName folder. This folder will have a MyAppName.exe file, amongst other files (resources, .dll's, etc). This is where your app is run from. Once a new version is installed, say version 1.0.1, in the same AppData/Local/MyAppName folder, you will have a new folder called 1.0.1, with a different MyAppName.exe. Squirrel takes it upon itself to relink the shortcuts it made earlier to your app to the new .exe file. Also, squirrel only keeps the most recent two versions of your app. So if you were to install version 1.0.2, 1.0.0 would be removed, and if you were to install 1.0.3, 1.0.1 would be removed.
One tip I have is to move over to electron-builder. It's a lot faster, easier, and is getting more support than grunt-electron-installer. It really makes life easier for distributing your app on multiple platforms.
Finally, it's recommended that you don't use autoUpdater.quitAndInstall(). Look here for an example of using autoUpdater. Only setFeedUrl and checkForUpdates are used - it's better to notfiy the user that an update is there, then install it, instead of quitting preemptively.
Hope I helped, good luck.
@mzmousa gain much more knowledge about autoUpdater from your comment.
I'm using the installer version 1.1.0 and as the docs say the app should run with squirrel-events as arguments but I only get the --squirrel-first-run flag, the install, updated, obsolete or uninstall are not getting fired at any time, even thou i´m able to update my app using the autoUpdater.
Versions are:
Build in Windows 10 x64
Any help is much appreciated.