mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
* feat(windows): add administrator PowerShell terminal setting * fix(settings): localize administrator terminal search keywords * fix(windows): restrict elevated terminal host to Orca's runtime and requesting account * fix(windows): harden administrator terminal routing, inventory and restore * fix(build): build the Windows agent hook when electron-builder packages Windows * fix(build): build the packaged Windows agent hook for the target architecture * fix(windows): accept the development terminal runtime and test real elevation in CI * feat(windows): show administrator status and restart instructions * fix(settings): localize administrator mode search keywords * test(settings): isolate the desktop permission section in shell picker tests * Add Windows administrator restart and simplify Terminal settings * Keep administrator restart silent and settings actions within narrow panes * Keep Windows shell choices and permission guides usable at minimum width * Prevent later restarts from replaying administrator terminal reset * Fix CI route resolution and transient Windows fixture cleanup
72 lines
2.3 KiB
JavaScript
72 lines
2.3 KiB
JavaScript
const { execFileSync } = require('node:child_process')
|
|
const { resolve } = require('node:path')
|
|
|
|
const projectDir = resolve(__dirname, '../..')
|
|
|
|
function electronBuilderNativeRebuild(context) {
|
|
return runElectronBuilderNativeRebuild(context)
|
|
}
|
|
|
|
function runElectronBuilderNativeRebuild(context, runner = execFileSync, runtime = {}) {
|
|
const args = buildNativeRebuildArgs(context, runtime)
|
|
if (readPlatformName(context?.platform) === 'win32') {
|
|
runner(process.execPath, ['config/scripts/build-windows-cli-launcher.mjs'], {
|
|
cwd: projectDir,
|
|
stdio: 'inherit'
|
|
})
|
|
// Packaging rejects a hook built for another machine, so build the one this package targets.
|
|
runner(
|
|
process.execPath,
|
|
['config/scripts/build-windows-agent-hook.mjs', '--arch', readArchName(context?.arch)],
|
|
{ cwd: projectDir, stdio: 'inherit' }
|
|
)
|
|
}
|
|
runner(process.execPath, args, {
|
|
cwd: projectDir,
|
|
stdio: 'inherit'
|
|
})
|
|
|
|
// Why: returning false tells electron-builder that native deps were handled
|
|
// externally, avoiding its all-module rebuild of optional cpu-features.
|
|
return false
|
|
}
|
|
|
|
function buildNativeRebuildArgs(
|
|
context,
|
|
{ environment = process.env, hostPlatform = process.platform, hostArch = process.arch } = {}
|
|
) {
|
|
const platform = readPlatformName(context?.platform)
|
|
const arch = readArchName(context?.arch)
|
|
const canReusePreparedRuntime =
|
|
environment.ORCA_REUSE_PREPARED_NATIVE_RUNTIME === '1' &&
|
|
platform === hostPlatform &&
|
|
arch === hostArch
|
|
|
|
return [
|
|
'config/scripts/rebuild-native-deps.mjs',
|
|
`--platform=${platform}`,
|
|
`--arch=${arch}`,
|
|
...(canReusePreparedRuntime ? [] : ['--force'])
|
|
]
|
|
}
|
|
|
|
function readPlatformName(platform) {
|
|
const name = typeof platform === 'string' ? platform : platform?.nodeName
|
|
if (!name) {
|
|
throw new Error('electron-builder native rebuild context is missing platform.nodeName')
|
|
}
|
|
return name
|
|
}
|
|
|
|
function readArchName(arch) {
|
|
if (!arch || typeof arch !== 'string') {
|
|
throw new Error('electron-builder native rebuild context is missing arch')
|
|
}
|
|
return arch
|
|
}
|
|
|
|
module.exports = electronBuilderNativeRebuild
|
|
module.exports.default = electronBuilderNativeRebuild
|
|
module.exports.buildNativeRebuildArgs = buildNativeRebuildArgs
|
|
module.exports.runElectronBuilderNativeRebuild = runElectronBuilderNativeRebuild
|