@rushstack/rush-sdk 5.103.0 → 5.104.1

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 (36) hide show
  1. package/dist/rush-lib.d.ts +419 -10
  2. package/lib/api/CobuildConfiguration.d.ts +71 -0
  3. package/lib/api/CobuildConfiguration.js +1 -0
  4. package/lib/api/EnvironmentConfiguration.d.ts +45 -0
  5. package/lib/api/RushProjectConfiguration.d.ts +19 -5
  6. package/lib/index.d.ts +5 -2
  7. package/lib/logic/RushConstants.d.ts +4 -0
  8. package/lib/logic/buildCache/ProjectBuildCache.d.ts +6 -7
  9. package/lib/logic/cobuild/CobuildLock.d.ts +43 -0
  10. package/lib/logic/cobuild/CobuildLock.js +1 -0
  11. package/lib/logic/cobuild/DisjointSet.d.ts +28 -0
  12. package/lib/logic/cobuild/DisjointSet.js +1 -0
  13. package/lib/logic/cobuild/ICobuildLockProvider.d.ts +99 -0
  14. package/lib/logic/cobuild/ICobuildLockProvider.js +1 -0
  15. package/lib/logic/operations/AsyncOperationQueue.d.ts +23 -4
  16. package/lib/logic/operations/CacheableOperationPlugin.d.ts +51 -0
  17. package/lib/logic/operations/CacheableOperationPlugin.js +1 -0
  18. package/lib/logic/operations/IOperationExecutionResult.d.ts +9 -1
  19. package/lib/logic/operations/IOperationRunner.d.ts +25 -6
  20. package/lib/logic/operations/LegacySkipPlugin.d.ts +22 -0
  21. package/lib/logic/operations/LegacySkipPlugin.js +1 -0
  22. package/lib/logic/operations/NullOperationRunner.d.ts +2 -2
  23. package/lib/logic/operations/OperationExecutionManager.d.ts +6 -0
  24. package/lib/logic/operations/OperationExecutionRecord.d.ts +19 -1
  25. package/lib/logic/operations/OperationMetadataManager.d.ts +3 -1
  26. package/lib/logic/operations/OperationStateFile.d.ts +2 -0
  27. package/lib/logic/operations/OperationStatus.d.ts +8 -0
  28. package/lib/logic/operations/PeriodicCallback.d.ts +20 -0
  29. package/lib/logic/operations/PeriodicCallback.js +1 -0
  30. package/lib/logic/operations/ProjectLogWritable.d.ts +11 -0
  31. package/lib/logic/operations/ShellOperationRunner.d.ts +4 -26
  32. package/lib/pluginFramework/PhasedCommandHooks.d.ts +31 -4
  33. package/lib/pluginFramework/RushSession.d.ts +11 -2
  34. package/lib/utilities/NullTerminalProvider.d.ts +10 -0
  35. package/lib/utilities/NullTerminalProvider.js +1 -0
  36. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  import { TerminalWritable } from '@rushstack/terminal';
2
2
  import { Operation } from './Operation';
3
+ import { OperationStatus } from './OperationStatus';
3
4
  import { OperationExecutionRecord } from './OperationExecutionRecord';
4
5
  import { IExecutionResult } from './IOperationExecutionResult';
