UNPKG

2.69 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 });
5const path = require("path");
6const node_core_library_1 = require("@microsoft/node-core-library");
7const rush_lib_1 = require("@microsoft/rush-lib");
8const RushConstants_1 = require("@microsoft/rush-lib/lib/logic/RushConstants");
9/**
10 * Represents a minimal subset of the rush.json configuration file. It provides the information necessary to
11 * decide which version of Rush should be installed/used.
12 */
13class MinimalRushConfiguration {
14 constructor(minimalRushConfigurationJson, rushJsonFilename) {
15 this._rushVersion = minimalRushConfigurationJson.rushVersion || minimalRushConfigurationJson.rushMinimumVersion;
16 this._commonRushConfigFolder = path.join(path.dirname(rushJsonFilename), RushConstants_1.RushConstants.commonFolderName, 'config', 'rush');
17 }
18 static loadFromDefaultLocation() {
19 const rushJsonLocation = rush_lib_1.RushConfiguration.tryFindRushJsonLocation({ showVerbose: true });
20 if (rushJsonLocation) {
21 return MinimalRushConfiguration._loadFromConfigurationFile(rushJsonLocation);
22 }
23 else {
24 return undefined;
25 }
26 }
27 static _loadFromConfigurationFile(rushJsonFilename) {
28 try {
29 const minimalRushConfigurationJson = node_core_library_1.JsonFile.load(rushJsonFilename);
30 return new MinimalRushConfiguration(minimalRushConfigurationJson, rushJsonFilename);
31 }
32 catch (e) {
33 return undefined;
34 }
35 }
36 /**
37 * The version of rush specified by the rushVersion property of the rush.json configuration file. If the
38 * rushVersion property is not specified, this falls back to the rushMinimumVersion property. This should be
39 * a semver style version number like "4.0.0"
40 */
41 get rushVersion() {
42 return this._rushVersion;
43 }
44 /**
45 * The folder where Rush's additional config files are stored. This folder is always a
46 * subfolder called "config\rush" inside the common folder. (The "common\config" folder
47 * is reserved for configuration files used by other tools.) To avoid confusion or mistakes,
48 * Rush will report an error if this this folder contains any unrecognized files.
49 *
50 * Example: "C:\MyRepo\common\config\rush"
51 */
52 get commonRushConfigFolder() {
53 return this._commonRushConfigFolder;
54 }
55}
56exports.MinimalRushConfiguration = MinimalRushConfiguration;
57//# sourceMappingURL=MinimalRushConfiguration.js.map
\No newline at end of file