Skip to content

Commit

Permalink
Merge pull request #2 from octogonz/octogonz/install-subspace-cont
Browse files Browse the repository at this point in the history
Refactor to replace "subspaceName" with a Subspace class
  • Loading branch information
william2958 authored Jan 29, 2024
2 parents d39cb48 + 77a266a commit bfe8f3e
Show file tree
Hide file tree
Showing 72 changed files with 1,041 additions and 840 deletions.
95 changes: 66 additions & 29 deletions common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1033,10 +1033,10 @@ export class ProjectChangeAnalyzer {
export class RepoStateFile {
readonly filePath: string;
get isValid(): boolean;
static loadFromFile(jsonFilename: string, subspaceName: string | undefined): RepoStateFile;
static loadFromFile(jsonFilename: string): RepoStateFile;
get pnpmShrinkwrapHash(): string | undefined;
get preferredVersionsHash(): string | undefined;
refreshState(rushConfiguration: RushConfiguration): boolean;
refreshState(rushConfiguration: RushConfiguration, commonVersions: CommonVersionsConfiguration | undefined): boolean;
}

// @public
Expand Down Expand Up @@ -1069,39 +1069,41 @@ export class RushConfiguration {
readonly customTipsConfiguration: CustomTipsConfiguration;
// @beta
readonly customTipsConfigurationFilePath: string;
// @beta (undocumented)
get defaultSubspace(): Subspace;
readonly ensureConsistentVersions: boolean;
// @beta
readonly eventHooks: EventHooks;
// @beta
readonly experimentsConfiguration: ExperimentsConfiguration;
findProjectByShorthandName(shorthandProjectName: string): RushConfigurationProject | undefined;
findProjectByTempName(tempProjectName: string): RushConfigurationProject | undefined;
getCommittedShrinkwrapFilename(subspaceName?: string | undefined): string;
getCommonRushConfigFolder(subspaceName?: string | undefined): string;
getCommonTempFolder(subspaceName?: string | undefined): string;
getCommonVersions(subspaceName?: string | undefined): CommonVersionsConfiguration;
getCommonVersionsFilePath(subspaceName?: string | undefined): string;
// @deprecated (undocumented)
getCommittedShrinkwrapFilename(subspace?: Subspace): string;
// @deprecated (undocumented)
getCommonVersions(subspace?: Subspace): CommonVersionsConfiguration;
// @deprecated (undocumented)
getCommonVersionsFilePath(subspace?: Subspace): string;
getImplicitlyPreferredVersions(variant?: string | undefined): Map<string, string>;
getPnpmfilePath(subspaceName?: string | undefined): string;
// @deprecated (undocumented)
getPnpmfilePath(subspace?: Subspace): string;
getProjectByName(projectName: string): RushConfigurationProject | undefined;
// @beta (undocumented)
getProjectLookupForRoot(rootPath: string): LookupByPath<RushConfigurationProject>;
getProjectsSubspaceSet(projects: Set<RushConfigurationProject>): string[];
getProjectSubspace(project: RushConfigurationProject): string | undefined;
getRepoState(subspaceName: string | undefined): RepoStateFile;
getRepoStateFilePath(subspaceName?: string | undefined): string;
getSubspaceProjects(subspaceName: string): RushConfigurationProject[];
// @beta
getTempShrinkwrapFilename(subspaceName?: string | undefined): string;
getTempShrinkwrapPreinstallFilename(subspaceName?: string | undefined): string;
getProjectsSubspaceSet(projects: ReadonlySet<RushConfigurationProject>): ReadonlySet<Subspace>;
// @deprecated (undocumented)
getRepoState(subspace?: Subspace): RepoStateFile;
// @deprecated (undocumented)
getRepoStateFilePath(subspace?: Subspace): string;
// @beta (undocumented)
getSubspace(subspaceName: string): Subspace;
readonly gitAllowedEmailRegExps: string[];
readonly gitChangefilesCommitMessage: string | undefined;
readonly gitChangeLogUpdateCommitMessage: string | undefined;
readonly gitSampleEmail: string;
readonly gitTagSeparator: string | undefined;
readonly gitVersionBumpCommitMessage: string | undefined;
// @beta
get hasSubspaces(): boolean;
readonly hotfixChangeEnabled: boolean;
static loadFromConfigurationFile(rushJsonFilename: string): RushConfiguration;
// (undocumented)
Expand All @@ -1122,7 +1124,7 @@ export class RushConfiguration {
// (undocumented)
get projects(): RushConfigurationProject[];
// @beta (undocumented)
get projectsByName(): Map<string, RushConfigurationProject>;
get projectsByName(): ReadonlyMap<string, RushConfigurationProject>;
// @beta
get projectsByTag(): ReadonlyMap<string, ReadonlySet<RushConfigurationProject>>;
readonly repositoryDefaultBranch: string;
Expand All @@ -1143,20 +1145,19 @@ export class RushConfiguration {
readonly shrinkwrapFilename: string;
get shrinkwrapFilePhrase(): string;
// @beta
get subspaceNames(): Iterable<string>;
get subspaces(): readonly Subspace[];
// @beta
readonly subspacesConfiguration?: SubspacesConfiguration;
// @beta
subspaceShrinkwrapFilenames(subspaceName: string): string;
readonly subspacesConfiguration: SubspacesConfiguration | undefined;
readonly subspacesFeatureEnabled: boolean;
readonly suppressNodeLtsWarning: boolean;
// @beta
readonly telemetryEnabled: boolean;
static tryFindRushJsonLocation(options?: ITryFindRushJsonLocationOptions): string | undefined;
tryGetProjectForPath(currentFolderPath: string): RushConfigurationProject | undefined;
// @beta (undocumented)
tryGetSubspace(subspaceName: string): Subspace | undefined;
// (undocumented)
static tryLoadFromDefaultLocation(options?: ITryFindRushJsonLocationOptions): RushConfiguration | undefined;
// (undocumented)
validateSubspaceName(subspaceName: string): void;
// @beta (undocumented)
readonly versionPolicyConfiguration: VersionPolicyConfiguration;
// @beta (undocumented)
Expand All @@ -1171,6 +1172,8 @@ export class RushConfigurationProject {
//
// @internal
constructor(options: IRushConfigurationProjectOptions);
// @beta
readonly configuredSubspaceName: string | undefined;
get consumingProjects(): ReadonlySet<RushConfigurationProject>;
// @deprecated
get cyclicDependencyProjects(): Set<string>;
Expand All @@ -1195,8 +1198,7 @@ export class RushConfigurationProject {
readonly rushConfiguration: RushConfiguration;
get shouldPublish(): boolean;
readonly skipRushCheck: boolean;
// @beta
readonly subspaceName: string | undefined;
readonly subspace: Subspace;
// @beta
readonly tags: ReadonlySet<string>;
readonly tempProjectName: string;
Expand Down Expand Up @@ -1331,15 +1333,50 @@ export class RushUserConfiguration {
static initializeAsync(): Promise<RushUserConfiguration>;
}

// @public
export class Subspace {
// Warning: (ae-forgotten-export) The symbol "ISubspaceOptions" needs to be exported by the entry point index.d.ts
constructor(options: ISubspaceOptions);
// @internal (undocumented)
_addProject(project: RushConfigurationProject): void;
// @beta
contains(project: RushConfigurationProject): boolean;
// @beta
getCommittedShrinkwrapFilename(): string;
// @beta
getCommonVersions(): CommonVersionsConfiguration;
// @beta
getCommonVersionsFilePath(): string;
// @beta
getPnpmfilePath(): string;
// @beta
getProjects(): RushConfigurationProject[];
// @beta
getRepoState(): RepoStateFile;
// @beta
getRepoStateFilePath(): string;
// @beta
getSubspaceConfigFolder(): string;
// @beta
getSubspaceTempFolder(): string;
// @beta
getTempShrinkwrapFilename(): string;
// @beta
getTempShrinkwrapPreinstallFilename(subspaceName?: string | undefined): string;
// (undocumented)
readonly subspaceName: string;
}

// @beta
export class SubspacesConfiguration {
// (undocumented)
static belongsInSubspace(rushProject: RushConfigurationProject, subspaceName: string): boolean;
readonly enabled: boolean;
isValidSubspaceName(subspaceName: string): boolean;
static explainIfInvalidSubspaceName(subspaceName: string): string | undefined;
static requireValidSubspaceName(subspaceName: string): void;
readonly splitWorkspaceCompatibility: boolean;
readonly subspaceJsonFilePath: string;
readonly subspaceNames: Set<string>;
readonly subspaceNames: ReadonlySet<string>;
// (undocumented)
static tryLoadFromConfigurationFile(subspaceJsonFilePath: string): SubspacesConfiguration | undefined;
// (undocumented)
Expand Down Expand Up @@ -1375,7 +1412,7 @@ export class VersionPolicyConfiguration {
bump(versionPolicyName?: string, bumpType?: BumpType, identifier?: string, shouldCommit?: boolean): void;
getVersionPolicy(policyName: string): VersionPolicy;
update(versionPolicyName: string, newVersion: string, shouldCommit?: boolean): void;
validate(projectsByName: Map<string, RushConfigurationProject>): void;
validate(projectsByName: ReadonlyMap<string, RushConfigurationProject>): void;
readonly versionPolicies: Map<string, VersionPolicy>;
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/rush-lib/src/api/ApprovedPackagesPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ export class ApprovedPackagesPolicy {

// Load browser-approved-packages.json
const browserApprovedPackagesPath: string = path.join(
rushConfiguration.getCommonRushConfigFolder(),
rushConfiguration.commonRushConfigFolder,
RushConstants.browserApprovedPackagesFilename
);
this.browserApprovedPackages = new ApprovedPackagesConfiguration(browserApprovedPackagesPath);
this.browserApprovedPackages.tryLoadFromFile(this.enabled);

// Load nonbrowser-approved-packages.json
const nonbrowserApprovedPackagesPath: string = path.join(
rushConfiguration.getCommonRushConfigFolder(),
rushConfiguration.commonRushConfigFolder,
RushConstants.nonbrowserApprovedPackagesFilename
);
this.nonbrowserApprovedPackages = new ApprovedPackagesConfiguration(nonbrowserApprovedPackagesPath);
Expand Down
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/api/BuildCacheConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class BuildCacheConfiguration {
* Gets the absolute path to the build-cache.json file in the specified rush workspace.
*/
public static getBuildCacheConfigFilePath(rushConfiguration: RushConfiguration): string {
return path.resolve(rushConfiguration.getCommonRushConfigFolder(), RushConstants.buildCacheFilename);
return path.resolve(rushConfiguration.commonRushConfigFolder, RushConstants.buildCacheFilename);
}

private static async _loadAsync(
Expand Down
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/api/CobuildConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class CobuildConfiguration {
}

public static getCobuildConfigFilePath(rushConfiguration: RushConfiguration): string {
return `${rushConfiguration.getCommonRushConfigFolder()}/${RushConstants.cobuildFilename}`;
return `${rushConfiguration.commonRushConfigFolder}/${RushConstants.cobuildFilename}`;
}

private static async _loadAsync(
Expand Down
5 changes: 3 additions & 2 deletions libraries/rush-lib/src/api/LastInstallFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FileSystem, JsonFile, type JsonObject, Path } from '@rushstack/node-cor
import type { PackageManagerName } from './packageManager/PackageManager';
import type { RushConfiguration } from './RushConfiguration';
import { objectsAreDeepEqual } from '../utilities/objectUtilities';
import type { Subspace } from './Subspace';

export const LAST_INSTALL_FLAG_FILE_NAME: string = 'last-install.flag';

Expand Down Expand Up @@ -162,7 +163,7 @@ export class LastInstallFlagFactory {
*/
public static getCommonTempFlag(
rushConfiguration: RushConfiguration,
subspaceName: string | undefined,
subspace: Subspace,
extraState: Record<string, string> = {}
): LastInstallFlag {
const currentState: JsonObject = {
Expand All @@ -180,6 +181,6 @@ export class LastInstallFlagFactory {
}
}

return new LastInstallFlag(rushConfiguration.getCommonTempFolder(subspaceName), currentState);
return new LastInstallFlag(subspace.getSubspaceTempFolder(), currentState);
}
}
9 changes: 3 additions & 6 deletions libraries/rush-lib/src/api/LastLinkFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { LastInstallFlag } from './LastInstallFlag';
import { type JsonObject, JsonFile, InternalError } from '@rushstack/node-core-library';
import type { RushConfiguration } from './RushConfiguration';
import type { Subspace } from './Subspace';

export const LAST_LINK_FLAG_FILE_NAME: string = 'last-link.flag';

Expand Down Expand Up @@ -57,10 +57,7 @@ export class LastLinkFlagFactory {
*
* @internal
*/
public static getCommonTempFlag(
rushConfiguration: RushConfiguration,
subspaceName?: string | undefined
): LastLinkFlag {
return new LastLinkFlag(rushConfiguration.getCommonTempFolder(subspaceName), {});
public static getCommonTempFlag(subspace: Subspace): LastLinkFlag {
return new LastLinkFlag(subspace.getSubspaceTempFolder(), {});
}
}
Loading

0 comments on commit bfe8f3e

Please sign in to comment.