Repository navigation
feat(cli): no implicit major updates of the cli and its plugins - #295
Merged
Merged
Conversation
The CLI installed every plugin from npm's latest, and plugins:update followed it, so a new major of a plugin (with its breaking changes) reached the users of any CLI version silently. - the plugin table holds the major each plugin is installed with (^N): a plugin is installed and updated within it - plugins:install <plugin> --latest (same as --tag latest, not together with it) installs its latest version, a new major included, also over an installed plugin: the explicit move to the next major - before plugins:update, the plugins that follow latest (installed by an older CLI, or with --latest) are pinned to the major they have - plugins:available shows the version range; a test checks the table against the majors of the workspace plugins Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Node.js 20 the CLI 7 failed while loading (ERR_REQUIRE_ESM) and printed the minified source of cli-core; cli:update of the 6.x CLI had installed it (npm install @latest), and printed the version of the running process, the previous one, so the update looked failed. - bin/run.js checks engines.node first and says which Node.js the CLI needs, or how to install the previous major - cli:update installs the latest version of the current major; --latest (exclusive with --version) installs a new major, never on a Node.js that the release doesn't support - after the update, the version npm installed (npm ls), and a hint when a new major is available; the update notice suggests --latest for a major Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pviti
requested review from
cl-mvezzelli,
gciotola,
malessani,
marco-commercelayer and
pfferrari
October 15, 2026 13:55
marco-commercelayer
approved these changes
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No implicit major updates of the CLI and its plugins
This PR replaces #293 and #294: one review instead of two. A new major of the CLI or of a plugin is installed only when the user asks for it with
--latest. On a Node.js version that is too old, the CLI now explains what to do.Tests of the combined branch: CLI 37 passing. The 2 that fail locally (
applications:login,config:show) fail on main too and depend on the environment.pnpm lintandcheck-packagespass.1. Plugins stay on their major unless
--latestis givenToday the CLI installs every plugin from npm's
latest, andplugins:updatefollows it. A new major of a plugin, with its breaking changes, therefore reaches the users of any CLI version without them asking for it. Since the release of the 7.0.0 majors, for example, the 6.x CLI installs tags 3.0.0.Changes
plugins:available). Each plugin has the major it is installed with, as a^Nrange: todayresources ^7,tags ^3, and so on.plugins:installuses it, oclif records it, andplugins:updatestays within it.plugins:availableshows the range in a new VERSION column.plugins:install <plugin> --latest. It installs the latest version on npm, a new major included, so moving to the next major is always explicit.--tag latestand cannot be used together with--tag.--latestor--tag, the "already installed" message suggests it.latest. Beforeplugins:updatethey are pinned to the major they have, not to the major of the table, so they never change major implicitly. The same happens after an install with--latest.^N, with N not above the major of the plugin in the workspace. The table may lag behind: a plugin's new major reaches the CLI only when the table is updated explicitly, which is a change of the CLI.Verification
End to end, with the CLI of this branch and the plugins on npm, in a sandbox with isolated config:
plugins:install tagstags@^3→ 3.0.0latest, thenplugins:update^5, stays 5.7.0 (table:^6)plugins:install orderswith orders installed--latesthintplugins:install orders --latest, thenplugins:update^6--latest --tag ^2plugins:uninstall tags --latestIn the
--latestcase, oclif prints "installed v5.7.0" when it reinstalls a plugin, but it does install 6.0.0, aspluginsshows.CLI tests: 33 passing. The 2 that fail locally (
applications:login,config:show) fail on main too and depend on the environment.Not included
The 6.x CLI keeps installing
latest. Its users can pin a plugin withplugins:install <plugin> --tag ^N.2. Clear Node.js error,
cli:updatestays on the current majorUsers on Node.js 20 updated the 6.x CLI with
cli:updateand ran into two problems.cli:updatemoved them to 7.0.0. The 6.x command runsnpm install -g @commercelayer/cli, without a version and without checking Node.js. It then printed the version of the process still running, the previous one (6.9.3), so the update looked failed.ERR_REQUIRE_ESMand prints the minified source of cli-core. I reproduced it with CLI 7.0.0 on Node.js 20.5.1 (the official binary, checksum verified).Changes
bin/run.jschecksengines.nodebefore loading anything and says what to do instead:src/engines.ts, with no imports, so it loads on any Node.js.cli:updateworks like the plugins (part 1).@^7).--latestinstalls a new major. It cannot be used together with--version.engines.nodedoesn't match the Node.js in use is not installed: the command stops and names the Node.js version needed.npm ls -g), for example6.9.3 -> 6.9.9or "up to date". When a new major is available it says so: runcli:update --latest, or the release needs a newer Node.js.cli:update --latest.Verification
Node.js 20.5.1: the branch CLI prints the message above and exits with code 1, instead of crashing.
cli:update, with npm writing to an isolated prefix (npm_config_prefix), so no real global install was touched:--latest--latest --version 7.0.0Tests: unit tests for the version check, the error message and the update target. The 2 that fail locally (
applications:login,config:show) fail on main too and depend on the environment.pnpm lintpasses anddocs/cli.mdis regenerated.Not included
The 6.x CLI keeps its old
cli:update, which moves to the latest major. Only a 6.x patch could change that, and those users would only get it withcli:update -v 6.🤖 Generated with Claude Code