-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbuild.ps1
More file actions
108 lines (91 loc) · 3.11 KB
/
build.ps1
File metadata and controls
108 lines (91 loc) · 3.11 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env pwsh
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Root build orchestrator for PSDocs monorepo
[CmdletBinding()]
param(
[Parameter()]
[ValidateSet('psdocs', 'psdocs-azure', 'vscode', 'all')]
[string]$Package = 'all',
[Parameter()]
[switch]$Build,
[Parameter()]
[switch]$Test,
[Parameter()]
[switch]$Clean
)
$ErrorActionPreference = 'Stop'
# Import common utilities
. $PSScriptRoot/build/common.ps1
function Invoke-PackageBuild {
param(
[string]$PackagePath,
[string]$PackageName,
[switch]$Build,
[switch]$Test,
[switch]$Clean
)
if (-not (Test-Path $PackagePath)) {
Write-Host "Package '$PackageName' not found at $PackagePath - skipping" -ForegroundColor Yellow
return
}
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "Building: $PackageName" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
Push-Location $PackagePath
try {
$buildScript = './pipeline.build.ps1'
if (Test-Path $buildScript) {
# pipeline.build.ps1 is an InvokeBuild script - use Invoke-Build
$tasks = @()
if ($Clean) { $tasks += 'Clean' }
if ($Build) { $tasks += 'Build' }
if ($Test) { $tasks += 'Test' }
if ($tasks.Count -gt 0) {
Invoke-Build -Task $tasks -File $buildScript
}
} elseif (Test-Path 'package.json') {
# Node.js package (VS Code extension)
if ($Clean) {
Remove-Item -Path 'node_modules', 'out', '*.vsix' -Recurse -Force -ErrorAction SilentlyContinue
}
if ($Build) {
npm ci
npm run compile
}
if ($Test) {
npm run lint
}
}
}
finally {
Pop-Location
}
}
# Install dependencies
Install-BuildDependencies
# Determine which packages to build
$packages = @()
switch ($Package) {
'psdocs' { $packages = @('psdocs') }
'psdocs-azure' { $packages = @('psdocs', 'psdocs-azure') } # psdocs-azure depends on psdocs
'vscode' { $packages = @('vscode') }
'all' { $packages = @('psdocs', 'psdocs-azure', 'vscode') }
}
# Build packages in order
foreach ($pkg in $packages) {
$pkgPath = switch ($pkg) {
'psdocs' { "$PSScriptRoot/packages/psdocs" }
'psdocs-azure' { "$PSScriptRoot/packages/psdocs-azure" }
'vscode' { "$PSScriptRoot/packages/vscode-extension" }
}
Invoke-PackageBuild -PackagePath $pkgPath -PackageName $pkg -Build:$Build -Test:$Test -Clean:$Clean
# After building psdocs, set up module path for psdocs-azure
if ($pkg -eq 'psdocs' -and $Build) {
$moduleInitialized = Get-LocalPSDocsModule
if (-not $moduleInitialized) {
Write-Error "Failed to locate or initialize the local PSDocs module. Cannot continue building dependent packages."
}
}
}
Write-Host "`n✅ Build complete!" -ForegroundColor Green