@rushstack/rush-sdk 5.96.0 → 5.97.1-pr3949

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 (29) hide show
  1. package/dist/rush-lib.d.ts +279 -29
  2. package/lib/api/CobuildConfiguration.d.ts +63 -0
  3. package/lib/api/CobuildConfiguration.js +1 -0
  4. package/lib/api/EnvironmentConfiguration.d.ts +61 -20
  5. package/lib/index.d.ts +3 -1
  6. package/lib/logic/RushConstants.d.ts +9 -0
  7. package/lib/logic/buildCache/ProjectBuildCache.d.ts +5 -4
  8. package/lib/logic/cobuild/CobuildLock.d.ts +24 -0
  9. package/lib/logic/cobuild/CobuildLock.js +1 -0
  10. package/lib/logic/cobuild/ICobuildLockProvider.d.ts +46 -0
  11. package/lib/logic/cobuild/ICobuildLockProvider.js +1 -0
  12. package/lib/logic/operations/AsyncOperationQueue.d.ts +23 -4
  13. package/lib/logic/operations/CacheableOperationPlugin.d.ts +21 -0
  14. package/lib/logic/operations/CacheableOperationPlugin.js +1 -0
  15. package/lib/logic/operations/IOperationRunner.d.ts +29 -10
  16. package/lib/logic/operations/OperationExecutionManager.d.ts +5 -0
  17. package/lib/logic/operations/OperationExecutionRecord.d.ts +7 -1
  18. package/lib/logic/operations/OperationRunnerHooks.d.ts +50 -0
  19. package/lib/logic/operations/OperationRunnerHooks.js +1 -0
  20. package/lib/logic/operations/OperationStatus.d.ts +8 -0
  21. package/lib/logic/operations/PeriodicCallback.d.ts +20 -0
  22. package/lib/logic/operations/PeriodicCallback.js +1 -0
  23. package/lib/logic/operations/ShellOperationRunner.d.ts +4 -13
  24. package/lib/pluginFramework/PhasedCommandHooks.d.ts +15 -1
  25. package/lib/pluginFramework/RushSession.d.ts +11 -2
  26. package/lib-shim/index.d.ts.map +1 -1
  27. package/lib-shim/index.js +5 -5
  28. package/lib-shim/index.js.map +1 -1
  29. package/package.json +5 -5
