farmcontrol-ui/scripts/build-windows-deeplink.mjs
Tom Butcher f641ea390d
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
Implement user access permissions and update deeplink handling in Windows installer
- Added a new macro in `grant-users-access.nsh` to grant standard users read and execute access to the installation directory, enhancing accessibility for non-admin users.
- Updated `installer.nsh` to include the new macro during installation, ensuring proper permissions are set.
- Changed the output file from `deeplink.js` to `deeplink.exe` in the build process, improving the executable handling for the application.
- Refactored the installer script to ensure the correct command is used for the farmcontrol URI handler, enhancing functionality.
- Introduced a new script, `patch-windows-binaries.mjs`, to set the requested execution level for Windows binaries, improving security and compliance.
2026-08-03 00:59:07 +01:00

58 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 stageWindowsDeeplink(appDir) {
if (!existsSync(entrypoint)) {
throw new Error(`stage-windows-deeplink: entrypoint not found: ${entrypoint}`)
}
const outputPath = path.join(appDir, 'bin', 'deeplink.exe')
mkdirSync(path.dirname(outputPath), { recursive: true })
const result = spawnSync(
'bun',
[
'build',
'--compile',
'--minify',
'--target=bun-windows-x64',
entrypoint,
'--outfile',
outputPath
],
{
cwd: rootDir,
stdio: 'inherit',
env: process.env
}
)
if (result.status !== 0) {
throw new Error(
`stage-windows-deeplink: bun build failed with exit code ${result.status ?? 1}`
)
}
if (!existsSync(outputPath)) {
throw new Error(`stage-windows-deeplink: output not created: ${outputPath}`)
}
console.log(`stage-windows-deeplink: created ${outputPath}`)
return outputPath
}
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const appDirArg = process.argv[2]
if (!appDirArg) {
console.error('Usage: bun scripts/build-windows-deeplink.mjs <app-dir>')
process.exit(1)
}
stageWindowsDeeplink(path.resolve(appDirArg))
}