@rushstack/rush-sdk 5.170.0 → 5.170.1-pr5378.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/rush-lib.d.ts +469 -132
  2. package/lib-commonjs/index.js +1 -0
  3. package/lib-commonjs/logic/operations/IOperationGraph.js +2 -0
  4. package/lib-commonjs/logic/operations/OperationGraph.js +3 -0
  5. package/lib-commonjs/logic/operations/OperationStatus.js +1 -0
  6. package/lib-commonjs/{cli/parsing → logic/operations}/ParseParallelism.js +2 -1
  7. package/lib-commonjs/pluginFramework/OperationGraphHooks.js +3 -0
  8. package/lib-dts/api/CommandLineConfiguration.d.ts +7 -0
  9. package/lib-dts/api/CommandLineJson.d.ts +1 -0
  10. package/lib-dts/api/EnvironmentConfiguration.d.ts +12 -0
  11. package/lib-dts/api/EventHooks.d.ts +1 -1
  12. package/lib-dts/cli/parsing/SelectionParameterSet.d.ts +1 -1
  13. package/lib-dts/cli/scriptActions/PhasedScriptAction.d.ts +2 -12
  14. package/lib-dts/index.d.ts +7 -4
  15. package/lib-dts/logic/ProjectWatcher.d.ts +64 -42
  16. package/lib-dts/logic/buildCache/OperationBuildCache.d.ts +2 -2
  17. package/lib-dts/logic/operations/IOperationExecutionResult.d.ts +57 -16
  18. package/lib-dts/logic/operations/IOperationGraph.d.ts +137 -0
  19. package/lib-dts/logic/operations/IOperationRunner.d.ts +32 -2
  20. package/lib-dts/logic/operations/IPCOperationRunner.d.ts +8 -8
  21. package/lib-dts/logic/operations/Operation.d.ts +50 -14
  22. package/lib-dts/logic/operations/OperationExecutionRecord.d.ts +21 -9
  23. package/lib-dts/logic/operations/OperationGraph.d.ts +125 -0
  24. package/lib-dts/logic/operations/OperationStatus.d.ts +4 -0
  25. package/lib-dts/logic/operations/ParseParallelism.d.ts +33 -0
  26. package/lib-dts/logic/operations/ShellOperationRunner.d.ts +6 -5
  27. package/lib-dts/logic/operations/ShellOperationRunnerPlugin.d.ts +2 -1
  28. package/lib-dts/logic/operations/ValidateOperationsPlugin.d.ts +1 -3
  29. package/lib-dts/pluginFramework/OperationGraphHooks.d.ts +129 -0
  30. package/lib-dts/pluginFramework/PhasedCommandHooks.d.ts +32 -98
  31. package/lib-dts/utilities/Stopwatch.d.ts +2 -2
  32. package/lib-shim/index.js +32 -2
  33. package/lib-shim/index.js.map +1 -1
  34. package/package.json +8 -8
  35. package/lib-commonjs/logic/operations/OperationExecutionManager.js +0 -3
  36. package/lib-commonjs/logic/operations/WeightedOperationPlugin.js +0 -3
  37. package/lib-dts/cli/parsing/ParseParallelism.d.ts +0 -17
  38. package/lib-dts/logic/operations/OperationExecutionManager.d.ts +0 -60
  39. package/lib-dts/logic/operations/WeightedOperationPlugin.d.ts +0 -10
@@ -1,16 +1,15 @@
1
- import type { OperationRequestRunCallback } from '@rushstack/operation-graph';
2
1
  import type { IPhase } from '../../api/CommandLineConfiguration';
3
2
  import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
4
- import type { IOperationRunner, IOperationRunnerContext } from './IOperationRunner';
3
+ import type { IOperationRunner, IOperationRunnerContext, IOperationLastState } from './IOperationRunner';
5
4
  import { OperationStatus } from './OperationStatus';
6
5
  export interface IIPCOperationRunnerOptions {
7
6
  phase: IPhase;
8
7
  project: RushConfigurationProject;
9
8
  name: string;
10
- commandToRun: string;
9
+ initialCommand: string;
10
+ incrementalCommand: string | undefined;
11
11
  commandForHash: string;
12
12
  persist: boolean;
13
- requestRun: OperationRequestRunCallback;
14
13
  ignoredParameterValues: ReadonlyArray<string>;
15
14
  }
