[rush] (BREAKING CHANGE) Overhaul watch-mode to facilitate orchestration #5378
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
Completely retools the watch engine in Rush to facilitate better interaction with plugins that wish to orchestrate the build process. Makes the Rush execution engine stateful across an entire Rush watch session.
BREAKING CHANGES
PhasedCommandHooks
that has not been moved or renamed isbeforeLog
.createOperations
is nowcreateOperationsAsync
, and the properties on thecontext
parameter have changed.ExecutionManagerHooks
object, accessible via theexecutionManagerAsync
hook. AccessexecutionManager.hooks
forbeforeExecuteOperationAsync
,afterExecuteOperationAsync
,beforeExecuteOperationsAsync
,afterExecuteOperationsAsync
, andonWaitingForChanges
.Details
The new lifecycle of a Rush phased command is that the command first invokes
createOperationsAsync
to create the session-long operation graph. This set of operations is then used to construct anIOperationExecutionManager
that will own the lifecycle of the execution session.There is a new watch option
includeAllProjectsInWatchGraph
that, if set to true, will cause Rush to build the graph with all projects inrush.json
, regardless of CLI selection parameters. Selected projects will only affect which projects are enabled for execution during the initial run. This also allows for a bare command, e.g.rush start
to select no projects. This feature is intended for use with plugins that offer the ability to alter the enabled/disabled states of operations in the graph while the session is ongoing. For an example, see@rushstack/rush-serve-plugin
, which facilitates altering these states via Web Socket messages.All in-repo plugins that interact with the Rush execution graph have also been updated.
This PR in its initial draft includes an AI-coded interactive live status dashboard; this dashboard will be extracted prior to checkin and moved to its own PR because it needs refactoring to have a proper build system with static analysis applied.
While this dashboard is included, you can test out all the functionality by checking out this branch and running:
rush install && rush build -t rush
node ./apps/rush/lib/start-dev.js start --port 4321
(or whatever number)Then open
https://localhost:4321/
in the browser. Currently it does not attempt to automatically launch, but VSCode may offer you a popup to launch it for you when it does automatic port forwarding.How it was tested
Added unit tests for all functionality of the new
IOperationExecutionManager
API contract.Manual validation via the rushstack repo's
rush start
command for the CLI interaction (enable/disable debug or verbose, alter parallelism, pause/resume, kick a single build, invalidate, close runners).Impacted documentation
All watch-mode documentation. Plugin documentation for phased commands.