11<#
22. SYNOPSIS
3- Full build pipeline: type-check, test, and package VSIX.
3+ Full build pipeline: install, type-check, test, and package VSIX.
44
55. DESCRIPTION
66 Runs the complete build process for Zoo-Code:
7- 1. TypeScript type-check across all packages
8- 2. Unit tests via turbo
9- 3. VSIX packaging
7+ 1. Check prerequisites (node, pnpm, git)
8+ 2. Install dependencies (pnpm install)
9+ 3. TypeScript type-check
10+ 4. Unit tests
11+ 5. VSIX packaging
12+ 6. Artifact verification (path, size, SHA-256)
1013
1114 Stops on first failure with a clear error message.
1215
1316. EXAMPLE
14- .\build.ps1
15- .\build.ps1 -SkipTests
16- .\build.ps1 -SkipTypes
17+ .\build.ps1 # Full pipeline
18+ .\build.ps1 -SkipTests # Skip tests
19+ .\build.ps1 -OnlyVsix # Just build VSIX (skip types + tests)
20+ .\build.ps1 -SkipInstall # Skip pnpm install (already installed)
1721#>
1822
1923param (
2024 [switch ]$SkipTypes ,
2125 [switch ]$SkipTests ,
2226 [switch ]$SkipVsix ,
23- [int ]$TimeoutSec = 300
27+ [switch ]$SkipInstall ,
28+ [switch ]$OnlyVsix ,
29+ [int ]$TimeoutSec = 600
2430)
2531
2632$ErrorActionPreference = " Stop"
2733$scriptDir = Split-Path - Parent $MyInvocation.MyCommand.Path
2834
35+ # OnlyVsix shorthand
36+ if ($OnlyVsix ) {
37+ $SkipTypes = $true
38+ $SkipTests = $true
39+ $SkipInstall = $true
40+ }
41+
2942function Write-Step ($step , $msg ) {
3043 Write-Host " `n ========================================" - ForegroundColor Cyan
3144 Write-Host " [$step ] $msg " - ForegroundColor Cyan
@@ -68,28 +81,59 @@ Push-Location $scriptDir
6881try {
6982 $global :stepCounter = 1
7083
71- # 1. Type-check
84+ # 0. Prerequisites
85+ Invoke-BuildStep " Check Prerequisites" {
86+ $nodeVer = & node -- version 2>&1
87+ if ($LASTEXITCODE -ne 0 ) { throw " Node.js not found. Install Node.js 20.x" }
88+ Write-Host " Node.js: $nodeVer " - ForegroundColor DarkGray
89+
90+ $pnpmVer = & pnpm -- version 2>&1
91+ if ($LASTEXITCODE -ne 0 ) {
92+ Write-Host " pnpm not found, enabling via corepack..." - ForegroundColor DarkYellow
93+ & corepack enable 2>&1
94+ $pnpmVer = & pnpm -- version 2>&1
95+ if ($LASTEXITCODE -ne 0 ) { throw " pnpm not available. Run: corepack enable" }
96+ }
97+ Write-Host " pnpm: $pnpmVer " - ForegroundColor DarkGray
98+
99+ $gitVer = & git -- version 2>&1
100+ if ($LASTEXITCODE -ne 0 ) { throw " Git not found" }
101+ Write-Host " Git: $gitVer " - ForegroundColor DarkGray
102+ }
103+
104+ # 1. Install dependencies
105+ if (-not $SkipInstall ) {
106+ Invoke-BuildStep " Install Dependencies" {
107+ & pnpm install -- frozen- lockfile
108+ }
109+ } else {
110+ Write-Host " [SKIP] Install dependencies" - ForegroundColor DarkYellow
111+ }
112+
113+ # 2. Type-check
72114 if (-not $SkipTypes ) {
73115 Invoke-BuildStep " TypeScript Type-Check" {
74- pnpm check- types
116+ Push-Location src
117+ try { & pnpm run check- types }
118+ finally { Pop-Location }
75119 }
76120 } else {
77121 Write-Host " [SKIP] TypeScript type-check" - ForegroundColor DarkYellow
78122 }
79123
80- # 2 . Tests
124+ # 3 . Tests
81125 if (-not $SkipTests ) {
82126 Invoke-BuildStep " Unit Tests" {
83- pnpm test
127+ & pnpm test
84128 }
85129 } else {
86130 Write-Host " [SKIP] Unit tests" - ForegroundColor DarkYellow
87131 }
88132
89- # 3 . VSIX
133+ # 4 . VSIX
90134 if (-not $SkipVsix ) {
91135 Invoke-BuildStep " VSIX Packaging" {
92- pnpm vsix
136+ & pnpm vsix
93137 }
94138 } else {
95139 Write-Host " [SKIP] VSIX packaging" - ForegroundColor DarkYellow
@@ -104,10 +148,16 @@ try {
104148 $vsix = Get-ChildItem - Path " bin\*.vsix" - ErrorAction SilentlyContinue | Sort-Object LastWriteTime - Descending | Select-Object - First 1
105149 if ($vsix ) {
106150 $sizeMB = [math ]::Round($vsix.Length / 1 MB , 2 )
107- Write-Host " `n Output: bin\$ ( $vsix.Name ) ($sizeMB MB)" - ForegroundColor Green
151+ $hash = (Get-FileHash - Path $vsix.FullName - Algorithm SHA256).Hash
152+ Write-Host " `n Artifact Details:" - ForegroundColor Green
153+ Write-Host " Path: $ ( $vsix.FullName ) " - ForegroundColor White
154+ Write-Host " Size: $ ( $vsix.Length ) bytes ($sizeMB MB)" - ForegroundColor White
155+ Write-Host " SHA256: $hash " - ForegroundColor White
156+ } else {
157+ Write-Host " `n [WARN] No VSIX found in bin/" - ForegroundColor DarkYellow
108158 }
109159 }
110160}
111161finally {
112162 Pop-Location
113- }
163+ }
0 commit comments