#!/usr/bin/env bun import { join } from "node:path"; import { syncPreviewDb } from "../datasources/preview-db"; import { getEnvConfig } from "../utils/env-config"; // Apply the committed `.migrations/` (schema) then seed the local preview D1. // Run at dev-server startup (dev.sh) and by the pre-commit hook after migration // generation. Seeds from static fixtures; the DatasourcePoller backfills real // API items at runtime. async function main() { let { WORKSPACE, WORKSPACE_TMP } = getEnvConfig(); if (!WORKSPACE) { WORKSPACE = process.cwd(); } if (!WORKSPACE_TMP) { WORKSPACE_TMP = join(WORKSPACE, ".tmp"); } return syncPreviewDb(WORKSPACE, WORKSPACE_TMP); } main() .then(() => { process.exit(0); }) .catch((e) => { console.error(e instanceof Error ? e.message : e); process.exit(1); });