@rushstack/rush-sdk 0.0.0 → 5.57.0-dev.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/LICENSE +24 -0
- package/README.md +26 -0
- package/dist/rush-lib.d.ts +2700 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +90 -0
- package/lib/index.js.map +1 -0
- package/package.json +29 -3
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
7
|
+
}) : (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
o[k2] = m[k];
|
|
10
|
+
}));
|
|
11
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
12
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
13
|
+
}) : function(o, v) {
|
|
14
|
+
o["default"] = v;
|
|
15
|
+
});
|
|
16
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
17
|
+
if (mod && mod.__esModule) return mod;
|
|
18
|
+
var result = {};
|
|
19
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
20
|
+
__setModuleDefault(result, mod);
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
var _a;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const path = __importStar(require("path"));
|
|
26
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
27
|
+
const RUSH_LIB_NAME = '@microsoft/rush-lib';
|
|
28
|
+
// SCENARIO 1: Rush's PluginManager has initialized "rush-sdk" with Rush's own instance of rush-lib.
|
|
29
|
+
// The Rush host process will assign "global.___rush___rushLibModule" before loading the plugin.
|
|
30
|
+
let rushLibModule = global.___rush___rushLibModule;
|
|
31
|
+
// SCENARIO 2: The project importing "rush-sdk" has installed its own instance of "rush-lib"
|
|
32
|
+
// as a package.json dependency. For example, this is used by the Jest tests for Rush plugins.
|
|
33
|
+
if (rushLibModule === undefined) {
|
|
34
|
+
const importingPath = (_a = module === null || module === void 0 ? void 0 : module.parent) === null || _a === void 0 ? void 0 : _a.filename;
|
|
35
|
+
if (importingPath !== undefined) {
|
|
36
|
+
const callerPackageFolder = node_core_library_1.PackageJsonLookup.instance.tryGetPackageFolderFor(importingPath);
|
|
37
|
+
if (callerPackageFolder !== undefined) {
|
|
38
|
+
const callerPackageJson = require(path.join(callerPackageFolder, 'package.json'));
|
|
39
|
+
// Does the caller properly declare a dependency on rush-lib?
|
|
40
|
+
if ((callerPackageJson.dependencies && callerPackageJson.dependencies[RUSH_LIB_NAME] !== undefined) ||
|
|
41
|
+
(callerPackageJson.devDependencies &&
|
|
42
|
+
callerPackageJson.devDependencies[RUSH_LIB_NAME] !== undefined) ||
|
|
43
|
+
(callerPackageJson.peerDependencies &&
|
|
44
|
+
callerPackageJson.peerDependencies[RUSH_LIB_NAME] !== undefined)) {
|
|
45
|
+
// Try to resolve rush-lib from the caller's folder
|
|
46
|
+
try {
|
|
47
|
+
const rushLibModulePath = node_core_library_1.Import.resolveModule({
|
|
48
|
+
modulePath: RUSH_LIB_NAME,
|
|
49
|
+
baseFolderPath: callerPackageFolder
|
|
50
|
+
});
|
|
51
|
+
rushLibModule = require(rushLibModulePath);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
// If we fail to resolve it, ignore the error
|
|
55
|
+
}
|
|
56
|
+
// If two different libraries invoke `rush-sdk`, and one of them provides "rush-lib"
|
|
57
|
+
// then the first version to be loaded wins. We do not support side-by-side instances of "rush-lib".
|
|
58
|
+
if (rushLibModule !== undefined) {
|
|
59
|
+
// TODO: When we implement Scenario 3, we should also add some diagnostic state
|
|
60
|
+
// to track which scenario is active and how it got initialized.
|
|
61
|
+
global.___rush___rushLibModule = rushLibModule;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// SCENARIO 3: A tool or script depends on "rush-sdk", and is meant to be used inside a monorepo folder.
|
|
68
|
+
// In this case, we can use install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.
|
|
69
|
+
//
|
|
70
|
+
// NOT IMPLEMENTED YET
|
|
71
|
+
if (rushLibModule === undefined) {
|
|
72
|
+
// This error indicates that a project is trying to import "@rushstack/rush-sdk", but the Rush engine
|
|
73
|
+
// instance cannot be found. If you are writing Jest tests for a Rush plugin, add "@microsoft/rush-lib"
|
|
74
|
+
// to the devDependencies for your project.
|
|
75
|
+
throw new Error('The "@rushstack/rush-sdk" package context has not been initialized.');
|
|
76
|
+
}
|
|
77
|
+
// Based on TypeScript's __exportStar()
|
|
78
|
+
for (const property in rushLibModule) {
|
|
79
|
+
if (property !== 'default' && !exports.hasOwnProperty(property)) {
|
|
80
|
+
const rushLibModuleForClosure = rushLibModule;
|
|
81
|
+
// Based on TypeScript's __createBinding()
|
|
82
|
+
Object.defineProperty(exports, property, {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return rushLibModuleForClosure[property];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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AC,OAAO,KAAK,EAAE;oBACd,6CAA6C;iBAC9C;gBAED,oFAAoF;gBACpF,qGAAqG;gBACrG,IAAI,aAAa,KAAK,SAAS,EAAE;oBAC/B,+EAA+E;oBAC/E,gEAAgE;oBAChE,MAAM,CAAC,uBAAuB,GAAG,aAAa,CAAC;iBAChD;aACF;SACF;KACF;CACF;AAED,yGAAyG;AACzG,4GAA4G;AAC5G,EAAE;AACF,sBAAsB;AACtB,IAAI,aAAa,KAAK,SAAS,EAAE;IAC/B,qGAAqG;IACrG,wGAAwG;IACxG,2CAA2C;IAC3C,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;CACxF;AAED,uCAAuC;AACvC,KAAK,MAAM,QAAQ,IAAI,aAAa,EAAE;IACpC,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;QAC/D,MAAM,uBAAuB,GAAsB,aAAa,CAAC;QAEjE,0CAA0C;QAC1C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE;YACvC,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE;gBACH,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC,CAAC;KACJ;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport * as path from 'path';\r\nimport { Import, IPackageJson, PackageJsonLookup } from '@rushstack/node-core-library';\r\n\r\nconst RUSH_LIB_NAME: string = '@microsoft/rush-lib';\r\n\r\ntype RushLibModuleType = Record<string, unknown>;\r\ndeclare const global: NodeJS.Global &\r\n typeof globalThis & {\r\n ___rush___rushLibModule?: RushLibModuleType;\r\n };\r\n\r\n// SCENARIO 1: Rush's PluginManager has initialized \"rush-sdk\" with Rush's own instance of rush-lib.\r\n// The Rush host process will assign \"global.___rush___rushLibModule\" before loading the plugin.\r\nlet rushLibModule: RushLibModuleType | undefined = global.___rush___rushLibModule;\r\n\r\n// SCENARIO 2: The project importing \"rush-sdk\" has installed its own instance of \"rush-lib\"\r\n// as a package.json dependency. For example, this is used by the Jest tests for Rush plugins.\r\nif (rushLibModule === undefined) {\r\n const importingPath: string | undefined = module?.parent?.filename;\r\n if (importingPath !== undefined) {\r\n const callerPackageFolder: string | undefined =\r\n PackageJsonLookup.instance.tryGetPackageFolderFor(importingPath);\r\n\r\n if (callerPackageFolder !== undefined) {\r\n const callerPackageJson: IPackageJson = require(path.join(callerPackageFolder, 'package.json'));\r\n\r\n // Does the caller properly declare a dependency on rush-lib?\r\n if (\r\n (callerPackageJson.dependencies && callerPackageJson.dependencies[RUSH_LIB_NAME] !== undefined) ||\r\n (callerPackageJson.devDependencies &&\r\n callerPackageJson.devDependencies[RUSH_LIB_NAME] !== undefined) ||\r\n (callerPackageJson.peerDependencies &&\r\n callerPackageJson.peerDependencies[RUSH_LIB_NAME] !== undefined)\r\n ) {\r\n // Try to resolve rush-lib from the caller's folder\r\n try {\r\n const rushLibModulePath: string = Import.resolveModule({\r\n modulePath: RUSH_LIB_NAME,\r\n baseFolderPath: callerPackageFolder\r\n });\r\n\r\n rushLibModule = require(rushLibModulePath);\r\n } catch (error) {\r\n // If we fail to resolve it, ignore the error\r\n }\r\n\r\n // If two different libraries invoke `rush-sdk`, and one of them provides \"rush-lib\"\r\n // then the first version to be loaded wins. We do not support side-by-side instances of \"rush-lib\".\r\n if (rushLibModule !== undefined) {\r\n // TODO: When we implement Scenario 3, we should also add some diagnostic state\r\n // to track which scenario is active and how it got initialized.\r\n global.___rush___rushLibModule = rushLibModule;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n// SCENARIO 3: A tool or script depends on \"rush-sdk\", and is meant to be used inside a monorepo folder.\r\n// In this case, we can use install-run-rush.js to obtain the appropriate rush-lib version for the monorepo.\r\n//\r\n// NOT IMPLEMENTED YET\r\nif (rushLibModule === undefined) {\r\n // This error indicates that a project is trying to import \"@rushstack/rush-sdk\", but the Rush engine\r\n // instance cannot be found. If you are writing Jest tests for a Rush plugin, add \"@microsoft/rush-lib\"\r\n // to the devDependencies for your project.\r\n throw new Error('The \"@rushstack/rush-sdk\" package context has not been initialized.');\r\n}\r\n\r\n// Based on TypeScript's __exportStar()\r\nfor (const property in rushLibModule) {\r\n if (property !== 'default' && !exports.hasOwnProperty(property)) {\r\n const rushLibModuleForClosure: RushLibModuleType = rushLibModule;\r\n\r\n // Based on TypeScript's __createBinding()\r\n Object.defineProperty(exports, property, {\r\n enumerable: true,\r\n get: function () {\r\n return rushLibModuleForClosure[property];\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"name": "@rushstack/rush-sdk",
|
|
3
|
+
"version": "5.57.0-dev.1",
|
|
4
|
+
"description": "An API for interacting with the Rush engine",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/microsoft/rushstack.git",
|
|
8
|
+
"directory": "apps/rush-sdk"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://rushjs.io",
|
|
11
|
+
"main": "lib/index.js",
|
|
12
|
+
"typings": "dist/rush-lib.d.ts",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@rushstack/node-core-library": "3.43.2",
|
|
16
|
+
"@types/node-fetch": "1.6.9",
|
|
17
|
+
"tapable": "2.2.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@microsoft/rush-lib": "5.57.0-dev.1",
|
|
21
|
+
"@rushstack/eslint-config": "2.4.5",
|
|
22
|
+
"@rushstack/heft": "0.42.3",
|
|
23
|
+
"@rushstack/heft-node-rig": "1.2.31",
|
|
24
|
+
"@types/heft-jest": "1.0.1",
|
|
25
|
+
"@types/node": "12.20.24",
|
|
26
|
+
"@types/semver": "7.3.5"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "heft test --clean"
|
|
30
|
+
}
|
|
5
31
|
}
|