Add scripts for running the nxapi command using the app Electron binary

This commit is contained in:
Samuel Elliott 2023-07-14 18:54:51 +01:00
parent 584f0e2d89
commit eda75b4dee
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
8 changed files with 69 additions and 8 deletions

View File

@ -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?

View File

@ -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"
}
}
}

View File

@ -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" $@

View File

@ -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" $@

View File

@ -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

6
resources/build/app/deb/postrm Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
rm -f '/usr/bin/nxapi'
# Delete the link to the binary
rm -f '/usr/bin/nxapi-app'

View File

@ -106,6 +106,7 @@ const main = {
}),
],
external: [
'electron',
'node-notifier',
'register-scheme',
'bindings',

View File

@ -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.