@rushstack/rush-sdk 5.130.3 → 5.131.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/rush-lib.d.ts +4 -119
  2. package/dist/tsdoc-metadata.json +1 -1
  3. package/lib/api/RushConfiguration.d.ts +1 -1
  4. package/lib/cli/actions/AlertAction.d.ts +10 -0
  5. package/lib/cli/actions/AlertAction.js +1 -0
  6. package/lib/index.d.ts +1 -1
  7. package/lib/utilities/RushAlerts.d.ts +54 -6
  8. package/lib-shim/index.js +1995 -119
  9. package/lib-shim/index.js.map +1 -1
  10. package/lib-shim/loader.js +299 -174
  11. package/lib-shim/loader.js.map +1 -1
  12. package/package.json +8 -7
  13. package/lib/logic/LookupByPath.d.ts +0 -120
  14. package/lib/logic/LookupByPath.js +0 -1
  15. package/lib-commonjs/generate-stubs.d.ts +0 -2
  16. package/lib-commonjs/generate-stubs.d.ts.map +0 -1
  17. package/lib-commonjs/generate-stubs.js +0 -84
  18. package/lib-commonjs/generate-stubs.js.map +0 -1
  19. package/lib-commonjs/helpers.d.ts +0 -21
  20. package/lib-commonjs/helpers.d.ts.map +0 -1
  21. package/lib-commonjs/helpers.js +0 -83
  22. package/lib-commonjs/helpers.js.map +0 -1
  23. package/lib-commonjs/index.d.ts +0 -5
  24. package/lib-commonjs/index.d.ts.map +0 -1
  25. package/lib-commonjs/index.js +0 -207
  26. package/lib-commonjs/index.js.map +0 -1
  27. package/lib-commonjs/loader.d.ts +0 -86
  28. package/lib-commonjs/loader.d.ts.map +0 -1
  29. package/lib-commonjs/loader.js +0 -192
  30. package/lib-commonjs/loader.js.map +0 -1
  31. package/lib-esnext/generate-stubs.js +0 -57
  32. package/lib-esnext/generate-stubs.js.map +0 -1
  33. package/lib-esnext/helpers.js +0 -54
  34. package/lib-esnext/helpers.js.map +0 -1
  35. package/lib-esnext/index.js +0 -180
  36. package/lib-esnext/index.js.map +0 -1
  37. package/lib-esnext/loader.js +0 -165
  38. package/lib-esnext/loader.js.map +0 -1
  39. package/lib-shim/commons.js +0 -2200
  40. package/lib-shim/commons.js.map +0 -1
