From a196d0f26d0913b4aa77009400fa61eed71b2437 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 2 Aug 2026 21:34:43 +0100 Subject: [PATCH] Update Windows installer and deeplink handling - Changed the default icon reference in the Windows installer from `deeplink.exe` to `launcher.exe`. - Updated the command for opening the deeplink to use `bun.exe` with the new `deeplink.js` script. - Refactored the deeplink build script to rename the function from `buildWindowsDeeplinkExe` to `stageWindowsDeeplink` for clarity. - Adjusted the PowerShell script to check for the presence of `deeplink.js` instead of `deeplink.exe`, ensuring correct staging of the application. - Modified the finalization script to reflect the new staging function for the deeplink, enhancing the build process. --- packaging/windows/installer.nsh | 4 ++-- scripts/build-windows-deeplink.mjs | 26 +++++++++++--------------- scripts/build-windows-nsis.ps1 | 6 +++--- scripts/finalize-desktop-artifacts.mjs | 10 ++++------ 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/packaging/windows/installer.nsh b/packaging/windows/installer.nsh index d205edd..251d261 100644 --- a/packaging/windows/installer.nsh +++ b/packaging/windows/installer.nsh @@ -51,10 +51,10 @@ DeleteRegKey HKCR "farmcontrol" WriteRegStr HKCR "farmcontrol" "" "URL:farmcontrol" WriteRegStr HKCR "farmcontrol" "URL Protocol" "" - WriteRegStr HKCR "farmcontrol\DefaultIcon" "" "$INSTDIR\bin\deeplink.exe" + WriteRegStr HKCR "farmcontrol\DefaultIcon" "" "$INSTDIR\bin\launcher.exe" WriteRegStr HKCR "farmcontrol\shell" "" "" WriteRegStr HKCR "farmcontrol\shell\Open" "" "" - WriteRegStr HKCR "farmcontrol\shell\Open\command" "" '"$INSTDIR\bin\deeplink.exe" "%1"' + WriteRegStr HKCR "farmcontrol\shell\Open\command" "" '"$INSTDIR\bin\bun.exe" "$INSTDIR\bin\deeplink.js" "%1"' !macroend !macro customUnInstall diff --git a/scripts/build-windows-deeplink.mjs b/scripts/build-windows-deeplink.mjs index d5cf304..5a1b05f 100644 --- a/scripts/build-windows-deeplink.mjs +++ b/scripts/build-windows-deeplink.mjs @@ -6,24 +6,20 @@ import { fileURLToPath } from 'node:url' const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') const entrypoint = path.join(rootDir, 'src/bun/deeplink.js') -export function buildWindowsDeeplinkExe(outputPath) { +export function stageWindowsDeeplink(appDir) { if (!existsSync(entrypoint)) { - throw new Error(`build-windows-deeplink: entrypoint not found: ${entrypoint}`) + throw new Error(`stage-windows-deeplink: entrypoint not found: ${entrypoint}`) } + const outputPath = path.join(appDir, 'bin', 'deeplink.js') mkdirSync(path.dirname(outputPath), { recursive: true }) - const target = process.env.ELECTROBUN_ARCH === 'arm64' - ? 'bun-windows-x64' - : 'bun-windows-x64' - const result = spawnSync( 'bun', [ 'build', - '--compile', '--minify', - `--target=${target}`, + '--target=bun', entrypoint, '--outfile', outputPath @@ -37,24 +33,24 @@ export function buildWindowsDeeplinkExe(outputPath) { if (result.status !== 0) { throw new Error( - `build-windows-deeplink: bun build failed with exit code ${result.status ?? 1}` + `stage-windows-deeplink: bun build failed with exit code ${result.status ?? 1}` ) } if (!existsSync(outputPath)) { - throw new Error(`build-windows-deeplink: output not created: ${outputPath}`) + throw new Error(`stage-windows-deeplink: output not created: ${outputPath}`) } - console.log(`build-windows-deeplink: created ${outputPath}`) + console.log(`stage-windows-deeplink: created ${outputPath}`) return outputPath } if (process.argv[1] === fileURLToPath(import.meta.url)) { - const outputArg = process.argv[2] - if (!outputArg) { - console.error('Usage: bun scripts/build-windows-deeplink.mjs ') + const appDirArg = process.argv[2] + if (!appDirArg) { + console.error('Usage: bun scripts/build-windows-deeplink.mjs ') process.exit(1) } - buildWindowsDeeplinkExe(path.resolve(outputArg)) + stageWindowsDeeplink(path.resolve(appDirArg)) } diff --git a/scripts/build-windows-nsis.ps1 b/scripts/build-windows-nsis.ps1 index 6bcfdea..34f1b7e 100644 --- a/scripts/build-windows-nsis.ps1 +++ b/scripts/build-windows-nsis.ps1 @@ -68,12 +68,12 @@ if ($stagedAppBytes -lt 5242880) { } $requiredExe = Join-Path $stagingAppDir "bin\launcher.exe" -$requiredDeeplinkExe = Join-Path $stagingAppDir "bin\deeplink.exe" +$requiredDeeplinkScript = Join-Path $stagingAppDir "bin\deeplink.js" if (-not (Test-Path $requiredExe)) { throw "Staged application is missing bin\launcher.exe" } -if (-not (Test-Path $requiredDeeplinkExe)) { - throw "Staged application is missing bin\deeplink.exe" +if (-not (Test-Path $requiredDeeplinkScript)) { + throw "Staged application is missing bin\deeplink.js" } Copy-Item -LiteralPath $nsiPath -Destination (Join-Path $workDir "farmcontrol.nsi") diff --git a/scripts/finalize-desktop-artifacts.mjs b/scripts/finalize-desktop-artifacts.mjs index 2254c0d..3e3a525 100644 --- a/scripts/finalize-desktop-artifacts.mjs +++ b/scripts/finalize-desktop-artifacts.mjs @@ -19,7 +19,7 @@ import { cleanExpandedWindowsApp, expandWindowsAppFromArchive } from './expand-windows-installer.mjs' -import { buildWindowsDeeplinkExe } from './build-windows-deeplink.mjs' +import { stageWindowsDeeplink } from './build-windows-deeplink.mjs' import { codesignMacAppBundle } from './codesign-macos-app.mjs' const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') @@ -429,10 +429,8 @@ function buildMacPkg(appBundlePath, arch) { return pkgPath } -function stageWindowsDeeplinkExe(appDir) { - const deeplinkPath = path.join(appDir, 'bin', 'deeplink.exe') - buildWindowsDeeplinkExe(deeplinkPath) - return deeplinkPath +function stageWindowsDeeplinkScript(appDir) { + return stageWindowsDeeplink(appDir) } function cleanWinBuildDir(arch) { @@ -584,7 +582,7 @@ async function main() { installerFiles.setupArchive, platformDir ) - stageWindowsDeeplinkExe(appDir) + stageWindowsDeeplinkScript(appDir) let published try {