Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rush] Rename the subspace pnpmfileSettings file to globalPnpmfileSettings.json to avoid overwriting the original pnpmfileSettings.json #5133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fzxen
Copy link
Contributor

@fzxen fzxen commented Feb 25, 2025

Summary

This MR rename subspace pnpmfileSettings file to globalPnpmfileSettings.json, because subspace pnpmfileSettings overrides original pnpmfileSettings and they have different data structures.

subspace pnpmfileSettings

export interface ISubspacePnpmfileShimSettings {
semverPath: string;
workspaceProjects: Record<string, IWorkspaceProjectInfo>;
subspaceProjects: Record<string, IWorkspaceProjectInfo>;
userPnpmfilePath?: string;
}

original pnpmfileSettings

export interface IPnpmfileShimSettings {
semverPath: string;
allPreferredVersions: { [dependencyName: string]: string };
allowedAlternativeVersions: { [dependencyName: string]: ReadonlyArray<string> };
/**
* The versions of all packages that are part of the workspace.
*/
workspaceVersions: Record<string, string>;
userPnpmfilePath?: string;
}

Due to the missing preferredVersion information in subspace pnpmfileSettings file, the preferredVersion does not take effect when the subspace is enabled.

Fixes #5118

Details

After debugging rush-lib, I found that pnpmfileSettings.json will be written twice.

First time:

// Write the settings file used by the shim
await JsonFile.saveAsync(pnpmfileShimSettings, path.join(targetDir, 'pnpmfileSettings.json'), {
ensureFolderExists: true
});

Second time:

await JsonFile.saveAsync(
subspaceGlobalPnpmfileShimSettings,
path.join(targetDir, 'pnpmfileSettings.json'),
{
ensureFolderExists: true
}
);

The second write operation will overwrite the first write content. And pnpmfileSettings.json is read once by global-pnpmfile.cjs and pnpmfile.cjs respectively.

Maybe we should distinguish the file names written twice, one is named pnpmfileSettings.json and the other named is globalPnpmfileSettings.json.

How it was tested

Impacted documentation

@iclanton iclanton changed the title Rename the subspace pnpmfileSettings file to globalPnpmfileSettings.json to avoid overwriting the original pnpmfileSettings.json [rush] Rename the subspace pnpmfileSettings file to globalPnpmfileSettings.json to avoid overwriting the original pnpmfileSettings.json Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[rush] preferredVersions doesn't work when subspace is enabled.
1 participant