45 lines
2.3 KiB
PowerShell
45 lines
2.3 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[switch]$DryRun,
|
|
[ValidateSet('Codex','Claude','Both')][string]$Client,
|
|
[ValidateSet('Windows','Linux')][string]$Platform,
|
|
[switch]$Summary
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$root = Split-Path $PSScriptRoot -Parent
|
|
. (Join-Path $PSScriptRoot 'lib/plugins.ps1')
|
|
. (Join-Path $PSScriptRoot 'lib/manifest.ps1')
|
|
. (Join-Path $PSScriptRoot 'lib/install-targets.ps1')
|
|
. (Join-Path $PSScriptRoot 'lib/selection-state.ps1')
|
|
|
|
$Platform = Read-InstallPlatform -Platform $Platform
|
|
$platform = $Platform.ToLowerInvariant()
|
|
$Client = Read-InstallClient -Client $Client
|
|
|
|
$homePath = [Environment]::GetFolderPath('UserProfile')
|
|
if (-not $DryRun -and (Test-AnyManifestPresent (Get-InstallDestinations -HomePath $homePath -Client $Client))) {
|
|
throw 'Already installed, use the update script.'
|
|
}
|
|
|
|
$buildScript = Join-Path $PSScriptRoot 'build.ps1'
|
|
& $buildScript -Summary:$Summary
|
|
if (-not $?) { throw 'Build failed. Installation was not started.' }
|
|
$generated = Join-Path $root 'generated'
|
|
if (-not (Test-Path $generated)) { throw 'Generated output is missing after a successful build.' }
|
|
|
|
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
|
|
$shellCommand = 'pwsh -NoProfile -ExecutionPolicy Bypass -File'
|
|
$windowsShellCommand = 'powershell -NoProfile -ExecutionPolicy Bypass -File'
|
|
if ([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT) { $shellCommand = $windowsShellCommand }
|
|
|
|
foreach ($item in (Get-InstallTargets -Generated $generated -HomePath $homePath -Platform $platform -Client $Client)) {
|
|
Sync-ManagedDestination -Source $item.Source -Destination $item.Destination -Stamp $stamp `
|
|
-AiConfigRoot $item.Destination.Replace('\','/') -ShellCommand $shellCommand -WindowsShellCommand $windowsShellCommand -DryRun:$DryRun -Summary:$Summary
|
|
}
|
|
|
|
$plugins = Select-ConfiguredPlugins -RepositoryRoot $root -Client $Client -Mode 'Install' -DryRun:$DryRun
|
|
Install-ConfiguredPlugins -RepositoryRoot $root -Client $Client -DryRun:$DryRun -Summary:$Summary -Entries $plugins.Selected
|
|
if (-not $DryRun) { Save-UpdateSelection -HomePath $homePath -RepositoryRoot $root -Platform $Platform -Client $Client -Plugins $plugins }
|
|
if ($Summary) { Write-Output "Install: PASS | $Client, $Platform$(if ($DryRun) { ', dry-run' })" } else { Write-Output ($(if ($DryRun) { 'PASS install dry-run' } else { 'PASS install' })) }
|
|
exit 0
|