-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-samples.ps1
43 lines (33 loc) · 1.11 KB
/
build-samples.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$WEB_SAMPLES_DIR = "$PSScriptRoot/../ui-web/samples"
$PHP_SAMPLES_DIR = "$PSScriptRoot/samples/server"
try {
Write-Host "Building ui-web project..."
Push-Location $WEB_SAMPLES_DIR
npm ci
npm run build
$exitCode = $LASTEXITCODE
Pop-Location
if ($exitCode -ne 0) {
throw "The npm build command failed with exit code $exitCode"
}
Write-Host "Copying ui-web dist directory..."
Copy-Item -Path "$WEB_SAMPLES_DIR/dist/*" -Destination "$PHP_SAMPLES_DIR/public" -Recurse -Force
Push-Location $PHP_SAMPLES_DIR
Write-Host "Installing api-php sample project dependencies..."
composer install
Write-Host "Ensure there's an .env file..."
if (-not (Test-Path "$PHP_SAMPLES_DIR/.env")) {
New-Item -Path "$PHP_SAMPLES_DIR/.env" -ItemType "File"
}
Write-Host "Validating php script..."
php public/index.php
$exitCode = $LASTEXITCODE
Pop-Location
if ($exitCode -ne 0) {
throw "The php public/index.php command failed with exit code $exitCode"
}
}
catch {
Write-Host "An error occurred: $_" -ForegroundColor Red
Exit 1
}