chore: establish YCode replication baseline and TODO
This commit is contained in:
commit
6dc59f89ba
1118 files changed
+196002
No files matched your search
@@ -0,0 +1,21 @@
|
||||
/** Exact public REA export. Does not read ASAR or installed files itself. */
|
||||
import fs from 'node:fs'
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import crypto from 'node:crypto'
|
||||
const inventory = JSON.parse(fs.readFileSync('.tmp/rea-expert-package-inventory.json', 'utf8'))
|
||||
const paths = process.argv.slice(2)
|
||||
if (!paths.length) throw new Error('Select exact paths')
|
||||
const r = spawnSync(process.execPath, ['.tmp/rea-css-runtime/scripts/rea.mjs', 'export-selected-artifact-text',
|
||||
inventory.inputPath, inventory.rootSha256, JSON.stringify(paths)], {encoding:'utf8', maxBuffer:32*1024*1024})
|
||||
if (r.status !== 0) throw new Error(r.stderr || r.stdout || `REA exited ${r.status}`)
|
||||
const evidence = JSON.parse(r.stdout)
|
||||
if (evidence.normalized_result.root_sha256 !== inventory.rootSha256) throw new Error('REA root mismatch')
|
||||
for (const file of evidence.normalized_result.files) {
|
||||
const sha = crypto.createHash('sha256').update(file.text).digest('hex')
|
||||
if (sha !== file.sha256) throw new Error(`Text SHA mismatch: ${file.path}`)
|
||||
const expected = inventory.files.find(item => item.path === file.path)
|
||||
if (expected && expected.sha256 !== sha) throw new Error(`Inventory SHA mismatch: ${file.path}`)
|
||||
}
|
||||
const output = `.tmp/rea-expert-package-${evidence.evidence_id}.json`
|
||||
fs.writeFileSync(output,JSON.stringify(evidence))
|
||||
console.log(JSON.stringify({output,evidenceId:evidence.evidence_id,files:evidence.normalized_result.files.map(({text,...metadata})=>metadata)},null,2))
|
||||
Reference in new issue
Block a user