/**
 * `pnpm db:demo` — the command-line face of the demo book.
 *
 * The dataset itself lives in `demo/`, one module per slice of the book; start
 * at `demo/index.ts`, which carries the note on what is invented and why.
 *
 * This file stays a file rather than becoming `demo/index.ts` outright because
 * the path is public: `packages/db/package.json` runs `tsx src/seed/demo.ts`,
 * the README and `deploy/README.md` document `pnpm db:demo -- --clear`, and
 * anything importing `seed/demo` expects the same exports it has always had.
 * Splitting the implementation is not a reason to break either.
 */
import { clear, clearHostedLearn, demoContext, seedDemo, seedHostedLearn } from './demo/index';

export { HOSTED_LEARN_MANIFEST, seedHostedLearn } from './demo/index';

const argv = process.argv.slice(2);
const run = argv.includes('--clear')
  ? clear
  : argv.includes('--clear-hosted')
    ? clearHostedLearn
    // Insert only the self-hosted rows: the command to run after generating a
    // video, when reseeding the whole demo book would be beside the point.
    : argv.includes('--hosted')
      ? seedHostedLearn
      : seedDemo;

run(demoContext)
  .then(() => process.exit(0))
  .catch((error) => {
    console.error('Demo seed failed:', error);
    process.exit(1);
  });
