Skip to content
Open
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": "Fix minimumReleaseAge and minimumReleaseAgeExclude in pnpm-config.json being silently ignored because they were written to package.json instead of .npmrc",
"type": "none",
"packageName": "@microsoft/rush"
}
],
"packageName": "@microsoft/rush",
"email": "will.porter@workos.com"
}
50 changes: 49 additions & 1 deletion libraries/rush-lib/src/logic/base/BaseInstallManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { SetupPackageRegistry } from '../setup/SetupPackageRegistry';
import { PnpmfileConfiguration } from '../pnpm/PnpmfileConfiguration';
import type { IInstallManagerOptions } from './BaseInstallManagerTypes';
import { isVariableSetInNpmrcFile } from '../../utilities/npmrcUtilities';
import type { PnpmResolutionMode } from '../pnpm/PnpmOptionsConfiguration';
import type { PnpmOptionsConfiguration, PnpmResolutionMode } from '../pnpm/PnpmOptionsConfiguration';
import { SubspacePnpmfileConfiguration } from '../pnpm/SubspacePnpmfileConfiguration';
import type { Subspace } from '../../api/Subspace';
import { ProjectImpactGraphGenerator } from '../ProjectImpactGraphGenerator';
Expand Down Expand Up @@ -542,13 +542,61 @@ export abstract class BaseInstallManager {
);
}

// Build lines to append to the generated .npmrc so they take precedence over user-committed values.
// pnpm does not read minimumReleaseAge/minimumReleaseAgeExclude from package.json, so we inject
// them here as minimum-release-age / minimum-release-age-exclude .npmrc settings instead.
const pnpmNpmrcAppendLines: string[] = [];
if (this.rushConfiguration.isPnpm) {
const pnpmOptions: PnpmOptionsConfiguration =
subspace.getPnpmOptions() ?? this.rushConfiguration.pnpmOptions;

if (pnpmOptions.minimumReleaseAgeMinutes !== undefined || pnpmOptions.minimumReleaseAgeExclude) {
if (
this.rushConfiguration.rushConfigurationJson.pnpmVersion !== undefined &&
semver.lt(this.rushConfiguration.rushConfigurationJson.pnpmVersion, '10.16.0')
) {
terminal.writeWarningLine(
Colorize.yellow(
`Your version of pnpm (${this.rushConfiguration.rushConfigurationJson.pnpmVersion}) ` +
`doesn't support the "minimumReleaseAgeMinutes" or "minimumReleaseAgeExclude" fields in ` +
`${this.rushConfiguration.commonRushConfigFolder}/${RushConstants.pnpmConfigFilename}. ` +
'Remove these fields or upgrade to pnpm 10.16.0 or newer.'
)
);
}

if (pnpmOptions.minimumReleaseAgeMinutes !== undefined) {
if (
isVariableSetInNpmrcFile(
subspace.getSubspaceConfigFolderPath(),
'minimum-release-age',
this.rushConfiguration.isPnpm
)
) {
terminal.writeWarningLine(
`Warning: PNPM's minimum-release-age is specified in both .npmrc and pnpm-config.json. ` +
`The value in pnpm-config.json will take precedence.`
);
}
pnpmNpmrcAppendLines.push(`minimum-release-age=${pnpmOptions.minimumReleaseAgeMinutes}`);
}

if (pnpmOptions.minimumReleaseAgeExclude) {
for (const packageName of pnpmOptions.minimumReleaseAgeExclude) {
pnpmNpmrcAppendLines.push(`minimum-release-age-exclude[]=${packageName}`);
}
}
}
}

// Also copy down the committed .npmrc file, if there is one
// "common\config\rush\.npmrc" --> "common\temp\.npmrc"
// Also ensure that we remove any old one that may be hanging around
const npmrcText: string | undefined = Utilities.syncNpmrc({
sourceNpmrcFolder: subspace.getSubspaceConfigFolderPath(),
targetNpmrcFolder: subspace.getSubspaceTempFolderPath(),
linesToPrepend: extraNpmrcLines,
linesToAppend: pnpmNpmrcAppendLines.length > 0 ? pnpmNpmrcAppendLines : undefined,
createIfMissing: this.rushConfiguration.subspacesFeatureEnabled,
supportEnvVarFallbackSyntax: this.rushConfiguration.isPnpm
});
Expand Down
27 changes: 0 additions & 27 deletions libraries/rush-lib/src/logic/installManager/InstallHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ interface ICommonPackageJson extends IPackageJson {
ignoredOptionalDependencies?: typeof PnpmOptionsConfiguration.prototype.globalIgnoredOptionalDependencies;
allowedDeprecatedVersions?: typeof PnpmOptionsConfiguration.prototype.globalAllowedDeprecatedVersions;
patchedDependencies?: typeof PnpmOptionsConfiguration.prototype.globalPatchedDependencies;
minimumReleaseAge?: typeof PnpmOptionsConfiguration.prototype.minimumReleaseAgeMinutes;
minimumReleaseAgeExclude?: typeof PnpmOptionsConfiguration.prototype.minimumReleaseAgeExclude;
trustPolicy?: typeof PnpmOptionsConfiguration.prototype.trustPolicy;
trustPolicyExclude?: typeof PnpmOptionsConfiguration.prototype.trustPolicyExclude;
trustPolicyIgnoreAfter?: typeof PnpmOptionsConfiguration.prototype.trustPolicyIgnoreAfterMinutes;
Expand Down Expand Up @@ -124,31 +122,6 @@ export class InstallHelpers {
commonPackageJson.pnpm.patchedDependencies = pnpmOptions.globalPatchedDependencies;
}

if (pnpmOptions.minimumReleaseAgeMinutes !== undefined || pnpmOptions.minimumReleaseAgeExclude) {
if (
rushConfiguration.rushConfigurationJson.pnpmVersion !== undefined &&
semver.lt(rushConfiguration.rushConfigurationJson.pnpmVersion, '10.16.0')
) {
terminal.writeWarningLine(
Colorize.yellow(
`Your version of pnpm (${rushConfiguration.rushConfigurationJson.pnpmVersion}) ` +
`doesn't support the "minimumReleaseAgeMinutes" or "minimumReleaseAgeExclude" fields in ` +
`${rushConfiguration.commonRushConfigFolder}/${RushConstants.pnpmConfigFilename}. ` +
'Remove these fields or upgrade to pnpm 10.16.0 or newer.'
)
);
}

if (pnpmOptions.minimumReleaseAgeMinutes !== undefined) {
// NOTE: the pnpm setting is `minimumReleaseAge`, but the Rush setting is `minimumReleaseAgeMinutes`
commonPackageJson.pnpm.minimumReleaseAge = pnpmOptions.minimumReleaseAgeMinutes;
}

if (pnpmOptions.minimumReleaseAgeExclude) {
commonPackageJson.pnpm.minimumReleaseAgeExclude = pnpmOptions.minimumReleaseAgeExclude;
}
}

if (pnpmOptions.trustPolicy !== undefined) {
if (
rushConfiguration.rushConfigurationJson.pnpmVersion !== undefined &&
Expand Down
Loading