16
15
  /**
@@ -23,16 +22,17 @@ export declare class IPCOperationRunner implements IOperationRunner {
23
22
  readonly silent: boolean;
24
23
  readonly warningsAreAllowed: boolean;
25
24
  private readonly _rushProject;
26
- private readonly _commandToRun;
25
+ private readonly _initialCommand;
26
+ private readonly _incrementalCommand;
27
27
  private readonly _commandForHash;
28
28
  private readonly _persist;
29
- private readonly _requestRun;
30
29
  private readonly _ignoredParameterValues;
31
30
  private _ipcProcess;
32
31
  private _processReadyPromise;
33
32
  constructor(options: IIPCOperationRunnerOptions);
34
- executeAsync(context: IOperationRunnerContext): Promise<OperationStatus>;
33
+ get isActive(): boolean;
34
+ executeAsync(context: IOperationRunnerContext, lastState?: IOperationLastState): Promise<OperationStatus>;
35
35
  getConfigHash(): string;
36
- shutdownAsync(): Promise<void>;
36
+ closeAsync(): Promise<void>;
37
37
  }
38
38
  //# sourceMappingURL=IPCOperationRunner.d.ts.map
@@ -2,6 +2,18 @@ import type { RushConfigurationProject } from '../../api/RushConfigurationProjec
2
2
  import type { IPhase } from '../../api/CommandLineConfiguration';
3
3
  import type { IOperationRunner } from './IOperationRunner';
4
4
  import type { IOperationSettings } from '../../api/RushProjectConfiguration';
5
+ import { type Parallelism } from './ParseParallelism';
6
+ /**
7
+ * State for the `enabled` property of an `Operation`.
8
+ *
9
+ * - `true`: The operation should be executed if it or any dependencies changed.
10
+ * - `false`: The operation should be skipped.
11
+ * - `"ignore-dependency-changes"`: The operation should be executed if there are local changes in the project,
12
+ * otherwise it should be skipped. This is useful for operations like "test" where you may want to skip
13
+ * testing projects that haven't changed.
14
+ * @alpha
15
+ */
16
+ export type OperationEnabledState = boolean | 'ignore-dependency-changes';
5
17
  /**
6
18
  * Options for constructing a new Operation.
7
19
  * @alpha
@@ -15,6 +27,18 @@ export interface IOperationOptions {
15
27
  * The Rush project associated with this Operation
16
28
  */
17
29
  project: RushConfigurationProject;
30
+ /**
31
+ * If set to false, this operation will be skipped during evaluation (return OperationStatus.Skipped).
32
+ * This is useful for plugins to alter the scope of the operation graph across executions,
33
+ * e.g. to enable or disable unit test execution, or to include or exclude dependencies.
34
+ *
35
+ * The special value "ignore-dependency-changes" can be used to indicate that this operation should only
36
+ * be executed if there are local changes in the project. This is useful for operations like
37
+ * "test" where you may want to skip testing projects that haven't changed.
38
+ *
39
+ * The default value is `true`, meaning the operation will be executed if it or any dependencies change.
40
+ */
41
+ enabled?: OperationEnabledState;
18
42
  /**
19
43
  * When the scheduler is ready to process this `Operation`, the `runner` implements the actual work of
20
44
  * running the operation.
@@ -31,7 +55,7 @@ export interface IOperationOptions {
31
55
  }
32
56
  /**
33
57
  * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
34
- * `OperationExecutionManager`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
58
+ * `OperationGraph`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
35
59
  * implementation manages the actual process of running a single operation.
36
60
  *
37
61
  * The graph of `Operation` instances will be cloned into a separate execution graph after processing.
@@ -67,17 +91,23 @@ export declare class Operation {
67
91
  */
68
92
  runner: IOperationRunner | undefined;
