spine-framework 0.3.81 → 0.3.83
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.
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import type { Command } from 'commander'
|
|
19
|
-
import { existsSync, mkdirSync, writeFileSync, copyFileSync, readdirSync, statSync, cpSync } from 'fs'
|
|
19
|
+
import { existsSync, mkdirSync, writeFileSync, copyFileSync, readdirSync, statSync, cpSync, readFileSync } from 'fs'
|
|
20
20
|
import { resolve, dirname, join } from 'path'
|
|
21
21
|
import { fileURLToPath } from 'url'
|
|
22
22
|
import { execSync } from 'child_process'
|
|
@@ -174,13 +174,14 @@ export function registerInitCommands(program: Command) {
|
|
|
174
174
|
const envTemplate = [
|
|
175
175
|
'# Supabase credentials',
|
|
176
176
|
'# Get these from: Supabase Dashboard → Your Project → Settings → API',
|
|
177
|
-
'
|
|
177
|
+
'# Replace the values below — do not leave them blank or as placeholders',
|
|
178
|
+
'SUPABASE_URL=',
|
|
178
179
|
'SUPABASE_ANON_KEY=',
|
|
179
180
|
'SUPABASE_SERVICE_ROLE_KEY=',
|
|
180
181
|
'SUPABASE_DB_PASSWORD=',
|
|
181
182
|
'',
|
|
182
|
-
'# Vite (browser-safe)',
|
|
183
|
-
'VITE_SUPABASE_URL=
|
|
183
|
+
'# Vite (browser-safe) — copy from above',
|
|
184
|
+
'VITE_SUPABASE_URL=',
|
|
184
185
|
'VITE_SUPABASE_ANON_KEY=',
|
|
185
186
|
'VITE_DB_SCHEMA=public',
|
|
186
187
|
'VITE_APP_NAME=Spine',
|
|
@@ -211,7 +212,14 @@ export function registerInitCommands(program: Command) {
|
|
|
211
212
|
console.log(' ✓ .gitignore written')
|
|
212
213
|
}
|
|
213
214
|
|
|
214
|
-
|
|
215
|
+
// Read installed package version from the package's own package.json
|
|
216
|
+
let pkgVersion = 'unknown'
|
|
217
|
+
try {
|
|
218
|
+
const pkgJson = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8'))
|
|
219
|
+
pkgVersion = pkgJson.version ?? 'unknown'
|
|
220
|
+
} catch { /* non-fatal */ }
|
|
221
|
+
|
|
222
|
+
console.log(`\n✅ Project initialized! (spine-framework@${pkgVersion})\n`)
|
|
215
223
|
console.log('Next steps:')
|
|
216
224
|
console.log(' 1. Edit .env with your Supabase credentials')
|
|
217
225
|
console.log(' 2. Run: npx spine-framework migrate')
|
|
@@ -20,9 +20,21 @@ import WebSocket from 'ws'
|
|
|
20
20
|
// ─── ENVIRONMENT RESOLUTION ──────────────────────────────────────────────────
|
|
21
21
|
|
|
22
22
|
const _env = (globalThis as any).process?.env || {}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
|
|
24
|
+
// Use a known-valid placeholder URL so that createClient() doesn't throw at
|
|
25
|
+
// module load time when env vars haven't been set yet (e.g. during CLI init).
|
|
26
|
+
// All real requests validate credentials before hitting the DB.
|
|
27
|
+
const PLACEHOLDER_URL = 'https://placeholder.supabase.co'
|
|
28
|
+
const PLACEHOLDER_KEY = 'placeholder'
|
|
29
|
+
|
|
30
|
+
function isValidUrl(url: string): boolean {
|
|
31
|
+
try { new URL(url); return true } catch { return false }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const rawUrl = _env.SUPABASE_URL || ''
|
|
35
|
+
const supabaseUrl: string = rawUrl && isValidUrl(rawUrl) ? rawUrl : PLACEHOLDER_URL
|
|
36
|
+
const supabaseServiceKey: string = _env.SUPABASE_SERVICE_ROLE_KEY || PLACEHOLDER_KEY
|
|
37
|
+
const supabaseAnonKey: string = _env.SUPABASE_ANON_KEY || PLACEHOLDER_KEY
|
|
26
38
|
const dbSchema: string = _env.DB_SCHEMA || 'public'
|
|
27
39
|
|
|
28
40
|
// ─── CLIENTS ─────────────────────────────────────────────────────────────────
|