@rushstack/rush-sdk 5.129.6 → 5.130.0
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/dist/rush-lib.d.ts +23 -6
- package/{lib-shim → dist}/tsdoc-metadata.json +1 -1
- package/lib/api/CommonVersionsConfiguration.d.ts +3 -2
- package/lib/api/ExperimentsConfiguration.d.ts +7 -0
- package/lib/api/RushConfiguration.d.ts +6 -0
- package/lib/logic/RushConstants.d.ts +8 -0
- package/lib/logic/operations/AsyncOperationQueue.d.ts +3 -17
- package/lib/logic/operations/OperationExecutionRecord.d.ts +1 -0
- package/lib/logic/operations/OperationStatus.d.ts +5 -4
- package/lib/utilities/RushAlerts.d.ts +22 -0
- package/lib/utilities/RushAlerts.js +1 -0
- package/lib-commonjs/generate-stubs.d.ts +2 -0
- package/lib-commonjs/generate-stubs.d.ts.map +1 -0
- package/lib-commonjs/generate-stubs.js +84 -0
- package/lib-commonjs/generate-stubs.js.map +1 -0
- package/lib-commonjs/index.d.ts.map +1 -0
- package/lib-commonjs/index.js +207 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/loader.js +192 -0
- package/lib-commonjs/loader.js.map +1 -0
- package/lib-esnext/generate-stubs.js +57 -0
- package/lib-esnext/generate-stubs.js.map +1 -0
- package/lib-esnext/helpers.js +54 -0
- package/lib-esnext/helpers.js.map +1 -0
- package/lib-esnext/index.js +180 -0
- package/lib-esnext/index.js.map +1 -0
- package/lib-esnext/loader.js +165 -0
- package/lib-esnext/loader.js.map +1 -0
- package/lib-shim/commons.js +2200 -0
- package/lib-shim/commons.js.map +1 -0
- package/lib-shim/index.js +298 -184
- package/lib-shim/index.js.map +1 -1
- package/lib-shim/loader.js +228 -191
- package/lib-shim/loader.js.map +1 -1
- package/package.json +22 -9
- package/lib-shim/index.d.ts.map +0 -1
- /package/{lib-shim → lib-commonjs}/helpers.d.ts +0 -0
- /package/{lib-shim → lib-commonjs}/helpers.d.ts.map +0 -0
- /package/{lib-shim → lib-commonjs}/helpers.js +0 -0
- /package/{lib-shim → lib-commonjs}/helpers.js.map +0 -0
- /package/{lib-shim → lib-commonjs}/index.d.ts +0 -0
- /package/{lib-shim → lib-commonjs}/loader.d.ts +0 -0
- /package/{lib-shim → lib-commonjs}/loader.d.ts.map +0 -0
package/dist/rush-lib.d.ts
CHANGED
|
@@ -302,7 +302,7 @@ export declare class CommonVersionsConfiguration {
|
|
|
302
302
|
* If true, then consistent version specifiers for dependencies will be enforced.
|
|
303
303
|
* I.e. "rush check" is run before some commands.
|
|
304
304
|
*/
|
|
305
|
-
readonly ensureConsistentVersions: boolean
|
|
305
|
+
readonly ensureConsistentVersions: boolean;
|
|
306
306
|
/**
|
|
307
307
|
* A table that specifies a "preferred version" for a given NPM package. This feature is typically used
|
|
308
308
|
* to hold back an indirect dependency to a specific older version, or to reduce duplication of indirect dependencies.
|
|
@@ -336,7 +336,7 @@ export declare class CommonVersionsConfiguration {
|
|
|
336
336
|
* Loads the common-versions.json data from the specified file path.
|
|
337
337
|
* If the file has not been created yet, then an empty object is returned.
|
|
338
338
|
*/
|
|
339
|
-
static loadFromFile(jsonFilename: string): CommonVersionsConfiguration;
|
|
339
|
+
static loadFromFile(jsonFilename: string, rushConfiguration?: RushConfiguration): CommonVersionsConfiguration;
|
|
340
340
|
private static _deserializeTable;
|
|
341
341
|
private static _serializeTable;
|
|
342
342
|
/**
|
|
@@ -1419,6 +1419,13 @@ export declare interface IExperimentsJson {
|
|
|
1419
1419
|
* across invocations.
|
|
1420
1420
|
*/
|
|
1421
1421
|
useIPCScriptsInWatchMode?: boolean;
|
|
1422
|
+
/**
|
|
1423
|
+
* (UNDER DEVELOPMENT) The Rush alerts feature provides a way to send announcements to engineers
|
|
1424
|
+
* working in the monorepo, by printing directly in the user's shell window when they invoke Rush commands.
|
|
1425
|
+
* This ensures that important notices will be seen by anyone doing active development, since people often
|
|
1426
|
+
* ignore normal discussion group messages or don't know to subscribe.
|
|
1427
|
+
*/
|
|
1428
|
+
rushAlerts?: boolean;
|
|
1422
1429
|
}
|
|
1423
1430
|
|
|
1424
1431
|
/**
|
|
@@ -2860,10 +2867,6 @@ export declare enum OperationStatus {
|
|
|
2860
2867
|
* The Operation is currently executing
|
|
2861
2868
|
*/
|
|
2862
2869
|
Executing = "EXECUTING",
|
|
2863
|
-
/**
|
|
2864
|
-
* The Operation is currently executing by a remote process
|
|
2865
|
-
*/
|
|
2866
|
-
RemoteExecuting = "REMOTE EXECUTING",
|
|
2867
2870
|
/**
|
|
2868
2871
|
* The Operation completed successfully and did not write to standard output
|
|
2869
2872
|
*/
|
|
@@ -3733,6 +3736,12 @@ export declare class RushConfiguration {
|
|
|
3733
3736
|
* to disable Rush's warning.
|
|
3734
3737
|
*/
|
|
3735
3738
|
readonly suppressNodeLtsWarning: boolean;
|
|
3739
|
+
/**
|
|
3740
|
+
* The raw value of `ensureConsistentVersions` from the `rush.json` file.
|
|
3741
|
+
*
|
|
3742
|
+
* @internal
|
|
3743
|
+
*/
|
|
3744
|
+
readonly _ensureConsistentVersionsJsonValue: boolean | undefined;
|
|
3736
3745
|
/**
|
|
3737
3746
|
* If true, then consistent version specifiers for dependencies will be enforced.
|
|
3738
3747
|
* I.e. "rush check" is run before some commands.
|
|
@@ -4444,6 +4453,14 @@ export declare class RushConstants {
|
|
|
4444
4453
|
* The filename for the last link flag
|
|
4445
4454
|
*/
|
|
4446
4455
|
static readonly lastLinkFlagFilename: 'last-link';
|
|
4456
|
+
/**
|
|
4457
|
+
* The filename for the Rush alerts config file.
|
|
4458
|
+
*/
|
|
4459
|
+
static readonly rushAlertsConfigFilename: 'rush-alerts.json';
|
|
4460
|
+
/**
|
|
4461
|
+
* The filename for the machine-generated file that tracks state for Rush alerts.
|
|
4462
|
+
*/
|
|
4463
|
+
static readonly rushAlertsStateFilename: 'rush-alerts-state.json';
|
|
4447
4464
|
}
|
|
4448
4465
|
|
|
4449
4466
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RushConfiguration } from './RushConfiguration';
|
|
1
2
|
/**
|
|
2
3
|
* Part of the ICommonVersionsJson structure.
|
|
3
4
|
*/
|
|
@@ -45,7 +46,7 @@ export declare class CommonVersionsConfiguration {
|
|
|
45
46
|
* If true, then consistent version specifiers for dependencies will be enforced.
|
|
46
47
|
* I.e. "rush check" is run before some commands.
|
|
47
48
|
*/
|
|
48
|
-
readonly ensureConsistentVersions: boolean
|
|
49
|
+
readonly ensureConsistentVersions: boolean;
|
|
49
50
|
/**
|
|
50
51
|
* A table that specifies a "preferred version" for a given NPM package. This feature is typically used
|
|
51
52
|
* to hold back an indirect dependency to a specific older version, or to reduce duplication of indirect dependencies.
|
|
@@ -79,7 +80,7 @@ export declare class CommonVersionsConfiguration {
|
|
|
79
80
|
* Loads the common-versions.json data from the specified file path.
|
|
80
81
|
* If the file has not been created yet, then an empty object is returned.
|
|
81
82
|
*/
|
|
82
|
-
static loadFromFile(jsonFilename: string): CommonVersionsConfiguration;
|
|
83
|
+
static loadFromFile(jsonFilename: string, rushConfiguration?: RushConfiguration): CommonVersionsConfiguration;
|
|
83
84
|
private static _deserializeTable;
|
|
84
85
|
private static _serializeTable;
|
|
85
86
|
/**
|
|
@@ -76,6 +76,13 @@ export interface IExperimentsJson {
|
|
|
76
76
|
* across invocations.
|
|
77
77
|
*/
|
|
78
78
|
useIPCScriptsInWatchMode?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* (UNDER DEVELOPMENT) The Rush alerts feature provides a way to send announcements to engineers
|
|
81
|
+
* working in the monorepo, by printing directly in the user's shell window when they invoke Rush commands.
|
|
82
|
+
* This ensures that important notices will be seen by anyone doing active development, since people often
|
|
83
|
+
* ignore normal discussion group messages or don't know to subscribe.
|
|
84
|
+
*/
|
|
85
|
+
rushAlerts?: boolean;
|
|
79
86
|
}
|
|
80
87
|
/**
|
|
81
88
|
* Use this class to load the "common/config/rush/experiments.json" config file.
|
|
@@ -356,6 +356,12 @@ export declare class RushConfiguration {
|
|
|
356
356
|
* to disable Rush's warning.
|
|
357
357
|
*/
|
|
358
358
|
readonly suppressNodeLtsWarning: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* The raw value of `ensureConsistentVersions` from the `rush.json` file.
|
|
361
|
+
*
|
|
362
|
+
* @internal
|
|
363
|
+
*/
|
|
364
|
+
readonly _ensureConsistentVersionsJsonValue: boolean | undefined;
|
|
359
365
|
/**
|
|
360
366
|
* If true, then consistent version specifiers for dependencies will be enforced.
|
|
361
367
|
* I.e. "rush check" is run before some commands.
|
|
@@ -260,5 +260,13 @@ export declare class RushConstants {
|
|
|
260
260
|
* The filename for the last link flag
|
|
261
261
|
*/
|
|
262
262
|
static readonly lastLinkFlagFilename: 'last-link';
|
|
263
|
+
/**
|
|
264
|
+
* The filename for the Rush alerts config file.
|
|
265
|
+
*/
|
|
266
|
+
static readonly rushAlertsConfigFilename: 'rush-alerts.json';
|
|
267
|
+
/**
|
|
268
|
+
* The filename for the machine-generated file that tracks state for Rush alerts.
|
|
269
|
+
*/
|
|
270
|
+
static readonly rushAlertsStateFilename: 'rush-alerts-state.json';
|
|
263
271
|
}
|
|
264
272
|
//# sourceMappingURL=RushConstants.d.ts.map
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
import type { OperationExecutionRecord } from './OperationExecutionRecord';
|
|
2
|
-
/**
|
|
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 | {
|
|
12
|
-
weight: 1;
|
|
13
|
-
status: typeof UNASSIGNED_OPERATION;
|
|
14
|
-
};
|
|
15
2
|
/**
|
|
16
3
|
* Implementation of the async iteration protocol for a collection of IOperation objects.
|
|
17
4
|
* The async iterator will wait for an operation to be ready for execution, or terminate if there are no more operations.
|
|
@@ -21,7 +8,7 @@ export type IOperationIteratorResult = OperationExecutionRecord | {
|
|
|
21
8
|
* it must manually invoke `assignOperations()` after performing the updates, otherwise iterators will
|
|
22
9
|
* stall until another operations completes.
|
|
23
10
|
*/
|
|
24
|
-
export declare class AsyncOperationQueue implements AsyncIterable<
|
|
11
|
+
export declare class AsyncOperationQueue implements AsyncIterable<OperationExecutionRecord>, AsyncIterator<OperationExecutionRecord> {
|
|
25
12
|
private readonly _queue;
|
|
26
13
|
private readonly _pendingIterators;
|
|
27
14
|
private readonly _totalOperations;
|
|
@@ -39,7 +26,7 @@ export declare class AsyncOperationQueue implements AsyncIterable<IOperationIter
|
|
|
39
26
|
* For use with `for await (const operation of taskQueue)`
|
|
40
27
|
* @see {AsyncIterator}
|
|
41
28
|
*/
|
|
42
|
-
next(): Promise<IteratorResult<
|
|
29
|
+
next(): Promise<IteratorResult<OperationExecutionRecord>>;
|
|
43
30
|
/**
|
|
44
31
|
* Set a callback to be invoked when one operation is completed.
|
|
45
32
|
* If all operations are completed, set the queue to done, resolve all pending iterators in next cycle.
|
|
@@ -50,12 +37,11 @@ export declare class AsyncOperationQueue implements AsyncIterable<IOperationIter
|
|
|
50
37
|
* if the caller does not update operation dependencies prior to calling `next()`, may need to be invoked manually.
|
|
51
38
|
*/
|
|
52
39
|
assignOperations(): void;
|
|
53
|
-
tryGetRemoteExecutingOperation(): OperationExecutionRecord | undefined;
|
|
54
40
|
/**
|
|
55
41
|
* Returns this queue as an async iterator, such that multiple functions iterating this object concurrently
|
|
56
42
|
* receive distinct iteration results.
|
|
57
43
|
*/
|
|
58
|
-
[Symbol.asyncIterator](): AsyncIterator<
|
|
44
|
+
[Symbol.asyncIterator](): AsyncIterator<OperationExecutionRecord>;
|
|
59
45
|
}
|
|
60
46
|
export interface IOperationSortFunction {
|
|
61
47
|
/**
|
|
@@ -85,6 +85,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
|
|
|
85
85
|
get collatedWriter(): CollatedWriter;
|
|
86
86
|
get nonCachedDurationMs(): number | undefined;
|
|
87
87
|
get cobuildRunnerId(): string | undefined;
|
|
88
|
+
get isTerminal(): boolean;
|
|
88
89
|
/**
|
|
89
90
|
* The current execution status of an operation. Operations start in the 'ready' state,
|
|
90
91
|
* but can be 'blocked' if an upstream operation failed. It is 'executing' when
|
|
@@ -19,10 +19,6 @@ export declare enum OperationStatus {
|
|
|
19
19
|
* The Operation is currently executing
|
|
20
20
|
*/
|
|
21
21
|
Executing = "EXECUTING",
|
|
22
|
-
/**
|
|
23
|
-
* The Operation is currently executing by a remote process
|
|
24
|
-
*/
|
|
25
|
-
RemoteExecuting = "REMOTE EXECUTING",
|
|
26
22
|
/**
|
|
27
23
|
* The Operation completed successfully and did not write to standard output
|
|
28
24
|
*/
|
|
@@ -52,4 +48,9 @@ export declare enum OperationStatus {
|
|
|
52
48
|
*/
|
|
53
49
|
NoOp = "NO OP"
|
|
54
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The set of statuses that are considered terminal.
|
|
53
|
+
* @alpha
|
|
54
|
+
*/
|
|
55
|
+
export declare const TERMINAL_STATUSES: Set<OperationStatus>;
|
|
55
56
|
//# sourceMappingURL=OperationStatus.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Terminal } from '@rushstack/terminal';
|
|
2
|
+
import type { RushConfiguration } from '../api/RushConfiguration';
|
|
3
|
+
export interface IRushAlertsOptions {
|
|
4
|
+
rushConfiguration: RushConfiguration;
|
|
5
|
+
terminal: Terminal;
|
|
6
|
+
}
|
|
7
|
+
export declare class RushAlerts {
|
|
8
|
+
private readonly _rushConfiguration;
|
|
9
|
+
private readonly _terminal;
|
|
10
|
+
private static _rushAlertsJsonSchema;
|
|
11
|
+
readonly rushAlertsStateFilePath: string;
|
|
12
|
+
constructor(options: IRushAlertsOptions);
|
|
13
|
+
private _loadRushAlertsStateAsync;
|
|
14
|
+
isAlertsStateUpToDateAsync(): Promise<boolean>;
|
|
15
|
+
retrieveAlertsAsync(): Promise<void>;
|
|
16
|
+
printAlertsAsync(): Promise<void>;
|
|
17
|
+
private static _parseDate;
|
|
18
|
+
private _isAlertValidAsync;
|
|
19
|
+
private _printMessageInBoxStyle;
|
|
20
|
+
private _writeRushAlertStateAsync;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=RushAlerts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("../../lib-shim/index")._rushSdk_loadInternalModule("utilities/RushAlerts");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-stubs.d.ts","sourceRoot":"","sources":["../src/generate-stubs.ts"],"names":[],"mappings":"AAkDA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB9C"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.runAsync = void 0;
|
|
29
|
+
const path = __importStar(require("path"));
|
|
30
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
31
|
+
function generateLibFilesRecursively(options) {
|
|
32
|
+
for (const folderItem of node_core_library_1.FileSystem.readFolderItems(options.parentSourcePath)) {
|
|
33
|
+
const sourcePath = path.join(options.parentSourcePath, folderItem.name);
|
|
34
|
+
const targetPath = path.join(options.parentTargetPath, folderItem.name);
|
|
35
|
+
if (folderItem.isDirectory()) {
|
|
36
|
+
// create destination folder
|
|
37
|
+
node_core_library_1.FileSystem.ensureEmptyFolder(targetPath);
|
|
38
|
+
generateLibFilesRecursively({
|
|
39
|
+
parentSourcePath: sourcePath,
|
|
40
|
+
parentTargetPath: targetPath,
|
|
41
|
+
parentSrcImportPathWithSlash: options.parentSrcImportPathWithSlash + folderItem.name + '/',
|
|
42
|
+
libShimIndexPath: options.libShimIndexPath
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (folderItem.name.endsWith('.d.ts')) {
|
|
47
|
+
node_core_library_1.FileSystem.copyFile({
|
|
48
|
+
sourcePath: sourcePath,
|
|
49
|
+
destinationPath: targetPath
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else if (folderItem.name.endsWith('.js')) {
|
|
53
|
+
const srcImportPath = options.parentSrcImportPathWithSlash + path.parse(folderItem.name).name;
|
|
54
|
+
const shimPath = path.relative(options.parentTargetPath, options.libShimIndexPath);
|
|
55
|
+
const shimPathLiteral = JSON.stringify(node_core_library_1.Path.convertToSlashes(shimPath));
|
|
56
|
+
const srcImportPathLiteral = JSON.stringify(srcImportPath);
|
|
57
|
+
node_core_library_1.FileSystem.writeFile(targetPath,
|
|
58
|
+
// Example:
|
|
59
|
+
// module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/policy/GitEmailPolicy");
|
|
60
|
+
`module.exports = require(${shimPathLiteral})._rushSdk_loadInternalModule(${srcImportPathLiteral});`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Entry point invoked by "runScript" action from config/heft.json
|
|
66
|
+
async function runAsync() {
|
|
67
|
+
const rushLibFolder = node_core_library_1.Import.resolvePackage({
|
|
68
|
+
baseFolderPath: __dirname,
|
|
69
|
+
packageName: '@microsoft/rush-lib'
|
|
70
|
+
});
|
|
71
|
+
const stubsTargetPath = path.resolve(__dirname, '../lib');
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.log('generate-stubs: Generating stub files under: ' + stubsTargetPath);
|
|
74
|
+
generateLibFilesRecursively({
|
|
75
|
+
parentSourcePath: path.join(rushLibFolder, 'lib'),
|
|
76
|
+
parentTargetPath: stubsTargetPath,
|
|
77
|
+
parentSrcImportPathWithSlash: '',
|
|
78
|
+
libShimIndexPath: path.join(__dirname, '../lib-shim/index')
|
|
79
|
+
});
|
|
80
|
+
// eslint-disable-next-line no-console
|
|
81
|
+
console.log('generate-stubs: Completed successfully.');
|
|
82
|
+
}
|
|
83
|
+
exports.runAsync = runAsync;
|
|
84
|
+
//# sourceMappingURL=generate-stubs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-stubs.js","sourceRoot":"","sources":["../src/generate-stubs.ts"],"names":[],"mappings":";A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,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;gBAC3F,MAAM,eAAe,GAAW,IAAI,CAAC,SAAS,CAAC,wBAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAChF,MAAM,oBAAoB,GAAW,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;gBAEnE,8BAAU,CAAC,SAAS,CAClB,UAAU;gBACV,WAAW;gBACX,kHAAkH;gBAClH,4BAA4B,eAAe,iCAAiC,oBAAoB,IAAI,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,kEAAkE;AAC3D,KAAK,UAAU,QAAQ;IAC5B,MAAM,aAAa,GAAW,0BAAM,CAAC,cAAc,CAAC;QAClD,cAAc,EAAE,SAAS;QACzB,WAAW,EAAE,qBAAqB;KACnC,CAAC,CAAC;IAEH,MAAM,eAAe,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClE,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,+CAA+C,GAAG,eAAe,CAAC,CAAC;IAC/E,2BAA2B,CAAC;QAC1B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC;QACjD,gBAAgB,EAAE,eAAe;QACjC,4BAA4B,EAAE,EAAE;QAChC,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC;KAC5D,CAAC,CAAC;IACH,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;AACzD,CAAC;AAjBD,4BAiBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\n\nimport { FileSystem, Import, Path } from '@rushstack/node-core-library';\n\nfunction generateLibFilesRecursively(options: {\n parentSourcePath: string;\n parentTargetPath: string;\n parentSrcImportPathWithSlash: string;\n libShimIndexPath: string;\n}): void {\n for (const folderItem of FileSystem.readFolderItems(options.parentSourcePath)) {\n const sourcePath: string = path.join(options.parentSourcePath, folderItem.name);\n const targetPath: string = path.join(options.parentTargetPath, folderItem.name);\n\n if (folderItem.isDirectory()) {\n // create destination folder\n FileSystem.ensureEmptyFolder(targetPath);\n generateLibFilesRecursively({\n parentSourcePath: sourcePath,\n parentTargetPath: targetPath,\n parentSrcImportPathWithSlash: options.parentSrcImportPathWithSlash + folderItem.name + '/',\n libShimIndexPath: options.libShimIndexPath\n });\n } else {\n if (folderItem.name.endsWith('.d.ts')) {\n FileSystem.copyFile({\n sourcePath: sourcePath,\n destinationPath: targetPath\n });\n } else if (folderItem.name.endsWith('.js')) {\n const srcImportPath: string = options.parentSrcImportPathWithSlash + path.parse(folderItem.name).name;\n const shimPath: string = path.relative(options.parentTargetPath, options.libShimIndexPath);\n const shimPathLiteral: string = JSON.stringify(Path.convertToSlashes(shimPath));\n const srcImportPathLiteral: string = JSON.stringify(srcImportPath);\n\n FileSystem.writeFile(\n targetPath,\n // Example:\n // module.exports = require(\"../../../lib-shim/index\")._rushSdk_loadInternalModule(\"logic/policy/GitEmailPolicy\");\n `module.exports = require(${shimPathLiteral})._rushSdk_loadInternalModule(${srcImportPathLiteral});`\n );\n }\n }\n }\n}\n\n// Entry point invoked by \"runScript\" action from config/heft.json\nexport async function runAsync(): Promise<void> {\n const rushLibFolder: string = Import.resolvePackage({\n baseFolderPath: __dirname,\n packageName: '@microsoft/rush-lib'\n });\n\n const stubsTargetPath: string = path.resolve(__dirname, '../lib');\n // eslint-disable-next-line no-console\n console.log('generate-stubs: Generating stub files under: ' + stubsTargetPath);\n generateLibFilesRecursively({\n parentSourcePath: path.join(rushLibFolder, 'lib'),\n parentTargetPath: stubsTargetPath,\n parentSrcImportPathWithSlash: '',\n libShimIndexPath: path.join(__dirname, '../lib-shim/index')\n });\n // eslint-disable-next-line no-console\n console.log('generate-stubs: Completed successfully.');\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoOA;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAO1E"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var _a;
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports._rushSdk_loadInternalModule = void 0;
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
32
|
+
const terminal_1 = require("@rushstack/terminal");
|
|
33
|
+
const RushGlobalFolder_1 = require("@microsoft/rush-lib/lib-esnext/api/RushGlobalFolder");
|
|
34
|
+
const helpers_1 = require("./helpers");
|
|
35
|
+
const verboseEnabled = typeof process !== 'undefined' &&
|
|
36
|
+
(process.env.RUSH_SDK_DEBUG === '1' || process.env._RUSH_SDK_DEBUG === '1');
|
|
37
|
+
const terminal = new terminal_1.Terminal(new terminal_1.ConsoleTerminalProvider({
|
|
38
|
+
verboseEnabled
|
|
39
|
+
}));
|
|
40
|
+
let errorMessage = '';
|
|
41
|
+
// SCENARIO 1: Rush's PluginManager has initialized "rush-sdk" with Rush's own instance of rush-lib.
|
|
42
|
+
// The Rush host process will assign "global.___rush___rushLibModule" before loading the plugin.
|
|
43
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
44
|
+
helpers_1.sdkContext.rushLibModule =
|
|
45
|
+
global.___rush___rushLibModule ||
|
|
46
|
+
global.___rush___rushLibModuleFromEnvironment ||
|
|
47
|
+
global.___rush___rushLibModuleFromRushGlobalFolder ||
|
|
48
|
+
global.___rush___rushLibModuleFromInstallAndRunRush;
|
|
49
|
+
}
|
|
50
|
+
// SCENARIO 2: The project importing "rush-sdk" has installed its own instance of "rush-lib"
|
|
51
|
+
// as a package.json dependency. For example, this is used by the Jest tests for Rush plugins.
|
|
52
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
53
|
+
const importingPath = (_a = module === null || module === void 0 ? void 0 : module.parent) === null || _a === void 0 ? void 0 : _a.filename;
|
|
54
|
+
if (importingPath) {
|
|
55
|
+
const callerPackageFolder = node_core_library_1.PackageJsonLookup.instance.tryGetPackageFolderFor(importingPath);
|
|
56
|
+
if (callerPackageFolder !== undefined) {
|
|
57
|
+
const callerPackageJson = (0, helpers_1._require)(path.join(callerPackageFolder, 'package.json'));
|
|
58
|
+
// Does the caller properly declare a dependency on rush-lib?
|
|
59
|
+
if ((callerPackageJson.dependencies && callerPackageJson.dependencies[helpers_1.RUSH_LIB_NAME] !== undefined) ||
|
|
60
|
+
(callerPackageJson.devDependencies &&
|
|
61
|
+
callerPackageJson.devDependencies[helpers_1.RUSH_LIB_NAME] !== undefined) ||
|
|
62
|
+
(callerPackageJson.peerDependencies &&
|
|
63
|
+
callerPackageJson.peerDependencies[helpers_1.RUSH_LIB_NAME] !== undefined)) {
|
|
64
|
+
// Try to resolve rush-lib from the caller's folder
|
|
65
|
+
terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from caller package`);
|
|
66
|
+
try {
|
|
67
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(callerPackageFolder);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
// If we fail to resolve it, ignore the error
|
|
71
|
+
terminal.writeVerboseLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} from caller package`);
|
|
72
|
+
}
|
|
73
|
+
// If two different libraries invoke `rush-sdk`, and one of them provides "rush-lib"
|
|
74
|
+
// then the first version to be loaded wins. We do not support side-by-side instances of "rush-lib".
|
|
75
|
+
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
76
|
+
// to track which scenario is active and how it got initialized.
|
|
77
|
+
global.___rush___rushLibModule = helpers_1.sdkContext.rushLibModule;
|
|
78
|
+
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} from caller`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// SCENARIO 3: A tool or script has been invoked as a child process by an instance of "rush-lib" and can use the
|
|
85
|
+
// version that invoked it. In this case, use process.env._RUSH_LIB_PATH to find "rush-lib".
|
|
86
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
87
|
+
const rushLibPath = process.env[helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME];
|
|
88
|
+
if (rushLibPath) {
|
|
89
|
+
terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME} from caller package`);
|
|
90
|
+
try {
|
|
91
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1._require)(rushLibPath);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
// Log this as a warning, since it is unexpected to define an incorrect value of the variable.
|
|
95
|
+
terminal.writeWarningLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} via process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME}`);
|
|
96
|
+
}
|
|
97
|
+
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
98
|
+
// to track which scenario is active and how it got initialized.
|
|
99
|
+
global.___rush___rushLibModuleFromEnvironment = helpers_1.sdkContext.rushLibModule;
|
|
100
|
+
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} from process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// SCENARIO 4: A standalone tool or script depends on "rush-sdk", and is meant to be used inside a monorepo folder.
|
|
105
|
+
// In this case, we can first load the rush-lib version in rush global folder. If the expected version is not installed,
|
|
106
|
+
// using install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.
|
|
107
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
108
|
+
try {
|
|
109
|
+
const rushJsonPath = (0, helpers_1.tryFindRushJsonLocation)(process.cwd());
|
|
110
|
+
if (!rushJsonPath) {
|
|
111
|
+
throw new Error('Unable to find rush.json in the current folder or its parent folders.\n' +
|
|
112
|
+
'This tool is meant to be invoked from a working directory inside a Rush repository.');
|
|
113
|
+
}
|
|
114
|
+
const monorepoRoot = path.dirname(rushJsonPath);
|
|
115
|
+
const rushJson = node_core_library_1.JsonFile.load(rushJsonPath);
|
|
116
|
+
const { rushVersion } = rushJson;
|
|
117
|
+
try {
|
|
118
|
+
terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from rush global folder`);
|
|
119
|
+
const rushGlobalFolder = new RushGlobalFolder_1.RushGlobalFolder();
|
|
120
|
+
// The path needs to keep align with the logic inside RushVersionSelector
|
|
121
|
+
const expectedGlobalRushInstalledFolder = `${rushGlobalFolder.nodeSpecificPath}/rush-${rushVersion}`;
|
|
122
|
+
terminal.writeVerboseLine(`The expected global rush installed folder is "${expectedGlobalRushInstalledFolder}"`);
|
|
123
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(expectedGlobalRushInstalledFolder);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
terminal.writeVerboseLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} from rush global folder: ${e.message}`);
|
|
127
|
+
}
|
|
128
|
+
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
129
|
+
// to track which scenario is active and how it got initialized.
|
|
130
|
+
global.___rush___rushLibModuleFromRushGlobalFolder = helpers_1.sdkContext.rushLibModule;
|
|
131
|
+
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} installed from rush global folder`);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const installRunNodeModuleFolder = `${monorepoRoot}/common/temp/install-run/@microsoft+rush@${rushVersion}`;
|
|
135
|
+
try {
|
|
136
|
+
// First, try to load the version of "rush-lib" that was installed by install-run-rush.js
|
|
137
|
+
terminal.writeVerboseLine(`Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`);
|
|
138
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
|
|
139
|
+
}
|
|
140
|
+
catch (e1) {
|
|
141
|
+
let installAndRunRushStderrContent = '';
|
|
142
|
+
try {
|
|
143
|
+
const installAndRunRushJSPath = `${monorepoRoot}/common/scripts/install-run-rush.js`;
|
|
144
|
+
terminal.writeLine('The Rush engine has not been installed yet. Invoking install-run-rush.js...');
|
|
145
|
+
const installAndRunRushProcess = node_core_library_1.Executable.spawnSync('node', [installAndRunRushJSPath, '--help'], {
|
|
146
|
+
stdio: 'pipe'
|
|
147
|
+
});
|
|
148
|
+
installAndRunRushStderrContent = installAndRunRushProcess.stderr;
|
|
149
|
+
if (installAndRunRushProcess.status !== 0) {
|
|
150
|
+
throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to install`);
|
|
151
|
+
}
|
|
152
|
+
// Retry to load "rush-lib" after install-run-rush run
|
|
153
|
+
terminal.writeVerboseLine(`Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush a second time`);
|
|
154
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
|
|
155
|
+
}
|
|
156
|
+
catch (e2) {
|
|
157
|
+
// eslint-disable-next-line no-console
|
|
158
|
+
console.error(`${installAndRunRushStderrContent}`);
|
|
159
|
+
throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to load`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
163
|
+
// to track which scenario is active and how it got initialized.
|
|
164
|
+
global.___rush___rushLibModuleFromInstallAndRunRush = helpers_1.sdkContext.rushLibModule;
|
|
165
|
+
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
// no-catch
|
|
171
|
+
errorMessage = e.message;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
175
|
+
// This error indicates that a project is trying to import "@rushstack/rush-sdk", but the Rush engine
|
|
176
|
+
// instance cannot be found. If you are writing Jest tests for a Rush plugin, add "@microsoft/rush-lib"
|
|
177
|
+
// to the devDependencies for your project.
|
|
178
|
+
// eslint-disable-next-line no-console
|
|
179
|
+
console.error(`Error: The @rushstack/rush-sdk package was not able to load the Rush engine:
|
|
180
|
+
${errorMessage}
|
|
181
|
+
`);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
// Based on TypeScript's __exportStar()
|
|
185
|
+
for (const property in helpers_1.sdkContext.rushLibModule) {
|
|
186
|
+
if (property !== 'default' && !exports.hasOwnProperty(property)) {
|
|
187
|
+
const rushLibModuleForClosure = helpers_1.sdkContext.rushLibModule;
|
|
188
|
+
// Based on TypeScript's __createBinding()
|
|
189
|
+
Object.defineProperty(exports, property, {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
get: function () {
|
|
192
|
+
return rushLibModuleForClosure[property];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Used by the .js stubs for path-based imports of `@microsoft/rush-lib` internal APIs.
|
|
199
|
+
*/
|
|
200
|
+
function _rushSdk_loadInternalModule(srcImportPath) {
|
|
201
|
+
if (!exports._RushInternals) {
|
|
202
|
+
throw new Error(`Rush version ${exports.Rush.version} does not support internal API imports via rush-sdk`);
|
|
203
|
+
}
|
|
204
|
+
return exports._RushInternals.loadModule(srcImportPath);
|
|
205
|
+
}
|
|
206
|
+
exports._rushSdk_loadInternalModule = _rushSdk_loadInternalModule;
|
|
207
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAC7B,oEAMsC;AACtC,kDAAwE;AACxE,0FAAuF;AAEvF,uCAQmB;AAEnB,MAAM,cAAc,GAClB,OAAO,OAAO,K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K,CACb,gBAAgB,OAAO,CAAC,IAAI,CAAC,OAAO,qDAAqD,CAC1F,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC1D,CAAC;AAPD,kEAOC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\nimport {\n JsonFile,\n type JsonObject,\n type IPackageJson,\n PackageJsonLookup,\n Executable\n} from '@rushstack/node-core-library';\nimport { Terminal, ConsoleTerminalProvider } from '@rushstack/terminal';\nimport { RushGlobalFolder } from '@microsoft/rush-lib/lib-esnext/api/RushGlobalFolder';\nimport type { SpawnSyncReturns } from 'child_process';\nimport {\n RUSH_LIB_NAME,\n RUSH_LIB_PATH_ENV_VAR_NAME,\n type RushLibModuleType,\n _require,\n requireRushLibUnderFolderPath,\n tryFindRushJsonLocation,\n sdkContext\n} from './helpers';\n\nconst verboseEnabled: boolean =\n typeof process !== 'undefined' &&\n (process.env.RUSH_SDK_DEBUG === '1' || process.env._RUSH_SDK_DEBUG === '1');\nconst terminal: Terminal = new Terminal(\n new ConsoleTerminalProvider({\n verboseEnabled\n })\n);\n\ndeclare const global: typeof globalThis & {\n ___rush___rushLibModule?: RushLibModuleType;\n ___rush___rushLibModuleFromEnvironment?: RushLibModuleType;\n ___rush___rushLibModuleFromRushGlobalFolder?: RushLibModuleType;\n ___rush___rushLibModuleFromInstallAndRunRush?: RushLibModuleType;\n};\n\nlet errorMessage: string = '';\n\n// SCENARIO 1: Rush's PluginManager has initialized \"rush-sdk\" with Rush's own instance of rush-lib.\n// The Rush host process will assign \"global.___rush___rushLibModule\" before loading the plugin.\nif (sdkContext.rushLibModule === undefined) {\n sdkContext.rushLibModule =\n global.___rush___rushLibModule ||\n global.___rush___rushLibModuleFromEnvironment ||\n global.___rush___rushLibModuleFromRushGlobalFolder ||\n global.___rush___rushLibModuleFromInstallAndRunRush;\n}\n\n// SCENARIO 2: The project importing \"rush-sdk\" has installed its own instance of \"rush-lib\"\n// as a package.json dependency. For example, this is used by the Jest tests for Rush plugins.\nif (sdkContext.rushLibModule === undefined) {\n const importingPath: string | null | undefined = module?.parent?.filename;\n if (importingPath) {\n const callerPackageFolder: string | undefined =\n PackageJsonLookup.instance.tryGetPackageFolderFor(importingPath);\n\n if (callerPackageFolder !== undefined) {\n const callerPackageJson: IPackageJson = _require(path.join(callerPackageFolder, 'package.json'));\n\n // Does the caller properly declare a dependency on rush-lib?\n if (\n (callerPackageJson.dependencies && callerPackageJson.dependencies[RUSH_LIB_NAME] !== undefined) ||\n (callerPackageJson.devDependencies &&\n callerPackageJson.devDependencies[RUSH_LIB_NAME] !== undefined) ||\n (callerPackageJson.peerDependencies &&\n callerPackageJson.peerDependencies[RUSH_LIB_NAME] !== undefined)\n ) {\n // Try to resolve rush-lib from the caller's folder\n terminal.writeVerboseLine(`Try to load ${RUSH_LIB_NAME} from caller package`);\n try {\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(callerPackageFolder);\n } catch (error) {\n // If we fail to resolve it, ignore the error\n terminal.writeVerboseLine(`Failed to load ${RUSH_LIB_NAME} from caller package`);\n }\n\n // If two different libraries invoke `rush-sdk`, and one of them provides \"rush-lib\"\n // then the first version to be loaded wins. We do not support side-by-side instances of \"rush-lib\".\n if (sdkContext.rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModule = sdkContext.rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} from caller`);\n }\n }\n }\n }\n}\n\n// SCENARIO 3: A tool or script has been invoked as a child process by an instance of \"rush-lib\" and can use the\n// version that invoked it. In this case, use process.env._RUSH_LIB_PATH to find \"rush-lib\".\nif (sdkContext.rushLibModule === undefined) {\n const rushLibPath: string | undefined = process.env[RUSH_LIB_PATH_ENV_VAR_NAME];\n if (rushLibPath) {\n terminal.writeVerboseLine(\n `Try to load ${RUSH_LIB_NAME} from process.env.${RUSH_LIB_PATH_ENV_VAR_NAME} from caller package`\n );\n try {\n sdkContext.rushLibModule = _require(rushLibPath);\n } catch (error) {\n // Log this as a warning, since it is unexpected to define an incorrect value of the variable.\n terminal.writeWarningLine(\n `Failed to load ${RUSH_LIB_NAME} via process.env.${RUSH_LIB_PATH_ENV_VAR_NAME}`\n );\n }\n\n if (sdkContext.rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModuleFromEnvironment = sdkContext.rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} from process.env.${RUSH_LIB_PATH_ENV_VAR_NAME}`);\n }\n }\n}\n\n// SCENARIO 4: A standalone tool or script depends on \"rush-sdk\", and is meant to be used inside a monorepo folder.\n// In this case, we can first load the rush-lib version in rush global folder. If the expected version is not installed,\n// using install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.\nif (sdkContext.rushLibModule === undefined) {\n try {\n const rushJsonPath: string | undefined = tryFindRushJsonLocation(process.cwd());\n if (!rushJsonPath) {\n throw new Error(\n 'Unable to find rush.json in the current folder or its parent folders.\\n' +\n 'This tool is meant to be invoked from a working directory inside a Rush repository.'\n );\n }\n const monorepoRoot: string = path.dirname(rushJsonPath);\n\n const rushJson: JsonObject = JsonFile.load(rushJsonPath);\n const { rushVersion } = rushJson;\n\n try {\n terminal.writeVerboseLine(`Try to load ${RUSH_LIB_NAME} from rush global folder`);\n const rushGlobalFolder: RushGlobalFolder = new RushGlobalFolder();\n // The path needs to keep align with the logic inside RushVersionSelector\n const expectedGlobalRushInstalledFolder: string = `${rushGlobalFolder.nodeSpecificPath}/rush-${rushVersion}`;\n terminal.writeVerboseLine(\n `The expected global rush installed folder is \"${expectedGlobalRushInstalledFolder}\"`\n );\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(expectedGlobalRushInstalledFolder);\n } catch (e) {\n terminal.writeVerboseLine(`Failed to load ${RUSH_LIB_NAME} from rush global folder: ${e.message}`);\n }\n\n if (sdkContext.rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModuleFromRushGlobalFolder = sdkContext.rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} installed from rush global folder`);\n } else {\n const installRunNodeModuleFolder: string = `${monorepoRoot}/common/temp/install-run/@microsoft+rush@${rushVersion}`;\n\n try {\n // First, try to load the version of \"rush-lib\" that was installed by install-run-rush.js\n terminal.writeVerboseLine(`Trying to load ${RUSH_LIB_NAME} installed by install-run-rush`);\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);\n } catch (e1) {\n let installAndRunRushStderrContent: string = '';\n try {\n const installAndRunRushJSPath: string = `${monorepoRoot}/common/scripts/install-run-rush.js`;\n\n terminal.writeLine('The Rush engine has not been installed yet. Invoking install-run-rush.js...');\n\n const installAndRunRushProcess: SpawnSyncReturns<string> = Executable.spawnSync(\n 'node',\n [installAndRunRushJSPath, '--help'],\n {\n stdio: 'pipe'\n }\n );\n\n installAndRunRushStderrContent = installAndRunRushProcess.stderr;\n if (installAndRunRushProcess.status !== 0) {\n throw new Error(`The ${RUSH_LIB_NAME} package failed to install`);\n }\n\n // Retry to load \"rush-lib\" after install-run-rush run\n terminal.writeVerboseLine(\n `Trying to load ${RUSH_LIB_NAME} installed by install-run-rush a second time`\n );\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);\n } catch (e2) {\n // eslint-disable-next-line no-console\n console.error(`${installAndRunRushStderrContent}`);\n throw new Error(`The ${RUSH_LIB_NAME} package failed to load`);\n }\n }\n\n if (sdkContext.rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModuleFromInstallAndRunRush = sdkContext.rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} installed by install-run-rush`);\n }\n }\n } catch (e) {\n // no-catch\n errorMessage = (e as Error).message;\n }\n}\n\nif (sdkContext.rushLibModule === undefined) {\n // This error indicates that a project is trying to import \"@rushstack/rush-sdk\", but the Rush engine\n // instance cannot be found. If you are writing Jest tests for a Rush plugin, add \"@microsoft/rush-lib\"\n // to the devDependencies for your project.\n // eslint-disable-next-line no-console\n console.error(`Error: The @rushstack/rush-sdk package was not able to load the Rush engine:\n${errorMessage}\n`);\n process.exit(1);\n}\n\n// Based on TypeScript's __exportStar()\nfor (const property in sdkContext.rushLibModule) {\n if (property !== 'default' && !exports.hasOwnProperty(property)) {\n const rushLibModuleForClosure: RushLibModuleType = sdkContext.rushLibModule;\n\n // Based on TypeScript's __createBinding()\n Object.defineProperty(exports, property, {\n enumerable: true,\n get: function () {\n return rushLibModuleForClosure[property];\n }\n });\n }\n}\n\n/**\n * Used by the .js stubs for path-based imports of `@microsoft/rush-lib` internal APIs.\n */\nexport function _rushSdk_loadInternalModule(srcImportPath: string): unknown {\n if (!exports._RushInternals) {\n throw new Error(\n `Rush version ${exports.Rush.version} does not support internal API imports via rush-sdk`\n );\n }\n return exports._RushInternals.loadModule(srcImportPath);\n}\n"]}
|