75 lines
2.8 KiB
PowerShell
75 lines
2.8 KiB
PowerShell
param(
|
|
[switch]$SkipHermesSkill
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$ProjectRoot = Split-Path -Parent $PSScriptRoot
|
|
Set-Location -LiteralPath $ProjectRoot
|
|
|
|
Write-Host "Project root: $ProjectRoot"
|
|
|
|
$requiredDirs = @(
|
|
'runtime\erp-order-entry',
|
|
'runtime\erp-order-entry\incoming',
|
|
'runtime\erp-order-entry\downloads',
|
|
'runtime\erp-order-entry\outputs',
|
|
'runtime\erp-order-entry\audit',
|
|
'runtime\erp-order-entry\logs',
|
|
'runtime\erp-order-entry\browser-profile',
|
|
'diagnostics\deployment-health'
|
|
)
|
|
|
|
foreach ($dir in $requiredDirs) {
|
|
New-Item -ItemType Directory -Force -Path (Join-Path $ProjectRoot $dir) | Out-Null
|
|
}
|
|
|
|
$configPath = Join-Path $ProjectRoot 'config\erp-deployment.local.json'
|
|
if (-not (Test-Path -LiteralPath $configPath)) {
|
|
throw "Missing config: $configPath"
|
|
}
|
|
|
|
$cfg = Get-Content -Raw -Encoding UTF8 -LiteralPath $configPath | ConvertFrom-Json
|
|
$cfg.safety.allowRealSubmit = $false
|
|
$cfg.browser.interactiveLoginWaitMs = 1800000
|
|
$cfg | ConvertTo-Json -Depth 20 | Set-Content -Encoding UTF8 -LiteralPath $configPath
|
|
Write-Host "Safety reset: allowRealSubmit=false, interactiveLoginWaitMs=1800000"
|
|
|
|
if (-not $SkipHermesSkill) {
|
|
$skillSource = Join-Path $ProjectRoot 'deploy\hermes-travel-erp-order-operator'
|
|
$skillRoot = Join-Path $env:LOCALAPPDATA 'hermes\skills'
|
|
$skillDest = Join-Path $skillRoot 'travel-erp-order-operator'
|
|
New-Item -ItemType Directory -Force -Path $skillRoot | Out-Null
|
|
|
|
if (Test-Path -LiteralPath $skillDest) {
|
|
$backup = Join-Path $skillRoot ("travel-erp-order-operator.backup-" + (Get-Date -Format 'yyyyMMdd-HHmmss'))
|
|
Move-Item -LiteralPath $skillDest -Destination $backup
|
|
Write-Host "Backed up existing Hermes skill to: $backup"
|
|
}
|
|
|
|
Copy-Item -LiteralPath $skillSource -Destination $skillDest -Recurse
|
|
$skillFile = Join-Path $skillDest 'SKILL.md'
|
|
$skill = Get-Content -Raw -Encoding UTF8 -LiteralPath $skillFile
|
|
$skill = $skill.Replace('C:\Users\ZHIWEI\Desktop\泰国skill', $ProjectRoot)
|
|
$skill = $skill.Replace('C:/Users/ZHIWEI/Desktop/泰国skill', ($ProjectRoot -replace '\\', '/'))
|
|
Set-Content -Encoding UTF8 -LiteralPath $skillFile -Value $skill
|
|
Write-Host "Installed Hermes skill: $skillDest"
|
|
}
|
|
|
|
Write-Host "Checking Node..."
|
|
node --version
|
|
|
|
if (-not (Test-Path -LiteralPath (Join-Path $ProjectRoot 'node_modules\playwright-core'))) {
|
|
Write-Host "node_modules/playwright-core not found. Running npm install..."
|
|
npm install
|
|
}
|
|
|
|
Write-Host "Running local health check without ERP..."
|
|
node tools\erp_deployment_health_check.js --config config\erp-deployment.local.json --no-erp
|
|
|
|
Write-Host ""
|
|
Write-Host "Next:"
|
|
Write-Host "1. Restart Hermes/Aimashi."
|
|
Write-Host "2. Run: node tools\erp_interactive_login.js --config config\erp-deployment.local.json --timeout-ms 1800000"
|
|
Write-Host "3. After login succeeds, run: node tools\erp_deployment_health_check.js --config config\erp-deployment.local.json --erp"
|