69
93
  /**
70
- * The weight for this operation. This scalar is the contribution of this operation to the
71
- * `criticalPathLength` calculation above. Modify to indicate the following:
72
- * - `weight` === 1: indicates that this operation has an average duration
73
- * - `weight` &gt; 1: indicates that this operation takes longer than average and so the scheduler
74
- * should try to favor starting it over other, shorter operations. An example might be an operation that
75
- * bundles an entire application and runs whole-program optimization.
76
- * - `weight` &lt; 1: indicates that this operation takes less time than average and so the scheduler
77
- * should favor other, longer operations over it. An example might be an operation to unpack a cached
78
- * output, or an operation using NullOperationRunner, which might use a value of 0.
79
- */
80
- weight: number;
94
+ * The concurrency weight for this operation. When coerced to an integer via `coerceParallelism`,
95
+ * this value represents how many concurrency slots the operation consumes while running.
96
+ *
97
+ * May be specified as:
98
+ * - A raw `number`: used directly as the slot count (e.g. `2` consumes two slots).
99
+ * - An `IParallelismScalar` (e.g. `{ scalar: 0.5 }`): coerced relative to the graph's
100
+ * configured `maxParallelism` at execution time, so the weight scales with the available
101
+ * concurrency rather than being fixed at parse time.
102
+ *
103
+ * Coerced values guide scheduling as follows:
104
+ * - `1` slot: typical operation consuming one logical thread.
105
+ * - `> 1` slots: operation that spawns multiple threads or requires significant RAM; reserving
106
+ * extra slots prevents overloading the machine (e.g. a whole-program bundler or a test suite
107
+ * that runs its own internal parallelism).
108
+ * - `0` slots: effectively free (e.g. a no-op or cache-restore step).
109
+ */
110
+ weight: Parallelism;
81
111
  /**
82
112
  * Get the operation settings for this operation, defaults to the values defined in
83
113
  * the project configuration.
@@ -87,8 +117,14 @@ export declare class Operation {
87
117
  * If set to false, this operation will be skipped during evaluation (return OperationStatus.Skipped).
88
118
  * This is useful for plugins to alter the scope of the operation graph across executions,
89
119
  * e.g. to enable or disable unit test execution, or to include or exclude dependencies.
90
- */
91
- enabled: boolean;
120
+ *
121
+ * The special value "ignore-dependency-changes" can be used to indicate that this operation should only
122
+ * be executed if there are local changes in the project. This is useful for operations like
123
+ * "test" where you may want to skip testing projects that haven't changed.
124
+ *
125
+ * The default value is `true`, meaning the operation will be executed if it or any dependencies change.
126
+ */
127
+ enabled: OperationEnabledState;
92
128
  constructor(options: IOperationOptions);
93
129
  /**
94
130
  * The name of this operation, for logging.
@@ -7,7 +7,7 @@ import { Stopwatch } from '../../utilities/Stopwatch';
7
7
  import { OperationMetadataManager } from './OperationMetadataManager';
8
8
  import type { IPhase } from '../../api/CommandLineConfiguration';
9
9
  import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
10
- import type { IOperationExecutionResult } from './IOperationExecutionResult';
10
+ import type { IOperationExecutionResult, IOperationStateHashComponents } from './IOperationExecutionResult';
11
11
  import type { IInputsSnapshot } from '../incremental/InputsSnapshot';
12
12
  import type { IEnvironment } from '../../utilities/Utilities';
13
13
  import { type ILogFilePaths } from './ProjectLogWritable';
@@ -16,12 +16,22 @@ import { type ILogFilePaths } from './ProjectLogWritable';
16
16
  */
17
17
  export interface IOperationExecutionRecordContext {
18
18
  streamCollator: StreamCollator;
19
- onOperationStatusChanged?: (record: OperationExecutionRecord) => void;
19
+ onOperationStateChanged?: (record: OperationExecutionRecord) => void;
20
20
  createEnvironment?: (record: OperationExecutionRecord) => IEnvironment;
21
+ invalidate?: (operations: Iterable<Operation>, reason: string) => void;
21
22
  inputsSnapshot: IInputsSnapshot | undefined;
23
+ maxParallelism: number;
22
24
  debugMode: boolean;
23
25
  quietMode: boolean;
24
26
  }
27
+ /**
28
+ * Context object for the executeAsync() method.
29
+ * @internal
30
+ */
31
+ export interface IOperationExecutionContext {
32
+ onStartAsync: (record: OperationExecutionRecord) => Promise<OperationStatus | undefined>;
33
+ onResultAsync: (record: OperationExecutionRecord) => Promise<void>;
34
+ }
25
35
  /**
26
36
  * Internal class representing everything about executing an operation
27
37
  *
@@ -37,6 +47,10 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
37
47
  * it later (for example to re-print errors at end of execution).
38
48
  */
39
49
  error: Error | undefined;
