diff options
author | Rémy Raes <contact@remyraes.com> | 2022-01-01 22:30:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-01 22:30:01 +0100 |
commit | 1598d8b3510580cd886c884b80a69c7b2bcfa422 (patch) | |
tree | 1452eacea43b6e6c6a52d75b8159f4af6588819f | |
parent | b91a1ad65ec617486bc6c99d6334cea249db7e15 (diff) | |
download | Viper-1598d8b3510580cd886c884b80a69c7b2bcfa422.tar.gz Viper-1598d8b3510580cd886c884b80a69c7b2bcfa422.zip |
chore: Auto updating (#16)
* [chore] adding electron-updater dependency
* [feat] adding auto-updating mechanism
* [chore] setting package version to v0.8.0
* [fix] restoring original repo URL
* [docs] adding some documentation about publishing new releases
* [chore] adding publish:windows command
* [docs] updating publish instructions with new publish command
* [chore] adding publish:linux command
* [docs] updating publish instructions
* --updatevp, and option to disable auto updates
If you want you can set "autoupdates" to false in your config, no GUI
tools to do this yet. For the CLI auto updates is off by default and
you'll have to use --updatevp.
I also removed the snap package, tho whether this stays as a change is
still to be discussed.
And with the new option I updated the help menu, the man page and
everything along else that needs it.
* removed "soon" parts of README for auto-updates
* [feat] adding French translation for cli.help.updatevp key
* confirmation for restarting the app
Now instead of automatically updating and restarting the app, which may
be slightly confusing to some users, (the app opens then closes and then
opens), it now asks whether you want to restart and open the new
version. If you say no, instead next time you launch it, it'll be on the
new version.
If you want to completely disable updates you can disable it in the
viper.json file...
* [feat] adding French translation for gui.update.available key
* added configuration instruction in README
Co-authored-by: 0neGal <mail@0negal.com>
-rw-r--r-- | PUBLISH.md | 9 | ||||
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | docs/viper.1 | 7 | ||||
-rw-r--r-- | docs/viper.1.md | 5 | ||||
-rw-r--r-- | package-lock.json | 183 | ||||
-rw-r--r-- | package.json | 17 | ||||
-rw-r--r-- | src/app/main.js | 7 | ||||
-rw-r--r-- | src/cli.js | 2 | ||||
-rw-r--r-- | src/index.js | 18 | ||||
-rw-r--r-- | src/lang/en.json | 2 | ||||
-rw-r--r-- | src/lang/fr.json | 2 | ||||
-rw-r--r-- | src/utils.js | 17 |
12 files changed, 237 insertions, 43 deletions
diff --git a/PUBLISH.md b/PUBLISH.md new file mode 100644 index 0000000..4d38be4 --- /dev/null +++ b/PUBLISH.md @@ -0,0 +1,9 @@ +# Publishing a new release + +1. Make sure your code works! +2. Update `package.json` version +3. Make sure `package.json`'s `repository.url` key references correct repository +4. Ensure application builds correctly with `npm run build:[windows/linux]` +5. Expose `GH_TOKEN` environment var with your Github token +6. Build and publish with `npm run publish:[windows/linux]` +7. Edit the draft release message and publish the new release!
\ No newline at end of file @@ -30,7 +30,7 @@ Additionally, if you really want to, you can build Viper with `npm run build` an Downloads are available on the [releases page](https://github.com/0neGal/viper/releases/latest). -Please note that some versions will (*[soon™](https://github.com/0neGal/viper/tree/auto-updates)*) update themselves automatically when a new release is available (just like Origin or Steam) and some will NOT, so choose it accordingly. Only the AppImage and Windows Setup/Installer can auto-update. +Please note that some versions will update themselves automatically when a new release is available (just like Origin or Steam) and some will NOT, so choose it accordingly. Only the AppImage and Windows Setup/Installer can auto-update. **Windows:** `Viper Setup [x.y.z].exe` (auto-updates, and is recommanded), `Viper [x.y.z].exe` (single executable, no fuss) @@ -43,11 +43,17 @@ Currently Viper is capable of: * Updating/Installing Northstar * Launching Vanilla and or Northstar * Manage Mods (Soon, see [**mod-support**](https://github.com/0neGal/viper/tree/mod-support) branch) - * Auto-Update itself (Soon, see [**auto-updater**](https://github.com/0neGal/viper/tree/auto-updates) branch) + * Auto-Update itself * Be pretty! Besides this I've been considering adding some easy to use VPK modding tools so everybody can have fun with VPK modding even if you don't know how to do it the traditional way. However that is not at the top of the todo list right now. +## Configuration + +Almost all configuration takes place inside the UI, and almost no configuration isn't either handled their or automatically handled, the only option that isn't configured in the GUI is disabling auto-updates, by default updates are handled automatically, when you launch the application it'll update, ask you if you want to restart, if not it'll continue with the old version until you restart, however you can disable this entirely by settings `"autoupdates": true` to false in your `viper.json` + +Your configuration file will be found in `%APPDATA%\viper.json` on Windows, and inside either `~/.config` or through your environment variables (`$XDG_CONFIG_HOME`) on Linux, the latter has priority. + ## Sidenote Given that we already have so many Northstar updaters and launchers I urge people to instead of creating new launchers unless there's a very specific reason, just make a pull request on one of the existing, otherwise we'll continue to have new ones. @@ -63,7 +69,6 @@ Some of the existing launchers are listed below: * [laundmo's updater](https://github.com/laundmo/northstar-updater) - another CLI only updater * [Juicy's mod manager](https://github.com/BigSpice/NorthStar-Mod-Manager-Ext-1) - an updater and manager for mods, most feature rich - ## Credits All credits for logos go to Imply#9781. diff --git a/docs/viper.1 b/docs/viper.1 index 0b399b8..5b5b913 100644 --- a/docs/viper.1 +++ b/docs/viper.1 @@ -1,4 +1,4 @@ -.TH "VIPER" "1" "December 2021" "" "" +.TH "VIPER" "1" "January 2022" "" "" .SH "NAME" \fBviper\fR \- update and manage northstar .SH SYNOPSIS @@ -6,7 +6,7 @@ \fBviper\fP [<optional>\|\.\.\.] .SH DESCRIPTION .P -Viper is a program made to make updating and launching Northstar a lot easier\. It has both a CLI and GUI tool, specifying no command line arguments opens the latter\. +Viper is a program made to make updating and launching Northstar a lot easier\. It has both a CLI and GUI tool, specifying no command line arguments opens the latter\. Viper also is able to update itself, that is if you've the AppImage or NSIS version\. .SH OPTIONS .P \fB\-\-help\fP @@ -22,6 +22,9 @@ Viper is a program made to make updating and launching Northstar a lot easier\. \fB\-\-update\fP Updates Northstar, this uses your \fBviper\.json\fP to determine the location, it also won't try to update if the installed version of Northstar is already the newest, if you must re\-install Northstar you can delete the \fBns_version\.txt\fP file in the game path\. .P +\fB\-\-updatevp\fP + Updates Viper itself, by default CLI does not have auto updates, as a server owner may not want this, so use this option to update\. +.P \fB\-\-launch\fP=<version> Launches Northstar, this is currently only supported on Windows\. If you must launch Vanilla you can run \fB\-\-launch=vanilla\fP diff --git a/docs/viper.1.md b/docs/viper.1.md index fa531c3..e271f4f 100644 --- a/docs/viper.1.md +++ b/docs/viper.1.md @@ -7,7 +7,7 @@ viper(1) -- update and manage northstar ## DESCRIPTION -Viper is a program made to make updating and launching Northstar a lot easier. It has both a CLI and GUI tool, specifying no command line arguments opens the latter. +Viper is a program made to make updating and launching Northstar a lot easier. It has both a CLI and GUI tool, specifying no command line arguments opens the latter. Viper also is able to update itself, that is if you've the AppImage or NSIS version. ## OPTIONS @@ -24,6 +24,9 @@ Viper is a program made to make updating and launching Northstar a lot easier. I `--update` Updates Northstar, this uses your `viper.json` to determine the location, it also won't try to update if the installed version of Northstar is already the newest, if you must re-install Northstar you can delete the `ns_version.txt` file in the game path. +`--updatevp` + Updates Viper itself, by default CLI does not have auto updates, as a server owner may not want this, so use this option to update. + `--launch`=<version> Launches Northstar, this is currently only supported on Windows. If you must launch Vanilla you can run `--launch=vanilla` diff --git a/package-lock.json b/package-lock.json index fc3dc60..96d23eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,15 @@ { "name": "viper", - "version": "1.0.0", + "version": "0.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "viper", - "version": "1.0.0", + "version": "0.9.0", "license": "GPL-3.0-or-later", "dependencies": { + "electron-updater": "^4.6.1", "follow-redirects": "^1.14.6", "marked-man": "^0.7.0", "request": "^2.88.2", @@ -263,6 +264,11 @@ "xmlbuilder": ">=11.0.1" } }, + "node_modules/@types/semver": { + "version": "7.3.9", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.9.tgz", + "integrity": "sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ==" + }, "node_modules/@types/verror": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.5.tgz", @@ -457,8 +463,7 @@ "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/asar": { "version": "3.1.0", @@ -786,7 +791,6 @@ "version": "8.9.1", "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-8.9.1.tgz", "integrity": "sha512-c8a8J3wK6BIVLW7ls+7TRK9igspTbzWmUqxFbgK0m40Ggm6efUbxtWVCGIjc+dtchyr5qAMAUL6iEGRdS/6vwg==", - "dev": true, "dependencies": { "debug": "^4.3.2", "sax": "^1.2.4" @@ -1134,7 +1138,6 @@ "version": "4.3.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", - "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -1556,6 +1559,67 @@ "node": ">= 10.0.0" } }, + "node_modules/electron-updater": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-4.6.1.tgz", + "integrity": "sha512-YsU1mHqXLrXXmBMsxhxy24PrbaB8rnpZDPmFa2gOkTYk/Ch13+R0fjsRSpPYvqtskVVY0ux8fu+HnUkVkqc7og==", + "dependencies": { + "@types/semver": "^7.3.6", + "builder-util-runtime": "8.9.1", + "fs-extra": "^10.0.0", + "js-yaml": "^4.1.0", + "lazy-val": "^1.0.5", + "lodash.escaperegexp": "^4.1.2", + "lodash.isequal": "^4.5.0", + "semver": "^7.3.5" + } + }, + "node_modules/electron-updater/node_modules/fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/electron-updater/node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/electron-updater/node_modules/semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/electron-updater/node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -2287,7 +2351,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, "dependencies": { "argparse": "^2.0.1" }, @@ -2383,8 +2446,7 @@ "node_modules/lazy-val": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz", - "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==", - "dev": true + "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==" }, "node_modules/listenercount": { "version": "1.0.1", @@ -2397,6 +2459,16 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "node_modules/lodash.escaperegexp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", + "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=" + }, + "node_modules/lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" + }, "node_modules/lowercase-keys": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", @@ -2410,7 +2482,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "dependencies": { "yallist": "^4.0.0" }, @@ -2539,8 +2610,7 @@ "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/node-addon-api": { "version": "1.7.2", @@ -2924,8 +2994,7 @@ "node_modules/sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "node_modules/semver": { "version": "6.3.0", @@ -3591,8 +3660,7 @@ "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/yargs": { "version": "17.3.1", @@ -3828,6 +3896,11 @@ "xmlbuilder": ">=11.0.1" } }, + "@types/semver": { + "version": "7.3.9", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.9.tgz", + "integrity": "sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ==" + }, "@types/verror": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.5.tgz", @@ -3989,8 +4062,7 @@ "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "asar": { "version": "3.1.0", @@ -4270,7 +4342,6 @@ "version": "8.9.1", "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-8.9.1.tgz", "integrity": "sha512-c8a8J3wK6BIVLW7ls+7TRK9igspTbzWmUqxFbgK0m40Ggm6efUbxtWVCGIjc+dtchyr5qAMAUL6iEGRdS/6vwg==", - "dev": true, "requires": { "debug": "^4.3.2", "sax": "^1.2.4" @@ -4513,7 +4584,6 @@ "version": "4.3.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", - "dev": true, "requires": { "ms": "2.1.2" } @@ -4848,6 +4918,55 @@ } } }, + "electron-updater": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-4.6.1.tgz", + "integrity": "sha512-YsU1mHqXLrXXmBMsxhxy24PrbaB8rnpZDPmFa2gOkTYk/Ch13+R0fjsRSpPYvqtskVVY0ux8fu+HnUkVkqc7og==", + "requires": { + "@types/semver": "^7.3.6", + "builder-util-runtime": "8.9.1", + "fs-extra": "^10.0.0", + "js-yaml": "^4.1.0", + "lazy-val": "^1.0.5", + "lodash.escaperegexp": "^4.1.2", + "lodash.isequal": "^4.5.0", + "semver": "^7.3.5" + }, + "dependencies": { + "fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" + } + } + }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -5398,7 +5517,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, "requires": { "argparse": "^2.0.1" } @@ -5479,8 +5597,7 @@ "lazy-val": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz", - "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==", - "dev": true + "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==" }, "listenercount": { "version": "1.0.1", @@ -5493,6 +5610,16 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "lodash.escaperegexp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", + "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=" + }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" + }, "lowercase-keys": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", @@ -5503,7 +5630,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "requires": { "yallist": "^4.0.0" } @@ -5588,8 +5714,7 @@ "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node-addon-api": { "version": "1.7.2", @@ -5902,8 +6027,7 @@ "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "semver": { "version": "6.3.0", @@ -6429,8 +6553,7 @@ "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "yargs": { "version": "17.3.1", diff --git a/package.json b/package.json index 3dec425..449adb7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "viper", "productName": "Viper", - "version": "1.0.0", + "version": "0.9.0", "description": "Launcher+Updater for TF|2 Northstar", "main": "src/index.js", "build": { @@ -19,10 +19,9 @@ "category": "Game", "target": [ "AppImage", - "snap", + "tar.gz", "deb", - "rpm", - "tar.gz" + "rpm" ] } }, @@ -30,13 +29,18 @@ "start": "npx electron src/index.js", "debug": "npx electron src/index.js --debug", "man": "npx marked-man docs/viper.1.md > docs/viper.1", + "build": "npx electron-builder --win nsis --win portable --linux", "build:windows": "npx electron-builder --win nsis --win portable", - "build:linux": "npx electron-builder --linux" + "build:linux": "npx electron-builder --linux", + + "publish": "npx electron-builder --win nsis --win portable --linux -p always", + "publish:windows": "npx electron-builder --win nsis --win portable -p always", + "publish:linux": "npx electron-builder --linux -p always" }, "repository": { "type": "git", - "url": "git+https://github.com/0neGal/viper.git" + "url": "git+https://github.com/0neGal/viper" }, "author": "0neGal <mail@0negal.com>", "license": "GPL-3.0-or-later", @@ -45,6 +49,7 @@ }, "homepage": "https://github.com/0neGal/viper#readme", "dependencies": { + "electron-updater": "^4.6.1", "follow-redirects": "^1.14.6", "marked-man": "^0.7.0", "request": "^2.88.2", diff --git a/src/app/main.js b/src/app/main.js index a33ef72..d30489e 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -6,6 +6,7 @@ const lang = require("../lang"); var settings = { gamepath: "", + autoupdate: true, zip: "/northstar.zip", lang: navigator.language, excludes: [ @@ -58,6 +59,12 @@ ipcRenderer.on("version", (event, versions) => { nsversion.innerText = lang("gui.versions.northstar") + ": " + versions.ns; }); ipcRenderer.send("getversion"); +ipcRenderer.on("updateavailable", () => { + if (confirm(lang("gui.update.available"))) { + ipcRenderer.send("updatenow"); + } +}) + setlang(); setInterval(() => { ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 20); @@ -14,6 +14,7 @@ function hasArgs() { cli.hasSwitch("launch") || cli.hasSwitch("setpath") || cli.hasSwitch("version") || + cli.hasSwitch("updatevp") || cli.hasSwitch("gamepath")) { return true; } else {return false} @@ -32,6 +33,7 @@ async function init() { --cli ${lang("cli.help.cli")} --update ${lang("cli.help.update")} + --updatevp ${lang("cli.help.updatevp")} --setpath ${lang("cli.help.setpath")}`) // In the future --setpath should be able to understand // relative paths, instead of just absolute ones. diff --git a/src/index.js b/src/index.js index 198bc74..b43611d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ const fs = require("fs"); const path = require("path"); +const { autoUpdater } = require("electron-updater"); const { app, dialog, ipcMain, BrowserWindow, ipcRenderer } = require("electron"); const Emitter = require("events"); @@ -41,6 +42,17 @@ function start() { ipcMain.on("ns-updated", () => {win.webContents.send("ns-updated")}) ipcMain.on("ns-updating", () => {win.webContents.send("ns-updating")}) ipcMain.on("winLog", (event, ...args) => {win.webContents.send("log", ...args)}) + + if (utils.settings.autoupdate) {utils.updatevp(false)} + + autoUpdater.on("update-downloaded", () => { + win.webContents.send("updateavailable") + }); + + ipcMain.on("updatenow", () => { + autoUpdater.quitAndInstall(); + }) + } ipcMain.on("launch", (event) => {utils.launch()}) @@ -68,7 +80,11 @@ ipcMain.on("versioncli", () => { process.chdir(app.getPath("appData")); if (cli.hasArgs()) { - cli.init(); + if (cli.hasParam("updatevp")) { + utils.updatevp(true); + } else { + cli.init(); + } } else { app.on("ready", () => { app.setPath("userData", path.join(app.getPath("cache"), app.name)); diff --git a/src/lang/en.json b/src/lang/en.json index 8f388ae..83f23f3 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -5,6 +5,7 @@ "cli.help.cli": "forces the CLI to enable", "cli.help.update": "updates Northstar from your set game path", "cli.help.setpath": "sets your game path", + "cli.help.updatevp": "updates Viper itself, if supported.", "cli.setpath.noarg": "No argument provided for --setpath", @@ -28,6 +29,7 @@ "gui.update.extracting": "Extracting update...", "gui.update.finished": "Done! Ready to play!", "gui.update.uptodate": "Already up to date!", + "gui.update.available": "A new update for Viper is available, do you want to restart and apply it?", "gui.launch": "Launch", "gui.launchvanilla": "Vanilla", diff --git a/src/lang/fr.json b/src/lang/fr.json index 26648c4..fe4d63c 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -5,6 +5,7 @@ "cli.help.cli": "force l'activation de la CLI", "cli.help.update": "met à jour Northstar sur le chemin du jeu précisé", "cli.help.setpath": "enregistre le chemin du client de jeu", + "cli.help.updatevp": "met à jour le client Viper, si le format actuel le permet.", "cli.setpath.noarg": "Aucun argument donné à --setpath", @@ -28,6 +29,7 @@ "gui.update.extracting": "Extraction des fichiers...", "gui.update.finished": "Terminé, vous pouvez jouer !", "gui.update.uptodate": "Déjà à jour !", + "gui.update.available": "Une mise à jour pour Viper est disponible, voulez-vous l'installer maintenant ?", "gui.launch": "Jouer", "gui.launchvanilla": "Vanilla", diff --git a/src/utils.js b/src/utils.js index 06acbdf..9e6154a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -18,6 +18,7 @@ process.chdir(app.getPath("appData")); var settings = { gamepath: "", lang: "en-US", + autoupdate: true, zip: "/northstar.zip", excludes: [ "ns_startup_args.txt", @@ -125,6 +126,21 @@ function update() { }) } +function updatevp(autoinstall) { + const { autoUpdater } = require("electron-updater"); + + if (autoinstall) { + autoUpdater.on("update-downloaded", (info) => { + autoUpdater.quitAndInstall(); + }); + } + + autoUpdater.on("error", (info) => {cli.exit(1)}); + autoUpdater.on("update-not-available", (info) => {cli.exit()}); + + autoUpdater.checkForUpdatesAndNotify(); +} + function launch(version) { if (process.platform == "linux") { console.error("error:", lang("cli.launch.linuxerror")) @@ -153,6 +169,7 @@ module.exports = { launch, update, setpath, + updatevp, settings, getNSVersion, setlang: (lang) => { |