← Files DataARCHIVED FILE

templates/data-app/base/examples/reports/activation-diagnostics/reproduce.mjs

988 Bytes · Oct 3, 2026 · 06:03 UTC

↓ Download file

import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { analyzeProductGrowth, createReportSnapshot } from "./analysis.mjs";

const content = dirname(fileURLToPath(import.meta.url));
const project = resolve(content, "../../..");
if (content !== join(project, "src/content/report")) {
  throw new Error("Run this reproducer from the generated artifact, or use the example's build.mjs.");
}
const results = analyzeProductGrowth(readFileSync(join(content, "evidence/demo-product-growth.csv"), "utf8"));
mkdirSync(join(content, "evidence"), { recursive: true });
writeFileSync(join(content, "evidence/results.json"), `${JSON.stringify(results, null, 2)}\n`);
writeFileSync(join(project, "src/data.json"), `${JSON.stringify(createReportSnapshot(results), null, 2)}\n`);
console.log(JSON.stringify({ changePp: results.changePp, withinPp: results.withinPp, mixPp: results.mixPp }));

SHA-256: c6fed33542686e8f9a00e470b7f371523dea193e90392dd81bfd727ffdf67c7a