Skip to content

Commit

Permalink
Added admin ux to deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Curtis Gray committed May 22, 2024
1 parent 3070e65 commit ce70ade
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 3 deletions.
101 changes: 101 additions & 0 deletions admin/build-ux-ci.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
param(
[Parameter(Mandatory = $true)]
[ValidateSet("windows", "windows-cublas", "linux", "linux-cublas", "macos", "macos-metal")]
[string]$BuildPlatform,

[Parameter(Mandatory = $false)]
[switch]$Force,

[Parameter(Mandatory = $false)]
[switch]$SkipDeployment,

[Parameter(Mandatory = $false)]
[switch]$SkipNpmInstall
)

try {
# Clean up the previous build artifacts

if ($Force) {
Write-Host "Cleaning previous build artifacts..."
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue node_modules
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue dist
}

# Determine architecture based on platform
$platform = ""
switch ($BuildPlatform) {
"windows" {
$platform = "win32"
}
"windows-cublas" {
$platform = "win32"
}
"linux" {
$platform = "linux"
}
"linux-cublas" {
$platform = "linux"
}
"macos" {
} # For universal macOS build
"macos-metal" {
} # For universal macOS build
default {
throw "Unsupported platform: $BuildPlatform"
}
}

if (-not $SkipNpmInstall) {

# Install dependencies
Write-Host "Installing Node dependencies..."
# skip dev dependencies on linux platform
if ($platform -eq "linux") {
npm ci --cache .npm --prefer-offline --production
}
else {
npm ci --cache .npm --prefer-offline
}

if ($LASTEXITCODE -ne 0) {
throw "npm install failed"
}
# # Conditional appdmg installation for macOS builds
# # if ($BuildPlatform -eq "macos" -or $BuildPlatform -eq "macos-metal") {
# if ($BuildPlatform -eq "macos-metal") {
# Write-Host "Installing appdmg for macOS..."
# npm install appdmg --save-dev
# if ($LASTEXITCODE -ne 0) {
# throw "npm install appdmg failed"
# }
# }
}
# Build the project
Write-Host "Building the project..."
npm run build
if ($LASTEXITCODE -ne 0) {
throw "npm run build failed"
}

if ($SkipDeployment) {
Write-Warning "Skipping deployment..."
}
else {
# Copy the dist folder to wingman.cpp if the ../services/wingman.cpp/wingman folder exists
$distRoot = "../services/wingman.cpp/wingman"
if (Test-Path $distRoot) {
Write-Host "Copying dist folder to wingman.cpp..."
Copy-Item -Recurse -Force -ErrorAction SilentlyContinue ./dist ../services/wingman.cpp/wingman/distadmin
}
else {
Write-Warning "wingman.cpp folder not found. Skipping copy of dist folder..."
}
}

Write-Host "UX $command completed successfully."
}
catch {
Write-Error "An error occurred during the UX build process: $_"
exit 1
}
9 changes: 9 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ try {
}
Pop-Location

# Build Wingman Admin UX
Write-Host "Building Wingman Admin UX"
Push-Location -Path "./admin"
./build-ux-ci.ps1 -BuildPlatform $BuildPlatform -Force:$Force -SkipDeployment:$SkipDeployment
if ($LASTEXITCODE -ne 0) {
throw "Building Wingman Admin UX failed with exit code $LASTEXITCODE"
}
Pop-Location

# Build Wingman.cpp
Write-Host "Building Wingman.cpp"
Push-Location -Path "./services/wingman.cpp"
Expand Down
2 changes: 1 addition & 1 deletion services/wingman.cpp
3 changes: 1 addition & 2 deletions ux/build-ux-ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ try {
if ($Force) {
Write-Host "Cleaning previous build artifacts..."
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue node_modules
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue out
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue .next
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue dist
}

# Determine architecture based on platform
Expand Down

0 comments on commit ce70ade

Please sign in to comment.