@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.
- 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 +21 -9
package/lib-shim/index.js
CHANGED
|
@@ -29,59 +29,49 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports._rushSdk_loadInternalModule = void 0;
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
32
|
-
const
|
|
33
|
-
const RUSH_LIB_PATH_ENV_VAR_NAME = '_RUSH_LIB_PATH';
|
|
32
|
+
const helpers_1 = require("./helpers");
|
|
34
33
|
const verboseEnabled = typeof process !== 'undefined' && process.env.RUSH_SDK_DEBUG === '1';
|
|
35
34
|
const terminal = new node_core_library_1.Terminal(new node_core_library_1.ConsoleTerminalProvider({
|
|
36
35
|
verboseEnabled
|
|
37
36
|
}));
|
|
38
|
-
|
|
39
|
-
if (typeof __non_webpack_require__ === 'function') {
|
|
40
|
-
// If this library has been bundled with Webpack, we need to call the real `require` function
|
|
41
|
-
// that doesn't get turned into a `__webpack_require__` statement.
|
|
42
|
-
// `__non_webpack_require__` is a Webpack macro that gets turned into a `require` statement
|
|
43
|
-
// during bundling.
|
|
44
|
-
return __non_webpack_require__(moduleName);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return require(moduleName);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
37
|
+
let errorMessage = '';
|
|
50
38
|
// SCENARIO 1: Rush's PluginManager has initialized "rush-sdk" with Rush's own instance of rush-lib.
|
|
51
39
|
// The Rush host process will assign "global.___rush___rushLibModule" before loading the plugin.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
41
|
+
helpers_1.sdkContext.rushLibModule =
|
|
42
|
+
global.___rush___rushLibModule ||
|
|
43
|
+
global.___rush___rushLibModuleFromEnvironment ||
|
|
44
|
+
global.___rush___rushLibModuleFromInstallAndRunRush;
|
|
45
|
+
}
|
|
56
46
|
// SCENARIO 2: The project importing "rush-sdk" has installed its own instance of "rush-lib"
|
|
57
47
|
// as a package.json dependency. For example, this is used by the Jest tests for Rush plugins.
|
|
58
|
-
if (rushLibModule === undefined) {
|
|
48
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
59
49
|
const importingPath = (_a = module === null || module === void 0 ? void 0 : module.parent) === null || _a === void 0 ? void 0 : _a.filename;
|
|
60
50
|
if (importingPath) {
|
|
61
51
|
const callerPackageFolder = node_core_library_1.PackageJsonLookup.instance.tryGetPackageFolderFor(importingPath);
|
|
62
52
|
if (callerPackageFolder !== undefined) {
|
|
63
|
-
const callerPackageJson = _require(path.join(callerPackageFolder, 'package.json'));
|
|
53
|
+
const callerPackageJson = (0, helpers_1._require)(path.join(callerPackageFolder, 'package.json'));
|
|
64
54
|
// Does the caller properly declare a dependency on rush-lib?
|
|
65
|
-
if ((callerPackageJson.dependencies && callerPackageJson.dependencies[RUSH_LIB_NAME] !== undefined) ||
|
|
55
|
+
if ((callerPackageJson.dependencies && callerPackageJson.dependencies[helpers_1.RUSH_LIB_NAME] !== undefined) ||
|
|
66
56
|
(callerPackageJson.devDependencies &&
|
|
67
|
-
callerPackageJson.devDependencies[RUSH_LIB_NAME] !== undefined) ||
|
|
57
|
+
callerPackageJson.devDependencies[helpers_1.RUSH_LIB_NAME] !== undefined) ||
|
|
68
58
|
(callerPackageJson.peerDependencies &&
|
|
69
|
-
callerPackageJson.peerDependencies[RUSH_LIB_NAME] !== undefined)) {
|
|
59
|
+
callerPackageJson.peerDependencies[helpers_1.RUSH_LIB_NAME] !== undefined)) {
|
|
70
60
|
// Try to resolve rush-lib from the caller's folder
|
|
71
|
-
terminal.writeVerboseLine(`Try to load ${RUSH_LIB_NAME} from caller package`);
|
|
61
|
+
terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from caller package`);
|
|
72
62
|
try {
|
|
73
|
-
rushLibModule = requireRushLibUnderFolderPath(callerPackageFolder);
|
|
63
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(callerPackageFolder);
|
|
74
64
|
}
|
|
75
65
|
catch (error) {
|
|
76
66
|
// If we fail to resolve it, ignore the error
|
|
77
|
-
terminal.writeVerboseLine(`Failed to load ${RUSH_LIB_NAME} from caller package`);
|
|
67
|
+
terminal.writeVerboseLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} from caller package`);
|
|
78
68
|
}
|
|
79
69
|
// If two different libraries invoke `rush-sdk`, and one of them provides "rush-lib"
|
|
80
70
|
// then the first version to be loaded wins. We do not support side-by-side instances of "rush-lib".
|
|
81
|
-
if (rushLibModule !== undefined) {
|
|
71
|
+
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
82
72
|
// to track which scenario is active and how it got initialized.
|
|
83
|
-
global.___rush___rushLibModule = rushLibModule;
|
|
84
|
-
terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} from caller`);
|
|
73
|
+
global.___rush___rushLibModule = helpers_1.sdkContext.rushLibModule;
|
|
74
|
+
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} from caller`);
|
|
85
75
|
}
|
|
86
76
|
}
|
|
87
77
|
}
|
|
@@ -89,29 +79,29 @@ if (rushLibModule === undefined) {
|
|
|
89
79
|
}
|
|
90
80
|
// SCENARIO 3: A tool or script has been invoked as a child process by an instance of "rush-lib" and can use the
|
|
91
81
|
// version that invoked it. In this case, use process.env._RUSH_LIB_PATH to find "rush-lib".
|
|
92
|
-
if (rushLibModule === undefined) {
|
|
93
|
-
const rushLibPath = process.env[RUSH_LIB_PATH_ENV_VAR_NAME];
|
|
82
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
83
|
+
const rushLibPath = process.env[helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME];
|
|
94
84
|
if (rushLibPath) {
|
|
95
|
-
terminal.writeVerboseLine(`Try to load ${RUSH_LIB_NAME} from process.env.${RUSH_LIB_PATH_ENV_VAR_NAME} from caller package`);
|
|
85
|
+
terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME} from caller package`);
|
|
96
86
|
try {
|
|
97
|
-
rushLibModule = _require(rushLibPath);
|
|
87
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1._require)(rushLibPath);
|
|
98
88
|
}
|
|
99
89
|
catch (error) {
|
|
100
90
|
// Log this as a warning, since it is unexpected to define an incorrect value of the variable.
|
|
101
|
-
terminal.writeWarningLine(`Failed to load ${RUSH_LIB_NAME} via process.env.${RUSH_LIB_PATH_ENV_VAR_NAME}`);
|
|
91
|
+
terminal.writeWarningLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} via process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME}`);
|
|
102
92
|
}
|
|
103
|
-
if (rushLibModule !== undefined) {
|
|
93
|
+
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
104
94
|
// to track which scenario is active and how it got initialized.
|
|
105
|
-
global.___rush___rushLibModuleFromEnvironment = rushLibModule;
|
|
106
|
-
terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} from process.env.${RUSH_LIB_PATH_ENV_VAR_NAME}`);
|
|
95
|
+
global.___rush___rushLibModuleFromEnvironment = helpers_1.sdkContext.rushLibModule;
|
|
96
|
+
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} from process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME}`);
|
|
107
97
|
}
|
|
108
98
|
}
|
|
109
99
|
}
|
|
110
100
|
// SCENARIO 4: A standalone tool or script depends on "rush-sdk", and is meant to be used inside a monorepo folder.
|
|
111
101
|
// In this case, we can use install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.
|
|
112
|
-
if (rushLibModule === undefined) {
|
|
102
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
113
103
|
try {
|
|
114
|
-
const rushJsonPath = tryFindRushJsonLocation(process.cwd());
|
|
104
|
+
const rushJsonPath = (0, helpers_1.tryFindRushJsonLocation)(process.cwd());
|
|
115
105
|
if (!rushJsonPath) {
|
|
116
106
|
throw new Error('Unable to find rush.json in the current folder or its parent folders.\n' +
|
|
117
107
|
'This tool is meant to be invoked from a working directory inside a Rush repository.');
|
|
@@ -122,34 +112,34 @@ if (rushLibModule === undefined) {
|
|
|
122
112
|
const installRunNodeModuleFolder = path.join(monorepoRoot, `common/temp/install-run/@microsoft+rush@${rushVersion}`);
|
|
123
113
|
try {
|
|
124
114
|
// First, try to load the version of "rush-lib" that was installed by install-run-rush.js
|
|
125
|
-
terminal.writeVerboseLine(`Trying to load ${RUSH_LIB_NAME} installed by install-run-rush`);
|
|
126
|
-
rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);
|
|
115
|
+
terminal.writeVerboseLine(`Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`);
|
|
116
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
|
|
127
117
|
}
|
|
128
118
|
catch (e) {
|
|
129
119
|
let installAndRunRushStderrContent = '';
|
|
130
120
|
try {
|
|
131
121
|
const installAndRunRushJSPath = path.join(monorepoRoot, 'common/scripts/install-run-rush.js');
|
|
132
122
|
terminal.writeLine('The Rush engine has not been installed yet. Invoking install-run-rush.js...');
|
|
133
|
-
const
|
|
123
|
+
const installAndRunRushProcess = node_core_library_1.Executable.spawnSync('node', [installAndRunRushJSPath, '--help'], {
|
|
134
124
|
stdio: 'pipe'
|
|
135
125
|
});
|
|
136
|
-
installAndRunRushStderrContent =
|
|
137
|
-
if (
|
|
138
|
-
throw new Error(`The ${RUSH_LIB_NAME} package failed to install`);
|
|
126
|
+
installAndRunRushStderrContent = installAndRunRushProcess.stderr;
|
|
127
|
+
if (installAndRunRushProcess.status !== 0) {
|
|
128
|
+
throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to install`);
|
|
139
129
|
}
|
|
140
130
|
// Retry to load "rush-lib" after install-run-rush run
|
|
141
|
-
terminal.writeVerboseLine(`Trying to load ${RUSH_LIB_NAME} installed by install-run-rush a second time`);
|
|
142
|
-
rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);
|
|
131
|
+
terminal.writeVerboseLine(`Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush a second time`);
|
|
132
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
|
|
143
133
|
}
|
|
144
134
|
catch (e) {
|
|
145
135
|
console.error(`${installAndRunRushStderrContent}`);
|
|
146
|
-
throw new Error(`The ${RUSH_LIB_NAME} package failed to load`);
|
|
136
|
+
throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to load`);
|
|
147
137
|
}
|
|
148
138
|
}
|
|
149
|
-
if (rushLibModule !== undefined) {
|
|
139
|
+
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
150
140
|
// to track which scenario is active and how it got initialized.
|
|
151
|
-
global.___rush___rushLibModuleFromInstallAndRunRush = rushLibModule;
|
|
152
|
-
terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} installed by install-run-rush`);
|
|
141
|
+
global.___rush___rushLibModuleFromInstallAndRunRush = helpers_1.sdkContext.rushLibModule;
|
|
142
|
+
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`);
|
|
153
143
|
}
|
|
154
144
|
}
|
|
155
145
|
catch (e) {
|
|
@@ -157,7 +147,7 @@ if (rushLibModule === undefined) {
|
|
|
157
147
|
errorMessage = e.message;
|
|
158
148
|
}
|
|
159
149
|
}
|
|
160
|
-
if (rushLibModule === undefined) {
|
|
150
|
+
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
161
151
|
// This error indicates that a project is trying to import "@rushstack/rush-sdk", but the Rush engine
|
|
162
152
|
// instance cannot be found. If you are writing Jest tests for a Rush plugin, add "@microsoft/rush-lib"
|
|
163
153
|
// to the devDependencies for your project.
|
|
@@ -167,9 +157,9 @@ ${errorMessage}
|
|
|
167
157
|
process.exit(1);
|
|
168
158
|
}
|
|
169
159
|
// Based on TypeScript's __exportStar()
|
|
170
|
-
for (const property in rushLibModule) {
|
|
160
|
+
for (const property in helpers_1.sdkContext.rushLibModule) {
|
|
171
161
|
if (property !== 'default' && !exports.hasOwnProperty(property)) {
|
|
172
|
-
const rushLibModuleForClosure = rushLibModule;
|
|
162
|
+
const rushLibModuleForClosure = helpers_1.sdkContext.rushLibModule;
|
|
173
163
|
// Based on TypeScript's __createBinding()
|
|
174
164
|
Object.defineProperty(exports, property, {
|
|
175
165
|
enumerable: true,
|
|
@@ -189,36 +179,4 @@ function _rushSdk_loadInternalModule(srcImportPath) {
|
|
|
189
179
|
return exports._RushInternals.loadModule(srcImportPath);
|
|
190
180
|
}
|
|
191
181
|
exports._rushSdk_loadInternalModule = _rushSdk_loadInternalModule;
|
|
192
|
-
/**
|
|
193
|
-
* Require `@microsoft/rush-lib` under the specified folder path.
|
|
194
|
-
*/
|
|
195
|
-
function requireRushLibUnderFolderPath(folderPath) {
|
|
196
|
-
const rushLibModulePath = node_core_library_1.Import.resolveModule({
|
|
197
|
-
modulePath: RUSH_LIB_NAME,
|
|
198
|
-
baseFolderPath: folderPath
|
|
199
|
-
});
|
|
200
|
-
return _require(rushLibModulePath);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Find the rush.json location and return the path, or undefined if a rush.json can't be found.
|
|
204
|
-
*
|
|
205
|
-
* @privateRemarks
|
|
206
|
-
* Keep this in sync with `RushConfiguration.tryFindRushJsonLocation`.
|
|
207
|
-
*/
|
|
208
|
-
function tryFindRushJsonLocation(startingFolder) {
|
|
209
|
-
let currentFolder = startingFolder;
|
|
210
|
-
// Look upwards at parent folders until we find a folder containing rush.json
|
|
211
|
-
for (let i = 0; i < 10; ++i) {
|
|
212
|
-
const rushJsonFilename = path.join(currentFolder, 'rush.json');
|
|
213
|
-
if (node_core_library_1.FileSystem.exists(rushJsonFilename)) {
|
|
214
|
-
return rushJsonFilename;
|
|
215
|
-
}
|
|
216
|
-
const parentFolder = path.dirname(currentFolder);
|
|
217
|
-
if (parentFolder === currentFolder) {
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
currentFolder = parentFolder;
|
|
221
|
-
}
|
|
222
|
-
return undefined;
|
|
223
|
-
}
|
|
224
182
|
//# sourceMappingURL=index.js.map
|
package/lib-shim/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAC7B,oEAUsC;AAItC,MAAM,aAAa,GAA0B,qBAAqB,CAAC;AACnE,MAAM,0BAA0B,GAAkD,gBAAgB,CAAC;AAEnG,MAAM,cAAc,GAAY,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,GAAG,CAAC;AACrG,MAAM,QAAQ,GAAa,IAAI,4BAAQ,CACrC,IAAI,2CAAuB,CAAC;IAC1B,cAAc;CACf,CAAC,CACH,CAA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ED;;GAEG;AACH,SAAS,6BAA6B,CAAC,UAAkB;IACvD,MAAM,iBAAiB,GAAW,0BAAM,CAAC,aAAa,CAAC;QACrD,UAAU,EAAE,aAAa;QACzB,cAAc,EAAE,UAAU;KAC3B,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAS,uBAAuB,CAAC,cAAsB;IACrD,IAAI,aAAa,GAAW,cAAc,CAAC;IAE3C,6EAA6E;IAC7E,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE;QACnC,MAAM,gBAAgB,GAAW,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAEvE,IAAI,8BAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;YACvC,OAAO,gBAAgB,CAAC;SACzB;QAED,MAAM,YAAY,GAAW,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACzD,IAAI,YAAY,KAAK,aAAa,EAAE;YAClC,MAAM;SACP;QAED,aAAa,GAAG,YAAY,CAAC;KAC9B;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","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 JsonObject,\n Import,\n IPackageJson,\n PackageJsonLookup,\n Executable,\n FileSystem,\n Terminal,\n ConsoleTerminalProvider\n} from '@rushstack/node-core-library';\nimport type { SpawnSyncReturns } from 'child_process';\nimport type { EnvironmentVariableNames } from '@microsoft/rush-lib';\n\nconst RUSH_LIB_NAME: '@microsoft/rush-lib' = '@microsoft/rush-lib';\nconst RUSH_LIB_PATH_ENV_VAR_NAME: typeof EnvironmentVariableNames.RUSH_LIB_PATH = '_RUSH_LIB_PATH';\n\nconst verboseEnabled: boolean = typeof process !== 'undefined' && process.env.RUSH_SDK_DEBUG === '1';\nconst terminal: Terminal = new Terminal(\n new ConsoleTerminalProvider({\n verboseEnabled\n })\n);\n\ntype RushLibModuleType = Record<string, unknown>;\ndeclare const global: NodeJS.Global &\n typeof globalThis & {\n ___rush___rushLibModule?: RushLibModuleType;\n ___rush___rushLibModuleFromEnvironment?: RushLibModuleType;\n ___rush___rushLibModuleFromInstallAndRunRush?: RushLibModuleType;\n };\n\nfunction _require<TResult>(moduleName: string): TResult {\n if (typeof __non_webpack_require__ === 'function') {\n // If this library has been bundled with Webpack, we need to call the real `require` function\n // that doesn't get turned into a `__webpack_require__` statement.\n // `__non_webpack_require__` is a Webpack macro that gets turned into a `require` statement\n // during bundling.\n return __non_webpack_require__(moduleName);\n } else {\n return require(moduleName);\n }\n}\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.\nlet rushLibModule: RushLibModuleType | undefined =\n global.___rush___rushLibModule ||\n global.___rush___rushLibModuleFromEnvironment ||\n global.___rush___rushLibModuleFromInstallAndRunRush;\nlet errorMessage: string = '';\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 (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 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 (rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModule = 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 (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 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 (rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModuleFromEnvironment = 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 use install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.\nif (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 const installRunNodeModuleFolder: string = path.join(\n monorepoRoot,\n `common/temp/install-run/@microsoft+rush@${rushVersion}`\n );\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 rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);\n } catch (e) {\n let installAndRunRushStderrContent: string = '';\n try {\n const installAndRunRushJSPath: string = path.join(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 installAndRuhRushProcess: SpawnSyncReturns<string> = Executable.spawnSync(\n 'node',\n [installAndRunRushJSPath, '--help'],\n {\n stdio: 'pipe'\n }\n );\n\n installAndRunRushStderrContent = installAndRuhRushProcess.stderr;\n if (installAndRuhRushProcess.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 rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);\n } catch (e) {\n console.error(`${installAndRunRushStderrContent}`);\n throw new Error(`The ${RUSH_LIB_NAME} package failed to load`);\n }\n }\n\n if (rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModuleFromInstallAndRunRush = rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} installed by install-run-rush`);\n }\n } catch (e) {\n // no-catch\n errorMessage = (e as Error).message;\n }\n}\n\nif (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 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 rushLibModule) {\n if (property !== 'default' && !exports.hasOwnProperty(property)) {\n const rushLibModuleForClosure: RushLibModuleType = 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\n/**\n * Require `@microsoft/rush-lib` under the specified folder path.\n */\nfunction requireRushLibUnderFolderPath(folderPath: string): RushLibModuleType {\n const rushLibModulePath: string = Import.resolveModule({\n modulePath: RUSH_LIB_NAME,\n baseFolderPath: folderPath\n });\n\n return _require(rushLibModulePath);\n}\n\n/**\n * Find the rush.json location and return the path, or undefined if a rush.json can't be found.\n *\n * @privateRemarks\n * Keep this in sync with `RushConfiguration.tryFindRushJsonLocation`.\n */\nfunction tryFindRushJsonLocation(startingFolder: string): string | undefined {\n let currentFolder: string = startingFolder;\n\n // Look upwards at parent folders until we find a folder containing rush.json\n for (let i: number = 0; i < 10; ++i) {\n const rushJsonFilename: string = path.join(currentFolder, 'rush.json');\n\n if (FileSystem.exists(rushJsonFilename)) {\n return rushJsonFilename;\n }\n\n const parentFolder: string = path.dirname(currentFolder);\n if (parentFolder === currentFolder) {\n break;\n }\n\n currentFolder = parentFolder;\n }\n\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceR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,QAAQ,EAAE;YACvC,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE;gBACH,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC,CAAC;KACJ;CACF;AAED;;GAEG;AACH,SAAgB,2BAA2B,CAAC,aAAqB;IAC/D,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,gBAAgB,OAAO,CAAC,IAAI,CAAC,OAAO,qDAAqD,CAC1F,CAAC;KACH;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 JsonObject,\n IPackageJson,\n PackageJsonLookup,\n Executable,\n Terminal,\n ConsoleTerminalProvider\n} from '@rushstack/node-core-library';\nimport type { SpawnSyncReturns } from 'child_process';\nimport {\n RUSH_LIB_NAME,\n RUSH_LIB_PATH_ENV_VAR_NAME,\n RushLibModuleType,\n _require,\n requireRushLibUnderFolderPath,\n tryFindRushJsonLocation,\n sdkContext\n} from './helpers';\n\nconst verboseEnabled: boolean = typeof process !== 'undefined' && process.env.RUSH_SDK_DEBUG === '1';\nconst terminal: Terminal = new Terminal(\n new ConsoleTerminalProvider({\n verboseEnabled\n })\n);\n\ndeclare const global: NodeJS.Global &\n typeof globalThis & {\n ___rush___rushLibModule?: RushLibModuleType;\n ___rush___rushLibModuleFromEnvironment?: 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___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 use 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 const installRunNodeModuleFolder: string = path.join(\n monorepoRoot,\n `common/temp/install-run/@microsoft+rush@${rushVersion}`\n );\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 (e) {\n let installAndRunRushStderrContent: string = '';\n try {\n const installAndRunRushJSPath: string = path.join(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 (e) {\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 } 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 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"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Type of {@link ISdkCallbackEvent.logMessage}
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IProgressBarCallbackLogMessage {
|
|
7
|
+
/**
|
|
8
|
+
* A status message to print in the log window, or `undefined` if there are
|
|
9
|
+
* no further messages. This string may contain newlines.
|
|
10
|
+
*/
|
|
11
|
+
text: string;
|
|
12
|
+
/**
|
|
13
|
+
* The type of message. More message types may be added in the future.
|
|
14
|
+
*/
|
|
15
|
+
kind: 'info' | 'debug';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Event options for {@link ILoadSdkAsyncOptions.onNotifyEvent}
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export interface ISdkCallbackEvent {
|
|
22
|
+
/**
|
|
23
|
+
* Allows the caller to display log information about the operation.
|
|
24
|
+
*/
|
|
25
|
+
logMessage: IProgressBarCallbackLogMessage | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Allows the caller to display a progress bar for long-running operations.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* If a long-running operation is required, then `progressPercent` will
|
|
31
|
+
* start at 0.0 and count upwards and finish at 100.0 if the operation completes
|
|
32
|
+
* successfully. If the long-running operation has not yet started, or
|
|
33
|
+
* is not required, then the value will be `undefined`.
|
|
34
|
+
*/
|
|
35
|
+
progressPercent: number | undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Type of {@link ILoadSdkAsyncOptions.onNotifyEvent}
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export type SdkNotifyEventCallback = (sdkEvent: ISdkCallbackEvent) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Options for {@link RushSdkLoader.loadAsync}
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export interface ILoadSdkAsyncOptions {
|
|
47
|
+
/**
|
|
48
|
+
* The folder to start from when searching for the Rush workspace configuration.
|
|
49
|
+
* If this folder does not contain a `rush.json` file, then each parent folder
|
|
50
|
+
* will be searched. If `rush.json` is not found, then the SDK fails to load.
|
|
51
|
+
*/
|
|
52
|
+
rushJsonSearchFolder?: string;
|
|
53
|
+
/**
|
|
54
|
+
* A cancellation token that the caller can use to prematurely abort the operation.
|
|
55
|
+
*/
|
|
56
|
+
abortSignal?: AbortSignal;
|
|
57
|
+
/**
|
|
58
|
+
* Allows the caller to monitor the progress of the operation.
|
|
59
|
+
*/
|
|
60
|
+
onNotifyEvent?: SdkNotifyEventCallback;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Exposes operations that control how the `@microsoft/rush-lib` engine is
|
|
64
|
+
* located and loaded.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export declare class RushSdkLoader {
|
|
68
|
+
/**
|
|
69
|
+
* Throws an "AbortError" exception if abortSignal.aborted is true.
|
|
70
|
+
*/
|
|
71
|
+
private static _checkForCancel;
|
|
72
|
+
/**
|
|
73
|
+
* Returns true if the Rush engine has already been loaded.
|
|
74
|
+
*/
|
|
75
|
+
static get isLoaded(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Manually load the Rush engine based on rush.json found for `rushJsonSearchFolder`.
|
|
78
|
+
* Throws an exception if {@link RushSdkLoader.isLoaded} is already `true`.
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* This API supports an callback that can be used display a progress bar,
|
|
82
|
+
* log of operations, and allow the operation to be canceled prematurely.
|
|
83
|
+
*/
|
|
84
|
+
static loadAsync(options?: ILoadSdkAsyncOptions): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";AAsBA;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,UAAU,EAAE,8BAA8B,GAAG,SAAS,CAAC;IAEvD;;;;;;;;OAQG;IACH,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAE3E;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;CACxC;AAED;;;;GAIG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAwB9B;;OAEG;IACH,WAAkB,QAAQ,IAAI,OAAO,CAEpC;IAED;;;;;;;OAOG;WACiB,SAAS,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CA+I7E"}
|
|
@@ -0,0 +1,189 @@
|
|
|
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.RushSdkLoader = void 0;
|
|
29
|
+
const path = __importStar(require("path"));
|
|
30
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
31
|
+
const helpers_1 = require("./helpers");
|
|
32
|
+
/**
|
|
33
|
+
* Exposes operations that control how the `@microsoft/rush-lib` engine is
|
|
34
|
+
* located and loaded.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
class RushSdkLoader {
|
|
38
|
+
/**
|
|
39
|
+
* Throws an "AbortError" exception if abortSignal.aborted is true.
|
|
40
|
+
*/
|
|
41
|
+
static _checkForCancel(abortSignal, onNotifyEvent, progressPercent) {
|
|
42
|
+
if (!abortSignal.aborted) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (onNotifyEvent) {
|
|
46
|
+
onNotifyEvent({
|
|
47
|
+
logMessage: {
|
|
48
|
+
kind: 'info',
|
|
49
|
+
text: `The operation was canceled`
|
|
50
|
+
},
|
|
51
|
+
progressPercent
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const error = new Error('The operation was canceled');
|
|
55
|
+
error.name = 'AbortError';
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns true if the Rush engine has already been loaded.
|
|
60
|
+
*/
|
|
61
|
+
static get isLoaded() {
|
|
62
|
+
return helpers_1.sdkContext.rushLibModule !== undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Manually load the Rush engine based on rush.json found for `rushJsonSearchFolder`.
|
|
66
|
+
* Throws an exception if {@link RushSdkLoader.isLoaded} is already `true`.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* This API supports an callback that can be used display a progress bar,
|
|
70
|
+
* log of operations, and allow the operation to be canceled prematurely.
|
|
71
|
+
*/
|
|
72
|
+
static async loadAsync(options) {
|
|
73
|
+
// SCENARIO 5: The rush-lib engine is loaded manually using rushSdkLoader.loadAsync().
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
if (!options) {
|
|
76
|
+
options = {};
|
|
77
|
+
}
|
|
78
|
+
if (RushSdkLoader.isLoaded) {
|
|
79
|
+
throw new Error('RushSdkLoader.loadAsync() failed because the Rush engine has already been loaded');
|
|
80
|
+
}
|
|
81
|
+
const onNotifyEvent = options.onNotifyEvent;
|
|
82
|
+
let progressPercent = undefined;
|
|
83
|
+
const abortSignal = (_a = options.abortSignal) !== null && _a !== void 0 ? _a : { aborted: false };
|
|
84
|
+
try {
|
|
85
|
+
const rushJsonSearchFolder = (_b = options.rushJsonSearchFolder) !== null && _b !== void 0 ? _b : process.cwd();
|
|
86
|
+
if (onNotifyEvent) {
|
|
87
|
+
onNotifyEvent({
|
|
88
|
+
logMessage: {
|
|
89
|
+
kind: 'debug',
|
|
90
|
+
text: `Searching for rush.json starting from: ` + rushJsonSearchFolder
|
|
91
|
+
},
|
|
92
|
+
progressPercent
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const rushJsonPath = (0, helpers_1.tryFindRushJsonLocation)(rushJsonSearchFolder);
|
|
96
|
+
if (!rushJsonPath) {
|
|
97
|
+
throw new Error('Unable to find rush.json in the specified folder or its parent folders:\n' +
|
|
98
|
+
`${rushJsonSearchFolder}\n`);
|
|
99
|
+
}
|
|
100
|
+
const monorepoRoot = path.dirname(rushJsonPath);
|
|
101
|
+
const rushJson = await node_core_library_1.JsonFile.loadAsync(rushJsonPath);
|
|
102
|
+
const { rushVersion } = rushJson;
|
|
103
|
+
const installRunNodeModuleFolder = path.join(monorepoRoot, `common/temp/install-run/@microsoft+rush@${rushVersion}`);
|
|
104
|
+
try {
|
|
105
|
+
// First, try to load the version of "rush-lib" that was installed by install-run-rush.js
|
|
106
|
+
if (onNotifyEvent) {
|
|
107
|
+
onNotifyEvent({
|
|
108
|
+
logMessage: {
|
|
109
|
+
kind: 'info',
|
|
110
|
+
text: `Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`
|
|
111
|
+
},
|
|
112
|
+
progressPercent
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
let installAndRunRushStderrContent = '';
|
|
119
|
+
try {
|
|
120
|
+
const installAndRunRushJSPath = path.join(monorepoRoot, 'common/scripts/install-run-rush.js');
|
|
121
|
+
if (onNotifyEvent) {
|
|
122
|
+
onNotifyEvent({
|
|
123
|
+
logMessage: {
|
|
124
|
+
kind: 'info',
|
|
125
|
+
text: 'The Rush engine has not been installed yet. Invoking install-run-rush.js...'
|
|
126
|
+
},
|
|
127
|
+
progressPercent
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
// Start the installation
|
|
131
|
+
progressPercent = 0;
|
|
132
|
+
const installAndRunRushProcess = node_core_library_1.Executable.spawnSync('node', [installAndRunRushJSPath, '--help'], {
|
|
133
|
+
stdio: 'pipe'
|
|
134
|
+
});
|
|
135
|
+
installAndRunRushStderrContent = installAndRunRushProcess.stderr;
|
|
136
|
+
if (installAndRunRushProcess.status !== 0) {
|
|
137
|
+
throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to install`);
|
|
138
|
+
}
|
|
139
|
+
RushSdkLoader._checkForCancel(abortSignal, onNotifyEvent, progressPercent);
|
|
140
|
+
// TODO: Implement incremental progress updates
|
|
141
|
+
progressPercent = 90;
|
|
142
|
+
// Retry to load "rush-lib" after install-run-rush run
|
|
143
|
+
if (onNotifyEvent) {
|
|
144
|
+
onNotifyEvent({
|
|
145
|
+
logMessage: {
|
|
146
|
+
kind: 'debug',
|
|
147
|
+
text: `Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush a second time`
|
|
148
|
+
},
|
|
149
|
+
progressPercent
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
|
|
153
|
+
progressPercent = 100;
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
console.error(`${installAndRunRushStderrContent}`);
|
|
157
|
+
throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to load`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
161
|
+
// to track which scenario is active and how it got initialized.
|
|
162
|
+
global.___rush___rushLibModuleFromInstallAndRunRush = helpers_1.sdkContext.rushLibModule;
|
|
163
|
+
if (onNotifyEvent) {
|
|
164
|
+
onNotifyEvent({
|
|
165
|
+
logMessage: {
|
|
166
|
+
kind: 'debug',
|
|
167
|
+
text: `Loaded ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`
|
|
168
|
+
},
|
|
169
|
+
progressPercent
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
if (onNotifyEvent) {
|
|
176
|
+
onNotifyEvent({
|
|
177
|
+
logMessage: {
|
|
178
|
+
kind: 'info',
|
|
179
|
+
text: 'The operation failed: ' + ((_c = e.message) !== null && _c !== void 0 ? _c : 'An unknown error occurred')
|
|
180
|
+
},
|
|
181
|
+
progressPercent
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
throw e;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.RushSdkLoader = RushSdkLoader;
|
|
189
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAE7B,oEAAgF;AAEhF,uCAMmB;AA6EnB;;;;GAIG;AACH,MAAa,aAAa;IACxB;;OAEG;IACK,MAAM,CAAC,eAAe,CAC5B,WAAwB,EACxB,aAAiD,EACjD,eAAmC;QAEnC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;YACxB,OAAO;SACR;QAED,IAAI,aAAa,EAAE;YACjB,aAAa,CAAC;gBACZ,UAAU,EAAE;oBACV,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,4BAA4B;iBACnC;gBACD,eAAe;aAChB,CAAC,CAAC;SACJ;QAED,MAAM,KAAK,GAAU,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC7D,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,QAAQ;QACxB,OAAO,oBAAU,CAAC,aAAa,KAAK,SAAS,CAAC;IAChD,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,OAA8B;QAC1D,sFAAsF;;Q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iBACvB;gBAAC,OAAO,CAAC,EAAE;oBACV,OAAO,CAAC,KAAK,CAAC,GAAG,8BAA8B,EAAE,CAAC,CAAC;oBACnD,MAAM,IAAI,KAAK,CAAC,OAAO,uBAAa,yBAAyB,CAAC,CAAC;iBAChE;aACF;YAED,IAAI,oBAAU,CAAC,aAAa,KAAK,SAAS,EAAE;gBAC1C,gEAAgE;gBAChE,MAAM,CAAC,4CAA4C,GAAG,oBAAU,CAAC,aAAa,CAAC;gBAC/E,IAAI,aAAa,EAAE;oBACjB,aAAa,CAAC;wBACZ,UAAU,EAAE;4BACV,IAAI,EAAE,OAAO;4BACb,IAAI,EAAE,UAAU,uBAAa,gCAAgC;yBAC9D;wBACD,eAAe;qBAChB,CAAC,CAAC;iBACJ;aACF;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,aAAa,EAAE;gBACjB,aAAa,CAAC;oBACZ,UAAU,EAAE;wBACV,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,wBAAwB,GAAG,CAAC,MAAA,CAAC,CAAC,OAAO,mCAAI,2BAA2B,CAAC;qBAC5E;oBACD,eAAe;iBAChB,CAAC,CAAC;aACJ;YACD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;CACF;AA1LD,sCA0LC","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 type { SpawnSyncReturns } from 'child_process';\nimport { JsonFile, JsonObject, Executable } from '@rushstack/node-core-library';\n\nimport {\n tryFindRushJsonLocation,\n RUSH_LIB_NAME,\n RushLibModuleType,\n requireRushLibUnderFolderPath,\n sdkContext\n} from './helpers';\n\ndeclare const global: NodeJS.Global &\n typeof globalThis & {\n ___rush___rushLibModule?: RushLibModuleType;\n ___rush___rushLibModuleFromEnvironment?: RushLibModuleType;\n ___rush___rushLibModuleFromInstallAndRunRush?: RushLibModuleType;\n };\n\n/**\n * Type of {@link ISdkCallbackEvent.logMessage}\n * @public\n */\nexport interface IProgressBarCallbackLogMessage {\n /**\n * A status message to print in the log window, or `undefined` if there are\n * no further messages. This string may contain newlines.\n */\n text: string;\n\n /**\n * The type of message. More message types may be added in the future.\n */\n kind: 'info' | 'debug';\n}\n\n/**\n * Event options for {@link ILoadSdkAsyncOptions.onNotifyEvent}\n * @public\n */\nexport interface ISdkCallbackEvent {\n /**\n * Allows the caller to display log information about the operation.\n */\n logMessage: IProgressBarCallbackLogMessage | undefined;\n\n /**\n * Allows the caller to display a progress bar for long-running operations.\n *\n * @remarks\n * If a long-running operation is required, then `progressPercent` will\n * start at 0.0 and count upwards and finish at 100.0 if the operation completes\n * successfully. If the long-running operation has not yet started, or\n * is not required, then the value will be `undefined`.\n */\n progressPercent: number | undefined;\n}\n\n/**\n * Type of {@link ILoadSdkAsyncOptions.onNotifyEvent}\n * @public\n */\nexport type SdkNotifyEventCallback = (sdkEvent: ISdkCallbackEvent) => void;\n\n/**\n * Options for {@link RushSdkLoader.loadAsync}\n * @public\n */\nexport interface ILoadSdkAsyncOptions {\n /**\n * The folder to start from when searching for the Rush workspace configuration.\n * If this folder does not contain a `rush.json` file, then each parent folder\n * will be searched. If `rush.json` is not found, then the SDK fails to load.\n */\n rushJsonSearchFolder?: string;\n\n /**\n * A cancellation token that the caller can use to prematurely abort the operation.\n */\n abortSignal?: AbortSignal;\n\n /**\n * Allows the caller to monitor the progress of the operation.\n */\n onNotifyEvent?: SdkNotifyEventCallback;\n}\n\n/**\n * Exposes operations that control how the `@microsoft/rush-lib` engine is\n * located and loaded.\n * @public\n */\nexport class RushSdkLoader {\n /**\n * Throws an \"AbortError\" exception if abortSignal.aborted is true.\n */\n private static _checkForCancel(\n abortSignal: AbortSignal,\n onNotifyEvent: SdkNotifyEventCallback | undefined,\n progressPercent: number | undefined\n ): void {\n if (!abortSignal.aborted) {\n return;\n }\n\n if (onNotifyEvent) {\n onNotifyEvent({\n logMessage: {\n kind: 'info',\n text: `The operation was canceled`\n },\n progressPercent\n });\n }\n\n const error: Error = new Error('The operation was canceled');\n error.name = 'AbortError';\n throw error;\n }\n\n /**\n * Returns true if the Rush engine has already been loaded.\n */\n public static get isLoaded(): boolean {\n return sdkContext.rushLibModule !== undefined;\n }\n\n /**\n * Manually load the Rush engine based on rush.json found for `rushJsonSearchFolder`.\n * Throws an exception if {@link RushSdkLoader.isLoaded} is already `true`.\n *\n * @remarks\n * This API supports an callback that can be used display a progress bar,\n * log of operations, and allow the operation to be canceled prematurely.\n */\n public static async loadAsync(options?: ILoadSdkAsyncOptions): Promise<void> {\n // SCENARIO 5: The rush-lib engine is loaded manually using rushSdkLoader.loadAsync().\n\n if (!options) {\n options = {};\n }\n\n if (RushSdkLoader.isLoaded) {\n throw new Error('RushSdkLoader.loadAsync() failed because the Rush engine has already been loaded');\n }\n\n const onNotifyEvent: SdkNotifyEventCallback | undefined = options.onNotifyEvent;\n let progressPercent: number | undefined = undefined;\n\n const abortSignal: AbortSignal = options.abortSignal ?? { aborted: false };\n\n try {\n const rushJsonSearchFolder: string = options.rushJsonSearchFolder ?? process.cwd();\n\n if (onNotifyEvent) {\n onNotifyEvent({\n logMessage: {\n kind: 'debug',\n text: `Searching for rush.json starting from: ` + rushJsonSearchFolder\n },\n progressPercent\n });\n }\n\n const rushJsonPath: string | undefined = tryFindRushJsonLocation(rushJsonSearchFolder);\n if (!rushJsonPath) {\n throw new Error(\n 'Unable to find rush.json in the specified folder or its parent folders:\\n' +\n `${rushJsonSearchFolder}\\n`\n );\n }\n const monorepoRoot: string = path.dirname(rushJsonPath);\n\n const rushJson: JsonObject = await JsonFile.loadAsync(rushJsonPath);\n const { rushVersion } = rushJson;\n\n const installRunNodeModuleFolder: string = path.join(\n monorepoRoot,\n `common/temp/install-run/@microsoft+rush@${rushVersion}`\n );\n\n try {\n // First, try to load the version of \"rush-lib\" that was installed by install-run-rush.js\n if (onNotifyEvent) {\n onNotifyEvent({\n logMessage: {\n kind: 'info',\n text: `Trying to load ${RUSH_LIB_NAME} installed by install-run-rush`\n },\n progressPercent\n });\n }\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);\n } catch (e) {\n let installAndRunRushStderrContent: string = '';\n try {\n const installAndRunRushJSPath: string = path.join(\n monorepoRoot,\n 'common/scripts/install-run-rush.js'\n );\n\n if (onNotifyEvent) {\n onNotifyEvent({\n logMessage: {\n kind: 'info',\n text: 'The Rush engine has not been installed yet. Invoking install-run-rush.js...'\n },\n progressPercent\n });\n }\n\n // Start the installation\n progressPercent = 0;\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 RushSdkLoader._checkForCancel(abortSignal, onNotifyEvent, progressPercent);\n\n // TODO: Implement incremental progress updates\n progressPercent = 90;\n\n // Retry to load \"rush-lib\" after install-run-rush run\n if (onNotifyEvent) {\n onNotifyEvent({\n logMessage: {\n kind: 'debug',\n text: `Trying to load ${RUSH_LIB_NAME} installed by install-run-rush a second time`\n },\n progressPercent\n });\n }\n\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);\n\n progressPercent = 100;\n } catch (e) {\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 if (onNotifyEvent) {\n onNotifyEvent({\n logMessage: {\n kind: 'debug',\n text: `Loaded ${RUSH_LIB_NAME} installed by install-run-rush`\n },\n progressPercent\n });\n }\n }\n } catch (e) {\n if (onNotifyEvent) {\n onNotifyEvent({\n logMessage: {\n kind: 'info',\n text: 'The operation failed: ' + (e.message ?? 'An unknown error occurred')\n },\n progressPercent\n });\n }\n throw e;\n }\n }\n}\n"]}
|