@rushstack/rush-sdk 5.100.2 → 5.101.0-pr3949.3

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 (48) hide show
  1. package/README.md +97 -5
  2. package/dist/loader.d.ts +92 -0
  3. package/dist/rush-lib.d.ts +292 -10
  4. package/dist/rush-sdk.d.ts +92 -0
  5. package/dist/tsdoc-metadata.json +11 -0
  6. package/lib/api/CobuildConfiguration.d.ts +71 -0
  7. package/lib/api/CobuildConfiguration.js +1 -0
  8. package/lib/api/EnvironmentConfiguration.d.ts +61 -0
  9. package/lib/index.d.ts +3 -1
  10. package/lib/logic/RushConstants.d.ts +4 -0
  11. package/lib/logic/buildCache/ProjectBuildCache.d.ts +5 -4
  12. package/lib/logic/cobuild/CobuildLock.d.ts +43 -0
  13. package/lib/logic/cobuild/CobuildLock.js +1 -0
  14. package/lib/logic/cobuild/DisjointSet.d.ts +28 -0
  15. package/lib/logic/cobuild/DisjointSet.js +1 -0
  16. package/lib/logic/cobuild/ICobuildLockProvider.d.ts +99 -0
  17. package/lib/logic/cobuild/ICobuildLockProvider.js +1 -0
  18. package/lib/logic/deploy/DeployScenarioConfiguration.d.ts +2 -0
  19. package/lib/logic/operations/AsyncOperationQueue.d.ts +23 -4
  20. package/lib/logic/operations/CacheableOperationPlugin.d.ts +30 -0
  21. package/lib/logic/operations/CacheableOperationPlugin.js +1 -0
  22. package/lib/logic/operations/IOperationExecutionResult.d.ts +4 -0
  23. package/lib/logic/operations/IOperationRunner.d.ts +27 -8
  24. package/lib/logic/operations/OperationExecutionManager.d.ts +5 -0
  25. package/lib/logic/operations/OperationExecutionRecord.d.ts +8 -1
  26. package/lib/logic/operations/OperationMetadataManager.d.ts +3 -1
  27. package/lib/logic/operations/OperationRunnerHooks.d.ts +52 -0
  28. package/lib/logic/operations/OperationRunnerHooks.js +1 -0
  29. package/lib/logic/operations/OperationStateFile.d.ts +2 -0
  30. package/lib/logic/operations/OperationStatus.d.ts +8 -0
  31. package/lib/logic/operations/PeriodicCallback.d.ts +20 -0
  32. package/lib/logic/operations/PeriodicCallback.js +1 -0
  33. package/lib/logic/operations/ShellOperationRunner.d.ts +6 -14
  34. package/lib/logic/pnpm/PnpmShrinkwrapFile.d.ts +5 -0
  35. package/lib/pluginFramework/PhasedCommandHooks.d.ts +20 -3
  36. package/lib/pluginFramework/RushSession.d.ts +11 -2
  37. package/lib-shim/helpers.d.ts +21 -0
  38. package/lib-shim/helpers.d.ts.map +1 -0
  39. package/lib-shim/helpers.js +83 -0
  40. package/lib-shim/helpers.js.map +1 -0
  41. package/lib-shim/index.d.ts.map +1 -1
  42. package/lib-shim/index.js +44 -86
  43. package/lib-shim/index.js.map +1 -1
  44. package/lib-shim/loader.d.ts +86 -0
  45. package/lib-shim/loader.d.ts.map +1 -0
  46. package/lib-shim/loader.js +189 -0
  47. package/lib-shim/loader.js.map +1 -0
  48. package/package.json +21 -9
