Skip to content

Commit d98231e

Browse files
committed
Create a pnpmWorkspaceFileName constant.
1 parent ba24f16 commit d98231e

5 files changed

Lines changed: 11 additions & 8 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,7 @@ export class RushConstants {
15741574
static readonly pnpmSyncFilename: '.pnpm-sync.json';
15751575
static readonly pnpmV3ShrinkwrapFilename: 'pnpm-lock.yaml';
15761576
static readonly pnpmVirtualStoreFolderName: '.pnpm';
1577+
static readonly pnpmWorkspaceFileName: 'pnpm-workspace.yaml';
15771578
static readonly projectImpactGraphFilename: 'project-impact-graph.yaml';
15781579
static readonly projectRushFolderName: '.rush';
15791580
static readonly projectShrinkwrapFilename: 'shrinkwrap-deps.json';

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class RushPnpmCommandLineParser {
166166
this._subspace = subspace;
167167

168168
const workspaceFolder: string = subspace.getSubspaceTempFolderPath();
169-
const workspaceFilePath: string = path.join(workspaceFolder, 'pnpm-workspace.yaml');
169+
const workspaceFilePath: string = `${workspaceFolder}/${RushConstants.pnpmWorkspaceFileName}`;
170170

171171
if (!FileSystem.exists(workspaceFilePath)) {
172172
this._terminal.writeErrorLine('Error: The PNPM workspace file has not been generated:');
@@ -546,7 +546,7 @@ export class RushPnpmCommandLineParser {
546546
if (semver.gte(pnpmVersion, '11.0.0')) {
547547
// PNPM 11+ stores patchedDependencies in pnpm-workspace.yaml instead of the package.json "pnpm" field
548548
newGlobalPatchedDependencies = await PnpmWorkspaceFile.loadPatchedDependenciesAsync(
549-
`${subspaceTempFolder}/pnpm-workspace.yaml`
549+
`${subspaceTempFolder}/${RushConstants.pnpmWorkspaceFileName}`
550550
);
551551
} else {
552552
// PNPM 10.x and earlier store patchedDependencies in the package.json "pnpm" field
@@ -612,7 +612,7 @@ export class RushPnpmCommandLineParser {
612612

613613
if (semver.gte(pnpmVersion, '11.0.0')) {
614614
// PNPM 11+ uses allowBuilds in pnpm-workspace.yaml instead of onlyBuiltDependencies in package.json
615-
const workspaceYamlFilename: string = `${subspaceTempFolder}/pnpm-workspace.yaml`;
615+
const workspaceYamlFilename: string = `${subspaceTempFolder}/${RushConstants.pnpmWorkspaceFileName}`;
616616
const yamlModule: typeof import('js-yaml') = await import('js-yaml');
617617
const workspaceYamlContent: string = await FileSystem.readFileAsync(workspaceYamlFilename);
618618
const workspaceYaml: { allowBuilds?: Record<string, boolean> } = (yamlModule.load(

libraries/rush-lib/src/logic/RushConstants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,9 @@ export class RushConstants {
369369
* The filename ("pnpm-sync.json") used to store the state of the pnpm sync command.
370370
*/
371371
public static readonly pnpmSyncFilename: '.pnpm-sync.json' = '.pnpm-sync.json';
372+
373+
/**
374+
* The filename ("pnpm-workspace.yaml") used to store the state of the pnpm workspace configuration.
375+
*/
376+
public static readonly pnpmWorkspaceFileName: 'pnpm-workspace.yaml' = 'pnpm-workspace.yaml';
372377
}

libraries/rush-lib/src/logic/installManager/InstallHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export class InstallHelpers {
316316
// Populate a PnpmWorkspaceFile with the workspace settings. The caller adds the workspace
317317
// packages to this file and saves it; here we only set the pnpm settings.
318318
const workspaceFile: PnpmWorkspaceFile = new PnpmWorkspaceFile(
319-
`${subspace.getSubspaceTempFolderPath()}/pnpm-workspace.yaml`
319+
`${subspace.getSubspaceTempFolderPath()}/${RushConstants.pnpmWorkspaceFileName}`
320320
);
321321
workspaceFile.catalogs = globalCatalogs;
322322
workspaceFile.allowBuilds = allowBuilds;

libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,7 @@ export class WorkspaceInstallManager extends BaseInstallManager {
465465

466466
if (this.rushConfiguration.isPnpm) {
467467
// Add workspace file. This file is only modified when workspace packages change.
468-
const pnpmWorkspaceFilename: string = path.join(
469-
subspace.getSubspaceTempFolderPath(),
470-
'pnpm-workspace.yaml'
471-
);
468+
const pnpmWorkspaceFilename: string = `${subspace.getSubspaceTempFolderPath()}/${RushConstants.pnpmWorkspaceFileName}`;
472469

473470
if (FileSystem.exists(pnpmWorkspaceFilename)) {
474471
potentiallyChangedFiles.push(pnpmWorkspaceFilename);

0 commit comments

Comments
 (0)