@@ -9,7 +9,7 @@ export interface IEnvironmentConfigurationInitializeOptions {
9
9
  * Names of environment variables used by Rush.
10
10
  * @beta
11
11
  */
12
- export declare enum EnvironmentVariableNames {
12
+ export declare const EnvironmentVariableNames: {
13
13
  /**
14
14
  * This variable overrides the temporary folder used by Rush.
15
15
  * The default value is "common/temp" under the repository root.
@@ -17,43 +17,43 @@ export declare enum EnvironmentVariableNames {
17
17
  * @remarks This environment variable is not compatible with workspace installs. If attempting
18
18
  * to move the PNPM store path, see the `RUSH_PNPM_STORE_PATH` environment variable.
19
19
  */
20
- RUSH_TEMP_FOLDER = "RUSH_TEMP_FOLDER",
20
+ readonly RUSH_TEMP_FOLDER: "RUSH_TEMP_FOLDER";
21
21
  /**
22
22
  * This variable overrides the version of Rush that will be installed by
23
23
  * the version selector. The default value is determined by the "rushVersion"
24
24
  * field from rush.json.
25
25
  */
26
- RUSH_PREVIEW_VERSION = "RUSH_PREVIEW_VERSION",
26
+ readonly RUSH_PREVIEW_VERSION: "RUSH_PREVIEW_VERSION";
27
27
  /**
28
28
  * If this variable is set to "1", Rush will not fail the build when running a version
29
29
  * of Node that does not match the criteria specified in the "nodeSupportedVersionRange"
30
30
  * field from rush.json.
31
31
  */
32
- RUSH_ALLOW_UNSUPPORTED_NODEJS = "RUSH_ALLOW_UNSUPPORTED_NODEJS",
32
+ readonly RUSH_ALLOW_UNSUPPORTED_NODEJS: "RUSH_ALLOW_UNSUPPORTED_NODEJS";
33
33
  /**
34
34
  * Setting this environment variable overrides the value of `allowWarningsInSuccessfulBuild`
35
35
  * in the `command-line.json` configuration file. Specify `1` to allow warnings in a successful build,
36
36
  * or `0` to disallow them. (See the comments in the command-line.json file for more information).
37
37
  */
38
- RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD = "RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD",
38
+ readonly RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD: "RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD";
39
39
  /**
40
40
  * This variable selects a specific installation variant for Rush to use when installing
41
41
  * and linking package dependencies.
42
42
  * For more information, see the command-line help for the `--variant` parameter
43
43
  * and this article: https://rushjs.io/pages/advanced/installation_variants/
44
44
  */
45
- RUSH_VARIANT = "RUSH_VARIANT",
45
+ readonly RUSH_VARIANT: "RUSH_VARIANT";
46
46
  /**
47
47
  * Specifies the maximum number of concurrent processes to launch during a build.
48
48
  * For more information, see the command-line help for the `--parallelism` parameter for "rush build".
49
49
  */
50
- RUSH_PARALLELISM = "RUSH_PARALLELISM",
50
+ readonly RUSH_PARALLELISM: "RUSH_PARALLELISM";
51
51
  /**
52
52
  * If this variable is set to "1", Rush will create symlinks with absolute paths instead
53
53
  * of relative paths. This can be necessary when a repository is moved during a build or
54
54
  * if parts of a repository are moved into a sandbox.
55
55
  */
56
- RUSH_ABSOLUTE_SYMLINKS = "RUSH_ABSOLUTE_SYMLINKS",
56
+ readonly RUSH_ABSOLUTE_SYMLINKS: "RUSH_ABSOLUTE_SYMLINKS";
57
57
  /**
58
58
  * When using PNPM as the package manager, this variable can be used to configure the path that
59
59
  * PNPM will use as the store directory.
@@ -61,18 +61,18 @@ export declare enum EnvironmentVariableNames {
61
61
  * If a relative path is used, then the store path will be resolved relative to the process's
62
62
  * current working directory. An absolute path is recommended.
63
63
  */
64
- RUSH_PNPM_STORE_PATH = "RUSH_PNPM_STORE_PATH",
64
+ readonly RUSH_PNPM_STORE_PATH: "RUSH_PNPM_STORE_PATH";
65
65
  /**
66
66
  * When using PNPM as the package manager, this variable can be used to control whether or not PNPM
67
67
  * validates the integrity of the PNPM store during installation. The value of this environment variable must be
68
68
  * `1` (for true) or `0` (for false). If not specified, defaults to the value in .npmrc.
69
69
  */
70
- RUSH_PNPM_VERIFY_STORE_INTEGRITY = "RUSH_PNPM_VERIFY_STORE_INTEGRITY",
70
+ readonly RUSH_PNPM_VERIFY_STORE_INTEGRITY: "RUSH_PNPM_VERIFY_STORE_INTEGRITY";
71
71
  /**
72
72
  * This environment variable can be used to specify the `--target-folder` parameter
73
73
  * for the "rush deploy" command.
74
74
  */
75
- RUSH_DEPLOY_TARGET_FOLDER = "RUSH_DEPLOY_TARGET_FOLDER",
75
+ readonly RUSH_DEPLOY_TARGET_FOLDER: "RUSH_DEPLOY_TARGET_FOLDER";
76
76
  /**
77
77
  * Overrides the location of the `~/.rush` global folder where Rush stores temporary files.
78
78
  *
@@ -89,7 +89,7 @@ export declare enum EnvironmentVariableNames {
89
89
  *
90
90
  * POSIX is a registered trademark of the Institute of Electrical and Electronic Engineers, Inc.
91
91
  */
92
- RUSH_GLOBAL_FOLDER = "RUSH_GLOBAL_FOLDER",
92
+ readonly RUSH_GLOBAL_FOLDER: "RUSH_GLOBAL_FOLDER";
93
93
  /**
94
94
  * Provides a credential for a remote build cache, if configured. This credential overrides any cached credentials.
95
95
  *
@@ -103,7 +103,7 @@ export declare enum EnvironmentVariableNames {
103
103
  *
104
104
  * For information on SAS tokens, see here: https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview
105
105
  */
106
- RUSH_BUILD_CACHE_CREDENTIAL = "RUSH_BUILD_CACHE_CREDENTIAL",
106
+ readonly RUSH_BUILD_CACHE_CREDENTIAL: "RUSH_BUILD_CACHE_CREDENTIAL";
107
107
  /**
108
108
  * Setting this environment variable overrides the value of `buildCacheEnabled` in the `build-cache.json`
109
109
  * configuration file.
@@ -113,26 +113,49 @@ export declare enum EnvironmentVariableNames {
113
113
  *
114
114
  * If there is no build cache configured, then this environment variable is ignored.
115
115
  */
116
- RUSH_BUILD_CACHE_ENABLED = "RUSH_BUILD_CACHE_ENABLED",
116
+ readonly RUSH_BUILD_CACHE_ENABLED: "RUSH_BUILD_CACHE_ENABLED";
117
117
  /**
118
118
  * Overrides the value of `isCacheWriteAllowed` in the `build-cache.json` configuration file. The value of this
119
119
  * environment variable must be `1` (for true) or `0` (for false). If there is no build cache configured, then
120
120
  * this environment variable is ignored.
121
121
  */
122
- RUSH_BUILD_CACHE_WRITE_ALLOWED = "RUSH_BUILD_CACHE_WRITE_ALLOWED",
122
+ readonly RUSH_BUILD_CACHE_WRITE_ALLOWED: "RUSH_BUILD_CACHE_WRITE_ALLOWED";
123
+ /**
124
+ * Setting this environment variable overrides the value of `cobuildEnabled` in the `cobuild.json`
125
+ * configuration file.
126
+ *
127
+ * @remarks
128
+ * Specify `1` to enable the cobuild or `0` to disable it.
129
+ *
130
+ * If there is no cobuild configured, then this environment variable is ignored.
131
+ */
132
+ readonly RUSH_COBUILD_ENABLED: "RUSH_COBUILD_ENABLED";
133
+ /**
134
+ * Setting this environment variable opt into running with cobuilds.
135
+ *
136
+ * @remarks
137
+ * If there is no cobuild configured, then this environment variable is ignored.
138
+ */
139
+ readonly RUSH_COBUILD_CONTEXT_ID: "RUSH_COBUILD_CONTEXT_ID";
140
+ /**
141
+ * If this variable is set to "1", When getting distributed builds, Rush will automatically handle the leaf project
142
+ * with build cache "disabled" by writing to the cache in a special "log files only mode". This is useful when you
143
+ * want to use Cobuilds to improve the performance in CI validations and the leaf projects have not enabled cache.
144
+ */
145
+ readonly RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED: "RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED";
123
146
  /**
124
147
  * Explicitly specifies the path for the Git binary that is invoked by certain Rush operations.
125
148
  */
126
- RUSH_GIT_BINARY_PATH = "RUSH_GIT_BINARY_PATH",
149
+ readonly RUSH_GIT_BINARY_PATH: "RUSH_GIT_BINARY_PATH";
127
150
  /**
128
151
  * Explicitly specifies the path for the `tar` binary that is invoked by certain Rush operations.
129
152
  */
130
- RUSH_TAR_BINARY_PATH = "RUSH_TAR_BINARY_PATH",
153
+ readonly RUSH_TAR_BINARY_PATH: "RUSH_TAR_BINARY_PATH";
131
154
  /**
132
155
  * Internal variable that explicitly specifies the path for the version of `@microsoft/rush-lib` being executed.
133
156
  * Will be set upon loading Rush.
134
157
  */
135
- RUSH_LIB_PATH = "_RUSH_LIB_PATH",
158
+ readonly RUSH_LIB_PATH: "_RUSH_LIB_PATH";
136
159
  /**
137
160
  * When Rush executes shell scripts, it sometimes changes the working directory to be a project folder or
138
161
  * the repository root folder. The original working directory (where the Rush command was invoked) is assigned
@@ -142,8 +165,8 @@ export declare enum EnvironmentVariableNames {
142
165
  * The `RUSH_INVOKED_FOLDER` variable is the same idea as the `INIT_CWD` variable that package managers
143
166
  * assign when they execute lifecycle scripts.
144
167
  */
145
- RUSH_INVOKED_FOLDER = "RUSH_INVOKED_FOLDER"
146
- }
168
+ readonly RUSH_INVOKED_FOLDER: "RUSH_INVOKED_FOLDER";
169
+ };
147
170
  /**
148
171
  * Provides Rush-specific environment variable data. All Rush environment variables must start with "RUSH_". This class
149
172
  * is designed to be used by RushConfiguration.
@@ -164,6 +187,9 @@ export declare class EnvironmentConfiguration {
164
187
  private static _buildCacheCredential;
165
188
  private static _buildCacheEnabled;
166
189
  private static _buildCacheWriteAllowed;
190
+ private static _cobuildEnabled;
191
+ private static _cobuildContextId;
192
+ private static _cobuildLeafProjectLogOnlyAllowed;
167
193
  private static _gitBinaryPath;
168
194
  private static _tarBinaryPath;
169
195
  /**
@@ -219,6 +245,21 @@ export declare class EnvironmentConfiguration {
219
245
  * See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_WRITE_ALLOWED}
220
246
  */
221
247
  static get buildCacheWriteAllowed(): boolean | undefined;
248
+ /**
249
+ * If set, enables or disables the cobuild feature.
250
+ * See {@link EnvironmentVariableNames.RUSH_COBUILD_ENABLED}
251
+ */
252
+ static get cobuildEnabled(): boolean | undefined;
253
+ /**
254
+ * Provides a determined cobuild context id if configured
255
+ * See {@link EnvironmentVariableNames.RUSH_COBUILD_CONTEXT_ID}
256
+ */
257
+ static get cobuildContextId(): string | undefined;
258
+ /**
259
+ * If set, enables or disables the cobuild leaf project log only feature.
260
+ * See {@link EnvironmentVariableNames.RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED}
261
+ */
262
+ static get cobuildLeafProjectLogOnlyAllowed(): boolean | undefined;
222
263
  /**
223
264
  * Allows the git binary path to be explicitly provided.
224
265
  * See {@link EnvironmentVariableNames.RUSH_GIT_BINARY_PATH}
package/lib/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { INpmOptionsJson as _INpmOptionsJson, NpmOptionsConfiguration } from './
9
9
  export { IYarnOptionsJson as _IYarnOptionsJson, YarnOptionsConfiguration } from './logic/yarn/YarnOptionsConfiguration';
10
10
  export { IPnpmOptionsJson as _IPnpmOptionsJson, PnpmStoreOptions, PnpmOptionsConfiguration } from './logic/pnpm/PnpmOptionsConfiguration';
11
11
  export { BuildCacheConfiguration } from './api/BuildCacheConfiguration';
12
+ export { CobuildConfiguration, ICobuildJson } from './api/CobuildConfiguration';
12
13
  export { GetCacheEntryIdFunction, IGenerateCacheEntryIdOptions } from './logic/buildCache/CacheEntryId';
13
14
  export { FileSystemBuildCacheProvider, IFileSystemBuildCacheProviderOptions } from './logic/buildCache/FileSystemBuildCacheProvider';
14
15
  export { IPhase } from './api/CommandLineConfiguration';
@@ -36,7 +37,7 @@ export { IOperationRunner, IOperationRunnerContext } from './logic/operations/IO
36
37
  export { IExecutionResult, IOperationExecutionResult } from './logic/operations/IOperationExecutionResult';
37
38
  export { IOperationOptions, Operation } from './logic/operations/Operation';
38
39
  export { OperationStatus } from './logic/operations/OperationStatus';
39
- export { RushSession, IRushSessionOptions, CloudBuildCacheProviderFactory } from './pluginFramework/RushSession';
40
+ export { RushSession, IRushSessionOptions, CloudBuildCacheProviderFactory, CobuildLockProviderFactory } from './pluginFramework/RushSession';
40
41
  export { IRushCommand, IGlobalCommand, IPhasedCommand, RushLifecycleHooks } from './pluginFramework/RushLifeCycle';
41
42
  export { ICreateOperationsContext, PhasedCommandHooks } from './pluginFramework/PhasedCommandHooks';
42
43
  export { IRushPlugin } from './pluginFramework/IRushPlugin';
@@ -44,6 +45,7 @@ export { IBuiltInPluginConfiguration as _IBuiltInPluginConfiguration } from './p
44
45
  export { IRushPluginConfigurationBase as _IRushPluginConfigurationBase } from './api/RushPluginsConfiguration';
45
46
  export { ILogger } from './pluginFramework/logging/Logger';
46
47
  export { ICloudBuildCacheProvider } from './logic/buildCache/ICloudBuildCacheProvider';
48
+ export { ICobuildLockProvider, ICobuildContext, ICobuildCompletedState } from './logic/cobuild/ICobuildLockProvider';
47
49
  export { ICredentialCacheOptions, ICredentialCacheEntry, CredentialCache } from './logic/CredentialCache';
48
50
  export type { ITelemetryData, ITelemetryMachineInfo, ITelemetryOperationResult } from './logic/Telemetry';
49
51
  export { IStopwatchResult } from './utilities/Stopwatch';
@@ -148,6 +148,15 @@ export declare class RushConstants {
148
148
  * Changing this ensures that cache entries generated by an old version will no longer register as a cache hit.
149
149
  */
150
150
  static readonly buildCacheVersion: number;
151
+ /**
152
+ * Cobuild configuration file.
153
+ */
154
+ static readonly cobuildFilename: string;
155
+ /**
156
+ * Cobuild version number, incremented when the logic to create cobuild lock changes.
157
+ * Changing this ensures that lock generated by an old version will no longer access as a cobuild lock.
158
+ */
159
+ static readonly cobuildLockVersion: number;
151
160
  /**
152
161
  * Per-project configuration filename.
153
162
  */
@@ -1,10 +1,10 @@
1
1
  import { ITerminal } from '@rushstack/node-core-library';
2
+ import { RushConfigurationProject } from '../../api/RushConfigurationProject';
2
3
  import { ProjectChangeAnalyzer } from '../ProjectChangeAnalyzer';
3
- import { RushProjectConfiguration } from '../../api/RushProjectConfiguration';
4
4
  import { BuildCacheConfiguration } from '../../api/BuildCacheConfiguration';
5
5
  export interface IProjectBuildCacheOptions {
6
6
  buildCacheConfiguration: BuildCacheConfiguration;
7
- projectConfiguration: RushProjectConfiguration;
7
+ project: RushConfigurationProject;
8
8
  projectOutputFolderNames: ReadonlyArray<string>;
9
9
  additionalProjectOutputFilePaths?: ReadonlyArray<string>;
10
10
  additionalContext?: Record<string, string>;
@@ -30,10 +30,11 @@ export declare class ProjectBuildCache {
30
30
  private _cacheId;
31
31
  private constructor();
32
32
  private static _tryGetTarUtility;
33
+ get cacheId(): string | undefined;
33
34
  static tryGetProjectBuildCache(options: IProjectBuildCacheOptions): Promise<ProjectBuildCache | undefined>;
34
35
  private static _validateProject;
35
- tryRestoreFromCacheAsync(terminal: ITerminal): Promise<boolean>;
36
- trySetCacheEntryAsync(terminal: ITerminal): Promise<boolean>;
36
+ tryRestoreFromCacheAsync(terminal: ITerminal, specifiedCacheId?: string): Promise<boolean>;
37
+ trySetCacheEntryAsync(terminal: ITerminal, specifiedCacheId?: string): Promise<boolean>;
37
38
  /**
38
39
  * Walks the declared output folders of the project and collects a list of files.
39
40
  * @returns The list of output files as project-relative paths, or `undefined` if a
@@ -0,0 +1,24 @@
1
+ import type { CobuildConfiguration } from '../../api/CobuildConfiguration';
2
+ import type { ProjectBuildCache } from '../buildCache/ProjectBuildCache';
3
+ import type { OperationStatus } from '../operations/OperationStatus';
4
+ import type { ICobuildContext } from './ICobuildLockProvider';
5
+ export interface ICobuildLockOptions {
6
+ cobuildConfiguration: CobuildConfiguration;
7
+ projectBuildCache: ProjectBuildCache;
8
+ }
9
+ export interface ICobuildCompletedState {
10
+ status: OperationStatus.Success | OperationStatus.SuccessWithWarning | OperationStatus.Failure;
11
+ cacheId: string;
12
+ }
13
+ export declare class CobuildLock {
14
+ readonly projectBuildCache: ProjectBuildCache;
15
+ readonly cobuildConfiguration: CobuildConfiguration;
16
+ private _cobuildContext;
17
+ constructor(options: ICobuildLockOptions);
18
+ setCompletedStateAsync(state: ICobuildCompletedState): Promise<void>;
19
+ getCompletedStateAsync(): Promise<ICobuildCompletedState | undefined>;
20
+ tryAcquireLockAsync(): Promise<boolean>;
21
+ renewLockAsync(): Promise<void>;
22
+ get cobuildContext(): ICobuildContext;
23
+ }
24
+ //# sourceMappingURL=CobuildLock.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/cobuild/CobuildLock");
@@ -0,0 +1,46 @@
1
+ import type { OperationStatus } from '../operations/OperationStatus';
2
+ /**
3
+ * @beta
4
+ */
5
+ export interface ICobuildContext {
6
+ /**
7
+ * The contextId is provided by the monorepo maintainer, it reads from environment variable {@link EnvironmentVariableNames.RUSH_COBUILD_CONTEXT_ID}.
8
+ * It ensure only the builds from the same given contextId cooperated. If user was more permissive,
9
+ * and wanted all PR and CI builds building anything with the same contextId to cooperate, then just
10
+ * set it to a static value.
11
+ */
12
+ contextId: string;
13
+ /**
14
+ * The id of cache. It should be keep same as the normal cacheId from ProjectBuildCache.
15
+ * Otherwise, there is a discrepancy in the success case then turning on cobuilds will
16
+ * fail to populate the normal build cache.
17
+ */
18
+ cacheId: string;
19
+ /**
20
+ * {@inheritdoc RushConstants.cobuildLockVersion}
21
+ */
22
+ version: number;
23
+ }
24
+ /**
25
+ * @beta
26
+ */
27
+ export interface ICobuildCompletedState {
28
+ status: OperationStatus.Success | OperationStatus.SuccessWithWarning | OperationStatus.Failure;
29
+ /**
30
+ * Completed state points to the cache id that was used to store the build cache.
31
+ * Note: Cache failed builds in a separate cache id
32
+ */
33
+ cacheId: string;
34
+ }
35
+ /**
36
+ * @beta
37
+ */
38
+ export interface ICobuildLockProvider {
39
+ connectAsync(): Promise<void>;
40
+ disconnectAsync(): Promise<void>;
41
+ acquireLockAsync(context: ICobuildContext): Promise<boolean>;
42
+ renewLockAsync(context: ICobuildContext): Promise<void>;
43
+ setCompletedStateAsync(context: ICobuildContext, state: ICobuildCompletedState): Promise<void>;
44
+ getCompletedStateAsync(context: ICobuildContext): Promise<ICobuildCompletedState | undefined>;
45
+ }
46
+ //# sourceMappingURL=ICobuildLockProvider.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/cobuild/ICobuildLockProvider");
@@ -1,6 +1,16 @@
1
1
  import { OperationExecutionRecord } from './OperationExecutionRecord';
2
2
  /**
3
- * Implmentation of the async iteration protocol for a collection of IOperation objects.
3
+ * When the queue returns an unassigned operation, it means there is at least one remote executing operation,
4
+ * at this time, the caller has a chance to make a decision:
5
+ * 1. Manually invoke `tryGetRemoteExecutingOperation()` to get the remote executing operation.
6
+ * 2. If there is no remote executing operation available, wait for some time and return in callback, which
7
+ * internally invoke `assignOperations()` to assign new operations.
8
+ * NOTE: the caller must wait for some time to avoid busy loop and burn CPU cycles.
9
+ */
10
+ export declare const UNASSIGNED_OPERATION: 'UNASSIGNED_OPERATION';
11
+ export declare type IOperationIteratorResult = OperationExecutionRecord | typeof UNASSIGNED_OPERATION;
12
+ /**
13
+ * Implementation of the async iteration protocol for a collection of IOperation objects.
4
14
  * The async iterator will wait for an operation to be ready for execution, or terminate if there are no more operations.
5
15
  *
6
16
  * @remarks
@@ -8,9 +18,12 @@ import { OperationExecutionRecord } from './OperationExecutionRecord';
8
18
  * it must manually invoke `assignOperations()` after performing the updates, otherwise iterators will
9
19
  * stall until another operations completes.
10
20
  */
11
- export declare class AsyncOperationQueue implements AsyncIterable<OperationExecutionRecord>, AsyncIterator<OperationExecutionRecord> {
21
+ export declare class AsyncOperationQueue implements AsyncIterable<IOperationIteratorResult>, AsyncIterator<IOperationIteratorResult> {
12
22
  private readonly _queue;
13
23
  private readonly _pendingIterators;
24
+ private readonly _totalOperations;
25
+ private readonly _completedOperations;
26
+ private _isDone;
14
27
  /**
15
28
  * @param operations - The set of operations to be executed
16
29
  * @param sortFn - A function that sorts operations in reverse priority order:
@@ -23,17 +36,23 @@ export declare class AsyncOperationQueue implements AsyncIterable<OperationExecu
23
36
  * For use with `for await (const operation of taskQueue)`
24
37
  * @see {AsyncIterator}
25
38
  */
26
- next(): Promise<IteratorResult<OperationExecutionRecord>>;
39
+ next(): Promise<IteratorResult<IOperationIteratorResult>>;
40
+ /**
41
+ * Set a callback to be invoked when one operation is completed.
42
+ * If all operations are completed, set the queue to done, resolve all pending iterators in next cycle.
43
+ */
44
+ complete(record: OperationExecutionRecord): void;
27
45
  /**
28
46
  * Routes ready operations with 0 dependencies to waiting iterators. Normally invoked as part of `next()`, but
29
47
  * if the caller does not update operation dependencies prior to calling `next()`, may need to be invoked manually.
30
48
  */
31
49
  assignOperations(): void;
50
+ tryGetRemoteExecutingOperation(): OperationExecutionRecord | undefined;
32
51
  /**
33
52
  * Returns this queue as an async iterator, such that multiple functions iterating this object concurrently
34
53
  * receive distinct iteration results.
35
54
  */
36
- [Symbol.asyncIterator](): AsyncIterator<OperationExecutionRecord>;
55
+ [Symbol.asyncIterator](): AsyncIterator<IOperationIteratorResult>;
37
56
  }
38
57
  export interface IOperationSortFunction {
39
58
  /**
@@ -0,0 +1,21 @@
1
+ import { CobuildLock } from '../cobuild/CobuildLock';
2
+ import { ProjectBuildCache } from '../buildCache/ProjectBuildCache';
3
+ import type { IPhasedCommandPlugin, PhasedCommandHooks } from '../../pluginFramework/PhasedCommandHooks';
4
+ export interface IOperationBuildCacheContext {
5
+ isCacheWriteAllowed: boolean;
6
+ isCacheReadAllowed: boolean;
7
+ isSkipAllowed: boolean;
8
+ projectBuildCache: ProjectBuildCache | undefined;
9
+ cobuildLock: CobuildLock | undefined;
10
+ }
11
+ export declare class CacheableOperationPlugin implements IPhasedCommandPlugin {
12
+ private _buildCacheContextByOperationRunner;
13
+ apply(hooks: PhasedCommandHooks): void;
14
+ private _applyShellOperationRunner;
15
+ private _getBuildCacheContextByRunner;
16
+ private _getBuildCacheContextByRunnerOrThrow;
17
+ private _tryGetProjectBuildCacheAsync;
18
+ private _tryGetLogOnlyProjectBuildCacheAsync;
19
+ private _tryGetCobuildLockAsync;
20
+ }
21
+ //# sourceMappingURL=CacheableOperationPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/operations/CacheableOperationPlugin");
@@ -2,7 +2,7 @@ import type { StdioSummarizer } from '@rushstack/terminal';
2
2
  import type { CollatedWriter } from '@rushstack/stream-collator';
3
3
  import type { OperationStatus } from './OperationStatus';
4
4
  import type { OperationMetadataManager } from './OperationMetadataManager';
5
- import type { IStopwatchResult } from '../../utilities/Stopwatch';
5
+ import type { Stopwatch } from '../../utilities/Stopwatch';
6
6
  /**
7
7
  * Information passed to the executing `IOperationRunner`
8
8
  *
@@ -34,7 +34,34 @@ export interface IOperationRunnerContext {
34
34
  /**
35
35
  * Object used to track elapsed time.
36
36
  */
37
- stopwatch: IStopwatchResult;
37
+ stopwatch: Stopwatch;
38
+ /**
39
+ * The current execution status of an operation. Operations start in the 'ready' state,
40
+ * but can be 'blocked' if an upstream operation failed. It is 'executing' when
41
+ * the operation is executing. Once execution is complete, it is either 'success' or
42
+ * 'failure'.
43
+ */
44
+ status: OperationStatus;
45
+ /**
46
+ * Error which occurred while executing this operation, this is stored in case we need
47
+ * it later (for example to re-print errors at end of execution).
48
+ */
49
+ error?: Error;
50
+ /**
51
+ * The set of operations that depend on this operation.
52
+ */
53
+ readonly consumers: Set<IOperationRunnerContext>;
54
+ /**
55
+ * The operation runner that is executing this operation.
56
+ */
57
+ readonly runner: IOperationRunner;
58
+ /**
59
+ * Normally the incremental build logic will rebuild changed projects as well as
60
+ * any projects that directly or indirectly depend on a changed project.
61
+ * If true, then the incremental build logic will only rebuild changed projects and
62
+ * ignore dependent projects.
63
+ */
64
+ readonly changedProjectsOnly: boolean;
38
65
  }
39
66
  /**
40
67
  * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
@@ -48,10 +75,6 @@ export interface IOperationRunner {
48
75
  * Name of the operation, for logging.
49
76
  */
50
77
  readonly name: string;
51
- /**
52
- * This flag determines if the operation is allowed to be skipped if up to date.
53
- */
54
- isSkipAllowed: boolean;
55
78
  /**
56
79
  * Indicates that this runner's duration has meaning.
57
80
  */
@@ -65,10 +88,6 @@ export interface IOperationRunner {
65
88
  * exit code
66
89
  */
67
90
  warningsAreAllowed: boolean;
68
- /**
69
- * Indicates if the output of this operation may be written to the cache
70
- */
71
- isCacheWriteAllowed: boolean;
72
91
  /**
73
92
  * Method to be executed for the operation.
74
93
  */
@@ -8,6 +8,8 @@ export interface IOperationExecutionManagerOptions {
8
8
  parallelism: number;
9
9
  changedProjectsOnly: boolean;
10
10
  destination?: TerminalWritable;
11
+ beforeExecuteOperation?: (operation: OperationExecutionRecord) => Promise<void>;
12
+ afterExecuteOperation?: (operation: OperationExecutionRecord) => Promise<void>;
11
13
  onOperationStatusChanged?: (record: OperationExecutionRecord) => void;
12
14
  beforeExecuteOperations?: (records: Map<Operation, OperationExecutionRecord>) => Promise<void>;
13
15
  }
@@ -27,11 +29,14 @@ export declare class OperationExecutionManager {
27
29
  private readonly _colorsNewlinesTransform;
28
30
  private readonly _streamCollator;
29
31
  private readonly _terminal;
32
+ private readonly _beforeExecuteOperation?;
33
+ private readonly _afterExecuteOperation?;
30
34
  private readonly _onOperationStatusChanged?;
31
35
  private readonly _beforeExecuteOperations?;
32
36
  private _hasAnyFailures;
33
37
  private _hasAnyNonAllowedWarnings;
34
38
  private _completedOperations;
39
+ private _executionQueue;
35
40
  constructor(operations: Set<Operation>, options: IOperationExecutionManagerOptions);
36
41
  private _streamCollator_onWriterActive;
37
42
  /**
@@ -10,9 +10,12 @@ export interface IOperationExecutionRecordContext {
10
10
  onOperationStatusChanged?: (record: OperationExecutionRecord) => void;
11
11
  debugMode: boolean;
12
12
  quietMode: boolean;
13
+ changedProjectsOnly: boolean;
13
14
  }
14
15
  /**
15
16
  * Internal class representing everything about executing an operation
17
+ *
18
+ * @internal
16
19
  */
17
20
  export declare class OperationExecutionRecord implements IOperationRunnerContext {
18
21
  /**
@@ -37,6 +40,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
37
40
  * operation to execute, the operation with the highest criticalPathLength is chosen.
38
41
  *
39
42
  * Example:
43
+ * ```
40
44
  * (0) A
41
45
  * \
42
46
  * (1) B C (0) (applications)
@@ -53,6 +57,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
53
57
  * X has a score of 1, since the only package which depends on it is A
54
58
  * Z has a score of 2, since only X depends on it, and X has a score of 1
55
59
  * Y has a score of 2, since the chain Y->X->C is longer than Y->C
60
+ * ```
56
61
  *
57
62
  * The algorithm is implemented in AsyncOperationQueue.ts as calculateCriticalPathLength()
58
63
  */
@@ -76,8 +81,9 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
76
81
  get name(): string;
77
82
  get debugMode(): boolean;
78
83
  get quietMode(): boolean;
84
+ get changedProjectsOnly(): boolean;
79
85
  get collatedWriter(): CollatedWriter;
80
86
  get nonCachedDurationMs(): number | undefined;
81
- executeAsync(onResult: (record: OperationExecutionRecord) => void): Promise<void>;
87
+ executeAsync(onResult: (record: OperationExecutionRecord) => Promise<void>): Promise<void>;
82
88
  }
83
89
  //# sourceMappingURL=OperationExecutionRecord.d.ts.map
@@ -0,0 +1,50 @@
1
+ import { AsyncSeriesWaterfallHook } from 'tapable';
2
+ import type { ITerminal } from '@rushstack/node-core-library';
3
+ import type { IOperationRunnerContext } from './IOperationRunner';
4
+ import type { OperationStatus } from './OperationStatus';
5
+ import type { IProjectDeps, ShellOperationRunner } from './ShellOperationRunner';
6
+ import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
7
+ import type { IPhase } from '../../api/CommandLineConfiguration';
8
+ /**
9
+ * A plugin tht interacts with a operation runner
10
+ */
11
+ export interface IOperationRunnerPlugin {
12
+ /**
13
+ * Applies this plugin.
14
+ */
15
+ apply(hooks: OperationRunnerHooks): void;
16
+ }
17
+ export interface IOperationRunnerBeforeExecuteContext {
18
+ context: IOperationRunnerContext;
19
+ runner: ShellOperationRunner;
20
+ earlyReturnStatus: OperationStatus | undefined;
21
+ terminal: ITerminal;
22
+ projectDeps: IProjectDeps | undefined;
23
+ lastProjectDeps: IProjectDeps | undefined;
24
+ trackedProjectFiles: string[] | undefined;
25
+ logPath: string;
26
+ errorLogPath: string;
27
+ rushProject: RushConfigurationProject;
28
+ phase: IPhase;
29
+ commandName: string;
30
+ commandToRun: string;
31
+ }
32
+ export interface IOperationRunnerAfterExecuteContext {
33
+ context: IOperationRunnerContext;
34
+ terminal: ITerminal;
35
+ /**
36
+ * Exit code of the operation command
37
+ */
38
+ exitCode: number;
39
+ status: OperationStatus;
40
+ taskIsSuccessful: boolean;
41
+ }
42
+ /**
43
+ * Hooks into the lifecycle of the operation runner
44
+ *
45
+ */
46
+ export declare class OperationRunnerHooks {
47
+ beforeExecute: AsyncSeriesWaterfallHook<IOperationRunnerBeforeExecuteContext>;
48
+ afterExecute: AsyncSeriesWaterfallHook<IOperationRunnerAfterExecuteContext>;
49
+ }
50
+ //# sourceMappingURL=OperationRunnerHooks.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/operations/OperationRunnerHooks");
@@ -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 declare 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