1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const NodeJsCompatibility_1 = require("@microsoft/rush-lib/lib/logic/NodeJsCompatibility");
|
10 | if (NodeJsCompatibility_1.NodeJsCompatibility.warnAboutVersionTooOld()) {
|
11 |
|
12 | process.exit(1);
|
13 | }
|
14 | const alreadyReportedNodeTooNewError = NodeJsCompatibility_1.NodeJsCompatibility.warnAboutVersionTooNew({
|
15 | isRushLib: false,
|
16 | alreadyReportedNodeTooNewError: false
|
17 | });
|
18 | const colors = require("colors");
|
19 | const os = require("os");
|
20 | const semver = require("semver");
|
21 | const node_core_library_1 = require("@microsoft/node-core-library");
|
22 | const rushLib = require("@microsoft/rush-lib");
|
23 | const RushCommandSelector_1 = require("./RushCommandSelector");
|
24 | const RushVersionSelector_1 = require("./RushVersionSelector");
|
25 | const MinimalRushConfiguration_1 = require("./MinimalRushConfiguration");
|
26 |
|
27 | const configuration = MinimalRushConfiguration_1.MinimalRushConfiguration.loadFromDefaultLocation();
|
28 | const currentPackageVersion = node_core_library_1.PackageJsonLookup.loadOwnPackageJson(__dirname).version;
|
29 | let rushVersionToLoad = undefined;
|
30 | const previewVersion = process.env["RUSH_PREVIEW_VERSION" ];
|
31 | if (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 | }
|
47 | else if (configuration) {
|
48 | rushVersionToLoad = configuration.rushVersion;
|
49 | }
|
50 |
|
51 |
|
52 | if (rushVersionToLoad && semver.lt(rushVersionToLoad, '5.0.0-dev.18')) {
|
53 | delete process.env["RUSH_PREVIEW_VERSION" ];
|
54 | }
|
55 |
|
56 | const isManaged = !!configuration;
|
57 | const launchOptions = { isManaged, alreadyReportedNodeTooNewError };
|
58 |
|
59 |
|
60 | if (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 | }
|
67 | else {
|
68 |
|
69 | RushCommandSelector_1.RushCommandSelector.execute(currentPackageVersion, rushLib, launchOptions);
|
70 | }
|
71 |
|
\ | No newline at end of file |