@rushstack/rush-sdk 5.100.1 → 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.
- package/README.md +97 -5
- package/dist/loader.d.ts +92 -0
- package/dist/rush-lib.d.ts +292 -10
- package/dist/rush-sdk.d.ts +92 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/api/CobuildConfiguration.d.ts +71 -0
- package/lib/api/CobuildConfiguration.js +1 -0
- package/lib/api/EnvironmentConfiguration.d.ts +61 -0
- package/lib/index.d.ts +3 -1
- package/lib/logic/RushConstants.d.ts +4 -0
- package/lib/logic/buildCache/ProjectBuildCache.d.ts +5 -4
- package/lib/logic/cobuild/CobuildLock.d.ts +43 -0
- package/lib/logic/cobuild/CobuildLock.js +1 -0
- package/lib/logic/cobuild/DisjointSet.d.ts +28 -0
- package/lib/logic/cobuild/DisjointSet.js +1 -0
- package/lib/logic/cobuild/ICobuildLockProvider.d.ts +99 -0
- package/lib/logic/cobuild/ICobuildLockProvider.js +1 -0
- package/lib/logic/deploy/DeployScenarioConfiguration.d.ts +2 -0
- package/lib/logic/operations/AsyncOperationQueue.d.ts +23 -4
- package/lib/logic/operations/CacheableOperationPlugin.d.ts +30 -0
- package/lib/logic/operations/CacheableOperationPlugin.js +1 -0
- package/lib/logic/operations/IOperationExecutionResult.d.ts +4 -0
- package/lib/logic/operations/IOperationRunner.d.ts +27 -8
- package/lib/logic/operations/OperationExecutionManager.d.ts +5 -0
- package/lib/logic/operations/OperationExecutionRecord.d.ts +8 -1
- package/lib/logic/operations/OperationMetadataManager.d.ts +3 -1
- package/lib/logic/operations/OperationRunnerHooks.d.ts +52 -0
- package/lib/logic/operations/OperationRunnerHooks.js +1 -0
- package/lib/logic/operations/OperationStateFile.d.ts +2 -0
- package/lib/logic/operations/OperationStatus.d.ts +8 -0
- package/lib/logic/operations/PeriodicCallback.d.ts +20 -0
- package/lib/logic/operations/PeriodicCallback.js +1 -0
- package/lib/logic/operations/ShellOperationRunner.d.ts +6 -14
- package/lib/logic/pnpm/PnpmShrinkwrapFile.d.ts +5 -0
- package/lib/pluginFramework/PhasedCommandHooks.d.ts +20 -3
- package/lib/pluginFramework/RushSession.d.ts +11 -2
- package/lib-shim/helpers.d.ts +21 -0
- package/lib-shim/helpers.d.ts.map +1 -0
- package/lib-shim/helpers.js +83 -0
- package/lib-shim/helpers.js.map +1 -0
- package/lib-shim/index.d.ts.map +1 -1
- package/lib-shim/index.js +44 -86
- package/lib-shim/index.js.map +1 -1
- package/lib-shim/loader.d.ts +86 -0
- package/lib-shim/loader.d.ts.map +1 -0
- package/lib-shim/loader.js +189 -0
- package/lib-shim/loader.js.map +1 -0
- package/package.json +22 -10
package/README.md
CHANGED
|
@@ -4,18 +4,110 @@ This is a companion package for the Rush tool. See the [@microsoft/rush](https:/
|
|
|
4
4
|
|
|
5
5
|
⚠ **_THIS PACKAGE IS EXPERIMENTAL_** ⚠
|
|
6
6
|
|
|
7
|
-
The **@rushstack/rush-sdk** package acts as a lightweight proxy for accessing the APIs of the **@microsoft/rush-lib** engine. It is intended to support
|
|
7
|
+
The **@rushstack/rush-sdk** package acts as a lightweight proxy for accessing the APIs of the **@microsoft/rush-lib** engine. It is intended to support five different use cases:
|
|
8
8
|
|
|
9
|
-
1. Rush plugins should import from **@rushstack/rush-sdk** instead of **@microsoft/rush-lib**. This gives plugins full access to Rush APIs while avoiding a redundant installation of those packages. At runtime, the APIs will be bound to the correct `rushVersion` from **rush.json**, and guaranteed to be the same **@microsoft/rush-lib** module instance as the plugin host.
|
|
9
|
+
1. **Rush plugins:** Rush plugins should import from **@rushstack/rush-sdk** instead of **@microsoft/rush-lib**. This gives plugins full access to Rush APIs while avoiding a redundant installation of those packages. At runtime, the APIs will be bound to the correct `rushVersion` from **rush.json**, and guaranteed to be the same **@microsoft/rush-lib** module instance as the plugin host.
|
|
10
10
|
|
|
11
|
-
2. When authoring unit tests for a Rush plugin, developers should add **@microsoft/rush-lib** to their **package.json** `devDependencies`. In this context, **@rushstack/rush-sdk** will resolve to
|
|
11
|
+
2. **Unit tests:** When authoring unit tests (for a Rush plugin, for example), developers should add **@microsoft/rush-lib** to their **package.json** `devDependencies` and add **@rushstack/rush-sdk** to the regular `dependencies`. In this context, **@rushstack/rush-sdk** will resolve to the locally installed instance for testing purposes.
|
|
12
12
|
|
|
13
|
-
3. For
|
|
13
|
+
3. **Rush subprocesses:** For tools within a monorepo that import **@rushstack/rush-sdk** during their build process, child processes will inherit the installation of Rush that invoked them. This is communicated using the `_RUSH_LIB_PATH` environment variable.
|
|
14
14
|
|
|
15
|
-
4. For scripts and tools that are designed to be used in a Rush monorepo,
|
|
15
|
+
4. **Monorepo tools:** For scripts and tools that are designed to be used in a Rush monorepo, **@rushstack/rush-sdk** will automatically invoke **install-run-rush.js** and load the local installation. This ensures that tools load a compatible version of the Rush engine for the given branch.
|
|
16
|
+
|
|
17
|
+
5. **Advanced scenarios:** The secondary `@rushstack/rush-sdk/loader` entry point can be imported by tools that need to explicitly control where **@microsoft/rush-lib** gets loaded from. This API also allows monitoring installation and canceling the operation. This API is used by the Rush Stack VS Code extension, for example.
|
|
16
18
|
|
|
17
19
|
The **@rushstack/rush-sdk** API declarations are identical to the corresponding version of **@microsoft/rush-lib**.
|
|
18
20
|
|
|
21
|
+
## Basic usage
|
|
22
|
+
|
|
23
|
+
Here's an example of basic usage that works with cases 1-4 above:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
// CommonJS notation:
|
|
27
|
+
const { RushConfiguration } = require('@rushstack/rush-sdk');
|
|
28
|
+
|
|
29
|
+
const config = RushConfiguration.loadFromDefaultLocation();
|
|
30
|
+
console.log(config.commonFolder);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// TypeScript notation:
|
|
35
|
+
import { RushConfiguration } from '@rushstack/rush-sdk';
|
|
36
|
+
|
|
37
|
+
const config = RushConfiguration.loadFromDefaultLocation();
|
|
38
|
+
console.log(config.commonFolder);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Loader API
|
|
42
|
+
|
|
43
|
+
Here's a basic example of how to manually load **@rushstack/rush-sdk** and monitor installation progress:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { RushSdkLoader, ISdkCallbackEvent } from '@rushstack/rush-sdk/loader';
|
|
47
|
+
|
|
48
|
+
if (!RushSdkLoader.isLoaded) {
|
|
49
|
+
await RushSdkLoader.loadAsync({
|
|
50
|
+
// the search for rush.json starts here:
|
|
51
|
+
rushJsonSearchFolder: "path/to/my-repo/apps/my-app",
|
|
52
|
+
|
|
53
|
+
onNotifyEvent: (event: ISdkCallbackEvent) => {
|
|
54
|
+
if (event.logMessage) {
|
|
55
|
+
// Your tool can show progress about the loading:
|
|
56
|
+
if (event.logMessage.kind === 'info') {
|
|
57
|
+
console.log(event.logMessage.text);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Any subsequent attempts to call require() will return the same instance
|
|
65
|
+
// that was loaded above.
|
|
66
|
+
const rushSdk = require('@rushstack/rush-sdk');
|
|
67
|
+
const config = rushSdk.RushConfiguration.loadFromDefaultLocation();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Here's a more elaborate example illustrating other API features:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { RushSdkLoader, ISdkCallbackEvent } from '@rushstack/rush-sdk/loader';
|
|
74
|
+
|
|
75
|
+
// Use an AbortController to cancel the operation after a certain time period
|
|
76
|
+
const abortController = new AbortController();
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
abortController.abort();
|
|
79
|
+
}, 1000);
|
|
80
|
+
|
|
81
|
+
if (!RushSdkLoader.isLoaded) {
|
|
82
|
+
await RushSdkLoader.loadAsync({
|
|
83
|
+
// the search for rush.json starts here:
|
|
84
|
+
rushJsonSearchFolder: "path/to/my-repo/apps/my-app",
|
|
85
|
+
|
|
86
|
+
abortSignal: abortController.signal,
|
|
87
|
+
|
|
88
|
+
onNotifyEvent: (event: ISdkCallbackEvent) => {
|
|
89
|
+
if (event.logMessage) {
|
|
90
|
+
// Your tool can show progress about the loading:
|
|
91
|
+
if (event.logMessage.kind === 'info') {
|
|
92
|
+
console.log(event.logMessage.text);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (event.progressPercent !== undefined) {
|
|
97
|
+
// If installation takes a long time, your tool can display a progress bar
|
|
98
|
+
displayYourProgressBar(event.progressPercent);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Any subsequent attempts to call require() will return the same instance
|
|
105
|
+
// that was loaded above.
|
|
106
|
+
const rushSdk = require('@rushstack/rush-sdk');
|
|
107
|
+
const config = rushSdk.RushConfiguration.loadFromDefaultLocation();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
|
|
19
111
|
## Importing internal APIs
|
|
20
112
|
|
|
21
113
|
Backwards compatibility is only guaranteed for the APIs marked as `@public` in the official `rush-lib.d.ts` entry point.
|
package/dist/loader.d.ts
ADDED
|
@@ -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 { }
|
package/dist/rush-lib.d.ts
CHANGED
|
@@ -209,6 +209,62 @@ export declare class ChangeManager {
|
|
|
209
209
|
*/
|
|
210
210
|
export declare type CloudBuildCacheProviderFactory = (buildCacheJson: IBuildCacheJson) => ICloudBuildCacheProvider | Promise<ICloudBuildCacheProvider>;
|
|
211
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Use this class to load and save the "common/config/rush/cobuild.json" config file.
|
|
214
|
+
* This file provides configuration options for the Rush Cobuild feature.
|
|
215
|
+
* @beta
|
|
216
|
+
*/
|
|
217
|
+
export declare class CobuildConfiguration {
|
|
218
|
+
private static _jsonSchema;
|
|
219
|
+
/**
|
|
220
|
+
* Indicates whether the cobuild feature is enabled.
|
|
221
|
+
* Typically it is enabled in the cobuild.json config file.
|
|
222
|
+
*
|
|
223
|
+
* Note: The orchestrator (or local users) should always have to opt into running with cobuilds by
|
|
224
|
+
* providing a cobuild context id. Even if cobuilds are "enabled" as a feature, they don't
|
|
225
|
+
* actually turn on for that particular build unless the cobuild context id is provided as an
|
|
226
|
+
* non-empty string.
|
|
227
|
+
*/
|
|
228
|
+
readonly cobuildEnabled: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Cobuild context id
|
|
231
|
+
*
|
|
232
|
+
* @remarks
|
|
233
|
+
* The cobuild feature won't be enabled until the context id is provided as an non-empty string.
|
|
234
|
+
*/
|
|
235
|
+
readonly cobuildContextId: string | undefined;
|
|
236
|
+
/**
|
|
237
|
+
* This is a name of the participating cobuild runner. It can be specified by the environment variable
|
|
238
|
+
* RUSH_COBUILD_RUNNER_ID. If it is not provided, a random id will be generated to identify the runner.
|
|
239
|
+
*/
|
|
240
|
+
readonly cobuildRunnerId: string;
|
|
241
|
+
/**
|
|
242
|
+
* If true, Rush will automatically handle the leaf project with build cache "disabled" by writing
|
|
243
|
+
* to the cache in a special "log files only mode". This is useful when you want to use Cobuilds
|
|
244
|
+
* to improve the performance in CI validations and the leaf projects have not enabled cache.
|
|
245
|
+
*/
|
|
246
|
+
readonly cobuildLeafProjectLogOnlyAllowed: boolean;
|
|
247
|
+
private _cobuildLockProvider;
|
|
248
|
+
private readonly _cobuildLockProviderFactory;
|
|
249
|
+
private readonly _cobuildJson;
|
|
250
|
+
private constructor();
|
|
251
|
+
/**
|
|
252
|
+
* Attempts to load the cobuild.json data from the standard file path `common/config/rush/cobuild.json`.
|
|
253
|
+
* If the file has not been created yet, then undefined is returned.
|
|
254
|
+
*/
|
|
255
|
+
static tryLoadAsync(terminal: ITerminal, rushConfiguration: RushConfiguration, rushSession: RushSession): Promise<CobuildConfiguration | undefined>;
|
|
256
|
+
static getCobuildConfigFilePath(rushConfiguration: RushConfiguration): string;
|
|
257
|
+
private static _loadAsync;
|
|
258
|
+
createLockProviderAsync(terminal: ITerminal): Promise<void>;
|
|
259
|
+
destroyLockProviderAsync(): Promise<void>;
|
|
260
|
+
get cobuildLockProvider(): ICobuildLockProvider;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @beta
|
|
265
|
+
*/
|
|
266
|
+
export declare type CobuildLockProviderFactory = (cobuildJson: ICobuildJson) => ICobuildLockProvider | Promise<ICobuildLockProvider>;
|
|
267
|
+
|
|
212
268
|
/**
|
|
213
269
|
* Use this class to load and save the "common/config/rush/common-versions.json" config file.
|
|
214
270
|
* This config file stores dependency version information that affects all projects in the repo.
|
|
@@ -338,6 +394,10 @@ export declare class EnvironmentConfiguration {
|
|
|
338
394
|
private static _buildCacheCredential;
|
|
339
395
|
private static _buildCacheEnabled;
|
|
340
396
|
private static _buildCacheWriteAllowed;
|
|
397
|
+
private static _cobuildEnabled;
|
|
398
|
+
private static _cobuildContextId;
|
|
399
|
+
private static _cobuildRunnerId;
|
|
400
|
+
private static _cobuildLeafProjectLogOnlyAllowed;
|
|
341
401
|
private static _gitBinaryPath;
|
|
342
402
|
private static _tarBinaryPath;
|
|
343
403
|
/**
|
|
@@ -393,6 +453,26 @@ export declare class EnvironmentConfiguration {
|
|
|
393
453
|
* See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_WRITE_ALLOWED}
|
|
394
454
|
*/
|
|
395
455
|
static get buildCacheWriteAllowed(): boolean | undefined;
|
|
456
|
+
/**
|
|
457
|
+
* If set, enables or disables the cobuild feature.
|
|
458
|
+
* See {@link EnvironmentVariableNames.RUSH_COBUILD_ENABLED}
|
|
459
|
+
*/
|
|
460
|
+
static get cobuildEnabled(): boolean | undefined;
|
|
461
|
+
/**
|
|
462
|
+
* Provides a determined cobuild context id if configured
|
|
463
|
+
* See {@link EnvironmentVariableNames.RUSH_COBUILD_CONTEXT_ID}
|
|
464
|
+
*/
|
|
465
|
+
static get cobuildContextId(): string | undefined;
|
|
466
|
+
/**
|
|
467
|
+
* Provides a determined cobuild runner id if configured
|
|
468
|
+
* See {@link EnvironmentVariableNames.RUSH_COBUILD_RUNNER_ID}
|
|
469
|
+
*/
|
|
470
|
+
static get cobuildRunnerId(): string | undefined;
|
|
471
|
+
/**
|
|
472
|
+
* If set, enables or disables the cobuild leaf project log only feature.
|
|
473
|
+
* See {@link EnvironmentVariableNames.RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED}
|
|
474
|
+
*/
|
|
475
|
+
static get cobuildLeafProjectLogOnlyAllowed(): boolean | undefined;
|
|
396
476
|
/**
|
|
397
477
|
* Allows the git binary path to be explicitly provided.
|
|
398
478
|
* See {@link EnvironmentVariableNames.RUSH_GIT_BINARY_PATH}
|
|
@@ -550,6 +630,43 @@ export declare const EnvironmentVariableNames: {
|
|
|
550
630
|
* this environment variable is ignored.
|
|
551
631
|
*/
|
|
552
632
|
readonly RUSH_BUILD_CACHE_WRITE_ALLOWED: "RUSH_BUILD_CACHE_WRITE_ALLOWED";
|
|
633
|
+
/**
|
|
634
|
+
* Setting this environment variable overrides the value of `cobuildEnabled` in the `cobuild.json`
|
|
635
|
+
* configuration file.
|
|
636
|
+
*
|
|
637
|
+
* @remarks
|
|
638
|
+
* Specify `1` to enable the cobuild or `0` to disable it.
|
|
639
|
+
*
|
|
640
|
+
* If there is no cobuild configured, then this environment variable is ignored.
|
|
641
|
+
*/
|
|
642
|
+
readonly RUSH_COBUILD_ENABLED: "RUSH_COBUILD_ENABLED";
|
|
643
|
+
/**
|
|
644
|
+
* Setting this environment variable opts into running with cobuilds. The context id should be the same across
|
|
645
|
+
* multiple VMs, but changed when it is a new round of cobuilds.
|
|
646
|
+
*
|
|
647
|
+
* e.g. `Build.BuildNumber` in Azure DevOps Pipeline.
|
|
648
|
+
*
|
|
649
|
+
* @remarks
|
|
650
|
+
* If there is no cobuild configured, then this environment variable is ignored.
|
|
651
|
+
*/
|
|
652
|
+
readonly RUSH_COBUILD_CONTEXT_ID: "RUSH_COBUILD_CONTEXT_ID";
|
|
653
|
+
/**
|
|
654
|
+
* Explicitly specifies a name for each participating cobuild runner.
|
|
655
|
+
*
|
|
656
|
+
* Setting this environment variable opts into running with cobuilds.
|
|
657
|
+
*
|
|
658
|
+
* @remarks
|
|
659
|
+
* This environment variable is optional, if it is not provided, a random id is used.
|
|
660
|
+
*
|
|
661
|
+
* If there is no cobuild configured, then this environment variable is ignored.
|
|
662
|
+
*/
|
|
663
|
+
readonly RUSH_COBUILD_RUNNER_ID: "RUSH_COBUILD_RUNNER_ID";
|
|
664
|
+
/**
|
|
665
|
+
* If this variable is set to "1", When getting distributed builds, Rush will automatically handle the leaf project
|
|
666
|
+
* with build cache "disabled" by writing to the cache in a special "log files only mode". This is useful when you
|
|
667
|
+
* want to use Cobuilds to improve the performance in CI validations and the leaf projects have not enabled cache.
|
|
668
|
+
*/
|
|
669
|
+
readonly RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED: "RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED";
|
|
553
670
|
/**
|
|
554
671
|
* Explicitly specifies the path for the Git binary that is invoked by certain Rush operations.
|
|
555
672
|
*/
|
|
@@ -713,6 +830,114 @@ export declare interface ICloudBuildCacheProvider {
|
|
|
713
830
|
deleteCachedCredentialsAsync(terminal: ITerminal): Promise<void>;
|
|
714
831
|
}
|
|
715
832
|
|
|
833
|
+
/**
|
|
834
|
+
* @beta
|
|
835
|
+
*/
|
|
836
|
+
export declare interface ICobuildCompletedState {
|
|
837
|
+
status: OperationStatus.Success | OperationStatus.SuccessWithWarning | OperationStatus.Failure;
|
|
838
|
+
/**
|
|
839
|
+
* Completed state points to the cache id that was used to store the build cache.
|
|
840
|
+
* Note: Cache failed builds in a separate cache id
|
|
841
|
+
*/
|
|
842
|
+
cacheId: string;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* @beta
|
|
847
|
+
*/
|
|
848
|
+
export declare interface ICobuildContext {
|
|
849
|
+
/**
|
|
850
|
+
* The key for acquiring lock.
|
|
851
|
+
*/
|
|
852
|
+
lockKey: string;
|
|
853
|
+
/**
|
|
854
|
+
* The expire time of the lock in seconds.
|
|
855
|
+
*/
|
|
856
|
+
lockExpireTimeInSeconds: number;
|
|
857
|
+
/**
|
|
858
|
+
* The key for storing completed state.
|
|
859
|
+
*/
|
|
860
|
+
completedStateKey: string;
|
|
861
|
+
/**
|
|
862
|
+
* The contextId is provided by the monorepo maintainer, it reads from environment variable {@link EnvironmentVariableNames.RUSH_COBUILD_CONTEXT_ID}.
|
|
863
|
+
* It ensure only the builds from the same given contextId cooperated.
|
|
864
|
+
*/
|
|
865
|
+
contextId: string;
|
|
866
|
+
/**
|
|
867
|
+
* The id of the cluster. The operations in the same cluster share the same clusterId and
|
|
868
|
+
* will be executed on the same machine.
|
|
869
|
+
*/
|
|
870
|
+
clusterId: string;
|
|
871
|
+
/**
|
|
872
|
+
* The id of the runner. The identifier for the running machine.
|
|
873
|
+
*
|
|
874
|
+
* It can be specified via assigning `RUSH_COBUILD_RUNNER_ID` environment variable.
|
|
875
|
+
*/
|
|
876
|
+
runnerId: string;
|
|
877
|
+
/**
|
|
878
|
+
* The id of the cache entry. It should be kept the same as the normal cacheId from ProjectBuildCache.
|
|
879
|
+
* Otherwise, there is a discrepancy in the success case wherein turning on cobuilds will
|
|
880
|
+
* fail to populate the normal build cache.
|
|
881
|
+
*/
|
|
882
|
+
cacheId: string;
|
|
883
|
+
/**
|
|
884
|
+
* The name of NPM package
|
|
885
|
+
*
|
|
886
|
+
* Example: `@scope/MyProject`
|
|
887
|
+
*/
|
|
888
|
+
packageName: string;
|
|
889
|
+
/**
|
|
890
|
+
* The name of the phase.
|
|
891
|
+
*
|
|
892
|
+
* Example: _phase:build
|
|
893
|
+
*/
|
|
894
|
+
phaseName: string;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* @beta
|
|
899
|
+
*/
|
|
900
|
+
export declare interface ICobuildJson {
|
|
901
|
+
cobuildEnabled: boolean;
|
|
902
|
+
cobuildLockProvider: string;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* @beta
|
|
907
|
+
*/
|
|
908
|
+
export declare interface ICobuildLockProvider {
|
|
909
|
+
/**
|
|
910
|
+
* The callback function invoked to connect to the lock provider.
|
|
911
|
+
* For example, initializing the connection to the redis server.
|
|
912
|
+
*/
|
|
913
|
+
connectAsync(): Promise<void>;
|
|
914
|
+
/**
|
|
915
|
+
* The callback function invoked to disconnect the lock provider.
|
|
916
|
+
*/
|
|
917
|
+
disconnectAsync(): Promise<void>;
|
|
918
|
+
/**
|
|
919
|
+
* The callback function to acquire a lock with a lock key and specific contexts.
|
|
920
|
+
*
|
|
921
|
+
* NOTE: This lock implementation must be a ReentrantLock. It says the lock might be acquired
|
|
922
|
+
* multiple times, since tasks in the same cluster can be run in the same VM.
|
|
923
|
+
*/
|
|
924
|
+
acquireLockAsync(context: Readonly<ICobuildContext>): Promise<boolean>;
|
|
925
|
+
/**
|
|
926
|
+
* The callback function to renew a lock with a lock key and specific contexts.
|
|
927
|
+
*
|
|
928
|
+
* NOTE: If the lock key expired
|
|
929
|
+
*/
|
|
930
|
+
renewLockAsync(context: Readonly<ICobuildContext>): Promise<void>;
|
|
931
|
+
/**
|
|
932
|
+
* The callback function to set completed state.
|
|
933
|
+
*/
|
|
934
|
+
setCompletedStateAsync(context: Readonly<ICobuildContext>, state: ICobuildCompletedState): Promise<void>;
|
|
935
|
+
/**
|
|
936
|
+
* The callback function to get completed state.
|
|
937
|
+
*/
|
|
938
|
+
getCompletedStateAsync(context: Readonly<ICobuildContext>): Promise<ICobuildCompletedState | undefined>;
|
|
939
|
+
}
|
|
940
|
+
|
|
716
941
|
/**
|
|
717
942
|
* A collection of environment variables
|
|
718
943
|
* @public
|
|
@@ -750,6 +975,10 @@ export declare interface ICreateOperationsContext {
|
|
|
750
975
|
* The configuration for the build cache, if the feature is enabled.
|
|
751
976
|
*/
|
|
752
977
|
readonly buildCacheConfiguration: BuildCacheConfiguration | undefined;
|
|
978
|
+
/**
|
|
979
|
+
* The configuration for the cobuild, if cobuild feature and build cache feature are both enabled.
|
|
980
|
+
*/
|
|
981
|
+
readonly cobuildConfiguration: CobuildConfiguration | undefined;
|
|
753
982
|
/**
|
|
754
983
|
* The set of custom parameters for the executing command.
|
|
755
984
|
* Maps from the `longName` field in command-line.json to the parser configuration in ts-command-line.
|
|
@@ -1109,6 +1338,10 @@ export declare interface IOperationExecutionResult {
|
|
|
1109
1338
|
* The value indicates the duration of the same operation without cache hit.
|
|
1110
1339
|
*/
|
|
1111
1340
|
readonly nonCachedDurationMs: number | undefined;
|
|
1341
|
+
/**
|
|
1342
|
+
* The id of the runner which actually runs the building process in cobuild mode.
|
|
1343
|
+
*/
|
|
1344
|
+
readonly cobuildRunnerId: string | undefined;
|
|
1112
1345
|
}
|
|
1113
1346
|
|
|
1114
1347
|
/**
|
|
@@ -1118,6 +1351,8 @@ export declare interface _IOperationMetadata {
|
|
|
1118
1351
|
durationInSeconds: number;
|
|
1119
1352
|
logPath: string;
|
|
1120
1353
|
errorLogPath: string;
|
|
1354
|
+
cobuildContextId: string | undefined;
|
|
1355
|
+
cobuildRunnerId: string | undefined;
|
|
1121
1356
|
}
|
|
1122
1357
|
|
|
1123
1358
|
/**
|
|
@@ -1160,10 +1395,6 @@ export declare interface IOperationRunner {
|
|
|
1160
1395
|
* Name of the operation, for logging.
|
|
1161
1396
|
*/
|
|
1162
1397
|
readonly name: string;
|
|
1163
|
-
/**
|
|
1164
|
-
* This flag determines if the operation is allowed to be skipped if up to date.
|
|
1165
|
-
*/
|
|
1166
|
-
isSkipAllowed: boolean;
|
|
1167
1398
|
/**
|
|
1168
1399
|
* Indicates that this runner's duration has meaning.
|
|
1169
1400
|
*/
|
|
@@ -1177,10 +1408,6 @@ export declare interface IOperationRunner {
|
|
|
1177
1408
|
* exit code
|
|
1178
1409
|
*/
|
|
1179
1410
|
warningsAreAllowed: boolean;
|
|
1180
|
-
/**
|
|
1181
|
-
* Indicates if the output of this operation may be written to the cache
|
|
1182
|
-
*/
|
|
1183
|
-
isCacheWriteAllowed: boolean;
|
|
1184
1411
|
/**
|
|
1185
1412
|
* Method to be executed for the operation.
|
|
1186
1413
|
*/
|
|
@@ -1219,6 +1446,33 @@ export declare interface IOperationRunnerContext {
|
|
|
1219
1446
|
* Object used to track elapsed time.
|
|
1220
1447
|
*/
|
|
1221
1448
|
stopwatch: IStopwatchResult;
|
|
1449
|
+
/**
|
|
1450
|
+
* The current execution status of an operation. Operations start in the 'ready' state,
|
|
1451
|
+
* but can be 'blocked' if an upstream operation failed. It is 'executing' when
|
|
1452
|
+
* the operation is executing. Once execution is complete, it is either 'success' or
|
|
1453
|
+
* 'failure'.
|
|
1454
|
+
*/
|
|
1455
|
+
status: OperationStatus;
|
|
1456
|
+
/**
|
|
1457
|
+
* Error which occurred while executing this operation, this is stored in case we need
|
|
1458
|
+
* it later (for example to re-print errors at end of execution).
|
|
1459
|
+
*/
|
|
1460
|
+
error?: Error;
|
|
1461
|
+
/**
|
|
1462
|
+
* The set of operations that depend on this operation.
|
|
1463
|
+
*/
|
|
1464
|
+
readonly consumers: Set<IOperationRunnerContext>;
|
|
1465
|
+
/**
|
|
1466
|
+
* The operation runner that is executing this operation.
|
|
1467
|
+
*/
|
|
1468
|
+
readonly runner: IOperationRunner;
|
|
1469
|
+
/**
|
|
1470
|
+
* Normally the incremental build logic will rebuild changed projects as well as
|
|
1471
|
+
* any projects that directly or indirectly depend on a changed project.
|
|
1472
|
+
* If true, then the incremental build logic will only rebuild changed projects and
|
|
1473
|
+
* ignore dependent projects.
|
|
1474
|
+
*/
|
|
1475
|
+
readonly changedProjectsOnly: boolean;
|
|
1222
1476
|
}
|
|
1223
1477
|
|
|
1224
1478
|
/**
|
|
@@ -1234,6 +1488,8 @@ export declare interface _IOperationStateFileOptions {
|
|
|
1234
1488
|
*/
|
|
1235
1489
|
export declare interface _IOperationStateJson {
|
|
1236
1490
|
nonCachedDurationMs: number;
|
|
1491
|
+
cobuildContextId: string | undefined;
|
|
1492
|
+
cobuildRunnerId: string | undefined;
|
|
1237
1493
|
}
|
|
1238
1494
|
|
|
1239
1495
|
/**
|
|
@@ -2056,7 +2312,7 @@ export declare class _OperationMetadataManager {
|
|
|
2056
2312
|
* Example: `.rush/temp/operation/_phase_build/error.log`
|
|
2057
2313
|
*/
|
|
2058
2314
|
get relativeFilepaths(): string[];
|
|
2059
|
-
saveAsync({ durationInSeconds, logPath, errorLogPath }: _IOperationMetadata): Promise<void>;
|
|
2315
|
+
saveAsync({ durationInSeconds, cobuildContextId, cobuildRunnerId, logPath, errorLogPath }: _IOperationMetadata): Promise<void>;
|
|
2060
2316
|
tryRestoreAsync({ terminal, logPath, errorLogPath }: {
|
|
2061
2317
|
terminal: ITerminal;
|
|
2062
2318
|
logPath: string;
|
|
@@ -2099,10 +2355,18 @@ export declare enum OperationStatus {
|
|
|
2099
2355
|
* The Operation is on the queue, ready to execute (but may be waiting for dependencies)
|
|
2100
2356
|
*/
|
|
2101
2357
|
Ready = "READY",
|
|
2358
|
+
/**
|
|
2359
|
+
* The Operation is Queued
|
|
2360
|
+
*/
|
|
2361
|
+
Queued = "QUEUED",
|
|
2102
2362
|
/**
|
|
2103
2363
|
* The Operation is currently executing
|
|
2104
2364
|
*/
|
|
2105
2365
|
Executing = "EXECUTING",
|
|
2366
|
+
/**
|
|
2367
|
+
* The Operation is currently executing by a remote process
|
|
2368
|
+
*/
|
|
2369
|
+
RemoteExecuting = "REMOTE EXECUTING",
|
|
2106
2370
|
/**
|
|
2107
2371
|
* The Operation completed successfully and did not write to standard output
|
|
2108
2372
|
*/
|
|
@@ -2260,7 +2524,10 @@ export declare class PhasedCommandHooks {
|
|
|
2260
2524
|
* Hook invoked before operation start
|
|
2261
2525
|
* Hook is series for stable output.
|
|
2262
2526
|
*/
|
|
2263
|
-
readonly beforeExecuteOperations: AsyncSeriesHook<[
|
|
2527
|
+
readonly beforeExecuteOperations: AsyncSeriesHook<[
|
|
2528
|
+
Map<Operation, IOperationExecutionResult>,
|
|
2529
|
+
ICreateOperationsContext
|
|
2530
|
+
]>;
|
|
2264
2531
|
/**
|
|
2265
2532
|
* Hook invoked when operation status changed
|
|
2266
2533
|
* Hook is series for stable output.
|
|
@@ -2272,6 +2539,14 @@ export declare class PhasedCommandHooks {
|
|
|
2272
2539
|
* Hook is series for stable output.
|
|
2273
2540
|
*/
|
|
2274
2541
|
readonly afterExecuteOperations: AsyncSeriesHook<[IExecutionResult, ICreateOperationsContext]>;
|
|
2542
|
+
/**
|
|
2543
|
+
* Hook invoked before executing a operation.
|
|
2544
|
+
*/
|
|
2545
|
+
readonly beforeExecuteOperation: AsyncSeriesHook<[IOperationRunnerContext]>;
|
|
2546
|
+
/**
|
|
2547
|
+
* Hook invoked after executing a operation.
|
|
2548
|
+
*/
|
|
2549
|
+
readonly afterExecuteOperation: AsyncSeriesHook<[IOperationRunnerContext]>;
|
|
2275
2550
|
/**
|
|
2276
2551
|
* Hook invoked after a run has finished and the command is watching for changes.
|
|
2277
2552
|
* May be used to display additional relevant data to the user.
|
|
@@ -3415,6 +3690,10 @@ export declare class RushConstants {
|
|
|
3415
3690
|
* Changing this ensures that cache entries generated by an old version will no longer register as a cache hit.
|
|
3416
3691
|
*/
|
|
3417
3692
|
static readonly buildCacheVersion: number;
|
|
3693
|
+
/**
|
|
3694
|
+
* Cobuild configuration file.
|
|
3695
|
+
*/
|
|
3696
|
+
static readonly cobuildFilename: string;
|
|
3418
3697
|
/**
|
|
3419
3698
|
* Per-project configuration filename.
|
|
3420
3699
|
*/
|
|
@@ -3584,12 +3863,15 @@ declare class RushPluginsConfiguration {
|
|
|
3584
3863
|
export declare class RushSession {
|
|
3585
3864
|
private readonly _options;
|
|
3586
3865
|
private readonly _cloudBuildCacheProviderFactories;
|
|
3866
|
+
private readonly _cobuildLockProviderFactories;
|
|
3587
3867
|
readonly hooks: RushLifecycleHooks;
|
|
3588
3868
|
constructor(options: IRushSessionOptions);
|
|
3589
3869
|
getLogger(name: string): ILogger;
|
|
3590
3870
|
get terminalProvider(): ITerminalProvider;
|
|
3591
3871
|
registerCloudBuildCacheProviderFactory(cacheProviderName: string, factory: CloudBuildCacheProviderFactory): void;
|
|
3592
3872
|
getCloudBuildCacheProviderFactory(cacheProviderName: string): CloudBuildCacheProviderFactory | undefined;
|
|
3873
|
+
registerCobuildLockProviderFactory(cobuildLockProviderName: string, factory: CobuildLockProviderFactory): void;
|
|
3874
|
+
getCobuildLockProviderFactory(cobuildLockProviderName: string): CobuildLockProviderFactory | undefined;
|
|
3593
3875
|
}
|
|
3594
3876
|
|
|
3595
3877
|
/**
|