Skip to content

Commit dfea209

Browse files
authored
Merge pull request #4538 from iclanton/remove-variants
[rush] Remove the installation variants feature.
2 parents 84f8f4f + b0af8de commit dfea209

35 files changed

+131
-386
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "(BREAKING CHANGE) Remove the 'installation variants' feature and its related APIs, which have been superceded by the Subspaces feature.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/ts-command-line",
5+
"comment": "",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@rushstack/ts-command-line"
10+
}

common/reviews/api/rush-lib.api.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ export const EnvironmentVariableNames: {
251251
readonly RUSH_PREVIEW_VERSION: "RUSH_PREVIEW_VERSION";
252252
readonly RUSH_ALLOW_UNSUPPORTED_NODEJS: "RUSH_ALLOW_UNSUPPORTED_NODEJS";
253253
readonly RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD: "RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD";
254-
readonly RUSH_VARIANT: "RUSH_VARIANT";
255254
readonly RUSH_PARALLELISM: "RUSH_PARALLELISM";
256255
readonly RUSH_ABSOLUTE_SYMLINKS: "RUSH_ABSOLUTE_SYMLINKS";
257256
readonly RUSH_PNPM_STORE_PATH: "RUSH_PNPM_STORE_PATH";
@@ -1070,8 +1069,6 @@ export class RushConfiguration {
10701069
readonly commonTempFolder: string;
10711070
// @deprecated
10721071
get commonVersions(): CommonVersionsConfiguration;
1073-
get currentInstalledVariant(): string | undefined;
1074-
readonly currentVariantJsonFilename: string;
10751072
// @beta
10761073
readonly customTipsConfiguration: CustomTipsConfiguration;
10771074
// @beta
@@ -1091,7 +1088,7 @@ export class RushConfiguration {
10911088
getCommonVersions(subspace?: Subspace): CommonVersionsConfiguration;
10921089
// @deprecated (undocumented)
10931090
getCommonVersionsFilePath(subspace?: Subspace): string;
1094-
getImplicitlyPreferredVersions(variant?: string | undefined): Map<string, string>;
1091+
getImplicitlyPreferredVersions(): Map<string, string>;
10951092
// @deprecated (undocumented)
10961093
getPnpmfilePath(subspace?: Subspace): string;
10971094
getProjectByName(projectName: string): RushConfigurationProject | undefined;
@@ -1111,6 +1108,8 @@ export class RushConfiguration {
11111108
readonly gitSampleEmail: string;
11121109
readonly gitTagSeparator: string | undefined;
11131110
readonly gitVersionBumpCommitMessage: string | undefined;
1111+
// @internal @deprecated
1112+
readonly _hasVariantsField: boolean;
11141113
readonly hotfixChangeEnabled: boolean;
11151114
static loadFromConfigurationFile(rushJsonFilename: string): RushConfiguration;
11161115
// (undocumented)
@@ -1272,7 +1271,6 @@ export class RushConstants {
12721271
static readonly rushTempNpmScope: '@rush-temp';
12731272
static readonly rushTempProjectsFolderName: 'projects';
12741273
static readonly rushUserConfigurationFolderName: '.rush-user';
1275-
static readonly rushVariantsFolderName: 'variants';
12761274
static readonly rushWebSiteUrl: 'https://rushjs.io';
12771275
static readonly subspacesConfigFilename: 'subspaces.json';
12781276
// (undocumented)

libraries/rush-lib/assets/rush-init/rush.json

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -279,39 +279,6 @@
279279
"postRushx": []
280280
},
281281

282-
/**
283-
* Installation variants allow you to maintain a parallel set of configuration files that can be
284-
* used to build the entire monorepo with an alternate set of dependencies. For example, suppose
285-
* you upgrade all your projects to use a new release of an important framework, but during a transition period
286-
* you intend to maintain compatibility with the old release. In this situation, you probably want your
287-
* CI validation to build the entire repo twice: once with the old release, and once with the new release.
288-
*
289-
* Rush "installation variants" correspond to sets of config files located under this folder:
290-
*
291-
* common/config/rush/variants/<variant_name>
292-
*
293-
* The variant folder can contain an alternate common-versions.json file. Its "preferredVersions" field can be used
294-
* to select older versions of dependencies (within a loose SemVer range specified in your package.json files).
295-
* To install a variant, run "rush install --variant <variant_name>".
296-
*
297-
* For more details and instructions, see this article: https://rushjs.io/pages/advanced/installation_variants/
298-
*/
299-
"variants": [
300-
/*[BEGIN "HYPOTHETICAL"]*/
301-
{
302-
/**
303-
* The folder name for this variant.
304-
*/
305-
"variantName": "old-sdk",
306-
307-
/**
308-
* An informative description
309-
*/
310-
"description": "Build this repo using the previous release of the SDK"
311-
}
312-
/*[END "HYPOTHETICAL"]*/
313-
],
314-
315282
/**
316283
* Rush can collect anonymous telemetry about everyday developer activity such as
317284
* success/failure of installs, builds, and other operations. You can use this to identify
@@ -330,13 +297,13 @@
330297
/*[LINE "HYPOTHETICAL"]*/ "hotfixChangeEnabled": false,
331298

332299
/**
333-
* This is an optional, but recommended, list of allowed tags that can be applied to Rush projects
334-
* using the "tags" setting in this file. This list is useful for preventing mistakes such as misspelling,
335-
* and it also provides a centralized place to document your tags. If "allowedProjectTags" list is
336-
* not specified, then any valid tag is allowed. A tag name must be one or more words
337-
* separated by hyphens or slashes, where a word may contain lowercase ASCII letters, digits,
338-
* ".", and "@" characters.
339-
*/
300+
* This is an optional, but recommended, list of allowed tags that can be applied to Rush projects
301+
* using the "tags" setting in this file. This list is useful for preventing mistakes such as misspelling,
302+
* and it also provides a centralized place to document your tags. If "allowedProjectTags" list is
303+
* not specified, then any valid tag is allowed. A tag name must be one or more words
304+
* separated by hyphens or slashes, where a word may contain lowercase ASCII letters, digits,
305+
* ".", and "@" characters.
306+
*/
340307
/*[LINE "HYPOTHETICAL"]*/ "allowedProjectTags": [ "tools", "frontend-team", "1.0.0-release" ],
341308

342309
/**

libraries/rush-lib/src/api/EnvironmentConfiguration.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ export const EnvironmentVariableNames = {
5050
*/
5151
RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD: 'RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD',
5252

53-
/**
54-
* This variable selects a specific installation variant for Rush to use when installing
55-
* and linking package dependencies.
56-
* For more information, see the command-line help for the `--variant` parameter
57-
* and this article: https://rushjs.io/pages/advanced/installation_variants/
58-
*/
59-
RUSH_VARIANT: 'RUSH_VARIANT',
60-
6153
/**
6254
* Specifies the maximum number of concurrent processes to launch during a build.
6355
* For more information, see the command-line help for the `--parallelism` parameter for "rush build".
@@ -541,7 +533,6 @@ export class EnvironmentConfiguration {
541533

542534
case EnvironmentVariableNames.RUSH_PARALLELISM:
543535
case EnvironmentVariableNames.RUSH_PREVIEW_VERSION:
544-
case EnvironmentVariableNames.RUSH_VARIANT:
545536
case EnvironmentVariableNames.RUSH_DEPLOY_TARGET_FOLDER:
546537
// Handled by @microsoft/rush front end
547538
break;

libraries/rush-lib/src/api/LastLinkFlag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ export class LastLinkFlagFactory {
5858
* @internal
5959
*/
6060
public static getCommonTempFlag(subspace: Subspace): LastLinkFlag {
61-
return new LastLinkFlag(subspace.getSubspaceTempFolder(), {});
61+
return new LastLinkFlag(subspace.getSubspaceTempFolder());
6262
}
6363
}

libraries/rush-lib/src/api/RushConfiguration.ts

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as semver from 'semver';
88
import {
99
JsonFile,
1010
JsonSchema,
11-
type JsonNull,
1211
Path,
1312
FileSystem,
1413
type PackageNameParser,
@@ -144,14 +143,6 @@ export interface IRushRepositoryJsonMultipleUrls extends IRushRepositoryJsonBase
144143

145144
export type IRushRepositoryJson = IRushRepositoryJsonSingleUrl | IRushRepositoryJsonMultipleUrls;
146145

147-
/**
148-
* Options defining an allowed variant as part of IRushConfigurationJson.
149-
*/
150-
export interface IRushVariantOptionsJson {
151-
variantName: string;
152-
description: string;
153-
}
154-
155146
/**
156147
* This represents the JSON data structure for the "rush.json" configuration file.
157148
* See rush.schema.json for documentation.
@@ -180,14 +171,7 @@ export interface IRushConfigurationJson {
180171
pnpmOptions?: IPnpmOptionsJson;
181172
yarnOptions?: IYarnOptionsJson;
182173
ensureConsistentVersions?: boolean;
183-
variants?: IRushVariantOptionsJson[];
184-
}
185-
186-
/**
187-
* This represents the JSON data structure for the "current-variant.json" data file.
188-
*/
189-
export interface ICurrentVariantJson {
190-
variant: string | JsonNull;
174+
variants?: unknown;
191175
}
192176

193177
/**
@@ -224,7 +208,6 @@ export interface ITryFindRushJsonLocationOptions {
224208
export class RushConfiguration {
225209
private static _jsonSchema: JsonSchema = JsonSchema.fromLoadedObject(schemaJson);
226210

227-
private _variants: Set<string>;
228211
private readonly _pathTrees: Map<string, LookupByPath<RushConfigurationProject>>;
229212

230213
// Lazily loaded when the projects() getter is called.
@@ -236,9 +219,6 @@ export class RushConfiguration {
236219
// Lazily loaded when the projectsByTag() getter is called.
237220
private _projectsByTag: ReadonlyMap<string, ReadonlySet<RushConfigurationProject>> | undefined;
238221

239-
// variant -> common-versions configuration
240-
private _commonVersionsConfigurationsByVariant: Map<string, CommonVersionsConfiguration> | undefined;
241-
242222
// subspaceName -> subspace
243223
private readonly _subspacesByName: Map<string, Subspace>;
244224
private readonly _subspaces: Subspace[] = [];
@@ -358,13 +338,12 @@ export class RushConfiguration {
358338
public readonly subspacesFeatureEnabled: boolean;
359339

360340
/**
361-
* The filename of the variant dependency data file. By default this is
362-
* called 'current-variant.json' resides in the Rush common folder.
363-
* Its data structure is defined by ICurrentVariantJson.
341+
* If true, the `variants` field is present in rush.json.
364342
*
365-
* Example: `C:\MyRepo\common\temp\current-variant.json`
343+
* @internal
344+
* @deprecated - Remove when the field is removed from the rush.json schema.
366345
*/
367-
public readonly currentVariantJsonFilename: string;
346+
public readonly _hasVariantsField: boolean;
368347

369348
/**
370349
* The version of the locally package manager tool. (Example: "1.2.3")
@@ -625,8 +604,6 @@ export class RushConfiguration {
625604

626605
this.changesFolder = path.join(this.commonFolder, RushConstants.changeFilesFolderName);
627606

628-
this.currentVariantJsonFilename = path.join(this.commonTempFolder, 'current-variant.json');
629-
630607
this.suppressNodeLtsWarning = !!rushConfigurationJson.suppressNodeLtsWarning;
631608

632609
this.ensureConsistentVersions = !!rushConfigurationJson.ensureConsistentVersions;
@@ -834,19 +811,7 @@ export class RushConfiguration {
834811
);
835812
this.customTipsConfiguration = new CustomTipsConfiguration(this.customTipsConfigurationFilePath);
836813

837-
this._variants = new Set<string>();
838-
839-
if (rushConfigurationJson.variants) {
840-
for (const variantOptions of rushConfigurationJson.variants) {
841-
const { variantName } = variantOptions;
842-
843-
if (this._variants.has(variantName)) {
844-
throw new Error(`Duplicate variant named '${variantName}' specified in configuration.`);
845-
}
846-
847-
this._variants.add(variantName);
848-
}
849-
}
814+
this._hasVariantsField = !!rushConfigurationJson.variants;
850815

851816
this._pathTrees = new Map();
852817
}
@@ -1383,31 +1348,12 @@ export class RushConfiguration {
13831348
* Instead it will be initialized in an empty state, and calling CommonVersionsConfiguration.save()
13841349
* will create the file.
13851350
*
1386-
* @deprecated Use `getCommonVersions` instead, which gets the correct common version data
1387-
* for a given active variant.
1351+
* @deprecated Use `getCommonVersions` instead, which gets the correct common version data.
13881352
*/
13891353
public get commonVersions(): CommonVersionsConfiguration {
13901354
return this.defaultSubspace.getCommonVersions();
13911355
}
13921356

1393-
/**
1394-
* Gets the currently-installed variant, if an installation has occurred.
1395-
* For Rush operations which do not take a --variant parameter, this method
1396-
* determines which variant, if any, was last specified when performing "rush install"
1397-
* or "rush update".
1398-
*/
1399-
public get currentInstalledVariant(): string | undefined {
1400-
let variant: string | undefined;
1401-
1402-
if (FileSystem.exists(this.currentVariantJsonFilename)) {
1403-
const currentVariantJson: ICurrentVariantJson = JsonFile.load(this.currentVariantJsonFilename);
1404-
1405-
variant = currentVariantJson.variant || undefined;
1406-
}
1407-
1408-
return variant;
1409-
}
1410-
14111357
/**
14121358
* @deprecated Use {@link Subspace.getCommonVersionsFilePath} instead
14131359
*/
@@ -1424,18 +1370,17 @@ export class RushConfiguration {
14241370

14251371
/**
14261372
* Returns a map of all direct dependencies that only have a single semantic version specifier.
1427-
* @param variant - The name of the current variant in use by the active command.
14281373
*
14291374
* @returns A map of dependency name --\> version specifier for implicitly preferred versions.
14301375
*/
1431-
public getImplicitlyPreferredVersions(variant?: string | undefined): Map<string, string> {
1376+
public getImplicitlyPreferredVersions(): Map<string, string> {
14321377
// TODO: During the next major release of Rush, replace this `require` call with a dynamic import, and
14331378
// change this function to be async.
14341379
const DependencyAnalyzerModule: typeof DependencyAnalyzerModuleType = require('../logic/DependencyAnalyzer');
14351380
const dependencyAnalyzer: DependencyAnalyzerModuleType.DependencyAnalyzer =
14361381
DependencyAnalyzerModule.DependencyAnalyzer.forRushConfiguration(this);
14371382
const dependencyAnalysis: DependencyAnalyzerModuleType.IDependencyAnalysis =
1438-
dependencyAnalyzer.getAnalysis(variant);
1383+
dependencyAnalyzer.getAnalysis();
14391384
return dependencyAnalysis.implicitlyPreferredVersionByPackageName;
14401385
}
14411386

libraries/rush-lib/src/api/Subspace.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ export class Subspace {
193193
}
194194

195195
/**
196-
* Gets the settings from the common-versions.json config file for a specific variant.
197-
* @param variant - The name of the current variant in use by the active command.
196+
* Gets the settings from the common-versions.json config file.
198197
* @beta
199198
*/
200199
public getCommonVersions(): CommonVersionsConfiguration {
@@ -206,18 +205,16 @@ export class Subspace {
206205
}
207206

208207
/**
209-
* Gets the path to the repo-state.json file for a specific variant.
210-
* @param variant - The name of the current variant in use by the active command.
208+
* Gets the path to the repo-state.json file.
211209
* @beta
212210
*/
213211
public getRepoStateFilePath(): string {
214212
return this._ensureDetail().subspaceConfigFolder + '/' + RushConstants.repoStateFilename;
215213
}
216214

217215
/**
218-
* Gets the contents from the repo-state.json file for a specific variant.
216+
* Gets the contents from the repo-state.json file.
219217
* @param subspaceName - The name of the subspace in use by the active command.
220-
* @param variant - The name of the current variant in use by the active command.
221218
* @beta
222219
*/
223220
public getRepoState(): RepoStateFile {
@@ -226,8 +223,7 @@ export class Subspace {
226223
}
227224

228225
/**
229-
* Gets the committed shrinkwrap file name for a specific variant.
230-
* @param variant - The name of the current variant in use by the active command.
226+
* Gets the committed shrinkwrap file name.
231227
* @beta
232228
*/
233229
public getCommittedShrinkwrapFilename(): string {

libraries/rush-lib/src/api/Variants.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ export class RushPnpmCommandLineParser {
469469
networkConcurrency: undefined,
470470
offline: false,
471471
collectLogFile: false,
472-
variant: undefined,
473472
maxInstallAttempts: RushConstants.defaultMaxInstallAttempts,
474473
pnpmFilterArguments: [],
475474
checkOnly: false,

0 commit comments

Comments
 (0)