Repository navigation
fix: keep the latest CLI major as the default docs version - #2067
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix, regression test, menu guards, and restored redirects are consistent with existing behavior and have no identified blocking defects.
No open issues 🎉
What changed in this PR
Keeps CLI documentation on the major version identified by npm’s latest tag, even when a newer patch is published first.
Changes:
- Matches the default release by major version and adds a regression test.
- Restores v12’s latest status and unversioned redirects.
- Prevents missing versions from producing empty menu items.
| File | Description |
|---|---|
| src/components/variant-select.js | Guards missing versions and empty Current groups. |
| content/nav.yml | Marks v12 as the default/latest version. |
| content/cli/v12/using-npm/workspaces.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/scripts.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/scope.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/removal.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/registry.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/package-spec.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/orgs.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/logging.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/index.mdx | Restores section redirects. |
| content/cli/v12/using-npm/developers.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/dependency-selectors.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/config.mdx | Restores unversioned redirects. |
| content/cli/v12/using-npm/changelog.mdx | Restores unversioned redirects. |
| content/cli/v12/index.mdx | Restores CLI landing-page redirects. |
| content/cli/v12/configuring-npm/package-lock-json.mdx | Restores unversioned redirects. |
| content/cli/v12/configuring-npm/package-json.mdx | Restores unversioned redirects. |
| content/cli/v12/configuring-npm/npmrc.mdx | Restores unversioned redirects. |
| content/cli/v12/configuring-npm/npm-extension.mdx | Restores unversioned redirects. |
| content/cli/v12/configuring-npm/install.mdx | Restores unversioned redirects. |
| content/cli/v12/configuring-npm/index.mdx | Restores section redirects. |
| content/cli/v12/configuring-npm/folders.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npx.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-whoami.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-view.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-version.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-update.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-unpublish.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-uninstall.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-undeprecate.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-trust.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-token.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-test.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-team.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-stop.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-start.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-stage.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-set.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-search.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-sbom.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-run.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-root.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-restart.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-repo.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-rebuild.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-query.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-publish.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-prune.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-profile.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-prefix.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-pkg.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-ping.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-patch.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-pack.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-owner.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-outdated.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-org.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-ls.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-logout.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-login.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-ll.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-link.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-install.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-install-test.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-install-scripts.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-install-ci-test.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-init.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-help.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-help-search.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-get.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-fund.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-find-dupes.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-explore.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-explain.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-exec.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-edit.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-doctor.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-docs.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-dist-tag.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-diff.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-deprecate.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-deny-scripts.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-dedupe.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-config.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-completion.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-ci.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-cache.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-bugs.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-audit.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-approve-scripts.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/npm-access.mdx | Restores unversioned redirects. |
| content/cli/v12/commands/index.mdx | Restores section redirects. |
| cli/test/index.js | Tests a newer patch preceding the latest tag update. |
| cli/lib/build.js | Selects the default release by matching major versions. |
Review effort: Balanced
v-kartykp
force-pushed
the
kartykp/cli-docs-latest-version-fix
branch
from
October 21, 2026 21:20
f793ec3 to
99a43f4
Compare
v-kartykp
force-pushed
the
kartykp/cli-docs-latest-version-fix
branch
from
October 21, 2026 22:25
99a43f4 to
7fa327e
Compare
v-kartykp
force-pushed
the
kartykp/cli-docs-latest-version-fix
branch
from
October 21, 2026 22:48
7fa327e to
906402c
Compare
nishantms
approved these changes
Oct 21, 2026
The CLI docs build marked a release as the default only when its newest version exactly matched the `latest` dist-tag. When a new patch is published before `latest` is moved (for example 12.2.1 while `latest` is still 12.2.0), no release was marked latest, so the version menu rendered an empty "Current" item and the unversioned redirects were dropped from the default version's pages. Selecting a version also returned focus to the menu button while it still showed the previous version and was still expanded, so screen readers announced the old version and never announced the new one. - Mark the release whose major matches the `latest` dist-tag as default - Set v12 back to the default/latest variant in nav.yml - Only render the "Current" version group and items when they exist - Keep the version menu open until the selected version has loaded, then close it and move focus to the menu button once Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
v-kartykp
force-pushed
the
kartykp/cli-docs-latest-version-fix
branch
from
October 21, 2026 23:52
906402c to
ad90ff9
Compare
This branch was successfully deployed
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.
Summary
The CLI docs build stops marking any CLI version as the default ("latest") when npm publishes a new patch before moving the
latestdist-tag to it. This PR fixes the build logic and makes the version menu handle a missing latest version.Problem
cli/lib/build.jsmarked a release as the default only when the newest version in that major exactly matched npm'slatestdist-tag:npm
12.2.1is published under thenext-12tag, whilelateststill points to12.2.0. The build picks12.2.1as the newest v12 release, which isn't equal to12.2.0, so no release is marked default and v12 falls through totype: legacy. The last automated CLI docs update wrote that result tomain, which has two effects:nav.ymlhas nolatestvariant, so the "Select CLI Version" menu renders an empty, focusable "Current" item. It is focused first when the menu opens, and screen readers announce a blank menu item.redirect_fromentries (for example/cli/commands/npm-install). With v12 no longer default, those entries were removed from the v12 pages, so a clean build no longer produces those redirects.The same drop-and-restore of
type: latesthas happened in earlier automated updates. It recurs whenever a patch is published beforelatestis moved.Changes
cli/lib/build.js: the default release is now the one whose major matches thelatestdist-tag:cli/test/index.js: new test for a newer patch (9.0.1) published whilelatestis still9.0.0. It fails with the old logic (legacy) and passes with the fix.src/components/variant-select.js: the "Current" group and each item in it are only rendered when that version exists, so a missing latest version can no longer produce an empty menu item.content/nav.yml: v12 is set back todefault: true/type: latest. This is the exactnav.ymloutput of the fixed build against the live registry, so the version menu shows v12 under "Current" as "(Latest)" again.src/components/variant-select.js(focus after choosing a version): choosing a version closed the menu and returned focus to the menu button immediately, while the button still showed the previous version and was still expanded. The button then updated without being announced, so NVDA read the old version (for example "Version 12.2.1 (Latest), menu button, expanded" after choosing 11.21.1). The menu now stays open until the selected version has loaded, then closes and moves focus to the button once, so it is announced with the new version and as collapsed. Escape, Tab, choosing the version you're already on, and modifier-clicks (open in a new tab) behave as before.The generated v12 pages (
content/cli/v12/**) are not changed here. The scheduled "Update CLI" workflow regenerates them with the fixed build on its next v12 update, which restores the unversionedredirect_fromentries.Testing
node --test ./test/index.js ./test/transform.js): 10/10 pass. The new test fails without thebuild.jschange.default: true/type: latestand restores the unversionedredirect_fromentries on the v12 pages, with no other content changes.npm run build -w cli -- --check-onlypasses.npm test(jest) andnpm run lintpass.content/nav.ymlis identical to thenav.ymlproduced by the fixed build.aria-expanded="false".gatsby develop: the version menu shows "Version 12.2.1" under "Current" and the other versions under "Legacy", with no empty items. Opening the menu focuses "Version 12.2.1" ("Current", 1 of 1). Selecting it opens/cli/v12/using-npmlabelled "(Latest)" and returns focus to the menu button. With v12 set tolegacy, the menu shows no "Current" group and no empty item.