diff --git a/README.md b/README.md index 1ea367b..b94cc49 100644 --- a/README.md +++ b/README.md @@ -64,17 +64,25 @@ nxapi includes an Electron app, which can be downloaded [here](https://github.co ![Screenshot of the menu bar app with SplatNet 2 and NookLink open in the background](resources/menu-app.png) -The app includes the nxapi command line at `dist/bundle/cli-bundle.js`. Node.js must be installed separately to use this. +The app includes the nxapi command line at `dist/bundle/cli-bundle.js`. ```sh # macOS -node Nintendo\ Switch\ Online.app/Contents/Resources/app/dist/bundle/cli-bundle.js ... - -# Windows -node 'Nintendo Switch Online/resources/app/dist/bundle/cli-bundle.js' ... +Nintendo\ Switch\ Online.app/Contents/bin/nxapi # Linux, installed via dpkg -node /opt/Nintendo\ Switch\ Online/resources/app/dist/bundle/cli-bundle.js ... +# This is linked as /usr/bin/nxapi +/opt/Nintendo\ Switch\ Online/bin/nxapi +``` + +On Windows, Node.js must be installed separately. + +```powershell +# PowerShell +node $env:LOCALAPPDATA\Programs\nxapi-app\resources\app\dist\bundle\cli-bundle.js ... + +# Command Prompt +node %localappdata%\Programs\nxapi-app\resources\app\dist\bundle\cli-bundle.js ... ``` #### Do I need a Nintendo Switch Online membership? diff --git a/package.json b/package.json index 5cd08bd..55429ba 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "build": { "appId": "uk.org.fancy.nxapi.app", "productName": "Nintendo Switch Online", - "copyright": "Copyright © 2022 Samuel Elliott", + "copyright": "Copyright © 2023 Samuel Elliott", "npmRebuild": false, "files": [ "dist/app/bundle", @@ -130,7 +130,25 @@ } ], "mac": { + "extraFiles": [ + { + "from": "resources/build/app/cli-macos.sh", + "to": "bin/nxapi" + } + ], "identity": null + }, + "linux": { + "extraFiles": [ + { + "from": "resources/build/app/cli-linux.sh", + "to": "nxapi" + } + ] + }, + "deb": { + "afterInstall": "resources/build/app/deb/postinst", + "afterRemove": "resources/build/app/deb/postrm" } } } diff --git a/resources/build/app/cli-linux.sh b/resources/build/app/cli-linux.sh new file mode 100755 index 0000000..b6bd93c --- /dev/null +++ b/resources/build/app/cli-linux.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Run as /opt/Nintendo Switch Online/nxapi + +APP_BUNDLE_PATH="$(dirname "$0")" +export ELECTRON_RUN_AS_NODE=1 + +exec "$APP_BUNDLE_PATH/nxapi-app" "$APP_BUNDLE_PATH/resources/app/dist/bundle/cli-bundle.js" $@ diff --git a/resources/build/app/cli-macos.sh b/resources/build/app/cli-macos.sh new file mode 100755 index 0000000..ac54ccc --- /dev/null +++ b/resources/build/app/cli-macos.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Run as Nintendo Switch Online.app/Contents/bin/nxapi + +APP_BUNDLE_PATH="$(dirname "$0")/../.." +export ELECTRON_RUN_AS_NODE=1 + +exec "$APP_BUNDLE_PATH/Contents/MacOS/Nintendo Switch Online" "$APP_BUNDLE_PATH/Contents/Resources/app/dist/bundle/cli-bundle.js" $@ diff --git a/resources/build/app/deb/postinst b/resources/build/app/deb/postinst new file mode 100755 index 0000000..79ec553 --- /dev/null +++ b/resources/build/app/deb/postinst @@ -0,0 +1,12 @@ +#!/bin/bash + +ln -sf '/opt/Nintendo Switch Online/nxapi' '/usr/bin/nxapi' + +# Link to the binary +ln -sf '/opt/Nintendo Switch Online/nxapi-app' '/usr/bin/nxapi-app' + +# SUID chrome-sandbox for Electron 5+ +chmod 4755 '/opt/Nintendo Switch Online/chrome-sandbox' || true + +update-mime-database /usr/share/mime || true +update-desktop-database /usr/share/applications || true diff --git a/resources/build/app/deb/postrm b/resources/build/app/deb/postrm new file mode 100755 index 0000000..236b484 --- /dev/null +++ b/resources/build/app/deb/postrm @@ -0,0 +1,6 @@ +#!/bin/bash + +rm -f '/usr/bin/nxapi' + +# Delete the link to the binary +rm -f '/usr/bin/nxapi-app' diff --git a/rollup.config.js b/rollup.config.js index a37de8e..f5158ea 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -106,6 +106,7 @@ const main = { }), ], external: [ + 'electron', 'node-notifier', 'register-scheme', 'bindings', diff --git a/src/common/constants.ts b/src/common/constants.ts index e656221..bb4beae 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -6,7 +6,7 @@ export const USER_AGENT_INFO_URL = 'https://gitlab.fancy.org.uk/samuel/nxapi#use export const CONFIG_URL = 'https://fancy.org.uk/api/nxapi/config'; export const LICENCE_NOTICE = ` -Copyright (c) 2022 Samuel Elliott +Copyright (c) 2023 Samuel Elliott This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.