Skip to content

feat(packages): detect interrupted upgrades and add --from restore flag#29

Merged
dipto0321 merged 1 commit into
mainfrom
fix/platform/detect-interrupted-upgrades-and-prompt-for-replay
Jun 30, 2026
Merged

feat(packages): detect interrupted upgrades and add --from restore flag#29
dipto0321 merged 1 commit into
mainfrom
fix/platform/detect-interrupted-upgrades-and-prompt-for-replay

Conversation

@dipto0321

Copy link
Copy Markdown
Owner

Summary

Add an upgrade-in-progress sentinel file written after snapshot save and
removed by deferred cleanup, plus an --from <path> flag on
nodeup packages restore so users can replay an interrupted migration
by copy-pasting the path printed in the warning. A PersistentPreRunE
on the root command checks for an orphaned sentinel on every nodeup
invocation and emits a stderr warning with the resume command.

Linked issues

Closes #26

Type of change

  • fix — see the title; check the matching box below
    - [ ] feat
    - [ ] docs
    - [ ] style
    - [ ] refactor
    - [ ] perf
    - [ ] test
    - [ ] build
    - [ ] ci
    - [ ] chore
    - [ ] revert

Checklist

  • Title follows Conventional Commits (fix(platform): subject)
  • I ran make ci locally and it passes
  • I added or updated tests for the change
  • I updated relevant docs (README, docs/, inline godoc)
  • No new linter warnings
  • If breaking: I documented the migration path in the PR body and updated CHANGELOG.md

Scope notes / things reviewers may want to look at

  • The --from <path> flag is mutually exclusive with positional
    <manager> <version> args. Mixing them returns a Cobra arg-validation
    error.
  • RestoreFromSnapshot reads the snapshot file directly (no
    conventional-path lookup), so any user-provided JSON file matching
    the snapshot schema works — not only files in <DataDir>/snapshots/.
  • The sentinel is only written when migrate is enabled (skipped on
    --no-migrate or when cfg.Packages.Migrate = false), since the
    replay path only makes sense when a snapshot was taken.
  • Tests redirect HOME/USERPROFILE to a t.TempDir() and clear
    APPDATA/XDG_DATA_HOME so the sentinel helpers don't pollute the
    developer's real $HOME. CI does the same on its runners.

Screenshots / output

$ nodeup upgrade
Using manager: fnm
...
^C

$ nodeup list
Detected an interrupted upgrade (snapshot: /home/u/.local/share/nodeup/snapshots/fnm-20.9.0.json, started: 2026-06-30T17:30:14Z).
To resume: `nodeup packages restore --from /home/u/.local/share/nodeup/snapshots/fnm-20.9.0.json`

Add an upgrade-in-progress sentinel file under <DataDir> that is
written after snapshot save and before the first install, then
removed by a deferred cleanup. On every nodeup invocation a
PersistentPreRunE hook checks for an orphaned sentinel and prints a
stderr warning that includes the snapshot path and the resume
command.

Add `nodeup packages restore --from <path>` so users can replay an
interrupted migration by copy-pasting the path printed in the
warning. The positional <manager> <version> form continues to
work as before.

Refs #26
@cocogitto-bot

cocogitto-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

✔️ 111d288 - Conventional commits check succeeded.

@dipto0321 dipto0321 merged commit 6426270 into main Jun 30, 2026
10 checks passed
@dipto0321 dipto0321 deleted the fix/platform/detect-interrupted-upgrades-and-prompt-for-replay branch June 30, 2026 11:54
dipto0321 added a commit that referenced this pull request Jul 1, 2026
…ep (#33)

The CHANGELOG was missing Phase 6 bullets for PRs #28 (QuotePath
for paths with spaces), #29 (interrupted-upgrade sentinel + --from
restore), and #30 (system-node classifier with warnings). It also
had a duplicate `### Added` header from a prior merge and still
listed the scripts/issue-workflow.sh script that PR #32 deleted.

The README's Project status table said "Phase 1-5 OK" with no
mention of Phase 6 cross-platform polish. The Phase 7 status
(GoReleaser config + brew/scoop taps + npm wrapper) was also
missing.

CHANGELOG.md:
- Single Added / Changed / Removed block under [Unreleased] (was
  two Added blocks).
- Add Phase 6 bullets: system-node classifier (#30), interrupted-
  upgrade sentinel + replay (#29), QuotePath for paths with
  spaces (#28).
- Drop the stale `scripts/issue-workflow.sh` bullet; add a Removed
  entry pointing at the squash-merged PR #32 commit for context.

README.md:
- Project status table marks Phase 6 complete, with PR refs and
  a note that Phase 7 (issue #17) is the remaining work blocking
  the v1.0.0 tag.
- Trailing paragraph updated to reflect Phase 6 in the phase order.

Refs #18

Co-authored-by: dipto0321 <dipto@local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(platform): detect interrupted upgrades and prompt for replay

1 participant