Lines 60-100typescript
60 const value = trimmed.slice(eq + 1);
61 process.env[key] ??= value;
66 // ── Project guard ─────────────────────────────────────────────────────────
67 if (!fs.existsSync(path.join(cwd, 'package.json'))) {
68 console.error(chalk.red('\n Not in a project directory — package.json not found\n'));
72 const configPath = path.join(cwd, 'src', 'config', 'database.ts');
73 if (!fs.existsSync(configPath)) {
74 console.error(chalk.red('\n src/config/database.ts not found. Run: morphis new:connection\n'));
78 // ── Load database config ──────────────────────────────────────────────────
79 let databases: Record<string, any>;
81 const mod = await import(configPath);
82 databases = mod.default;
MediumDynamic Require
Package source references dynamic require/import behavior.
scripts/commands/migrate.tsView on unpkg · L80 84 console.error(chalk.red(
85 `\n Failed to load src/config/database.ts: ${err instanceof Error ? err.message : String(err)}\n`,
90 if (!databases || typeof databases !== 'object' || Object.keys(databases).length === 0) {
91 console.error(chalk.red('\n src/config/database.ts has no connections configured\n'));
95 // ── Resolve target connection ─────────────────────────────────────────────
96 const entries = Object.entries(databases);
97 const [resolvedConnectionName, config]: [string, any] = connectionName === 'default'
98 ? (entries.find(([, d]) => d.isDefault) ?? entries[0])
99 : [connectionName, databases[connectionName]];