Search / scripts /data /prepare_test_data.mjs
vomebook
Materialize Space search data from a verified immutable bucket generation
fc4c1a6
Raw History Blame Contribute Delete
805 Bytes
import {resolve} from "node:path";
import {pathToFileURL} from "node:url";
import {ensureSearchGeneration} from "./fetch_search_generation.mjs";
export const DEFAULT_GENERATION = "5c80388b465f35f74711c17aef9e31f8bb1c04fc0553e9820ac271658d740639";
export async function prepareTestData(target = "data") {
// An explicitly empty or invalid override must fail, not select the default.
const generation = process.env.SEARCH_DATA_GENERATION ?? DEFAULT_GENERATION;
return ensureSearchGeneration(generation, "space", target);
}
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
if (process.argv.length > 3) throw new Error("usage: node scripts/data/prepare_test_data.mjs [OUTPUT_DIR]");
console.log(JSON.stringify(await prepareTestData(process.argv[2])));
}