2026-10-15 11:30:55 +08:00
param ( [ ValidateSet ( 'Backend' , 'Frontend' , 'Both' ) ] [ string ] $Component = 'Both' , [ switch ] $RealDataReplay , [ switch ] $HistoryEntry , [ string ] $HistorySource = '' )
2026-10-12 16:41:42 +08:00
$ErrorActionPreference = 'Stop'
$taskRoot = ( Resolve-Path ( Join-Path $PSScriptRoot '../..' ) ) . Path
$taskTemp = Join-Path $taskRoot '.codex-tmp'
New-Item -ItemType Directory -Path $taskTemp -Force | Out-Null
if ( $Component -in @ ( 'Backend' , 'Both' ) ) {
if ( ! ( Get-NetTCPConnection -State Listen -LocalPort 8080 -ErrorAction SilentlyContinue ) ) {
$taskJava = Join-Path $env:USERPROFILE '.jdks/ms-17.0.19/bin/java.exe'
if ( ! ( Test-Path -LiteralPath $taskJava ) ) { throw 'Configure a Java 17 or newer runtime for this computer.' }
$env:RUOYI_PROFILE = Join-Path $taskTemp 'uploads'
$env:RUOYI_LOG_PATH = Join-Path $taskTemp 'logs'
$taskArgs = @ ( " -Djdk.net.unixdomain.tmpdir= $( $taskTemp . Replace ( '\' , '/' ) ) " , '-Dstdout.encoding=UTF-8' , '-Dstderr.encoding=UTF-8' , '-jar' , 'ruoyi-admin/target/cmvr-wms.jar' , '--spring.quartz.auto-startup=false' , '--spring.devtools.restart.enabled=false' )
2026-10-15 11:30:55 +08:00
if ( $RealDataReplay ) { $taskArgs + = '--projectdev.real-data-replay-enabled=true' }
if ( $HistoryEntry ) { $taskArgs + = '--projectdev.history-entry-enabled=true' }
if ( $HistorySource ) {
$taskSourceRoot = ( Resolve-Path ( Join-Path $taskRoot '.codex-tmp/real-data-replay' ) ) . Path
$taskSourceFile = ( Resolve-Path -LiteralPath $HistorySource ) . Path
if ( ! $taskSourceFile . StartsWith ( $taskSourceRoot + [ IO.Path ] :: DirectorySeparatorChar , [ StringComparison ] :: OrdinalIgnoreCase ) ) { throw 'History source must be an inventoried file inside the replay directory.' }
$taskArgs + = ( '--projectdev.history-entry-source=' + $taskSourceFile . Replace ( '\' , '/' ) )
}
2026-10-12 16:41:42 +08:00
Start-Process -FilePath $taskJava -ArgumentList $taskArgs -WorkingDirectory $taskRoot -WindowStyle Hidden -RedirectStandardOutput ( Join-Path $taskTemp 'backend.out.log' ) -RedirectStandardError ( Join-Path $taskTemp 'backend.err.log' ) | Out-Null
}
Write-Output 'Backend: http://localhost:8080 (copied scheduled jobs disabled)'
}
if ( $Component -in @ ( 'Frontend' , 'Both' ) ) {
if ( ! ( Get-NetTCPConnection -State Listen -LocalPort 8088 -ErrorAction SilentlyContinue ) ) {
2026-10-15 11:30:55 +08:00
$env:NODE_OPTIONS = '--max-old-space-size=2048'
2026-10-13 09:41:46 +08:00
Start-Process -FilePath 'C:/Program Files/nodejs/node.exe' -ArgumentList @ ( 'node_modules/vite/bin/vite.js' , '--host' , '0.0.0.0' , '--port' , '8088' ) -WorkingDirectory ( Join-Path $taskRoot 'ruoyi-ui-vue3' ) -WindowStyle Hidden -RedirectStandardOutput ( Join-Path $taskTemp 'frontend.out.log' ) -RedirectStandardError ( Join-Path $taskTemp 'frontend.err.log' ) | Out-Null
2026-10-12 16:41:42 +08:00
}
2026-10-13 09:41:46 +08:00
Write-Output 'Frontend Vue3: http://localhost:8088 (ruoyi-ui-vue3)'
2026-10-12 16:41:42 +08:00
}