35 lines
2.6 KiB
JavaScript
35 lines
2.6 KiB
JavaScript
import fs from 'node:fs';
|
|
import assert from 'node:assert/strict';
|
|
import { spawn } from 'node:child_process';
|
|
import { createHash } from 'node:crypto';
|
|
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
|
const prefix = '.qa/embedded-browser-d-', completed = [];
|
|
const read = file => JSON.parse(fs.readFileSync(file));
|
|
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
async function run(name, script) {
|
|
const file = prefix + name + '-finalization.log';
|
|
const stream = fs.createWriteStream(file, { flags: 'wx' });
|
|
const child = spawn(process.execPath, [script], { windowsHide: true, env: projectEnvironment(), stdio: ['ignore','pipe','pipe'] });
|
|
let tail = ''; const capture = bytes => { stream.write(bytes); tail = (tail + bytes.toString('utf8')).slice(-9000); };
|
|
child.stdout.on('data', capture); child.stderr.on('data', capture);
|
|
const exitCode = await new Promise((resolve, reject) => { child.once('error', reject); child.once('close', resolve); });
|
|
await new Promise(resolve => stream.end(resolve));
|
|
const row = { name, script, exitCode, log: file, logSha256: hash(fs.readFileSync(file)), finishedAt: new Date().toISOString() };
|
|
completed.push(row); console.log(JSON.stringify(row));
|
|
assert.equal(exitCode, 0, 'Keep original phase; do not replay: ' + tail);
|
|
}
|
|
let result;
|
|
try {
|
|
console.log('Awaiting complete D independent verification and formal promotion. No Git action will be taken.');
|
|
while (!fs.existsSync(prefix + 'promotion-result.json')) await new Promise(resolve => setTimeout(resolve, 3000));
|
|
assert.equal(read(prefix + 'promotion-result.json').success, true);
|
|
assert.equal(read(prefix + 'independent-continuation-result.json').success, true);
|
|
await run('ui-preflight', prefix + 'ui-evidence-preflight.mjs');
|
|
await run('review-timings', prefix + 'review-timings.mjs');
|
|
await run('seal', '.qa/seal-embedded-browser-d-release.mjs');
|
|
await run('finalize-docs', prefix + 'finalize-docs.mjs');
|
|
result = { success: true, completed, finishedAt: new Date().toISOString(), requiresLocalGitDiffReviewAndCommit: true, scope: 'Seals original final evidence and updates milestone documents only after all required D verification and formal stages pass. B UI and C core tests retain their original identities and require strict input binding. No Git staging, commit, or remote push.' };
|
|
} catch (error) { result = { success: false, completed, error: error.stack, finishedAt: new Date().toISOString() }; process.exitCode = 1; }
|
|
fs.writeFileSync(prefix + 'finalization-result.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
|
console.log(JSON.stringify(result));
|