@@ -1,2200 +0,0 @@
1
- "use strict";
2
- exports.id = "commons";
3
- exports.ids = ["commons"];
4
- exports.modules = {
5
-
6
- /***/ "../../common/temp/default/node_modules/.pnpm/true-case-path@2.2.1/node_modules/true-case-path/index.js":
7
- /*!**************************************************************************************************************!*\
8
- !*** ../../common/temp/default/node_modules/.pnpm/true-case-path@2.2.1/node_modules/true-case-path/index.js ***!
9
- \**************************************************************************************************************/
10
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11
-
12
-
13
-
14
- const { readdir: _readdir, readdirSync } = __webpack_require__(/*! fs */ "fs")
15
- const { platform } = __webpack_require__(/*! os */ "os")
16
- const { isAbsolute, normalize } = __webpack_require__(/*! path */ "path")
17
- const { promisify: pify } = __webpack_require__(/*! util */ "util")
18
-
19
- const readdir = pify(_readdir)
20
- const isWindows = platform() === 'win32'
21
- const delimiter = isWindows ? '\\' : '/'
22
-
23
- module.exports = {
24
- trueCasePath: _trueCasePath({ sync: false }),
25
- trueCasePathSync: _trueCasePath({ sync: true })
26
- }
27
-
28
- function getRelevantFilePathSegments(filePath) {
29
- return filePath.split(delimiter).filter((s) => s !== '')
30
- }
31
-
32
- function escapeString(str) {
33
- return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
34
- }
35
-
36
- function matchCaseInsensitive(fileOrDirectory, directoryContents, filePath) {
37
- const caseInsensitiveRegex = new RegExp(
38
- `^${escapeString(fileOrDirectory)}$`,
39
- 'i'
40
- )
41
- for (const file of directoryContents) {
42
- if (caseInsensitiveRegex.test(file)) return file
43
- }
44
- throw new Error(
45
- `[true-case-path]: Called with ${filePath}, but no matching file exists`
46
- )
47
- }
48
-
49
- function _trueCasePath({ sync }) {
50
- return (filePath, basePath) => {
51
- if (basePath) {
52
- if (!isAbsolute(basePath)) {
53
- throw new Error(
54
- `[true-case-path]: basePath argument must be absolute. Received "${basePath}"`
55
- )
56
- }
57
- basePath = normalize(basePath)
58
- }
59
- filePath = normalize(filePath)
60
- const segments = getRelevantFilePathSegments(filePath)
61
- if (isAbsolute(filePath)) {
62
- if (basePath) {
63
- throw new Error(
64
- '[true-case-path]: filePath must be relative when used with basePath'
65
- )
66
- }
67
- basePath = isWindows
68
- ? segments.shift().toUpperCase() // drive letter
69
- : ''
70
- } else if (!basePath) {
71
- basePath = process.cwd()
72
- }
73
- return sync
74
- ? iterateSync(basePath, filePath, segments)
75
- : iterateAsync(basePath, filePath, segments)
76
- }
77
- }
78
-
79
- function iterateSync(basePath, filePath, segments) {
80
- return segments.reduce(
81
- (realPath, fileOrDirectory) =>
82
- realPath +
83
- delimiter +
84
- matchCaseInsensitive(
85
- fileOrDirectory,
86
- readdirSync(realPath + delimiter),
87
- filePath
88
- ),
89
- basePath
90
- )
91
- }
92
-
93
- async function iterateAsync(basePath, filePath, segments) {
94
- return await segments.reduce(
95
- async (realPathPromise, fileOrDirectory) =>
96
- (await realPathPromise) +
97
- delimiter +
98
- matchCaseInsensitive(
99
- fileOrDirectory,
100
- await readdir((await realPathPromise) + delimiter),
101
- filePath
102
- ),
103
- basePath
104
- )
105
- }
106
-
107
-
108
- /***/ }),
109
-
110
- /***/ "../rush-lib/lib-esnext/api/EnvironmentConfiguration.js":
111
- /*!**************************************************************!*\
112
- !*** ../rush-lib/lib-esnext/api/EnvironmentConfiguration.js ***!
113
- \**************************************************************/
114
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
115
-
116
- __webpack_require__.r(__webpack_exports__);
117
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
118
- /* harmony export */ "EnvironmentConfiguration": () => (/* binding */ EnvironmentConfiguration),
119
- /* harmony export */ "EnvironmentVariableNames": () => (/* binding */ EnvironmentVariableNames)
120
- /* harmony export */ });
121
- /* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! os */ "os");
122
- /* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(os__WEBPACK_IMPORTED_MODULE_0__);
123
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ "path");
124
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
125
- /* harmony import */ var true_case_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! true-case-path */ "../../common/temp/default/node_modules/.pnpm/true-case-path@2.2.1/node_modules/true-case-path/index.js");
126
- /* harmony import */ var true_case_path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(true_case_path__WEBPACK_IMPORTED_MODULE_2__);
127
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
128
- // See LICENSE in the project root for license information.
129
-
130
-
131
-
132
- /**
133
- * Names of environment variables used by Rush.
134
- * @beta
135
- */
136
- // eslint-disable-next-line @typescript-eslint/typedef
137
- const EnvironmentVariableNames = {
138
- /**
139
- * This variable overrides the temporary folder used by Rush.
140
- * The default value is "common/temp" under the repository root.
141
- *
142
- * @remarks This environment variable is not compatible with workspace installs. If attempting
143
- * to move the PNPM store path, see the `RUSH_PNPM_STORE_PATH` environment variable.
144
- */
145
- RUSH_TEMP_FOLDER: 'RUSH_TEMP_FOLDER',
146
- /**
147
- * This variable overrides the version of Rush that will be installed by
148
- * the version selector. The default value is determined by the "rushVersion"
149
- * field from rush.json.
150
- */
151
- RUSH_PREVIEW_VERSION: 'RUSH_PREVIEW_VERSION',
152
- /**
153
- * If this variable is set to "1", Rush will not fail the build when running a version
154
- * of Node that does not match the criteria specified in the "nodeSupportedVersionRange"
155
- * field from rush.json.
156
- */
157
- RUSH_ALLOW_UNSUPPORTED_NODEJS: 'RUSH_ALLOW_UNSUPPORTED_NODEJS',
158
- /**
159
- * Setting this environment variable overrides the value of `allowWarningsInSuccessfulBuild`
160
- * in the `command-line.json` configuration file. Specify `1` to allow warnings in a successful build,
161
- * or `0` to disallow them. (See the comments in the command-line.json file for more information).
162
- */
163
- RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD: 'RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD',
164
- /**
165
- * Specifies the maximum number of concurrent processes to launch during a build.
166
- * For more information, see the command-line help for the `--parallelism` parameter for "rush build".
167
- */
168
- RUSH_PARALLELISM: 'RUSH_PARALLELISM',
169
- /**
170
- * If this variable is set to "1", Rush will create symlinks with absolute paths instead
171
- * of relative paths. This can be necessary when a repository is moved during a build or
172
- * if parts of a repository are moved into a sandbox.
173
- */
174
- RUSH_ABSOLUTE_SYMLINKS: 'RUSH_ABSOLUTE_SYMLINKS',
175
- /**
176
- * When using PNPM as the package manager, this variable can be used to configure the path that
177
- * PNPM will use as the store directory.
178
- *
179
- * If a relative path is used, then the store path will be resolved relative to the process's
180
- * current working directory. An absolute path is recommended.
181
- */
182
- RUSH_PNPM_STORE_PATH: 'RUSH_PNPM_STORE_PATH',
183
- /**
184
- * When using PNPM as the package manager, this variable can be used to control whether or not PNPM
185
- * validates the integrity of the PNPM store during installation. The value of this environment variable must be
186
- * `1` (for true) or `0` (for false). If not specified, defaults to the value in .npmrc.
187
- */
188
- RUSH_PNPM_VERIFY_STORE_INTEGRITY: 'RUSH_PNPM_VERIFY_STORE_INTEGRITY',
189
- /**
190
- * This environment variable can be used to specify the `--target-folder` parameter
191
- * for the "rush deploy" command.
192
- */
193
- RUSH_DEPLOY_TARGET_FOLDER: 'RUSH_DEPLOY_TARGET_FOLDER',
194
- /**
195
- * Overrides the location of the `~/.rush` global folder where Rush stores temporary files.
196
- *
197
- * @remarks
198
- *
199
- * Most of the temporary files created by Rush are stored separately for each monorepo working folder,
200
- * to avoid issues of concurrency and compatibility between tool versions. However, a small set
201
- * of files (e.g. installations of the `@microsoft/rush-lib` engine and the package manager) are stored
202
- * in a global folder to speed up installations. The default location is `~/.rush` on POSIX-like
203
- * operating systems or `C:\Users\YourName` on Windows.
204
- *
205
- * Use `RUSH_GLOBAL_FOLDER` to specify a different folder path. This is useful for example if a Windows
206
- * group policy forbids executing scripts installed in a user's home directory.
207
- *
208
- * POSIX is a registered trademark of the Institute of Electrical and Electronic Engineers, Inc.
209
- */
210
- RUSH_GLOBAL_FOLDER: 'RUSH_GLOBAL_FOLDER',
211
- /**
212
- * Provides a credential for a remote build cache, if configured. This credential overrides any cached credentials.
213
- *
214
- * @remarks
215
- * Setting this environment variable overrides whatever credential has been saved in the
216
- * local cloud cache credentials using `rush update-cloud-credentials`.
217
- *
218
- *
219
- * If Azure Blob Storage is used to store cache entries, this must be a SAS token serialized as query
220
- * parameters.
221
- *
222
- * For information on SAS tokens, see here: https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview
223
- */
224
- RUSH_BUILD_CACHE_CREDENTIAL: 'RUSH_BUILD_CACHE_CREDENTIAL',
225
- /**
226
- * Setting this environment variable overrides the value of `buildCacheEnabled` in the `build-cache.json`
227
- * configuration file.
228
- *
229
- * @remarks
230
- * Specify `1` to enable the build cache or `0` to disable it.
231
- *
232
- * If there is no build cache configured, then this environment variable is ignored.
233
- */
234
- RUSH_BUILD_CACHE_ENABLED: 'RUSH_BUILD_CACHE_ENABLED',
235
- /**
236
- * Overrides the value of `isCacheWriteAllowed` in the `build-cache.json` configuration file. The value of this
237
- * environment variable must be `1` (for true) or `0` (for false). If there is no build cache configured, then
238
- * this environment variable is ignored.
239
- */
240
- RUSH_BUILD_CACHE_WRITE_ALLOWED: 'RUSH_BUILD_CACHE_WRITE_ALLOWED',
241
- /**
242
- * Setting this environment variable opts into running with cobuilds. The context id should be the same across
243
- * multiple VMs, but changed when it is a new round of cobuilds.
244
- *
245
- * e.g. `Build.BuildNumber` in Azure DevOps Pipeline.
246
- *
247
- * @remarks
248
- * If there is no cobuild configured, then this environment variable is ignored.
249
- */
250
- RUSH_COBUILD_CONTEXT_ID: 'RUSH_COBUILD_CONTEXT_ID',
251
- /**
252
- * Explicitly specifies a name for each participating cobuild runner.
253
- *
254
- * Setting this environment variable opts into running with cobuilds.
255
- *
256
- * @remarks
257
- * This environment variable is optional, if it is not provided, a random id is used.
258
- *
259
- * If there is no cobuild configured, then this environment variable is ignored.
260
- */
261
- RUSH_COBUILD_RUNNER_ID: 'RUSH_COBUILD_RUNNER_ID',
262
- /**
263
- * If this variable is set to "1", When getting distributed builds, Rush will automatically handle the leaf project
264
- * with build cache "disabled" by writing to the cache in a special "log files only mode". This is useful when you
265
- * want to use Cobuilds to improve the performance in CI validations and the leaf projects have not enabled cache.
266
- */
267
- RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED: 'RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED',
268
- /**
269
- * Explicitly specifies the path for the Git binary that is invoked by certain Rush operations.
270
- */
271
- RUSH_GIT_BINARY_PATH: 'RUSH_GIT_BINARY_PATH',
272
- /**
273
- * Explicitly specifies the path for the `tar` binary that is invoked by certain Rush operations.
274
- */
275
- RUSH_TAR_BINARY_PATH: 'RUSH_TAR_BINARY_PATH',
276
- /**
277
- * Internal variable used by `rushx` when recursively invoking another `rushx` process, to avoid
278
- * nesting event hooks.
279
- */
280
- _RUSH_RECURSIVE_RUSHX_CALL: '_RUSH_RECURSIVE_RUSHX_CALL',
281
- /**
282
- * Internal variable that explicitly specifies the path for the version of `@microsoft/rush-lib` being executed.
283
- * Will be set upon loading Rush.
284
- */
285
- _RUSH_LIB_PATH: '_RUSH_LIB_PATH',
286
- /**
287
- * When Rush executes shell scripts, it sometimes changes the working directory to be a project folder or
288
- * the repository root folder. The original working directory (where the Rush command was invoked) is assigned
289
- * to the the child process's `RUSH_INVOKED_FOLDER` environment variable, in case it is needed by the script.
290
- *
291
- * @remarks
292
- * The `RUSH_INVOKED_FOLDER` variable is the same idea as the `INIT_CWD` variable that package managers
293
- * assign when they execute lifecycle scripts.
294
- */
295
- RUSH_INVOKED_FOLDER: 'RUSH_INVOKED_FOLDER',
296
- /**
297
- * When running a hook script, this environment variable communicates the original arguments
298
- * passed to the `rush` or `rushx` command.
299
- *
300
- * @remarks
301
- * Unlike `RUSH_INVOKED_FOLDER`, the `RUSH_INVOKED_ARGS` variable is only available for hook scripts.
302
- * Other lifecycle scripts should not make assumptions about Rush's command line syntax
303
- * if Rush did not explicitly pass along command-line parameters to their process.
304
- */
305
- RUSH_INVOKED_ARGS: 'RUSH_INVOKED_ARGS'
306
- };
307
- /**
308
- * Provides Rush-specific environment variable data. All Rush environment variables must start with "RUSH_". This class
309
- * is designed to be used by RushConfiguration.
310
- * @beta
311
- *
312
- * @remarks
313
- * Initialize will throw if any unknown parameters are present.
314
- */
315
- class EnvironmentConfiguration {
316
- /**
317
- * An override for the common/temp folder path.
318
- */
319
- static get rushTempFolderOverride() {
320
- EnvironmentConfiguration._ensureValidated();
321
- return EnvironmentConfiguration._rushTempFolderOverride;
322
- }
323
- /**
324
- * If "1", create symlinks with absolute paths instead of relative paths.
325
- * See {@link EnvironmentVariableNames.RUSH_ABSOLUTE_SYMLINKS}
326
- */
327
- static get absoluteSymlinks() {
328
- EnvironmentConfiguration._ensureValidated();
329
- return EnvironmentConfiguration._absoluteSymlinks;
330
- }
331
- /**
332
- * If this environment variable is set to "1", the Node.js version check will print a warning
333
- * instead of causing a hard error if the environment's Node.js version doesn't match the
334
- * version specifier in `rush.json`'s "nodeSupportedVersionRange" property.
335
- *
336
- * See {@link EnvironmentVariableNames.RUSH_ALLOW_UNSUPPORTED_NODEJS}.
337
- */
338
- static get allowUnsupportedNodeVersion() {
339
- EnvironmentConfiguration._ensureValidated();
340
- return EnvironmentConfiguration._allowUnsupportedNodeVersion;
341
- }
342
- /**
343
- * Setting this environment variable overrides the value of `allowWarningsInSuccessfulBuild`
344
- * in the `command-line.json` configuration file. Specify `1` to allow warnings in a successful build,
345
- * or `0` to disallow them. (See the comments in the command-line.json file for more information).
346
- */
347
- static get allowWarningsInSuccessfulBuild() {
348
- EnvironmentConfiguration._ensureValidated();
349
- return EnvironmentConfiguration._allowWarningsInSuccessfulBuild;
350
- }
351
- /**
352
- * An override for the PNPM store path, if `pnpmStore` configuration is set to 'path'
353
- * See {@link EnvironmentVariableNames.RUSH_PNPM_STORE_PATH}
354
- */
355
- static get pnpmStorePathOverride() {
356
- EnvironmentConfiguration._ensureValidated();
357
- return EnvironmentConfiguration._pnpmStorePathOverride;
358
- }
359
- /**
360
- * If specified, enables or disables integrity verification of the pnpm store during install.
361
- * See {@link EnvironmentVariableNames.RUSH_PNPM_VERIFY_STORE_INTEGRITY}
362
- */
363
- static get pnpmVerifyStoreIntegrity() {
364
- EnvironmentConfiguration._ensureValidated();
365
- return EnvironmentConfiguration._pnpmVerifyStoreIntegrity;
366
- }
367
- /**
368
- * Overrides the location of the `~/.rush` global folder where Rush stores temporary files.
369
- * See {@link EnvironmentVariableNames.RUSH_GLOBAL_FOLDER}
370
- */
371
- static get rushGlobalFolderOverride() {
372
- EnvironmentConfiguration._ensureValidated();
373
- return EnvironmentConfiguration._rushGlobalFolderOverride;
374
- }
375
- /**
376
- * Provides a credential for reading from and writing to a remote build cache, if configured.
377
- * See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_CREDENTIAL}
378
- */
379
- static get buildCacheCredential() {
380
- EnvironmentConfiguration._ensureValidated();
381
- return EnvironmentConfiguration._buildCacheCredential;
382
- }
383
- /**
384
- * If set, enables or disables the cloud build cache feature.
385
- * See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_ENABLED}
386
- */
387
- static get buildCacheEnabled() {
388
- EnvironmentConfiguration._ensureValidated();
389
- return EnvironmentConfiguration._buildCacheEnabled;
390
- }
391
- /**
392
- * If set, enables or disables writing to the cloud build cache.
393
- * See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_WRITE_ALLOWED}
394
- */
395
- static get buildCacheWriteAllowed() {
396
- EnvironmentConfiguration._ensureValidated();
397
- return EnvironmentConfiguration._buildCacheWriteAllowed;
398
- }
399
- /**
400
- * Provides a determined cobuild context id if configured
401
- * See {@link EnvironmentVariableNames.RUSH_COBUILD_CONTEXT_ID}
402
- */
403
- static get cobuildContextId() {
404
- EnvironmentConfiguration._ensureValidated();
405
- return EnvironmentConfiguration._cobuildContextId;
406
- }
407
- /**
408
- * Provides a determined cobuild runner id if configured
409
- * See {@link EnvironmentVariableNames.RUSH_COBUILD_RUNNER_ID}
410
- */
411
- static get cobuildRunnerId() {
412
- EnvironmentConfiguration._ensureValidated();
413
- return EnvironmentConfiguration._cobuildRunnerId;
414
- }
415
- /**
416
- * If set, enables or disables the cobuild leaf project log only feature.
417
- * See {@link EnvironmentVariableNames.RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED}
418
- */
419
- static get cobuildLeafProjectLogOnlyAllowed() {
420
- EnvironmentConfiguration._ensureValidated();
421
- return EnvironmentConfiguration._cobuildLeafProjectLogOnlyAllowed;
422
- }
423
- /**
424
- * Allows the git binary path to be explicitly provided.
425
- * See {@link EnvironmentVariableNames.RUSH_GIT_BINARY_PATH}
426
- */
427
- static get gitBinaryPath() {
428
- EnvironmentConfiguration._ensureValidated();
429
- return EnvironmentConfiguration._gitBinaryPath;
430
- }
431
- /**
432
- * Allows the tar binary path to be explicitly provided.
433
- * See {@link EnvironmentVariableNames.RUSH_TAR_BINARY_PATH}
434
- */
435
- static get tarBinaryPath() {
436
- EnvironmentConfiguration._ensureValidated();
437
- return EnvironmentConfiguration._tarBinaryPath;
438
- }
439
- /**
440
- * The front-end RushVersionSelector relies on `RUSH_GLOBAL_FOLDER`, so its value must be read before
441
- * `EnvironmentConfiguration` is initialized (and actually before the correct version of `EnvironmentConfiguration`
442
- * is even installed). Thus we need to read this environment variable differently from all the others.
443
- * @internal
444
- */
445
- static _getRushGlobalFolderOverride(processEnv) {
446
- const value = processEnv[EnvironmentVariableNames.RUSH_GLOBAL_FOLDER];
447
- if (value) {
448
- const normalizedValue = EnvironmentConfiguration._normalizeDeepestParentFolderPath(value);
449
- return normalizedValue;
450
- }
451
- }
452
- /**
453
- * Reads and validates environment variables. If any are invalid, this function will throw.
454
- */
455
- static validate(options = {}) {
456
- var _a, _b, _c;
457
- EnvironmentConfiguration.reset();
458
- const unknownEnvVariables = [];
459
- for (const envVarName in process.env) {
460
- if (process.env.hasOwnProperty(envVarName) && envVarName.match(/^RUSH_/i)) {
461
- const value = process.env[envVarName];
462
- // Environment variables are only case-insensitive on Windows
463
- const normalizedEnvVarName = os__WEBPACK_IMPORTED_MODULE_0__.platform() === 'win32' ? envVarName.toUpperCase() : envVarName;
464
- switch (normalizedEnvVarName) {
465
- case EnvironmentVariableNames.RUSH_TEMP_FOLDER: {
466
- EnvironmentConfiguration._rushTempFolderOverride =
467
- value && !options.doNotNormalizePaths
468
- ? EnvironmentConfiguration._normalizeDeepestParentFolderPath(value) || value
469
- : value;
470
- break;
471
- }
472
- case EnvironmentVariableNames.RUSH_ABSOLUTE_SYMLINKS: {
473
- EnvironmentConfiguration._absoluteSymlinks =
474
- (_a = EnvironmentConfiguration.parseBooleanEnvironmentVariable(EnvironmentVariableNames.RUSH_ABSOLUTE_SYMLINKS, value)) !== null && _a !== void 0 ? _a : false;
475
- break;
476
- }
477
- case EnvironmentVariableNames.RUSH_ALLOW_UNSUPPORTED_NODEJS: {
478
- if (value === 'true' || value === 'false') {
479
- // Small, undocumented acceptance of old "true" and "false" values for
480
- // users of RUSH_ALLOW_UNSUPPORTED_NODEJS in rush pre-v5.46.
481
- EnvironmentConfiguration._allowUnsupportedNodeVersion = value === 'true';
482
- }
483
- else {
484
- EnvironmentConfiguration._allowUnsupportedNodeVersion =
485
- (_b = EnvironmentConfiguration.parseBooleanEnvironmentVariable(EnvironmentVariableNames.RUSH_ALLOW_UNSUPPORTED_NODEJS, value)) !== null && _b !== void 0 ? _b : false;
486
- }
487
- break;
488
- }
489
- case EnvironmentVariableNames.RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD: {
490
- EnvironmentConfiguration._allowWarningsInSuccessfulBuild =
491
- (_c = EnvironmentConfiguration.parseBooleanEnvironmentVariable(EnvironmentVariableNames.RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD, value)) !== null && _c !== void 0 ? _c : false;
492
- break;
493
- }
494
- case EnvironmentVariableNames.RUSH_PNPM_STORE_PATH: {
495
- EnvironmentConfiguration._pnpmStorePathOverride =
496
- value && !options.doNotNormalizePaths
497
- ? EnvironmentConfiguration._normalizeDeepestParentFolderPath(value) || value
498
- : value;
499
- break;
500
- }
501
- case EnvironmentVariableNames.RUSH_PNPM_VERIFY_STORE_INTEGRITY: {
502
- EnvironmentConfiguration._pnpmVerifyStoreIntegrity =
503
- value === '1' ? true : value === '0' ? false : undefined;
504
- break;
505
- }
506
- case EnvironmentVariableNames.RUSH_GLOBAL_FOLDER: {
507
- // Handled specially below
508
- break;
509
- }
510
- case EnvironmentVariableNames.RUSH_BUILD_CACHE_CREDENTIAL: {
511
- EnvironmentConfiguration._buildCacheCredential = value;
512
- break;
513
- }
514
- case EnvironmentVariableNames.RUSH_BUILD_CACHE_ENABLED: {
515
- EnvironmentConfiguration._buildCacheEnabled =
516
- EnvironmentConfiguration.parseBooleanEnvironmentVariable(EnvironmentVariableNames.RUSH_BUILD_CACHE_ENABLED, value);
517
- break;
518
- }
519
- case EnvironmentVariableNames.RUSH_BUILD_CACHE_WRITE_ALLOWED: {
520
- EnvironmentConfiguration._buildCacheWriteAllowed =
521
- EnvironmentConfiguration.parseBooleanEnvironmentVariable(EnvironmentVariableNames.RUSH_BUILD_CACHE_WRITE_ALLOWED, value);
522
- break;
523
- }
524
- case EnvironmentVariableNames.RUSH_COBUILD_CONTEXT_ID: {
525
- EnvironmentConfiguration._cobuildContextId = value;
526
- break;
527
- }
528
- case EnvironmentVariableNames.RUSH_COBUILD_RUNNER_ID: {
529
- EnvironmentConfiguration._cobuildRunnerId = value;
530
- break;
531
- }
532
- case EnvironmentVariableNames.RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED: {
533
- EnvironmentConfiguration._cobuildLeafProjectLogOnlyAllowed =
534
- EnvironmentConfiguration.parseBooleanEnvironmentVariable(EnvironmentVariableNames.RUSH_COBUILD_LEAF_PROJECT_LOG_ONLY_ALLOWED, value);
535
- break;
536
- }
537
- case EnvironmentVariableNames.RUSH_GIT_BINARY_PATH: {
538
- EnvironmentConfiguration._gitBinaryPath = value;
539
- break;
540
- }
541
- case EnvironmentVariableNames.RUSH_TAR_BINARY_PATH: {
542
- EnvironmentConfiguration._tarBinaryPath = value;
543
- break;
544
- }
545
- case EnvironmentVariableNames.RUSH_PARALLELISM:
546
- case EnvironmentVariableNames.RUSH_PREVIEW_VERSION:
547
- case EnvironmentVariableNames.RUSH_DEPLOY_TARGET_FOLDER:
548
- // Handled by @microsoft/rush front end
549
- break;
550
- case EnvironmentVariableNames.RUSH_INVOKED_FOLDER:
551
- case EnvironmentVariableNames.RUSH_INVOKED_ARGS:
552
- case EnvironmentVariableNames._RUSH_LIB_PATH:
553
- // Assigned by Rush itself
554
- break;
555
- case EnvironmentVariableNames._RUSH_RECURSIVE_RUSHX_CALL:
556
- // Assigned/read internally by RushXCommandLine
557
- break;
558
- default:
559
- unknownEnvVariables.push(envVarName);
560
- break;
561
- }
562
- }
563
- }
564
- // This strictness intends to catch mistakes where variables are misspelled or not used correctly.
565
- if (unknownEnvVariables.length > 0) {
566
- throw new Error('The following environment variables were found with the "RUSH_" prefix, but they are not ' +
567
- `recognized by this version of Rush: ${unknownEnvVariables.join(', ')}`);
568
- }
569
- // See doc comment for EnvironmentConfiguration._getRushGlobalFolderOverride().
570
- EnvironmentConfiguration._rushGlobalFolderOverride =
571
- EnvironmentConfiguration._getRushGlobalFolderOverride(process.env);
572
- EnvironmentConfiguration._hasBeenValidated = true;
573
- }
574
- /**
575
- * Resets EnvironmentConfiguration into an un-initialized state.
576
- */
577
- static reset() {
578
- EnvironmentConfiguration._rushTempFolderOverride = undefined;
579
- EnvironmentConfiguration._hasBeenValidated = false;
580
- }
581
- static _ensureValidated() {
582
- if (!EnvironmentConfiguration._hasBeenValidated) {
583
- EnvironmentConfiguration.validate();
584
- }
585
- }
586
- static parseBooleanEnvironmentVariable(name, value) {
587
- if (value === '' || value === undefined) {
588
- return undefined;
589
- }
590
- else if (value === '0') {
591
- return false;
592
- }
593
- else if (value === '1') {
594
- return true;
595
- }
596
- else {
597
- throw new Error(`Invalid value "${value}" for the environment variable ${name}. Valid choices are 0 or 1.`);
598
- }
599
- }
600
- /**
601
- * Given a path to a folder (that may or may not exist), normalize the path, including casing,
602
- * to the first existing parent folder in the path.
603
- *
604
- * If no existing path can be found (for example, if the root is a volume that doesn't exist),
605
- * this function returns undefined.
606
- *
607
- * @example
608
- * If the following path exists on disk: `C:\Folder1\folder2\`
609
- * _normalizeFirstExistingFolderPath('c:\\folder1\\folder2\\temp\\subfolder')
610
- * returns 'C:\\Folder1\\folder2\\temp\\subfolder'
611
- */
612
- static _normalizeDeepestParentFolderPath(folderPath) {
613
- folderPath = path__WEBPACK_IMPORTED_MODULE_1__.normalize(folderPath);
614
- const endsWithSlash = folderPath.charAt(folderPath.length - 1) === path__WEBPACK_IMPORTED_MODULE_1__.sep;
615
- const parsedPath = path__WEBPACK_IMPORTED_MODULE_1__.parse(folderPath);
616
- const pathRoot = parsedPath.root;
617
- const pathWithoutRoot = parsedPath.dir.substr(pathRoot.length);
618
- const pathParts = [...pathWithoutRoot.split(path__WEBPACK_IMPORTED_MODULE_1__.sep), parsedPath.name].filter((part) => !!part);
619
- // Starting with all path sections, and eliminating one from the end during each loop iteration,
620
- // run trueCasePathSync. If trueCasePathSync returns without exception, we've found a subset
621
- // of the path that exists and we've now gotten the correct casing.
622
- //
623
- // Once we've found a parent folder that exists, append the path sections that didn't exist.
624
- for (let i = pathParts.length; i >= 0; i--) {
625
- const constructedPath = path__WEBPACK_IMPORTED_MODULE_1__.join(pathRoot, ...pathParts.slice(0, i));
626
- try {
627
- const normalizedConstructedPath = (0,true_case_path__WEBPACK_IMPORTED_MODULE_2__.trueCasePathSync)(constructedPath);
628
- const result = path__WEBPACK_IMPORTED_MODULE_1__.join(normalizedConstructedPath, ...pathParts.slice(i));
629
- if (endsWithSlash) {
630
- return `${result}${path__WEBPACK_IMPORTED_MODULE_1__.sep}`;
631
- }
632
- else {
633
- return result;
634
- }
635
- }
636
- catch (e) {
637
- // This path doesn't exist, continue to the next subpath
638
- }
639
- }
640
- return undefined;
641
- }
642
- }
643
- EnvironmentConfiguration._hasBeenValidated = false;
644
- EnvironmentConfiguration._absoluteSymlinks = false;
645
- EnvironmentConfiguration._allowUnsupportedNodeVersion = false;
646
- EnvironmentConfiguration._allowWarningsInSuccessfulBuild = false;
647
- //# sourceMappingURL=EnvironmentConfiguration.js.map
648
-
649
- /***/ }),
650
-
651
- /***/ "../rush-lib/lib-esnext/api/RushGlobalFolder.js":
652
- /*!******************************************************!*\
653
- !*** ../rush-lib/lib-esnext/api/RushGlobalFolder.js ***!
654
- \******************************************************/
655
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
656
-
657
- __webpack_require__.r(__webpack_exports__);
658
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
659
- /* harmony export */ "RushGlobalFolder": () => (/* binding */ RushGlobalFolder)
660
- /* harmony export */ });
661
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path */ "path");
662
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
663
- /* harmony import */ var _utilities_Utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utilities/Utilities */ "../rush-lib/lib-esnext/utilities/Utilities.js");
664
- /* harmony import */ var _EnvironmentConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EnvironmentConfiguration */ "../rush-lib/lib-esnext/api/EnvironmentConfiguration.js");
665
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
666
- // See LICENSE in the project root for license information.
667
-
668
-
669
-
670
- /**
671
- * This class provides global folders that are used for rush's internal install locations.
672
- *
673
- * @internal
674
- */
675
- class RushGlobalFolder {
676
- constructor() {
677
- // Because RushGlobalFolder is used by the front-end VersionSelector before EnvironmentConfiguration
678
- // is initialized, we need to read it using a special internal API.
679
- const rushGlobalFolderOverride = _EnvironmentConfiguration__WEBPACK_IMPORTED_MODULE_1__.EnvironmentConfiguration._getRushGlobalFolderOverride(process.env);
680
- if (rushGlobalFolderOverride !== undefined) {
681
- this.path = rushGlobalFolderOverride;
682
- }
683
- else {
684
- this.path = path__WEBPACK_IMPORTED_MODULE_0__.join(_utilities_Utilities__WEBPACK_IMPORTED_MODULE_2__.Utilities.getHomeFolder(), '.rush');
685
- }
686
- const normalizedNodeVersion = process.version.match(/^[a-z0-9\-\.]+$/i)
687
- ? process.version
688
- : 'unknown-version';
689
- this.nodeSpecificPath = path__WEBPACK_IMPORTED_MODULE_0__.join(this.path, `node-${normalizedNodeVersion}`);
690
- }
691
- }
692
- //# sourceMappingURL=RushGlobalFolder.js.map
693
-
694
- /***/ }),
695
-
696
- /***/ "../rush-lib/lib-esnext/logic/RushConstants.js":
697
- /*!*****************************************************!*\
698
- !*** ../rush-lib/lib-esnext/logic/RushConstants.js ***!
699
- \*****************************************************/
700
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
701
-
702
- __webpack_require__.r(__webpack_exports__);
703
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
704
- /* harmony export */ "RushConstants": () => (/* binding */ RushConstants)
705
- /* harmony export */ });
706
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
707
- // See LICENSE in the project root for license information.
708
- /**
709
- * Constants used by the Rush tool.
710
- * @beta
711
- *
712
- * @remarks
713
- *
714
- * These are NOT part of the public API surface for rush-lib.
715
- * The rationale is that we don't want people implementing custom parsers for
716
- * the Rush config files; instead, they should rely on the official APIs from rush-lib.
717
- */
718
- class RushConstants {
719
- }
720
- /**
721
- * The filename ("rush.json") for the root-level configuration file.
722
- */
723
- RushConstants.rushJsonFilename = 'rush.json';
724
- /**
725
- * The filename ("browser-approved-packages.json") for an optional policy configuration file
726
- * that stores a list of NPM packages that have been approved for usage by Rush projects.
727
- * This is part of a pair of config files, one for projects that run in a web browser
728
- * (e.g. whose approval criteria mostly focuses on licensing and code size), and one for everywhere else
729
- * (e.g. tooling projects whose approval criteria mostly focuses on avoiding node_modules sprawl).
730
- */
731
- RushConstants.browserApprovedPackagesFilename = 'browser-approved-packages.json';
732
- /**
733
- * The folder name ("changes") where change files will be stored.
734
- */
735
- RushConstants.changeFilesFolderName = 'changes';
736
- /**
737
- * The filename ("nonbrowser-approved-packages.json") for an optional policy configuration file
738
- * that stores a list of NPM packages that have been approved for usage by Rush projects.
739
- * This is part of a pair of config files, one for projects that run in a web browser
740
- * (e.g. whose approval criteria mostly focuses on licensing and code size), and one for everywhere else
741
- * (e.g. tooling projects whose approval criteria mostly focuses on avoiding node_modules sprawl).
742
- */
743
- RushConstants.nonbrowserApprovedPackagesFilename = 'nonbrowser-approved-packages.json';
744
- /**
745
- * The folder name ("common") where Rush's common data will be stored.
746
- */
747
- RushConstants.commonFolderName = 'common';
748
- /**
749
- * The NPM scope ("\@rush-temp") that is used for Rush's temporary projects.
750
- */
751
- RushConstants.rushTempNpmScope = '@rush-temp';
752
- /**
753
- * The folder name ("temp") under the common folder, or under the .rush folder in each project's directory where
754
- * temporary files will be stored.
755
- * Example: `C:\MyRepo\common\temp`
756
- */
757
- RushConstants.rushTempFolderName = 'temp';
758
- /**
759
- * The folder name ("projects") where temporary projects will be stored.
760
- * Example: `C:\MyRepo\common\temp\projects`
761
- */
762
- RushConstants.rushTempProjectsFolderName = 'projects';
763
- /**
764
- * The filename ("npm-shrinkwrap.json") used to store an installation plan for the NPM package manger.
765
- */
766
- RushConstants.npmShrinkwrapFilename = 'npm-shrinkwrap.json';
767
- /**
768
- * Number of installation attempts
769
- */
770
- RushConstants.defaultMaxInstallAttempts = 1;
771
- /**
772
- * The filename ("pnpm-lock.yaml") used to store an installation plan for the PNPM package manger
773
- * (PNPM version 3.x and later).
774
- */
775
- RushConstants.pnpmV3ShrinkwrapFilename = 'pnpm-lock.yaml';
776
- /**
777
- * The filename ("pnpmfile.js") used to add custom configuration to PNPM (PNPM version 1.x and later).
778
- */
779
- RushConstants.pnpmfileV1Filename = 'pnpmfile.js';
780
- /**
781
- * The filename (".pnpmfile.cjs") used to add custom configuration to PNPM (PNPM version 6.x and later).
782
- */
783
- RushConstants.pnpmfileV6Filename = '.pnpmfile.cjs';
784
- /**
785
- * The filename (".modules.yaml") used by pnpm to specify configurations in the node_modules directory
786
- */
787
- RushConstants.pnpmModulesFilename = '.modules.yaml';
788
- /**
789
- * The filename ("global-pnpmfile.cjs") used to add custom configuration to subspaces
790
- */
791
- RushConstants.pnpmfileGlobalFilename = 'global-pnpmfile.cjs';
792
- /**
793
- * The folder name used to store patch files for pnpm
794
- * Example: `C:\MyRepo\common\config\pnpm-patches`
795
- * Example: `C:\MyRepo\common\temp\patches`
796
- */
797
- RushConstants.pnpmPatchesFolderName = 'patches';
798
- /**
799
- * The folder name under `/common/temp` used to store checked-in patches.
800
- * Example: `C:\MyRepo\common\pnpm-patches`
801
- */
802
- RushConstants.pnpmPatchesCommonFolderName = `pnpm-${RushConstants.pnpmPatchesFolderName}`;
803
- /**
804
- * The filename ("shrinkwrap.yaml") used to store state for pnpm
805
- */
806
- RushConstants.yarnShrinkwrapFilename = 'yarn.lock';
807
- /**
808
- * The folder name ("node_modules") where NPM installs its packages.
809
- */
810
- RushConstants.nodeModulesFolderName = 'node_modules';
811
- /**
812
- * The filename ("pinned-versions.json") for an old configuration file that
813
- * that is no longer supported.
814
- *
815
- * @deprecated This feature has been superseded by the "preferredVersions" setting
816
- * in common-versions.json
817
- */
818
- // NOTE: Although this is marked as "deprecated", we will probably never retire it,
819
- // since we always want to report the warning when someone upgrades an old repo.
820
- RushConstants.pinnedVersionsFilename = 'pinned-versions.json';
821
- /**
822
- * The filename ("common-versions.json") for an optional configuration file
823
- * that stores dependency version information that affects all projects in the repo.
824
- * This configuration file should go in the "common/config/rush" folder.
825
- */
826
- RushConstants.commonVersionsFilename = 'common-versions.json';
827
- /**
828
- * The filename ("repo-state.json") for a file used by Rush to
829
- * store the state of various features as they stand in the repo.
830
- */
831
- RushConstants.repoStateFilename = 'repo-state.json';
832
- /**
833
- * The filename ("custom-tips.json") for the file used by Rush to
834
- * print user-customized messages.
835
- * This configuration file should go in the "common/config/rush" folder.
836
- */
837
- RushConstants.customTipsFilename = 'custom-tips.json';
838
- /**
839
- * The name of the per-project folder where project-specific Rush files are stored. For example,
840
- * the package-deps files, which are used by commands to determine if a particular project needs to be rebuilt.
841
- */
842
- RushConstants.projectRushFolderName = '.rush';
843
- /**
844
- * Custom command line configuration file, which is used by rush for implementing
845
- * custom command and options.
846
- */
847
- RushConstants.commandLineFilename = 'command-line.json';
848
- RushConstants.versionPoliciesFilename = 'version-policies.json';
849
- /**
850
- * Experiments configuration file.
851
- */
852
- RushConstants.experimentsFilename = 'experiments.json';
853
- /**
854
- * Pnpm configuration file
855
- */
856
- RushConstants.pnpmConfigFilename = 'pnpm-config.json';
857
- /**
858
- * Rush plugins configuration file name.
859
- */
860
- RushConstants.rushPluginsConfigFilename = 'rush-plugins.json';
861
- /**
862
- * Rush plugin manifest file name.
863
- */
864
- RushConstants.rushPluginManifestFilename = 'rush-plugin-manifest.json';
865
- /**
866
- * The artifactory.json configuration file name.
867
- */
868
- RushConstants.artifactoryFilename = 'artifactory.json';
869
- /**
870
- * The subspaces.json configuration file name
871
- */
872
- RushConstants.subspacesConfigFilename = 'subspaces.json';
873
- /**
874
- * The name of the default subspace if one isn't specified but subspaces is enabled.
875
- */
876
- RushConstants.defaultSubspaceName = 'default';
877
- /**
878
- * Build cache configuration file.
879
- */
880
- RushConstants.buildCacheFilename = 'build-cache.json';
881
- /**
882
- * Build cache version number, incremented when the logic to create cache entries changes.
883
- * Changing this ensures that cache entries generated by an old version will no longer register as a cache hit.
884
- */
885
- RushConstants.buildCacheVersion = 1;
886
- /**
887
- * Cobuild configuration file.
888
- */
889
- RushConstants.cobuildFilename = 'cobuild.json';
890
- /**
891
- * Per-project configuration filename.
892
- */
893
- RushConstants.rushProjectConfigFilename = 'rush-project.json';
894
- /**
895
- * The URL ("http://rushjs.io") for the Rush web site.
896
- */
897
- RushConstants.rushWebSiteUrl = 'https://rushjs.io';
898
- /**
899
- * The name of the NPM package for the Rush tool ("\@microsoft/rush").
900
- */
901
- RushConstants.rushPackageName = '@microsoft/rush';
902
- /**
903
- * The folder name ("rush-recycler") where Rush moves large folder trees
904
- * before asynchronously deleting them.
905
- */
906
- RushConstants.rushRecyclerFolderName = 'rush-recycler';
907
- /**
908
- * The name of the file to drop in project-folder/.rush/temp/ containing a listing of the project's direct
909
- * and indirect dependencies. This is used to detect if a project's dependencies have changed since the last build.
910
- */
911
- RushConstants.projectShrinkwrapFilename = 'shrinkwrap-deps.json';
912
- /**
913
- * The value of the "commandKind" property for a bulk command in command-line.json
914
- */
915
- RushConstants.bulkCommandKind = 'bulk';
916
- /**
917
- * The value of the "commandKind" property for a global command in command-line.json
918
- */
919
- RushConstants.globalCommandKind = 'global';
920
- /**
921
- * The value of the "commandKind" property for a phased command in command-line.json
922
- */
923
- RushConstants.phasedCommandKind = 'phased';
924
- /**
925
- * The name of the incremental build command.
926
- */
927
- RushConstants.buildCommandName = 'build';
928
- /**
929
- * The name of the non-incremental build command.
930
- */
931
- RushConstants.rebuildCommandName = 'rebuild';
932
- RushConstants.updateCloudCredentialsCommandName = 'update-cloud-credentials';
933
- /**
934
- * When a hash generated that contains multiple input segments, this character may be used
935
- * to separate them to avoid issues like
936
- * crypto.createHash('sha1').update('a').update('bc').digest('hex') === crypto.createHash('sha1').update('ab').update('c').digest('hex')
937
- */
938
- RushConstants.hashDelimiter = '|';
939
- /**
940
- * The name of the per-user Rush configuration data folder.
941
- */
942
- RushConstants.rushUserConfigurationFolderName = '.rush-user';
943
- /**
944
- * The name of the project `rush-logs` folder.
945
- */
946
- RushConstants.rushLogsFolderName = 'rush-logs';
947
- /**
948
- * The expected prefix for phase names in "common/config/rush/command-line.json"
949
- */
950
- RushConstants.phaseNamePrefix = '_phase:';
951
- /**
952
- * The default debounce value for Rush multi-project watch mode. When watching, controls
953
- * how long to wait after the last encountered file system event before execution. If another
954
- * file system event occurs in this interval, the timeout will reset.
955
- */
956
- RushConstants.defaultWatchDebounceMs = 1000;
957
- /**
958
- * The name of the parameter that can be used to bypass policies.
959
- */
960
- RushConstants.bypassPolicyFlagLongName = '--bypass-policy';
961
- /**
962
- * Merge Queue ignore configuration file.
963
- */
964
- RushConstants.mergeQueueIgnoreFileName = '.mergequeueignore';
965
- /**
966
- * The filename ("project-impact-graph.yaml") for the project impact graph file.
967
- */
968
- RushConstants.projectImpactGraphFilename = 'project-impact-graph.yaml';
969
- /**
970
- * The filename for the last link flag
971
- */
972
- RushConstants.lastLinkFlagFilename = 'last-link';
973
- /**
974
- * The filename for the Rush alerts config file.
975
- */
976
- RushConstants.rushAlertsConfigFilename = 'rush-alerts.json';
977
- /**
978
- * The filename for the machine-generated file that tracks state for Rush alerts.
979
- */
980
- RushConstants.rushAlertsStateFilename = 'rush-alerts-state.json';
981
- //# sourceMappingURL=RushConstants.js.map
982
-
983
- /***/ }),
984
-
985
- /***/ "../rush-lib/lib-esnext/utilities/Utilities.js":
986
- /*!*****************************************************!*\
987
- !*** ../rush-lib/lib-esnext/utilities/Utilities.js ***!
988
- \*****************************************************/
989
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
990
-
991
- __webpack_require__.r(__webpack_exports__);
992
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
993
- /* harmony export */ "UNINITIALIZED": () => (/* binding */ UNINITIALIZED),
994
- /* harmony export */ "Utilities": () => (/* binding */ Utilities)
995
- /* harmony export */ });
996
- /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! child_process */ "child_process");
997
- /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_0__);
998
- /* harmony import */ var os__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! os */ "os");
999
- /* harmony import */ var os__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(os__WEBPACK_IMPORTED_MODULE_1__);
1000
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! path */ "path");
1001
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
1002
- /* harmony import */ var perf_hooks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! perf_hooks */ "perf_hooks");
1003
- /* harmony import */ var perf_hooks__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(perf_hooks__WEBPACK_IMPORTED_MODULE_3__);
1004
- /* harmony import */ var stream__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! stream */ "stream");
1005
- /* harmony import */ var stream__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(stream__WEBPACK_IMPORTED_MODULE_4__);
1006
- /* harmony import */ var _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @rushstack/node-core-library */ "@rushstack/node-core-library");
1007
- /* harmony import */ var _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__);
1008
- /* harmony import */ var _npmrcUtilities__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./npmrcUtilities */ "../rush-lib/lib-esnext/utilities/npmrcUtilities.js");
1009
- /* harmony import */ var _api_EnvironmentConfiguration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../api/EnvironmentConfiguration */ "../rush-lib/lib-esnext/api/EnvironmentConfiguration.js");
1010
- /* harmony import */ var _logic_RushConstants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../logic/RushConstants */ "../rush-lib/lib-esnext/logic/RushConstants.js");
1011
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
1012
- // See LICENSE in the project root for license information.
1013
-
1014
-
1015
-
1016
-
1017
-
1018
-
1019
-
1020
-
1021
-
1022
- // eslint-disable-next-line @typescript-eslint/no-redeclare
1023
- const UNINITIALIZED = 'UNINITIALIZED';
1024
- class Utilities {
1025
- /**
1026
- * Get the user's home directory. On windows this looks something like "C:\users\username\" and on UNIX
1027
- * this looks something like "/home/username/"
1028
- */
1029
- static getHomeFolder() {
1030
- const unresolvedUserFolder = process.env[process.platform === 'win32' ? 'USERPROFILE' : 'HOME'];
1031
- const dirError = "Unable to determine the current user's home directory";
1032
- if (unresolvedUserFolder === undefined) {
1033
- throw new Error(dirError);
1034
- }
1035
- const homeFolder = path__WEBPACK_IMPORTED_MODULE_2__.resolve(unresolvedUserFolder);
1036
- if (!_rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.exists(homeFolder)) {
1037
- throw new Error(dirError);
1038
- }
1039
- return homeFolder;
1040
- }
1041
- /**
1042
- * Node.js equivalent of performance.now().
1043
- */
1044
- static getTimeInMs() {
1045
- return perf_hooks__WEBPACK_IMPORTED_MODULE_3__.performance.now();
1046
- }
1047
- /**
1048
- * Retries a function until a timeout is reached. The function is expected to throw if it failed and
1049
- * should be retried.
1050
- */
1051
- static retryUntilTimeout(fn, maxWaitTimeMs, getTimeoutError, fnName) {
1052
- const startTime = Utilities.getTimeInMs();
1053
- let looped = false;
1054
- let result;
1055
- for (;;) {
1056
- try {
1057
- result = fn();
1058
- break;
1059
- }
1060
- catch (e) {
1061
- looped = true;
1062
- const currentTime = Utilities.getTimeInMs();
1063
- if (currentTime - startTime > maxWaitTimeMs) {
1064
- throw getTimeoutError(e);
1065
- }
1066
- }
1067
- }
1068
- if (looped) {
1069
- const currentTime = Utilities.getTimeInMs();
1070
- const totalSeconds = ((currentTime - startTime) / 1000.0).toFixed(2);
1071
- // This logging statement isn't meaningful to the end-user. `fnName` should be updated
1072
- // to something like `operationDescription`
1073
- // eslint-disable-next-line no-console
1074
- console.log(`${fnName}() stalled for ${totalSeconds} seconds`);
1075
- }
1076
- return result;
1077
- }
1078
- /**
1079
- * Creates the specified folder by calling FileSystem.ensureFolder(), but using a
1080
- * retry loop to recover from temporary locks that may be held by other processes.
1081
- * If the folder already exists, no error occurs.
1082
- */
1083
- static createFolderWithRetry(folderName) {
1084
- // Note: If a file exists with the same name, then we fall through and report
1085
- // an error.
1086
- if (Utilities.directoryExists(folderName)) {
1087
- return;
1088
- }
1089
- // We need to do a simple "FileSystem.ensureFolder(localModulesFolder)" here,
1090
- // however if the folder we deleted above happened to contain any files,
1091
- // then there seems to be some OS process (virus scanner?) that holds
1092
- // a lock on the folder for a split second, which causes mkdirSync to
1093
- // fail. To workaround that, retry for up to 7 seconds before giving up.
1094
- const maxWaitTimeMs = 7 * 1000;
1095
- return Utilities.retryUntilTimeout(() => _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.ensureFolder(folderName), maxWaitTimeMs, (e) => new Error(`Error: ${e}\nOften this is caused by a file lock ` +
1096
- 'from a process such as your text editor, command prompt, ' +
1097
- 'or a filesystem watcher.'), 'createFolderWithRetry');
1098
- }
1099
- /**
1100
- * Determines if a path points to a directory and that it exists.
1101
- */
1102
- static directoryExists(directoryPath) {
1103
- let exists = false;
1104
- try {
1105
- const lstat = _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.getLinkStatistics(directoryPath);
1106
- exists = lstat.isDirectory();
1107
- }
1108
- catch (e) {
1109
- /* no-op */
1110
- }
1111
- return exists;
1112
- }
1113
- /**
1114
- * BE VERY CAREFUL CALLING THIS FUNCTION!
1115
- * If you specify the wrong folderPath (e.g. "/"), it could potentially delete your entire
1116
- * hard disk.
1117
- */
1118
- static dangerouslyDeletePath(folderPath) {
1119
- try {
1120
- _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.deleteFolder(folderPath);
1121
- }
1122
- catch (e) {
1123
- throw new Error(`${e.message}\nOften this is caused by a file lock from a process ` +
1124
- 'such as your text editor, command prompt, or a filesystem watcher');
1125
- }
1126
- }
1127
- /*
1128
- * Returns true if dateToCompare is more recent than all of the inputFilenames, which
1129
- * would imply that we don't need to rebuild it. Returns false if any of the files
1130
- * does not exist.
1131
- * NOTE: The filenames can also be paths for directories, in which case the directory
1132
- * timestamp is compared.
1133
- */
1134
- static isFileTimestampCurrent(dateToCompare, inputFilenames) {
1135
- for (const inputFilename of inputFilenames) {
1136
- if (!_rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.exists(inputFilename)) {
1137
- return false;
1138
- }
1139
- const inputStats = _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.getStatistics(inputFilename);
1140
- if (dateToCompare < inputStats.mtime) {
1141
- return false;
1142
- }
1143
- }
1144
- return true;
1145
- }
1146
- /**
1147
- * Executes the command with the specified command-line parameters, and waits for it to complete.
1148
- * The current directory will be set to the specified workingDirectory.
1149
- */
1150
- static async executeCommandAsync({ command, args, workingDirectory, suppressOutput, onStdoutStreamChunk, environment, keepEnvironment, captureExitCodeAndSignal }) {
1151
- const { exitCode, signal } = await Utilities._executeCommandInternalAsync({
1152
- command,
1153
- args,
1154
- workingDirectory,
1155
- stdio: onStdoutStreamChunk
1156
- ? // Inherit the stdin and stderr streams, but pipe the stdout stream, which will then be piped
1157
- // to the process's stdout after being intercepted by the onStdoutStreamChunk callback.
1158
- ['inherit', 'pipe', 'inherit']
1159
- : suppressOutput
1160
- ? // If the output is being suppressed, create pipes for all streams to prevent the child process
1161
- // from printing to the parent process's (this process's) stdout/stderr, but allow the stdout and
1162
- // stderr to be inspected if an error occurs.
1163
- // TODO: Consider ignoring stdout and stdin and only piping stderr for inspection on error.
1164
- ['pipe', 'pipe', 'pipe']
1165
- : // If the output is not being suppressed or intercepted, inherit all streams from the parent process.
1166
- ['inherit', 'inherit', 'inherit'],
1167
- environment,
1168
- keepEnvironment,
1169
- onStdoutStreamChunk,
1170
- captureOutput: false,
1171
- captureExitCodeAndSignal
1172
- });
1173
- if (captureExitCodeAndSignal) {
1174
- return { exitCode, signal };
1175
- }
1176
- }
1177
- /**
1178
- * Executes the command with the specified command-line parameters, and waits for it to complete.
1179
- * The current directory will be set to the specified workingDirectory.
1180
- */
1181
- static async executeCommandAndCaptureOutputAsync(command, args, workingDirectory, environment, keepEnvironment = false) {
1182
- const { stdout } = await Utilities._executeCommandInternalAsync({
1183
- command,
1184
- args,
1185
- workingDirectory,
1186
- stdio: ['pipe', 'pipe', 'pipe'],
1187
- environment,
1188
- keepEnvironment,
1189
- captureOutput: true
1190
- });
1191
- return stdout;
1192
- }
1193
- /**
1194
- * Attempts to run Utilities.executeCommand() up to maxAttempts times before giving up.
1195
- */
1196
- static async executeCommandWithRetryAsync(options, maxAttempts, retryCallback) {
1197
- if (maxAttempts < 1) {
1198
- throw new Error('The maxAttempts parameter cannot be less than 1');
1199
- }
1200
- let attemptNumber = 1;
1201
- for (;;) {
1202
- try {
1203
- await Utilities.executeCommandAsync(options);
1204
- }
1205
- catch (error) {
1206
- // eslint-disable-next-line no-console
1207
- console.log('\nThe command failed:');
1208
- const { command, args } = options;
1209
- // eslint-disable-next-line no-console
1210
- console.log(` ${command} ` + args.join(' '));
1211
- // eslint-disable-next-line no-console
1212
- console.log(`ERROR: ${error.toString()}`);
1213
- if (attemptNumber < maxAttempts) {
1214
- ++attemptNumber;
1215
- // eslint-disable-next-line no-console
1216
- console.log(`Trying again (attempt #${attemptNumber})...\n`);
1217
- if (retryCallback) {
1218
- retryCallback();
1219
- }
1220
- continue;
1221
- }
1222
- else {
1223
- // eslint-disable-next-line no-console
1224
- console.error(`Giving up after ${attemptNumber} attempts\n`);
1225
- throw error;
1226
- }
1227
- }
1228
- break;
1229
- }
1230
- }
1231
- /**
1232
- * Executes the command using cmd if running on windows, or using sh if running on a non-windows OS.
1233
- * @param command - the command to run on shell
1234
- * @param options - options for how the command should be run
1235
- */
1236
- static executeLifecycleCommand(command, options) {
1237
- const result = Utilities._executeLifecycleCommandInternal(command, child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync, options);
1238
- if (options.handleOutput) {
1239
- Utilities._processResult({
1240
- error: result.error,
1241
- status: result.status,
1242
- stderr: result.stderr.toString()
1243
- });
1244
- }
1245
- if (result.status !== null) {
1246
- return result.status;
1247
- }
1248
- else {
1249
- throw result.error || new Error('An unknown error occurred.');
1250
- }
1251
- }
1252
- /**
1253
- * Executes the command using cmd if running on windows, or using sh if running on a non-windows OS.
1254
- * @param command - the command to run on shell
1255
- * @param options - options for how the command should be run
1256
- */
1257
- static executeLifecycleCommandAsync(command, options) {
1258
- const child = Utilities._executeLifecycleCommandInternal(command, child_process__WEBPACK_IMPORTED_MODULE_0__.spawn, options);
1259
- if (options.connectSubprocessTerminator) {
1260
- _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.SubprocessTerminator.killProcessTreeOnExit(child, _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.SubprocessTerminator.RECOMMENDED_OPTIONS);
1261
- }
1262
- return child;
1263
- }
1264
- /**
1265
- * For strings passed to a shell command, this adds appropriate escaping
1266
- * to avoid misinterpretation of spaces or special characters.
1267
- *
1268
- * Example: 'hello there' --> '"hello there"'
1269
- */
1270
- static escapeShellParameter(parameter) {
1271
- // This approach is based on what NPM 7 now does:
1272
- // https://github.com/npm/run-script/blob/47a4d539fb07220e7215cc0e482683b76407ef9b/lib/run-script-pkg.js#L34
1273
- return JSON.stringify(parameter);
1274
- }
1275
- /**
1276
- * Installs a package by name and version in the specified directory.
1277
- */
1278
- static async installPackageInDirectoryAsync({ packageName, version, tempPackageTitle, commonRushConfigFolder, maxInstallAttempts, suppressOutput, directory }) {
1279
- directory = path__WEBPACK_IMPORTED_MODULE_2__.resolve(directory);
1280
- const directoryExists = await _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.existsAsync(directory);
1281
- if (directoryExists) {
1282
- // eslint-disable-next-line no-console
1283
- console.log('Deleting old files from ' + directory);
1284
- }
1285
- await _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.ensureEmptyFolderAsync(directory);
1286
- const npmPackageJson = {
1287
- dependencies: {
1288
- [packageName]: version
1289
- },
1290
- description: 'Temporary file generated by the Rush tool',
1291
- name: tempPackageTitle,
1292
- private: true,
1293
- version: '0.0.0'
1294
- };
1295
- await _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.JsonFile.saveAsync(npmPackageJson, path__WEBPACK_IMPORTED_MODULE_2__.join(directory, _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileConstants.PackageJson));
1296
- if (commonRushConfigFolder) {
1297
- Utilities.syncNpmrc({
1298
- sourceNpmrcFolder: commonRushConfigFolder,
1299
- targetNpmrcFolder: directory
1300
- });
1301
- }
1302
- // eslint-disable-next-line no-console
1303
- console.log('\nRunning "npm install" in ' + directory);
1304
- // NOTE: Here we use whatever version of NPM we happen to find in the PATH
1305
- await Utilities.executeCommandWithRetryAsync({
1306
- command: 'npm',
1307
- args: ['install'],
1308
- workingDirectory: directory,
1309
- environment: Utilities._createEnvironmentForRushCommand({}),
1310
- suppressOutput
1311
- }, maxInstallAttempts);
1312
- }
1313
- /**
1314
- * Copies the file "sourcePath" to "destinationPath", overwriting the target file location.
1315
- * If the source file does not exist, then the target file is deleted.
1316
- */
1317
- static syncFile(sourcePath, destinationPath) {
1318
- if (_rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.exists(sourcePath)) {
1319
- // eslint-disable-next-line no-console
1320
- console.log(`Copying "${sourcePath}"`);
1321
- // eslint-disable-next-line no-console
1322
- console.log(` --> "${destinationPath}"`);
1323
- _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.copyFile({ sourcePath, destinationPath });
1324
- }
1325
- else {
1326
- if (_rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.exists(destinationPath)) {
1327
- // If the source file doesn't exist and there is one in the target, delete the one in the target
1328
- // eslint-disable-next-line no-console
1329
- console.log(`Deleting ${destinationPath}`);
1330
- _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.deleteFile(destinationPath);
1331
- }
1332
- }
1333
- }
1334
- static getRushConfigNotFoundError() {
1335
- return new Error(`Unable to find ${_logic_RushConstants__WEBPACK_IMPORTED_MODULE_6__.RushConstants.rushJsonFilename} configuration file`);
1336
- }
1337
- static async usingAsync(getDisposableAsync, doActionAsync) {
1338
- let disposable;
1339
- try {
1340
- disposable = (await getDisposableAsync());
1341
- await doActionAsync(disposable);
1342
- }
1343
- finally {
1344
- disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
1345
- }
1346
- }
1347
- static trimAfterLastSlash(filePath) {
1348
- const indexOfLastSlash = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
1349
- if (indexOfLastSlash < 0) {
1350
- return filePath;
1351
- }
1352
- return filePath.substring(0, indexOfLastSlash);
1353
- }
1354
- /**
1355
- * If the path refers to a symlink, `FileSystem.exists()` would normally test whether the symlink
1356
- * points to a target that exists. By contrast, `existsOrIsBrokenSymlink()` will return true even if
1357
- * the symlink exists but its target does not. */
1358
- static existsOrIsSymlink(linkPath) {
1359
- try {
1360
- _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.FileSystem.getLinkStatistics(linkPath);
1361
- return true;
1362
- }
1363
- catch (err) {
1364
- return false;
1365
- }
1366
- }
1367
- static _executeLifecycleCommandInternal(command, spawnFunction, options) {
1368
- var _a;
1369
- let shellCommand = process.env.comspec || 'cmd';
1370
- let commandFlags = '/d /s /c';
1371
- let useShell = true;
1372
- if (process.platform !== 'win32') {
1373
- shellCommand = 'sh';
1374
- commandFlags = '-c';
1375
- useShell = false;
1376
- }
1377
- const environment = Utilities._createEnvironmentForRushCommand({
1378
- initCwd: options.initCwd,
1379
- initialEnvironment: options.initialEnvironment,
1380
- pathOptions: Object.assign(Object.assign({}, options.environmentPathOptions), { rushJsonFolder: (_a = options.rushConfiguration) === null || _a === void 0 ? void 0 : _a.rushJsonFolder, projectRoot: options.workingDirectory, commonTempFolder: options.rushConfiguration ? options.rushConfiguration.commonTempFolder : undefined })
1381
- });
1382
- const stdio = options.handleOutput ? ['pipe', 'pipe', 'pipe'] : [0, 1, 2];
1383
- if (options.ipc) {
1384
- stdio.push('ipc');
1385
- }
1386
- const spawnOptions = {
1387
- cwd: options.workingDirectory,
1388
- shell: useShell,
1389
- env: environment,
1390
- stdio
1391
- };
1392
- if (options.connectSubprocessTerminator) {
1393
- Object.assign(spawnOptions, _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.SubprocessTerminator.RECOMMENDED_OPTIONS);
1394
- }
1395
- return spawnFunction(shellCommand, [commandFlags, command], spawnOptions);
1396
- }
1397
- /**
1398
- * Returns a process.env environment suitable for executing lifecycle scripts.
1399
- * @param initialEnvironment - an existing environment to copy instead of process.env
1400
- *
1401
- * @remarks
1402
- * Rush._assignRushInvokedFolder() assigns the `RUSH_INVOKED_FOLDER` variable globally
1403
- * via the parent process's environment.
1404
- */
1405
- static _createEnvironmentForRushCommand(options) {
1406
- var _a;
1407
- if (options.initialEnvironment === undefined) {
1408
- options.initialEnvironment = process.env;
1409
- }
1410
- // Set some defaults for the environment
1411
- const environment = {};
1412
- if ((_a = options.pathOptions) === null || _a === void 0 ? void 0 : _a.rushJsonFolder) {
1413
- environment.RUSHSTACK_FILE_ERROR_BASE_FOLDER = options.pathOptions.rushJsonFolder;
1414
- }
1415
- for (const key of Object.getOwnPropertyNames(options.initialEnvironment)) {
1416
- const normalizedKey = os__WEBPACK_IMPORTED_MODULE_1__.platform() === 'win32' ? key.toUpperCase() : key;
1417
- // If Rush itself was invoked inside a lifecycle script, this may be set and would interfere
1418
- // with Rush's installations. If we actually want it, we will set it explicitly below.
1419
- if (normalizedKey === 'INIT_CWD') {
1420
- continue;
1421
- }
1422
- // When NPM invokes a lifecycle event, it copies its entire configuration into environment
1423
- // variables. Rush is supposed to be a deterministic controlled environment, so don't bring
1424
- // this along.
1425
- //
1426
- // NOTE: Longer term we should clean out the entire environment and use rush.json to bring
1427
- // back specific environment variables that the repo maintainer has determined to be safe.
1428
- if (normalizedKey.match(/^NPM_CONFIG_/)) {
1429
- continue;
1430
- }
1431
- // Use the uppercased environment variable name on Windows because environment variable names
1432
- // are case-insensitive on Windows
1433
- environment[normalizedKey] = options.initialEnvironment[key];
1434
- }
1435
- // When NPM invokes a lifecycle script, it sets an environment variable INIT_CWD that remembers
1436
- // the directory that NPM started in. This allows naive scripts to change their current working directory
1437
- // and invoke NPM operations, while still be able to find a local .npmrc file. Although Rush recommends
1438
- // for toolchain scripts to be professionally written (versus brittle stuff like
1439
- // "cd ./lib && npm run tsc && cd .."), we support INIT_CWD for compatibility.
1440
- //
1441
- // More about this feature: https://github.com/npm/npm/pull/12356
1442
- if (options.initCwd) {
1443
- environment['INIT_CWD'] = options.initCwd; // eslint-disable-line dot-notation
1444
- }
1445
- if (options.pathOptions) {
1446
- if (options.pathOptions.includeRepoBin && options.pathOptions.commonTempFolder) {
1447
- environment.PATH = Utilities._prependNodeModulesBinToPath(environment.PATH, options.pathOptions.commonTempFolder);
1448
- }
1449
- if (options.pathOptions.includeProjectBin && options.pathOptions.projectRoot) {
1450
- environment.PATH = Utilities._prependNodeModulesBinToPath(environment.PATH, options.pathOptions.projectRoot);
1451
- }
1452
- if (options.pathOptions.additionalPathFolders) {
1453
- environment.PATH = [...options.pathOptions.additionalPathFolders, environment.PATH].join(path__WEBPACK_IMPORTED_MODULE_2__.delimiter);
1454
- }
1455
- }
1456
- // Communicate to downstream calls that they should not try to run hooks
1457
- environment[_api_EnvironmentConfiguration__WEBPACK_IMPORTED_MODULE_7__.EnvironmentVariableNames._RUSH_RECURSIVE_RUSHX_CALL] = '1';
1458
- return environment;
1459
- }
1460
- /**
1461
- * Prepend the node_modules/.bin folder under the specified folder to the specified PATH variable. For example,
1462
- * if `rootDirectory` is "/foobar" and `existingPath` is "/bin", this function will return
1463
- * "/foobar/node_modules/.bin:/bin"
1464
- */
1465
- static _prependNodeModulesBinToPath(existingPath, rootDirectory) {
1466
- const binPath = path__WEBPACK_IMPORTED_MODULE_2__.resolve(rootDirectory, 'node_modules', '.bin');
1467
- if (existingPath) {
1468
- return `${binPath}${path__WEBPACK_IMPORTED_MODULE_2__.delimiter}${existingPath}`;
1469
- }
1470
- else {
1471
- return binPath;
1472
- }
1473
- }
1474
- /**
1475
- * Executes the command with the specified command-line parameters, and waits for it to complete.
1476
- * The current directory will be set to the specified workingDirectory.
1477
- */
1478
- static async _executeCommandInternalAsync({ command, args, workingDirectory, stdio, environment, keepEnvironment, onStdoutStreamChunk, captureOutput, captureExitCodeAndSignal }) {
1479
- var _a;
1480
- const options = {
1481
- cwd: workingDirectory,
1482
- shell: true,
1483
- stdio: stdio,
1484
- env: keepEnvironment
1485
- ? environment
1486
- : Utilities._createEnvironmentForRushCommand({ initialEnvironment: environment }),
1487
- maxBuffer: 10 * 1024 * 1024 // Set default max buffer size to 10MB
1488
- };
1489
- // This is needed since we specify shell=true below.
1490
- // NOTE: On Windows if we escape "NPM", the spawnSync() function runs something like this:
1491
- // [ 'C:\\Windows\\system32\\cmd.exe', '/s', '/c', '""NPM" "install""' ]
1492
- //
1493
- // Due to a bug with Windows cmd.exe, the npm.cmd batch file's "%~dp0" variable will
1494
- // return the current working directory instead of the batch file's directory.
1495
- // The workaround is to not escape, npm, i.e. do this instead:
1496
- // [ 'C:\\Windows\\system32\\cmd.exe', '/s', '/c', '"npm "install""' ]
1497
- //
1498
- // We will come up with a better solution for this when we promote executeCommand()
1499
- // into node-core-library, but for now this hack will unblock people:
1500
- // Only escape the command if it actually contains spaces:
1501
- const escapedCommand = command.indexOf(' ') < 0 ? command : Utilities.escapeShellParameter(command);
1502
- const escapedArgs = args.map((x) => Utilities.escapeShellParameter(x));
1503
- const childProcess = child_process__WEBPACK_IMPORTED_MODULE_0__.spawn(escapedCommand, escapedArgs, options);
1504
- if (onStdoutStreamChunk) {
1505
- const inspectStream = new stream__WEBPACK_IMPORTED_MODULE_4__.Transform({
1506
- transform: onStdoutStreamChunk
1507
- ? (chunk, encoding, callback) => {
1508
- const chunkString = chunk.toString();
1509
- const updatedChunk = onStdoutStreamChunk(chunkString);
1510
- callback(undefined, updatedChunk !== null && updatedChunk !== void 0 ? updatedChunk : chunk);
1511
- }
1512
- : undefined
1513
- });
1514
- (_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.pipe(inspectStream).pipe(process.stdout);
1515
- }
1516
- return await _rushstack_node_core_library__WEBPACK_IMPORTED_MODULE_5__.Executable.waitForExitAsync(childProcess, {
1517
- encoding: captureOutput ? 'utf8' : undefined,
1518
- throwOnNonZeroExitCode: !captureExitCodeAndSignal,
1519
- throwOnSignal: !captureExitCodeAndSignal
1520
- });
1521
- }
1522
- static _processResult({ error, stderr, status }) {
1523
- if (error) {
1524
- error.message += `\n${stderr}`;
1525
- if (status) {
1526
- error.message += `\nExited with status ${status}`;
1527
- }
1528
- throw error;
1529
- }
1530
- if (status) {
1531
- throw new Error(`The command failed with exit code ${status}\n${stderr}`);
1532
- }
1533
- }
1534
- }
1535
- Utilities.syncNpmrc = _npmrcUtilities__WEBPACK_IMPORTED_MODULE_8__.syncNpmrc;
1536
- //# sourceMappingURL=Utilities.js.map
1537
-
1538
- /***/ }),
1539
-
1540
- /***/ "../rush-lib/lib-esnext/utilities/npmrcUtilities.js":
1541
- /*!**********************************************************!*\
1542
- !*** ../rush-lib/lib-esnext/utilities/npmrcUtilities.js ***!
1543
- \**********************************************************/
1544
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1545
-
1546
- __webpack_require__.r(__webpack_exports__);
1547
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1548
- /* harmony export */ "isVariableSetInNpmrcFile": () => (/* binding */ isVariableSetInNpmrcFile),
1549
- /* harmony export */ "syncNpmrc": () => (/* binding */ syncNpmrc)
1550
- /* harmony export */ });
1551
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs */ "fs");
1552
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
1553
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ "path");
1554
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
1555
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
1556
- // See LICENSE in the project root for license information.
1557
- // IMPORTANT - do not use any non-built-in libraries in this file
1558
-
1559
-
1560
- /**
1561
- * This function reads the content for given .npmrc file path, and also trims
1562
- * unusable lines from the .npmrc file.
1563
- *
1564
- * @returns
1565
- * The text of the the .npmrc.
1566
- */
1567
- // create a global _combinedNpmrc for cache purpose
1568
- const _combinedNpmrcMap = new Map();
1569
- function _trimNpmrcFile(options) {
1570
- const { sourceNpmrcPath, linesToPrepend, linesToAppend } = options;
1571
- const combinedNpmrcFromCache = _combinedNpmrcMap.get(sourceNpmrcPath);
1572
- if (combinedNpmrcFromCache !== undefined) {
1573
- return combinedNpmrcFromCache;
1574
- }
1575
- let npmrcFileLines = [];
1576
- if (linesToPrepend) {
1577
- npmrcFileLines.push(...linesToPrepend);
1578
- }
1579
- if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(sourceNpmrcPath)) {
1580
- npmrcFileLines.push(...fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(sourceNpmrcPath).toString().split('\n'));
1581
- }
1582
- if (linesToAppend) {
1583
- npmrcFileLines.push(...linesToAppend);
1584
- }
1585
- npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim());
1586
- const resultLines = [];
1587
- // This finds environment variable tokens that look like "${VAR_NAME}"
1588
- const expansionRegExp = /\$\{([^\}]+)\}/g;
1589
- // Comment lines start with "#" or ";"
1590
- const commentRegExp = /^\s*[#;]/;
1591
- // Trim out lines that reference environment variables that aren't defined
1592
- for (let line of npmrcFileLines) {
1593
- let lineShouldBeTrimmed = false;
1594
- //remove spaces before or after key and value
1595
- line = line
1596
- .split('=')
1597
- .map((lineToTrim) => lineToTrim.trim())
1598
- .join('=');
1599
- // Ignore comment lines
1600
- if (!commentRegExp.test(line)) {
1601
- const environmentVariables = line.match(expansionRegExp);
1602
- if (environmentVariables) {
1603
- for (const token of environmentVariables) {
1604
- // Remove the leading "${" and the trailing "}" from the token
1605
- const environmentVariableName = token.substring(2, token.length - 1);
1606
- // Is the environment variable defined?
1607
- if (!process.env[environmentVariableName]) {
1608
- // No, so trim this line
1609
- lineShouldBeTrimmed = true;
1610
- break;
1611
- }
1612
- }
1613
- }
1614
- }
1615
- if (lineShouldBeTrimmed) {
1616
- // Example output:
1617
- // "; MISSING ENVIRONMENT VARIABLE: //my-registry.com/npm/:_authToken=${MY_AUTH_TOKEN}"
1618
- resultLines.push('; MISSING ENVIRONMENT VARIABLE: ' + line);
1619
- }
1620
- else {
1621
- resultLines.push(line);
1622
- }
1623
- }
1624
- const combinedNpmrc = resultLines.join('\n');
1625
- //save the cache
1626
- _combinedNpmrcMap.set(sourceNpmrcPath, combinedNpmrc);
1627
- return combinedNpmrc;
1628
- }
1629
- function _copyAndTrimNpmrcFile(options) {
1630
- const { logger, sourceNpmrcPath, targetNpmrcPath, linesToPrepend, linesToAppend } = options;
1631
- logger.info(`Transforming ${sourceNpmrcPath}`); // Verbose
1632
- logger.info(` --> "${targetNpmrcPath}"`);
1633
- const combinedNpmrc = _trimNpmrcFile({
1634
- sourceNpmrcPath,
1635
- linesToPrepend,
1636
- linesToAppend
1637
- });
1638
- fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(targetNpmrcPath, combinedNpmrc);
1639
- return combinedNpmrc;
1640
- }
1641
- function syncNpmrc(options) {
1642
- const { sourceNpmrcFolder, targetNpmrcFolder, useNpmrcPublish, logger = {
1643
- // eslint-disable-next-line no-console
1644
- info: console.log,
1645
- // eslint-disable-next-line no-console
1646
- error: console.error
1647
- }, createIfMissing = false, linesToAppend, linesToPrepend } = options;
1648
- const sourceNpmrcPath = path__WEBPACK_IMPORTED_MODULE_1__.join(sourceNpmrcFolder, !useNpmrcPublish ? '.npmrc' : '.npmrc-publish');
1649
- const targetNpmrcPath = path__WEBPACK_IMPORTED_MODULE_1__.join(targetNpmrcFolder, '.npmrc');
1650
- try {
1651
- if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(sourceNpmrcPath) || createIfMissing) {
1652
- // Ensure the target folder exists
1653
- if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcFolder)) {
1654
- fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(targetNpmrcFolder, { recursive: true });
1655
- }
1656
- return _copyAndTrimNpmrcFile({
1657
- sourceNpmrcPath,
1658
- targetNpmrcPath,
1659
- logger,
1660
- linesToAppend,
1661
- linesToPrepend
1662
- });
1663
- }
1664
- else if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcPath)) {
1665
- // If the source .npmrc doesn't exist and there is one in the target, delete the one in the target
1666
- logger.info(`Deleting ${targetNpmrcPath}`); // Verbose
1667
- fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(targetNpmrcPath);
1668
- }
1669
- }
1670
- catch (e) {
1671
- throw new Error(`Error syncing .npmrc file: ${e}`);
1672
- }
1673
- }
1674
- function isVariableSetInNpmrcFile(sourceNpmrcFolder, variableKey) {
1675
- const sourceNpmrcPath = `${sourceNpmrcFolder}/.npmrc`;
1676
- //if .npmrc file does not exist, return false directly
1677
- if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(sourceNpmrcPath)) {
1678
- return false;
1679
- }
1680
- const trimmedNpmrcFile = _trimNpmrcFile({ sourceNpmrcPath });
1681
- const variableKeyRegExp = new RegExp(`^${variableKey}=`, 'm');
1682
- return trimmedNpmrcFile.match(variableKeyRegExp) !== null;
1683
- }
1684
- //# sourceMappingURL=npmrcUtilities.js.map
1685
-
1686
- /***/ }),
1687
-
1688
- /***/ "./lib-commonjs/helpers.js":
1689
- /*!*********************************!*\
1690
- !*** ./lib-commonjs/helpers.js ***!
1691
- \*********************************/
1692
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1693
-
1694
-
1695
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
1696
- // See LICENSE in the project root for license information.
1697
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1698
- if (k2 === undefined) k2 = k;
1699
- var desc = Object.getOwnPropertyDescriptor(m, k);
1700
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1701
- desc = { enumerable: true, get: function() { return m[k]; } };
1702
- }
1703
- Object.defineProperty(o, k2, desc);
1704
- }) : (function(o, m, k, k2) {
1705
- if (k2 === undefined) k2 = k;
1706
- o[k2] = m[k];
1707
- }));
1708
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1709
- Object.defineProperty(o, "default", { enumerable: true, value: v });
1710
- }) : function(o, v) {
1711
- o["default"] = v;
1712
- });
1713
- var __importStar = (this && this.__importStar) || function (mod) {
1714
- if (mod && mod.__esModule) return mod;
1715
- var result = {};
1716
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1717
- __setModuleDefault(result, mod);
1718
- return result;
1719
- };
1720
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1721
- exports.requireRushLibUnderFolderPath = exports._require = exports.tryFindRushJsonLocation = exports.sdkContext = exports.RUSH_LIB_PATH_ENV_VAR_NAME = exports.RUSH_LIB_NAME = void 0;
1722
- const path = __importStar(__webpack_require__(/*! path */ "path"));
1723
- const node_core_library_1 = __webpack_require__(/*! @rushstack/node-core-library */ "@rushstack/node-core-library");
1724
- exports.RUSH_LIB_NAME = '@microsoft/rush-lib';
1725
- exports.RUSH_LIB_PATH_ENV_VAR_NAME = '_RUSH_LIB_PATH';
1726
- exports.sdkContext = {
1727
- rushLibModule: undefined
1728
- };
1729
- /**
1730
- * Find the rush.json location and return the path, or undefined if a rush.json can't be found.
1731
- *
1732
- * @privateRemarks
1733
- * Keep this in sync with `RushConfiguration.tryFindRushJsonLocation`.
1734
- */
1735
- function tryFindRushJsonLocation(startingFolder) {
1736
- let currentFolder = startingFolder;
1737
- // Look upwards at parent folders until we find a folder containing rush.json
1738
- for (let i = 0; i < 10; ++i) {
1739
- const rushJsonFilename = path.join(currentFolder, 'rush.json');
1740
- if (node_core_library_1.FileSystem.exists(rushJsonFilename)) {
1741
- return rushJsonFilename;
1742
- }
1743
- const parentFolder = path.dirname(currentFolder);
1744
- if (parentFolder === currentFolder) {
1745
- break;
1746
- }
1747
- currentFolder = parentFolder;
1748
- }
1749
- return undefined;
1750
- }
1751
- exports.tryFindRushJsonLocation = tryFindRushJsonLocation;
1752
- function _require(moduleName) {
1753
- if (typeof require === 'function') {
1754
- // If this library has been bundled with Webpack, we need to call the real `require` function
1755
- // that doesn't get turned into a `__webpack_require__` statement.
1756
- // `__non_webpack_require__` is a Webpack macro that gets turned into a `require` statement
1757
- // during bundling.
1758
- return require(moduleName);
1759
- }
1760
- else {
1761
- return require(moduleName);
1762
- }
1763
- }
1764
- exports._require = _require;
1765
- /**
1766
- * Require `@microsoft/rush-lib` under the specified folder path.
1767
- */
1768
- function requireRushLibUnderFolderPath(folderPath) {
1769
- const rushLibModulePath = node_core_library_1.Import.resolveModule({
1770
- modulePath: exports.RUSH_LIB_NAME,
1771
- baseFolderPath: folderPath
1772
- });
1773
- return _require(rushLibModulePath);
1774
- }
1775
- exports.requireRushLibUnderFolderPath = requireRushLibUnderFolderPath;
1776
- //# sourceMappingURL=helpers.js.map
1777
-
1778
- /***/ }),
1779
-
1780
- /***/ "./lib-commonjs/index.js":
1781
- /*!*******************************!*\
1782
- !*** ./lib-commonjs/index.js ***!
1783
- \*******************************/
1784
- /***/ (function(module, exports, __webpack_require__) {
1785
-
1786
- /* module decorator */ module = __webpack_require__.nmd(module);
1787
-
1788
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
1789
- // See LICENSE in the project root for license information.
1790
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1791
- if (k2 === undefined) k2 = k;
1792
- var desc = Object.getOwnPropertyDescriptor(m, k);
1793
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1794
- desc = { enumerable: true, get: function() { return m[k]; } };
1795
- }
1796
- Object.defineProperty(o, k2, desc);
1797
- }) : (function(o, m, k, k2) {
1798
- if (k2 === undefined) k2 = k;
1799
- o[k2] = m[k];
1800
- }));
1801
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1802
- Object.defineProperty(o, "default", { enumerable: true, value: v });
1803
- }) : function(o, v) {
1804
- o["default"] = v;
1805
- });
1806
- var __importStar = (this && this.__importStar) || function (mod) {
1807
- if (mod && mod.__esModule) return mod;
1808
- var result = {};
1809
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1810
- __setModuleDefault(result, mod);
1811
- return result;
1812
- };
1813
- var _a;
1814
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1815
- exports._rushSdk_loadInternalModule = void 0;
1816
- const path = __importStar(__webpack_require__(/*! path */ "path"));
1817
- const node_core_library_1 = __webpack_require__(/*! @rushstack/node-core-library */ "@rushstack/node-core-library");
1818
- const terminal_1 = __webpack_require__(/*! @rushstack/terminal */ "@rushstack/terminal");
1819
- const RushGlobalFolder_1 = __webpack_require__(/*! @microsoft/rush-lib/lib-esnext/api/RushGlobalFolder */ "../rush-lib/lib-esnext/api/RushGlobalFolder.js");
1820
- const helpers_1 = __webpack_require__(/*! ./helpers */ "./lib-commonjs/helpers.js");
1821
- const verboseEnabled = typeof process !== 'undefined' &&
1822
- (process.env.RUSH_SDK_DEBUG === '1' || process.env._RUSH_SDK_DEBUG === '1');
1823
- const terminal = new terminal_1.Terminal(new terminal_1.ConsoleTerminalProvider({
1824
- verboseEnabled
1825
- }));
1826
- let errorMessage = '';
1827
- // SCENARIO 1: Rush's PluginManager has initialized "rush-sdk" with Rush's own instance of rush-lib.
1828
- // The Rush host process will assign "global.___rush___rushLibModule" before loading the plugin.
1829
- if (helpers_1.sdkContext.rushLibModule === undefined) {
1830
- helpers_1.sdkContext.rushLibModule =
1831
- global.___rush___rushLibModule ||
1832
- global.___rush___rushLibModuleFromEnvironment ||
1833
- global.___rush___rushLibModuleFromRushGlobalFolder ||
1834
- global.___rush___rushLibModuleFromInstallAndRunRush;
1835
- }
1836
- // SCENARIO 2: The project importing "rush-sdk" has installed its own instance of "rush-lib"
1837
- // as a package.json dependency. For example, this is used by the Jest tests for Rush plugins.
1838
- if (helpers_1.sdkContext.rushLibModule === undefined) {
1839
- const importingPath = (_a = module === null || module === void 0 ? void 0 : module.parent) === null || _a === void 0 ? void 0 : _a.filename;
1840
- if (importingPath) {
1841
- const callerPackageFolder = node_core_library_1.PackageJsonLookup.instance.tryGetPackageFolderFor(importingPath);
1842
- if (callerPackageFolder !== undefined) {
1843
- const callerPackageJson = (0, helpers_1._require)(path.join(callerPackageFolder, 'package.json'));
1844
- // Does the caller properly declare a dependency on rush-lib?
1845
- if ((callerPackageJson.dependencies && callerPackageJson.dependencies[helpers_1.RUSH_LIB_NAME] !== undefined) ||
1846
- (callerPackageJson.devDependencies &&
1847
- callerPackageJson.devDependencies[helpers_1.RUSH_LIB_NAME] !== undefined) ||
1848
- (callerPackageJson.peerDependencies &&
1849
- callerPackageJson.peerDependencies[helpers_1.RUSH_LIB_NAME] !== undefined)) {
1850
- // Try to resolve rush-lib from the caller's folder
1851
- terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from caller package`);
1852
- try {
1853
- helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(callerPackageFolder);
1854
- }
1855
- catch (error) {
1856
- // If we fail to resolve it, ignore the error
1857
- terminal.writeVerboseLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} from caller package`);
1858
- }
1859
- // If two different libraries invoke `rush-sdk`, and one of them provides "rush-lib"
1860
- // then the first version to be loaded wins. We do not support side-by-side instances of "rush-lib".
1861
- if (helpers_1.sdkContext.rushLibModule !== undefined) {
1862
- // to track which scenario is active and how it got initialized.
1863
- global.___rush___rushLibModule = helpers_1.sdkContext.rushLibModule;
1864
- terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} from caller`);
1865
- }
1866
- }
1867
- }
1868
- }
1869
- }
1870
- // SCENARIO 3: A tool or script has been invoked as a child process by an instance of "rush-lib" and can use the
1871
- // version that invoked it. In this case, use process.env._RUSH_LIB_PATH to find "rush-lib".
1872
- if (helpers_1.sdkContext.rushLibModule === undefined) {
1873
- const rushLibPath = process.env[helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME];
1874
- if (rushLibPath) {
1875
- terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME} from caller package`);
1876
- try {
1877
- helpers_1.sdkContext.rushLibModule = (0, helpers_1._require)(rushLibPath);
1878
- }
1879
- catch (error) {
1880
- // Log this as a warning, since it is unexpected to define an incorrect value of the variable.
1881
- terminal.writeWarningLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} via process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME}`);
1882
- }
1883
- if (helpers_1.sdkContext.rushLibModule !== undefined) {
1884
- // to track which scenario is active and how it got initialized.
1885
- global.___rush___rushLibModuleFromEnvironment = helpers_1.sdkContext.rushLibModule;
1886
- terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} from process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME}`);
1887
- }
1888
- }
1889
- }
1890
- // SCENARIO 4: A standalone tool or script depends on "rush-sdk", and is meant to be used inside a monorepo folder.
1891
- // In this case, we can first load the rush-lib version in rush global folder. If the expected version is not installed,
1892
- // using install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.
1893
- if (helpers_1.sdkContext.rushLibModule === undefined) {
1894
- try {
1895
- const rushJsonPath = (0, helpers_1.tryFindRushJsonLocation)(process.cwd());
1896
- if (!rushJsonPath) {
1897
- throw new Error('Unable to find rush.json in the current folder or its parent folders.\n' +
1898
- 'This tool is meant to be invoked from a working directory inside a Rush repository.');
1899
- }
1900
- const monorepoRoot = path.dirname(rushJsonPath);
1901
- const rushJson = node_core_library_1.JsonFile.load(rushJsonPath);
1902
- const { rushVersion } = rushJson;
1903
- try {
1904
- terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from rush global folder`);
1905
- const rushGlobalFolder = new RushGlobalFolder_1.RushGlobalFolder();
1906
- // The path needs to keep align with the logic inside RushVersionSelector
1907
- const expectedGlobalRushInstalledFolder = `${rushGlobalFolder.nodeSpecificPath}/rush-${rushVersion}`;
1908
- terminal.writeVerboseLine(`The expected global rush installed folder is "${expectedGlobalRushInstalledFolder}"`);
1909
- helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(expectedGlobalRushInstalledFolder);
1910
- }
1911
- catch (e) {
1912
- terminal.writeVerboseLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} from rush global folder: ${e.message}`);
1913
- }
1914
- if (helpers_1.sdkContext.rushLibModule !== undefined) {
1915
- // to track which scenario is active and how it got initialized.
1916
- global.___rush___rushLibModuleFromRushGlobalFolder = helpers_1.sdkContext.rushLibModule;
1917
- terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} installed from rush global folder`);
1918
- }
1919
- else {
1920
- const installRunNodeModuleFolder = `${monorepoRoot}/common/temp/install-run/@microsoft+rush@${rushVersion}`;
1921
- try {
1922
- // First, try to load the version of "rush-lib" that was installed by install-run-rush.js
1923
- terminal.writeVerboseLine(`Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`);
1924
- helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
1925
- }
1926
- catch (e1) {
1927
- let installAndRunRushStderrContent = '';
1928
- try {
1929
- const installAndRunRushJSPath = `${monorepoRoot}/common/scripts/install-run-rush.js`;
1930
- terminal.writeLine('The Rush engine has not been installed yet. Invoking install-run-rush.js...');
1931
- const installAndRunRushProcess = node_core_library_1.Executable.spawnSync('node', [installAndRunRushJSPath, '--help'], {
1932
- stdio: 'pipe'
1933
- });
1934
- installAndRunRushStderrContent = installAndRunRushProcess.stderr;
1935
- if (installAndRunRushProcess.status !== 0) {
1936
- throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to install`);
1937
- }
1938
- // Retry to load "rush-lib" after install-run-rush run
1939
- terminal.writeVerboseLine(`Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush a second time`);
1940
- helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
1941
- }
1942
- catch (e2) {
1943
- // eslint-disable-next-line no-console
1944
- console.error(`${installAndRunRushStderrContent}`);
1945
- throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to load`);
1946
- }
1947
- }
1948
- if (helpers_1.sdkContext.rushLibModule !== undefined) {
1949
- // to track which scenario is active and how it got initialized.
1950
- global.___rush___rushLibModuleFromInstallAndRunRush = helpers_1.sdkContext.rushLibModule;
1951
- terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`);
1952
- }
1953
- }
1954
- }
1955
- catch (e) {
1956
- // no-catch
1957
- errorMessage = e.message;
1958
- }
1959
- }
1960
- if (helpers_1.sdkContext.rushLibModule === undefined) {
1961
- // This error indicates that a project is trying to import "@rushstack/rush-sdk", but the Rush engine
1962
- // instance cannot be found. If you are writing Jest tests for a Rush plugin, add "@microsoft/rush-lib"
1963
- // to the devDependencies for your project.
1964
- // eslint-disable-next-line no-console
1965
- console.error(`Error: The @rushstack/rush-sdk package was not able to load the Rush engine:
1966
- ${errorMessage}
1967
- `);
1968
- process.exit(1);
1969
- }
1970
- // Based on TypeScript's __exportStar()
1971
- for (const property in helpers_1.sdkContext.rushLibModule) {
1972
- if (property !== 'default' && !exports.hasOwnProperty(property)) {
1973
- const rushLibModuleForClosure = helpers_1.sdkContext.rushLibModule;
1974
- // Based on TypeScript's __createBinding()
1975
- Object.defineProperty(exports, property, {
1976
- enumerable: true,
1977
- get: function () {
1978
- return rushLibModuleForClosure[property];
1979
- }
1980
- });
1981
- }
1982
- }
1983
- /**
1984
- * Used by the .js stubs for path-based imports of `@microsoft/rush-lib` internal APIs.
1985
- */
1986
- function _rushSdk_loadInternalModule(srcImportPath) {
1987
- if (!exports._RushInternals) {
1988
- throw new Error(`Rush version ${exports.Rush.version} does not support internal API imports via rush-sdk`);
1989
- }
1990
- return exports._RushInternals.loadModule(srcImportPath);
1991
- }
1992
- exports._rushSdk_loadInternalModule = _rushSdk_loadInternalModule;
1993
- //# sourceMappingURL=index.js.map
1994
-
1995
- /***/ }),
1996
-
1997
- /***/ "./lib-commonjs/loader.js":
1998
- /*!********************************!*\
1999
- !*** ./lib-commonjs/loader.js ***!
2000
- \********************************/
2001
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2002
-
2003
-
2004
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2005
- // See LICENSE in the project root for license information.
2006
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2007
- if (k2 === undefined) k2 = k;
2008
- var desc = Object.getOwnPropertyDescriptor(m, k);
2009
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2010
- desc = { enumerable: true, get: function() { return m[k]; } };
2011
- }
2012
- Object.defineProperty(o, k2, desc);
2013
- }) : (function(o, m, k, k2) {
2014
- if (k2 === undefined) k2 = k;
2015
- o[k2] = m[k];
2016
- }));
2017
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
2018
- Object.defineProperty(o, "default", { enumerable: true, value: v });
2019
- }) : function(o, v) {
2020
- o["default"] = v;
2021
- });
2022
- var __importStar = (this && this.__importStar) || function (mod) {
2023
- if (mod && mod.__esModule) return mod;
2024
- var result = {};
2025
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2026
- __setModuleDefault(result, mod);
2027
- return result;
2028
- };
2029
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2030
- exports.RushSdkLoader = void 0;
2031
- const path = __importStar(__webpack_require__(/*! path */ "path"));
2032
- const node_core_library_1 = __webpack_require__(/*! @rushstack/node-core-library */ "@rushstack/node-core-library");
2033
- const helpers_1 = __webpack_require__(/*! ./helpers */ "./lib-commonjs/helpers.js");
2034
- /**
2035
- * Exposes operations that control how the `@microsoft/rush-lib` engine is
2036
- * located and loaded.
2037
- * @public
2038
- */
2039
- class RushSdkLoader {
2040
- /**
2041
- * Throws an "AbortError" exception if abortSignal.aborted is true.
2042
- */
2043
- static _checkForCancel(abortSignal, onNotifyEvent, progressPercent) {
2044
- if (!(abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted)) {
2045
- return;
2046
- }
2047
- if (onNotifyEvent) {
2048
- onNotifyEvent({
2049
- logMessage: {
2050
- kind: 'info',
2051
- text: `The operation was canceled`
2052
- },
2053
- progressPercent
2054
- });
2055
- }
2056
- const error = new Error('The operation was canceled');
2057
- error.name = 'AbortError';
2058
- throw error;
2059
- }
2060
- /**
2061
- * Returns true if the Rush engine has already been loaded.
2062
- */
2063
- static get isLoaded() {
2064
- return helpers_1.sdkContext.rushLibModule !== undefined;
2065
- }
2066
- /**
2067
- * Manually load the Rush engine based on rush.json found for `rushJsonSearchFolder`.
2068
- * Throws an exception if {@link RushSdkLoader.isLoaded} is already `true`.
2069
- *
2070
- * @remarks
2071
- * This API supports an callback that can be used display a progress bar,
2072
- * log of operations, and allow the operation to be canceled prematurely.
2073
- */
2074
- static async loadAsync(options) {
2075
- // SCENARIO 5: The rush-lib engine is loaded manually using rushSdkLoader.loadAsync().
2076
- var _a, _b;
2077
- if (!options) {
2078
- options = {};
2079
- }
2080
- if (RushSdkLoader.isLoaded) {
2081
- throw new Error('RushSdkLoader.loadAsync() failed because the Rush engine has already been loaded');
2082
- }
2083
- const onNotifyEvent = options.onNotifyEvent;
2084
- let progressPercent = undefined;
2085
- const abortSignal = options.abortSignal;
2086
- try {
2087
- const rushJsonSearchFolder = (_a = options.rushJsonSearchFolder) !== null && _a !== void 0 ? _a : process.cwd();
2088
- if (onNotifyEvent) {
2089
- onNotifyEvent({
2090
- logMessage: {
2091
- kind: 'debug',
2092
- text: `Searching for rush.json starting from: ` + rushJsonSearchFolder
2093
- },
2094
- progressPercent
2095
- });
2096
- }
2097
- const rushJsonPath = (0, helpers_1.tryFindRushJsonLocation)(rushJsonSearchFolder);
2098
- if (!rushJsonPath) {
2099
- throw new Error('Unable to find rush.json in the specified folder or its parent folders:\n' +
2100
- `${rushJsonSearchFolder}\n`);
2101
- }
2102
- const monorepoRoot = path.dirname(rushJsonPath);
2103
- const rushJson = await node_core_library_1.JsonFile.loadAsync(rushJsonPath);
2104
- const { rushVersion } = rushJson;
2105
- const installRunNodeModuleFolder = path.join(monorepoRoot, `common/temp/install-run/@microsoft+rush@${rushVersion}`);
2106
- try {
2107
- // First, try to load the version of "rush-lib" that was installed by install-run-rush.js
2108
- if (onNotifyEvent) {
2109
- onNotifyEvent({
2110
- logMessage: {
2111
- kind: 'info',
2112
- text: `Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`
2113
- },
2114
- progressPercent
2115
- });
2116
- }
2117
- helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
2118
- }
2119
- catch (e1) {
2120
- let installAndRunRushStderrContent = '';
2121
- try {
2122
- const installAndRunRushJSPath = path.join(monorepoRoot, 'common/scripts/install-run-rush.js');
2123
- if (onNotifyEvent) {
2124
- onNotifyEvent({
2125
- logMessage: {
2126
- kind: 'info',
2127
- text: 'The Rush engine has not been installed yet. Invoking install-run-rush.js...'
2128
- },
2129
- progressPercent
2130
- });
2131
- }
2132
- // Start the installation
2133
- progressPercent = 0;
2134
- const installAndRunRushProcess = node_core_library_1.Executable.spawnSync('node', [installAndRunRushJSPath, '--help'], {
2135
- stdio: 'pipe'
2136
- });
2137
- installAndRunRushStderrContent = installAndRunRushProcess.stderr;
2138
- if (installAndRunRushProcess.status !== 0) {
2139
- throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to install`);
2140
- }
2141
- if (abortSignal) {
2142
- RushSdkLoader._checkForCancel(abortSignal, onNotifyEvent, progressPercent);
2143
- }
2144
- // TODO: Implement incremental progress updates
2145
- progressPercent = 90;
2146
- // Retry to load "rush-lib" after install-run-rush run
2147
- if (onNotifyEvent) {
2148
- onNotifyEvent({
2149
- logMessage: {
2150
- kind: 'debug',
2151
- text: `Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush a second time`
2152
- },
2153
- progressPercent
2154
- });
2155
- }
2156
- helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
2157
- progressPercent = 100;
2158
- }
2159
- catch (e2) {
2160
- // eslint-disable-next-line no-console
2161
- console.error(`${installAndRunRushStderrContent}`);
2162
- throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to load`);
2163
- }
2164
- }
2165
- if (helpers_1.sdkContext.rushLibModule !== undefined) {
2166
- // to track which scenario is active and how it got initialized.
2167
- global.___rush___rushLibModuleFromInstallAndRunRush = helpers_1.sdkContext.rushLibModule;
2168
- if (onNotifyEvent) {
2169
- onNotifyEvent({
2170
- logMessage: {
2171
- kind: 'debug',
2172
- text: `Loaded ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`
2173
- },
2174
- progressPercent
2175
- });
2176
- }
2177
- }
2178
- }
2179
- catch (e) {
2180
- if (onNotifyEvent) {
2181
- onNotifyEvent({
2182
- logMessage: {
2183
- kind: 'info',
2184
- text: 'The operation failed: ' + ((_b = e.message) !== null && _b !== void 0 ? _b : 'An unknown error occurred')
2185
- },
2186
- progressPercent
2187
- });
2188
- }
2189
- throw e;
2190
- }
2191
- }
2192
- }
2193
- exports.RushSdkLoader = RushSdkLoader;
2194
- //# sourceMappingURL=loader.js.map
2195
-
2196
- /***/ })
2197
-
2198
- };
2199
- ;
2200
- //# sourceMappingURL=commons.js.map