2018-07-13 03:53:09 +03:00
|
|
|
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
|
2018-06-13 22:07:14 +03:00
|
|
|
//
|
2018-06-14 03:23:55 +03:00
|
|
|
// This script is intended for usage in an automated build environment where the Rush command may not have
|
|
|
|
// been preinstalled, or may have an unpredictable version. This script will automatically install the version of Rush
|
|
|
|
// specified in the rush.json configuration file (if not already installed), and then pass a command-line to it.
|
2018-07-13 03:53:09 +03:00
|
|
|
// An example usage would be:
|
|
|
|
//
|
|
|
|
// node common/scripts/install-run-rush.js install
|
|
|
|
//
|
|
|
|
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
|
2024-04-15 23:28:17 +03:00
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
|
|
// See the @microsoft/rush package's LICENSE file for details.
|
2023-01-28 06:31:22 +03:00
|
|
|
|
|
|
|
/******/ (() => { // webpackBootstrap
|
|
|
|
/******/ "use strict";
|
|
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
|
|
|
|
/***/ 657147:
|
|
|
|
/*!*********************!*\
|
|
|
|
!*** external "fs" ***!
|
|
|
|
\*********************/
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("fs");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 371017:
|
|
|
|
/*!***********************!*\
|
|
|
|
!*** external "path" ***!
|
|
|
|
\***********************/
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("path");
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
|
|
/******/ });
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ // The module cache
|
|
|
|
/******/ var __webpack_module_cache__ = {};
|
|
|
|
/******/
|
|
|
|
/******/ // The require function
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
/******/ // Check if module is in cache
|
|
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
|
|
/******/ if (cachedModule !== undefined) {
|
|
|
|
/******/ return cachedModule.exports;
|
|
|
|
/******/ }
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
|
|
/******/ // no module.id needed
|
|
|
|
/******/ // no module.loaded needed
|
|
|
|
/******/ exports: {}
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/ // Execute the module function
|
|
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
|
|
/******/
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
/******/ return module.exports;
|
|
|
|
/******/ }
|
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ /* webpack/runtime/compat get default export */
|
|
|
|
/******/ (() => {
|
|
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
|
|
/******/ __webpack_require__.n = (module) => {
|
|
|
|
/******/ var getter = module && module.__esModule ?
|
|
|
|
/******/ () => (module['default']) :
|
|
|
|
/******/ () => (module);
|
|
|
|
/******/ __webpack_require__.d(getter, { a: getter });
|
|
|
|
/******/ return getter;
|
|
|
|
/******/ };
|
|
|
|
/******/ })();
|
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/define property getters */
|
|
|
|
/******/ (() => {
|
|
|
|
/******/ // define getter functions for harmony exports
|
|
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
|
|
|
/******/ for(var key in definition) {
|
|
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
|
|
/******/ }
|
|
|
|
/******/ }
|
|
|
|
/******/ };
|
|
|
|
/******/ })();
|
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
|
|
/******/ (() => {
|
|
|
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
|
|
/******/ })();
|
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
|
|
/******/ (() => {
|
|
|
|
/******/ // define __esModule on exports
|
|
|
|
/******/ __webpack_require__.r = (exports) => {
|
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
/******/ }
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
/******/ };
|
|
|
|
/******/ })();
|
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
|
|
|
var __webpack_exports__ = {};
|
|
|
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
|
|
(() => {
|
|
|
|
/*!************************************************!*\
|
|
|
|
!*** ./lib-esnext/scripts/install-run-rush.js ***!
|
|
|
|
\************************************************/
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path */ 371017);
|
|
|
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fs */ 657147);
|
|
|
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
2023-09-27 04:48:58 +03:00
|
|
|
// See LICENSE in the project root for license information.
|
|
|
|
/* eslint-disable no-console */
|
2023-01-28 06:31:22 +03:00
|
|
|
|
|
|
|
|
|
|
|
const { installAndRun, findRushJsonFolder, RUSH_JSON_FILENAME, runWithErrorAndStatusCode } = require('./install-run');
|
2018-06-13 22:07:14 +03:00
|
|
|
const PACKAGE_NAME = '@microsoft/rush';
|
2019-09-12 00:51:24 +03:00
|
|
|
const RUSH_PREVIEW_VERSION = 'RUSH_PREVIEW_VERSION';
|
2023-01-28 06:31:22 +03:00
|
|
|
const INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE = 'INSTALL_RUN_RUSH_LOCKFILE_PATH';
|
2022-04-09 05:36:28 +03:00
|
|
|
function _getRushVersion(logger) {
|
2019-09-12 00:51:24 +03:00
|
|
|
const rushPreviewVersion = process.env[RUSH_PREVIEW_VERSION];
|
|
|
|
if (rushPreviewVersion !== undefined) {
|
2022-04-09 05:36:28 +03:00
|
|
|
logger.info(`Using Rush version from environment variable ${RUSH_PREVIEW_VERSION}=${rushPreviewVersion}`);
|
2019-09-12 00:51:24 +03:00
|
|
|
return rushPreviewVersion;
|
|
|
|
}
|
2023-01-28 06:31:22 +03:00
|
|
|
const rushJsonFolder = findRushJsonFolder();
|
|
|
|
const rushJsonPath = path__WEBPACK_IMPORTED_MODULE_0__.join(rushJsonFolder, RUSH_JSON_FILENAME);
|
2018-06-13 22:07:14 +03:00
|
|
|
try {
|
2023-01-28 06:31:22 +03:00
|
|
|
const rushJsonContents = fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync(rushJsonPath, 'utf-8');
|
2018-06-13 22:07:14 +03:00
|
|
|
// Use a regular expression to parse out the rushVersion value because rush.json supports comments,
|
|
|
|
// but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script.
|
|
|
|
const rushJsonMatches = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/);
|
|
|
|
return rushJsonMatches[1];
|
|
|
|
}
|
|
|
|
catch (e) {
|
2024-02-27 09:25:36 +03:00
|
|
|
throw new Error(`Unable to determine the required version of Rush from ${RUSH_JSON_FILENAME} (${rushJsonFolder}). ` +
|
|
|
|
`The 'rushVersion' field is either not assigned in ${RUSH_JSON_FILENAME} or was specified ` +
|
2018-06-13 22:07:14 +03:00
|
|
|
'using an unexpected syntax.');
|
|
|
|
}
|
|
|
|
}
|
2023-01-28 06:31:22 +03:00
|
|
|
function _getBin(scriptName) {
|
|
|
|
switch (scriptName.toLowerCase()) {
|
|
|
|
case 'install-run-rush-pnpm.js':
|
|
|
|
return 'rush-pnpm';
|
|
|
|
case 'install-run-rushx.js':
|
|
|
|
return 'rushx';
|
|
|
|
default:
|
|
|
|
return 'rush';
|
|
|
|
}
|
|
|
|
}
|
2019-09-12 00:51:24 +03:00
|
|
|
function _run() {
|
2020-06-11 03:07:53 +03:00
|
|
|
const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv;
|
2019-09-12 00:51:24 +03:00
|
|
|
// Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the
|
|
|
|
// appropriate binary inside the rush package to run
|
2023-01-28 06:31:22 +03:00
|
|
|
const scriptName = path__WEBPACK_IMPORTED_MODULE_0__.basename(scriptPath);
|
|
|
|
const bin = _getBin(scriptName);
|
2018-11-09 18:22:50 +03:00
|
|
|
if (!nodePath || !scriptPath) {
|
|
|
|
throw new Error('Unexpected exception: could not detect node path or script path');
|
|
|
|
}
|
2022-04-09 05:36:28 +03:00
|
|
|
let commandFound = false;
|
|
|
|
let logger = { info: console.log, error: console.error };
|
|
|
|
for (const arg of packageBinArgs) {
|
|
|
|
if (arg === '-q' || arg === '--quiet') {
|
|
|
|
// The -q/--quiet flag is supported by both `rush` and `rushx`, and will suppress
|
|
|
|
// any normal informational/diagnostic information printed during startup.
|
|
|
|
//
|
|
|
|
// To maintain the same user experience, the install-run* scripts pass along this
|
|
|
|
// flag but also use it to suppress any diagnostic information normally printed
|
|
|
|
// to stdout.
|
|
|
|
logger = {
|
|
|
|
info: () => { },
|
|
|
|
error: console.error
|
|
|
|
};
|
|
|
|
}
|
2022-04-23 03:25:31 +03:00
|
|
|
else if (!arg.startsWith('-') || arg === '-h' || arg === '--help') {
|
|
|
|
// We either found something that looks like a command (i.e. - doesn't start with a "-"),
|
|
|
|
// or we found the -h/--help flag, which can be run without a command
|
2022-04-09 05:36:28 +03:00
|
|
|
commandFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!commandFound) {
|
2019-09-12 00:51:24 +03:00
|
|
|
console.log(`Usage: ${scriptName} <command> [args...]`);
|
2023-01-28 06:31:22 +03:00
|
|
|
if (scriptName === 'install-run-rush-pnpm.js') {
|
|
|
|
console.log(`Example: ${scriptName} pnpm-command`);
|
|
|
|
}
|
|
|
|
else if (scriptName === 'install-run-rush.js') {
|
2019-09-12 00:51:24 +03:00
|
|
|
console.log(`Example: ${scriptName} build --to myproject`);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log(`Example: ${scriptName} custom-command`);
|
|
|
|
}
|
2018-06-14 03:23:55 +03:00
|
|
|
process.exit(1);
|
|
|
|
}
|
2023-01-28 06:31:22 +03:00
|
|
|
runWithErrorAndStatusCode(logger, () => {
|
2022-04-09 05:36:28 +03:00
|
|
|
const version = _getRushVersion(logger);
|
2024-02-27 09:25:36 +03:00
|
|
|
logger.info(`The ${RUSH_JSON_FILENAME} configuration requests Rush version ${version}`);
|
2023-01-28 06:31:22 +03:00
|
|
|
const lockFilePath = process.env[INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE];
|
|
|
|
if (lockFilePath) {
|
|
|
|
logger.info(`Found ${INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE}="${lockFilePath}", installing with lockfile.`);
|
|
|
|
}
|
|
|
|
return installAndRun(logger, PACKAGE_NAME, version, bin, packageBinArgs, lockFilePath);
|
2018-06-13 22:07:14 +03:00
|
|
|
});
|
|
|
|
}
|
2019-09-12 00:51:24 +03:00
|
|
|
_run();
|
2023-01-28 06:31:22 +03:00
|
|
|
//# sourceMappingURL=install-run-rush.js.map
|
|
|
|
})();
|
|
|
|
|
|
|
|
module.exports = __webpack_exports__;
|
|
|
|
/******/ })()
|
|
|
|
;
|
2018-08-30 21:43:36 +03:00
|
|
|
//# sourceMappingURL=install-run-rush.js.map
|