Closed akashnimare closed 7 years ago
Try adding:
// Log whats happening
autoUpdater.on('error', err => console.error(err))
autoUpdater.on('checking-for-update', () => console.log('checking-for-update'))
autoUpdater.on('update-available', () => console.log('update-available'))
autoUpdater.on('update-not-available', () => console.log('update-not-available'))
autoUpdater.on('update-downloaded', () => console.log('update-downloaded'))
// Ask the user if update is available
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
dialog.showMessageBox(window, {
type: 'question',
buttons: ['Update', 'Cancel'],
defaultId: 0,
message: `Version ${releaseName} is available, do you want to install it now?`,
title: 'Update available'
}, response => {
if (response === 0) {
autoUpdater.quitAndInstall()
}
})
})
// Trigger autoUpdater
autoUpdater.checkForUpdates()
@HaNdTriX thanks. I'll try it out :)
@HaNdTriX Thanks it worked for OSX. Could you please tell me what else I have to do to make it work on windows as well. I'm using electron-builder to build the installer for windows. It generates releases + appsetup.exe + appfull.nupkg files.
@akashnimare actually it should work at windows as well. Take a look at the docs & logs.
https://github.com/electron/electron/blob/master/docs/api/auto-updater.md#windows
@HaNdTriX yes, it did worked. The only change I had to made was to add following line in main.js to handle squirrel.windows event-
if(require('electron-squirrel-startup')) app.quit();
If anyone is looking for an example see here - zulip-electron.
Hey @akashnimare could you please give me a quick rundown of how to setup nuts in Heroku I'm not getting anywhere and I imagine i'm missing something.
I have my electron app working well and cannot seem to work out how to integrate nuts. Do I add a version of nuts to heroku, or do i incorporate it into my app folder? I feel like there really needs to be some steps in the gitbook.
Any help would be greatly appreciated.
@matt3224 I have written an article for this - How to add auto-updates to your Electron application: An up to date guide
@akashnimare That's great, so I am on the 'deploy your own Nuts' screen and have filled in the repo url with my app repo, my github token and have set the private api access username and password.
It deploys successfully but (and i'm not sure if maybe this is how its meant to be) when I click view app i get 'application error'. Also I have pushed new code-signed releases to github and i am not being prompted to update.
I read somewhere about setting up a webhook but your tut doesnt mention that, is there anything else i'm missing?
Thanks once again for your help!
@matt3224 sorry for the late response. Are you able to install it properly?
Hey @akashnimare, alas I was not, I tried the server install using npm but am getting a strange issue whereby It runs but says listing on http://:::6000
I have input the the github repo and access token. Not sure what the api username and password is for though. Have you set it up this way before?
@matt3224 Naah, not locally. I have just set it up on Heroku which works fine. I'm also getting the same error while deploying locally. Opened an issue here - https://github.com/GitbookIO/nuts/issues/126
ok @akashnimare i'm giving heroku another go. What do I put in the api username and password? Is it whatever i want or does it reference something?
@matt3224 did you have any luck? I'm also seeing "Listening at http://:::6000" when I try to view it locally and on my server.
Hey @JoeDawson I did have some luck yes! I got it working on heroku in the end... kinda.
By that i mean heroku is doing its thing now. The api username and password were my github credentials. My issue now is that the app doesnt appear to construct the url request properly.
https://gist.github.com/akashnimare
So it thinks there are not any updates when there are. What we really really need here is a video walkthrough by someone who knows how this magic works.
@matt3224 oh so the API_USERNAME
& API_PASSWORD
variables should be my Github username and password? I'll check out Heroku, but I have a couple of Digital Ocean servers and ideally I'd love it to be on there but if Heroku was a little easier I'll try that.
A video would definitely be of some help - if I can work it out and it's possible I'd like to contribute to the docs because they're very vague to someone who has never set this up before.
That would be great. Yup Heroku is much simpler if you can find the right link:
https://heroku.com/deploy?template=https://github.com/GitbookIO/nuts/tree/master&c=70130000001xFhx
Are you using the gist from @akashnimare ?
👋🏼
As stated in the Debug API page (https://nuts.gitbook.com/api.html), the API_USERNAME
& API_PASSWORD
are optional and only used to protect the /api
endpoint if need be via HTTP basic auth (that little prompt w/ username + password to show a webpage).
The http://:::6000
you see shouldn’t be a problem, I think it just means that a process is bound to localhost
on port 6000
http://localhost:6000 should actually work (it does for me).
Hey @EtienneLem, they appear to be required when you go through to Heroku. It was mentioned in #91
I did try http://localhost:6000 in my browser but I see "This site can’t be reached", also mentioned in #126.
But that said, I've just finished deploying to Heroku for now and I'm going to look at the gists @matt3224 suggested to look at now.
@EtienneLem I see, odd that it's required. I wasn't having any luck using things like 'hello' and 'world' or w/e perhaps it was coincidental that using my git creds worked. It would be amazing if I/we could get this auto update stuff to work. I currently email everyone lol
@matt3224 Did you make any more progress on this? I have heroku up and running, I think. It gives me an Application Error when I use the URL it provided, but from overview it looks to be working. I'm not familiar with heroko though, so I don't know if it actually is.
The repo I have is private so I used my token and github credentials for the API username and password like you had suggested.
Hey @GitFlip, I gave up on this, just could not get it to work no matter what I did. I may have another go soon as its been awhile. I found that my app just didnt see any releases even though i thought it was working
Why do you folks not use electron-builder, it's pretty straightforward. https://medium.com/how-to-electron/how-to-add-auto-updates-to-your-electron-application-an-up-to-date-guide-d62794a0467d
@akashnimare sweet, i'll give that article a go!
@akashnimare Did you post the correct article? That is the same link you provided earlier and it is about using nuts on Herkou - it doesn't reference electron-builder once... Or am I misunderstanding something?
Now, I will say I did follow the article, and I think I have everything setup. I'm just trying to understand where in Herkou can I see that it is has a connection to GitHub and it actually sees the releases? I'm not familiar with Herkou and I don't see where.
Second thing I'd like to ask, since you wrote the article, should I see "Application Error" if I paste the Herkou URL in my web browser?
I'm trying to understand if I setup Herkou correctly or not or if I have an issue with my electron app.
Do you have any tips on how you can verify if nuts is deployed correctly on Herkou and it can see your GitHub releases?
Thanks for any help!
@GitFlip oh, yeah that article needs a bit update. As of now, you don't need to use any server for release so if your project is on GitHub then electron-builder will handle everything on its own. @GitFlip please ping me on twitter for more help!
@akashnimare Thanks for the reply. I might try out electron-builder then. I'm currently using electron-forge to make, build, and publish my app's installer. Is it pretty easy to switch?
Also, before I completely abandon heroku and nuts, is there just a way to see on heroku that nuts is running? In the activity log it says build succeeded and then deployed, but if I go to the application URL it just says "Application Error". Is that normal if I'm just running nuts on heroku?
Thanks again!
I figured out how to enable and view logging in heroku for when it launches nuts. Turns out there is an issue with connecting to GitHub, although I'm not sure what just yet. The repo I'm connecting to is private. Did either of you run into this issue:
2018-04-25T20:36:28.127988+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-25T20:36:31.564677+00:00 app[web.1]:
2018-04-25T20:36:31.564699+00:00 app[web.1]: > nuts-serve@3.1.1 start /app
2018-04-25T20:36:31.564701+00:00 app[web.1]: > node bin/web.js
2018-04-25T20:36:31.564703+00:00 app[web.1]:
2018-04-25T20:36:34.072761+00:00 app[web.1]: GitHubError: Not Found
2018-04-25T20:36:34.072782+00:00 app[web.1]: at GitHub.onResponse (/app/node_modules/octocat/lib/index.js:89:15)
2018-04-25T20:36:34.072784+00:00 app[web.1]: at GitHub.wrapper [as onResponse] (/app/node_modules/octocat/node_modules/lodash/index.js:3095:19)
2018-04-25T20:36:34.072786+00:00 app[web.1]: at Request._callback (/app/node_modules/octocat/lib/index.js:126:31)
2018-04-25T20:36:34.072788+00:00 app[web.1]: at Request.self.callback (/app/node_modules/octocat/node_modules/request/request.js:198:22)
2018-04-25T20:36:34.072790+00:00 app[web.1]: at emitTwo (events.js:126:13)
2018-04-25T20:36:34.072791+00:00 app[web.1]: at Request.emit (events.js:214:7)
2018-04-25T20:36:34.072793+00:00 app[web.1]: at Request.<anonymous> (/app/node_modules/octocat/node_modules/request/request.js:1063:14)
2018-04-25T20:36:34.072795+00:00 app[web.1]: at emitOne (events.js:121:20)
2018-04-25T20:36:34.072796+00:00 app[web.1]: at Request.emit (events.js:211:7)
2018-04-25T20:36:34.072798+00:00 app[web.1]: at IncomingMessage.<anonymous> (/app/node_modules/octocat/node_modules/request/request.js:1009:12)
2018-04-25T20:36:34.126307+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-04-25T20:36:34.126851+00:00 app[web.1]: npm ERR! errno 1
2018-04-25T20:36:34.131733+00:00 app[web.1]: npm ERR! nuts-serve@3.1.1 start: `node bin/web.js`
2018-04-25T20:36:34.132003+00:00 app[web.1]: npm ERR! Exit status 1
2018-04-25T20:36:34.132810+00:00 app[web.1]: npm ERR!
2018-04-25T20:36:34.133093+00:00 app[web.1]: npm ERR! Failed at the nuts-serve@3.1.1 start script.
2018-04-25T20:36:34.133349+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-04-25T20:36:34.175037+00:00 app[web.1]:
2018-04-25T20:36:34.175455+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-04-25T20:36:34.175714+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-04-25T20_36_34_135Z-debug.log
Update: Fixed this issue by changing GITHUB_REPO from the full url path, to just username/repo-name.
To answer my own question... if you navigate to the URL provided by heroku, it should download the latest release of your electron app. It should not say "Application Error"
@matt3224 i created the docker and run with next command for changing the ports: docker run -p 127.0.0.1:6000:6000 DOCKERNAME:1.0
I'm having hard time implementing auto-updates in one of my electron app. I have set it up nuts on heroku successfully and it's working fine but I don't know how to implement this in my electron app's autoupdater api. Adding this in my main.js does nothing-
It would be awesome if you someone can point me to a working example.