[FA-5] FileService setup, build scripts tweaked to be easier to maintain
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set ROOT=%~dp0
|
||||
|
||||
for %%A in ("%ROOT%..") do set SERVICES_DIR=%%~fA\
|
||||
|
||||
REM ----------------------------------------
|
||||
REM List of project names to skip
|
||||
REM (space-separated, match folder names exactly)
|
||||
REM ----------------------------------------
|
||||
set SKIP_PROJECTS=FictionArchive.Service.Shared FictionArchive.Service.AuthenticationService
|
||||
|
||||
echo ----------------------------------------
|
||||
echo Finding GraphQL services...
|
||||
echo ----------------------------------------
|
||||
|
||||
set SERVICE_LIST=
|
||||
|
||||
for /d %%F in ("%SERVICES_DIR%FictionArchive.Service.*") do (
|
||||
set "PROJECT_NAME=%%~nxF"
|
||||
set "SKIP=0"
|
||||
|
||||
REM Check if this project name is in the skip list
|
||||
for %%X in (%SKIP_PROJECTS%) do (
|
||||
if /I "!PROJECT_NAME!"=="%%X" (
|
||||
set "SKIP=1"
|
||||
)
|
||||
)
|
||||
|
||||
if !SKIP!==0 (
|
||||
echo Found service: !PROJECT_NAME!
|
||||
set SERVICE_LIST=!SERVICE_LIST! %%F
|
||||
) else (
|
||||
echo Skipping service: !PROJECT_NAME!
|
||||
)
|
||||
)
|
||||
|
||||
echo:
|
||||
echo ----------------------------------------
|
||||
echo Exporting schemas and packing subgraphs...
|
||||
echo ----------------------------------------
|
||||
|
||||
for %%S in (%SERVICE_LIST%) do (
|
||||
echo Processing service folder: %%S
|
||||
pushd "%%S"
|
||||
|
||||
echo Running schema export...
|
||||
dotnet run -- schema export --output schema.graphql
|
||||
if errorlevel 1 (
|
||||
echo ERROR during schema export in %%S
|
||||
popd
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Running fusion subgraph pack...
|
||||
fusion subgraph pack
|
||||
if errorlevel 1 (
|
||||
echo ERROR during subgraph pack in %%S
|
||||
popd
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
popd
|
||||
echo Completed: %%S
|
||||
echo.
|
||||
)
|
||||
|
||||
echo ----------------------------------------
|
||||
echo Running fusion compose...
|
||||
echo ----------------------------------------
|
||||
|
||||
pushd "%ROOT%"
|
||||
|
||||
if exist gateway.fgp del gateway.fgp
|
||||
|
||||
for %%S in (%SERVICE_LIST%) do (
|
||||
REM Extract the full folder name WITH dots preserved
|
||||
set "SERVICE_NAME=%%~nxS"
|
||||
|
||||
echo Composing subgraph: !SERVICE_NAME!
|
||||
|
||||
fusion compose -p gateway.fgp -s "..\!SERVICE_NAME!"
|
||||
if errorlevel 1 (
|
||||
echo ERROR during fusion compose
|
||||
popd
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
popd
|
||||
|
||||
|
||||
echo ----------------------------------------
|
||||
echo Fusion build complete!
|
||||
echo ----------------------------------------
|
||||
|
||||
endlocal
|
||||
exit /b 0
|
||||
138
FictionArchive.API/build_gateway.ps1
Normal file
138
FictionArchive.API/build_gateway.ps1
Normal file
@@ -0,0 +1,138 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Export GraphQL schemas, pack subgraphs and compose the gateway (PowerShell).
|
||||
.DESCRIPTION
|
||||
- Searches for FictionArchive.Service.* folders one directory above this script.
|
||||
- Reads skip-projects.txt next to the script.
|
||||
- Builds each service (Release).
|
||||
- Runs `dotnet run --no-build --no-launch-profile -- schema export` in each service to avoid running the web host.
|
||||
- Packs subgraphs.
|
||||
- Composes the gateway from FictionArchive.API.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
function Write-ErrExit {
|
||||
param($Message, $Code = 1)
|
||||
Write-Error $Message
|
||||
exit $Code
|
||||
}
|
||||
|
||||
# Resolve directories
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
$ServicesDir = Resolve-Path -Path (Join-Path $ScriptDir '..') -ErrorAction Stop
|
||||
$ApiDir = Join-Path $ServicesDir 'FictionArchive.API'
|
||||
|
||||
Write-Host "Script dir: $ScriptDir"
|
||||
Write-Host "Services dir: $ServicesDir"
|
||||
|
||||
# Load skip list
|
||||
$SkipFile = Join-Path $ScriptDir 'gateway_skip.txt'
|
||||
$SkipList = @()
|
||||
|
||||
Write-Host "----------------------------------------"
|
||||
Write-Host " Loading skip list..."
|
||||
Write-Host "----------------------------------------"
|
||||
|
||||
if (Test-Path $SkipFile) {
|
||||
$SkipList = Get-Content $SkipFile |
|
||||
ForEach-Object { $_.Trim() } |
|
||||
Where-Object { $_ -and -not $_.StartsWith('#') }
|
||||
|
||||
Write-Host "Skipping: $($SkipList -join ', ')"
|
||||
} else {
|
||||
Write-Warning "skip-projects.txt not found — no services will be skipped."
|
||||
}
|
||||
|
||||
# Find service directories
|
||||
Write-Host
|
||||
Write-Host "----------------------------------------"
|
||||
Write-Host " Finding GraphQL services..."
|
||||
Write-Host "----------------------------------------"
|
||||
|
||||
$servicePattern = 'FictionArchive.Service.*'
|
||||
$serviceDirs = Get-ChildItem -Path $ServicesDir -Directory -Filter 'FictionArchive.Service.*'
|
||||
|
||||
if (-not $serviceDirs) {
|
||||
Write-ErrExit "No service folders found matching FictionArchive.Service.* under $ServicesDir"
|
||||
}
|
||||
|
||||
$selectedServices = @()
|
||||
|
||||
foreach ($d in $serviceDirs) {
|
||||
if ($SkipList -contains $d.Name) {
|
||||
Write-Host "Skipping: $($d.Name)"
|
||||
continue
|
||||
}
|
||||
|
||||
Write-Host "Found: $($d.Name)"
|
||||
$selectedServices += $d.FullName
|
||||
}
|
||||
|
||||
if (-not $selectedServices) {
|
||||
Write-ErrExit "All services skipped — nothing to do."
|
||||
}
|
||||
|
||||
# Export schemas and pack subgraphs
|
||||
Write-Host
|
||||
Write-Host "----------------------------------------"
|
||||
Write-Host " Exporting schemas & packing subgraphs..."
|
||||
Write-Host "----------------------------------------"
|
||||
|
||||
foreach ($svcPath in $selectedServices) {
|
||||
$svcName = Split-Path -Leaf $svcPath
|
||||
Write-Host "`nProcessing: $svcName"
|
||||
|
||||
Push-Location $svcPath
|
||||
try {
|
||||
# Build Release
|
||||
Write-Host "Building $svcName..."
|
||||
dotnet build -c Release
|
||||
if ($LASTEXITCODE -ne 0) { Write-ErrExit "dotnet build failed for $svcName" }
|
||||
|
||||
# Schema export using dotnet run (no server)
|
||||
Write-Host "Running schema export..."
|
||||
dotnet run --no-build --no-launch-profile -- schema export --output schema.graphql
|
||||
if ($LASTEXITCODE -ne 0) { Write-ErrExit "Schema export failed for $svcName" }
|
||||
|
||||
# Pack subgraph
|
||||
Write-Host "Running fusion subgraph pack..."
|
||||
fusion subgraph pack
|
||||
if ($LASTEXITCODE -ne 0) { Write-ErrExit "fusion subgraph pack failed for $svcName" }
|
||||
|
||||
Write-Host "Completed: $svcName"
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
# Compose gateway
|
||||
Write-Host
|
||||
Write-Host "----------------------------------------"
|
||||
Write-Host " Running fusion compose..."
|
||||
Write-Host "----------------------------------------"
|
||||
|
||||
if (-not (Test-Path $ApiDir)) {
|
||||
Write-ErrExit "API directory not found: $ApiDir"
|
||||
}
|
||||
|
||||
Push-Location $ApiDir
|
||||
try {
|
||||
if (Test-Path "gateway.fgp") { Remove-Item "gateway.fgp" -Force }
|
||||
|
||||
foreach ($svcPath in $selectedServices) {
|
||||
$svcName = Split-Path -Leaf $svcPath
|
||||
Write-Host "Composing: $svcName"
|
||||
fusion compose -p gateway.fgp -s ("..\" + $svcName)
|
||||
if ($LASTEXITCODE -ne 0) { Write-ErrExit "fusion compose failed for $svcName" }
|
||||
}
|
||||
|
||||
Write-Host "`nFusion build complete!"
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
exit 0
|
||||
@@ -14,10 +14,18 @@ SERVICES_DIR="$(cd "$ROOT/.." && pwd)"
|
||||
###############################################
|
||||
# Skip list (folder names, match exactly)
|
||||
###############################################
|
||||
SKIP_PROJECTS=(
|
||||
"FictionArchive.Service.Shared"
|
||||
"FictionArchive.Service.Legacy"
|
||||
)
|
||||
SKIP_FILE="$ROOT/gateway_skip.txt"
|
||||
SKIP_PROJECTS=()
|
||||
|
||||
if [[ -f "$SKIP_FILE" ]]; then
|
||||
# Read non-empty lines ignoring comments
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" || "$line" =~ ^# ]] && continue
|
||||
SKIP_PROJECTS+=("$line")
|
||||
done < "$SKIP_FILE"
|
||||
else
|
||||
echo "WARNING: skip-projects.txt not found — no projects will be skipped."
|
||||
fi
|
||||
|
||||
echo "----------------------------------------"
|
||||
echo " Finding GraphQL services..."
|
||||
|
||||
4
FictionArchive.API/gateway_skip.txt
Normal file
4
FictionArchive.API/gateway_skip.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
# List of service folders to skip
|
||||
FictionArchive.Service.Shared
|
||||
FictionArchive.Service.AuthenticationService
|
||||
FictionArchive.Service.FileService
|
||||
Reference in New Issue
Block a user