-
Notifications
You must be signed in to change notification settings - Fork 682
feat: read trustPolicy, trustPolicyExclude, and trustPolicyIgnoreAfter from pnpm-config.json
#5751
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
Open
fpapado
wants to merge
3
commits into
microsoft:main
Choose a base branch
from
fpapado:feat/pnpm-trust-policy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@microsoft/rush/feature-add-trust-policy-support_2026-04-07-00-00.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "comment": "Add support for pnpm `trustPolicy`, `trustPolicyExclude`, and `trustPolicyIgnoreAfter` settings in `pnpm-config.json`.", | ||
| "type": "minor", | ||
| "packageName": "@microsoft/rush" | ||
| } | ||
| ], | ||
| "packageName": "@microsoft/rush", | ||
| "email": "fpapado@users.noreply.github.com" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -34,6 +34,16 @@ export type PnpmStoreOptions = PnpmStoreLocation; | |||||
| */ | ||||||
| export type PnpmResolutionMode = 'highest' | 'time-based' | 'lowest-direct'; | ||||||
|
|
||||||
| /** | ||||||
| * Possible values for the `trustPolicy` setting in Rush's pnpm-config.json file. | ||||||
| * @remarks | ||||||
| * These values correspond to PNPM's `trust-policy` setting, which is documented here: | ||||||
| * {@link https://pnpm.io/settings#trustpolicy} | ||||||
| * | ||||||
| * @public | ||||||
| */ | ||||||
| export type PnpmTrustPolicy = 'no-downgrade' | 'off'; | ||||||
|
|
||||||
| /** | ||||||
| * Possible values for the `pnpmLockfilePolicies` setting in Rush's pnpm-config.json file. | ||||||
| * @public | ||||||
|
|
@@ -150,6 +160,18 @@ export interface IPnpmOptionsJson extends IPackageManagerOptionsJsonBase { | |||||
| * {@inheritDoc PnpmOptionsConfiguration.minimumReleaseAgeExclude} | ||||||
| */ | ||||||
| minimumReleaseAgeExclude?: string[]; | ||||||
| /** | ||||||
| * {@inheritDoc PnpmOptionsConfiguration.trustPolicy} | ||||||
| */ | ||||||
| trustPolicy?: PnpmTrustPolicy; | ||||||
| /** | ||||||
| * {@inheritDoc PnpmOptionsConfiguration.trustPolicyExclude} | ||||||
| */ | ||||||
| trustPolicyExclude?: string[]; | ||||||
| /** | ||||||
| * {@inheritDoc PnpmOptionsConfiguration.trustPolicyIgnoreAfter} | ||||||
| */ | ||||||
| trustPolicyIgnoreAfter?: number; | ||||||
| /** | ||||||
| * {@inheritDoc PnpmOptionsConfiguration.alwaysInjectDependenciesFromOtherSubspaces} | ||||||
| */ | ||||||
|
|
@@ -301,6 +323,42 @@ export class PnpmOptionsConfiguration extends PackageManagerOptionsConfiguration | |||||
| */ | ||||||
| public readonly minimumReleaseAgeExclude: string[] | undefined; | ||||||
|
|
||||||
| /** | ||||||
| * The trust policy controls whether pnpm should block installation of package versions where the | ||||||
| * trust level has decreased (e.g., a package previously published with provenance is now published | ||||||
| * without it). Setting this to `"no-downgrade"` enables the protection. | ||||||
| * | ||||||
| * @remarks | ||||||
| * (SUPPORTED ONLY IN PNPM 10.21.0 AND NEWER) | ||||||
| * | ||||||
| * PNPM documentation: https://pnpm.io/settings#trustpolicy | ||||||
| */ | ||||||
| public readonly trustPolicy: PnpmTrustPolicy | undefined; | ||||||
|
|
||||||
| /** | ||||||
| * List of package names or patterns that are excluded from the trust policy check. | ||||||
| * These packages will be allowed to install even if their trust level has decreased. | ||||||
| * | ||||||
| * @remarks | ||||||
| * (SUPPORTED ONLY IN PNPM 10.22.0 AND NEWER) | ||||||
| * | ||||||
| * PNPM documentation: https://pnpm.io/settings#trustpolicyexclude | ||||||
| * | ||||||
| * Example: ["webpack", "react", "\@myorg/*"] | ||||||
| */ | ||||||
| public readonly trustPolicyExclude: string[] | undefined; | ||||||
|
|
||||||
| /** | ||||||
| * The number of minutes after which pnpm will ignore trust level downgrades. Packages published | ||||||
| * longer ago than this threshold will not be blocked even if their trust level has decreased. | ||||||
| * | ||||||
| * @remarks | ||||||
| * (SUPPORTED ONLY IN PNPM 10.27.0 AND NEWER) | ||||||
| * | ||||||
| * PNPM documentation: https://pnpm.io/settings#trustpolicyignoreafter | ||||||
| */ | ||||||
| public readonly trustPolicyIgnoreAfter: number | undefined; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| /** | ||||||
| * If true, then `rush update` add injected install options for all cross-subspace | ||||||
| * workspace dependencies, to avoid subspace doppelganger issue. | ||||||
|
|
@@ -495,6 +553,9 @@ export class PnpmOptionsConfiguration extends PackageManagerOptionsConfiguration | |||||
| this.autoInstallPeers = json.autoInstallPeers; | ||||||
| this.minimumReleaseAge = json.minimumReleaseAge; | ||||||
| this.minimumReleaseAgeExclude = json.minimumReleaseAgeExclude; | ||||||
| this.trustPolicy = json.trustPolicy; | ||||||
| this.trustPolicyExclude = json.trustPolicyExclude; | ||||||
| this.trustPolicyIgnoreAfter = json.trustPolicyIgnoreAfter; | ||||||
| this.alwaysInjectDependenciesFromOtherSubspaces = json.alwaysInjectDependenciesFromOtherSubspaces; | ||||||
| this.alwaysFullInstall = json.alwaysFullInstall; | ||||||
| this.pnpmLockfilePolicies = json.pnpmLockfilePolicies; | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
libraries/rush-lib/src/logic/pnpm/test/jsonFiles/pnpm-config-trustPolicy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "trustPolicy": "no-downgrade", | ||
| "trustPolicyExclude": ["@myorg/*", "chokidar@4.0.3", "webpack@4.47.0 || 5.102.1", "@babel/core@7.28.5"], | ||
| "trustPolicyIgnoreAfter": 20160 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion, I agree that the name is clearer when it specifies the units (I kind of wish the pnpm settings were specifying that as well) One quirk aside from the mismatch with the pnpm setting, is that
pnpm-config.jsonalready specifiesminimumReleaseAge, which is also in minutes, without suffixing it with the unit. Do you think it is ok if the two are inconsistent?