5
6
  export interface IOperationExecutionManagerOptions {
@@ -8,6 +9,8 @@ export interface IOperationExecutionManagerOptions {
8
9
  parallelism: number;
9
10
  changedProjectsOnly: boolean;
10
11
  destination?: TerminalWritable;
12
+ beforeExecuteOperation?: (operation: OperationExecutionRecord) => Promise<OperationStatus | undefined>;
13
+ afterExecuteOperation?: (operation: OperationExecutionRecord) => Promise<void>;
11
14
  onOperationStatusChanged?: (record: OperationExecutionRecord) => void;
12
15
  beforeExecuteOperations?: (records: Map<Operation, OperationExecutionRecord>) => Promise<void>;
13
16
  }
@@ -27,11 +30,14 @@ export declare class OperationExecutionManager {
27
30
  private readonly _colorsNewlinesTransform;
28
31
  private readonly _streamCollator;
29
32
  private readonly _terminal;
33
+ private readonly _beforeExecuteOperation?;
34
+ private readonly _afterExecuteOperation?;
30
35
  private readonly _onOperationStatusChanged?;
31
36
  private readonly _beforeExecuteOperations?;
32
37
  private _hasAnyFailures;
33
38
  private _hasAnyNonAllowedWarnings;
34
39
  private _completedOperations;
40
+ private _executionQueue;
35
41
  constructor(operations: Set<Operation>, options: IOperationExecutionManagerOptions);
36
42
  private _streamCollator_onWriterActive;
37
43
  /**
@@ -5,16 +5,25 @@ import { IOperationRunner, IOperationRunnerContext } from './IOperationRunner';
5
5
  import { Operation } from './Operation';
6
6
  import { Stopwatch } from '../../utilities/Stopwatch';
7
7
  import { OperationMetadataManager } from './OperationMetadataManager';
8
+ import type { IPhase } from '../../api/CommandLineConfiguration';
9
+ import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
8
10
  export interface IOperationExecutionRecordContext {
9
11
  streamCollator: StreamCollator;
10
12
  onOperationStatusChanged?: (record: OperationExecutionRecord) => void;
11
13
  debugMode: boolean;
12
14
  quietMode: boolean;
15
+ changedProjectsOnly: boolean;
13
16
  }
14
17
  /**
15
18
  * Internal class representing everything about executing an operation
19
+ *
20
+ * @internal
16
21
  */
17
22
  export declare class OperationExecutionRecord implements IOperationRunnerContext {
23
+ /**
24
+ * The associated operation.
25
+ */
26
+ readonly operation: Operation;
18
27
  /**
19
28
  * The current execution status of an operation. Operations start in the 'ready' state,
20
29
  * but can be 'blocked' if an upstream operation failed. It is 'executing' when
@@ -37,6 +46,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
37
46
  * operation to execute, the operation with the highest criticalPathLength is chosen.
38
47
  *
39
48
  * Example:
49
+ * ```
40
50
  * (0) A
41
51
  * \
42
52
  * (1) B C (0) (applications)
@@ -53,6 +63,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
53
63
  * X has a score of 1, since the only package which depends on it is A
54
64
  * Z has a score of 2, since only X depends on it, and X has a score of 1
55
65
  * Y has a score of 2, since the chain Y->X->C is longer than Y->C
66
+ * ```
56
67
  *
57
68
  * The algorithm is implemented in AsyncOperationQueue.ts as calculateCriticalPathLength()
58
69
  */
@@ -69,6 +80,8 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
69
80
  readonly stdioSummarizer: StdioSummarizer;
70
81
  readonly runner: IOperationRunner;
71
82
  readonly weight: number;
83
+ readonly associatedPhase: IPhase | undefined;
84
+ readonly associatedProject: RushConfigurationProject | undefined;
72
85
  readonly _operationMetadataManager: OperationMetadataManager | undefined;
73
86
  private readonly _context;
74
87
  private _collatedWriter;
@@ -76,8 +89,13 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
76
89
  get name(): string;
77
90
  get debugMode(): boolean;
78
91
  get quietMode(): boolean;
92
+ get changedProjectsOnly(): boolean;
79
93
  get collatedWriter(): CollatedWriter;
80
94
  get nonCachedDurationMs(): number | undefined;
81
- executeAsync(onResult: (record: OperationExecutionRecord) => void): Promise<void>;
95
+ get cobuildRunnerId(): string | undefined;
96
+ executeAsync({ onStart, onResult }: {
97
+ onStart: (record: OperationExecutionRecord) => Promise<OperationStatus | undefined>;
98
+ onResult: (record: OperationExecutionRecord) => Promise<void>;
99
+ }): Promise<void>;
82
100
  }
83
101
  //# sourceMappingURL=OperationExecutionRecord.d.ts.map
@@ -16,6 +16,8 @@ export interface IOperationMetaData {
16
16
  durationInSeconds: number;
17
17
  logPath: string;
18
18
  errorLogPath: string;
19
+ cobuildContextId: string | undefined;
20
+ cobuildRunnerId: string | undefined;
19
21
  }
20
22
  /**
21
23
  * A helper class for managing the meta files of a operation.
@@ -38,7 +40,7 @@ export declare class OperationMetadataManager {
38
40
  * Example: `.rush/temp/operation/_phase_build/error.log`
39
41
  */
40
42
  get relativeFilepaths(): string[];
41
- saveAsync({ durationInSeconds, logPath, errorLogPath }: IOperationMetaData): Promise<void>;
43
+ saveAsync({ durationInSeconds, cobuildContextId, cobuildRunnerId, logPath, errorLogPath }: IOperationMetaData): Promise<void>;
42
44
  tryRestoreAsync({ terminal, logPath, errorLogPath }: {
43
45
  terminal: ITerminal;
44
46
  logPath: string;
@@ -10,6 +10,8 @@ export interface IOperationStateFileOptions {
10
10
  */
11
11
  export interface IOperationStateJson {
12
12
  nonCachedDurationMs: number;
13
+ cobuildContextId: string | undefined;
14
+ cobuildRunnerId: string | undefined;
13
15
  }
14
16
  /**
15
17
  * A helper class for managing the state file of a operation.
@@ -7,10 +7,18 @@ export declare enum OperationStatus {
7
7
  * The Operation is on the queue, ready to execute (but may be waiting for dependencies)
8
8
  */
9
9
  Ready = "READY",
10
+ /**
11
+ * The Operation is Queued
12
+ */
13
+ Queued = "QUEUED",
10
14
  /**
11
15
  * The Operation is currently executing
12
16
  */
13
17
  Executing = "EXECUTING",
18
+ /**
19
+ * The Operation is currently executing by a remote process
20
+ */
21
+ RemoteExecuting = "REMOTE EXECUTING",
14
22
  /**
15
23
  * The Operation completed successfully and did not write to standard output
16
24
  */
@@ -0,0 +1,20 @@
1
+ export type ICallbackFn = () => Promise<void> | void;
2
+ export interface IPeriodicCallbackOptions {
3
+ interval: number;
4
+ }
5
+ /**
6
+ * A help class to run callbacks in a loop with a specified interval.
7
+ *
8
+ * @beta
9
+ */
10
+ export declare class PeriodicCallback {
11
+ private _callbacks;
12
+ private _interval;
13
+ private _intervalId;
14
+ private _isRunning;
15
+ constructor(options: IPeriodicCallbackOptions);
16
+ addCallback(callback: ICallbackFn): void;
17
+ start(): void;
18
+ stop(): void;
19
+ }
20
+ //# sourceMappingURL=PeriodicCallback.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/operations/PeriodicCallback");
@@ -11,6 +11,17 @@ export declare class ProjectLogWritable extends TerminalWritable {
11
11
  private _logWriter;
12
12
  private _errorLogWriter;
13
13
  constructor(project: RushConfigurationProject, terminal: CollatedTerminal, logFilenameIdentifier: string);
14
+ static getLogFilePaths({ project, logFilenameIdentifier, isLegacyLog }: {
15
+ project: RushConfigurationProject;
16
+ logFilenameIdentifier: string;
17
+ isLegacyLog?: boolean;
18
+ }): {
19
+ logPath: string;
20
+ errorLogPath: string;
21
+ relativeLogPath: string;
22
+ relativeErrorLogPath: string;
23
+ };
24
+ writeChunk(chunk: ITerminalChunk): void;
14
25
  protected onWriteChunk(chunk: ITerminalChunk): void;
15
26
  protected onClose(): void;
16
27
  }
@@ -3,20 +3,11 @@ import { IOperationRunner, IOperationRunnerContext } from './IOperationRunner';
3
3
  import type { RushConfiguration } from '../../api/RushConfiguration';
4
4
  import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
5
5
  import type { ProjectChangeAnalyzer } from '../ProjectChangeAnalyzer';
6
- import type { BuildCacheConfiguration } from '../../api/BuildCacheConfiguration';
7
6
  import type { IPhase } from '../../api/CommandLineConfiguration';
8
- export interface IProjectDeps {
9
- files: {
10
- [filePath: string]: string;
11
- };
12
- arguments: string;
13
- }
14
7
  export interface IOperationRunnerOptions {
15
8
  rushProject: RushConfigurationProject;
16
9
  rushConfiguration: RushConfiguration;
17
- buildCacheConfiguration: BuildCacheConfiguration | undefined;
18
10
  commandToRun: string;
19
- isIncrementalBuildAllowed: boolean;
20
11
  projectChangeAnalyzer: ProjectChangeAnalyzer;
21
12
  displayName: string;
22
13
  phase: IPhase;
@@ -32,31 +23,18 @@ export interface IOperationRunnerOptions {
32
23
  */
33
24
  export declare class ShellOperationRunner implements IOperationRunner {
34
25
  readonly name: string;
35
- isCacheWriteAllowed: boolean;
36
- isSkipAllowed: boolean;
37
26
  readonly reportTiming: boolean;
38
27
  readonly silent: boolean;
28
+ readonly cacheable: boolean;
39
29
  readonly warningsAreAllowed: boolean;
40
- private readonly _rushProject;
41
- private readonly _phase;
42
- private readonly _rushConfiguration;
43
- private readonly _buildCacheConfiguration;
44
- private readonly _commandName;
45
30
  private readonly _commandToRun;
46
- private readonly _isCacheReadAllowed;
47
- private readonly _projectChangeAnalyzer;
48
- private readonly _packageDepsFilename;
49
31
  private readonly _logFilenameIdentifier;
50
- private readonly _selectedPhases;
51
- /**
52
- * UNINITIALIZED === we haven't tried to initialize yet
53
- * undefined === we didn't create one because the feature is not enabled
54
- */
55
- private _projectBuildCache;
32
+ private readonly _rushProject;
33
+ private readonly _rushConfiguration;
56
34
  constructor(options: IOperationRunnerOptions);
57
35
  executeAsync(context: IOperationRunnerContext): Promise<OperationStatus>;
36
+ getConfigHash(): string;
58
37
  private _executeAsync;
59
- private _tryGetProjectBuildCacheAsync;
60
38
  }
61
39
  /**
62
40
  * When running a command from the "scripts" block in package.json, if the command
@@ -1,4 +1,4 @@
1
- import { AsyncSeriesHook, AsyncSeriesWaterfallHook, SyncHook } from 'tapable';
1
+ import { AsyncSeriesBailHook, AsyncSeriesHook, AsyncSeriesWaterfallHook, SyncHook } from 'tapable';
2
2
  import type { CommandLineParameter } from '@rushstack/ts-command-line';
3
3
  import type { BuildCacheConfiguration } from '../api/BuildCacheConfiguration';
4
4
  import type { IPhase } from '../api/CommandLineConfiguration';
@@ -6,8 +6,12 @@ import type { RushConfiguration } from '../api/RushConfiguration';
6
6
  import type { RushConfigurationProject } from '../api/RushConfigurationProject';
7
7
  import type { Operation } from '../logic/operations/Operation';
8
8
  import type { ProjectChangeAnalyzer } from '../logic/ProjectChangeAnalyzer';
9
- import { ITelemetryData } from '../logic/Telemetry';
10
- import { IExecutionResult, IOperationExecutionResult } from '../logic/operations/IOperationExecutionResult';
9
+ import type { IExecutionResult, IOperationExecutionResult } from '../logic/operations/IOperationExecutionResult';
10
+ import type { CobuildConfiguration } from '../api/CobuildConfiguration';
11
+ import { RushProjectConfiguration } from '../api/RushProjectConfiguration';
12
+ import type { IOperationRunnerContext } from '../logic/operations/IOperationRunner';
13
+ import type { ITelemetryData } from '../logic/Telemetry';
14
+ import type { OperationStatus } from '../logic/operations/OperationStatus';
11
15
  /**
12
16
  * A plugin that interacts with a phased commands.
13
17
  * @alpha
@@ -27,6 +31,10 @@ export interface ICreateOperationsContext {
27
31
  * The configuration for the build cache, if the feature is enabled.
28
32
  */
29
33
  readonly buildCacheConfiguration: BuildCacheConfiguration | undefined;
34
+ /**
35
+ * The configuration for the cobuild, if cobuild feature and build cache feature are both enabled.
36
+ */
37
+ readonly cobuildConfiguration: CobuildConfiguration | undefined;
30
38
  /**
31
39
  * The set of custom parameters for the executing command.
32
40
  * Maps from the `longName` field in command-line.json to the parser configuration in ts-command-line.
@@ -62,6 +70,10 @@ export interface ICreateOperationsContext {
62
70
  * The set of Rush projects selected for the current command execution.
63
71
  */
64
72
  readonly projectSelection: ReadonlySet<RushConfigurationProject>;
73
+ /**
74
+ * All successfully loaded rush-project.json data for selected projects.
75
+ */
76
+ readonly projectConfigurations: ReadonlyMap<RushConfigurationProject, RushProjectConfiguration>;
65
77
  /**
66
78
  * The set of Rush projects that have not been built in the current process since they were last modified.
67
79
  * When `isInitial` is true, this will be an exact match of `projectSelection`.
@@ -86,7 +98,10 @@ export declare class PhasedCommandHooks {
86
98
  * Hook invoked before operation start
87
99
  * Hook is series for stable output.
88
100
  */
89
- readonly beforeExecuteOperations: AsyncSeriesHook<[Map<Operation, IOperationExecutionResult>]>;
101
+ readonly beforeExecuteOperations: AsyncSeriesHook<[
102
+ Map<Operation, IOperationExecutionResult>,
103
+ ICreateOperationsContext
104
+ ]>;
90
105
  /**
91
106
  * Hook invoked when operation status changed
92
107
  * Hook is series for stable output.
@@ -98,6 +113,18 @@ export declare class PhasedCommandHooks {
98
113
  * Hook is series for stable output.
99
114
  */
100
115
  readonly afterExecuteOperations: AsyncSeriesHook<[IExecutionResult, ICreateOperationsContext]>;
116
+ /**
117
+ * Hook invoked before executing a operation.
118
+ */
119
+ readonly beforeExecuteOperation: AsyncSeriesBailHook<[
120
+ IOperationRunnerContext & IOperationExecutionResult
121
+ ], OperationStatus | undefined>;
122
+ /**
123
+ * Hook invoked after executing a operation.
124
+ */
125
+ readonly afterExecuteOperation: AsyncSeriesHook<[
126
+ IOperationRunnerContext & IOperationExecutionResult
127
+ ]>;
101
128
  /**
102
129
  * Hook invoked after a run has finished and the command is watching for changes.
103
130
  * May be used to display additional relevant data to the user.
@@ -1,8 +1,10 @@
1
1
  import { ITerminalProvider } from '@rushstack/node-core-library';
2
- import { IBuildCacheJson } from '../api/BuildCacheConfiguration';
3
- import { ICloudBuildCacheProvider } from '../logic/buildCache/ICloudBuildCacheProvider';
4
2
  import { ILogger } from './logging/Logger';
5
3
  import { RushLifecycleHooks } from './RushLifeCycle';
4
+ import type { IBuildCacheJson } from '../api/BuildCacheConfiguration';
5
+ import type { ICloudBuildCacheProvider } from '../logic/buildCache/ICloudBuildCacheProvider';
6
+ import type { ICobuildJson } from '../api/CobuildConfiguration';
7
+ import type { ICobuildLockProvider } from '../logic/cobuild/ICobuildLockProvider';
6
8
  /**
7
9
  * @beta
8
10
  */
@@ -14,17 +16,24 @@ export interface IRushSessionOptions {
14
16
  * @beta
15
17
  */
16
18
  export type CloudBuildCacheProviderFactory = (buildCacheJson: IBuildCacheJson) => ICloudBuildCacheProvider | Promise<ICloudBuildCacheProvider>;
19
+ /**
20
+ * @beta
21
+ */
22
+ export type CobuildLockProviderFactory = (cobuildJson: ICobuildJson) => ICobuildLockProvider | Promise<ICobuildLockProvider>;
17
23
  /**
18
24
  * @beta
19
25
  */
20
26
  export declare class RushSession {
21
27
  private readonly _options;
22
28
  private readonly _cloudBuildCacheProviderFactories;
29
+ private readonly _cobuildLockProviderFactories;
23
30
  readonly hooks: RushLifecycleHooks;
24
31
  constructor(options: IRushSessionOptions);
25
32
  getLogger(name: string): ILogger;
26
33
  get terminalProvider(): ITerminalProvider;
27
34
  registerCloudBuildCacheProviderFactory(cacheProviderName: string, factory: CloudBuildCacheProviderFactory): void;
28
35
  getCloudBuildCacheProviderFactory(cacheProviderName: string): CloudBuildCacheProviderFactory | undefined;
36
+ registerCobuildLockProviderFactory(cobuildLockProviderName: string, factory: CobuildLockProviderFactory): void;
37
+ getCobuildLockProviderFactory(cobuildLockProviderName: string): CobuildLockProviderFactory | undefined;
29
38
  }
30
39
  //# sourceMappingURL=RushSession.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { ITerminalProvider } from '@rushstack/node-core-library';
2
+ /**
3
+ * A terminal provider like /dev/null
4
+ */
5
+ export declare class NullTerminalProvider implements ITerminalProvider {
6
+ supportsColor: boolean;
7
+ eolCharacter: string;
8
+ write(): void;
9
+ }
10
+ //# sourceMappingURL=NullTerminalProvider.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../lib-shim/index")._rushSdk_loadInternalModule("utilities/NullTerminalProvider");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/rush-sdk",
3
- "version": "5.103.0",
3
+ "version": "5.104.1",
4
4
  "description": "An API for interacting with the Rush engine",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  "@types/node": "14.18.36",
32
32
  "@types/semver": "7.5.0",
33
33
  "@types/webpack-env": "1.18.0",
34
- "@microsoft/rush-lib": "5.103.0",
34
+ "@microsoft/rush-lib": "5.104.1",
35
35
  "@rushstack/eslint-config": "3.3.3",
36
36
  "@rushstack/heft": "0.58.2",
37
37
  "@rushstack/heft-node-rig": "2.2.22",