-
Notifications
You must be signed in to change notification settings - Fork 607
/
ExperimentsConfiguration.ts
88 lines (76 loc) · 2.9 KB
/
ExperimentsConfiguration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import * as path from 'path';
import { JsonFile, JsonSchema, FileSystem } from '@rushstack/node-core-library';
/**
* This interface represents the raw experiments.json file which allows repo
* maintainers to enable and disable experimental Rush features.
* @beta
*/
export interface IExperimentsJson {
/**
* By default, 'rush install' passes --no-prefer-frozen-lockfile to 'pnpm install'.
* Set this option to true to pass '--frozen-lockfile' instead.
*/
usePnpmFrozenLockfileForRushInstall?: boolean;
/**
* By default, 'rush update' passes --no-prefer-frozen-lockfile to 'pnpm install'.
* Set this option to true to pass '--prefer-frozen-lockfile' instead.
*/
usePnpmPreferFrozenLockfileForRushUpdate?: boolean;
/**
* If using the 'preventManualShrinkwrapChanges' option, restricts the hash to only include the layout of external dependencies.
* Used to allow links between workspace projects or the addition/removal of references to existing dependency versions to not
* cause hash changes.
*/
omitImportersFromPreventManualShrinkwrapChanges?: boolean;
/**
* If true, the chmod field in temporary project tar headers will not be normalized.
* This normalization can help ensure consistent tarball integrity across platforms.
*/
noChmodFieldInTarHeaderNormalization?: boolean;
/**
* If true, build caching will respect the allowWarningsInSuccessfulBuild flag and cache builds with warnings.
* This will not replay warnings from the cached build.
*/
buildCacheWithAllowWarningsInSuccessfulBuild?: boolean;
/**
* If true, the phased commands feature is enabled. To use this feature, create a "phased" command
* in common/config/rush/command-line.json.
*/
phasedCommands?: boolean;
}
/**
* Use this class to load the "common/config/rush/experiments.json" config file.
* This file allows repo maintainers to enable and disable experimental Rush features.
* @public
*/
export class ExperimentsConfiguration {
private static _jsonSchema: JsonSchema = JsonSchema.fromFile(
path.resolve(__dirname, '..', 'schemas', 'experiments.schema.json')
);
private _experimentConfiguration: IExperimentsJson;
private _jsonFileName: string;
/**
* @internal
*/
public constructor(jsonFileName: string) {
this._jsonFileName = jsonFileName;
this._experimentConfiguration = {};
if (!FileSystem.exists(this._jsonFileName)) {
this._experimentConfiguration = {};
} else {
this._experimentConfiguration = JsonFile.loadAndValidate(
this._jsonFileName,
ExperimentsConfiguration._jsonSchema
);
}
}
/**
* Get the experiments configuration.
* @beta
*/
public get configuration(): Readonly<IExperimentsJson> {
return this._experimentConfiguration;
}
}