This commit is contained in:
68
server-rs/scripts/spacetime-dev.ps1
Normal file
68
server-rs/scripts/spacetime-dev.ps1
Normal file
@@ -0,0 +1,68 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Alias("h")]
|
||||
[switch]$Help,
|
||||
[string]$ListenHost = "127.0.0.1",
|
||||
[int]$Port = 3000,
|
||||
[string]$RootDir = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Write-Usage {
|
||||
@(
|
||||
'Usage:'
|
||||
' ./server-rs/scripts/spacetime-dev.ps1'
|
||||
' ./server-rs/scripts/spacetime-dev.ps1 -ListenHost 127.0.0.1 -Port 3101'
|
||||
''
|
||||
'Notes:'
|
||||
' 1. Start local standalone SpacetimeDB for the Genarrative Rust backend'
|
||||
' 2. Store local SpacetimeDB state in server-rs/.spacetimedb/local by default'
|
||||
' 3. Default port is 3000 to align with the spacetime CLI local server alias'
|
||||
' 4. Current stage already has crates/spacetime-module scaffold, but still does not auto-publish the module'
|
||||
) -join [Environment]::NewLine
|
||||
}
|
||||
|
||||
if ($Help) {
|
||||
Write-Usage
|
||||
exit 0
|
||||
}
|
||||
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$serverRsDir = Split-Path -Parent $scriptDir
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($RootDir)) {
|
||||
$RootDir = Join-Path $serverRsDir ".spacetimedb\local"
|
||||
}
|
||||
|
||||
if (-not (Test-Path (Join-Path $serverRsDir "crates\spacetime-module\README.md"))) {
|
||||
throw "Missing server-rs/crates/spacetime-module/README.md, cannot start SpacetimeDB local dev script."
|
||||
}
|
||||
|
||||
$spacetimeCommand = Get-Command spacetime -ErrorAction SilentlyContinue
|
||||
|
||||
if ($null -eq $spacetimeCommand) {
|
||||
throw @(
|
||||
"Missing 'spacetime' CLI.",
|
||||
"Install guide: https://spacetimedb.com/install",
|
||||
"Windows PowerShell: iwr https://windows.spacetimedb.com -useb | iex"
|
||||
) -join " "
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $RootDir | Out-Null
|
||||
|
||||
$listenAddress = "$ListenHost`:$Port"
|
||||
|
||||
Write-Host "[server-rs:spacetime-dev] working dir: $serverRsDir"
|
||||
Write-Host "[server-rs:spacetime-dev] root dir: $RootDir"
|
||||
Write-Host "[server-rs:spacetime-dev] listen addr: $listenAddress"
|
||||
Write-Host "[server-rs:spacetime-dev] mode: standalone"
|
||||
Write-Host "[server-rs:spacetime-dev] note: module scaffold already exists; publish remains manual in this stage"
|
||||
|
||||
Push-Location $serverRsDir
|
||||
try {
|
||||
& $spacetimeCommand.Source --root-dir $RootDir start --edition standalone --listen-addr $listenAddress
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
Reference in New Issue
Block a user