docs: enterprise refactor plan with ralph specs
This commit is contained in:
84
dist/replay.js
vendored
Normal file
84
dist/replay.js
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
/**
|
||||
* ABE Replay Script Runner
|
||||
* Loads a report.json and executes the generated Playwright replay script.
|
||||
*
|
||||
* Usage:
|
||||
* npm run replay -- --report reports/anom_xyz/report.json
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const PlaywrightReproducer_1 = require("./plugins/reproducers/PlaywrightReproducer");
|
||||
function parseArgs() {
|
||||
const args = process.argv.slice(2);
|
||||
let reportPath = '';
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (args[i] === '--report' && args[i + 1])
|
||||
reportPath = args[++i];
|
||||
}
|
||||
if (!reportPath) {
|
||||
console.error('Usage: npm run replay -- --report <path-to-report.json>');
|
||||
process.exit(1);
|
||||
}
|
||||
return { reportPath };
|
||||
}
|
||||
async function main() {
|
||||
const { reportPath } = parseArgs();
|
||||
if (!fs.existsSync(reportPath)) {
|
||||
console.error(`Report not found: ${reportPath}`);
|
||||
process.exit(1);
|
||||
}
|
||||
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
|
||||
// Reconstruct action trace from report steps
|
||||
const trace = report.reproduction.steps.map((step) => ({
|
||||
id: `replay_step_${step.step}`,
|
||||
type: step.action_type,
|
||||
selector: step.selector,
|
||||
value: step.value,
|
||||
url: step.url,
|
||||
timestamp: step.timestamp,
|
||||
seed: report.reproduction.seed ?? 42,
|
||||
stateId: 'replay',
|
||||
}));
|
||||
const reproducer = new PlaywrightReproducer_1.PlaywrightReproducer();
|
||||
const script = reproducer.generateScript(trace);
|
||||
const scriptPath = path.join(path.dirname(reportPath), 'replay.js');
|
||||
fs.writeFileSync(scriptPath, script, 'utf8');
|
||||
console.log(`[ABE Replay] Script written to: ${scriptPath}`);
|
||||
console.log(`[ABE Replay] Run with: node ${scriptPath}`);
|
||||
}
|
||||
main();
|
||||
Reference in New Issue
Block a user