Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"type": "none",
"packageName": "@microsoft/rush"
}
],
"packageName": "@microsoft/rush",
"email": "iclanton@users.noreply.github.com"
}
1 change: 1 addition & 0 deletions common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,7 @@ export class RushConstants {
static readonly pnpmSyncFilename: '.pnpm-sync.json';
static readonly pnpmV3ShrinkwrapFilename: 'pnpm-lock.yaml';
static readonly pnpmVirtualStoreFolderName: '.pnpm';
static readonly pnpmWorkspaceFileName: 'pnpm-workspace.yaml';
static readonly projectImpactGraphFilename: 'project-impact-graph.yaml';
static readonly projectRushFolderName: '.rush';
static readonly projectShrinkwrapFilename: 'shrinkwrap-deps.json';
Expand Down
18 changes: 8 additions & 10 deletions libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class RushPnpmCommandLineParser {
this._subspace = subspace;

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

if (!FileSystem.exists(workspaceFilePath)) {
this._terminal.writeErrorLine('Error: The PNPM workspace file has not been generated:');
Expand Down Expand Up @@ -545,9 +545,10 @@ export class RushPnpmCommandLineParser {
let newGlobalPatchedDependencies: Record<string, string> | undefined;
if (semver.gte(pnpmVersion, '11.0.0')) {
// PNPM 11+ stores patchedDependencies in pnpm-workspace.yaml instead of the package.json "pnpm" field
newGlobalPatchedDependencies = await PnpmWorkspaceFile.loadPatchedDependenciesAsync(
`${subspaceTempFolder}/pnpm-workspace.yaml`
const workspaceFile: PnpmWorkspaceFile = await PnpmWorkspaceFile.loadAsync(
`${subspaceTempFolder}/${RushConstants.pnpmWorkspaceFileName}`
);
newGlobalPatchedDependencies = workspaceFile.patchedDependencies;
} else {
// PNPM 10.x and earlier store patchedDependencies in the package.json "pnpm" field
// Example: "C:\MyRepo\common\temp\package.json"
Expand Down Expand Up @@ -612,13 +613,10 @@ export class RushPnpmCommandLineParser {

if (semver.gte(pnpmVersion, '11.0.0')) {
// PNPM 11+ uses allowBuilds in pnpm-workspace.yaml instead of onlyBuiltDependencies in package.json
const workspaceYamlFilename: string = `${subspaceTempFolder}/pnpm-workspace.yaml`;
const yamlModule: typeof import('js-yaml') = await import('js-yaml');
const workspaceYamlContent: string = await FileSystem.readFileAsync(workspaceYamlFilename);
const workspaceYaml: { allowBuilds?: Record<string, boolean> } = (yamlModule.load(
workspaceYamlContent
) ?? {}) as { allowBuilds?: Record<string, boolean> };
const newGlobalAllowBuilds: Record<string, boolean> | undefined = workspaceYaml?.allowBuilds;
const workspaceFile: PnpmWorkspaceFile = await PnpmWorkspaceFile.loadAsync(
`${subspaceTempFolder}/${RushConstants.pnpmWorkspaceFileName}`
);
const newGlobalAllowBuilds: Record<string, boolean> | undefined = workspaceFile.allowBuilds;
const currentGlobalAllowBuilds: Record<string, boolean> | undefined =
pnpmOptions?.globalAllowBuilds;

Expand Down
5 changes: 5 additions & 0 deletions libraries/rush-lib/src/logic/RushConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,9 @@ export class RushConstants {
* The filename ("pnpm-sync.json") used to store the state of the pnpm sync command.
*/
public static readonly pnpmSyncFilename: '.pnpm-sync.json' = '.pnpm-sync.json';

/**
* The filename ("pnpm-workspace.yaml") used to store the state of the pnpm workspace configuration.
*/
public static readonly pnpmWorkspaceFileName: 'pnpm-workspace.yaml' = 'pnpm-workspace.yaml';
}
Loading