Skip to content

Commit 0563d10

Browse files
feat(rush): add support for resolution only mode with pnpm
1 parent 9a6fcbb commit 0563d10

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

common/config/rush/experiments.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* By default, 'rush install' passes --no-prefer-frozen-lockfile to 'pnpm install'.
1010
* Set this option to true to pass '--frozen-lockfile' instead for faster installs.
1111
*/
12-
"usePnpmFrozenLockfileForRushInstall": true,
12+
// "usePnpmFrozenLockfileForRushInstall": true,
1313

1414
/**
1515
* By default, 'rush update' passes --no-prefer-frozen-lockfile to 'pnpm install'.

libraries/rush-lib/src/api/test/__snapshots__/RushCommandLine.test.ts.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,14 @@ Object {
462462
"required": false,
463463
"shortName": undefined,
464464
},
465+
Object {
466+
"description": "Only perform dependency resolution, useful for ensuring peer dependendencies are up to date.",
467+
"environmentVariable": undefined,
468+
"kind": "Flag",
469+
"longName": "--resolution-only",
470+
"required": false,
471+
"shortName": undefined,
472+
},
465473
],
466474
},
467475
Object {

libraries/rush-lib/src/cli/actions/InstallAction.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { RushConfigurationProject } from '../../api/RushConfigurationProjec
1111

1212
export class InstallAction extends BaseInstallAction {
1313
private readonly _checkOnlyParameter: CommandLineFlagParameter;
14+
private readonly _resolutionOnlyParameter: CommandLineFlagParameter;
1415

1516
public constructor(parser: RushCommandLineParser) {
1617
super({
@@ -45,6 +46,11 @@ export class InstallAction extends BaseInstallAction {
4546
parameterLongName: '--check-only',
4647
description: `Only check the validity of the shrinkwrap file without performing an install.`
4748
});
49+
50+
this._resolutionOnlyParameter = this.defineFlagParameter({
51+
parameterLongName: '--resolution-only',
52+
description: `Only perform dependency resolution, useful for ensuring peer dependendencies are up to date.`
53+
});
4854
}
4955

5056
protected async buildInstallOptionsAsync(): Promise<Omit<IInstallManagerOptions, 'subspace'>> {
@@ -71,6 +77,7 @@ export class InstallAction extends BaseInstallAction {
7177
pnpmFilterArgumentValues:
7278
(await this._selectionParameters?.getPnpmFilterArgumentValuesAsync(this._terminal)) ?? [],
7379
checkOnly: this._checkOnlyParameter.value,
80+
resolutionOnly: this._resolutionOnlyParameter.value,
7481
beforeInstallAsync: () => this.rushSession.hooks.beforeInstall.promise(this),
7582
terminal: this._terminal
7683
};

libraries/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ exports[`CommandLineHelp prints the help for each action: install 1`] = `
627627
[--to-version-policy VERSION_POLICY_NAME]
628628
[--from-version-policy VERSION_POLICY_NAME]
629629
[--subspace SUBSPACE_NAME] [--check-only]
630+
[--resolution-only]
630631
631632
632633
The \\"rush install\\" command installs package dependencies for all your
@@ -755,6 +756,8 @@ Optional arguments:
755756
be enabled in subspaces.json.
756757
--check-only Only check the validity of the shrinkwrap file
757758
without performing an install.
759+
--resolution-only Only perform dependency resolution, useful for
760+
ensuring peer dependendencies are up to date.
758761
"
759762
`;
760763

libraries/rush-lib/src/logic/base/BaseInstallManager.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,18 @@ ${gitLfsHookHandling}
745745
pnpmFilterArgumentValues,
746746
onlyShrinkwrap,
747747
networkConcurrency,
748-
allowShrinkwrapUpdates
748+
allowShrinkwrapUpdates,
749+
resolutionOnly
749750
} = options;
750751

751752
if (offline && this.rushConfiguration.packageManager !== 'pnpm') {
752753
throw new Error('The "--offline" parameter is only supported when using the PNPM package manager.');
753754
}
755+
if (resolutionOnly && this.rushConfiguration.packageManager !== 'pnpm') {
756+
throw new Error(
757+
'The "--resolution-only" parameter is only supported when using the PNPM package manager.'
758+
);
759+
}
754760
if (this.rushConfiguration.packageManager === 'npm') {
755761
if (semver.lt(this.rushConfiguration.packageManagerToolVersion, '5.0.0')) {
756762
// NOTE:
@@ -842,6 +848,10 @@ ${gitLfsHookHandling}
842848
args.push('--strict-peer-dependencies');
843849
}
844850

851+
if (resolutionOnly) {
852+
args.push('--resolution-only');
853+
}
854+
845855
/*
846856
If user set auto-install-peers in pnpm-config.json only, use the value in pnpm-config.json
847857
If user set auto-install-peers in pnpm-config.json and .npmrc, use the value in pnpm-config.json

libraries/rush-lib/src/logic/base/BaseInstallManagerTypes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export interface IInstallManagerOptions {
2222
*/
2323
checkOnly: boolean;
2424

25+
/**
26+
* Whether to only run resolutions. Only supported for PNPM.
27+
*/
28+
resolutionOnly?: boolean;
29+
2530
/**
2631
* Whether a "--bypass-policy" flag can be specified.
2732
*/

0 commit comments

Comments
 (0)