Files
orca/config/scripts/orcad-mobile-web-bundle.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

30 lines
1.2 KiB
JavaScript

import { cpSync, readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { join } from 'node:path'
import {
ORCAD_MOBILE_WEB_DIR,
ORCAD_MOBILE_WEB_MANIFEST,
orcadMobileWebAssetFilenames
} from '../../src/shared/orcad-artifacts.ts'
const { MOBILE_WEB_BUNDLE_DIR, assertMobileWebBundleBuilt } = createRequire(import.meta.url)(
'./verify-packaged-mobile-web-bundle.cjs'
)
/**
* The built page (pnpm build:mobile-web) into an orcad package. Fatal when it is missing or stale,
* as electron-builder's beforePack is: a server without it serves phones no page.
*/
export function stageOrcadMobileWebBundle(outputDir, bundleDir = MOBILE_WEB_BUNDLE_DIR) {
assertMobileWebBundleBuilt(bundleDir)
// The guard refuses unlisted files, so the tree is exactly the manifest and its assets.
cpSync(bundleDir, join(outputDir, ...ORCAD_MOBILE_WEB_DIR.split('/')), { recursive: true })
}
/** The asset half of a package's artifact list, read from the page it carries. */
export function readOrcadMobileWebAssetFilenames(packageDir) {
return orcadMobileWebAssetFilenames(
readFileSync(join(packageDir, ...ORCAD_MOBILE_WEB_MANIFEST.split('/')), 'utf8')
)
}