fix: Applied fix for name, the oracle team sharing, sentinel client list visibility
This commit is contained in:
140
scripts/import_velocity_local_bundle.ps1
Normal file
140
scripts/import_velocity_local_bundle.ps1
Normal file
@@ -0,0 +1,140 @@
|
||||
param(
|
||||
[string]$BundleRoot = "",
|
||||
[string]$RepoRoot = "F:\Workin In Progress\DESINEURON\GITLAB\Project_Velocity"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
if (-not $BundleRoot) {
|
||||
$candidate = Join-Path $RepoRoot ".local-dev\source-bundles"
|
||||
if (-not (Test-Path $candidate)) {
|
||||
throw "Bundle root not provided and no source bundles found at $candidate"
|
||||
}
|
||||
|
||||
$latest = Get-ChildItem -Path $candidate -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||
if (-not $latest) {
|
||||
throw "No extracted bundle directories found under $candidate"
|
||||
}
|
||||
$BundleRoot = $latest.FullName
|
||||
}
|
||||
|
||||
$envExport = Join-Path $BundleRoot "backend.env.export"
|
||||
$dumpFile = Join-Path $BundleRoot "velocity.dump"
|
||||
|
||||
if (-not (Test-Path $envExport)) {
|
||||
throw "Missing backend.env.export in $BundleRoot"
|
||||
}
|
||||
|
||||
if (-not (Test-Path $dumpFile)) {
|
||||
throw "Missing velocity.dump in $BundleRoot"
|
||||
}
|
||||
|
||||
$localRoot = Join-Path $RepoRoot ".local-dev"
|
||||
$backendRoot = Join-Path $localRoot "backend"
|
||||
$dbRoot = Join-Path $localRoot "db"
|
||||
$assetsRoot = Join-Path $localRoot "assets"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $localRoot, $backendRoot, $dbRoot, $assetsRoot | Out-Null
|
||||
|
||||
$targetEnv = Join-Path $backendRoot ".env.local"
|
||||
$restoreScript = Join-Path $dbRoot "restore_local_snapshot.ps1"
|
||||
$composeFile = Join-Path $dbRoot "docker-compose.local-db.yml"
|
||||
$copiedDump = Join-Path $dbRoot "velocity.dump"
|
||||
|
||||
Copy-Item $dumpFile $copiedDump -Force
|
||||
|
||||
$rawEnv = @{}
|
||||
Get-Content $envExport | ForEach-Object {
|
||||
if ($_ -match '^\s*#' -or $_ -notmatch '=') {
|
||||
return
|
||||
}
|
||||
$key, $value = $_ -split '=', 2
|
||||
$rawEnv[$key.Trim()] = $value.Trim()
|
||||
}
|
||||
|
||||
$localEnvLines = [System.Collections.Generic.List[string]]::new()
|
||||
$localEnvLines.Add("VELOCITY_DB_HOST=127.0.0.1")
|
||||
$localEnvLines.Add("VELOCITY_DB_PORT=54329")
|
||||
$localEnvLines.Add("VELOCITY_DB_NAME=velocity_local")
|
||||
$localEnvLines.Add("VELOCITY_DB_USER=velocity_local")
|
||||
$localEnvLines.Add("VELOCITY_DB_PASSWORD=velocity_local")
|
||||
$localEnvLines.Add("DATABASE_URL=postgresql://velocity_local:velocity_local@127.0.0.1:54329/velocity_local")
|
||||
$localEnvLines.Add("CORS_ORIGINS=http://127.0.0.1:5173,http://localhost:5173,http://127.0.0.1:3000,http://localhost:3000")
|
||||
|
||||
if ($rawEnv.ContainsKey("VELOCITY_JWT_SECRET")) {
|
||||
$localEnvLines.Add("VELOCITY_JWT_SECRET=$($rawEnv['VELOCITY_JWT_SECRET'])")
|
||||
}
|
||||
|
||||
if ($rawEnv.ContainsKey("JWT_SECRET_KEY")) {
|
||||
$localEnvLines.Add("JWT_SECRET_KEY=$($rawEnv['JWT_SECRET_KEY'])")
|
||||
}
|
||||
|
||||
if ($rawEnv.ContainsKey("JWT_ALGORITHM")) {
|
||||
$localEnvLines.Add("JWT_ALGORITHM=$($rawEnv['JWT_ALGORITHM'])")
|
||||
}
|
||||
|
||||
if ($rawEnv.ContainsKey("JWT_EXP_MINUTES")) {
|
||||
$localEnvLines.Add("JWT_EXP_MINUTES=$($rawEnv['JWT_EXP_MINUTES'])")
|
||||
}
|
||||
|
||||
$localAssetsRoot = Join-Path $localRoot "assets"
|
||||
$localEnvLines.Add("VELOCITY_ASSET_DIR=$localAssetsRoot")
|
||||
|
||||
Set-Content -Path $targetEnv -Value ($localEnvLines -join "`r`n") -Encoding UTF8
|
||||
|
||||
$compose = @"
|
||||
services:
|
||||
velocity-postgres-local:
|
||||
image: postgres:16
|
||||
container_name: velocity-postgres-local
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: velocity_local
|
||||
POSTGRES_USER: velocity_local
|
||||
POSTGRES_PASSWORD: velocity_local
|
||||
ports:
|
||||
- "54329:5432"
|
||||
volumes:
|
||||
- velocity_postgres_local_data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
velocity_postgres_local_data:
|
||||
"@
|
||||
|
||||
Set-Content -Path $composeFile -Value $compose -Encoding UTF8
|
||||
|
||||
$restoreTemplate = @'
|
||||
param(
|
||||
[string]$RepoRoot = "__REPO_ROOT__"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$DbRoot = Join-Path $RepoRoot ".local-dev\db"
|
||||
$Compose = Join-Path $DbRoot "docker-compose.local-db.yml"
|
||||
$Dump = Join-Path $DbRoot "velocity.dump"
|
||||
|
||||
docker compose -f $Compose up -d
|
||||
Start-Sleep -Seconds 4
|
||||
docker exec -i velocity-postgres-local dropdb --if-exists -U velocity_local velocity_local
|
||||
docker exec -i velocity-postgres-local createdb -U velocity_local velocity_local
|
||||
docker cp $Dump velocity-postgres-local:/tmp/velocity.dump
|
||||
docker exec -i velocity-postgres-local pg_restore -U velocity_local -d velocity_local --clean --if-exists --no-owner --no-privileges /tmp/velocity.dump
|
||||
|
||||
Write-Host "Local PostgreSQL restore complete."
|
||||
Write-Host "Use these local DB env values:"
|
||||
Write-Host "VELOCITY_DB_HOST=127.0.0.1"
|
||||
Write-Host "VELOCITY_DB_PORT=54329"
|
||||
Write-Host "VELOCITY_DB_NAME=velocity_local"
|
||||
Write-Host "VELOCITY_DB_USER=velocity_local"
|
||||
Write-Host "VELOCITY_DB_PASSWORD=velocity_local"
|
||||
'@
|
||||
|
||||
$restore = $restoreTemplate.Replace("__REPO_ROOT__", $RepoRoot)
|
||||
|
||||
Set-Content -Path $restoreScript -Value $restore -Encoding UTF8
|
||||
|
||||
Write-Host "Imported local bundle from $BundleRoot"
|
||||
Write-Host "Backend env snapshot: $targetEnv"
|
||||
Write-Host "DB dump copied to: $copiedDump"
|
||||
Write-Host "Run this next:"
|
||||
Write-Host "powershell -ExecutionPolicy Bypass -File `"$restoreScript`""
|
||||
Reference in New Issue
Block a user