50
+ /**
51
+ * If true, this operation should be executed. If false, it should be skipped.
52
+ */
53
+ enabled: boolean;
40
54
  /**
41
55
  * This number represents how far away this Operation is from the furthest "root" operation (i.e.
42
56
  * an operation with no consumers). This helps us to calculate the critical path (i.e. the
@@ -81,6 +95,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
81
95
  readonly stdioSummarizer: StdioSummarizer;
82
96
  readonly problemCollector: ProblemCollector;
83
97
  readonly runner: IOperationRunner;
98
+ readonly weight: number;
84
99
  readonly associatedPhase: IPhase;
85
100
  readonly associatedProject: RushConfigurationProject;
86
101
  readonly _operationMetadataManager: OperationMetadataManager;
@@ -92,14 +107,14 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
92
107
  private _stateHashComponents;
93
108
  constructor(operation: Operation, context: IOperationExecutionRecordContext);
94
109
  get name(): string;
95
- get weight(): number;
96
110
  get debugMode(): boolean;
97
111
  get quietMode(): boolean;
98
112
  get collatedWriter(): CollatedWriter;
99
113
  get nonCachedDurationMs(): number | undefined;
100
114
  get cobuildRunnerId(): string | undefined;
101
115
  get environment(): IEnvironment | undefined;
102
- get metadataFolderPath(): string | undefined;
116
+ getInvalidateCallback(): (reason: string) => void;
117
+ get metadataFolderPath(): string;
103
118
  get isTerminal(): boolean;
104
119
  /**
105
120
  * The current execution status of an operation. Operations start in the 'ready' state,
@@ -111,7 +126,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
111
126
  set status(newStatus: OperationStatus);
112
127
  get silent(): boolean;
113
128
  getStateHash(): string;
114
- getStateHashComponents(): ReadonlyArray<string>;
129
+ getStateHashComponents(): IOperationStateHashComponents;
115
130
  /**
116
131
  * {@inheritdoc IOperationRunnerContext.runWithTerminalAsync}
117
132
  */
@@ -119,9 +134,6 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
119
134
  createLogFile: boolean;
120
135
  logFileSuffix: string;
121
136
  }): Promise<T>;
122
- executeAsync({ onStart, onResult }: {
123
- onStart: (record: OperationExecutionRecord) => Promise<OperationStatus | undefined>;
124
- onResult: (record: OperationExecutionRecord) => Promise<void>;
125
- }): Promise<void>;
137
+ executeAsync(lastState: OperationExecutionRecord | undefined, executeContext: IOperationExecutionContext): Promise<void>;
126
138
  }
127
139
  //# sourceMappingURL=OperationExecutionRecord.d.ts.map
