/** * Writes the reporter settings into autotrader.sqlite before first launch. * * lib/db.ts seeds these keys with INSERT OR IGNORE, so values written here * survive the app's own startup seeding. Must be run from the project root — * lib/db.ts opens the database at process.cwd(). * * node scripts/seed-settings.js */ const path = require('path'); const Database = require('better-sqlite3'); const [, , url, name] = process.argv; const db = new Database(path.join(process.cwd(), 'autotrader.sqlite')); db.exec(` CREATE TABLE IF NOT EXISTS settings ( key TEXT PRIMARY KEY, value TEXT NOT NULL ); `); const upsert = db.prepare( 'INSERT INTO settings (key, value) VALUES (?, ?) ' + 'ON CONFLICT(key) DO UPDATE SET value = excluded.value' ); if (url) { upsert.run('master_dashboard_url', url); console.log(' master_dashboard_url = ' + url); } if (name) { upsert.run('instance_name', name); console.log(' instance_name = ' + name); } db.close();