Skip to content

Commit b23911b

Browse files
committed
Rename pass -> iteration
1 parent 2da4c4a commit b23911b

17 files changed

+290
-305
lines changed

common/reviews/api/rush-lib.api.md

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -618,24 +618,31 @@ export interface _IOperationBuildCacheOptions {
618618
terminal: ITerminal;
619619
}
620620

621+
// @alpha
622+
export interface IOperationExecutionIterationOptions {
623+
// (undocumented)
624+
inputsSnapshot?: IInputsSnapshot;
625+
startTime?: number;
626+
}
627+
621628
// @alpha
622629
export interface IOperationExecutionManager {
623630
readonly abortController: AbortController;
624-
abortCurrentPassAsync(): Promise<void>;
631+
abortCurrentIterationAsync(): Promise<void>;
625632
addTerminalDestination(destination: TerminalWritable): void;
626633
closeRunnersAsync(operations?: Iterable<Operation>): Promise<void>;
627634
debugMode: boolean;
628-
executeQueuedPassAsync(): Promise<boolean>;
629-
readonly hasQueuedPass: boolean;
635+
executeScheduledIterationAsync(): Promise<boolean>;
636+
readonly hasScheduledIteration: boolean;
630637
readonly hooks: OperationExecutionHooks;
631638
invalidateOperations(operations?: Iterable<Operation>, reason?: string): void;
632639
readonly lastExecutionResults: ReadonlyMap<Operation, IOperationExecutionResult>;
633640
readonly operations: ReadonlySet<Operation>;
634641
parallelism: number;
635-
queuePassAsync(options: IOperationExecutionPassOptions): Promise<boolean>;
642+
pauseNextIteration: boolean;
636643
quietMode: boolean;
637644
removeTerminalDestination(destination: TerminalWritable, close?: boolean): boolean;
638-
runNextPassBehavior: RunNextPassBehavior;
645+
scheduleIterationAsync(options: IOperationExecutionIterationOptions): Promise<boolean>;
639646
setEnabledStates(operations: Iterable<Operation>, targetState: Operation['enabled'], mode: 'safe' | 'unsafe'): boolean;
640647
readonly status: OperationStatus;
641648
}
@@ -645,13 +652,6 @@ export interface IOperationExecutionManagerContext extends ICreateOperationsCont
645652
readonly initialSnapshot?: IInputsSnapshot;
646653
}
647654

