Force config replacement during setup by default
Config Central CI Config Central passed all CI integrity checks.
Beffroi/config-central/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-10-19 13:47:46 +02:00
parent f8b4aa0937
commit efc14f56c7
6 changed files with 43 additions and 3 deletions

View File

@ -14,7 +14,8 @@ irm 'https://proxy.dandaedre.com/gitea/Beffroi/config-central/raw/branch/main/in
The bundled machine profile is `beffroi-laptop`, selected automatically. If you
add more machines, setup matches the computer name or asks you to choose one. It installs
Git, PowerShell 7, and the declared software, then applies the configs. Approve
administrator prompts when needed. Rerun this command to repair setup.
administrator prompts when needed. Existing managed settings are backed up and
replaced with repository versions. Rerun this command to repair setup.
Requires Windows 10 1809 or newer, Windows 11, or Windows Server 2025, with
internet access and support for WinGet.

View File

@ -127,3 +127,4 @@ open until it is run on disposable machines with the required account setups.
- [x] Use PowerShell 7-compatible ACL application for elevation requests; add Windows-only permission regression tests (Windows execution pending).
- [x] Retry an upgrade with an install when WinGet reports no matching installed package, preserving scope and testing bounded retries.
- [x] Make web config updates force replacement with backups by default, with an explicit opt-out.
- [x] Apply the force-by-default policy during install/bootstrap too, with a preserve-local-configs opt-out.

View File

@ -6,6 +6,7 @@ param(
[ValidatePattern('^[A-Za-z0-9._/-]+$')][string]$Branch = 'main',
[string]$Checkout = (Join-Path $env:LOCALAPPDATA 'ConfigCentral\repository'),
[switch]$SkipApply,
[switch]$PreserveLocalConfigs,
[switch]$RepairWinGetOnly
)
@ -170,6 +171,10 @@ if (($userPath -split ';') -notcontains $launcherDirectory) {
Write-Host "Config Central configured for '$Machine'."
if (-not $SkipApply) {
& $powerShell7 -NoLogo -NoProfile -ExecutionPolicy Bypass -File (Join-Path $Checkout 'cc.ps1') apply -Machine $Machine -DataRoot $dataRoot -RepositoryRoot $Checkout
$applyArguments = @('-NoLogo', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
(Join-Path $Checkout 'cc.ps1'), 'apply', '-Machine', $Machine,
'-DataRoot', $dataRoot, '-RepositoryRoot', $Checkout)
if (-not $PreserveLocalConfigs) { $applyArguments += '-ForceConfigs' }
& $powerShell7 @applyArguments
exit $LASTEXITCODE
}

View File

@ -40,6 +40,16 @@ For unattended installation, select the machine in the same command:
$env:CONFIG_CENTRAL_MACHINE = 'beffroi-laptop'; irm 'https://proxy.dandaedre.com/gitea/Beffroi/config-central/raw/branch/main/install.ps1' | iex
```
Setup backs up and replaces existing managed settings by default, just like the
web config updater. To preserve local settings and report conflicts during setup:
```powershell
& ([scriptblock]::Create((irm 'https://proxy.dandaedre.com/gitea/Beffroi/config-central/raw/branch/main/install.ps1'))) -PreserveLocalConfigs
```
The same `-PreserveLocalConfigs` switch is available on `bootstrap.ps1`.
`-SkipApply` continues to skip deployment entirely.
The installer is safe to rerun for repair or setup updates. Use the web updater
for routine config updates. Use `cc sync` when you also want package updates.

View File

@ -3,7 +3,8 @@
param(
[string]$Machine = $env:CONFIG_CENTRAL_MACHINE,
[string]$Branch = $env:CONFIG_CENTRAL_BRANCH,
[switch]$SkipApply
[switch]$SkipApply,
[switch]$PreserveLocalConfigs
)
Set-StrictMode -Version 2.0
@ -125,6 +126,7 @@ try {
'-Repository', $repository, '-Branch', $Branch, '-Machine', $Machine
)
if ($SkipApply) { $arguments += '-SkipApply' }
if ($PreserveLocalConfigs) { $arguments += '-PreserveLocalConfigs' }
& $windowsPowerShell @arguments
$bootstrapExitCode = $LASTEXITCODE

View File

@ -59,3 +59,24 @@ Describe 'One-stop installer machine selection' {
}
}
}
Describe 'Setup config replacement policy' {
It 'forwards the preserve option through setup and disables force only when requested' {
$installerText = Get-Content "$PSScriptRoot/../install.ps1" -Raw
$bootstrapText = Get-Content "$PSScriptRoot/../bootstrap.ps1" -Raw
$installerArguments = [regex]::Match($installerText, '(?s) \$arguments = @\(.*?(?= & \$windowsPowerShell)').Value
$bootstrapArguments = [regex]::Match($bootstrapText, '(?s) \$applyArguments = @\(.*?(?= & \$powerShell7)').Value
$installerArguments | Should -Not -BeNullOrEmpty
$bootstrapArguments | Should -Not -BeNullOrEmpty
$bootstrapPath = 'bootstrap.ps1'; $repository = 'https://example.test/repo.git'
$Branch = 'main'; $Machine = 'test'; $SkipApply = $false
$Checkout = $TestDrive; $dataRoot = $TestDrive
foreach ($preserve in @($false, $true)) {
$PreserveLocalConfigs = $preserve
. ([scriptblock]::Create($installerArguments))
($arguments -contains '-PreserveLocalConfigs') | Should -Be $preserve
. ([scriptblock]::Create($bootstrapArguments))
($applyArguments -contains '-ForceConfigs') | Should -Be (-not $preserve)
}
}
}