Skip to content

feat: nudge apps behind on Leaf majors after install/update - #25

Merged
mychidarko merged 1 commit into
v5.xfrom
feat/leaf5-nudge
Nov 9, 2026
Merged

mychidarko merged 1 commit into
v5.xfrom
feat/leaf5-nudge

Conversation

@mychidarko

Copy link
Copy Markdown
Member

After leaf install or leaf update succeeds, the CLI now prints one plain line when the app is behind on Leaf majors:

leafs/leaf 4.4.1 installed, Leaf 5 is available. See https://leafphp.dev/docs/upgrade-guide

or, on Leaf 5 with an older module:

Newer Leaf majors available: leafs/form 3.2 -> 5.0.1. See https://leafphp.dev/docs/upgrade-guide

How it works (src/Utils/Upgrade.php):

  • Reads leafs/leaf from composer.lock first. If it's below 5, it prints the line and doesn't touch the network.
  • Otherwise it runs composer outdated --direct --major-only --format=json (30s timeout) and lists only leafs/* packages with a newer stable major. Dev branches are ignored.
  • It prints nothing when everything is current, when there's no composer.json in the working directory, or when composer fails (offline, timeout, bad JSON). Any exception is swallowed, so an install never fails because of the nudge.
  • It prints once per run, with no colour.

I didn't suggest a command in the line on purpose. leaf update updates the CLI itself, not the app, so the line points to the upgrade guide.

Tests: tests/upgrade.test.php adds 6 cases (below 5, outdated module, current, offline, no project, dev branch). The full suite passes 28/28 and lint is clean.

This changes CLI behaviour, so it needs a review before merge.

@mychidarko
mychidarko merged commit 3bbfe7c into v5.x Nov 9, 2026
26 checks passed
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.

1 participant