Files
orca/config/scripts/orcad-artifact-version.mjs
T
Jinwoo Hong 776c791554 feat(orcad): ship the mobile web page so phones paired to orcad get it (#29882)
* feat(orcad): ship the mobile web page so phones paired to orcad get it

orcad never carried out/mobile-web, so it did not advertise
mobileWeb.bundle.v1 and phones paired directly to an orcad server fell
back to the app's built-in native screens.

The built page now ships in every orcad package at out/mobile-web, the
path getBundledMobileWebBundleRoot already probes under the install
root. Its manifest is a fixed artifact; its content-addressed assets
join the hashed artifact list from that manifest, as one shared copy in
the template's common files. build-orcad fails when the page is missing
or stale, and CI lanes that build orcad now build the page first.

* ci(orcad): check out mobile/ for the Windows host template build

* refactor(orcad): copy the page tree whole and build it once per CI run

The guard already refuses unlisted files, so staging copies the
bundle directory as native-chat-visuals is copied. The shipped template
takes the page the qualification lanes tested, the e2e build artifact
carries it, and the PR smoke builds it through install-mobile-dependencies
behind its own scope step. Drops tests that duplicated the guard's own.

* fix(orcad): refuse a template page asset name that escapes the slot
2026-10-16 19:29:41 -07:00

28 lines
1.2 KiB
JavaScript

import { createHash } from 'node:crypto'
import { existsSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { ORCAD_VERSION, orcadArtifactFilenames } from '../../src/shared/orcad-artifacts.ts'
import { readOrcadMobileWebAssetFilenames } from './orcad-mobile-web-bundle.mjs'
/** The runtime enters through `.runtime-node`'s executableSha256 string, never its bytes (design D2). */
export function computeOrcadFullVersion(artifactDir, { target, agentBrowserFilename }) {
const hash = createHash('sha256')
for (const filename of orcadArtifactFilenames(
target,
readOrcadMobileWebAssetFilenames(artifactDir)
)) {
const artifactPath = join(artifactDir, filename)
if (!existsSync(artifactPath)) {
throw new Error(
`orcad declares ${filename} in ORCAD_ARTIFACTS but never emitted it. Add the build ` +
'step, or drop it from src/shared/orcad-artifacts.ts.'
)
}
hash.update(readFileSync(artifactPath))
}
if (agentBrowserFilename && existsSync(join(artifactDir, agentBrowserFilename))) {
hash.update(readFileSync(join(artifactDir, agentBrowserFilename)))
}
return `${ORCAD_VERSION}+${hash.digest('hex').slice(0, 12)}`
}