48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { spawnSync } from 'node:child_process';
|
|
|
|
const root = process.cwd();
|
|
const outputDir = path.join(root, 'artifacts');
|
|
const outputFile = path.join(outputDir, 'ux-platform-gates.log');
|
|
const node = process.execPath;
|
|
const gates = [
|
|
['Navigation API', 'tools/verify-navigation-api-1.44.0.mjs'],
|
|
['Safe Action Adapters', 'tools/verify-safe-action-adapters-1.44.0.mjs'],
|
|
];
|
|
|
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
const lines = [
|
|
'Vendoo UX Platform Gates',
|
|
`Platform: ${process.platform}`,
|
|
`Node: ${process.version}`,
|
|
`Working directory: ${root}`,
|
|
'',
|
|
];
|
|
let failed = false;
|
|
|
|
for (const [name, relativeScript] of gates) {
|
|
const script = path.join(root, relativeScript);
|
|
lines.push(`=== ${name} ===`);
|
|
const result = spawnSync(node, [script], {
|
|
cwd: root,
|
|
encoding: 'utf8',
|
|
env: process.env,
|
|
windowsHide: true,
|
|
});
|
|
if (result.stdout) lines.push(result.stdout.trimEnd());
|
|
if (result.stderr) lines.push(result.stderr.trimEnd());
|
|
const exitCode = Number.isInteger(result.status) ? result.status : 1;
|
|
lines.push(`Exit code: ${exitCode}`, '');
|
|
if (exitCode !== 0 || result.error) {
|
|
failed = true;
|
|
if (result.error) lines.push(`Runner error: ${result.error.message}`, '');
|
|
}
|
|
}
|
|
|
|
lines.push(failed ? 'RESULT: FAILED' : 'RESULT: PASSED');
|
|
const report = `${lines.join('\n')}\n`;
|
|
fs.writeFileSync(outputFile, report, 'utf8');
|
|
process.stdout.write(report);
|
|
process.exitCode = failed ? 1 : 0;
|