支持windows系统的安装

This commit is contained in:
徐文彬
2025-12-06 23:40:24 +08:00
parent 017ad5e4d9
commit 90f9a131fe
2 changed files with 2 additions and 66 deletions

View File

@@ -1,66 +0,0 @@
[CmdletBinding()]
param()
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'Continue'
$tempFile = $null
function Get-Architecture {
$arch = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE }
switch ($arch.ToLower()) {
'amd64' { 'amd64' }
'x86' { throw 'Unsupported architecture: x86 (64-bit Windows is required).' }
'arm64' { 'arm64' }
'aarch64' { 'arm64' }
default { throw "Unsupported architecture: $arch" }
}
}
function Write-Step {
param([string] $Status, [int] $Percent)
Write-Progress -Activity 'Installing codex-wrapper' -Status $Status -PercentComplete $Percent
Write-Host $Status
}
try {
Write-Step 'Detecting CPU architecture...' 5
$arch = Get-Architecture
$url = "https://github.com/cexll/myclaude/releases/latest/download/codex-wrapper-windows-$arch.exe"
$tempFile = Join-Path ([IO.Path]::GetTempPath()) "codex-wrapper-$arch.exe"
$homeBin = Join-Path $HOME 'bin'
$destination = Join-Path $homeBin 'codex-wrapper.exe'
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Write-Step "Downloading codex-wrapper from $url ..." 25
Invoke-WebRequest -Uri $url -OutFile $tempFile -UseBasicParsing -ErrorAction Stop
Write-Step "Installing to $destination ..." 65
New-Item -ItemType Directory -Path $homeBin -Force | Out-Null
Move-Item -LiteralPath $tempFile -Destination $destination -Force
Write-Step 'Verifying installation...' 90
& $destination --version | Out-Null
Write-Step 'codex-wrapper installed successfully.' 100
Write-Progress -Activity 'Installing codex-wrapper' -Completed -Status 'Done'
Write-Host "Installed to $destination"
$normalizedBin = ($homeBin.TrimEnd('\') -replace '/','\').ToLower()
$pathEntries = ($env:PATH -split ';') | Where-Object { $_ } | ForEach-Object { ($_ -replace '/','\').TrimEnd('\').ToLower() }
if (-not ($pathEntries -contains $normalizedBin)) {
Write-Warning "$homeBin is not in your PATH."
Write-Host 'Add it permanently with:'
Write-Host " [Environment]::SetEnvironmentVariable('PATH', '$homeBin;' + [Environment]::GetEnvironmentVariable('PATH','User'), 'User')"
Write-Host 'Then restart your shell to pick up the updated PATH.'
}
} catch {
Write-Progress -Activity 'Installing codex-wrapper' -Completed -Status 'Failed'
Write-Error "Installation failed: $($_.Exception.Message)"
exit 1
} finally {
if ($tempFile -and (Test-Path $tempFile)) {
Remove-Item -LiteralPath $tempFile -Force -ErrorAction SilentlyContinue
}
}

View File

@@ -285,6 +285,8 @@ def op_run_command(op: Dict[str, Any], ctx: Dict[str, Any]) -> None:
env[key] = value.replace("${install_dir}", str(ctx["install_dir"]))
command = op.get("command", "")
if sys.platform == "win32" and command.strip() == "bash install.sh":
command = "cmd /c install.bat"
result = subprocess.run(
command,
shell=True,