Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,28 @@ code --install-extension build_extension/plecs-diff-viewer-0.2.0.vsix

### 3. Build the VSIX package:

**Mac/Linux:**
```bash
./build.sh
```

**Windows (PowerShell):**
```powershell
.\build.ps1
```

Optional: set a temporary package version for that build only:

**Mac/Linux:**
```bash
./build.sh --version 0.2.0
```

**Windows:**
```powershell
.\build.ps1 -version 0.2.0
```


## How To Use

Expand Down
67 changes: 67 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<#
.SYNOPSIS
Builds the PLECS Diff Viewer extension into a VSIX package.

.DESCRIPTION
This script is the Windows equivalent of build.sh.
It installs dependencies, builds the code, and packages it using vsce.

.PARAMETER version
Override extension version only for this build (e.g., 0.2.0)
#>
param (
[string]$version = ""
)

$ErrorActionPreference = "Stop"

$scriptDir = $PSScriptRoot
$outputDir = Join-Path $scriptDir "build_extension"
$packageJsonPath = Join-Path $scriptDir "package.json"
$backupJsonPath = Join-Path $scriptDir "package.json.bak"

if ($version -and $version -notmatch '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$') {
Write-Error "Invalid version '$version'. Expected format like 0.2.0"
exit 1
}

try {
if ($version) {
Write-Host "Using build version override: $version"
Copy-Item $packageJsonPath $backupJsonPath -Force
# Update version using node to preserve formatting
node -e "const fs=require('fs'); const p=process.argv[1]; const v=process.argv[2]; const pkg=JSON.parse(fs.readFileSync(p,'utf8')); pkg.version=v; fs.writeFileSync(p, JSON.stringify(pkg, null, 2) + '\n');" "$packageJsonPath" "$version"
}

# Clean output directory
if (Test-Path $outputDir) {
Remove-Item -Path $outputDir -Recurse -Force
}
New-Item -Path $outputDir -ItemType Directory -Force | Out-Null

# Install dependencies
Write-Host "Installing dependencies..."
& npm --prefix "$scriptDir" install

# Bundle TypeScript with esbuild
Write-Host "Building extension..."
& npm --prefix "$scriptDir" run build -- --minify

# Package as VSIX
Write-Host "Packaging VSIX..."

# Needs npx.cmd on windows
& npx.cmd --yes @vscode/vsce package --allow-missing-repository --readme-path "README.md" --out "$outputDir/" --baseImagesUrl "https://github.com/jaeyeon302/PLECS-diff/raw/main/"


$vsixFile = Get-ChildItem -Path "$outputDir\*.vsix" | Select-Object -First 1
if ($vsixFile) {
Write-Host "`nBuild complete: build_extension/$($vsixFile.Name)"
Write-Host "Install with: code --install-extension build_extension/$($vsixFile.Name)"
}
}
finally {
if (Test-Path $backupJsonPath) {
Move-Item $backupJsonPath $packageJsonPath -Force
}
}
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ npm --prefix "$SCRIPT_DIR" run build -- --minify

# Package as VSIX
echo "Packaging VSIX..."
npx @vscode/vsce package --allow-missing-repository --readme-path "README.md" --out "$OUTPUT_DIR/"
npx --yes @vscode/vsce package --allow-missing-repository --readme-path "README.md" --out "$OUTPUT_DIR/" --baseImagesUrl "https://github.com/jaeyeon302/PLECS-diff/raw/main/"


VSIX_FILE=$(ls "$OUTPUT_DIR"/*.vsix 2>/dev/null | head -1)
echo ""
Expand Down
Binary file modified build_extension/plecs-diff-viewer-0.2.1.vsix
Binary file not shown.
Loading