# PowerShell script to build and run asset-gui # Load configuration from JSON file $config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json $projectDir = $config.assetGui.projectDir $targetDir = $config.assetGui.targetDir Write-Host "Building asset-gui project..." -ForegroundColor Green # Check if target directory exists, create if not if (-not (Test-Path $targetDir)) { Write-Host "Creating target directory: $targetDir" -ForegroundColor Yellow New-Item -ItemType Directory -Path $targetDir -Force } # Convert to absolute path and change to project directory $absoluteProjectDir = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot $projectDir)) Push-Location $absoluteProjectDir try { # Install dependencies Write-Host "Installing Node.js dependencies..." -ForegroundColor Yellow npm install # Build the project Write-Host "Building the project..." -ForegroundColor Yellow gulp build --minified # Copy release folder to target directory Write-Host "Copying release folder to $targetDir..." -ForegroundColor Yellow Pop-Location # Return to original directory to use relative paths correctly $releaseDir = Join-Path $absoluteProjectDir "release" if (Test-Path $releaseDir) { $absoluteTargetDir = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot $targetDir)) Copy-Item -Path "$releaseDir\*" -Destination $absoluteTargetDir -Recurse -Force } else { Write-Host "Error: Release folder not found at $releaseDir" -ForegroundColor Red } # Change back to project directory for serving Push-Location $projectDir # Start development server Write-Host "Starting development server..." -ForegroundColor Green gulp watch } finally { # Return to original directory Pop-Location }