spine-framework 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/spine-framework.cjs +18 -1
- package/package.json +1 -1
package/bin/spine-framework.cjs
CHANGED
|
@@ -14,10 +14,27 @@ if (process.argv.length === 2) {
|
|
|
14
14
|
process.exit(0)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// Pre-parse credential flags so db.ts sees
|
|
17
|
+
// Pre-parse credential flags and load .env so db.ts sees env vars at module load time.
|
|
18
18
|
// tsx evaluates db.ts before Commander parses args, so we must inject here.
|
|
19
19
|
const args = process.argv.slice(2)
|
|
20
20
|
const childEnv = { ...process.env }
|
|
21
|
+
|
|
22
|
+
// Load .env from the consumer project root (process.cwd())
|
|
23
|
+
const dotenvPath = resolve(process.cwd(), '.env')
|
|
24
|
+
if (fs.existsSync(dotenvPath)) {
|
|
25
|
+
const lines = fs.readFileSync(dotenvPath, 'utf8').split('\n')
|
|
26
|
+
for (const line of lines) {
|
|
27
|
+
const trimmed = line.trim()
|
|
28
|
+
if (!trimmed || trimmed.startsWith('#')) continue
|
|
29
|
+
const eq = trimmed.indexOf('=')
|
|
30
|
+
if (eq === -1) continue
|
|
31
|
+
const key = trimmed.slice(0, eq).trim()
|
|
32
|
+
const val = trimmed.slice(eq + 1).trim()
|
|
33
|
+
if (key && !(key in childEnv)) childEnv[key] = val
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// CLI flags override .env values
|
|
21
38
|
for (let i = 0; i < args.length; i++) {
|
|
22
39
|
if (args[i] === '--url' && args[i + 1]) childEnv.SUPABASE_URL = args[++i]
|
|
23
40
|
if (args[i] === '--anon-key' && args[i + 1]) childEnv.SUPABASE_ANON_KEY = args[++i]
|