summaryrefslogtreecommitdiff
path: root/build.ps1
blob: 04966a15c347d2470fcb41772ea1f93d0679d623 (plain)
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
# Packages the extension into a ZIP for distribution.
# Excludes: tests/, doc/, ollama-js/, tools/, build artifacts, .git
# Requires only PowerShell (Compress-Archive). No Node.js.

$ErrorActionPreference = 'Stop'

$include = @(
  'manifest.json',
  'icons',
  'src'
)

$outDir = 'dist'
$outZip = Join-Path $outDir 'ollama-translations.zip'

if (-not (Test-Path $outDir)) {
  New-Item -ItemType Directory -Path $outDir | Out-Null
}

if (Test-Path $outZip) {
  Remove-Item $outZip -Force
}

# Stage files in a temp folder so the zip has a clean root.
$stage = Join-Path ([System.IO.Path]::GetTempPath()) ("ollama-translations-" + [System.Guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory -Path $stage | Out-Null

try {
  foreach ($item in $include) {
    Copy-Item -Recurse -Force $item (Join-Path $stage $item)
  }
  Compress-Archive -Path (Join-Path $stage '*') -DestinationPath $outZip
  Write-Host "Created $outZip"
} finally {
  Remove-Item -Recurse -Force $stage
}