Skip to content

[rush] supports "rush-pnpm patch-remove" command #4911

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

Merged
merged 3 commits into from
Sep 9, 2024
Merged
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,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Support the `rush-pnpm patch-remove` command.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
17 changes: 17 additions & 0 deletions libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ export class RushPnpmCommandLineParser {
}
break;
}
case 'patch-remove': {
const semver: typeof import('semver') = await import('semver');
/**
* The "patch-remove" command was introduced in pnpm version 8.5.0
*/
if (semver.lt(this._rushConfiguration.packageManagerToolVersion, '8.5.0')) {
this._terminal.writeErrorLine(
PrintUtilities.wrapWords(
`Error: The "pnpm patch-remove" command is added after pnpm@8.5.0.` +
` Please update "pnpmVersion" >= 8.5.0 in ${RushConstants.rushJsonFilename} file and run "rush update" to use this command.`
) + '\n'
);
throw new AlreadyReportedError();
}
break;
}

// Known safe
case 'audit':
Expand Down Expand Up @@ -447,6 +463,7 @@ export class RushPnpmCommandLineParser {
const subspaceConfigFolder: string = this._subspace.getSubspaceConfigFolderPath();

switch (commandName) {
case 'patch-remove':
case 'patch-commit': {
// why need to throw error when pnpm-config.json not exists?
// 1. pnpm-config.json is required for `rush-pnpm patch-commit`. Rush writes the patched dependency to the pnpm-config.json when finishes.
Expand Down
Loading