Node Webkit Angular Updater Service
infoUrlmust point to a json file which has aversionproperty with an integer value.downloadUrlmust point to the Node Webkit packaged app
** https://github.com/nwjs/nw.js/wiki/How-to-package-and-distribute-your-appsfilenameis the file name to be overwritten when the download completes. It must exist (or there wouldn't be nothing to update, would it?)currentVersionSets the current app version, to match against the one frominfoUrlauto(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
infoUrland parses its json for the propertyversion - If
versionis 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 queryinginfoUrlfor information.updateRequired- When the servicedownloading- When the service is downloading the new package fromdownloadUrlrestartRequired- 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.