UNPKG

4.2 kBJavaScriptView Raw
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.
4Object.defineProperty(exports, "__esModule", { value: true });
5// We're using a path-based import here to minimize the amount of code that is evaluated before
6// we check to see if the Node.js version is too old. If, for whatever reason, Rush crashes with
7// an old Node.js version when evaluating one of the more complex imports, we'll at least
8// shown a meaningful error message.
9const NodeJsCompatibility_1 = require("@microsoft/rush-lib/lib/logic/NodeJsCompatibility");
10if (NodeJsCompatibility_1.NodeJsCompatibility.warnAboutVersionTooOld()) {
11 // We are on an ancient version of Node.js that is known not to work with Rush
12 process.exit(1);
13}
14const alreadyReportedNodeTooNewError = NodeJsCompatibility_1.NodeJsCompatibility.warnAboutVersionTooNew({
15 isRushLib: false,
16 alreadyReportedNodeTooNewError: false
17});
18const colors = require("colors");
19const os = require("os");
20const semver = require("semver");
21const node_core_library_1 = require("@microsoft/node-core-library");
22const rushLib = require("@microsoft/rush-lib");
23const RushCommandSelector_1 = require("./RushCommandSelector");
24const RushVersionSelector_1 = require("./RushVersionSelector");
25const MinimalRushConfiguration_1 = require("./MinimalRushConfiguration");
26// Load the configuration
27const configuration = MinimalRushConfiguration_1.MinimalRushConfiguration.loadFromDefaultLocation();
28const currentPackageVersion = node_core_library_1.PackageJsonLookup.loadOwnPackageJson(__dirname).version;
29let rushVersionToLoad = undefined;
30const previewVersion = process.env["RUSH_PREVIEW_VERSION" /* RUSH_PREVIEW_VERSION */];
31if (previewVersion) {
32 if (!semver.valid(previewVersion, false)) {
33 console.error(colors.red(`Invalid value for RUSH_PREVIEW_VERSION environment variable: "${previewVersion}"`));
34 process.exit(1);
35 }
36 rushVersionToLoad = previewVersion;
37 const lines = [];
38 lines.push(`*********************************************************************`, `* WARNING! THE "RUSH_PREVIEW_VERSION" ENVIRONMENT VARIABLE IS SET. *`, `* *`, `* You are previewing Rush version: ${node_core_library_1.Text.padEnd(previewVersion, 25)} *`);
39 if (configuration) {
40 lines.push(`* The rush.json configuration asks for: ${node_core_library_1.Text.padEnd(configuration.rushVersion, 25)} *`);
41 }
42 lines.push(`* *`, `* To restore the normal behavior, unset the RUSH_PREVIEW_VERSION *`, `* environment variable. *`, `*********************************************************************`);
43 console.error(lines
44 .map(line => colors.black(colors.bgYellow(line)))
45 .join(os.EOL));
46}
47else if (configuration) {
48 rushVersionToLoad = configuration.rushVersion;
49}
50// If we are previewing an older Rush that doesn't understand the RUSH_PREVIEW_VERSION variable,
51// then unset it.
52if (rushVersionToLoad && semver.lt(rushVersionToLoad, '5.0.0-dev.18')) {
53 delete process.env["RUSH_PREVIEW_VERSION" /* RUSH_PREVIEW_VERSION */];
54}
55// Rush is "managed" if its version and configuration are dictated by a repo's rush.json
56const isManaged = !!configuration;
57const launchOptions = { isManaged, alreadyReportedNodeTooNewError };
58// If we're inside a repo folder, and it's requesting a different version, then use the RushVersionManager to
59// install it
60if (rushVersionToLoad && rushVersionToLoad !== currentPackageVersion) {
61 const versionSelector = new RushVersionSelector_1.RushVersionSelector(currentPackageVersion);
62 versionSelector.ensureRushVersionInstalled(rushVersionToLoad, configuration, launchOptions)
63 .catch((error) => {
64 console.log(colors.red('Error: ' + error.message));
65 });
66}
67else {
68 // Otherwise invoke the rush-lib that came with this rush package
69 RushCommandSelector_1.RushCommandSelector.execute(currentPackageVersion, rushLib, launchOptions);
70}
71//# sourceMappingURL=start.js.map
\No newline at end of file