Skip to content

Commit

Permalink
Rename SubspaceConfiguration -> SubspacesConfugration to clarify that…
Browse files Browse the repository at this point in the history
… it represents the overall subspaces.json, not the configuration of one subspace
  • Loading branch information
octogonz committed Jan 26, 2024
1 parent eff28ad commit d39cb48
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 42 deletions.
10 changes: 5 additions & 5 deletions common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1143,10 +1143,10 @@ export class RushConfiguration {
readonly shrinkwrapFilename: string;
get shrinkwrapFilePhrase(): string;
// @beta
readonly subspaceConfiguration?: SubspaceConfiguration;
// @beta
get subspaceNames(): Iterable<string>;
// @beta
readonly subspacesConfiguration?: SubspacesConfiguration;
// @beta
subspaceShrinkwrapFilenames(subspaceName: string): string;
readonly suppressNodeLtsWarning: boolean;
// @beta
Expand Down Expand Up @@ -1332,7 +1332,7 @@ export class RushUserConfiguration {
}

// @beta
export class SubspaceConfiguration {
export class SubspacesConfiguration {
// (undocumented)
static belongsInSubspace(rushProject: RushConfigurationProject, subspaceName: string): boolean;
readonly enabled: boolean;
Expand All @@ -1341,9 +1341,9 @@ export class SubspaceConfiguration {
readonly subspaceJsonFilePath: string;
readonly subspaceNames: Set<string>;
// (undocumented)
static tryLoadFromConfigurationFile(subspaceJsonFilePath: string): SubspaceConfiguration | undefined;
static tryLoadFromConfigurationFile(subspaceJsonFilePath: string): SubspacesConfiguration | undefined;
// (undocumented)
static tryLoadFromDefaultLocation(rushConfiguration: RushConfiguration): SubspaceConfiguration | undefined;
static tryLoadFromDefaultLocation(rushConfiguration: RushConfiguration): SubspacesConfiguration | undefined;
}

// @public
Expand Down
18 changes: 9 additions & 9 deletions libraries/rush-lib/src/api/RushConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import schemaJson from '../schemas/rush.schema.json';
import type * as DependencyAnalyzerModuleType from '../logic/DependencyAnalyzer';
import type { PackageManagerOptionsConfigurationBase } from '../logic/base/BasePackageManagerOptionsConfiguration';
import { CustomTipsConfiguration } from './CustomTipsConfiguration';
import { SubspaceConfiguration } from './SubspaceConfiguration';
import { SubspacesConfiguration } from './SubspacesConfiguration';

const MINIMUM_SUPPORTED_RUSH_JSON_VERSION: string = '0.0.0';
const DEFAULT_BRANCH: string = 'main';
Expand Down Expand Up @@ -353,7 +353,7 @@ export class RushConfiguration {
* The object that specifies subspace configurations if they are provided in the rush workspace.
* @beta
*/
public readonly subspaceConfiguration?: SubspaceConfiguration;
public readonly subspacesConfiguration?: SubspacesConfiguration;

/**
* The filename of the variant dependency data file. By default this is
Expand Down Expand Up @@ -630,7 +630,7 @@ export class RushConfiguration {
this.ensureConsistentVersions = !!rushConfigurationJson.ensureConsistentVersions;

// Try getting a subspace configuration
this.subspaceConfiguration = SubspaceConfiguration.tryLoadFromDefaultLocation(this);
this.subspacesConfiguration = SubspacesConfiguration.tryLoadFromDefaultLocation(this);

this._rushProjectsBySubspaceName = new Map<string, RushConfigurationProject[]>();
this._subspaceConfigFolderBySubspace = new Map<string, string>();
Expand Down Expand Up @@ -885,7 +885,7 @@ export class RushConfiguration {
);
}
this._projectsByName.set(project.packageName, project);
if (this.subspaceConfiguration?.enabled) {
if (this.subspacesConfiguration?.enabled) {
let subspaceName: string;
if (projectJson.subspaceName) {
subspaceName = projectJson.subspaceName;
Expand Down Expand Up @@ -1176,7 +1176,7 @@ export class RushConfiguration {
let subspaceConfigFolder: string = `${this.commonFolder}/config/subspaces/${subspaceName}`;
if (
!FileSystem.exists(subspaceConfigFolder) &&
this.subspaceConfiguration?.splitWorkspaceCompatibility
this.subspacesConfiguration?.splitWorkspaceCompatibility
) {
// Look in the project folder
const rushProjectsInSubspace: RushConfigurationProject[] | undefined =
Expand Down Expand Up @@ -1258,10 +1258,10 @@ export class RushConfiguration {
if (!this._projects) {
this._initializeAndValidateLocalProjects();
}
if (!this.subspaceConfiguration) {
if (!this.subspacesConfiguration) {
throw new Error(`Subspaces is not enabled!`);
}
if (!this.subspaceConfiguration.isValidSubspaceName(subspaceName)) {
if (!this.subspacesConfiguration.isValidSubspaceName(subspaceName)) {
throw new Error(`Received an invalid subspace name: ${subspaceName}`);
}
}
Expand Down Expand Up @@ -1350,7 +1350,7 @@ export class RushConfiguration {
* Returns the subspace name that a project belongs to. Returns undefined if subspaces is not enabled.
*/
public getProjectSubspace(project: RushConfigurationProject): string | undefined {
if (!this.subspaceConfiguration?.enabled) {
if (!this.subspacesConfiguration?.enabled) {
return undefined;
}
if (!this._projects) {
Expand All @@ -1367,7 +1367,7 @@ export class RushConfiguration {
* Returns a list of unique subspace names that the given projects belong to
*/
public getProjectsSubspaceSet(projects: Set<RushConfigurationProject>): string[] {
if (!this.subspaceConfiguration?.enabled) {
if (!this.subspacesConfiguration?.enabled) {
return [];
}
if (!this._projects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const SUBSPACE_NAME_REGEXP: RegExp = /^[a-z0-9]*([-+_a-z0-9]+)*$/;
* This represents the JSON data structure for the "subspaces.json" configuration file.
* See subspace.schema.json for documentation.
*/
interface ISubspaceConfigurationJson {
interface ISubspacesConfigurationJson {
enabled: boolean;
splitWorkspaceCompatibility?: boolean;
subspaceNames: string[];
Expand All @@ -29,7 +29,7 @@ interface ISubspaceConfigurationJson {
* configuration file.
* @beta
*/
export class SubspaceConfiguration {
export class SubspacesConfiguration {
private static _jsonSchema: JsonSchema = JsonSchema.fromLoadedObject(schemaJson);

/**
Expand All @@ -52,7 +52,7 @@ export class SubspaceConfiguration {
*/
public readonly subspaceNames: Set<string>;

private constructor(configuration: Readonly<ISubspaceConfigurationJson>, subspaceJsonFilePath: string) {
private constructor(configuration: Readonly<ISubspacesConfigurationJson>, subspaceJsonFilePath: string) {
this.subspaceJsonFilePath = subspaceJsonFilePath;
this.enabled = configuration.enabled;
this.splitWorkspaceCompatibility = !!configuration.splitWorkspaceCompatibility;
Expand All @@ -79,27 +79,27 @@ export class SubspaceConfiguration {

public static tryLoadFromConfigurationFile(
subspaceJsonFilePath: string
): SubspaceConfiguration | undefined {
let configuration: Readonly<ISubspaceConfigurationJson> | undefined;
): SubspacesConfiguration | undefined {
let configuration: Readonly<ISubspacesConfigurationJson> | undefined;
try {
configuration = JsonFile.loadAndValidate(subspaceJsonFilePath, SubspaceConfiguration._jsonSchema);
configuration = JsonFile.loadAndValidate(subspaceJsonFilePath, SubspacesConfiguration._jsonSchema);
} catch (e) {
if (!FileSystem.isNotExistError(e)) {
throw e;
}
}
if (configuration) {
return new SubspaceConfiguration(configuration, subspaceJsonFilePath);
return new SubspacesConfiguration(configuration, subspaceJsonFilePath);
}
}

public static tryLoadFromDefaultLocation(
rushConfiguration: RushConfiguration
): SubspaceConfiguration | undefined {
): SubspacesConfiguration | undefined {
const commonRushConfigFolder: string = rushConfiguration.getCommonRushConfigFolder();
if (commonRushConfigFolder) {
const subspaceJsonLocation: string = `${commonRushConfigFolder}/${RushConstants.subspacesConfigFilename}`;
return SubspaceConfiguration.tryLoadFromConfigurationFile(subspaceJsonLocation);
return SubspacesConfiguration.tryLoadFromConfigurationFile(subspaceJsonLocation);
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export class RushPnpmCommandLineParser {
}

private async _doRushUpdateAsync(): Promise<void> {
if (this._rushConfiguration.subspaceConfiguration?.enabled) {
if (this._rushConfiguration.subspacesConfiguration?.enabled) {
this._terminal.writeLine(Colors.red('Rush Pnpm is currently unsupported with subspaces.'));
throw new AlreadyReportedError();
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/cli/actions/BaseInstallAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export abstract class BaseInstallAction extends BaseRushAction {
let subspaceNames: string[] | undefined;
if (
installManagerOptions.pnpmFilterArguments.length &&
this.rushConfiguration.subspaceConfiguration?.enabled
this.rushConfiguration.subspacesConfiguration?.enabled
) {
const selectedProjects: Set<RushConfigurationProject> | undefined =
await this._selectionParameters?.getSelectedProjectsAsync(this._terminal);
Expand Down
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/cli/actions/UpdateAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class UpdateAction extends BaseInstallAction {
parser
});

if (this.rushConfiguration?.subspaceConfiguration?.enabled) {
if (this.rushConfiguration?.subspacesConfiguration?.enabled) {
// Partial update is supported only when subspaces is enabled.
this._selectionParameters = new SelectionParameterSet(this.rushConfiguration, this, {
// Include lockfile processing since this expands the selection, and we need to select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {
// TODO: Replace with last-install.flag when "rush link" and "rush unlink" are removed
const lastLinkFlag: LastLinkFlag = LastLinkFlagFactory.getCommonTempFlag(this.rushConfiguration);
// Only check for a valid link flag when subspaces is not enabled
if (!lastLinkFlag.isValid() && !this.rushConfiguration.subspaceConfiguration?.enabled) {
if (!lastLinkFlag.isValid() && !this.rushConfiguration.subspacesConfiguration?.enabled) {
const useWorkspaces: boolean =
this.rushConfiguration.pnpmOptions && this.rushConfiguration.pnpmOptions.useWorkspaces;
if (useWorkspaces) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export { ApprovedPackagesPolicy } from './api/ApprovedPackagesPolicy';

export { RushConfiguration, ITryFindRushJsonLocationOptions } from './api/RushConfiguration';

export { SubspaceConfiguration } from './api/SubspaceConfiguration';
export { SubspacesConfiguration } from './api/SubspacesConfiguration';

export {
IPackageManagerOptionsJsonBase,
Expand Down
4 changes: 2 additions & 2 deletions libraries/rush-lib/src/logic/PackageJsonUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class PackageJsonUpdater {
}

if (!skipUpdate) {
if (this._rushConfiguration.subspaceConfiguration?.enabled) {
if (this._rushConfiguration.subspacesConfiguration?.enabled) {
const subspaceNames: string[] = this._rushConfiguration.getProjectsSubspaceSet(
new Set(options.projects)
);
Expand Down Expand Up @@ -272,7 +272,7 @@ export class PackageJsonUpdater {
}

if (!skipUpdate) {
if (this._rushConfiguration.subspaceConfiguration?.enabled) {
if (this._rushConfiguration.subspacesConfiguration?.enabled) {
const subspaceNames: string[] = this._rushConfiguration.getProjectsSubspaceSet(
new Set(options.projects)
);
Expand Down
8 changes: 4 additions & 4 deletions libraries/rush-lib/src/logic/base/BaseInstallManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export abstract class BaseInstallManager {
);

this.subspaceInstallFlags = new Map();
if (rushConfiguration.subspaceConfiguration?.enabled) {
if (rushConfiguration.subspacesConfiguration?.enabled) {
for (const subspaceName of rushConfiguration.subspaceNames) {
this.subspaceInstallFlags.set(
subspaceName,
Expand Down Expand Up @@ -128,7 +128,7 @@ export abstract class BaseInstallManager {
// Ensure that subspaces is enabled
const subspaceName: string | undefined = this.options.subspaceName;

if (this.rushConfiguration.subspaceConfiguration?.enabled && !this.options.subspaceName) {
if (this.rushConfiguration.subspacesConfiguration?.enabled && !this.options.subspaceName) {
// Temporarily ensure that a subspace is provided
// eslint-disable-next-line no-console
console.log();
Expand All @@ -139,9 +139,9 @@ export abstract class BaseInstallManager {
)
);
throw new AlreadyReportedError();
} else if (this.options.subspaceName && !this.rushConfiguration.subspaceConfiguration?.enabled) {
} else if (this.options.subspaceName && !this.rushConfiguration.subspacesConfiguration?.enabled) {
// Ensure that subspaces is enabled
if (!this.rushConfiguration.subspaceConfiguration?.enabled) {
if (!this.rushConfiguration.subspacesConfiguration?.enabled) {
// eslint-disable-next-line no-console
console.log();
// eslint-disable-next-line no-console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { EnvironmentConfiguration } from '../../api/EnvironmentConfiguration';
import { ShrinkwrapFileFactory } from '../ShrinkwrapFileFactory';
import { BaseProjectShrinkwrapFile } from '../base/BaseProjectShrinkwrapFile';
import { type CustomTipId, type ICustomTipInfo, PNPM_CUSTOM_TIPS } from '../../api/CustomTipsConfiguration';
import { SubspaceConfiguration } from '../../api/SubspaceConfiguration';
import { SubspacesConfiguration } from '../../api/SubspacesConfiguration';
import type { PnpmShrinkwrapFile } from '../pnpm/PnpmShrinkwrapFile';
import { objectsAreDeepEqual } from '../../utilities/objectUtilities';

Expand Down Expand Up @@ -152,7 +152,7 @@ export class WorkspaceInstallManager extends BaseInstallManager {
// Loop through the projects and add them to the workspace file. While we're at it, also validate that
// referenced workspace projects are valid, and check if the shrinkwrap file is already up-to-date.
for (const rushProject of this.rushConfiguration.projects) {
if (subspaceName && !SubspaceConfiguration.belongsInSubspace(rushProject, subspaceName)) {
if (subspaceName && !SubspacesConfiguration.belongsInSubspace(rushProject, subspaceName)) {
// skip processing any project that isn't in this subspace
continue;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ export class WorkspaceInstallManager extends BaseInstallManager {
// get the relative path from common temp folder to repo root folder
const relativeFromTempFolderToRootFolder: string = path.relative(commonTempFolder, rushJsonFolder);
for (const rushProject of this.rushConfiguration.projects) {
if (subspaceName && !SubspaceConfiguration.belongsInSubspace(rushProject, subspaceName)) {
if (subspaceName && !SubspacesConfiguration.belongsInSubspace(rushProject, subspaceName)) {
// skip processing any project that isn't in this subspace
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { subspacePnpmfileShimFilename, scriptsFolderPath } from '../../utilities
import type { IPnpmfileContext, ISubspacePnpmfileShimSettings, IWorkspaceProjectInfo } from './IPnpmfile';
import type { RushConfiguration } from '../../api/RushConfiguration';
import type { PnpmPackageManager } from '../../api/packageManager/PnpmPackageManager';
import { SubspaceConfiguration } from '../../api/SubspaceConfiguration';
import { SubspacesConfiguration } from '../../api/SubspacesConfiguration';
import { RushConstants } from '../RushConstants';

/**
Expand Down Expand Up @@ -86,9 +86,9 @@ export class SubspacePnpmfileConfiguration {
projectRelativeFolder,
packageVersion: packageJson.version
};
(SubspaceConfiguration.belongsInSubspace(project, subspaceName) ? subspaceProjects : workspaceProjects)[
packageName
] = workspaceProjectInfo;
(SubspacesConfiguration.belongsInSubspace(project, subspaceName)
? subspaceProjects
: workspaceProjects)[packageName] = workspaceProjectInfo;
}

const settings: ISubspacePnpmfileShimSettings = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Loaded @microsoft/rush-lib from process.env._RUSH_LIB_PATH
'RushProjectConfiguration',
'RushSession',
'RushUserConfiguration',
'SubspaceConfiguration',
'SubspacesConfiguration',
'VersionPolicy',
'VersionPolicyConfiguration',
'VersionPolicyDefinitionName',
Expand Down

0 comments on commit d39cb48

Please sign in to comment.