farmcontrol-ui/scripts/build-windows-deeplink.mjs
Tom Butcher 5450473f74
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
Implement deeplink functionality and update installer for Windows
- Introduced a new script to build the Windows deeplink executable, enhancing deep link handling.
- Updated the installer script to replace references from `launcher.exe` to `deeplink.exe` for better integration with the new deeplink functionality.
- Added a new `deeplink.js` file to manage deeplink processing and communication with running instances.
- Refactored single instance management to utilize the new deeplink capabilities, improving instance handling and navigation.
- Removed deprecated Windows launch argument handling to streamline the codebase.
2026-08-02 21:24:05 +01:00

61 lines
1.5 KiB
JavaScript

import { existsSync, mkdirSync } from 'node:fs'
import path from 'node:path'
import { spawnSync } from 'node:child_process'
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) {
if (!existsSync(entrypoint)) {
throw new Error(`build-windows-deeplink: entrypoint not found: ${entrypoint}`)
}
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}`,
entrypoint,
'--outfile',
outputPath
],
{
cwd: rootDir,
stdio: 'inherit',
env: process.env
}
)
if (result.status !== 0) {
throw new Error(
`build-windows-deeplink: bun build failed with exit code ${result.status ?? 1}`
)
}
if (!existsSync(outputPath)) {
throw new Error(`build-windows-deeplink: output not created: ${outputPath}`)
}
console.log(`build-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 <output-path>')
process.exit(1)
}
buildWindowsDeeplinkExe(path.resolve(outputArg))
}