[eric] remove vendored 9router (now fetched from npm at build), remove Copilot, and fix subs + tools

This commit is contained in:
ciregenz
2026-04-25 02:26:08 -07:00
parent 744a14dc47
commit f5cc3a36fb
510 changed files with 1736 additions and 73260 deletions
+17 -34
View File
@@ -163,36 +163,27 @@ if (-not (Test-Path (Join-Path $ProjectRoot 'electron\python-env'))) {
Write-Host "Python environment ready."
Write-Host ""
# --- Step 3: 9Router build ---
Write-Host "[3/5] Building 9Router..."
Push-Location (Join-Path $ProjectRoot '9router')
try {
& npm install
if ($LASTEXITCODE -ne 0) { throw "npm install (9router) failed" }
& npm run build
if ($LASTEXITCODE -ne 0) { throw "9router build failed" }
} finally { Pop-Location }
$Standalone = Join-Path $ProjectRoot '9router\.next\standalone'
if (-not (Test-Path $Standalone)) { throw "9Router build failed - .next\standalone not found" }
$NextStatic = Join-Path $ProjectRoot '9router\.next\static'
if (Test-Path $NextStatic) {
$StandaloneStatic = Join-Path $Standalone '.next\static'
New-Item -ItemType Directory -Force -Path (Split-Path $StandaloneStatic -Parent) | Out-Null
Copy-Item -Recurse -Force $NextStatic $StandaloneStatic
}
$NextPublic = Join-Path $ProjectRoot '9router\public'
if (Test-Path $NextPublic) {
Copy-Item -Recurse -Force $NextPublic (Join-Path $Standalone 'public')
}
Write-Host "9Router build complete."
Write-Host ""
# --- Step 4: Snapshot source dirs into electron\build-staging\ ---
Write-Host "[4/5] Snapshotting source directories..."
# --- Step 3: Fetch Router from npm ---
# The 9router Next.js server is published as an npm package with a pre-built
# standalone output. Stage it directly from npm instead of vendoring + rebuilding.
Write-Host "[3/5] Fetching Router from npm..."
$Staging = Join-Path $ProjectRoot 'electron\build-staging'
if (Test-Path $Staging) { Remove-Item -Recurse -Force $Staging }
New-Item -ItemType Directory -Force -Path $Staging | Out-Null
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $ProjectRoot 'scripts\fetch-router.ps1') -Dest (Join-Path $Staging 'router')
if ($LASTEXITCODE -ne 0) { throw "fetch-router.ps1 failed" }
if (-not (Test-Path (Join-Path $Staging 'router\server.js'))) {
throw "Router fetch failed - server.js not found in staging"
}
Write-Host "Router staged."
Write-Host ""
# --- Step 4: Snapshot source dirs into electron\build-staging\ ---
# (Router was already staged in step 3; do not wipe or re-copy it here.)
Write-Host "[4/5] Snapshotting source directories..."
function Copy-Excluded($Source, $Dest, $Exclude) {
# robocopy: built-in, fast, handles long paths.
$args = @($Source, $Dest, '/E', '/NJH', '/NJS', '/NDL', '/NFL', '/NP', '/MT:8')
@@ -215,14 +206,6 @@ Copy-Excluded `
Copy-Item -Recurse -Force (Join-Path $ProjectRoot 'frontend\dist\*') (New-Item -ItemType Directory -Force -Path (Join-Path $Staging 'frontend')).FullName
# 9Router standalone -> staging\9router
Copy-Excluded $Standalone (Join-Path $Staging '9router') @{ Dirs = @(); Files = @() }
if (Test-Path $NextStatic) {
$TargetStatic = Join-Path $Staging '9router\.next\static'
New-Item -ItemType Directory -Force -Path (Split-Path $TargetStatic -Parent) | Out-Null
Copy-Item -Recurse -Force $NextStatic $TargetStatic
}
Write-Host ""
Write-Host "========================================" -BackgroundColor Green -ForegroundColor White
Write-Host " SOURCE SNAPSHOT COMPLETE " -BackgroundColor Green -ForegroundColor White
+17 -33
View File
@@ -140,33 +140,26 @@ fi
echo "Python environment ready."
echo ""
# Step 3: Build 9Router
echo "[3/5] Building 9Router..."
cd "$PROJECT_ROOT/9router"
npm install
npm run build
if [[ ! -d "$PROJECT_ROOT/9router/.next/standalone" ]]; then
echo "ERROR: 9Router build failed — .next/standalone not found"
exit 1
fi
# Copy static assets into standalone (required by Next.js standalone mode)
if [[ -d "$PROJECT_ROOT/9router/.next/static" ]]; then
cp -r "$PROJECT_ROOT/9router/.next/static" "$PROJECT_ROOT/9router/.next/standalone/.next/static"
fi
if [[ -d "$PROJECT_ROOT/9router/public" ]]; then
cp -r "$PROJECT_ROOT/9router/public" "$PROJECT_ROOT/9router/.next/standalone/public"
fi
echo "9Router build complete."
echo ""
# Step 4: Snapshot source directories for packaging
echo "[4/5] Snapshotting source directories..."
# Step 3: Fetch Router from npm
# The 9router Next.js server is published as an npm package with a pre-built
# standalone output. We install it into a scratch dir and stage it directly
# rather than vendoring the source + rebuilding here.
echo "[3/5] Fetching Router from npm..."
STAGING_DIR="$PROJECT_ROOT/electron/build-staging"
rm -rf "$STAGING_DIR"
mkdir -p "$STAGING_DIR"
bash "$PROJECT_ROOT/scripts/fetch-router.sh" "$STAGING_DIR/router"
if [[ ! -f "$STAGING_DIR/router/server.js" ]]; then
echo "ERROR: Router fetch failed — server.js not found in staged dir"
exit 1
fi
echo "Router staged."
echo ""
# Step 4: Snapshot source directories for packaging
# (Router was already staged in step 3; do not touch STAGING_DIR/router/ here.)
echo "[4/5] Snapshotting source directories..."
rsync -a \
--exclude='__pycache__' --exclude='**/__pycache__' \
@@ -185,15 +178,6 @@ rsync -a \
rsync -a "$PROJECT_ROOT/frontend/dist/" "$STAGING_DIR/frontend/"
# 9Router — copy the pre-built standalone directory
rsync -a \
"$PROJECT_ROOT/9router/.next/standalone/" "$STAGING_DIR/9router/"
# Copy the .next directory structure needed by standalone
mkdir -p "$STAGING_DIR/9router/.next"
if [[ -d "$PROJECT_ROOT/9router/.next/static" ]]; then
rsync -a "$PROJECT_ROOT/9router/.next/static/" "$STAGING_DIR/9router/.next/static/"
fi
echo ""
printf '\033[1;42;97m%s\033[0m\n' "========================================"
printf '\033[1;42;97m%s\033[0m\n' " ✅ SOURCE SNAPSHOT COMPLETE "
+36
View File
@@ -0,0 +1,36 @@
param(
[Parameter(Mandatory=$true)]
[string]$Dest
)
$ErrorActionPreference = 'Stop'
$RouterVersion = if ($env:ROUTER_VERSION) { $env:ROUTER_VERSION } else { '0.3.60' }
Write-Host "Fetching 9router@$RouterVersion from npm..."
$Scratch = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "9router-fetch-$([guid]::NewGuid())")
try {
Push-Location $Scratch
'{"name":"_fetch","version":"0.0.0","private":true}' | Out-File -Encoding utf8 -NoNewline package.json
& npm install "9router@$RouterVersion" --no-save --no-audit --no-fund --silent --ignore-scripts
if ($LASTEXITCODE -ne 0) { throw "npm install 9router@$RouterVersion failed" }
$Src = Join-Path $Scratch 'node_modules\9router\app'
if (-not (Test-Path $Src)) {
throw "9router@$RouterVersion did not install to expected layout ($Src missing)"
}
Pop-Location
if (Test-Path $Dest) { Remove-Item -Recurse -Force $Dest }
New-Item -ItemType Directory -Force -Path $Dest | Out-Null
robocopy $Src $Dest /E /NJH /NJS /NDL /NFL /NP /MT:8 | Out-Null
if ($LASTEXITCODE -ge 8) { throw "robocopy failed staging 9router (exit $LASTEXITCODE)" }
$global:LASTEXITCODE = 0
Write-Host "9router staged at: $Dest"
} finally {
if (Test-Path $Scratch) { Remove-Item -Recurse -Force $Scratch }
}
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# Fetch the pre-built 9router Next.js app from npm and stage it for packaging.
# Usage: bash scripts/fetch-router.sh <dest_dir>
set -euo pipefail
DEST="${1:-}"
if [[ -z "$DEST" ]]; then
echo "Usage: $0 <dest_dir>" >&2
exit 1
fi
ROUTER_VERSION="${ROUTER_VERSION:-0.3.60}"
echo "Fetching 9router@${ROUTER_VERSION} from npm..."
SCRATCH="$(mktemp -d)"
trap 'rm -rf "$SCRATCH"' EXIT
cd "$SCRATCH"
printf '{"name":"_fetch","version":"0.0.0","private":true}\n' > package.json
npm install "9router@${ROUTER_VERSION}" --no-save --no-audit --no-fund --silent --ignore-scripts
SRC="$SCRATCH/node_modules/9router/app"
if [[ ! -d "$SRC" ]]; then
echo "ERROR: 9router@${ROUTER_VERSION} did not install to expected layout ($SRC missing)" >&2
exit 1
fi
mkdir -p "$DEST"
rsync -a --delete "$SRC/" "$DEST/"
echo "9router staged at: $DEST"