-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
42 lines (35 loc) · 1.5 KB
/
Copy pathinstall.ps1
File metadata and controls
42 lines (35 loc) · 1.5 KB
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
37
38
39
40
41
42
param(
[string]$ConfigDir = (Join-Path $HOME ".config\opencode"),
[switch]$Force
)
$ErrorActionPreference = "Stop"
$archiveUrl = if ($env:OPENCODE_MEMORY_KIT_ARCHIVE_URL) { $env:OPENCODE_MEMORY_KIT_ARCHIVE_URL } else { "https://github.com/alejodevelop/opencode-memory-kit/archive/refs/heads/main.zip" }
$sourceDir = $env:OPENCODE_MEMORY_KIT_SOURCE_DIR
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ("opencode-memory-kit-" + [Guid]::NewGuid().ToString("N"))
$archivePath = Join-Path $tempDir "opencode-memory-kit.zip"
$extractDir = Join-Path $tempDir "extract"
try {
if ($sourceDir) {
$repoDir = Get-Item -LiteralPath $sourceDir
}
else {
New-Item -ItemType Directory -Force -Path $extractDir | Out-Null
Write-Host "Downloading OpenCode memory kit..."
Invoke-WebRequest -UseBasicParsing -Uri $archiveUrl -OutFile $archivePath
Expand-Archive -Path $archivePath -DestinationPath $extractDir -Force
$repoDir = Get-ChildItem -Directory $extractDir | Select-Object -First 1
if (-not $repoDir) {
throw "Could not locate extracted kit contents."
}
}
$installScript = Join-Path $repoDir.FullName "scripts\install-global.ps1"
if (-not (Test-Path $installScript)) {
throw "Could not locate install-global.ps1 in the downloaded kit."
}
& $installScript -ConfigDir $ConfigDir -Force:$Force
}
finally {
if (Test-Path $tempDir) {
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}
}