@ijfw/install 1.5.3 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/install.ps1 CHANGED
@@ -94,10 +94,25 @@ function Invoke-CloneOrPull($target, $branch) {
94
94
  if ($LASTEXITCODE -eq 0) {
95
95
  # Self-heal stale origin URLs across host migrations (1.2.9 parity with install.js).
96
96
  # Without this, Windows users on the pre-GitLab origin still 404 on every upgrade.
97
+ # V155-012: only rewrite ORIGINS THAT MATCH KNOWN STALE PATTERNS. Previously
98
+ # this clobbered SSH remotes, forks, and any user-customized origin — anyone
99
+ # working on the IJFW source itself ended up silently retargeted to upstream.
100
+ # Port the install.js STALE_PATTERNS allowlist verbatim (case-insensitive).
97
101
  $currentOrigin = ($currentOriginRaw | Out-String).Trim()
98
- if ($currentOrigin -and $currentOrigin -ne $DEFAULT_REPO) {
102
+ $stalePatterns = @(
103
+ '^https://github\.com/seandonahoe/ijfw(\.git)?/?$',
104
+ '^https://github\.com/therealseandonahoe/ijfw(\.git)?/?$'
105
+ )
106
+ $isStale = $false
107
+ foreach ($pat in $stalePatterns) {
108
+ if ($currentOrigin -imatch $pat) { $isStale = $true; break }
109
+ }
110
+ if ($currentOrigin -and $isStale) {
99
111
  Write-Host " origin migration: $currentOrigin -> $DEFAULT_REPO"
100
112
  & git -C $target remote set-url origin $DEFAULT_REPO
113
+ if ($LASTEXITCODE -ne 0) {
114
+ Write-Warning " origin migration failed -- could not repoint $currentOrigin to $DEFAULT_REPO"
115
+ }
101
116
  }
102
117
  # fetch + hard checkout avoids ff-only failures from local divergence.
103
118
  & git -C $target fetch --depth 1 origin $branch
@@ -118,7 +133,13 @@ function Invoke-CloneOrPull($target, $branch) {
118
133
  try {
119
134
  & git clone --depth 1 --branch $branch $DEFAULT_REPO $target
120
135
  if ($LASTEXITCODE -ne 0) { throw "Could not reach the IJFW repo (exit $LASTEXITCODE). Check your network connection and retry." }
121
- foreach ($item in @('memory', 'sessions', 'install.log', '.session-counter')) {
136
+ # V155-013: expanded restore allowlist + retain backup if residual content remains
137
+ # so the operator can recover anything the allowlist doesn't know about.
138
+ $restoreAllowlist = @(
139
+ 'memory', 'sessions', 'install.log', '.session-counter',
140
+ 'ijfw', 'state', 'cache', 'logs', 'run', '.ijfw'
141
+ )
142
+ foreach ($item in $restoreAllowlist) {
122
143
  $src = Join-Path $backupDir $item
123
144
  if (Test-Path $src) {
124
145
  $dst = Join-Path $target $item
@@ -126,7 +147,13 @@ function Invoke-CloneOrPull($target, $branch) {
126
147
  Move-Item -LiteralPath $src -Destination $dst -Force
127
148
  }
128
149
  }
129
- Remove-Item -Recurse -Force -LiteralPath $backupDir
150
+ $residual = Get-ChildItem -LiteralPath $backupDir -Force -ErrorAction SilentlyContinue
151
+ if (-not $residual -or $residual.Count -eq 0) {
152
+ Remove-Item -Recurse -Force -LiteralPath $backupDir -ErrorAction SilentlyContinue
153
+ } else {
154
+ $sample = ($residual | Select-Object -First 8 | ForEach-Object { $_.Name }) -join ', '
155
+ Write-Warning " restored known dirs; backup retained at $backupDir (contains: $sample). Remove manually after verifying."
156
+ }
130
157
  return "updated"
131
158
  } catch {
132
159
  if (Test-Path $target) { Remove-Item -Recurse -Force -LiteralPath $target }