-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
87 lines (75 loc) · 3.13 KB
/
Copy pathsetup.ps1
File metadata and controls
87 lines (75 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Sonlum self-hosting setup script (Windows PowerShell)
# Usage: .\setup.ps1
$ErrorActionPreference = 'Stop'
Write-Host ""
Write-Host "✦ Sonlum Setup" -ForegroundColor White
Write-Host "──────────────────────────────────────────"
Write-Host "This will create your .env file."
Write-Host ""
function Prompt-Value {
param([string]$Label, [string]$Default = "", [switch]$Secret)
if ($Default) {
Write-Host "$Label (default: $Default):" -ForegroundColor Cyan
} else {
Write-Host "${Label}:" -ForegroundColor Cyan
}
if ($Secret) {
$value = Read-Host -AsSecureString | ForEach-Object { [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($_)) }
} else {
$value = Read-Host
}
if (-not $value -and $Default) { $value = $Default }
return $value
}
Write-Host "Supabase" -ForegroundColor White
Write-Host "Create a free project at https://supabase.com → Project Settings → API"
Write-Host ""
$SupabaseUrl = Prompt-Value "Project URL (e.g. https://xyz.supabase.co)"
$AnonKey = Prompt-Value "Anon (public) key"
$ServiceKey = Prompt-Value "Service role key (secret)" -Secret
Write-Host ""
Write-Host "AI (DeepSeek)" -ForegroundColor White
Write-Host "Get a key at https://platform.deepseek.com/api_keys"
Write-Host ""
$DeepSeekKey = Prompt-Value "DeepSeek API key (secret)" -Secret
Write-Host ""
Write-Host "Encryption" -ForegroundColor White
$bytes = New-Object byte[] 32
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($bytes)
$EncSecret = [BitConverter]::ToString($bytes).Replace('-','').ToLower()
Write-Host "A random encryption secret was generated for you."
Write-Host ""
Write-Host "Writing .env ..."
$envContent = @"
VITE_SUPABASE_URL=$SupabaseUrl
VITE_SUPABASE_ANON_KEY=$AnonKey
VITE_DEEPSEEK_API_KEY=$DeepSeekKey
SUPABASE_URL=$SupabaseUrl
SUPABASE_SERVICE_ROLE_KEY=$ServiceKey
ENCRYPTION_SECRET=$EncSecret
"@
$envContent | Out-File -FilePath ".env" -Encoding utf8
$envContent | Out-File -FilePath ".env.vercel" -Encoding utf8
Write-Host "✓ .env and .env.vercel created" -ForegroundColor Green
Write-Host ""
Write-Host "Database" -ForegroundColor White
Write-Host "Apply the schema to your Supabase project:"
Write-Host ""
Write-Host " 1. Go to https://supabase.com/dashboard → SQL Editor" -ForegroundColor Cyan
Write-Host " 2. Paste the contents of supabase/schema.sql"
Write-Host " 3. Click Run"
Write-Host ""
Write-Host "Next steps" -ForegroundColor White
Write-Host ""
Write-Host " Run locally:"
Write-Host " pnpm install (or npm install)" -ForegroundColor Cyan
Write-Host " vercel dev (runs app + API routes)" -ForegroundColor Cyan
Write-Host ""
Write-Host " Deploy to Vercel (free):"
Write-Host " vercel" -ForegroundColor Cyan
Write-Host " Then add your env vars in the Vercel dashboard."
Write-Host ""
Write-Host "⚠ Keep your service role key and encryption secret safe." -ForegroundColor Yellow
Write-Host " Losing the encryption secret means existing data cannot be read." -ForegroundColor Yellow
Write-Host ""
Write-Host "Setup complete!" -ForegroundColor Green