@rushstack/rush-sdk 5.131.0 → 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.
- package/dist/rush-lib.d.ts +4 -119
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/api/RushConfiguration.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib-shim/index.js +1995 -119
- package/lib-shim/index.js.map +1 -1
- package/lib-shim/loader.js +299 -174
- package/lib-shim/loader.js.map +1 -1
- package/package.json +5 -4
- package/lib/logic/LookupByPath.d.ts +0 -120
- package/lib/logic/LookupByPath.js +0 -1
- package/lib-commonjs/generate-stubs.d.ts +0 -2
- package/lib-commonjs/generate-stubs.d.ts.map +0 -1
- package/lib-commonjs/generate-stubs.js +0 -84
- package/lib-commonjs/generate-stubs.js.map +0 -1
- package/lib-commonjs/helpers.d.ts +0 -21
- package/lib-commonjs/helpers.d.ts.map +0 -1
- package/lib-commonjs/helpers.js +0 -83
- package/lib-commonjs/helpers.js.map +0 -1
- package/lib-commonjs/index.d.ts +0 -5
- package/lib-commonjs/index.d.ts.map +0 -1
- package/lib-commonjs/index.js +0 -207
- package/lib-commonjs/index.js.map +0 -1
- package/lib-commonjs/loader.d.ts +0 -86
- package/lib-commonjs/loader.d.ts.map +0 -1
- package/lib-commonjs/loader.js +0 -192
- package/lib-commonjs/loader.js.map +0 -1
- package/lib-esnext/generate-stubs.js +0 -57
- package/lib-esnext/generate-stubs.js.map +0 -1
- package/lib-esnext/helpers.js +0 -54
- package/lib-esnext/helpers.js.map +0 -1
- package/lib-esnext/index.js +0 -180
- package/lib-esnext/index.js.map +0 -1
- package/lib-esnext/loader.js +0 -165
- package/lib-esnext/loader.js.map +0 -1
- package/lib-shim/commons.js +0 -2200
- package/lib-shim/commons.js.map +0 -1
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object containing both the matched item and the start index of the remainder of the query.
|
|
3
|
-
*
|
|
4
|
-
* @beta
|
|
5
|
-
*/
|
|
6
|
-
export interface IPrefixMatch<TItem> {
|
|
7
|
-
value: TItem;
|
|
8
|
-
index: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* This class is used to associate POSIX relative paths, such as those returned by `git` commands,
|
|
12
|
-
* with entities that correspond with ancestor folders, such as Rush Projects.
|
|
13
|
-
*
|
|
14
|
-
* It is optimized for efficiently locating the nearest ancestor path with an associated value.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* const tree = new LookupByPath([['foo', 1], ['bar', 2], ['foo/bar', 3]]);
|
|
19
|
-
* tree.findChildPath('foo'); // returns 1
|
|
20
|
-
* tree.findChildPath('foo/baz'); // returns 1
|
|
21
|
-
* tree.findChildPath('baz'); // returns undefined
|
|
22
|
-
* tree.findChildPath('foo/bar/baz'); returns 3
|
|
23
|
-
* tree.findChildPath('bar/foo/bar'); returns 2
|
|
24
|
-
* ```
|
|
25
|
-
* @beta
|
|
26
|
-
*/
|
|
27
|
-
export declare class LookupByPath<TItem> {
|
|
28
|
-
/**
|
|
29
|
-
* The delimiter used to split paths
|
|
30
|
-
*/
|
|
31
|
-
readonly delimiter: string;
|
|
32
|
-
/**
|
|
33
|
-
* The root node of the tree, corresponding to the path ''
|
|
34
|
-
*/
|
|
35
|
-
private readonly _root;
|
|
36
|
-
/**
|
|
37
|
-
* Constructs a new `LookupByPath`
|
|
38
|
-
*
|
|
39
|
-
* @param entries - Initial path-value pairs to populate the tree.
|
|
40
|
-
*/
|
|
41
|
-
constructor(entries?: Iterable<[string, TItem]>, delimiter?: string);
|
|
42
|
-
/**
|
|
43
|
-
* Iterates over the segments of a serialized path.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
*
|
|
47
|
-
* `LookupByPath.iteratePathSegments('foo/bar/baz')` yields 'foo', 'bar', 'baz'
|
|
48
|
-
*
|
|
49
|
-
* `LookupByPath.iteratePathSegments('foo\\bar\\baz', '\\')` yields 'foo', 'bar', 'baz'
|
|
50
|
-
*/
|
|
51
|
-
static iteratePathSegments(serializedPath: string, delimiter?: string): Iterable<string>;
|
|
52
|
-
private static _iteratePrefixes;
|
|
53
|
-
/**
|
|
54
|
-
* Associates the value with the specified serialized path.
|
|
55
|
-
* If a value is already associated, will overwrite.
|
|
56
|
-
*
|
|
57
|
-
* @returns this, for chained calls
|
|
58
|
-
*/
|
|
59
|
-
setItem(serializedPath: string, value: TItem): this;
|
|
60
|
-
/**
|
|
61
|
-
* Associates the value with the specified path.
|
|
62
|
-
* If a value is already associated, will overwrite.
|
|
63
|
-
*
|
|
64
|
-
* @returns this, for chained calls
|
|
65
|
-
*/
|
|
66
|
-
setItemFromSegments(pathSegments: Iterable<string>, value: TItem): this;
|
|
67
|
-
/**
|
|
68
|
-
* Searches for the item associated with `childPath`, or the nearest ancestor of that path that
|
|
69
|
-
* has an associated item.
|
|
70
|
-
*
|
|
71
|
-
* @returns the found item, or `undefined` if no item was found
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* const tree = new LookupByPath([['foo', 1], ['foo/bar', 2]]);
|
|
76
|
-
* tree.findChildPath('foo/baz'); // returns 1
|
|
77
|
-
* tree.findChildPath('foo/bar/baz'); // returns 2
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
findChildPath(childPath: string): TItem | undefined;
|
|
81
|
-
/**
|
|
82
|
-
* Searches for the item for which the recorded prefix is the longest matching prefix of `query`.
|
|
83
|
-
* Obtains both the item and the length of the matched prefix, so that the remainder of the path can be
|
|
84
|
-
* extracted.
|
|
85
|
-
*
|
|
86
|
-
* @returns the found item and the length of the matched prefix, or `undefined` if no item was found
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* const tree = new LookupByPath([['foo', 1], ['foo/bar', 2]]);
|
|
91
|
-
* tree.findLongestPrefixMatch('foo/baz'); // returns { item: 1, index: 3 }
|
|
92
|
-
* tree.findLongestPrefixMatch('foo/bar/baz'); // returns { item: 2, index: 7 }
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
findLongestPrefixMatch(query: string): IPrefixMatch<TItem> | undefined;
|
|
96
|
-
/**
|
|
97
|
-
* Searches for the item associated with `childPathSegments`, or the nearest ancestor of that path that
|
|
98
|
-
* has an associated item.
|
|
99
|
-
*
|
|
100
|
-
* @returns the found item, or `undefined` if no item was found
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* const tree = new LookupByPath([['foo', 1], ['foo/bar', 2]]);
|
|
105
|
-
* tree.findChildPathFromSegments(['foo', 'baz']); // returns 1
|
|
106
|
-
* tree.findChildPathFromSegments(['foo','bar', 'baz']); // returns 2
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* Iterates through progressively longer prefixes of a given string and returns as soon
|
|
112
|
-
* as the number of candidate items that match the prefix are 1 or 0.
|
|
113
|
-
*
|
|
114
|
-
* If a match is present, returns the matched itme and the length of the matched prefix.
|
|
115
|
-
*
|
|
116
|
-
* @returns the found item, or `undefined` if no item was found
|
|
117
|
-
*/
|
|
118
|
-
private _findLongestPrefixMatch;
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=LookupByPath.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("../../lib-shim/index")._rushSdk_loadInternalModule("logic/LookupByPath");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-stubs.d.ts","sourceRoot":"","sources":["../src/generate-stubs.ts"],"names":[],"mappings":"AAkDA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB9C"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
-
// See LICENSE in the project root for license information.
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
19
|
-
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
-
if (mod && mod.__esModule) return mod;
|
|
22
|
-
var result = {};
|
|
23
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
-
__setModuleDefault(result, mod);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.runAsync = void 0;
|
|
29
|
-
const path = __importStar(require("path"));
|
|
30
|
-
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
31
|
-
function generateLibFilesRecursively(options) {
|
|
32
|
-
for (const folderItem of node_core_library_1.FileSystem.readFolderItems(options.parentSourcePath)) {
|
|
33
|
-
const sourcePath = path.join(options.parentSourcePath, folderItem.name);
|
|
34
|
-
const targetPath = path.join(options.parentTargetPath, folderItem.name);
|
|
35
|
-
if (folderItem.isDirectory()) {
|
|
36
|
-
// create destination folder
|
|
37
|
-
node_core_library_1.FileSystem.ensureEmptyFolder(targetPath);
|
|
38
|
-
generateLibFilesRecursively({
|
|
39
|
-
parentSourcePath: sourcePath,
|
|
40
|
-
parentTargetPath: targetPath,
|
|
41
|
-
parentSrcImportPathWithSlash: options.parentSrcImportPathWithSlash + folderItem.name + '/',
|
|
42
|
-
libShimIndexPath: options.libShimIndexPath
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
if (folderItem.name.endsWith('.d.ts')) {
|
|
47
|
-
node_core_library_1.FileSystem.copyFile({
|
|
48
|
-
sourcePath: sourcePath,
|
|
49
|
-
destinationPath: targetPath
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
else if (folderItem.name.endsWith('.js')) {
|
|
53
|
-
const srcImportPath = options.parentSrcImportPathWithSlash + path.parse(folderItem.name).name;
|
|
54
|
-
const shimPath = path.relative(options.parentTargetPath, options.libShimIndexPath);
|
|
55
|
-
const shimPathLiteral = JSON.stringify(node_core_library_1.Path.convertToSlashes(shimPath));
|
|
56
|
-
const srcImportPathLiteral = JSON.stringify(srcImportPath);
|
|
57
|
-
node_core_library_1.FileSystem.writeFile(targetPath,
|
|
58
|
-
// Example:
|
|
59
|
-
// module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/policy/GitEmailPolicy");
|
|
60
|
-
`module.exports = require(${shimPathLiteral})._rushSdk_loadInternalModule(${srcImportPathLiteral});`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// Entry point invoked by "runScript" action from config/heft.json
|
|
66
|
-
async function runAsync() {
|
|
67
|
-
const rushLibFolder = node_core_library_1.Import.resolvePackage({
|
|
68
|
-
baseFolderPath: __dirname,
|
|
69
|
-
packageName: '@microsoft/rush-lib'
|
|
70
|
-
});
|
|
71
|
-
const stubsTargetPath = path.resolve(__dirname, '../lib');
|
|
72
|
-
// eslint-disable-next-line no-console
|
|
73
|
-
console.log('generate-stubs: Generating stub files under: ' + stubsTargetPath);
|
|
74
|
-
generateLibFilesRecursively({
|
|
75
|
-
parentSourcePath: path.join(rushLibFolder, 'lib'),
|
|
76
|
-
parentTargetPath: stubsTargetPath,
|
|
77
|
-
parentSrcImportPathWithSlash: '',
|
|
78
|
-
libShimIndexPath: path.join(__dirname, '../lib-shim/index')
|
|
79
|
-
});
|
|
80
|
-
// eslint-disable-next-line no-console
|
|
81
|
-
console.log('generate-stubs: Completed successfully.');
|
|
82
|
-
}
|
|
83
|
-
exports.runAsync = runAsync;
|
|
84
|
-
//# sourceMappingURL=generate-stubs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-stubs.js","sourceRoot":"","sources":["../src/generate-stubs.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAE7B,oEAAwE;AAExE,SAAS,2BAA2B,CAAC,OAKpC;IACC,KAAK,MAAM,UAAU,IAAI,8BAAU,CAAC,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC9E,MAAM,UAAU,GAAW,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAChF,MAAM,UAAU,GAAW,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAEhF,IAAI,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7B,4BAA4B;YAC5B,8BAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACzC,2BAA2B,CAAC;gBAC1B,gBAAgB,EAAE,UAAU;gBAC5B,gBAAgB,EAAE,UAAU;gBAC5B,4BAA4B,EAAE,OAAO,CAAC,4BAA4B,GAAG,UAAU,CAAC,IAAI,GAAG,GAAG;gBAC1F,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;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,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC;QACjD,gBAAgB,EAAE,eAAe;QACjC,4BAA4B,EAAE,EAAE;QAChC,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC;KAC5D,CAAC,CAAC;IACH,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;AACzD,CAAC;AAjBD,4BAiBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\n\nimport { FileSystem, Import, Path } from '@rushstack/node-core-library';\n\nfunction generateLibFilesRecursively(options: {\n parentSourcePath: string;\n parentTargetPath: string;\n parentSrcImportPathWithSlash: string;\n libShimIndexPath: string;\n}): void {\n for (const folderItem of FileSystem.readFolderItems(options.parentSourcePath)) {\n const sourcePath: string = path.join(options.parentSourcePath, folderItem.name);\n const targetPath: string = path.join(options.parentTargetPath, folderItem.name);\n\n if (folderItem.isDirectory()) {\n // create destination folder\n FileSystem.ensureEmptyFolder(targetPath);\n generateLibFilesRecursively({\n parentSourcePath: sourcePath,\n parentTargetPath: targetPath,\n parentSrcImportPathWithSlash: options.parentSrcImportPathWithSlash + folderItem.name + '/',\n libShimIndexPath: options.libShimIndexPath\n });\n } else {\n if (folderItem.name.endsWith('.d.ts')) {\n FileSystem.copyFile({\n sourcePath: sourcePath,\n destinationPath: targetPath\n });\n } else if (folderItem.name.endsWith('.js')) {\n const srcImportPath: string = options.parentSrcImportPathWithSlash + path.parse(folderItem.name).name;\n const shimPath: string = path.relative(options.parentTargetPath, options.libShimIndexPath);\n const shimPathLiteral: string = JSON.stringify(Path.convertToSlashes(shimPath));\n const srcImportPathLiteral: string = JSON.stringify(srcImportPath);\n\n FileSystem.writeFile(\n targetPath,\n // Example:\n // module.exports = require(\"../../../lib-shim/index\")._rushSdk_loadInternalModule(\"logic/policy/GitEmailPolicy\");\n `module.exports = require(${shimPathLiteral})._rushSdk_loadInternalModule(${srcImportPathLiteral});`\n );\n }\n }\n }\n}\n\n// Entry point invoked by \"runScript\" action from config/heft.json\nexport async function runAsync(): Promise<void> {\n const rushLibFolder: string = Import.resolvePackage({\n baseFolderPath: __dirname,\n packageName: '@microsoft/rush-lib'\n });\n\n const stubsTargetPath: string = path.resolve(__dirname, '../lib');\n // eslint-disable-next-line no-console\n console.log('generate-stubs: Generating stub files under: ' + stubsTargetPath);\n generateLibFilesRecursively({\n parentSourcePath: path.join(rushLibFolder, 'lib'),\n parentTargetPath: stubsTargetPath,\n parentSrcImportPathWithSlash: '',\n libShimIndexPath: path.join(__dirname, '../lib-shim/index')\n });\n // eslint-disable-next-line no-console\n console.log('generate-stubs: Completed successfully.');\n}\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { EnvironmentVariableNames } from '@microsoft/rush-lib';
|
|
2
|
-
export declare const RUSH_LIB_NAME: '@microsoft/rush-lib';
|
|
3
|
-
export declare const RUSH_LIB_PATH_ENV_VAR_NAME: typeof EnvironmentVariableNames._RUSH_LIB_PATH;
|
|
4
|
-
export type RushLibModuleType = Record<string, unknown>;
|
|
5
|
-
export interface ISdkContext {
|
|
6
|
-
rushLibModule: RushLibModuleType | undefined;
|
|
7
|
-
}
|
|
8
|
-
export declare const sdkContext: ISdkContext;
|
|
9
|
-
/**
|
|
10
|
-
* Find the rush.json location and return the path, or undefined if a rush.json can't be found.
|
|
11
|
-
*
|
|
12
|
-
* @privateRemarks
|
|
13
|
-
* Keep this in sync with `RushConfiguration.tryFindRushJsonLocation`.
|
|
14
|
-
*/
|
|
15
|
-
export declare function tryFindRushJsonLocation(startingFolder: string): string | undefined;
|
|
16
|
-
export declare function _require<TResult>(moduleName: string): TResult;
|
|
17
|
-
/**
|
|
18
|
-
* Require `@microsoft/rush-lib` under the specified folder path.
|
|
19
|
-
*/
|
|
20
|
-
export declare function requireRushLibUnderFolderPath(folderPath: string): RushLibModuleType;
|
|
21
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,eAAO,MAAM,aAAa,EAAE,qBAA6C,CAAC;AAC1E,eAAO,MAAM,0BAA0B,EAAE,OAAO,wBAAwB,CAAC,cAAiC,CAAC;AAE3G,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAC9C;AAED,eAAO,MAAM,UAAU,EAAE,WAExB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAoBlF;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAU7D;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAOnF"}
|
package/lib-commonjs/helpers.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
-
// See LICENSE in the project root for license information.
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
19
|
-
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
-
if (mod && mod.__esModule) return mod;
|
|
22
|
-
var result = {};
|
|
23
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
-
__setModuleDefault(result, mod);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.requireRushLibUnderFolderPath = exports._require = exports.tryFindRushJsonLocation = exports.sdkContext = exports.RUSH_LIB_PATH_ENV_VAR_NAME = exports.RUSH_LIB_NAME = void 0;
|
|
29
|
-
const path = __importStar(require("path"));
|
|
30
|
-
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
31
|
-
exports.RUSH_LIB_NAME = '@microsoft/rush-lib';
|
|
32
|
-
exports.RUSH_LIB_PATH_ENV_VAR_NAME = '_RUSH_LIB_PATH';
|
|
33
|
-
exports.sdkContext = {
|
|
34
|
-
rushLibModule: undefined
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Find the rush.json location and return the path, or undefined if a rush.json can't be found.
|
|
38
|
-
*
|
|
39
|
-
* @privateRemarks
|
|
40
|
-
* Keep this in sync with `RushConfiguration.tryFindRushJsonLocation`.
|
|
41
|
-
*/
|
|
42
|
-
function tryFindRushJsonLocation(startingFolder) {
|
|
43
|
-
let currentFolder = startingFolder;
|
|
44
|
-
// Look upwards at parent folders until we find a folder containing rush.json
|
|
45
|
-
for (let i = 0; i < 10; ++i) {
|
|
46
|
-
const rushJsonFilename = path.join(currentFolder, 'rush.json');
|
|
47
|
-
if (node_core_library_1.FileSystem.exists(rushJsonFilename)) {
|
|
48
|
-
return rushJsonFilename;
|
|
49
|
-
}
|
|
50
|
-
const parentFolder = path.dirname(currentFolder);
|
|
51
|
-
if (parentFolder === currentFolder) {
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
currentFolder = parentFolder;
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
exports.tryFindRushJsonLocation = tryFindRushJsonLocation;
|
|
59
|
-
function _require(moduleName) {
|
|
60
|
-
if (typeof __non_webpack_require__ === 'function') {
|
|
61
|
-
// If this library has been bundled with Webpack, we need to call the real `require` function
|
|
62
|
-
// that doesn't get turned into a `__webpack_require__` statement.
|
|
63
|
-
// `__non_webpack_require__` is a Webpack macro that gets turned into a `require` statement
|
|
64
|
-
// during bundling.
|
|
65
|
-
return __non_webpack_require__(moduleName);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
return require(moduleName);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports._require = _require;
|
|
72
|
-
/**
|
|
73
|
-
* Require `@microsoft/rush-lib` under the specified folder path.
|
|
74
|
-
*/
|
|
75
|
-
function requireRushLibUnderFolderPath(folderPath) {
|
|
76
|
-
const rushLibModulePath = node_core_library_1.Import.resolveModule({
|
|
77
|
-
modulePath: exports.RUSH_LIB_NAME,
|
|
78
|
-
baseFolderPath: folderPath
|
|
79
|
-
});
|
|
80
|
-
return _require(rushLibModulePath);
|
|
81
|
-
}
|
|
82
|
-
exports.requireRushLibUnderFolderPath = requireRushLibUnderFolderPath;
|
|
83
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2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AEH,OAAO,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AACrC,CAAC;AAPD,sEAOC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\nimport { Import, FileSystem } from '@rushstack/node-core-library';\nimport type { EnvironmentVariableNames } from '@microsoft/rush-lib';\n\nexport const RUSH_LIB_NAME: '@microsoft/rush-lib' = '@microsoft/rush-lib';\nexport const RUSH_LIB_PATH_ENV_VAR_NAME: typeof EnvironmentVariableNames._RUSH_LIB_PATH = '_RUSH_LIB_PATH';\n\nexport type RushLibModuleType = Record<string, unknown>;\n\nexport interface ISdkContext {\n rushLibModule: RushLibModuleType | undefined;\n}\n\nexport const sdkContext: ISdkContext = {\n rushLibModule: undefined\n};\n\n/**\n * Find the rush.json location and return the path, or undefined if a rush.json can't be found.\n *\n * @privateRemarks\n * Keep this in sync with `RushConfiguration.tryFindRushJsonLocation`.\n */\nexport function tryFindRushJsonLocation(startingFolder: string): string | undefined {\n let currentFolder: string = startingFolder;\n\n // Look upwards at parent folders until we find a folder containing rush.json\n for (let i: number = 0; i < 10; ++i) {\n const rushJsonFilename: string = path.join(currentFolder, 'rush.json');\n\n if (FileSystem.exists(rushJsonFilename)) {\n return rushJsonFilename;\n }\n\n const parentFolder: string = path.dirname(currentFolder);\n if (parentFolder === currentFolder) {\n break;\n }\n\n currentFolder = parentFolder;\n }\n\n return undefined;\n}\n\nexport function _require<TResult>(moduleName: string): TResult {\n if (typeof __non_webpack_require__ === 'function') {\n // If this library has been bundled with Webpack, we need to call the real `require` function\n // that doesn't get turned into a `__webpack_require__` statement.\n // `__non_webpack_require__` is a Webpack macro that gets turned into a `require` statement\n // during bundling.\n return __non_webpack_require__(moduleName);\n } else {\n return require(moduleName);\n }\n}\n\n/**\n * Require `@microsoft/rush-lib` under the specified folder path.\n */\nexport function requireRushLibUnderFolderPath(folderPath: string): RushLibModuleType {\n const rushLibModulePath: string = Import.resolveModule({\n modulePath: RUSH_LIB_NAME,\n baseFolderPath: folderPath\n });\n\n return _require(rushLibModulePath);\n}\n"]}
|
package/lib-commonjs/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoOA;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAO1E"}
|
package/lib-commonjs/index.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
-
// See LICENSE in the project root for license information.
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
19
|
-
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
-
if (mod && mod.__esModule) return mod;
|
|
22
|
-
var result = {};
|
|
23
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
-
__setModuleDefault(result, mod);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var _a;
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports._rushSdk_loadInternalModule = void 0;
|
|
30
|
-
const path = __importStar(require("path"));
|
|
31
|
-
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
32
|
-
const terminal_1 = require("@rushstack/terminal");
|
|
33
|
-
const RushGlobalFolder_1 = require("@microsoft/rush-lib/lib-esnext/api/RushGlobalFolder");
|
|
34
|
-
const helpers_1 = require("./helpers");
|
|
35
|
-
const verboseEnabled = typeof process !== 'undefined' &&
|
|
36
|
-
(process.env.RUSH_SDK_DEBUG === '1' || process.env._RUSH_SDK_DEBUG === '1');
|
|
37
|
-
const terminal = new terminal_1.Terminal(new terminal_1.ConsoleTerminalProvider({
|
|
38
|
-
verboseEnabled
|
|
39
|
-
}));
|
|
40
|
-
let errorMessage = '';
|
|
41
|
-
// SCENARIO 1: Rush's PluginManager has initialized "rush-sdk" with Rush's own instance of rush-lib.
|
|
42
|
-
// The Rush host process will assign "global.___rush___rushLibModule" before loading the plugin.
|
|
43
|
-
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
44
|
-
helpers_1.sdkContext.rushLibModule =
|
|
45
|
-
global.___rush___rushLibModule ||
|
|
46
|
-
global.___rush___rushLibModuleFromEnvironment ||
|
|
47
|
-
global.___rush___rushLibModuleFromRushGlobalFolder ||
|
|
48
|
-
global.___rush___rushLibModuleFromInstallAndRunRush;
|
|
49
|
-
}
|
|
50
|
-
// SCENARIO 2: The project importing "rush-sdk" has installed its own instance of "rush-lib"
|
|
51
|
-
// as a package.json dependency. For example, this is used by the Jest tests for Rush plugins.
|
|
52
|
-
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
53
|
-
const importingPath = (_a = module === null || module === void 0 ? void 0 : module.parent) === null || _a === void 0 ? void 0 : _a.filename;
|
|
54
|
-
if (importingPath) {
|
|
55
|
-
const callerPackageFolder = node_core_library_1.PackageJsonLookup.instance.tryGetPackageFolderFor(importingPath);
|
|
56
|
-
if (callerPackageFolder !== undefined) {
|
|
57
|
-
const callerPackageJson = (0, helpers_1._require)(path.join(callerPackageFolder, 'package.json'));
|
|
58
|
-
// Does the caller properly declare a dependency on rush-lib?
|
|
59
|
-
if ((callerPackageJson.dependencies && callerPackageJson.dependencies[helpers_1.RUSH_LIB_NAME] !== undefined) ||
|
|
60
|
-
(callerPackageJson.devDependencies &&
|
|
61
|
-
callerPackageJson.devDependencies[helpers_1.RUSH_LIB_NAME] !== undefined) ||
|
|
62
|
-
(callerPackageJson.peerDependencies &&
|
|
63
|
-
callerPackageJson.peerDependencies[helpers_1.RUSH_LIB_NAME] !== undefined)) {
|
|
64
|
-
// Try to resolve rush-lib from the caller's folder
|
|
65
|
-
terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from caller package`);
|
|
66
|
-
try {
|
|
67
|
-
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(callerPackageFolder);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
// If we fail to resolve it, ignore the error
|
|
71
|
-
terminal.writeVerboseLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} from caller package`);
|
|
72
|
-
}
|
|
73
|
-
// If two different libraries invoke `rush-sdk`, and one of them provides "rush-lib"
|
|
74
|
-
// then the first version to be loaded wins. We do not support side-by-side instances of "rush-lib".
|
|
75
|
-
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
76
|
-
// to track which scenario is active and how it got initialized.
|
|
77
|
-
global.___rush___rushLibModule = helpers_1.sdkContext.rushLibModule;
|
|
78
|
-
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} from caller`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// SCENARIO 3: A tool or script has been invoked as a child process by an instance of "rush-lib" and can use the
|
|
85
|
-
// version that invoked it. In this case, use process.env._RUSH_LIB_PATH to find "rush-lib".
|
|
86
|
-
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
87
|
-
const rushLibPath = process.env[helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME];
|
|
88
|
-
if (rushLibPath) {
|
|
89
|
-
terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME} from caller package`);
|
|
90
|
-
try {
|
|
91
|
-
helpers_1.sdkContext.rushLibModule = (0, helpers_1._require)(rushLibPath);
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
// Log this as a warning, since it is unexpected to define an incorrect value of the variable.
|
|
95
|
-
terminal.writeWarningLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} via process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME}`);
|
|
96
|
-
}
|
|
97
|
-
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
98
|
-
// to track which scenario is active and how it got initialized.
|
|
99
|
-
global.___rush___rushLibModuleFromEnvironment = helpers_1.sdkContext.rushLibModule;
|
|
100
|
-
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} from process.env.${helpers_1.RUSH_LIB_PATH_ENV_VAR_NAME}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// SCENARIO 4: A standalone tool or script depends on "rush-sdk", and is meant to be used inside a monorepo folder.
|
|
105
|
-
// In this case, we can first load the rush-lib version in rush global folder. If the expected version is not installed,
|
|
106
|
-
// using install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.
|
|
107
|
-
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
108
|
-
try {
|
|
109
|
-
const rushJsonPath = (0, helpers_1.tryFindRushJsonLocation)(process.cwd());
|
|
110
|
-
if (!rushJsonPath) {
|
|
111
|
-
throw new Error('Unable to find rush.json in the current folder or its parent folders.\n' +
|
|
112
|
-
'This tool is meant to be invoked from a working directory inside a Rush repository.');
|
|
113
|
-
}
|
|
114
|
-
const monorepoRoot = path.dirname(rushJsonPath);
|
|
115
|
-
const rushJson = node_core_library_1.JsonFile.load(rushJsonPath);
|
|
116
|
-
const { rushVersion } = rushJson;
|
|
117
|
-
try {
|
|
118
|
-
terminal.writeVerboseLine(`Try to load ${helpers_1.RUSH_LIB_NAME} from rush global folder`);
|
|
119
|
-
const rushGlobalFolder = new RushGlobalFolder_1.RushGlobalFolder();
|
|
120
|
-
// The path needs to keep align with the logic inside RushVersionSelector
|
|
121
|
-
const expectedGlobalRushInstalledFolder = `${rushGlobalFolder.nodeSpecificPath}/rush-${rushVersion}`;
|
|
122
|
-
terminal.writeVerboseLine(`The expected global rush installed folder is "${expectedGlobalRushInstalledFolder}"`);
|
|
123
|
-
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(expectedGlobalRushInstalledFolder);
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
terminal.writeVerboseLine(`Failed to load ${helpers_1.RUSH_LIB_NAME} from rush global folder: ${e.message}`);
|
|
127
|
-
}
|
|
128
|
-
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
129
|
-
// to track which scenario is active and how it got initialized.
|
|
130
|
-
global.___rush___rushLibModuleFromRushGlobalFolder = helpers_1.sdkContext.rushLibModule;
|
|
131
|
-
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} installed from rush global folder`);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
const installRunNodeModuleFolder = `${monorepoRoot}/common/temp/install-run/@microsoft+rush@${rushVersion}`;
|
|
135
|
-
try {
|
|
136
|
-
// First, try to load the version of "rush-lib" that was installed by install-run-rush.js
|
|
137
|
-
terminal.writeVerboseLine(`Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`);
|
|
138
|
-
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
|
|
139
|
-
}
|
|
140
|
-
catch (e1) {
|
|
141
|
-
let installAndRunRushStderrContent = '';
|
|
142
|
-
try {
|
|
143
|
-
const installAndRunRushJSPath = `${monorepoRoot}/common/scripts/install-run-rush.js`;
|
|
144
|
-
terminal.writeLine('The Rush engine has not been installed yet. Invoking install-run-rush.js...');
|
|
145
|
-
const installAndRunRushProcess = node_core_library_1.Executable.spawnSync('node', [installAndRunRushJSPath, '--help'], {
|
|
146
|
-
stdio: 'pipe'
|
|
147
|
-
});
|
|
148
|
-
installAndRunRushStderrContent = installAndRunRushProcess.stderr;
|
|
149
|
-
if (installAndRunRushProcess.status !== 0) {
|
|
150
|
-
throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to install`);
|
|
151
|
-
}
|
|
152
|
-
// Retry to load "rush-lib" after install-run-rush run
|
|
153
|
-
terminal.writeVerboseLine(`Trying to load ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush a second time`);
|
|
154
|
-
helpers_1.sdkContext.rushLibModule = (0, helpers_1.requireRushLibUnderFolderPath)(installRunNodeModuleFolder);
|
|
155
|
-
}
|
|
156
|
-
catch (e2) {
|
|
157
|
-
// eslint-disable-next-line no-console
|
|
158
|
-
console.error(`${installAndRunRushStderrContent}`);
|
|
159
|
-
throw new Error(`The ${helpers_1.RUSH_LIB_NAME} package failed to load`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (helpers_1.sdkContext.rushLibModule !== undefined) {
|
|
163
|
-
// to track which scenario is active and how it got initialized.
|
|
164
|
-
global.___rush___rushLibModuleFromInstallAndRunRush = helpers_1.sdkContext.rushLibModule;
|
|
165
|
-
terminal.writeVerboseLine(`Loaded ${helpers_1.RUSH_LIB_NAME} installed by install-run-rush`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
catch (e) {
|
|
170
|
-
// no-catch
|
|
171
|
-
errorMessage = e.message;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (helpers_1.sdkContext.rushLibModule === undefined) {
|
|
175
|
-
// This error indicates that a project is trying to import "@rushstack/rush-sdk", but the Rush engine
|
|
176
|
-
// instance cannot be found. If you are writing Jest tests for a Rush plugin, add "@microsoft/rush-lib"
|
|
177
|
-
// to the devDependencies for your project.
|
|
178
|
-
// eslint-disable-next-line no-console
|
|
179
|
-
console.error(`Error: The @rushstack/rush-sdk package was not able to load the Rush engine:
|
|
180
|
-
${errorMessage}
|
|
181
|
-
`);
|
|
182
|
-
process.exit(1);
|
|
183
|
-
}
|
|
184
|
-
// Based on TypeScript's __exportStar()
|
|
185
|
-
for (const property in helpers_1.sdkContext.rushLibModule) {
|
|
186
|
-
if (property !== 'default' && !exports.hasOwnProperty(property)) {
|
|
187
|
-
const rushLibModuleForClosure = helpers_1.sdkContext.rushLibModule;
|
|
188
|
-
// Based on TypeScript's __createBinding()
|
|
189
|
-
Object.defineProperty(exports, property, {
|
|
190
|
-
enumerable: true,
|
|
191
|
-
get: function () {
|
|
192
|
-
return rushLibModuleForClosure[property];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Used by the .js stubs for path-based imports of `@microsoft/rush-lib` internal APIs.
|
|
199
|
-
*/
|
|
200
|
-
function _rushSdk_loadInternalModule(srcImportPath) {
|
|
201
|
-
if (!exports._RushInternals) {
|
|
202
|
-
throw new Error(`Rush version ${exports.Rush.version} does not support internal API imports via rush-sdk`);
|
|
203
|
-
}
|
|
204
|
-
return exports._RushInternals.loadModule(srcImportPath);
|
|
205
|
-
}
|
|
206
|
-
exports._rushSdk_loadInternalModule = _rushSdk_loadInternalModule;
|
|
207
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;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;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CAAC,aAAqB;IAC/D,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,gBAAgB,OAAO,CAAC,IAAI,CAAC,OAAO,qDAAqD,CAC1F,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC1D,CAAC;AAPD,kEAOC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\nimport {\n JsonFile,\n type JsonObject,\n type IPackageJson,\n PackageJsonLookup,\n Executable\n} from '@rushstack/node-core-library';\nimport { Terminal, ConsoleTerminalProvider } from '@rushstack/terminal';\nimport { RushGlobalFolder } from '@microsoft/rush-lib/lib-esnext/api/RushGlobalFolder';\nimport type { SpawnSyncReturns } from 'child_process';\nimport {\n RUSH_LIB_NAME,\n RUSH_LIB_PATH_ENV_VAR_NAME,\n type RushLibModuleType,\n _require,\n requireRushLibUnderFolderPath,\n tryFindRushJsonLocation,\n sdkContext\n} from './helpers';\n\nconst verboseEnabled: boolean =\n typeof process !== 'undefined' &&\n (process.env.RUSH_SDK_DEBUG === '1' || process.env._RUSH_SDK_DEBUG === '1');\nconst terminal: Terminal = new Terminal(\n new ConsoleTerminalProvider({\n verboseEnabled\n })\n);\n\ndeclare const global: typeof globalThis & {\n ___rush___rushLibModule?: RushLibModuleType;\n ___rush___rushLibModuleFromEnvironment?: RushLibModuleType;\n ___rush___rushLibModuleFromRushGlobalFolder?: RushLibModuleType;\n ___rush___rushLibModuleFromInstallAndRunRush?: RushLibModuleType;\n};\n\nlet errorMessage: string = '';\n\n// SCENARIO 1: Rush's PluginManager has initialized \"rush-sdk\" with Rush's own instance of rush-lib.\n// The Rush host process will assign \"global.___rush___rushLibModule\" before loading the plugin.\nif (sdkContext.rushLibModule === undefined) {\n sdkContext.rushLibModule =\n global.___rush___rushLibModule ||\n global.___rush___rushLibModuleFromEnvironment ||\n global.___rush___rushLibModuleFromRushGlobalFolder ||\n global.___rush___rushLibModuleFromInstallAndRunRush;\n}\n\n// SCENARIO 2: The project importing \"rush-sdk\" has installed its own instance of \"rush-lib\"\n// as a package.json dependency. For example, this is used by the Jest tests for Rush plugins.\nif (sdkContext.rushLibModule === undefined) {\n const importingPath: string | null | undefined = module?.parent?.filename;\n if (importingPath) {\n const callerPackageFolder: string | undefined =\n PackageJsonLookup.instance.tryGetPackageFolderFor(importingPath);\n\n if (callerPackageFolder !== undefined) {\n const callerPackageJson: IPackageJson = _require(path.join(callerPackageFolder, 'package.json'));\n\n // Does the caller properly declare a dependency on rush-lib?\n if (\n (callerPackageJson.dependencies && callerPackageJson.dependencies[RUSH_LIB_NAME] !== undefined) ||\n (callerPackageJson.devDependencies &&\n callerPackageJson.devDependencies[RUSH_LIB_NAME] !== undefined) ||\n (callerPackageJson.peerDependencies &&\n callerPackageJson.peerDependencies[RUSH_LIB_NAME] !== undefined)\n ) {\n // Try to resolve rush-lib from the caller's folder\n terminal.writeVerboseLine(`Try to load ${RUSH_LIB_NAME} from caller package`);\n try {\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(callerPackageFolder);\n } catch (error) {\n // If we fail to resolve it, ignore the error\n terminal.writeVerboseLine(`Failed to load ${RUSH_LIB_NAME} from caller package`);\n }\n\n // If two different libraries invoke `rush-sdk`, and one of them provides \"rush-lib\"\n // then the first version to be loaded wins. We do not support side-by-side instances of \"rush-lib\".\n if (sdkContext.rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModule = sdkContext.rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} from caller`);\n }\n }\n }\n }\n}\n\n// SCENARIO 3: A tool or script has been invoked as a child process by an instance of \"rush-lib\" and can use the\n// version that invoked it. In this case, use process.env._RUSH_LIB_PATH to find \"rush-lib\".\nif (sdkContext.rushLibModule === undefined) {\n const rushLibPath: string | undefined = process.env[RUSH_LIB_PATH_ENV_VAR_NAME];\n if (rushLibPath) {\n terminal.writeVerboseLine(\n `Try to load ${RUSH_LIB_NAME} from process.env.${RUSH_LIB_PATH_ENV_VAR_NAME} from caller package`\n );\n try {\n sdkContext.rushLibModule = _require(rushLibPath);\n } catch (error) {\n // Log this as a warning, since it is unexpected to define an incorrect value of the variable.\n terminal.writeWarningLine(\n `Failed to load ${RUSH_LIB_NAME} via process.env.${RUSH_LIB_PATH_ENV_VAR_NAME}`\n );\n }\n\n if (sdkContext.rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModuleFromEnvironment = sdkContext.rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} from process.env.${RUSH_LIB_PATH_ENV_VAR_NAME}`);\n }\n }\n}\n\n// SCENARIO 4: A standalone tool or script depends on \"rush-sdk\", and is meant to be used inside a monorepo folder.\n// In this case, we can first load the rush-lib version in rush global folder. If the expected version is not installed,\n// using install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.\nif (sdkContext.rushLibModule === undefined) {\n try {\n const rushJsonPath: string | undefined = tryFindRushJsonLocation(process.cwd());\n if (!rushJsonPath) {\n throw new Error(\n 'Unable to find rush.json in the current folder or its parent folders.\\n' +\n 'This tool is meant to be invoked from a working directory inside a Rush repository.'\n );\n }\n const monorepoRoot: string = path.dirname(rushJsonPath);\n\n const rushJson: JsonObject = JsonFile.load(rushJsonPath);\n const { rushVersion } = rushJson;\n\n try {\n terminal.writeVerboseLine(`Try to load ${RUSH_LIB_NAME} from rush global folder`);\n const rushGlobalFolder: RushGlobalFolder = new RushGlobalFolder();\n // The path needs to keep align with the logic inside RushVersionSelector\n const expectedGlobalRushInstalledFolder: string = `${rushGlobalFolder.nodeSpecificPath}/rush-${rushVersion}`;\n terminal.writeVerboseLine(\n `The expected global rush installed folder is \"${expectedGlobalRushInstalledFolder}\"`\n );\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(expectedGlobalRushInstalledFolder);\n } catch (e) {\n terminal.writeVerboseLine(`Failed to load ${RUSH_LIB_NAME} from rush global folder: ${e.message}`);\n }\n\n if (sdkContext.rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModuleFromRushGlobalFolder = sdkContext.rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} installed from rush global folder`);\n } else {\n const installRunNodeModuleFolder: string = `${monorepoRoot}/common/temp/install-run/@microsoft+rush@${rushVersion}`;\n\n try {\n // First, try to load the version of \"rush-lib\" that was installed by install-run-rush.js\n terminal.writeVerboseLine(`Trying to load ${RUSH_LIB_NAME} installed by install-run-rush`);\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);\n } catch (e1) {\n let installAndRunRushStderrContent: string = '';\n try {\n const installAndRunRushJSPath: string = `${monorepoRoot}/common/scripts/install-run-rush.js`;\n\n terminal.writeLine('The Rush engine has not been installed yet. Invoking install-run-rush.js...');\n\n const installAndRunRushProcess: SpawnSyncReturns<string> = Executable.spawnSync(\n 'node',\n [installAndRunRushJSPath, '--help'],\n {\n stdio: 'pipe'\n }\n );\n\n installAndRunRushStderrContent = installAndRunRushProcess.stderr;\n if (installAndRunRushProcess.status !== 0) {\n throw new Error(`The ${RUSH_LIB_NAME} package failed to install`);\n }\n\n // Retry to load \"rush-lib\" after install-run-rush run\n terminal.writeVerboseLine(\n `Trying to load ${RUSH_LIB_NAME} installed by install-run-rush a second time`\n );\n sdkContext.rushLibModule = requireRushLibUnderFolderPath(installRunNodeModuleFolder);\n } catch (e2) {\n // eslint-disable-next-line no-console\n console.error(`${installAndRunRushStderrContent}`);\n throw new Error(`The ${RUSH_LIB_NAME} package failed to load`);\n }\n }\n\n if (sdkContext.rushLibModule !== undefined) {\n // to track which scenario is active and how it got initialized.\n global.___rush___rushLibModuleFromInstallAndRunRush = sdkContext.rushLibModule;\n terminal.writeVerboseLine(`Loaded ${RUSH_LIB_NAME} installed by install-run-rush`);\n }\n }\n } catch (e) {\n // no-catch\n errorMessage = (e as Error).message;\n }\n}\n\nif (sdkContext.rushLibModule === undefined) {\n // This error indicates that a project is trying to import \"@rushstack/rush-sdk\", but the Rush engine\n // instance cannot be found. If you are writing Jest tests for a Rush plugin, add \"@microsoft/rush-lib\"\n // to the devDependencies for your project.\n // eslint-disable-next-line no-console\n console.error(`Error: The @rushstack/rush-sdk package was not able to load the Rush engine:\n${errorMessage}\n`);\n process.exit(1);\n}\n\n// Based on TypeScript's __exportStar()\nfor (const property in sdkContext.rushLibModule) {\n if (property !== 'default' && !exports.hasOwnProperty(property)) {\n const rushLibModuleForClosure: RushLibModuleType = sdkContext.rushLibModule;\n\n // Based on TypeScript's __createBinding()\n Object.defineProperty(exports, property, {\n enumerable: true,\n get: function () {\n return rushLibModuleForClosure[property];\n }\n });\n }\n}\n\n/**\n * Used by the .js stubs for path-based imports of `@microsoft/rush-lib` internal APIs.\n */\nexport function _rushSdk_loadInternalModule(srcImportPath: string): unknown {\n if (!exports._RushInternals) {\n throw new Error(\n `Rush version ${exports.Rush.version} does not support internal API imports via rush-sdk`\n );\n }\n return exports._RushInternals.loadModule(srcImportPath);\n}\n"]}
|