Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/rush-plugins/rush-buildxl-graph-plugin](./rush-plugins/rush-buildxl-graph-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-buildxl-graph-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-buildxl-graph-plugin) | | [@rushstack/rush-buildxl-graph-plugin](https://www.npmjs.com/package/@rushstack/rush-buildxl-graph-plugin) |
| [/rush-plugins/rush-http-build-cache-plugin](./rush-plugins/rush-http-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-http-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-http-build-cache-plugin) | | [@rushstack/rush-http-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-http-build-cache-plugin) |
| [/rush-plugins/rush-mcp-docs-plugin](./rush-plugins/rush-mcp-docs-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-mcp-docs-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-mcp-docs-plugin) | [changelog](./rush-plugins/rush-mcp-docs-plugin/CHANGELOG.md) | [@rushstack/rush-mcp-docs-plugin](https://www.npmjs.com/package/@rushstack/rush-mcp-docs-plugin) |
| [/rush-plugins/rush-published-versions-json-plugin](./rush-plugins/rush-published-versions-json-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-published-versions-json-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-published-versions-json-plugin) | [changelog](./rush-plugins/rush-published-versions-json-plugin/CHANGELOG.md) | [@rushstack/rush-published-versions-json-plugin](https://www.npmjs.com/package/@rushstack/rush-published-versions-json-plugin) |
| [/rush-plugins/rush-redis-cobuild-plugin](./rush-plugins/rush-redis-cobuild-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-redis-cobuild-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-redis-cobuild-plugin) | | [@rushstack/rush-redis-cobuild-plugin](https://www.npmjs.com/package/@rushstack/rush-redis-cobuild-plugin) |
| [/rush-plugins/rush-resolver-cache-plugin](./rush-plugins/rush-resolver-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-resolver-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-resolver-cache-plugin) | | [@rushstack/rush-resolver-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-resolver-cache-plugin) |
| [/rush-plugins/rush-serve-plugin](./rush-plugins/rush-serve-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-serve-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-serve-plugin) | | [@rushstack/rush-serve-plugin](https://www.npmjs.com/package/@rushstack/rush-serve-plugin) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Add `getCustomParametersByLongName()` and `setHandled()` to `IGlobalCommand`, enabling Rush plugins to handle global command execution and access parsed command-line parameter values.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Add a new \"globalPlugin\" command kind for command-line.json that allows Rush plugins to define global commands without a shellCommand. This command kind can only be used in plugin-provided command-line.json files.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/rush-published-versions-json-plugin",
"comment": "Initial release.",
"type": "minor"
}
],
"packageName": "@rushstack/rush-published-versions-json-plugin"
}
59 changes: 42 additions & 17 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/config/subspaces/default/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "54470e7caa94b190d86dbd4f9cc43e0d58456972",
"pnpmShrinkwrapHash": "c482c23c40b202ed750549c796c24b3550d0ba6e",
"preferredVersionsHash": "029c99bd6e65c5e1f25e2848340509811ff9753c"
}
5 changes: 4 additions & 1 deletion common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ export interface IGetChangedProjectsOptions {

// @beta
export interface IGlobalCommand extends IRushCommand {
getCustomParametersByLongName<TParameter extends CommandLineParameter>(longName: string): TParameter;
setHandled(): void;
}

// @public
Expand Down Expand Up @@ -1434,6 +1436,7 @@ export class RushConstants {
static readonly defaultWatchDebounceMs: 1000;
static readonly experimentsFilename: 'experiments.json';
static readonly globalCommandKind: 'global';
static readonly globalPluginCommandKind: 'globalPlugin';
static readonly hashDelimiter: '|';
static readonly lastLinkFlagFilename: 'last-link';
static readonly mergeQueueIgnoreFileName: '.mergequeueignore';
Expand Down Expand Up @@ -1502,7 +1505,7 @@ export class RushLifecycleHooks {
variant: string | undefined
]>;
readonly beforeInstall: AsyncSeriesHook<[
command: IGlobalCommand,
command: IRushCommand,
subspace: Subspace,
variant: string | undefined
]>;
Expand Down
34 changes: 33 additions & 1 deletion libraries/rush-lib/src/api/CommandLineConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ export interface IPhasedCommandConfig extends IPhasedCommandWithoutPhasesJson, I
alwaysInstall: boolean | undefined;
}

export interface IGlobalCommandConfig extends IGlobalCommandJson, ICommandWithParameters {}
export interface IGlobalCommandConfig extends IGlobalCommandJson, ICommandWithParameters {
/**
* If true, this command was declared with commandKind "globalPlugin" and its implementation
* is provided by a Rush plugin via the `runGlobalCustomCommand` hook. There is no shell
* command to execute.
*/
providedByPlugin: boolean;
}

export type Command = IGlobalCommandConfig | IPhasedCommandConfig;

Expand Down Expand Up @@ -408,6 +415,20 @@ export class CommandLineConfiguration {
case RushConstants.globalCommandKind: {
normalizedCommand = {
...command,
providedByPlugin: false,
associatedParameters: new Set<IParameterJson>()
};
break;
}

case RushConstants.globalPluginCommandKind: {
// Normalize globalPlugin commands to global commands with an empty shellCommand,
// similar to how bulk commands are converted to phased commands.
normalizedCommand = {
...command,
commandKind: RushConstants.globalCommandKind,
shellCommand: '',
providedByPlugin: true,
associatedParameters: new Set<IParameterJson>()
};
break;
Expand Down Expand Up @@ -694,6 +715,17 @@ export class CommandLineConfiguration {
this._applyBuildCommandDefaults(commandLineJson);

CommandLineConfiguration._jsonSchema.validateObject(commandLineJson, jsonFilePath);

// Validate that globalPlugin commands are not used in the repo's command-line.json
for (const { commandKind, name } of commandLineJson.commands) {
if (commandKind === RushConstants.globalPluginCommandKind) {
throw new Error(
`${RushConstants.commandLineFilename} defines a command "${name}" using ` +
`the command kind "${RushConstants.globalPluginCommandKind}". This command kind can only ` +
`be used in command-line.json files provided by Rush plugins.`
);
}
}
}
}

Expand Down
17 changes: 15 additions & 2 deletions libraries/rush-lib/src/api/CommandLineJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* "baseCommand" from command-line.schema.json
*/
export interface IBaseCommandJson {
commandKind: 'bulk' | 'global' | 'phased';
commandKind: 'bulk' | 'global' | 'globalPlugin' | 'phased';
name: string;
summary: string;
/**
Expand Down Expand Up @@ -66,7 +66,20 @@ export interface IGlobalCommandJson extends IBaseCommandJson {
shellCommand: string;
}

export type CommandJson = IBulkCommandJson | IGlobalCommandJson | IPhasedCommandJson;
/**
* "globalPluginCommand" from command-line.schema.json.
* A global command whose implementation is provided entirely by a Rush plugin.
* This command kind can only be used in command-line.json files provided by Rush plugins.
*/
export interface IGlobalPluginCommandJson extends IBaseCommandJson {
commandKind: 'globalPlugin';
}

export type CommandJson =
| IBulkCommandJson
| IGlobalCommandJson
| IGlobalPluginCommandJson
| IPhasedCommandJson;

/**
* The dependencies of a phase.
Expand Down
Loading