From 335cb3c757bb485a2bbfd8048ab8eb2e98ce9156 Mon Sep 17 00:00:00 2001 From: Brian Hursey Date: Sun, 29 Nov 2026 01:15:52 +0000 Subject: [PATCH] Ship Windows as a per-user NSIS installer Replaces the Inno Setup script, which could not be built off Windows, with an NSIS installer that cross-compiles on Linux, installs under LOCALAPPDATA with no UAC prompt, and keeps the catalog on uninstall. build.mjs gains --installer and --no-installer, and --publish now ships the setup exe beside the portable zip. --- .gitignore | 1 + windows/README.md | 71 ++++++++--- windows/SEPARATE-REPO.md | 13 +- windows/build.mjs | 173 ++++++++++++++++++++++++-- windows/installer.iss | 90 -------------- windows/installer.nsi | 212 ++++++++++++++++++++++++++++++++ windows/releases/README.md | 7 +- windows/releases/SHA256SUMS.txt | 3 +- 8 files changed, 442 insertions(+), 128 deletions(-) delete mode 100644 windows/installer.iss create mode 100644 windows/installer.nsi diff --git a/.gitignore b/.gitignore index 259464e..3ff3c9e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ windows/launcher/webview2/obj/ # Transfer-only Windows release archives windows/releases/*.zip +windows/releases/*.exe diff --git a/windows/README.md b/windows/README.md index fa35bef..a71a990 100644 --- a/windows/README.md +++ b/windows/README.md @@ -41,7 +41,8 @@ not assumed: | Develop module | a current browser with WebGL2 (Edge, Chrome, Firefox) | So: a clean Windows 10/11 x64 machine, a browser, and ~250 MB where the data -folder lives. No VC++ redist, no .NET, no admin prompt, no installer. +folder lives. No VC++ redist, no .NET, no admin prompt. The setup exe installs +for the current user only; the portable zip needs no installer at all. What the launcher checks on every start (and `-Status` prints): @@ -67,8 +68,10 @@ Official links, shown in the dialogs when relevant: | Network | `node.exe` from nodejs.org (SHA-256 checked) and the npm registry | | Optional: Go 1.21+ | builds `Luminary.exe`; without it the PowerShell launcher ships | | Optional: Docker + BuildKit | the reproducible path, and the only way to get the Go exe on Linux | +| Optional: NSIS 3 | builds the setup exe; `--installer` unpacks a private copy on Linux when `makensis` is absent | -No Windows machine is required for the portable zip. +No Windows machine is required for either the portable zip or the setup exe: +NSIS cross-compiles the installer on Linux and macOS. ## Build @@ -77,21 +80,25 @@ node windows/build.mjs # npm run build, then the bundle node windows/build.mjs --skip-build # reuse the existing dist/ node windows/build.mjs --out /srv/builds/luminary-win node windows/build.mjs --launcher go # fail unless Go is installed -node windows/build.mjs --skip-build --publish # also copy the zip to windows/releases +node windows/build.mjs --installer # also build the setup exe (NSIS) +node windows/build.mjs --skip-build --publish # copy the zip and setup to windows/releases ``` Output: ``` / - Luminary-0.5.1-win-x64.zip the deliverable + Luminary-0.5.1-win-x64.zip the portable deliverable + installer/Luminary-0.5.1-win-x64-setup.exe the per-user installer stage/Luminary/ the unpacked bundle (kept for inspection) cache/node-v24.22.2-win-x64.exe pinned runtime, reused next time cache/SHASUMS256-v24.22.2.txt ``` -The build prints the zip size, its SHA-256, the Node version, the launcher kind -and the staged folder. +The build prints each artifact's size and SHA-256, the Node version, the +launcher kind and the staged folder. The setup exe is built whenever `makensis` +is found (or with `--installer`, which fetches NSIS on Linux); otherwise the zip +is built alone with a warning. ### Transferring it to Windows @@ -120,18 +127,44 @@ is `scratch`, so `--output` exports only the zip, checksum and staged bundle. `windows/Dockerfile.dockerignore` keeps `.git`, `node_modules` and `dist` out of the context; the app's own `Dockerfile` is unaffected. -### Installer (optional) +### Installer -Inno Setup 6 on any Windows machine (or a Windows CI runner): +`windows/installer.nsi` wraps the same staged bundle in an NSIS setup exe. NSIS +is a cross-compiler, so this builds on the Linux host as well as on Windows: -```bat -iscc /DAppVersion=0.5.1 /DLauncher=Luminary.cmd ^ - /DSourceDir="C:\builds\luminary\stage\Luminary" windows\installer.iss +```bash +node windows/build.mjs --installer # or --skip-build --installer ``` -Per-user install under `%LOCALAPPDATA%\Programs\Luminary`, Start-menu and -optional desktop shortcuts, optional "start at login" (`HKCU\…\Run`), and an -uninstaller that **keeps** `%LOCALAPPDATA%\Luminary\data`. +`--installer` uses `makensis` from `PATH` or `$MAKENSIS`; if neither exists on +Linux it downloads the two Ubuntu `nsis` packages into `/tools/nsis` and +runs them from there, so no root install is needed. Install it yourself with +`sudo apt install nsis`, `brew install makensis`, or the Windows installer from +. Compile by hand with: + +```bash +makensis -DAPP_VERSION=0.5.1 -DAPP_VERSION4=0.5.1.0 \ + -DSOURCE_DIR="$PWD/stage/Luminary" windows/installer.nsi +``` + +The setup is per-user: **no UAC prompt**, nothing in Program Files. It installs +to `%LOCALAPPDATA%\Programs\Luminary`, creates Start-menu shortcuts (Luminary, +Stop Luminary, the data folder), an optional desktop shortcut and an optional +"start at login" (`HKCU\…\Run`), registers an uninstaller in Apps & features, +and **keeps** `%LOCALAPPDATA%\Luminary\data` when uninstalled. Before replacing +files it runs the bundle's own `Luminary.ps1 -Stop`, so an upgrade over a +running copy works without killing every `node.exe` on the machine. + +Silent install and uninstall, for a script or a school lab image: + +```bat +Luminary-0.5.1-win-x64-setup.exe /S +"%LOCALAPPDATA%\Programs\Luminary\Uninstall.exe" /S +``` + +`/D=C:\path` overrides the install folder (last argument, unquoted, as NSIS +requires). The installer refuses 32-bit Windows and anything before Windows 10, +the same limits as the launcher, but says so before copying 250 MB. ## What is in the bundle @@ -312,8 +345,10 @@ then replaces `node.exe`. It refuses while Luminary is running. Set - Loopback only by default; set `HOST=0.0.0.0` for LAN proofing galleries. - The PowerShell launcher cannot clean up after a server crash; a stale `runtime.json` is simply ignored on the next start. -- `windows/installer.iss` needs Inno Setup and is not exercised by the Linux - build. +- The setup exe cannot be executed on the Linux build host. It is verified by + unpacking it and comparing the SHA-256 of every payload file with the staged + bundle, plus `SMOKE-WINDOWS.ps1` for the installed tree; a real install and + uninstall still needs one pass on Windows. ## Troubleshooting @@ -332,4 +367,6 @@ then replaces `node.exe`. It refuses while Luminary is running. Set | A sign-in screen appears | the server was started without `LUMINARY_LOCAL=1`, or it is the normal server, not the bundle | | Opens as a normal tab | Edge/Chrome not found, or `-Browser` / `LUMINARY_WINDOW=browser` was used | | Build refuses `--out` | the path is inside the repo; choose one outside | -| SmartScreen on first run | unsigned bundle: "More info" → "Run anyway" | +| SmartScreen on first run | unsigned build: "More info" → "Run anyway" (same for the setup exe) | +| The setup exe closes immediately on 32-bit Windows | it needs a 64-bit Windows 10/11 install; use the 64-bit build | +| Installed, but no catalog after uninstall | that is intentional: `%LOCALAPPDATA%\Luminary\data` is kept | diff --git a/windows/SEPARATE-REPO.md b/windows/SEPARATE-REPO.md index 2bef7c4..1c23fc9 100644 --- a/windows/SEPARATE-REPO.md +++ b/windows/SEPARATE-REPO.md @@ -25,7 +25,7 @@ luminary-windows/ upstream.txt # pinned tag + commit + expected package version build.mjs # same script as windows/build.mjs, one copy launcher/ # Luminary.ps1, .cmd, .vbs, Stop, go/ - installer.iss + installer.nsi # NSIS, builds on Linux Dockerfile # Go + Node 24 image for the exe build README.md CHANGELOG.md # per-release: upstream tag, node version, hashes @@ -99,14 +99,15 @@ jobs: path: ${{ runner.temp }}/out/* ``` -Optional later steps: `softprops/action-gh-release` to attach the zip to a -Gitea release, and a Windows runner that also builds `installer.iss` (Inno Setup -is not available on Linux without Wine). +Optional later steps: `softprops/action-gh-release` to attach the zip and setup +exe to a Gitea release. NSIS runs on the Linux runner too (`--installer`), so a +Windows runner is not needed for the installer. ## Release and version policy - One packaging release per upstream tag that should be installable on Windows; - the artifact is `Luminary--win-x64.zip`. + the artifacts are `Luminary--win-x64-setup.exe` and the portable + `Luminary--win-x64.zip`. - `CHANGELOG.md` records upstream tag/commit, bundled Node version, artifact SHA-256 and any launcher change. - Security fixes: when upstream ships one, the pin moves, the packaging tag @@ -124,7 +125,7 @@ is a packaging-repo feature, not an app change. ## Migration from the in-repo `windows/` folder 1. Create the new repo. -2. Copy `windows/` to its root (`build.mjs`, `launcher/`, `installer.iss`, +2. Copy `windows/` to its root (`build.mjs`, `launcher/`, `installer.nsi`, `Dockerfile`, this plan and `README.md`), adjusting the input paths in `build.mjs` to the fetched upstream work tree. 3. Add `upstream.txt`, the CI workflow, `CHANGELOG.md`. diff --git a/windows/build.mjs b/windows/build.mjs index 3a19684..bdbb156 100644 --- a/windows/build.mjs +++ b/windows/build.mjs @@ -62,8 +62,11 @@ Usage: node windows/build.mjs [options] --launcher auto (default), ps or go. "go" needs a Go toolchain and produces Luminary.exe; "ps" always works. --allow-dirty skip the check that the checkout is clean outside windows/ - --publish copy the finished zip to windows/releases (plus a - SHA256SUMS.txt) so it can be transferred to a Windows PC + --installer also build Luminary--win-x64-setup.exe with NSIS + (fetches a private NSIS copy on Linux if makensis is absent) + --no-installer skip the setup exe even when makensis is installed + --publish copy the finished zip and setup exe to windows/releases + (plus a SHA256SUMS.txt) so they can be transferred to a PC --webview2 ship a prebuilt LuminaryWindow.exe (native WebView2 window). Build it with: docker run --rm -v $PWD/windows/launcher:/src \\ @@ -104,6 +107,7 @@ function parseArgs(argv) { launcher: 'auto', build: true, allowDirty: false, + installer: 'auto', publish: false, webview2: null, help: false, @@ -127,6 +131,10 @@ function parseArgs(argv) { i += 1; } else if (arg === '--skip-build') { options.build = false; + } else if (arg === '--installer') { + options.installer = 'yes'; + } else if (arg === '--no-installer') { + options.installer = 'no'; } else if (arg === '--allow-dirty') { options.allowDirty = true; } else if (arg === '--publish') { @@ -595,6 +603,129 @@ function writeZip(sourceDir, zipPath) { return { files: count, bytes: statSync(zipPath).size }; } +/* ------------------------------------------------------------- installer ---- */ + +function dirSizeBytes(dir) { + let total = 0; + for (const entry of readdirSync(dir, { withFileTypes: true })) { + const absolute = path.join(dir, entry.name); + total += entry.isDirectory() ? dirSizeBytes(absolute) : statSync(absolute).size; + } + return total; +} + +function cachedMakensis(outDir) { + const root = path.join(outDir, 'tools', 'nsis'); + const bin = path.join(root, 'usr', 'bin', 'makensis'); + if (!existsSync(bin)) return null; + return { bin, nsisdir: path.join(root, 'usr', 'share', 'nsis') }; +} + +function findMakensis(outDir) { + if (process.env.MAKENSIS) { + return { bin: process.env.MAKENSIS, nsisdir: process.env.NSISDIR || null }; + } + const cached = cachedMakensis(outDir); + if (cached) return cached; + const which = spawnSync(process.platform === 'win32' ? 'where' : 'which', ['makensis'], { + encoding: 'utf8', + }); + const found = !which.error && which.status === 0 ? which.stdout.split(/\r?\n/)[0].trim() : ''; + return found ? { bin: found, nsisdir: process.env.NSISDIR || null } : null; +} + +/** + * NSIS is a small cross-compiler: on Linux it produces the same .exe as it + * would on Windows. Ubuntu ships it as two .debs, which unpack into the build + * cache without root, so a fresh host can build the installer unattended. + */ +async function fetchMakensis(outDir) { + if (process.platform !== 'linux' || process.arch !== 'x64') return null; + const dpkg = spawnSync('dpkg-deb', ['--version'], { stdio: 'ignore' }); + if (dpkg.error || dpkg.status !== 0) return null; + const packVersion = '3.09-4ubuntu1'; + const base = 'http://archive.ubuntu.com/ubuntu/pool/universe/n/nsis'; + const debs = path.join(outDir, 'cache', 'nsis-debs'); + const root = path.join(outDir, 'tools', 'nsis'); + mkdirSync(debs, { recursive: true }); + rmSync(root, { recursive: true, force: true }); + for (const name of [`nsis_${packVersion}_amd64.deb`, `nsis-common_${packVersion}_all.deb`]) { + const file = path.join(debs, name); + if (!existsSync(file)) { + try { + writeFileSync(file, await download(`${base}/${name}`)); + } catch (error) { + warn(`could not download ${name} (${error.message})`); + return null; + } + } + const unpack = spawnSync('dpkg-deb', ['-x', file, root], { encoding: 'utf8' }); + if (unpack.error || unpack.status !== 0) { + warn(`could not unpack ${name}: ${(unpack.stderr || '').trim() || 'dpkg-deb failed'}`); + return null; + } + } + return cachedMakensis(outDir); +} + +async function resolveMakensis(outDir, required) { + const found = findMakensis(outDir); + if (found) return found; + if (!required) return null; + log('nsis', 'makensis not found; unpacking a private NSIS into the build cache'); + const fetched = await fetchMakensis(outDir); + if (fetched) { + log('nsis', `NSIS ${packVersionOf(fetched.bin)} ready (no root install needed)`); + return fetched; + } + fail( + 'NSIS is required for --installer and was not found.\n' + + ' Ubuntu/Debian: sudo apt install nsis\n' + + ' macOS: brew install makensis\n' + + ' Windows: https://nsis.sourceforge.io\n' + + ' or set MAKENSIS=/path/to/makensis', + ); +} + +function packVersionOf(makensis) { + const result = spawnSync(makensis, ['-VERSION'], { encoding: 'utf8' }); + return !result.error && result.status === 0 ? result.stdout.trim() : 'unknown version'; +} + +function buildInstaller({ outDir, bundle, pkg, makensis }) { + const script = path.join(HERE, 'installer.nsi'); + if (!existsSync(script)) fail(`installer script missing: ${script}`); + const outputDir = path.join(outDir, 'installer'); + mkdirSync(outputDir, { recursive: true }); + const setup = path.join(outputDir, `Luminary-${pkg.version}-win-x64-setup.exe`); + rmSync(setup, { force: true }); + + // NSIS wants four numeric fields; 0.5.1 -> 0.5.1.0 + const fields = pkg.version.split('.').map((n) => Number(n) || 0); + while (fields.length < 4) fields.push(0); + const version4 = fields.slice(0, 4).join('.'); + const installKb = Math.ceil(dirSizeBytes(bundle) / 1024); + + log('installer', `makensis ${path.basename(script)} (${(installKb / 1024).toFixed(0)} MB payload)`); + run( + makensis.bin, + [ + '-V2', + `-DAPP_VERSION=${pkg.version}`, + `-DAPP_VERSION4=${version4}`, + `-DSOURCE_DIR=${bundle}`, + `-DOUTPUT_DIR=${outputDir}`, + `-DICON=${path.join(LAUNCHER_FILES, 'Luminary.ico')}`, + `-DINSTALL_KB=${installKb}`, + script, + ], + ROOT, + makensis.nsisdir ? { NSISDIR: makensis.nsisdir } : undefined, + ); + if (!existsSync(setup)) fail('makensis reported success but produced no setup exe'); + return { path: setup, bytes: statSync(setup).size }; +} + /* ----------------------------------------------------------------- main ---- */ async function main() { @@ -653,9 +784,20 @@ async function main() { rmSync(stageRoot, { recursive: true, force: true }); renameSync(workRoot, stageRoot); + const stagedBundle = path.join(stageRoot, 'Luminary'); + let installer = null; + if (options.installer !== 'no') { + const makensis = await resolveMakensis(options.out, options.installer === 'yes'); + if (makensis) { + installer = buildInstaller({ outDir: options.out, bundle: stagedBundle, pkg, makensis }); + log('installer', `${path.basename(installer.path)} (${(installer.bytes / 1024 / 1024).toFixed(1)} MB)`); + } else { + warn('makensis is not installed; shipping the zip only (install NSIS for the setup exe)'); + } + } + // The isolation contract: nothing outside windows/ may have changed. if (!options.allowDirty) checkRepoClean(options); - const stagedBundle = path.join(stageRoot, 'Luminary'); // Hand-off copy. The staging and the zip stay outside the checkout; this is // the one write into the repository, into windows/releases, for transfer to a @@ -663,14 +805,16 @@ async function main() { let published = null; if (options.publish) { mkdirSync(RELEASES_DIR, { recursive: true }); - const target = path.join(RELEASES_DIR, path.basename(zipPath)); - cpSync(zipPath, target); - writeFileSync( - path.join(RELEASES_DIR, 'SHA256SUMS.txt'), - `${sha256File(target)} ${path.basename(target)}\n`, - ); - published = target; - log('publish', path.relative(ROOT, target)); + const artifacts = [zipPath, ...(installer ? [installer.path] : [])]; + const sums = []; + for (const artifact of artifacts) { + const target = path.join(RELEASES_DIR, path.basename(artifact)); + cpSync(artifact, target); + sums.push(`${sha256File(target)} ${path.basename(target)}`); + log('publish', path.relative(ROOT, target)); + } + writeFileSync(path.join(RELEASES_DIR, 'SHA256SUMS.txt'), `${sums.join('\n')}\n`); + published = path.join(RELEASES_DIR, path.basename(zipPath)); } process.stdout.write( @@ -680,6 +824,13 @@ async function main() { ` artifact ${zipPath}`, ` size ${(zip.bytes / 1024 / 1024).toFixed(1)} MB (${zip.files} files)`, ` sha256 ${sha256File(zipPath)}`, + ...(installer + ? [ + ` setup ${installer.path}`, + ` setup MB ${(installer.bytes / 1024 / 1024).toFixed(1)}`, + ` setup sha ${sha256File(installer.path)}`, + ] + : []), ` node ${options.node} win-x64`, ` launcher ${launcher === 'go' ? 'Luminary.exe' : 'Luminary.cmd / Luminary.vbs'}`, ...(options.webview2 ? [` window LuminaryWindow.exe (native WebView2)`] : []), diff --git a/windows/installer.iss b/windows/installer.iss deleted file mode 100644 index 240cd0f..0000000 --- a/windows/installer.iss +++ /dev/null @@ -1,90 +0,0 @@ -; Optional per-user installer for the Luminary Windows bundle. -; -; Build the bundle first: node windows/build.mjs -; Then, from the output directory: -; iscc /DAppVersion=0.5.1 /DSourceDir="" \ -; \windows\installer.iss -; -; The default SourceDir is relative to this script and only works when iscc is -; run with the bundle's stage folder in reach. Inno Setup 6 is required: -; https://jrsoftware.org/isinfo.php -; -; Per-user install: no UAC, no Program Files, data stays in -; %LOCALAPPDATA%\Luminary\data and is kept on uninstall. - -#ifndef AppVersion - #define AppVersion "0.5.1" -#endif -#ifndef Launcher - ; Luminary.cmd works even when Windows Script Host is disabled; Luminary.exe - ; for the Go launcher build. - #define Launcher "Luminary.cmd" -#endif -#ifndef SourceDir - #define SourceDir "stage\Luminary" -#endif - -#define AppName "Luminary" -#define AppPublisher "Maple Street" -#define AppURL "https://git.maple-street.net/bhursey/luminary" - -[Setup] -AppId={{6E1B4C1E-8D6B-4F2E-9E3B-2C7A5D9F4A11} -AppName={#AppName} -AppVersion={#AppVersion} -AppPublisher={#AppPublisher} -AppPublisherURL={#AppURL} -DefaultDirName={localappdata}\Programs\{#AppName} -DefaultGroupName={#AppName} -DisableProgramGroupPage=yes -PrivilegesRequired=lowest -ArchitecturesAllowed=x64compatible -ArchitecturesInstallIn64BitMode=x64compatible -OutputDir=installer-output -OutputBaseFilename=Luminary-{#AppVersion}-win-x64-setup -Compression=lzma2/max -SolidCompression=yes -WizardStyle=modern -UninstallDisplayName={#AppName} -SetupIconFile={#SourceDir}\Luminary.ico -; The uninstaller must not delete the catalog in %LOCALAPPDATA%\Luminary\data; -; the data folder lives outside {app} on purpose. - -[Tasks] -Name: "desktopicon"; Description: "Create a desktop shortcut"; GroupDescription: "Shortcuts:"; Flags: checkedonce -Name: "startup"; Description: "Start Luminary when I sign in"; GroupDescription: "Startup:"; Flags: unchecked - -[Files] -; recurses into app\, node_modules\, logs placeholders and the launcher files. -Source: "{#SourceDir}\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs ignoreversion - -[Icons] -Name: "{group}\{#AppName}"; Filename: "{app}\{#Launcher}"; WorkingDir: "{app}"; IconFilename: "{app}\Luminary.ico" -Name: "{group}\Stop {#AppName}"; Filename: "{app}\Stop Luminary.cmd"; WorkingDir: "{app}"; IconFilename: "{app}\Luminary.ico" -Name: "{group}\{#AppName} data folder"; Filename: "%LOCALAPPDATA%\Luminary\data" -Name: "{autodesktop}\{#AppName}"; Filename: "{app}\{#Launcher}"; WorkingDir: "{app}"; Tasks: desktopicon; IconFilename: "{app}\Luminary.ico" - -[Registry] -Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; \ - ValueName: "Luminary"; ValueData: """{app}\{#Launcher}"""; Flags: uninsdeletevalue; Tasks: startup - -[Run] -Filename: "{app}\{#Launcher}"; Description: "Start Luminary now"; Flags: nowait postinstall skipifsilent - -[UninstallDelete] -; Remove the program folder and its logs/runtime file. Never the data folder. -Type: filesandordirs; Name: "{app}" - -[Code] -procedure CurStepChanged(CurStep: TSetupStep); -begin - if CurStep = ssPostInstall then - begin - // The data folder is created by the launcher on first start; tell the user - // where it is so the "uninstall keeps my catalog" promise is obvious. - MsgBox('Luminary stores its catalog in:' + #13#10 + - ExpandConstant('{localappdata}') + '\Luminary\data' + #13#10#13#10 + - 'It is not removed when you uninstall. Back it up by copying that folder ' - + 'while Luminary is stopped.', mbInformation, MB_OK); - end; -end; diff --git a/windows/installer.nsi b/windows/installer.nsi new file mode 100644 index 0000000..b1147f2 --- /dev/null +++ b/windows/installer.nsi @@ -0,0 +1,212 @@ +; Per-user installer for the Luminary Windows bundle, built with NSIS 3. +; +; NSIS runs on Linux, macOS and Windows, so the same build host that produces +; the zip also produces the setup executable: +; +; node windows/build.mjs --installer --publish +; +; or by hand, from the repository root: +; +; makensis -DAPP_VERSION=0.5.1 -DAPP_VERSION4=0.5.1.0 \ +; -DSOURCE_DIR="$PWD/../.cache/stage/Luminary" windows/installer.nsi +; +; Nothing is installed for all users: no UAC prompt, no Program Files. The +; program goes to %LOCALAPPDATA%\Programs\Luminary and the catalog stays in +; %LOCALAPPDATA%\Luminary\data, which the uninstaller never touches. + +Unicode true +ManifestDPIAware true +ManifestSupportedOS win10 +RequestExecutionLevel user +SetCompressor /SOLID lzma +SetCompressorDictSize 32 +CRCCheck on + +!include "MUI2.nsh" +!include "x64.nsh" +!include "WinVer.nsh" + +!ifndef APP_VERSION + !define APP_VERSION "0.5.1" +!endif +; NSIS wants four numeric fields for the exe's version resource. +!ifndef APP_VERSION4 + !define APP_VERSION4 "0.5.1.0" +!endif +; Forward slashes throughout: makensis is cross-platform, and this file is +; compiled on Linux as often as on Windows. +!ifndef SOURCE_DIR + !define SOURCE_DIR "${__FILEDIR__}/stage/Luminary" +!endif +!ifndef OUTPUT_DIR + !define OUTPUT_DIR "${__FILEDIR__}/installer-output" +!endif +!ifndef ICON + !define ICON "${__FILEDIR__}/launcher/Luminary.ico" +!endif +; Size of the installed tree in KB, for Add/Remove Programs. The builder +; measures the staged bundle; the fallback is roughly right for a full build. +!ifndef INSTALL_KB + !define INSTALL_KB "250000" +!endif + +!define APP_NAME "Luminary" +!define APP_PUBLISHER "Maple Street" +!define APP_URL "https://git.maple-street.net/bhursey/luminary" +!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Luminary" +!define APP_KEY "Software\Luminary" +!define RUN_KEY "Software\Microsoft\Windows\CurrentVersion\Run" + +Name "${APP_NAME} ${APP_VERSION}" +BrandingText "${APP_NAME} ${APP_VERSION}" +OutFile "${OUTPUT_DIR}/Luminary-${APP_VERSION}-win-x64-setup.exe" +InstallDir "$LOCALAPPDATA\Programs\Luminary" +InstallDirRegKey HKCU "${APP_KEY}" "InstallDir" + +VIProductVersion "${APP_VERSION4}" +VIAddVersionKey "ProductName" "${APP_NAME}" +VIAddVersionKey "ProductVersion" "${APP_VERSION}" +VIAddVersionKey "FileDescription" "${APP_NAME} setup" +VIAddVersionKey "FileVersion" "${APP_VERSION}" +VIAddVersionKey "CompanyName" "${APP_PUBLISHER}" +VIAddVersionKey "LegalCopyright" "MIT licensed" + +!define MUI_ICON "${ICON}" +!define MUI_UNICON "${ICON}" +!define MUI_ABORTWARNING +!define MUI_WELCOMEPAGE_TITLE "Install ${APP_NAME} ${APP_VERSION}" +!define MUI_WELCOMEPAGE_TEXT "This installs the Luminary desktop app for your Windows account.$\r$\n$\r$\nNo administrator rights are needed: the app goes in your own AppData folder, and the catalog, previews and originals index stay in %LOCALAPPDATA%\Luminary\data. Uninstalling keeps that folder so you never lose a catalog.$\r$\n$\r$\nNode.js, .NET and the Visual C++ runtime are not required - everything Luminary needs ships inside." +!define MUI_FINISHPAGE_TEXT "${APP_NAME} is installed.$\r$\n$\r$\nYour catalog lives in %LOCALAPPDATA%\Luminary\data. Back it up by copying that folder while Luminary is stopped.$\r$\n$\r$\nUninstalling removes the app but not the catalog." +!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README-windows.txt" +!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show the Windows readme" +!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED + +!if /FileExists "${SOURCE_DIR}/Luminary.vbs" + !define MUI_FINISHPAGE_RUN "$INSTDIR\Luminary.vbs" +!else + !define MUI_FINISHPAGE_RUN "$INSTDIR\Luminary.cmd" +!endif +!define MUI_FINISHPAGE_RUN_TEXT "Start ${APP_NAME}" + +!insertmacro MUI_PAGE_WELCOME +!if /FileExists "${SOURCE_DIR}/LICENSE" + !insertmacro MUI_PAGE_LICENSE "${SOURCE_DIR}/LICENSE" +!endif +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +!insertmacro MUI_LANGUAGE "English" + +LangString DESC_Main ${LANG_ENGLISH} "The editor, film looks, bundled Node runtime and documentation. Required." +LangString DESC_Desktop ${LANG_ENGLISH} "Put a Luminary shortcut on the desktop." +LangString DESC_Startup ${LANG_ENGLISH} "Start Luminary in the background when you sign in to Windows." + +Function .onInit + ; The launcher refuses these too, but the installer should say so before it + ; copies 250 MB onto an unsupported PC. + ${IfNot} ${RunningX64} + MessageBox MB_ICONSTOP "${APP_NAME} needs 64-bit Windows 10 or 11. This PC is running a 32-bit copy of Windows." + Abort + ${EndIf} + ${IfNot} ${AtLeastWin10} + MessageBox MB_ICONSTOP "${APP_NAME} needs Windows 10 or 11. Older versions are not supported." + Abort + ${EndIf} +FunctionEnd + +; Stop a copy started from this folder, so an upgrade can replace node.exe and +; app\ while it is not in use. Uses the launcher's own -Stop path, which reads +; runtime.json, rather than killing every node.exe on the machine. +!macro StopRunning + ${If} ${FileExists} "$INSTDIR\Luminary.ps1" + DetailPrint "Stopping a running Luminary..." + nsExec::ExecToLog 'powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$INSTDIR\Luminary.ps1" -Stop' + Pop $0 + Sleep 1200 + ${EndIf} +!macroend + +Section "Luminary (required)" SEC_MAIN + SectionIn RO + + !insertmacro StopRunning + + SetOutPath "$INSTDIR" + File /r "${SOURCE_DIR}/*.*" + + CreateDirectory "$LOCALAPPDATA\Luminary\data" + WriteUninstaller "$INSTDIR\Uninstall.exe" + + CreateDirectory "$SMPROGRAMS\Luminary" + !if /FileExists "${SOURCE_DIR}/Luminary.vbs" + CreateShortCut "$SMPROGRAMS\Luminary\Luminary.lnk" "$INSTDIR\Luminary.vbs" "" "$INSTDIR\Luminary.ico" 0 + !else + CreateShortCut "$SMPROGRAMS\Luminary\Luminary.lnk" "$INSTDIR\Luminary.cmd" "" "$INSTDIR\Luminary.ico" 0 + !endif + CreateShortCut "$SMPROGRAMS\Luminary\Stop Luminary.lnk" "$INSTDIR\Stop Luminary.cmd" "" "$INSTDIR\Luminary.ico" 0 + CreateShortCut "$SMPROGRAMS\Luminary\Luminary data folder.lnk" "$LOCALAPPDATA\Luminary\data" "" "$INSTDIR\Luminary.ico" 0 + + WriteRegStr HKCU "${APP_KEY}" "InstallDir" "$INSTDIR" + WriteRegStr HKCU "${APP_KEY}" "Version" "${APP_VERSION}" + + WriteRegStr HKCU "${UNINST_KEY}" "DisplayName" "${APP_NAME}" + WriteRegStr HKCU "${UNINST_KEY}" "DisplayVersion" "${APP_VERSION}" + WriteRegStr HKCU "${UNINST_KEY}" "Publisher" "${APP_PUBLISHER}" + WriteRegStr HKCU "${UNINST_KEY}" "URLInfoAbout" "${APP_URL}" + WriteRegStr HKCU "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\Luminary.ico" + WriteRegStr HKCU "${UNINST_KEY}" "InstallLocation" "$INSTDIR" + WriteRegStr HKCU "${UNINST_KEY}" "UninstallString" '"$INSTDIR\Uninstall.exe"' + WriteRegStr HKCU "${UNINST_KEY}" "QuietUninstallString" '"$INSTDIR\Uninstall.exe" /S' + WriteRegDWORD HKCU "${UNINST_KEY}" "EstimatedSize" ${INSTALL_KB} + WriteRegDWORD HKCU "${UNINST_KEY}" "NoModify" 1 + WriteRegDWORD HKCU "${UNINST_KEY}" "NoRepair" 1 +SectionEnd + +Section "Desktop shortcut" SEC_DESKTOP + !if /FileExists "${SOURCE_DIR}/Luminary.vbs" + CreateShortCut "$DESKTOP\Luminary.lnk" "$INSTDIR\Luminary.vbs" "" "$INSTDIR\Luminary.ico" 0 + !else + CreateShortCut "$DESKTOP\Luminary.lnk" "$INSTDIR\Luminary.cmd" "" "$INSTDIR\Luminary.ico" 0 + !endif +SectionEnd + +Section "Start Luminary when I sign in" SEC_STARTUP + !if /FileExists "${SOURCE_DIR}/Luminary.vbs" + WriteRegStr HKCU "${RUN_KEY}" "Luminary" '"$INSTDIR\Luminary.vbs"' + !else + WriteRegStr HKCU "${RUN_KEY}" "Luminary" '"$INSTDIR\Luminary.cmd"' + !endif +SectionEnd + +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${SEC_MAIN} $(DESC_Main) + !insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} $(DESC_Desktop) + !insertmacro MUI_DESCRIPTION_TEXT ${SEC_STARTUP} $(DESC_Startup) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + +Section "Uninstall" + !insertmacro StopRunning + + Delete "$SMPROGRAMS\Luminary\Luminary.lnk" + Delete "$SMPROGRAMS\Luminary\Stop Luminary.lnk" + Delete "$SMPROGRAMS\Luminary\Luminary data folder.lnk" + RMDir "$SMPROGRAMS\Luminary" + Delete "$DESKTOP\Luminary.lnk" + + DeleteRegValue HKCU "${RUN_KEY}" "Luminary" + DeleteRegKey HKCU "${UNINST_KEY}" + DeleteRegKey HKCU "${APP_KEY}" + + ; %LOCALAPPDATA%\Luminary\data is deliberately outside $INSTDIR, so this + ; only removes the program, its logs and its runtime marker. + RMDir /r "$INSTDIR" + + IfSilent uninstallDone + MessageBox MB_ICONINFORMATION|MB_OK "${APP_NAME} was removed.$\r$\n$\r$\nYour catalog in $LOCALAPPDATA\Luminary\data was kept: delete that folder yourself if you no longer want it." + uninstallDone: +SectionEnd diff --git a/windows/releases/README.md b/windows/releases/README.md index 23ec633..41d394d 100644 --- a/windows/releases/README.md +++ b/windows/releases/README.md @@ -6,9 +6,10 @@ app never looks in this folder. | File | What to do with it | | --- | --- | -| `Luminary--win-x64.zip` | Copy to the Windows PC, right-click → **Extract All…**, then run `Luminary.cmd` (or `Luminary.vbs`) from the extracted `Luminary` folder. `README-windows.txt` inside the zip is the end-user guide. | +| `Luminary--win-x64-setup.exe` | Copy to the Windows PC and run it. Per-user install, no admin prompt: Start-menu shortcuts, optional desktop shortcut and start-at-login, and an uninstaller that keeps `%LOCALAPPDATA%\Luminary\data`. | +| `Luminary--win-x64.zip` | The portable alternative: extract, then run `Luminary.cmd` (or `Luminary.vbs`) from the extracted `Luminary` folder. `README-windows.txt` inside the zip is the end-user guide. | | `LuminaryWindow.exe` inside the zip | optional native window (WebView2); the launcher uses it automatically when present, and starting it directly forwards to the launcher | -| `SHA256SUMS.txt` | Check the copy did not corrupt: `certutil -hashfile Luminary--win-x64.zip SHA256` | +| `SHA256SUMS.txt` | Check a copy did not corrupt: `certutil -hashfile Luminary--win-x64-setup.exe SHA256` | ## Rebuilding this folder @@ -17,7 +18,7 @@ node windows/build.mjs --publish # npm run build, then bundle + copy node windows/build.mjs --skip-build --publish # reuse the existing dist/ ``` -`--publish` copies the finished zip and writes `SHA256SUMS.txt`. The build still +`--publish` copies the finished zip, the setup exe and `SHA256SUMS.txt`. The build still stages and zips **outside** the checkout (`~/.cache/luminary-windows`, or `%LOCALAPPDATA%\Luminary\build` on Windows); this folder only receives the final artifact. Old versions are not deleted, so remove the ones you no longer ship. diff --git a/windows/releases/SHA256SUMS.txt b/windows/releases/SHA256SUMS.txt index cfc9563..ff0cd89 100644 --- a/windows/releases/SHA256SUMS.txt +++ b/windows/releases/SHA256SUMS.txt @@ -1 +1,2 @@ -644c4e60451466e69d16860a9d1be509acc204168fb30bcd3f4f6b75ba24d922 Luminary-0.5.1-win-x64.zip +22b8943d1ca3bed3ef115530831947e4e03f6a45317ec6b35c10e871fad22a9a Luminary-0.5.1-win-x64.zip +b33e3d8b595aa3ff20b0898f3adea639e02afe9eb54c4fba5dd09ec07e041a0c Luminary-0.5.1-win-x64-setup.exe