{"id":13991959,"url":"https://github.com/nwutils/nw-updater","last_synced_at":"2025-05-15T07:03:52.580Z","repository":{"id":17359750,"uuid":"20131416","full_name":"nwutils/nw-updater","owner":"nwutils","description":"Update NW.js applications.","archived":false,"fork":false,"pushed_at":"2025-05-02T18:15:31.000Z","size":151356,"stargazers_count":479,"open_issues_count":31,"forks_count":91,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-05-15T07:03:50.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nwutils.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-05-24T14:31:50.000Z","updated_at":"2025-03-04T17:03:51.000Z","dependencies_parsed_at":"2023-11-14T01:30:25.045Z","dependency_job_id":"a738eb8a-e360-42f3-9cce-3ce5b4b3017f","html_url":"https://github.com/nwutils/nw-updater","commit_stats":{"total_commits":172,"total_committers":24,"mean_commits":7.166666666666667,"dds":0.5813953488372092,"last_synced_commit":"2313d8f72de0686fe9c95e5ed0c3f7e75b0cc189"},"previous_names":["edjafarov/node-webkit-updater","nwutils/nw-updater"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwutils%2Fnw-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwutils%2Fnw-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwutils%2Fnw-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwutils%2Fnw-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nwutils","download_url":"https://codeload.github.com/nwutils/nw-updater/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254291974,"owners_count":22046425,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-09T14:01:42.259Z","updated_at":"2025-05-15T07:03:52.542Z","avatar_url":"https://github.com/nwutils.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003e This repository is in maintainance mode. Bug fixes will be provided on a best effort basis. If you use this project, please consider contributing back.\r\n\r\n# @nwutils/updater\r\n\r\n[![npm](https://img.shields.io/npm/v/node-webkit-updater.svg?style=flat)](https://www.npmjs.com/package/node-webkit-updater)\r\n[![Join the chat at https://gitter.im/nwjs/nwjs](https://badges.gitter.im/nwjs/nwjs.svg)](https://gitter.im/nwjs/nwjs)\r\n\r\n```shell\r\nnpm i @nwutils/updater\r\n```\r\n\r\nIt gives you low-level API to:\r\n\r\n1. Check the manifest for version (from your running \"old\" app).\r\n2. If the version is different from the running one, download new package to a temp directory.\r\n3. Unpack the package in temp.\r\n4. Run new app from temp and kill the old one (i.e. still all from the running app).\r\n5. The new app (in temp) will copy itself to the original folder, overwriting the old app.\r\n6. The new app will run itself from original folder and exit the process.\r\n\r\nYou should build this logic by yourself though. As a reference you can use [example](app/index.html).\r\n\r\nCovered by tests and works for [linux](http://screencast.com/t/Je2ptbHhP), [windows](http://screencast.com/t/MSTKqVS3) and [mac](http://screencast.com/t/OXyC5xoA).\r\n\r\n## Examples\r\n\r\n- [Basic](examples/basic.js)\r\n\r\n\r\n## API\r\n\r\n\u003ca name=\"new_updater\"\u003e\u003c/a\u003e\r\n#### new updater(manifest, options)\r\nCreates new instance of updater. Manifest could be a `package.json` of project.\r\n\r\nNote that compressed apps are assumed to be downloaded in the format produced by [nw-builder](https://github.com/nwutils/nw-builder) (or [grunt-nw-builder](https://github.com/nwjs/grunt-nw-builder)).\r\n\r\n**Params**\r\n\r\n- manifest `object` - See the [manifest schema](#manifest-schema) below.  \r\n- options `object` - Optional  \r\n\r\n\u003ca name=\"updater#checkNewVersion\"\u003e\u003c/a\u003e\r\n#### updater.checkNewVersion(cb)\r\nWill check the latest available version of the application by requesting the manifest specified in `manifestUrl`.\r\n\r\nThe callback will always be called; the second parameter indicates whether or not there's a newer version.\r\nThis function assumes you use [Semantic Versioning](http://semver.org) and enforces it; if your local version is `0.2.0` and the remote one is `0.1.23456` then the callback will be called with `false` as the second paramter. If on the off chance you don't use semantic versioning, you could manually download the remote manifest and call `download` if you're happy that the remote version is newer.\r\n\r\n**Params**\r\n\r\n- cb `function` - Callback arguments: error, newerVersionExists (`Boolean`), remoteManifest  \r\n\r\n\u003ca name=\"updater#download\"\u003e\u003c/a\u003e\r\n#### updater.download(cb, newManifest)\r\nDownloads the new app to a template folder\r\n\r\n**Params**\r\n\r\n- cb `function` - called when download completes. Callback arguments: error, downloaded filepath  \r\n- newManifest `Object` - see [manifest schema](#manifest-schema) below  \r\n\r\n**Returns**: `Request` - Request - stream, the stream contains `manifest` property with new manifest and 'content-length' property with the size of package.  \r\n\u003ca name=\"updater#getAppPath\"\u003e\u003c/a\u003e\r\n#### updater.getAppPath()\r\nReturns executed application path\r\n\r\n**Returns**: `string`  \r\n\u003ca name=\"updater#getAppExec\"\u003e\u003c/a\u003e\r\n#### updater.getAppExec()\r\nReturns current application executable\r\n\r\n**Returns**: `string`  \r\n\u003ca name=\"updater#unpack\"\u003e\u003c/a\u003e\r\n#### updater.unpack(filename, cb, manifest)\r\nWill unpack the `filename` in temporary folder.\r\nFor Windows, [unzip](https://www.mkssoftware.com/docs/man1/unzip.1.asp) is used (which is [not signed](https://github.com/edjafarov/node-webkit-updater/issues/68)).\r\n\r\n**Params**\r\n\r\n- filename `string`  \r\n- cb `function` - Callback arguments: error, unpacked directory  \r\n- manifest `object`  \r\n\r\n\u003ca name=\"updater#runInstaller\"\u003e\u003c/a\u003e\r\n#### updater.runInstaller(appPath, args, options)\r\nRuns installer\r\n\r\n**Params**\r\n\r\n- appPath `string`  \r\n- args `array` - Arguments which will be passed when running the new app  \r\n- options `object` - Optional  \r\n\r\n**Returns**: `function`  \r\n\u003ca name=\"updater#install\"\u003e\u003c/a\u003e\r\n#### updater.install(copyPath, cb)\r\nInstalls the app (copies current application to `copyPath`)\r\n\r\n**Params**\r\n\r\n- copyPath `string`  \r\n- cb `function` - Callback arguments: error  \r\n\r\n\u003ca name=\"updater#run\"\u003e\u003c/a\u003e\r\n#### updater.run(execPath, args, options)\r\nRuns the app from original app executable path.\r\n\r\n**Params**\r\n\r\n- execPath `string`  \r\n- args `array` - Arguments passed to the app being ran.  \r\n- options `object` - Optional. See `spawn` from nodejs docs.\r\n\r\nNote: if this doesn't work, try `gui.Shell.openItem(execPath)` (see [node-webkit Shell](https://github.com/rogerwang/node-webkit/wiki/Shell)).  \r\n\r\n\r\n---\r\n\r\n## Manifest Schema\r\n\r\nAn example manifest:\r\n\r\n```json\r\n{\r\n    \"name\": \"updapp\",\r\n    \"version\": \"0.0.2\",\r\n    \"author\": \"Eldar Djafarov \u003cdjkojb@gmail.com\u003e\",\r\n    \"manifestUrl\": \"http://localhost:3000/package.json\",\r\n    \"packages\": {\r\n        \"mac\": {\r\n           \"url\": \"http://localhost:3000/releases/updapp/mac/updapp.zip\"\r\n        },\r\n        \"win\": {\r\n           \"url\": \"http://localhost:3000/releases/updapp/win/updapp.zip\"\r\n        },\r\n        \"linux32\": {\r\n           \"url\": \"http://localhost:3000/releases/updapp/linux32/updapp.tar.gz\"\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThe manifest could be a `package.json` of project, but doesn't have to be.\r\n\r\n### manifest.name\r\n\r\nThe name of your app. From time, it is assumed your Mac app is called `\u003cmanifest.name\u003e.app`, your Windows executable is `\u003cmanifest.name\u003e.exe`, etc.\r\n\r\n### manifest.version\r\n[semver](http://semver.org) version of your app.\r\n\r\n### manifest.manifestUrl\r\nThe URL where your latest manifest is hosted; where node-webkit-updater looks to check if there is a newer version of your app available.\r\n\r\n### manifest.packages\r\nAn \"object\" containing an object for each OS your app (at least this version of your app) supports; `mac`, `win`, `linux32`, `linux64`.\r\n\r\n### manifest.packages.{mac, win, linux32, linux64}.url\r\nEach package has to contain a `url` property pointing to where the app (for the version \u0026 OS in question) can be downloaded.\r\n\r\n### manifest.packages.{mac, win, linux32, linux64}.execPath (Optional)\r\nIt's assumed your app is stored at the root of your package, use this to override that and specify a path (relative to the root of your package).\r\n\r\nThis can also be used to override `manifest.name`; e.g. if your `manifest.name` is `helloWorld` (therefore `helloWorld.app` on Mac) but your Windows executable is named `nw.exe`. Then you'd set `execPath` to `nw.exe`\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n### Mac\r\nIf you get an error on Mac about too many files being open, run `ulimit -n 10240`\r\n\r\n### Windows\r\nOn Windows, there is no \"unzip\" command built in by default. As a result, this project uses a third party \"unzip.exe\" in order to extract the downloaded update. On the NWJS site, in the \"How to package and distribute your apps\" file, one of the recommended methods of distribution is using EnigmaVirtualBox to package the app, nw.exe, and required DLLs into a single EXE file. This method works great for distribution, but unfortunately breaks node-webkit-updater, because it wraps the required unzip.exe file inside of the created EnigmaVirtualBox EXE. As a result, *it is not possible to use EnigmaVirtualBox to distribute your app if you plan on using node-webkit-updater*. Try using InnoSetup instead.\r\n\r\n## Contributing\r\n\r\nSee [CONTRIBUTING.md](CONTRIBUTING.md)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwutils%2Fnw-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnwutils%2Fnw-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwutils%2Fnw-updater/lists"}