← Files DataARCHIVED FILE
templates/data-app/examples/business-performance/fixtures/generate.mjs
782 Bytes · Oct 5, 2026 · 12:04 UTC
import { writeFileSync } from "node:fs";
import { pathToFileURL } from "node:url";
import { isAbsolute } from "node:path";
import { parseArgs } from "node:util";
import { fixture } from "./fixture.js";
export { fixture, products } from "./fixture.js";
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const { values } = parseArgs({ options: { output: { type: "string" } } });
if (!values.output || !isAbsolute(values.output)) throw new Error("Use --output /absolute/fixture.json; generated data is not stored in the plugin.");
const data = fixture();
const json = JSON.stringify(data, null, 2).replace(/\{\n\s+"(?:date|contractId)": [\s\S]*?\n\s+\}/g, row => JSON.stringify(JSON.parse(row)));
writeFileSync(values.output, json + "\n");
}
SHA-256: 442e3a61c3cf026de3b0e735255116bdcf359babfd8ffef7ac070b80cc8bee7f