123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- "use strict";
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- });
- var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- const path = __importStar(require("path"));
- const fs = __importStar(require("fs"));
- const install_run_1 = require("./install-run");
- const PACKAGE_NAME = '@microsoft/rush';
- const RUSH_PREVIEW_VERSION = 'RUSH_PREVIEW_VERSION';
- const INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE = 'INSTALL_RUN_RUSH_LOCKFILE_PATH';
- function _getRushVersion(logger) {
- const rushPreviewVersion = process.env[RUSH_PREVIEW_VERSION];
- if (rushPreviewVersion !== undefined) {
- logger.info(`Using Rush version from environment variable ${RUSH_PREVIEW_VERSION}=${rushPreviewVersion}`);
- return rushPreviewVersion;
- }
- const rushJsonFolder = (0, install_run_1.findRushJsonFolder)();
- const rushJsonPath = path.join(rushJsonFolder, install_run_1.RUSH_JSON_FILENAME);
- try {
- const rushJsonContents = fs.readFileSync(rushJsonPath, 'utf-8');
-
-
- const rushJsonMatches = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/);
- return rushJsonMatches[1];
- }
- catch (e) {
- throw new Error(`Unable to determine the required version of Rush from rush.json (${rushJsonFolder}). ` +
- "The 'rushVersion' field is either not assigned in rush.json or was specified " +
- 'using an unexpected syntax.');
- }
- }
- function _run() {
- const [nodePath , scriptPath , ...packageBinArgs ] = process.argv;
-
-
- const scriptName = path.basename(scriptPath);
- const bin = scriptName.toLowerCase() === 'install-run-rushx.js' ? 'rushx' : 'rush';
- if (!nodePath || !scriptPath) {
- throw new Error('Unexpected exception: could not detect node path or script path');
- }
- let commandFound = false;
- let logger = { info: console.log, error: console.error };
- for (const arg of packageBinArgs) {
- if (arg === '-q' || arg === '--quiet') {
-
-
-
-
-
-
- logger = {
- info: () => { },
- error: console.error
- };
- }
- else if (!arg.startsWith('-') || arg === '-h' || arg === '--help') {
-
-
- commandFound = true;
- }
- }
- if (!commandFound) {
- console.log(`Usage: ${scriptName} <command> [args...]`);
- if (scriptName === 'install-run-rush.js') {
- console.log(`Example: ${scriptName} build --to myproject`);
- }
- else {
- console.log(`Example: ${scriptName} custom-command`);
- }
- process.exit(1);
- }
- (0, install_run_1.runWithErrorAndStatusCode)(logger, () => {
- const version = _getRushVersion(logger);
- logger.info(`The rush.json configuration requests Rush version ${version}`);
- 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 (0, install_run_1.installAndRun)(logger, PACKAGE_NAME, version, bin, packageBinArgs, lockFilePath);
- });
- }
- _run();
|