@@ -0,0 +1,125 @@
1
+ import { type TerminalWritable } from '@rushstack/terminal';
2
+ import type { Operation } from './Operation';
3
+ import { OperationStatus } from './OperationStatus';
4
+ import { OperationExecutionRecord } from './OperationExecutionRecord';
5
+ import type { IExecutionResult } from './IOperationExecutionResult';
6
+ import type { IInputsSnapshot } from '../incremental/InputsSnapshot';
7
+ import type { IOperationGraph, IOperationGraphIterationOptions } from './IOperationGraph';
8
+ import { OperationGraphHooks } from '../../pluginFramework/OperationGraphHooks';
9
+ import { type Parallelism } from './ParseParallelism';
10
+ import type { ITelemetryData } from '../Telemetry';
11
+ export interface IOperationGraphTelemetry {
12
+ initialExtraData: Record<string, unknown>;
13
+ changedProjectsOnlyKey: string | undefined;
14
+ nameForLog: string;
15
+ log: (telemetry: ITelemetryData) => void;
16
+ }
17
+ export interface IOperationGraphOptions {
18
+ quietMode: boolean;
19
+ debugMode: boolean;
20
+ parallelism: Parallelism;
21
+ allowOversubscription: boolean;
22
+ destinations: Iterable<TerminalWritable>;
23
+ /** Optional maximum allowed parallelism. Defaults to `getNumberOfCores()`. */
24
+ maxParallelism?: number;
25
+ /**
26
+ * Controller used to signal abortion of the entire execution session (e.g. terminating watch mode).
27
+ * Consumers (e.g. ProjectWatcher) can subscribe to this to perform cleanup.
28
+ */
29
+ abortController: AbortController;
30
+ isWatch?: boolean;
31
+ pauseNextIteration?: boolean;
32
+ telemetry?: IOperationGraphTelemetry;
33
+ getInputsSnapshotAsync?: () => Promise<IInputsSnapshot | undefined>;
34
+ }
35
+ /**
36
+ * A class which manages the execution of a set of tasks with interdependencies.
37
+ */
38
+ export declare class OperationGraph implements IOperationGraph {
39
+ readonly hooks: OperationGraphHooks;
40
+ readonly operations: Set<Operation>;
41
+ readonly abortController: AbortController;
42
+ private readonly _sortedOperations;
43
+ resultByOperation: Map<Operation, OperationExecutionRecord>;
44
+ private _parallelism;
45
+ private _maxParallelism;
46
+ private _debugMode;
47
+ private _quietMode;
48
+ private _allowOversubscription;
49
+ private _pauseNextIteration;
50
+ private readonly _isWatch;
51
+ private readonly _telemetry;
52
+ private readonly _getInputsSnapshotAsync;
53
+ /**
54
+ * Records invalidated during the current iteration that could not be marked `Ready` immediately
55
+ * because their record object is shared between `resultByOperation` and the active iteration's
56
+ * `records` map (mutating it mid-iteration would corrupt the summarizer's view of results).
57
+ * Maps each record to the invalidation reason; applied once the iteration completes.
58
+ */
59
+ private readonly _deferredInvalidations;
60
+ private _currentIteration;
61
+ private _scheduledIteration;
62
+ private _terminalSplitter;
63
+ private _idleTimeout;
64
+ /** Tracks if a graph state change notification has been scheduled for next tick. */
65
+ private _graphStateChangeScheduled;
66
+ private _status;
67
+ constructor(operations: Set<Operation>, options: IOperationGraphOptions);
68
+ /**
69
+ * {@inheritDoc IOperationGraph.setEnabledStates}
70
+ */
71
+ setEnabledStates(operations: Iterable<Operation>, targetState: Operation['enabled'], mode: 'safe' | 'unsafe'): boolean;
72
+ get parallelism(): number;
73
+ set parallelism(value: Parallelism);
74
+ get debugMode(): boolean;
75
+ set debugMode(value: boolean);
76
+ get quietMode(): boolean;
77
+ set quietMode(value: boolean);
78
+ get allowOversubscription(): boolean;
79
+ set allowOversubscription(value: boolean);
80
+ get pauseNextIteration(): boolean;
81
+ set pauseNextIteration(value: boolean);
82
+ get hasScheduledIteration(): boolean;
83
+ get status(): OperationStatus;
84
+ get terminalDestinations(): ReadonlySet<TerminalWritable>;
85
+ private _setStatus;
86
+ private _setScheduledIteration;
87
+ closeRunnersAsync(operations?: Operation[]): Promise<void>;
88
+ invalidateOperations(operations?: Iterable<Operation>, reason?: string): void;
89
+ /**
90
+ * Shorthand for scheduling an iteration then executing it.
91
+ * Call `abortCurrentIterationAsync()` to cancel the execution of any operations that have not yet begun execution.
92
+ * @param iterationOptions - Options for this execution iteration.
93
+ * @returns A promise which is resolved when all operations have been processed to a final state.
94
+ */
95
+ executeAsync(iterationOptions: IOperationGraphIterationOptions): Promise<IExecutionResult>;
96
+ /**
97
+ * Queues a new execution iteration.
98
+ * @param iterationOptions - Options for this execution iteration.
99
+ * @returns A promise that resolves to true if the iteration was successfully queued, or false if it was not.
100
+ */
101
+ scheduleIterationAsync(iterationOptions: IOperationGraphIterationOptions): Promise<boolean>;
102
+ /**
103
+ * Executes all operations which have been registered, returning a promise which is resolved when all operations have been processed to a final state.
104
+ * Aborts the current iteration first, if any.
105
+ */
106
+ executeScheduledIterationAsync(): Promise<boolean>;
107
+ abortCurrentIterationAsync(): Promise<void>;
108
+ addTerminalDestination(destination: TerminalWritable): void;
109
+ removeTerminalDestination(destination: TerminalWritable, close?: boolean): boolean;
110
+ private _setIdleTimeout;
111
+ private _onIdle;
112
+ private _scheduleIterationAsync;
113
+ /**
114
+ * Debounce configuration change notifications so that multiple property setters invoked within the same tick
115
+ * only trigger the hook once. This avoids redundant re-computation in listeners (e.g. UI refresh) while preserving
116
+ * ordering guarantees that the notification occurs after the initiating state changes are fully applied.
117
+ */
118
+ private _scheduleManagerStateChanged;
119
+ /**
120
+ * Executes all operations which have been registered, returning a promise which is resolved when all operations have been processed to a final state.
121
+ * The abortController can be used to cancel the execution of any operations that have not yet begun execution.
122
+ */
123
+ private _executeInnerAsync;
124
+ }
125
+ //# sourceMappingURL=OperationGraph.d.ts.map
@@ -57,4 +57,8 @@ export declare enum OperationStatus {
57
57
  * @alpha
58
58
  */
59
59
  export declare const TERMINAL_STATUSES: Set<OperationStatus>;
60
+ /**
61
+ * The set of statuses that are considered successful and don't trigger a rebuild if current.
62
+ */
63
+ export declare const SUCCESS_STATUSES: Set<OperationStatus>;
60
64
  //# sourceMappingURL=OperationStatus.d.ts.map
@@ -0,0 +1,33 @@
1
+ export declare function getNumberOfCores(): number;
2
+ /**
3
+ * A parallelism value expressed as a fraction of total available concurrency slots.
4
+ * @beta
5
+ */
6
+ export interface IParallelismScalar {
7
+ readonly scalar: number;
8
+ }
9
+ /**
10
+ * A parallelism value, either as an absolute integer count or a scalar fraction of available parallelism.
11
+ * @beta
12
+ */
13
+ export type Parallelism = number | IParallelismScalar;
14
+ /**
15
+ * Since the JSON value is a string, it must be a percentage like "50%",
16
+ * which we parse into a scalar in the range (0, 1].
17
+ * The caller is responsible for multiplying by the available parallelism.
18
+ */
19
+ export declare function parseParallelismPercent(weight: string): number;
20
+ /**
21
+ * Coerces a `Parallelism` value to a concrete integer number of concurrency units, given the
22
+ * maximum number of available slots.
23
+ *
24
+ * - Raw numeric values are clamped to `[minimum, maxParallelism]`.
25
+ * - Scalar values are multiplied by `maxParallelism`, floored, and clamped to `[Math.max(1, minimum), maxParallelism]`.
26
+ */
27
+ export declare function coerceParallelism(parallelism: Parallelism, maxParallelism: number, minimum?: number): number;
28
+ /**
29
+ * Parses a command line specification for desired parallelism.
30
+ * Factored out to enable unit tests
31
+ */
32
+ export declare function parseParallelism(rawParallelism: string | undefined): Parallelism;
33
+ //# sourceMappingURL=ParseParallelism.d.ts.map
@@ -1,12 +1,13 @@
1
1
  import type { IPhase } from '../../api/CommandLineConfiguration';
2
2
  import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
3
- import type { IOperationRunner, IOperationRunnerContext } from './IOperationRunner';
3
+ import type { IOperationRunner, IOperationRunnerContext, IOperationLastState } from './IOperationRunner';
4
4
  import { OperationStatus } from './OperationStatus';
5
5
  export interface IShellOperationRunnerOptions {
6
6
  phase: IPhase;
7
7
  rushProject: RushConfigurationProject;
8
8
  displayName: string;
9
- commandToRun: string;
9
+ initialCommand: string;
10
+ incrementalCommand: string | undefined;
10
11
  commandForHash: string;
11
12
  ignoredParameterValues: ReadonlyArray<string>;
12
13
  }
@@ -21,18 +22,18 @@ export declare class ShellOperationRunner implements IOperationRunner {
21
22
  readonly silent: boolean;
22
23
  readonly cacheable: boolean;
23
24
  readonly warningsAreAllowed: boolean;
24
- readonly commandToRun: string;
25
25
  /**
26
26
  * The creator is expected to use a different runner if the command is known to be a noop.
27
27
  */
28
28
  readonly isNoOp: boolean;
29
29
  private readonly _commandForHash;
30
+ private readonly _initialCommand;
31
+ private readonly _incrementalCommand;
30
32
  private readonly _rushProject;
31
33
  private readonly _ignoredParameterValues;
32
34
  constructor(options: IShellOperationRunnerOptions);
33
- executeAsync(context: IOperationRunnerContext): Promise<OperationStatus>;
35
+ executeAsync(context: IOperationRunnerContext, lastState?: IOperationLastState): Promise<OperationStatus>;
34
36
  getConfigHash(): string;
35
- private _executeAsync;
36
37
  }
37
38
  /**
38
39
  * When running a command from the "scripts" block in package.json, if the command
@@ -16,7 +16,8 @@ export declare function initializeShellOperationRunner(options: {
16
16
  project: RushConfigurationProject;
17
17
  displayName: string;
18
18
  rushConfiguration: RushConfiguration;
19
- commandToRun: string | undefined;
19
+ initialCommand: string | undefined;
20
+ incrementalCommand: string | undefined;
20
21
  commandForHash?: string;
21
22
  customParameterValues: ReadonlyArray<string>;
22
23
  ignoredParameterValues: ReadonlyArray<string>;
@@ -1,13 +1,11 @@
1
1
  import type { ITerminal } from '@rushstack/terminal';
2
2
  import type { IPhasedCommandPlugin, PhasedCommandHooks } from '../../pluginFramework/PhasedCommandHooks';
3
3
  /**
4
- * Core phased command plugin that provides the functionality for generating a base operation graph
5
- * from the set of selected projects and phases.
4
+ * Core phased command plugin that verifies correctness of the entries in rush-project.json
6
5
  */
7
6
  export declare class ValidateOperationsPlugin implements IPhasedCommandPlugin {
8
7
  private readonly _terminal;
9
8
  constructor(terminal: ITerminal);
10
9
  apply(hooks: PhasedCommandHooks): void;
11
- private _validateOperations;
12
10
  }
13
11
  //# sourceMappingURL=ValidateOperationsPlugin.d.ts.map
@@ -0,0 +1,129 @@
1
+ import { AsyncSeriesBailHook, AsyncSeriesHook, AsyncSeriesWaterfallHook, SyncHook, SyncWaterfallHook } from 'tapable';
2
+ import type { Operation } from '../logic/operations/Operation';
3
+ import type { IOperationExecutionResult, IConfigurableOperation } from '../logic/operations/IOperationExecutionResult';
4
+ import type { OperationStatus } from '../logic/operations/OperationStatus';
5
+ import type { IOperationRunnerContext } from '../logic/operations/IOperationRunner';
6
+ import type { ITelemetryData } from '../logic/Telemetry';
7
+ import type { IEnvironment } from '../utilities/Utilities';
8
+ import type { IOperationGraph, IOperationGraphIterationOptions } from '../logic/operations/IOperationGraph';
9
+ /**
10
+ * Hooks into the execution process for operations within the graph.
11
+ *
12
+ * Per-iteration lifecycle:
13
+ * 1. `configureIteration` - Synchronously decide which operations to enable for the next iteration.
14
+ * 2. `onIterationScheduled` - Fires after the iteration is prepared but before execution begins, if it has any enabled operations.
15
+ * 3. `beforeExecuteIterationAsync` - Async hook that can bail out the iteration entirely.
16
+ * 4. Operations execute (status changes reported via `onExecutionStatesUpdated`).
17
+ * 5. `afterExecuteIterationAsync` - Fires after all operations in the iteration have settled.
18
+ * 6. `onIdle` - Fires when the graph enters idle state awaiting changes (watch mode only).
19
+ *
20
+ * Additional hooks:
21
+ * - `onEnableStatesChanged` - Fires when `setEnabledStates` mutates operation enabled flags.
22
+ * - `onInvalidateOperations` - Fires when operations are invalidated (e.g. by file watchers).
23
+ * - `onGraphStateChanged` - Fires on any observable graph state change.
24
+ *
25
+ * @alpha
26
+ */
27
+ export declare class OperationGraphHooks {
28
+ /**
29
+ * Hook invoked to decide what work a potential new iteration contains.
30
+ * Use the `lastExecutedRecords` to determine which operations are new or have had their inputs changed.
31
+ * Set the `enabled` states on the values in `initialRecords` to control which operations will be executed.
32
+ *
33
+ * @remarks
34
+ * This hook is synchronous to guarantee that the `lastExecutedRecords` map remains stable for the
35
+ * duration of configuration. This hook often executes while an execution iteration is currently running, so
36
+ * operations could complete if there were async ticks during the configuration phase.
37
+ *
38
+ * If no operations are marked for execution, the iteration will not be scheduled.
39
+ * If there is an existing scheduled iteration, it will remain.
40
+ */
41
+ readonly configureIteration: SyncHook<[
42
+ ReadonlyMap<Operation, IConfigurableOperation>,
43
+ ReadonlyMap<Operation, IOperationExecutionResult>,
44
+ IOperationGraphIterationOptions
45
+ ]>;
46
+ /**
47
+ * Hook invoked before operation start for an iteration. Allows a plugin to perform side-effects or
48
+ * short-circuit the entire iteration.
49
+ *
50
+ * If any tap returns an {@link OperationStatus}, the remaining taps are skipped and the iteration will
51
+ * end immediately with that status. All operations which have not yet executed will be marked
52
+ * Aborted.
53
+ */
54
+ readonly beforeExecuteIterationAsync: AsyncSeriesBailHook<[
55
+ ReadonlyMap<Operation, IOperationExecutionResult>,
56
+ IOperationGraphIterationOptions
57
+ ], OperationStatus | undefined | void>;
58
+ /**
59
+ * Batched hook invoked when one or more operation statuses have changed during the same microtask.
60
+ * The hook receives an array of the operation execution results that changed status.
61
+ * @remarks
62
+ * This hook is batched to reduce noise when updating many operations synchronously in quick succession.
63
+ */
64
+ readonly onExecutionStatesUpdated: SyncHook<[ReadonlySet<IOperationExecutionResult>]>;
65
+ /**
66
+ * Hook invoked when one or more operations have their enabled state mutated via
67
+ * {@link IOperationGraph.setEnabledStates}. Provides the set of operations whose
68
+ * enabled state actually changed.
69
+ */
70
+ readonly onEnableStatesChanged: SyncHook<[ReadonlySet<Operation>]>;
71
+ /**
72
+ * Hook invoked immediately after a new execution iteration is scheduled (i.e. operations selected and prepared),
73
+ * before any operations in that iteration have started executing. Can be used to snapshot planned work,
74
+ * drive UIs, or pre-compute auxiliary data.
75
+ */
76
+ readonly onIterationScheduled: SyncHook<[ReadonlyMap<Operation, IOperationExecutionResult>]>;
77
+ /**
78
+ * Hook invoked when any observable state on the operation graph changes.
79
+ * This includes configuration mutations (parallelism, quiet/debug modes, pauseNextIteration)
80
+ * as well as dynamic state (status transitions, scheduled iteration availability, etc.).
81
+ * Hook is series for stable output.
82
+ */
83
+ readonly onGraphStateChanged: SyncHook<[IOperationGraph]>;
84
+ /**
85
+ * Hook invoked when operations are invalidated for any reason.
86
+ */
87
+ readonly onInvalidateOperations: SyncHook<[Iterable<Operation>, string | undefined]>;
88
+ /**
89
+ * Hook invoked after an iteration has finished and the command is watching for changes.
90
+ * May be used to display additional relevant data to the user.
91
+ * Only relevant when running in watch mode.
92
+ */
93
+ readonly onIdle: SyncHook<void>;
94
+ /**
95
+ * Hook invoked after executing a set of operations.
96
+ * Hook is series for stable output.
97
+ */
98
+ readonly afterExecuteIterationAsync: AsyncSeriesWaterfallHook<[
99
+ OperationStatus,
100
+ ReadonlyMap<Operation, IOperationExecutionResult>,
101
+ IOperationGraphIterationOptions
102
+ ]>;
103
+ /**
104
+ * Hook invoked after executing an iteration, before the telemetry entry is written.
105
+ * Allows the caller to augment or modify the log entry.
106
+ */
107
+ readonly beforeLog: SyncHook<ITelemetryData, void>;
108
+ /**
109
+ * Hook invoked before executing a operation.
110
+ */
111
+ readonly beforeExecuteOperationAsync: AsyncSeriesBailHook<[
112
+ IOperationRunnerContext & IOperationExecutionResult
113
+ ], OperationStatus | undefined>;
114
+ /**
115
+ * Hook invoked to define environment variables for an operation.
116
+ * May be invoked by the runner to get the environment for the operation.
117
+ */
118
+ readonly createEnvironmentForOperation: SyncWaterfallHook<[
119
+ IEnvironment,
120
+ IOperationRunnerContext & IOperationExecutionResult
121
+ ]>;
122
+ /**
123
+ * Hook invoked after executing a operation.
124
+ */
125
+ readonly afterExecuteOperationAsync: AsyncSeriesHook<[
126
+ IOperationRunnerContext & IOperationExecutionResult
127
+ ]>;
128
+ }
129
+ //# sourceMappingURL=OperationGraphHooks.d.ts.map