Route build outputs to dist/ and commit release artifacts

build.ps1 now always packages the .vsix and writes both artifacts to
dist/. Added .vscodeignore so the .vsix excludes Go source, TS source,
and other dev-only files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 01:20:54 +08:00
parent f123cbfc4a
commit 1cfdcb03ab
5 changed files with 42 additions and 39 deletions

1
.gitignore vendored
View File

@@ -93,7 +93,6 @@ out
# Nuxt.js build / generate output # Nuxt.js build / generate output
.nuxt .nuxt
dist
# Gatsby files # Gatsby files
.cache/ .cache/

11
.vscodeignore Normal file
View File

@@ -0,0 +1,11 @@
.git/**
.vscode/**
.gitignore
standalone/**
dist/**
src/**
out/**/*.map
build.ps1
tsconfig.json
**/*.vsix
node_modules/.cache/**

View File

@@ -1,22 +1,15 @@
<# <#
.SYNOPSIS .SYNOPSIS
Builds both the VSCode extension and the standalone Windows exe. Builds both the VSCode extension (.vsix) and the standalone Windows exe.
Both artifacts land in dist/.
.DESCRIPTION
- Extension: tsc compile -> out/extension.js
- Standalone: go build -> standalone/hpl-toolbox.exe (single static binary)
Optionally packages the extension as a .vsix with -Package.
.EXAMPLE .EXAMPLE
.\build.ps1 .\build.ps1
.\build.ps1 -Package
.\build.ps1 -Standalone # Skip the extension; build only the exe .\build.ps1 -Standalone # Skip the extension; build only the exe
.\build.ps1 -Extension # Skip the standalone; build only the extension .\build.ps1 -Extension # Skip the standalone; build only the .vsix
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[switch]$Package,
[switch]$Extension, [switch]$Extension,
[switch]$Standalone [switch]$Standalone
) )
@@ -31,6 +24,9 @@ if (-not $Extension -and -not $Standalone) {
$Standalone = $true $Standalone = $true
} }
$distDir = Join-Path $repoRoot "dist"
New-Item -ItemType Directory -Path $distDir -Force | Out-Null
function Write-Step($msg) { function Write-Step($msg) {
Write-Host "" Write-Host ""
Write-Host "==> $msg" -ForegroundColor Cyan Write-Host "==> $msg" -ForegroundColor Cyan
@@ -58,10 +54,10 @@ if (-not (Get-Command go -ErrorAction SilentlyContinue)) {
$summary = @() $summary = @()
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# VSCode extension # VSCode extension -> .vsix
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if ($Extension) { if ($Extension) {
Write-Step "Building VSCode extension (tsc)" Write-Step "Building VSCode extension"
if (-not (Test-Path "node_modules")) { if (-not (Test-Path "node_modules")) {
Write-Host " node_modules missing - running npm install" -ForegroundColor Yellow Write-Host " node_modules missing - running npm install" -ForegroundColor Yellow
npm install npm install
@@ -69,36 +65,32 @@ if ($Extension) {
} }
npm run compile npm run compile
if ($LASTEXITCODE -ne 0) { Write-Error "tsc compile failed"; exit 1 } if ($LASTEXITCODE -ne 0) { Write-Error "tsc compile failed"; exit 1 }
$extOut = Join-Path $repoRoot "out\extension.js"
$summary += [pscustomobject]@{
Artifact = "Extension (out/extension.js)"
Size = Get-FileSize $extOut
}
if ($Package) { Write-Step "Packaging .vsix -> dist/"
Write-Step "Packaging .vsix" $vsixTargetDir = $distDir
if (-not (Get-Command vsce -ErrorAction SilentlyContinue)) { if (Get-Command vsce -ErrorAction SilentlyContinue) {
Write-Host " vsce not found - installing via npx (one-time)" -ForegroundColor Yellow vsce package --out $vsixTargetDir
npx --yes @vscode/vsce package
} else { } else {
vsce package Write-Host " vsce not found - using npx @vscode/vsce" -ForegroundColor Yellow
npx --yes @vscode/vsce package --out $vsixTargetDir
} }
if ($LASTEXITCODE -ne 0) { Write-Error "vsce package failed"; exit 1 } if ($LASTEXITCODE -ne 0) { Write-Error "vsce package failed"; exit 1 }
$vsix = Get-ChildItem -Path $repoRoot -Filter "*.vsix" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
$vsix = Get-ChildItem -Path $distDir -Filter "*.vsix" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($vsix) { if ($vsix) {
$summary += [pscustomobject]@{ $summary += [pscustomobject]@{
Artifact = "Extension ($($vsix.Name))" Artifact = $vsix.Name
Path = "dist\$($vsix.Name)"
Size = Get-FileSize $vsix.FullName Size = Get-FileSize $vsix.FullName
} }
} }
} }
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Standalone Windows exe # Standalone Windows exe -> dist/hpl-toolbox.exe
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if ($Standalone) { if ($Standalone) {
Write-Step "Building standalone exe (go build)" Write-Step "Building standalone exe -> dist/"
Push-Location (Join-Path $repoRoot "standalone") Push-Location (Join-Path $repoRoot "standalone")
try { try {
# If rsrc.syso is missing (e.g. fresh clone before icon embedding), regenerate. # If rsrc.syso is missing (e.g. fresh clone before icon embedding), regenerate.
@@ -112,13 +104,14 @@ if ($Standalone) {
} }
} }
go build -ldflags="-s -w -H windowsgui" -trimpath -o hpl-toolbox.exe . $exeOut = Join-Path $distDir "hpl-toolbox.exe"
go build -ldflags="-s -w -H windowsgui" -trimpath -o $exeOut .
if ($LASTEXITCODE -ne 0) { Write-Error "go build failed"; exit 1 } if ($LASTEXITCODE -ne 0) { Write-Error "go build failed"; exit 1 }
$exePath = Join-Path (Get-Location) "hpl-toolbox.exe"
$summary += [pscustomobject]@{ $summary += [pscustomobject]@{
Artifact = "Standalone (standalone/hpl-toolbox.exe)" Artifact = "hpl-toolbox.exe"
Size = Get-FileSize $exePath Path = "dist\hpl-toolbox.exe"
Size = Get-FileSize $exeOut
} }
} finally { } finally {
Pop-Location Pop-Location

BIN
dist/hpl-toolbox.exe vendored Normal file

Binary file not shown.