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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist/
out/
*.vsix
.vscode-test/
.socket/
media/*.js
media/*.css
media/*.map
Expand Down
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ esbuild.js
test/**
docs/open-collection-gap-analysis/**
vitest.config.ts
scripts/build-and-install.ps1
examples/demo-api/fixtures/*.key
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@
"vscode:prepublish": "npm run build",
"build:schema": "node schema/build-schema.js",
"build": "npm run build:schema && node esbuild.js --production",
"install:local": "powershell -ExecutionPolicy Bypass -File scripts/build-and-install.ps1",
"watch": "node esbuild.js --watch",
"test": "vitest run",
"test:watch": "vitest",
Expand Down
81 changes: 81 additions & 0 deletions scripts/build-and-install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
param(
[string]$OutputPath,
[string]$CodeCommand,
[switch]$SkipNpmCi
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

function Invoke-Checked {
param(
[string]$Label,
[scriptblock]$Command
)

Write-Host ""
Write-Host "==> $Label"
& $Command
if ($LASTEXITCODE -ne 0) {
throw "$Label failed with exit code $LASTEXITCODE"
}
}

$repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
Push-Location $repoRoot

try {
if ($SkipNpmCi) {
if (-not (Test-Path -LiteralPath 'node_modules')) {
throw 'node_modules was not found. Run without -SkipNpmCi to install dependencies before packaging.'
}
Write-Host ""
Write-Host "==> Skipping dependency install"
} else {
Invoke-Checked 'Install dependencies' { npm ci }
}

$packageJson = Get-Content -LiteralPath 'package.json' -Raw | ConvertFrom-Json
$version = [string]$packageJson.version

if ([string]::IsNullOrWhiteSpace($OutputPath)) {
$OutputPath = Join-Path $env:TEMP "missio-$version-local.vsix"
}

$resolvedOutputPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputPath)
$outputDir = Split-Path -Parent $resolvedOutputPath
if (-not (Test-Path -LiteralPath $outputDir)) {
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
}
if (Test-Path -LiteralPath $resolvedOutputPath) {
Remove-Item -LiteralPath $resolvedOutputPath -Force
}

if ([string]::IsNullOrWhiteSpace($CodeCommand)) {
$code = Get-Command code.cmd -ErrorAction SilentlyContinue
if (-not $code) {
$code = Get-Command code -ErrorAction SilentlyContinue
}
if (-not $code) {
throw 'Could not find VS Code CLI. Add code.cmd/code to PATH or pass -CodeCommand <path>.'
}
$CodeCommand = $code.Source
}

Invoke-Checked 'Package VSIX (runs npm run vscode:prepublish)' {
npx @vscode/vsce package --out $resolvedOutputPath
}

Invoke-Checked 'Install VSIX into VS Code' {
& $CodeCommand --install-extension $resolvedOutputPath --force
}

Write-Host ""
Write-Host "==> Installed extension"
& $CodeCommand --list-extensions --show-versions | Select-String -Pattern '^missio\.missio@'

Write-Host ""
Write-Host "VSIX: $resolvedOutputPath"
} finally {
Pop-Location
}
Loading