[rush-lib][rush-published-versions-json-plugin] Add plugin-native global commands; add published versions JSON plugin.#5701
Open
iclanton wants to merge 6 commits intomicrosoft:mainfrom
Conversation
bmiddha
reviewed
Mar 15, 2026
| "summary": "Generates a JSON file recording the version numbers of all published packages.", | ||
| "safeForSimultaneousRushProcesses": true, | ||
| // The command is handled by the plugin, so we don't want Rush to attempt to execute anything. | ||
| "shellCommand": "" |
Member
There was a problem hiding this comment.
why not make shellCommand optional?
is this to maintain backwards compat?
Member
Author
There was a problem hiding this comment.
It shouldn't be optional in common/config/rush/command-line.json. I didn't make it optional for the sake of not forking the schema just for plugins.
Collaborator
There was a problem hiding this comment.
This design might be a bit confusing. When a person sees "shellCommand": "" they would reasonably think nothing happens. How are they supposed to know that actually the implementation is provided in code?
| "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/command-line.schema.json", | ||
| "commands": [ | ||
| { | ||
| "commandKind": "global", |
Member
There was a problem hiding this comment.
or perhaps this can be globalPlugin? to signify that it is handled by a rush plugin and does not need to provide a shell command. maybe it has an options param?
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):customParametersByLongNametoIGlobalCommand, 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 command hasshellCommand: ""but no plugin callssetHandled(), a clear error is thrown.beforeInstallhook's command type fromIGlobalCommandtoIRushCommand, since install/update actions were never global custom commands.Plugin (
@rushstack/rush-published-versions-json-plugin):command-line.jsondefining therecord-published-versionsglobal command with a required--output-pathstring parameter andshellCommand: "".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.isFromPluginflag onCommandLineConfiguration— replaced with thesetHandled()approach, which is more explicit and lets the plugin itself declare that it handled the command.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.Impacted documentation
shellCommandfor global commands — should note that empty string is supported for plugin-handled commands)