Node Webkit Angular Updater Service
infoUrl
must point to a json file which has aversion
property with an integer value.downloadUrl
must point to the Node Webkit packaged app
** https://github.com/nwjs/nw.js/wiki/How-to-package-and-distribute-your-appsfilename
is the file name to be overwritten when the download completes. It must exist (or there wouldn't be nothing to update, would it?)currentVersion
Sets the current app version, to match against the one frominfoUrl
auto
(optional; Defaults to true) Automatically downloads new package (if needed) upon app execution. Otherwise, it just checks if an update is needed.
- Upon app execution, it queries
infoUrl
and parses its json for the propertyversion
- If
version
is greater thancurrentVersion
, it starts downloading fromdownloadUrl
- When the download completes, it renames the downloaded file to
filename
Install through bower
bower i --save nw-angular-updater
Then add 'nwUpdater'
as a dependency
app = angular.module('yourApp', ['nwUpdater'])
Now you need to configure the provider with the required values
app.config(function(nwUpdateProvider) {
nwUpdateProvider
.setInfoUrl('http://url.to/latest.info')
.setDownloadUrl('http://url.to/latest.nw')
.setFilename('yourapp.nw')
.setCurrentVersion 1
})
Then you just inject it into a controller
app.controller('yourController', ['nwUpdate', function(nwUpdate) {
});
And you're set.
nwUpdate has these Boolean
properties:
checking
- When the service is queryinginfoUrl
for information.updateRequired
- When the servicedownloading
- When the service is downloading the new package fromdownloadUrl
restartRequired
- Package downloaded and ready. Restart app to load new package.
nwUpdate has these methods:
check()
- Checks if an update is neededcheckAndUpdate()
- Checks if an update is needed and downloads the new package in one command.