45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
/**
|
|
* Host capability profile hints for boot policy / initd (BARE_OS_HOST_PROFILE).
|
|
*/
|
|
|
|
const VALID = new Set(['desktop', 'mobile', 'embedded', 'server', 'iot', 'unknown'])
|
|
|
|
/**
|
|
* @param {Record<string, unknown> | null | undefined} env
|
|
*/
|
|
export function bareOsReadHostProfile(env) {
|
|
const raw = String(env?.BARE_OS_HOST_PROFILE || '').trim().toLowerCase()
|
|
const profile = VALID.has(raw) ? raw : 'unknown'
|
|
const flags = String(env?.BARE_OS_HOST_FEATURE_FLAGS || '')
|
|
.split(/[\s,]+/)
|
|
.map((s) => s.trim())
|
|
.filter(Boolean)
|
|
.slice(0, 64)
|
|
return {
|
|
schema: 2,
|
|
profile,
|
|
featureFlags: flags,
|
|
bridgeHints: {
|
|
hrpcBridge:
|
|
env?.BARE_OS_HRPC_BRIDGE_WIRED === '1' ||
|
|
env?.BARE_OS_HRPC_BRIDGE_WIRED === 'true',
|
|
sidecarBridge:
|
|
env?.BARE_OS_SIDECAR_BRIDGE_WIRED === '1' ||
|
|
env?.BARE_OS_SIDECAR_BRIDGE_WIRED === 'true',
|
|
bundlebeeCli:
|
|
env?.BARE_OS_BUNDLEBEE_CLI_WIRED === '1' ||
|
|
env?.BARE_OS_BUNDLEBEE_CLI_WIRED === 'true',
|
|
hrpcAllowlistJson: Boolean(
|
|
String(env?.BARE_OS_HRPC_ALLOWLIST_JSON || '').trim()
|
|
),
|
|
pearRuntimeMatrixJson: Boolean(
|
|
String(env?.BARE_OS_PEAR_RUNTIME_MATRIX_JSON || '').trim()
|
|
),
|
|
bundlebeeStageJson: Boolean(
|
|
String(env?.BARE_OS_BUNDLEBEE_STAGE_JSON || '').trim()
|
|
)
|
|
},
|
|
atMs: Date.now()
|
|
}
|
|
}
|