Files
SGF/scripts/ledger-reports-run.mjs
2026-11-04 09:37:20 +02:00

7 lines
1.4 KiB
JavaScript

import fs from 'node:fs';import path from 'node:path';import {spawnSync} from 'node:child_process';
const native=process.argv[2]==='native';if(!['sgf','native'].includes(process.argv[2]))throw Error('Select sgf or native; always provisions a NEW dedicated report database');
const node=process.execPath,php='C:/laragon/tools/sgf-tempo/php-8.4.27/php.exe',run=(exe,args)=>{const r=spawnSync(exe,args,{encoding:'utf8',windowsHide:true,maxBuffer:1024*1024});if(r.status!==0)throw Error('Directed report phase failed; inspect its private diagnostics.');return r.stdout;};
const setup=run(node,[native?'scripts/ledger-cycle-native-run.mjs':'scripts/ledger-run.mjs','new']),owned=JSON.parse(setup.trim().split(/\r?\n/).at(-1));if(!/^[a-f0-9]{12}$/.test(owned.tag))throw Error('Owned fixture result missing');
for(const phase of ['seed','cases','isolation']){run(php,['scripts/payable-history-sgf-proof.php',path.join(owned.root,'settings.json'),(native?'native-cycle':'ledger')+'-reports-'+phase]);const proof=JSON.parse(fs.readFileSync(path.join(owned.root,'ledger-reports-'+phase+'.json'),'utf8'));if(!proof.passed)throw Error('Expected successful directed artifact missing');}
process.stdout.write(run(node,['scripts/ledger-reports-http.mjs',owned.tag,...(native?['native']:[])]));console.log(JSON.stringify({tag:owned.tag,root:owned.root,host:native?'SGC':'SGF',new_database_only:true,existing_proofs_and_demos_not_reset:true}));