40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* CI: generated ctx client helper must list the current ctx API semver (same as bare-os-ctx.d.ts).
|
|
*/
|
|
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
import process from 'node:process'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
|
|
function main() {
|
|
const apiPath = path.join(
|
|
root,
|
|
'packages/bare-os-booter/lib/ctx/bare-os-ctx-api.js'
|
|
)
|
|
const helperPath = path.join(
|
|
root,
|
|
'docs/reference/ctx-client-helper.generated.ts'
|
|
)
|
|
const apiSrc = fs.readFileSync(apiPath, 'utf8')
|
|
const m = apiSrc.match(/export const BARE_OS_CTX_API_VERSION = '([^']+)'/)
|
|
if (!m) {
|
|
console.error('verify-ctx-client-helper-sync: could not parse ctx API version')
|
|
process.exit(1)
|
|
}
|
|
const ver = m[1]
|
|
const helper = fs.readFileSync(helperPath, 'utf8')
|
|
if (!helper.includes(ver)) {
|
|
console.error(
|
|
'verify-ctx-client-helper-sync: run `node scripts/gen-ctx-client-helper.mjs` — helper missing',
|
|
ver
|
|
)
|
|
process.exit(1)
|
|
}
|
|
console.log('verify-ctx-client-helper-sync:', ver, 'OK')
|
|
}
|
|
|
|
main()
|