Skip to content
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

feat(patch)!: Improves patches #4218

Merged
merged 4 commits into from
Mar 18, 2022
Merged

feat(patch)!: Improves patches #4218

merged 4 commits into from
Mar 18, 2022

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Mar 14, 2022

What's the problem this PR addresses?

The yarn patch-commit commands generates an incorrect configuration which often results in the patch not being correctly applied without tweaking the config.

How did you fix it?

The command will now be smarter in the configuration it generates. In particular:

  • If workspace dependencies are patched, this will be reflected in their dependency sets (rather than resolutions)
  • Otherwise, the resolutions field will reference the correct original range(s) rather than an arbitrary one

A few other things are also improved:

  • Patches can now reference paths via the ~/ prefix, in which case it'll be relative to the project root
  • The yarn patch command now supports a -u flag which will reapply existing patches

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis arcanis changed the title Fixes the changes patch-commit generates feat(patch): Improves patches Mar 15, 2022
@arcanis arcanis merged commit f68aed4 into master Mar 18, 2022
@arcanis arcanis deleted the mael/patch-commit branch March 18, 2022 23:28
@merceyz merceyz mentioned this pull request Mar 19, 2022
3 tasks
@merceyz
Copy link
Member

merceyz commented Mar 19, 2022

Running patch-commit for a package that has a builtin patch now fails with

Internal Error: Assertion failed: Expected the resolution to have been registered
    at PatchCommitCommand.execute (/berry/packages/plugin-patch/sources/commands/patchCommit.ts:82:15)  
    at PatchCommitCommand.validateAndExecute (/berry/.yarn/__virtual__/clipanion-virtual-6f45223597/0/cache/clipanion-npm-3.2.0-rc.4-8470d16306-c9d8ba9e16.zip/node_modules/clipanion/lib/advanced/Command.js:67:26)
    at Cli.run (/berry/.yarn/__virtual__/clipanion-virtual-6f45223597/0/cache/clipanion-npm-3.2.0-rc.4-8470d16306-c9d8ba9e16.zip/node_modules/clipanion/lib/advanced/Cli.js:149:24)
    at Cli.runExit (/berry/.yarn/__virtual__/clipanion-virtual-6f45223597/0/cache/clipanion-npm-3.2.0-rc.4-8470d16306-c9d8ba9e16.zip/node_modules/clipanion/lib/advanced/Cli.js:158:28)
    at exec (/berry/packages/yarnpkg-cli/sources/main.ts:148:7)
    at run (/berry/packages/yarnpkg-cli/sources/main.ts:48:7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants