rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

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

Open fzxen opened this issue 11 months ago • 2 comments

Summary

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

subspace pnpmfileSettings https://github.com/microsoft/rushstack/blob/e64a1e51976626f95250205cbb9d21b5fc805769/libraries/rush-lib/src/logic/pnpm/IPnpmfile.ts#L34-L39

original pnpmfileSettings https://github.com/microsoft/rushstack/blob/e64a1e51976626f95250205cbb9d21b5fc805769/libraries/rush-lib/src/logic/pnpm/IPnpmfile.ts#L13-L22

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: https://github.com/microsoft/rushstack/blob/438525caf08bcbdb75d33f6747cc34e050837d46/libraries/rush-lib/src/logic/pnpm/PnpmfileConfiguration.ts#L80-L83

Second time: https://github.com/microsoft/rushstack/blob/438525caf08bcbdb75d33f6747cc34e050837d46/libraries/rush-lib/src/logic/pnpm/SubspacePnpmfileConfiguration.ts#L50-L56

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

fzxen avatar Feb 25 '25 05:02 fzxen

@iclanton Could we publish a prerelease version? I want test it in my company repo.

fzxen avatar Mar 11 '25 03:03 fzxen

@iclanton bump, this would also be very helpful for me

martinnaj avatar Aug 25 '25 07:08 martinnaj