648-
// @alpha
649-
export interface IOperationExecutionPassOptions {
650-
// (undocumented)
651-
inputsSnapshot?: IInputsSnapshot;
652-
startTime?: number;
653-
}
654-
655655
// @alpha
656656
export interface IOperationExecutionResult extends IBaseOperationExecutionResult {
657657
readonly enabled: boolean;
@@ -1066,25 +1066,25 @@ export type OperationEnabledState = boolean | 'ignore-dependency-changes';
10661066

10671067
// @alpha
10681068
export class OperationExecutionHooks {
1069+
readonly afterExecuteIterationAsync: AsyncSeriesWaterfallHook<[
1070+
OperationStatus,
1071+
ReadonlyMap<Operation, IOperationExecutionResult>,
1072+
IOperationExecutionIterationOptions
1073+
]>;
10691074
readonly afterExecuteOperationAsync: AsyncSeriesHook<[
10701075
IOperationRunnerContext & IOperationExecutionResult
10711076
]>;
1072-
readonly afterExecuteOperationsAsync: AsyncSeriesWaterfallHook<[
1073-
OperationStatus,
1077+
readonly beforeExecuteIterationAsync: AsyncSeriesBailHook<[
10741078
ReadonlyMap<Operation, IOperationExecutionResult>,
1075-
IOperationExecutionPassOptions
1076-
]>;
1079+
IOperationExecutionIterationOptions
1080+
], OperationStatus | undefined | void>;
10771081
readonly beforeExecuteOperationAsync: AsyncSeriesBailHook<[
10781082
IOperationRunnerContext & IOperationExecutionResult
10791083
], OperationStatus | undefined>;
1080-
readonly beforeExecuteOperationsAsync: AsyncSeriesBailHook<[
1081-
ReadonlyMap<Operation, IOperationExecutionResult>,
1082-
IOperationExecutionPassOptions
1083-
], OperationStatus | undefined | void>;
1084-
readonly configureRun: SyncHook<[
1084+
readonly configureIteration: SyncHook<[
10851085
ReadonlyMap<Operation, IConfigurableOperation>,
10861086
ReadonlyMap<Operation, IOperationExecutionResult>,
1087-
IOperationExecutionPassOptions
1087+
IOperationExecutionIterationOptions
10881088
]>;
10891089
readonly createEnvironmentForOperation: SyncWaterfallHook<[
10901090
IEnvironment,
@@ -1093,8 +1093,8 @@ export class OperationExecutionHooks {
10931093
readonly onEnableStatesChanged: SyncHook<[ReadonlySet<Operation>]>;
10941094
readonly onExecutionStatesUpdated: SyncHook<[ReadonlySet<IOperationExecutionResult>]>;
10951095
readonly onInvalidateOperations: SyncHook<[Iterable<Operation>, string | undefined]>;
1096+
readonly onIterationScheduled: SyncHook<[ReadonlyMap<Operation, IOperationExecutionResult>]>;
10961097
readonly onManagerStateChanged: SyncHook<[IOperationExecutionManager]>;
1097-
readonly onPassQueued: SyncHook<[ReadonlyMap<Operation, IOperationExecutionResult>]>;
10981098
readonly onWaitingForChanges: SyncHook<void>;
10991099
}
11001100

@@ -1299,9 +1299,6 @@ export class RepoStateFile {
12991299
refreshState(rushConfiguration: RushConfiguration, subspace: Subspace | undefined, variant?: string): boolean;
13001300
}
13011301

1302-
// @alpha (undocumented)
1303-
export type RunNextPassBehavior = 'manual' | 'automatic';
1304-
13051302
// @public
13061303
export class Rush {
13071304
static launch(launcherVersion: string, options: ILaunchOptions): void;

libraries/rush-lib/src/api/EventHooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Enum } from '@rushstack/node-core-library';
66
import type { IEventHooksJson } from './RushConfiguration';
77

88
/**
9-
* Events happen during Rush runs.
9+
* Events happen during Rush invocation.
1010
* @beta
1111
*/
1212
export enum Event {

libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type { Subspace } from '../../api/Subspace';
1717
import type { IPhasedCommand } from '../../pluginFramework/RushLifeCycle';
1818
import {
1919
type IOperationExecutionManagerContext,
20-
type IOperationExecutionPassOptions,
20+
type IOperationExecutionIterationOptions,
2121
PhasedCommandHooks,
2222
type ICreateOperationsContext
2323
} from '../../pluginFramework/PhasedCommandHooks';
@@ -596,7 +596,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
596596
destinations: [StdioWritable.instance],
597597
parallelism,
598598
isWatch,
599-
runNextPassBehavior: 'automatic',
599+
pauseNextIteration: false,
600600
getInputsSnapshotAsync,
601601
abortController: this.sessionAbortController,
602602
telemetry: executionTelemetryHandler
@@ -614,7 +614,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
614614

615615
const abortPromise: Promise<void> = once(this.sessionAbortController.signal, 'abort').then(() => {
616616
terminal.writeLine(`Exiting watch mode...`);
617-
return executionManager.abortCurrentPassAsync();
617+
return executionManager.abortCurrentIterationAsync();
618618
});
619619

620620
await measureAsyncFn(`${PERF_PREFIX}:executionManager`, async () => {
@@ -629,7 +629,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
629629
terminal
630630
};
631631

632-
const initialPassOptions: IOperationExecutionPassOptions = {
632+
const initialIterationOptions: IOperationExecutionIterationOptions = {
633633
inputsSnapshot: initialSnapshot,
634634
// Mark as starting at time 0, which is process startup.
635635
startTime: 0
@@ -659,7 +659,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
659659
watcher.clearStatus();
660660

661661
await measureAsyncFn(`${PERF_PREFIX}:executeOperationsInner`, async () => {
662-
return await executionManager.executeAsync(initialPassOptions);
662+
return await executionManager.executeAsync(initialIterationOptions);
663663
});
664664

665665
await abortPromise;
@@ -668,7 +668,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
668668
} else {
669669
await measureAsyncFn(`${PERF_PREFIX}:runInitialPhases`, () =>
670670
measureAsyncFn(`${PERF_PREFIX}:executeOperations`, () =>
671-
this._executeOperationsAsync(executeOptions, initialPassOptions)
671+
this._executeOperationsAsync(executeOptions, initialIterationOptions)
672672
)
673673
);
674674
}
@@ -684,22 +684,22 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
684684
*/
685685
private async _executeOperationsAsync(
686686
options: IExecuteOperationsOptions,
687-
passOptions: IOperationExecutionPassOptions
687+
iterationOptions: IOperationExecutionIterationOptions
688688
): Promise<void> {
689689
const { executionManager, ignoreHooks, stopwatch, isWatch, terminal } = options;
690690

691691
let success: boolean = false;
692692
let result: IExecutionResult | undefined;
693693

694-
if (passOptions.startTime) {
695-
(stopwatch as { startTime: number }).startTime = passOptions.startTime;
694+
if (iterationOptions.startTime) {
695+
(stopwatch as { startTime: number }).startTime = iterationOptions.startTime;
696696
}
697697

698698
try {
699699
const definiteResult: IExecutionResult = await measureAsyncFn(
700700
`${PERF_PREFIX}:executeOperationsInner`,
701701
async () => {
702-
return await executionManager.executeAsync(passOptions);
702+
return await executionManager.executeAsync(iterationOptions);
703703
}
704704
);
705705
success = definiteResult.status === OperationStatus.Success;

libraries/rush-lib/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,12 @@ export {
162162

163163
export {
164164
type ICreateOperationsContext,
165-
type IOperationExecutionPassOptions,
165+
type IOperationExecutionIterationOptions,
166166
type IOperationExecutionManagerContext,
167167
type IOperationExecutionManager,
168168
type IPhasedCommandPlugin,
169169
PhasedCommandHooks,
170-
OperationExecutionHooks,
171-
type RunNextPassBehavior
170+
OperationExecutionHooks
172171
} from './pluginFramework/PhasedCommandHooks';
173172

174173
export type { IRushPlugin } from './pluginFramework/IRushPlugin';

libraries/rush-lib/src/logic/ProjectWatcher.ts

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { RushConfiguration } from '../api/RushConfiguration';
1616
import type { RushConfigurationProject } from '../api/RushConfigurationProject';
1717
import type { IOperationExecutionManager } from '../pluginFramework/PhasedCommandHooks';
1818
import type { Operation } from './operations/Operation';
19-
import type { IOperationExecutionPassOptions } from '../pluginFramework/PhasedCommandHooks';
19+
import type { IOperationExecutionIterationOptions } from '../pluginFramework/PhasedCommandHooks';
2020
import { OperationStatus } from './operations/OperationStatus';
2121

2222
export interface IProjectWatcherOptions {
@@ -85,15 +85,15 @@ export class ProjectWatcher {
8585
// Initialize stdin listener early so keybinds are available immediately
8686
this._ensureStdin();
8787

88-
// Capture snapshot (if provided) prior to executing next operations pass (will replace initial snapshot)
89-
executionManager.hooks.beforeExecuteOperationsAsync.tapPromise(
88+
// Capture snapshot (if provided) prior to executing next iteration (will replace initial snapshot)
89+
executionManager.hooks.beforeExecuteIterationAsync.tapPromise(
9090
'ProjectWatcher',
9191
async (
9292
records: ReadonlyMap<Operation, unknown>,
93-
passOptions: IOperationExecutionPassOptions
93+
iterationOptions: IOperationExecutionIterationOptions
9494
): Promise<void> => {
9595
this.clearStatus();
96-
this._lastSnapshot = passOptions.inputsSnapshot;
96+
this._lastSnapshot = iterationOptions.inputsSnapshot;
9797
await this._stopWatchingAsync();
9898
}
9999
);
@@ -121,19 +121,11 @@ export class ProjectWatcher {
121121
this._setStatus(this._lastStatus ?? 'Waiting for changes...');
122122
}
123123

124-
/**
125-
* Waits for a change to the package-deps of one or more of the selected projects, since the previous invocation.
126-
* Will return immediately the first time it is invoked, since no state has been recorded.
127-
* If no change is currently present, watches the source tree of all selected projects for file changes.
128-
* `waitForChange` is not allowed to be called multiple times concurrently.
129-
*/
130-
// Previous waitForChangeAsync logic removed; watching is now driven by execution manager lifecycle.
131-
132124
private _setStatus(status: string): void {
133-
const isPaused: boolean = this._executionManager.runNextPassBehavior === 'manual';
134-
const hasQueuedPass: boolean = this._executionManager.hasQueuedPass;
125+
const isPaused: boolean = this._executionManager.pauseNextIteration === true;
126+
const hasScheduledIteration: boolean = this._executionManager.hasScheduledIteration;
135127
const modeLabel: string = isPaused ? 'PAUSED' : 'WATCHING';
136-
const pendingLabel: string = hasQueuedPass ? ' PENDING' : '';
128+
const pendingLabel: string = hasScheduledIteration ? ' PENDING' : '';
137129
const statusLines: string[] = [`[${modeLabel}${pendingLabel}] Watch Status: ${status}`];
138130
if (this._stdinListening) {
139131
const em: IOperationExecutionManager = this._executionManager;
@@ -144,7 +136,7 @@ export class ProjectWatcher {
144136
);
145137
// Second line: keybind help kept concise to avoid overwhelming output
146138
lines.push(
147-
' keys(active): [q]quit [a]abort-pass [i]invalidate [x]close-runners [d]debug ' +
139+
' keys(active): [q]quit [a]abort-iteration [i]invalidate [x]close-runners [d]debug ' +
148140
'[v]verbose [w]pause/resume [b]build [+/-]parallelism'
149141
);
150142
statusLines.push(...lines.map((l) => ` ${l}`));
@@ -286,14 +278,14 @@ export class ProjectWatcher {
286278
if (this._debounceHandle) {
287279
clearTimeout(this._debounceHandle);
288280
}
289-
this._debounceHandle = setTimeout(() => this._queueNextPass(), this._debounceMs);
281+
this._debounceHandle = setTimeout(() => this._scheduleIteration(), this._debounceMs);
290282
}
291283

292-
private _queueNextPass(): void {
293-
this._setStatus('File change detected. Queuing new pass...');
284+
private _scheduleIteration(): void {
285+
this._setStatus('File change detected. Queuing new iteration...');
294286
this._executionManager
295-
.queuePassAsync({} as IOperationExecutionPassOptions)
296-
.catch((e) => this._terminal.writeErrorLine(`Failed to queue pass: ${(e as Error).message}`));
287+
.scheduleIterationAsync({} as IOperationExecutionIterationOptions)
288+
.catch((e) => this._terminal.writeErrorLine(`Failed to queue iteration: ${(e as Error).message}`));
297289
}
298290

299291
/** Setup stdin listener for interactive keybinds */
@@ -351,8 +343,8 @@ export class ProjectWatcher {
351343
manager.abortController.abort();
352344
return; // stop processing further chars
353345
case 'a':
354-
void manager.abortCurrentPassAsync().then(() => {
355-
this._setStatus('Current pass aborted');
346+
void manager.abortCurrentIterationAsync().then(() => {
347+
this._setStatus('Current iteration aborted');
356348
});
357349
break;
358350
case 'i':
@@ -373,8 +365,9 @@ export class ProjectWatcher {
373365
this._setStatus(`Verbose mode ${!manager.quietMode ? 'enabled' : 'disabled'}`);
374366
break;
375367
case 'w':
376-
manager.runNextPassBehavior = manager.runNextPassBehavior === 'automatic' ? 'manual' : 'automatic';
377-
this._setStatus(manager.runNextPassBehavior === 'manual' ? 'Watch paused' : 'Watch resumed');
368+
// Toggle pauseNextIteration mode
369+
manager.pauseNextIteration = !manager.pauseNextIteration;
370+
this._setStatus(manager.pauseNextIteration ? 'Watch paused' : 'Watch resumed');
378371
break;
379372
case '+':
380373
case '=':
@@ -385,12 +378,12 @@ export class ProjectWatcher {
385378
break;
386379
case 'b':
387380
// Queue and (if manual) execute
388-
void manager.queuePassAsync({ startTime: performance.now() }).then((queued) => {
381+
void manager.scheduleIterationAsync({ startTime: performance.now() }).then((queued) => {
389382
if (queued) {
390-
if (manager.runNextPassBehavior === 'manual') {
391-
void manager.executeQueuedPassAsync();
383+
if (manager.pauseNextIteration === true) {
384+
void manager.executeScheduledIterationAsync();
392385
}
393-
this._setStatus('Build pass queued');
386+
this._setStatus('Build iteration queued');
394387
} else {
395388
this._setStatus('No work to queue');
396389
}

libraries/rush-lib/src/logic/operations/BuildPlanPlugin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { ITerminal } from '@rushstack/terminal';
66
import type {
77
IOperationExecutionManager,
88
IOperationExecutionManagerContext,
9-
IOperationExecutionPassOptions,
9+
IOperationExecutionIterationOptions,
1010
IPhasedCommandPlugin,
1111
PhasedCommandHooks
1212
} from '../../pluginFramework/PhasedCommandHooks';
@@ -47,18 +47,18 @@ export class BuildPlanPlugin implements IPhasedCommandPlugin {
4747
hooks.executionManagerAsync.tap(
4848
PLUGIN_NAME,
4949
(manager: IOperationExecutionManager, context: IOperationExecutionManagerContext) => {
50-
manager.hooks.configureRun.tap(PLUGIN_NAME, (currentStates, lastStates, passOptions) => {
51-
createBuildPlan(currentStates, passOptions, context);
50+
manager.hooks.configureIteration.tap(PLUGIN_NAME, (currentStates, lastStates, iterationOptions) => {
51+
createBuildPlan(currentStates, iterationOptions, context);
5252
});
5353
}
5454
);
5555

5656
function createBuildPlan(
5757
recordByOperation: ReadonlyMap<Operation, IConfigurableOperation>,
58-
passOptions: IOperationExecutionPassOptions,
58+
iterationOptions: IOperationExecutionIterationOptions,
5959
context: IOperationExecutionManagerContext
6060
): void {
61-
const { inputsSnapshot } = passOptions;
61+
const { inputsSnapshot } = iterationOptions;
6262
const { projectConfigurations } = context;
6363
const disjointSet: DisjointSet<Operation> = new DisjointSet<Operation>();
6464
const operations: Operation[] = [...recordByOperation.keys()];

0 commit comments

Comments
 (0)