Splits seed bootstrap (ports/roles/profile) into a shared module so
two seed entry points can share it:
- pnpm db:seed realistic NocoDB-shaped fixture (existing)
- pnpm db:seed:synthetic 12 clients, one per pipeline stage + archive
variants (rich metadata for restore wizard)
scripts/db-reset.ts truncates all data tables (preserves migrations);
guarded by --confirm and a localhost host check. Companion npm scripts:
- pnpm db:reset
- pnpm db:reseed:realistic
- pnpm db:reseed:synthetic
scripts/dev-open-browser.ts launches a headed Chromium with no viewport
override (uses the host monitor's natural size), pre-fills the login
form for the requested role.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
/**
|
|
* Synthetic seed (the "every pipeline stage" fixture).
|
|
*
|
|
* Bootstraps the same ports/roles/profile as `seed.ts` then loads
|
|
* `seedSyntheticPortData()` per port — 12 clients, one per pipeline
|
|
* stage plus archive variants, designed for thoroughly testing the
|
|
* CRM end-to-end.
|
|
*
|
|
* Use the realistic seed (`pnpm db:seed`) for shapes that mirror the
|
|
* production NocoDB clone.
|
|
*
|
|
* Run with: pnpm db:seed:synthetic
|
|
*/
|
|
|
|
import 'dotenv/config';
|
|
import { seedBootstrap } from './seed-bootstrap';
|
|
import { seedSyntheticPortData, type SyntheticSeedSummary } from './seed-synthetic-data';
|
|
|
|
async function seed() {
|
|
console.log('Seeding Port Nimara CRM (synthetic test fixture)...');
|
|
|
|
const portIds = await seedBootstrap();
|
|
|
|
console.log('');
|
|
console.log('Seeding per-port synthetic fixtures...');
|
|
|
|
const summaries: Array<{ name: string; summary: SyntheticSeedSummary | null }> = [];
|
|
for (const p of portIds) {
|
|
console.log(` [${p.slug}] seeding synthetic data...`);
|
|
const summary = await seedSyntheticPortData(p.id, p.slug);
|
|
summaries.push({ name: p.name, summary });
|
|
}
|
|
|
|
console.log('');
|
|
console.log('─── Summary ───────────────────────────────────────────────');
|
|
for (const s of summaries) {
|
|
if (s.summary === null) {
|
|
console.log(` ✓ Port "${s.name}" - already seeded (skipped)`);
|
|
} else {
|
|
const x = s.summary;
|
|
console.log(
|
|
` ✓ Port "${s.name}" - ${x.berths} berths, ${x.clients} clients, ${x.companies} companies, ${x.yachts} yachts, ${x.interests} interests, ${x.residentialClients} residential clients`,
|
|
);
|
|
}
|
|
}
|
|
console.log('');
|
|
console.log('Synthetic seed complete!');
|
|
|
|
process.exit(0);
|
|
}
|
|
|
|
seed().catch((err) => {
|
|
console.error('Synthetic seed failed:', err);
|
|
process.exit(1);
|
|
});
|