feat(update): reuse saved choices with quick mode

This commit is contained in:
fraujulian committed 2026-09-16 19:18:25 +02:00
1 parent f0fd4349c2
commit e62609d433
3 files changed
+51 -13

No files matched your search

+3 -3
View File
@@ -9,14 +9,14 @@ function Invoke-PluginCommand {
if ($DryRun) { if (-not $Summary) { Write-Output "DRYRUN $display" }; return } if ($DryRun) { if (-not $Summary) { Write-Output "DRYRUN $display" }; return }
$resolvedCommand = Get-Command $Command -ErrorAction Stop $resolvedCommand = Get-Command $Command -ErrorAction Stop
if (-not $Summary) { if (-not $Summary) {
& $resolvedCommand @Arguments if ($script:PluginNonInteractive) { $null | & $resolvedCommand @Arguments } else { & $resolvedCommand @Arguments }
if ($LASTEXITCODE -ne 0) { throw "Plugin command failed: $display" } if ($LASTEXITCODE -ne 0) { throw "Plugin command failed: $display" }
return return
} }
$previousPreference = $ErrorActionPreference $previousPreference = $ErrorActionPreference
try { try {
$ErrorActionPreference = 'Continue' $ErrorActionPreference = 'Continue'
$output = @(& $resolvedCommand @Arguments 2>&1) $output = if ($script:PluginNonInteractive) { @($null | & $resolvedCommand @Arguments 2>&1) } else { @(& $resolvedCommand @Arguments 2>&1) }
$exitCode = $LASTEXITCODE $exitCode = $LASTEXITCODE
} finally { $ErrorActionPreference = $previousPreference } } finally { $ErrorActionPreference = $previousPreference }
if (-not $Summary -or $env:AI_CONFIG_VERBOSE -eq '1') { $output | Write-Output } elseif ($exitCode -eq 0) { $output | Where-Object { "$_" -match '(?i)warn|error|fail|deprecat' } } if (-not $Summary -or $env:AI_CONFIG_VERBOSE -eq '1') { $output | Write-Output } elseif ($exitCode -eq 0) { $output | Where-Object { "$_" -match '(?i)warn|error|fail|deprecat' } }
@@ -60,7 +60,7 @@ function Ensure-CodexMarketplace {
$previousErrorActionPreference = $ErrorActionPreference $previousErrorActionPreference = $ErrorActionPreference
try { try {
$ErrorActionPreference = 'Continue' $ErrorActionPreference = 'Continue'
$output = @(& codex plugin marketplace add $Source 2>&1) $output = if ($script:PluginNonInteractive) { @($null | & codex plugin marketplace add $Source 2>&1) } else { @(& codex plugin marketplace add $Source 2>&1) }
$exitCode = $LASTEXITCODE $exitCode = $LASTEXITCODE
} catch { } catch {
$output = @($_) $output = @($_)
+28 -4
View File
@@ -1,6 +1,7 @@
[CmdletBinding()] [CmdletBinding()]
param( param(
[switch]$DryRun, [switch]$DryRun,
[switch]$Quick,
[ValidateSet('Codex','Claude','Both')][string]$Client, [ValidateSet('Codex','Claude','Both')][string]$Client,
[ValidateSet('Windows','Linux')][string]$Platform, [ValidateSet('Windows','Linux')][string]$Platform,
[switch]$Summary [switch]$Summary
@@ -10,12 +11,19 @@ $root = Split-Path $PSScriptRoot -Parent
. (Join-Path $PSScriptRoot 'lib/plugins.ps1') . (Join-Path $PSScriptRoot 'lib/plugins.ps1')
. (Join-Path $PSScriptRoot 'lib/manifest.ps1') . (Join-Path $PSScriptRoot 'lib/manifest.ps1')
. (Join-Path $PSScriptRoot 'lib/install-targets.ps1') . (Join-Path $PSScriptRoot 'lib/install-targets.ps1')
. (Join-Path $PSScriptRoot 'lib/selection-state.ps1')
$homePath = [Environment]::GetFolderPath('UserProfile')
if ($Quick) {
$saved = Read-UpdateSelection -HomePath $homePath -RepositoryRoot $root
if (-not $Platform) { $Platform = $saved.platform }
if (-not $Client) { $Client = $saved.client }
}
$Platform = Read-InstallPlatform -Platform $Platform $Platform = Read-InstallPlatform -Platform $Platform
$platform = $Platform.ToLowerInvariant() $platform = $Platform.ToLowerInvariant()
$Client = Read-InstallClient -Client $Client $Client = Read-InstallClient -Client $Client
$homePath = [Environment]::GetFolderPath('UserProfile')
if (-not $DryRun -and -not (Test-AllManifestsPresent (Get-InstallDestinations -HomePath $homePath -Client $Client))) { if (-not $DryRun -and -not (Test-AllManifestsPresent (Get-InstallDestinations -HomePath $homePath -Client $Client))) {
throw 'Not installed, use the install script.' throw 'Not installed, use the install script.'
} }
@@ -31,13 +39,29 @@ $shellCommand = 'pwsh -NoProfile -ExecutionPolicy Bypass -File'
$windowsShellCommand = 'powershell -NoProfile -ExecutionPolicy Bypass -File' $windowsShellCommand = 'powershell -NoProfile -ExecutionPolicy Bypass -File'
if ([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT) { $shellCommand = $windowsShellCommand } if ([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT) { $shellCommand = $windowsShellCommand }
$plugins = if ($Quick) {
$entries = @(Get-ConfiguredPluginEntries -RepositoryRoot $root)
@{ Selected = @($entries | Where-Object { $saved.selected -contains $_.name }); Deselected = @($entries | Where-Object { $saved.deselected -contains $_.name }) }
} else {
Select-ConfiguredPlugins -RepositoryRoot $root -Client $Client -Mode 'Update' -DryRun:$DryRun
}
foreach ($item in (Get-InstallTargets -Generated $generated -HomePath $homePath -Platform $platform -Client $Client)) { foreach ($item in (Get-InstallTargets -Generated $generated -HomePath $homePath -Platform $platform -Client $Client)) {
Sync-ManagedDestination -Source $item.Source -Destination $item.Destination -Stamp $stamp ` Sync-ManagedDestination -Source $item.Source -Destination $item.Destination -Stamp $stamp `
-AiConfigRoot $item.Destination.Replace('\','/') -ShellCommand $shellCommand -WindowsShellCommand $windowsShellCommand -DryRun:$DryRun -Summary:$Summary -AiConfigRoot $item.Destination.Replace('\','/') -ShellCommand $shellCommand -WindowsShellCommand $windowsShellCommand -DryRun:$DryRun -Summary:$Summary
} }
$plugins = Select-ConfiguredPlugins -RepositoryRoot $root -Client $Client -Mode 'Update' -DryRun:$DryRun $previousPluginNonInteractive = $script:PluginNonInteractive
Install-ConfiguredPlugins -RepositoryRoot $root -Client $Client -DryRun:$DryRun -Update -Summary:$Summary -Entries $plugins.Selected $previousCI = $env:CI
Uninstall-DeselectedPlugins -Entries $plugins.Deselected -Client $Client -DryRun:$DryRun -Summary:$Summary try {
$script:PluginNonInteractive = [bool]$Quick
if ($Quick) { $env:CI = 'true' }
Install-ConfiguredPlugins -RepositoryRoot $root -Client $Client -DryRun:$DryRun -Update -Summary:$Summary -Entries $plugins.Selected
Uninstall-DeselectedPlugins -Entries $plugins.Deselected -Client $Client -DryRun:$DryRun -Summary:$Summary
} finally {
$script:PluginNonInteractive = $previousPluginNonInteractive
$env:CI = $previousCI
}
if (-not $DryRun) { Save-UpdateSelection -HomePath $homePath -RepositoryRoot $root -Platform $Platform -Client $Client -Plugins $plugins }
if ($Summary) { Write-Output "Update: PASS | $Client, $Platform$(if ($DryRun) { ', dry-run' })" } else { Write-Output ($(if ($DryRun) { 'PASS update dry-run' } else { 'PASS update' })) } if ($Summary) { Write-Output "Update: PASS | $Client, $Platform$(if ($DryRun) { ', dry-run' })" } else { Write-Output ($(if ($DryRun) { 'PASS update dry-run' } else { 'PASS update' })) }
exit 0 exit 0
+20 -6
View File
@@ -2,12 +2,14 @@
set -euo pipefail set -euo pipefail
dry_run=false dry_run=false
quick=false
client="" client=""
platform="" platform=""
summary=false summary=false
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
--dry-run) dry_run=true; shift ;; --dry-run) dry_run=true; shift ;;
--quick) quick=true; shift ;;
--summary) summary=true; shift ;; --summary) summary=true; shift ;;
--client) client=${2:?--client requires a value}; shift 2 ;; --client) client=${2:?--client requires a value}; shift 2 ;;
--platform) platform=${2:?--platform requires a value}; shift 2 ;; --platform) platform=${2:?--platform requires a value}; shift 2 ;;
@@ -19,11 +21,16 @@ root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
. "$root/scripts/lib/plugins.sh" . "$root/scripts/lib/plugins.sh"
. "$root/scripts/lib/manifest.sh" . "$root/scripts/lib/manifest.sh"
. "$root/scripts/lib/install-targets.sh" . "$root/scripts/lib/install-targets.sh"
. "$root/scripts/lib/selection-state.sh"
home_path=${HOME:?HOME is required}
selected_plugins=()
deselected_plugins=()
if [ "$quick" = true ]; then read_update_selection; fi
platform=$(read_install_platform "$platform") platform=$(read_install_platform "$platform")
client=$(read_install_client "$client") client=$(read_install_client "$client")
home_path=${HOME:?HOME is required}
if [ "$dry_run" = false ]; then if [ "$dry_run" = false ]; then
mapfile -t destinations < <(get_install_destinations "$home_path" "$client") mapfile -t destinations < <(get_install_destinations "$home_path" "$client")
if ! all_manifests_present "${destinations[@]}"; then if ! all_manifests_present "${destinations[@]}"; then
@@ -42,17 +49,24 @@ stamp=$(date +%Y%m%d-%H%M%S)
shell_command=bash shell_command=bash
windows_shell_command='powershell -NoProfile -ExecutionPolicy Bypass -File' windows_shell_command='powershell -NoProfile -ExecutionPolicy Bypass -File'
if [ "$quick" = false ]; then
select_configured_plugins "$root" "$client" Update "$dry_run" selected_plugins deselected_plugins
fi
while IFS='|' read -r source destination; do while IFS='|' read -r source destination; do
ai_config_root=$destination ai_config_root=$destination
command -v cygpath >/dev/null && ai_config_root=$(cygpath -m "$destination") command -v cygpath >/dev/null && ai_config_root=$(cygpath -m "$destination")
sync_managed_destination "$source" "$destination" "$stamp" "$ai_config_root" "$shell_command" "$windows_shell_command" "$dry_run" "$summary" sync_managed_destination "$source" "$destination" "$stamp" "$ai_config_root" "$shell_command" "$windows_shell_command" "$dry_run" "$summary"
done < <(get_install_targets "$generated" "$home_path" "$platform" "$client") done < <(get_install_targets "$generated" "$home_path" "$platform" "$client")
selected_plugins=() if [ "$quick" = true ]; then
deselected_plugins=() CI=true install_configured_plugins "$root" "$client" "$dry_run" true selected_plugins "$summary" </dev/null
select_configured_plugins "$root" "$client" Update "$dry_run" selected_plugins deselected_plugins CI=true uninstall_deselected_plugins "$root" "$client" "$dry_run" deselected_plugins "$summary" </dev/null
install_configured_plugins "$root" "$client" "$dry_run" true selected_plugins "$summary" else
uninstall_deselected_plugins "$root" "$client" "$dry_run" deselected_plugins "$summary" install_configured_plugins "$root" "$client" "$dry_run" true selected_plugins "$summary"
uninstall_deselected_plugins "$root" "$client" "$dry_run" deselected_plugins "$summary"
fi
if [ "$dry_run" = false ]; then save_update_selection; fi
if [ "$summary" = true ]; then if [ "$summary" = true ]; then
suffix= suffix=