@@ -0,0 +1,92 @@
1
+ /// <reference types="node" />
2
+
3
+ /**
4
+ * Options for {@link RushSdkLoader.loadAsync}
5
+ * @public
6
+ */
7
+ export declare interface ILoadSdkAsyncOptions {
8
+ /**
9
+ * The folder to start from when searching for the Rush workspace configuration.
10
+ * If this folder does not contain a `rush.json` file, then each parent folder
11
+ * will be searched. If `rush.json` is not found, then the SDK fails to load.
12
+ */
13
+ rushJsonSearchFolder?: string;
14
+ /**
15
+ * A cancellation token that the caller can use to prematurely abort the operation.
16
+ */
17
+ abortSignal?: AbortSignal;
18
+ /**
19
+ * Allows the caller to monitor the progress of the operation.
20
+ */
21
+ onNotifyEvent?: SdkNotifyEventCallback;
22
+ }
23
+
24
+ /**
25
+ * Type of {@link ISdkCallbackEvent.logMessage}
26
+ * @public
27
+ */
28
+ export declare interface IProgressBarCallbackLogMessage {
29
+ /**
30
+ * A status message to print in the log window, or `undefined` if there are
31
+ * no further messages. This string may contain newlines.
32
+ */
33
+ text: string;
34
+ /**
35
+ * The type of message. More message types may be added in the future.
36
+ */
37
+ kind: 'info' | 'debug';
38
+ }
39
+
40
+ /**
41
+ * Event options for {@link ILoadSdkAsyncOptions.onNotifyEvent}
42
+ * @public
43
+ */
44
+ export declare interface ISdkCallbackEvent {
45
+ /**
46
+ * Allows the caller to display log information about the operation.
47
+ */
48
+ logMessage: IProgressBarCallbackLogMessage | undefined;
49
+ /**
50
+ * Allows the caller to display a progress bar for long-running operations.
51
+ *
52
+ * @remarks
53
+ * If a long-running operation is required, then `progressPercent` will
54
+ * start at 0.0 and count upwards and finish at 100.0 if the operation completes
55
+ * successfully. If the long-running operation has not yet started, or
56
+ * is not required, then the value will be `undefined`.
57
+ */
58
+ progressPercent: number | undefined;
59
+ }
60
+
61
+ /**
62
+ * Exposes operations that control how the `@microsoft/rush-lib` engine is
63
+ * located and loaded.
64
+ * @public
65
+ */
66
+ export declare class RushSdkLoader {
67
+ /**
68
+ * Throws an "AbortError" exception if abortSignal.aborted is true.
69
+ */
70
+ private static _checkForCancel;
71
+ /**
72
+ * Returns true if the Rush engine has already been loaded.
73
+ */
74
+ static get isLoaded(): boolean;
75
+ /**
76
+ * Manually load the Rush engine based on rush.json found for `rushJsonSearchFolder`.
77
+ * Throws an exception if {@link RushSdkLoader.isLoaded} is already `true`.
78
+ *
79
+ * @remarks
80
+ * This API supports an callback that can be used display a progress bar,
81
+ * log of operations, and allow the operation to be canceled prematurely.
82
+ */
83
+ static loadAsync(options?: ILoadSdkAsyncOptions): Promise<void>;
84
+ }
85
+
86
+ /**
87
+ * Type of {@link ILoadSdkAsyncOptions.onNotifyEvent}
88
+ * @public
89
+ */
90
+ export declare type SdkNotifyEventCallback = (sdkEvent: ISdkCallbackEvent) => void;
91
+
92
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.36.4"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,71 @@
1
+ import { ITerminal } from '@rushstack/node-core-library';
2
+ import { CobuildLockProviderFactory, RushSession } from '../pluginFramework/RushSession';
3
+ import type { ICobuildLockProvider } from '../logic/cobuild/ICobuildLockProvider';
4
+ import type { RushConfiguration } from './RushConfiguration';
5
+ /**
6
+ * @beta
7
+ */
8
+ export interface ICobuildJson {
9
+ cobuildEnabled: boolean;
10
+ cobuildLockProvider: string;
11
+ }
12
+ /**
13
+ * @beta
14
+ */
15
+ export interface ICobuildConfigurationOptions {
16
+ cobuildJson: ICobuildJson;
17
+ rushConfiguration: RushConfiguration;
18
+ rushSession: RushSession;
19
+ cobuildLockProviderFactory: CobuildLockProviderFactory;
20
+ }
21
+ /**
22
+ * Use this class to load and save the "common/config/rush/cobuild.json" config file.
23
+ * This file provides configuration options for the Rush Cobuild feature.
24
+ * @beta
25
+ */
26
+ export declare class CobuildConfiguration {
27
+ private static _jsonSchema;
28
+ /**
29
+ * Indicates whether the cobuild feature is enabled.
30
+ * Typically it is enabled in the cobuild.json config file.
31
+ *
32
+ * Note: The orchestrator (or local users) should always have to opt into running with cobuilds by
33
+ * providing a cobuild context id. Even if cobuilds are "enabled" as a feature, they don't
34
+ * actually turn on for that particular build unless the cobuild context id is provided as an
35
+ * non-empty string.
36
+ */
37
+ readonly cobuildEnabled: boolean;
38
+ /**
39
+ * Cobuild context id
40
+ *
41
+ * @remarks
42
+ * The cobuild feature won't be enabled until the context id is provided as an non-empty string.
43
+ */
44
+ readonly cobuildContextId: string | undefined;
45
+ /**
46
+ * This is a name of the participating cobuild runner. It can be specified by the environment variable
47
+ * RUSH_COBUILD_RUNNER_ID. If it is not provided, a random id will be generated to identify the runner.
48
+ */
49
+ readonly cobuildRunnerId: string;
50
+ /**
51
+ * If true, Rush will automatically handle the leaf project with build cache "disabled" by writing
52
+ * to the cache in a special "log files only mode". This is useful when you want to use Cobuilds
53
+ * to improve the performance in CI validations and the leaf projects have not enabled cache.
54
+ */
55
+ readonly cobuildLeafProjectLogOnlyAllowed: boolean;
56
+ private _cobuildLockProvider;
57
+ private readonly _cobuildLockProviderFactory;
58
+ private readonly _cobuildJson;
59
+ private constructor();
60
+ /**
61
+ * Attempts to load the cobuild.json data from the standard file path `common/config/rush/cobuild.json`.
62
+ * If the file has not been created yet, then undefined is returned.
63
+ */
64
+ static tryLoadAsync(terminal: ITerminal, rushConfiguration: RushConfiguration, rushSession: RushSession): Promise<CobuildConfiguration | undefined>;
65
+ static getCobuildConfigFilePath(rushConfiguration: RushConfiguration): string;
66
+ private static _loadAsync;
67
+ createLockProviderAsync(terminal: ITerminal): Promise<void>;
68
+ destroyLockProviderAsync(): Promise<void>;
69
+ get cobuildLockProvider(): ICobuildLockProvider;
70
+ }
71
+ //# sourceMappingURL=CobuildConfiguration.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../lib-shim/index")._rushSdk_loadInternalModule("api/CobuildConfiguration");
@@ -120,6 +120,43 @@ export declare const EnvironmentVariableNames: {
120
120
  * this environment variable is ignored.
121
121
  */
122
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 opts into running with cobuilds. The context id should be the same across
135
+ * multiple VMs, but changed when it is a new round of cobuilds.
136
+ *
137
+ * e.g. `Build.BuildNumber` in Azure DevOps Pipeline.
138
+ *
139
+ * @remarks
140
+ * If there is no cobuild configured, then this environment variable is ignored.
141
+ */
142
+ readonly RUSH_COBUILD_CONTEXT_ID: "RUSH_COBUILD_CONTEXT_ID";
143
+ /**
144
+ * Explicitly specifies a name for each participating cobuild runner.
145
+ *
146
+ * Setting this environment variable opts into running with cobuilds.
147
+ *
148
+ * @remarks
149
+ * This environment variable is optional, if it is not provided, a random id is used.
150
+ *
151
+ * If there is no cobuild configured, then this environment variable is ignored.
152
+ */
153
+ readonly RUSH_COBUILD_RUNNER_ID: "RUSH_COBUILD_RUNNER_ID";
154
+ /**
155
+ * If this variable is set to "1", When getting distributed builds, Rush will automatically handle the leaf project
156
+ * with build cache "disabled" by writing to the cache in a special "log files only mode". This is useful when you
157
+ * want to use Cobuilds to improve the performance in CI validations and the leaf projects have not enabled cache.
158
+ */
159
+ readonly RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED: "RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED";
123
160
  /**
124
161
  * Explicitly specifies the path for the Git binary that is invoked by certain Rush operations.
125
162
  */
@@ -164,6 +201,10 @@ export declare class EnvironmentConfiguration {
164
201
  private static _buildCacheCredential;
165
202
  private static _buildCacheEnabled;
166
203
  private static _buildCacheWriteAllowed;
204
+ private static _cobuildEnabled;
205
+ private static _cobuildContextId;
206
+ private static _cobuildRunnerId;
207
+ private static _cobuildLeafProjectLogOnlyAllowed;
167
208
  private static _gitBinaryPath;
168
209
  private static _tarBinaryPath;
169
210
  /**
@@ -219,6 +260,26 @@ export declare class EnvironmentConfiguration {
219
260
  * See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_WRITE_ALLOWED}
220
261
  */
221
262
  static get buildCacheWriteAllowed(): boolean | undefined;
263
+ /**
264
+ * If set, enables or disables the cobuild feature.
265
+ * See {@link EnvironmentVariableNames.RUSH_COBUILD_ENABLED}
266
+ */
267
+ static get cobuildEnabled(): boolean | undefined;
268
+ /**
269
+ * Provides a determined cobuild context id if configured
270
+ * See {@link EnvironmentVariableNames.RUSH_COBUILD_CONTEXT_ID}
271
+ */
272
+ static get cobuildContextId(): string | undefined;
273
+ /**
274
+ * Provides a determined cobuild runner id if configured
275
+ * See {@link EnvironmentVariableNames.RUSH_COBUILD_RUNNER_ID}
276
+ */
277
+ static get cobuildRunnerId(): string | undefined;
278
+ /**
279
+ * If set, enables or disables the cobuild leaf project log only feature.
280
+ * See {@link EnvironmentVariableNames.RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED}
281
+ */
282
+ static get cobuildLeafProjectLogOnlyAllowed(): boolean | undefined;
222
283
  /**
223
284
  * Allows the git binary path to be explicitly provided.
224
285
  * 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, PhaseBehaviorForMissingScript as IPhaseBehaviorForMissingScript } 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,10 @@ 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;
151
155
  /**
152
156
  * Per-project configuration filename.
153
157
  */
@@ -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,43 @@
1
+ import type { CobuildConfiguration } from '../../api/CobuildConfiguration';
2
+ import type { OperationStatus } from '../operations/OperationStatus';
3
+ import type { ICobuildContext } from './ICobuildLockProvider';
4
+ import type { ProjectBuildCache } from '../buildCache/ProjectBuildCache';
5
+ export interface ICobuildLockOptions {
6
+ /**
7
+ * {@inheritdoc CobuildConfiguration}
8
+ */
9
+ cobuildConfiguration: CobuildConfiguration;
10
+ /**
11
+ * {@inheritdoc ICobuildContext.clusterId}
12
+ */
13
+ cobuildClusterId: string;
14
+ /**
15
+ * {@inheritdoc ICobuildContext.packageName}
16
+ */
17
+ packageName: string;
18
+ /**
19
+ * {@inheritdoc ICobuildContext.phaseName}
20
+ */
21
+ phaseName: string;
22
+ projectBuildCache: ProjectBuildCache;
23
+ /**
24
+ * The expire time of the lock in seconds.
25
+ */
26
+ lockExpireTimeInSeconds: number;
27
+ }
28
+ export interface ICobuildCompletedState {
29
+ status: OperationStatus.Success | OperationStatus.SuccessWithWarning | OperationStatus.Failure;
30
+ cacheId: string;
31
+ }
32
+ export declare class CobuildLock {
33
+ readonly cobuildConfiguration: CobuildConfiguration;
34
+ readonly projectBuildCache: ProjectBuildCache;
35
+ private _cobuildContext;
36
+ constructor(options: ICobuildLockOptions);
37
+ setCompletedStateAsync(state: ICobuildCompletedState): Promise<void>;
38
+ getCompletedStateAsync(): Promise<ICobuildCompletedState | undefined>;
39
+ tryAcquireLockAsync(): Promise<boolean>;
40
+ renewLockAsync(): Promise<void>;
41
+ get cobuildContext(): ICobuildContext;
42
+ }
43
+ //# sourceMappingURL=CobuildLock.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/cobuild/CobuildLock");
@@ -0,0 +1,28 @@
1
+ /**
2
+ * A disjoint set data structure
3
+ */
4
+ export declare class DisjointSet<T extends object> {
5
+ private _forest;
6
+ private _parentMap;
7
+ private _sizeMap;
8
+ private _setByElement;
9
+ constructor();
10
+ destroy(): void;
11
+ /**
12
+ * Adds a new set containing specific object
13
+ */
14
+ add(x: T): void;
15
+ /**
16
+ * Unions the sets that contain two objects
17
+ */
18
+ union(a: T, b: T): void;
19
+ getAllSets(): Iterable<Set<T>>;
20
+ /**
21
+ * Returns true if x and y are in the same set
22
+ */
23
+ isConnected(x: T, y: T): boolean;
24
+ private _find;
25
+ private _getParent;
26
+ private _getSize;
27
+ }
28
+ //# sourceMappingURL=DisjointSet.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/cobuild/DisjointSet");
@@ -0,0 +1,99 @@
1
+ import type { OperationStatus } from '../operations/OperationStatus';
2
+ /**
3
+ * @beta
4
+ */
5
+ export interface ICobuildContext {
6
+ /**
7
+ * The key for acquiring lock.
8
+ */
9
+ lockKey: string;
10
+ /**
11
+ * The expire time of the lock in seconds.
12
+ */
13
+ lockExpireTimeInSeconds: number;
14
+ /**
15
+ * The key for storing completed state.
16
+ */
17
+ completedStateKey: string;
18
+ /**
19
+ * The contextId is provided by the monorepo maintainer, it reads from environment variable {@link EnvironmentVariableNames.RUSH_COBUILD_CONTEXT_ID}.
20
+ * It ensure only the builds from the same given contextId cooperated.
21
+ */
22
+ contextId: string;
23
+ /**
24
+ * The id of the cluster. The operations in the same cluster share the same clusterId and
25
+ * will be executed on the same machine.
26
+ */
27
+ clusterId: string;
28
+ /**
29
+ * The id of the runner. The identifier for the running machine.
30
+ *
31
+ * It can be specified via assigning `RUSH_COBUILD_RUNNER_ID` environment variable.
32
+ */
33
+ runnerId: string;
34
+ /**
35
+ * The id of the cache entry. It should be kept the same as the normal cacheId from ProjectBuildCache.
36
+ * Otherwise, there is a discrepancy in the success case wherein turning on cobuilds will
37
+ * fail to populate the normal build cache.
38
+ */
39
+ cacheId: string;
40
+ /**
41
+ * The name of NPM package
42
+ *
43
+ * Example: `@scope/MyProject`
44
+ */
45
+ packageName: string;
46
+ /**
47
+ * The name of the phase.
48
+ *
49
+ * Example: _phase:build
50
+ */
51
+ phaseName: string;
52
+ }
53
+ /**
54
+ * @beta
55
+ */
56
+ export interface ICobuildCompletedState {
57
+ status: OperationStatus.Success | OperationStatus.SuccessWithWarning | OperationStatus.Failure;
58
+ /**
59
+ * Completed state points to the cache id that was used to store the build cache.
60
+ * Note: Cache failed builds in a separate cache id
61
+ */
62
+ cacheId: string;
63
+ }
64
+ /**
65
+ * @beta
66
+ */
67
+ export interface ICobuildLockProvider {
68
+ /**
69
+ * The callback function invoked to connect to the lock provider.
70
+ * For example, initializing the connection to the redis server.
71
+ */
72
+ connectAsync(): Promise<void>;
73
+ /**
74
+ * The callback function invoked to disconnect the lock provider.
75
+ */
76
+ disconnectAsync(): Promise<void>;
77
+ /**
78
+ * The callback function to acquire a lock with a lock key and specific contexts.
79
+ *
80
+ * NOTE: This lock implementation must be a ReentrantLock. It says the lock might be acquired
81
+ * multiple times, since tasks in the same cluster can be run in the same VM.
82
+ */
83
+ acquireLockAsync(context: Readonly<ICobuildContext>): Promise<boolean>;
84
+ /**
85
+ * The callback function to renew a lock with a lock key and specific contexts.
86
+ *
87
+ * NOTE: If the lock key expired
88
+ */
89
+ renewLockAsync(context: Readonly<ICobuildContext>): Promise<void>;
90
+ /**
91
+ * The callback function to set completed state.
92
+ */
93
+ setCompletedStateAsync(context: Readonly<ICobuildContext>, state: ICobuildCompletedState): Promise<void>;
94
+ /**
95
+ * The callback function to get completed state.
96
+ */
97
+ getCompletedStateAsync(context: Readonly<ICobuildContext>): Promise<ICobuildCompletedState | undefined>;
98
+ }
99
+ //# sourceMappingURL=ICobuildLockProvider.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/cobuild/ICobuildLockProvider");
@@ -5,6 +5,8 @@ export interface IDeployScenarioProjectJson {
5
5
  additionalProjectsToInclude?: string[];
6
6
  additionalDependenciesToInclude?: string[];
7
7
  dependenciesToExclude?: string[];
8
+ patternsToInclude?: string[];
9
+ patternsToExclude?: string[];
8
10
  }
9
11
  export interface IDeployScenarioJson {
10
12
  deploymentProjectNames: string[];
@@ -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 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,30 @@
1
+ import { ITerminal } from '@rushstack/node-core-library';
2
+ import { CobuildLock } from '../cobuild/CobuildLock';
3
+ import { ProjectBuildCache } from '../buildCache/ProjectBuildCache';
4
+ import { ProjectLogWritable } from './ProjectLogWritable';
5
+ import type { IPhasedCommandPlugin, PhasedCommandHooks } from '../../pluginFramework/PhasedCommandHooks';
6
+ export interface IOperationBuildCacheContext {
7
+ isCacheWriteAllowed: boolean;
8
+ isCacheReadAllowed: boolean;
9
+ isSkipAllowed: boolean;
10
+ projectBuildCache: ProjectBuildCache | undefined;
11
+ cobuildLock: CobuildLock | undefined;
12
+ cobuildClusterId: string | undefined;
13
+ buildCacheTerminal: ITerminal | undefined;
14
+ buildCacheProjectLogWritable: ProjectLogWritable | undefined;
15
+ }
16
+ export declare class CacheableOperationPlugin implements IPhasedCommandPlugin {
17
+ private _buildCacheContextByOperationRunner;
18
+ apply(hooks: PhasedCommandHooks): void;
19
+ private _applyShellOperationRunner;
20
+ private _getBuildCacheContextByRunner;
21
+ private _getBuildCacheContextByRunnerOrThrow;
22
+ private _tryGetProjectBuildCacheEnabledAsync;
23
+ private _tryGetProjectBuildCacheAsync;
24
+ private _tryGetLogOnlyProjectBuildCacheAsync;
25
+ private _tryGetCobuildLockAsync;
26
+ private _getBuildCacheTerminal;
27
+ private _createBuildCacheTerminal;
28
+ private _tryGetBuildCacheProjectLogWritable;
29
+ }
30
+ //# sourceMappingURL=CacheableOperationPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/operations/CacheableOperationPlugin");
@@ -31,6 +31,10 @@ export interface IOperationExecutionResult {
31
31
  * The value indicates the duration of the same operation without cache hit.
32
32
  */
33
33
  readonly nonCachedDurationMs: number | undefined;
34
+ /**
35
+ * The id of the runner which actually runs the building process in cobuild mode.
36
+ */
37
+ readonly cobuildRunnerId: string | undefined;
34
38
  }
35
39
  /**
36
40
  * The `IExecutionResult` interface represents the results of executing a set of {@link Operation}s.