summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-client
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-04 10:47:21 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-04 10:47:21 +0200
commit3edb0357b7841f1cd9314fd1917bb866a0cba11b (patch)
tree5dc0dc54737d17b3e6fd4a2c91cd3f63dc4fa805 /packages/meshbay-client
parent3ce52774760b222d94d78bc0118e9da2662a809f (diff)
downloadmeshbay-3edb0357b7841f1cd9314fd1917bb866a0cba11b.tar.gz
feat(packaging): put the bundled meshbay-node on the per-user PATH
The installer had no console entry point, so running the CLI meant cd-ing into resources\node-runtime\ every time. installer.nsh now adds that dir to HKCU\Environment\Path on install and removes it on uninstall, via stock WordFunc.nsh (electron-builder's NSIS bundle has no EnVar plugin). It points at the real meshbay-node.exe dir — not a shim — so `where meshbay-node`, findNodeBinary and the W3 autostart launcher all resolve to the same binary. A WM_SETTINGCHANGE broadcast nudges open shells; new ones just work. Rebuilt: electron-builder --win nsis compiles the WordFunc includes fine, MeshBay-Setup-0.1.0.exe (155 MB). test_packaging_win.py covers the add/remove symmetry. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-client')
-rw-r--r--packages/meshbay-client/build/installer.nsh38
1 files changed, 33 insertions, 5 deletions
diff --git a/packages/meshbay-client/build/installer.nsh b/packages/meshbay-client/build/installer.nsh
index cf8e5ff..15a840f 100644
--- a/packages/meshbay-client/build/installer.nsh
+++ b/packages/meshbay-client/build/installer.nsh
@@ -1,22 +1,50 @@
; electron-builder NSIS customisation (auto-included: build/installer.nsh).
;
-; Per-user install, no elevation (package.json build.nsis). These macros only
-; deal with the one piece of state that lives outside the install directory:
-; the W3 "run at sign-in" launcher the node's own CLI can create.
+; Per-user install, no elevation (package.json build.nsis). This does two things
+; beyond the default: put the bundled daemon on the user's PATH so `meshbay-node`
+; works in a terminal, and clean up the one piece of state that lives outside
+; the install directory (the W3 "run at sign-in" launcher).
;
-; Deliberately NOT touched here:
+; Deliberately NOT touched:
; - %LOCALAPPDATA%\meshbay\ (node.toml, keystore.enc, unlock.key, data/) --
; the keystore must survive an uninstall/reinstall; installers place files,
; never remove secrets.
+!include "WinMessages.nsh"
+!include "WordFunc.nsh"
+!insertmacro WordAdd
+!insertmacro un.WordAdd
+
+; The dir electron-builder drops resources into. `meshbay-node.exe` and its
+; frozen Python live directly in here. A fixed suffix of $INSTDIR, so both the
+; add (install) and the remove (uninstall, where $INSTDIR is still known) match
+; the exact same string.
+!define MB_NODE_BIN "$INSTDIR\resources\node-runtime"
+
!macro customInstall
- ; resources\node-runtime\meshbay-node.exe is overwritten by this install; a
+ ; resources\node-runtime\meshbay-node.exe is about to be overwritten; a
; daemon still running from a previous version holds the file open.
nsExec::Exec 'taskkill /IM meshbay-node.exe /F'
+
+ ; Add the daemon dir to the per-user PATH (HKCU\Environment). WordAdd is a
+ ; stock NSIS macro over a ';'-delimited list -- it is a no-op if the entry is
+ ; already there, so a reinstall does not double it. New shells only; the
+ ; broadcast tells already-open Explorer/shells to reload the environment.
+ ReadRegStr $0 HKCU "Environment" "Path"
+ ${WordAdd} "$0" ";" "+${MB_NODE_BIN}" $1
+ WriteRegExpandStr HKCU "Environment" "Path" "$1"
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
!macroend
!macro customUnInstall
nsExec::Exec 'taskkill /IM meshbay-node.exe /F'
+
+ ; Take our entry back out of PATH, leaving the rest of it alone.
+ ReadRegStr $0 HKCU "Environment" "Path"
+ ${un.WordAdd} "$0" ";" "-${MB_NODE_BIN}" $1
+ WriteRegExpandStr HKCU "Environment" "Path" "$1"
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
+
; meshbay_node.platform._startup_vbs() -- if the user ran "meshbay-node
; autostart install" (or toggled it in the client), this points wscript at
; the binary we are about to delete, and would error at every sign-in.