Files
orca/config/scripts/orcad-distribution/template/packaged-orcad-browser.cjs
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

59 lines
2.3 KiB
JavaScript

const { createHash } = require('node:crypto')
const { existsSync, readFileSync, writeFileSync } = require('node:fs')
const { join } = require('node:path')
const { ORCAD_TEMPLATE_MANIFEST_FILENAME } = require('../../../../src/shared/orcad-artifacts.ts')
const {
orcadAgentBrowserNativeName
} = require('../../../../src/shared/orcad-agent-browser-name.ts')
const { verifyPackagedOrcadTemplate } = require('./verify-packaged-orcad-template.cjs')
function sha256(path) {
return createHash('sha256').update(readFileSync(path)).digest('hex')
}
function targetBrowserName(target) {
const [platform, arch] = target.split('-')
return orcadAgentBrowserNativeName(platform, arch, target.endsWith('-musl') ? 'musl' : 'glibc')
}
function manifestPath(resourcesDir) {
return join(resourcesDir, 'orcad-template', ORCAD_TEMPLATE_MANIFEST_FILENAME)
}
/** The template omits drivers for size; point a target at the app's own copy so its slot still gets one (#33846). */
function referencePackagedOrcadBrowser(resourcesDir) {
const path = manifestPath(resourcesDir)
const manifest = JSON.parse(readFileSync(path, 'utf8'))
const referenced = []
for (const [target, entry] of Object.entries(manifest.targets)) {
const browserName = targetBrowserName(target)
if (entry.browserName || !existsSync(join(resourcesDir, browserName))) {
continue
}
entry.browserName = browserName
entry.browserSha256 = sha256(join(resourcesDir, browserName))
entry.packagedBrowser = true
referenced.push(target)
}
if (referenced.length > 0) {
writeFileSync(path, `${JSON.stringify(manifest, null, 2)}\n`)
}
verifyPackagedOrcadTemplate(resourcesDir)
return referenced
}
/** Reseal referenced drivers the Windows signer rewrote; `signedResourcePaths` are resources-relative. */
function resealSignedPackagedBrowser(resourcesDir, signedResourcePaths) {
const path = manifestPath(resourcesDir)
const manifest = JSON.parse(readFileSync(path, 'utf8'))
const signed = new Set(signedResourcePaths)
for (const entry of Object.values(manifest.targets)) {
if (entry.packagedBrowser && signed.has(entry.browserName)) {
entry.browserSha256 = sha256(join(resourcesDir, entry.browserName))
}
}
writeFileSync(path, `${JSON.stringify(manifest, null, 2)}\n`)
}
module.exports = { referencePackagedOrcadBrowser, resealSignedPackagedBrowser }