[rush][rush-published-versions-json-plugin] Add plugin-native global commands; add published versions JSON plugin.#5701
Merged
iclanton merged 11 commits intomicrosoft:mainfrom Mar 24, 2026
Conversation
bmiddha
reviewed
Mar 15, 2026
rush-plugins/rush-published-versions-json-plugin/command-line.json
Outdated
Show resolved
Hide resolved
rush-plugins/rush-published-versions-json-plugin/command-line.json
Outdated
Show resolved
Hide resolved
octogonz
reviewed
Mar 24, 2026
octogonz
reviewed
Mar 24, 2026
common/changes/@microsoft/rush/rush-published-versions-plugin_2026-03-15-04-22.json
Show resolved
Hide resolved
octogonz
approved these changes
Mar 24, 2026
Introduces a new "globalPlugin" commandKind for command-line.json that can only be used in Rush plugin command-line.json files. Unlike "global" commands, it has no shellCommand — the implementation must be provided entirely by the plugin via the runGlobalCustomCommand hook with setHandled(). - Added globalPluginCommandKind constant to RushConstants - Added globalPluginCommand to JSON schema (no shellCommand/autoinstallerName) - Added IGlobalPluginCommandJson type; at runtime, normalized to IGlobalCommandConfig with shellCommand="" and isPluginOnly=true (similar to bulk→phased conversion) - Rejected globalPlugin in repo command-line.json (loadFromFileOrDefault) - Updated plugin command-line.json to use the new kind - Fixed plugin .npmignore to include command-line.json Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename isPluginOnly → providedByPlugin for clarity per review feedback. Also update the first changefile comment to reflect the globalPlugin design. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
81f7d9f to
c4d9d79
Compare
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
This PR makes two related changes:
Extends the Rush plugin API to allow plugins to implement native global commands without requiring a shell script. Previously, global commands always required a
shellCommand— plugins had no way to run their own code directly.Adds
@rushstack/rush-published-versions-json-plugin, a new Rush plugin that generates a JSON file recording the version numbers of all published packages in a monorepo. Usage:rush record-published-versions --output-path <path>. This plugin is also the first consumer of the new API, serving as a reference implementation.Details
Rush plugin API changes (
@microsoft/rush-lib):"globalPlugin"command kind: A newcommandKindvalue forcommand-line.jsonthat can only be used in plugin-providedcommand-line.jsonfiles. Unlike"global"commands,"globalPlugin"commands have noshellCommandorautoinstallerName— the implementation is provided entirely by the plugin's code via therunGlobalCustomCommandhook. If a repo user tries to use"globalPlugin"in the repo'scommand-line.json, Rush rejects it with a clear error. At runtime,"globalPlugin"is normalized to a"global"command with an empty shell command and anisPluginOnlyflag (similar to how"bulk"commands are normalized to"phased").getCustomParametersByLongName()toIGlobalCommand, giving plugin hooks access to parsed command-line parameter values (e.g.--output-path). Parameters are keyed by long name and returnCommandLineParameterobjects from@rushstack/ts-command-line.setHandled()toIGlobalCommand. When a plugin hook calls this, the default shell command execution is skipped. If a"globalPlugin"command runs but no plugin callssetHandled(), Rush throws a clear error indicating the plugin is not properly handling the command.beforeInstallhook's command type fromIGlobalCommandtoIRushCommand, since install/update actions were never global custom commands.Plugin (
@rushstack/rush-published-versions-json-plugin):command-line.jsonusing the new"globalPlugin"command kind for therecord-published-versionscommand, with a required--output-pathstring parameter.apply()method tapsrunGlobalCustomCommand.for('record-published-versions'), callscommand.setHandled(), then generates a JSON map of{ packageName: version }for all projects withshouldPublishor aversionPolicy.Design alternatives considered:
shellCommandoptional in the JSON schema — rejected because it would let repo users accidentally omitshellCommandand get a command that silently does nothing.shellCommand: ""with a regular"global"kind — replaced with the dedicated"globalPlugin"kind, which is more explicit, self-documenting, and restricts usage to plugins only. The schema itself acts as a version gate: if Rush is too old to understand"globalPlugin", it fails at schema validation with a clear error.No backwards compatibility concerns —
IGlobalCommandis@betaand the new members are additive. Existing global commands with ashellCommandare unaffected.How it was tested
@microsoft/rush-lib,@rushstack/rush-sdk, and@rushstack/rush-published-versions-json-pluginwithrush build— all pass cleanly with no errors or warnings.rush-lib.api.md) reflects the expected surface changes (globalPluginCommandKindadded toRushConstants).Impacted documentation
commandKindvalues — should add"globalPlugin"for plugin-native global commands)