Skip to content

Conversation

@suhdonghwi
Copy link

What's the problem this PR addresses?

Currently, @yarnpkg/plugin-essentials only provides "after" hooks (afterWorkspaceDependencyAddition, afterWorkspaceDependencyReplacement, afterWorkspaceDependencyRemoval) that fire after dependencies are added, updated, or removed via CLI commands.

There is currently no way to intercept or control the behavior before package version suggestions or installations take place. Also "after" hooks do not provide enough information to determine whether the user explicitly specified a version range in CLI commands.

How did you fix it?

Added three new hooks to the Hooks interface in @yarnpkg/plugin-essentials that mirror the existing "after" hooks:

beforeWorkspaceDependencyAddition?: (
  workspace: Workspace,
  target: suggestUtils.Target,
  descriptor: Descriptor,
) => Promise<void>;

beforeWorkspaceDependencyReplacement?: (
  workspace: Workspace,
  target: suggestUtils.Target,
  fromDescriptor: Descriptor,
  toDescriptor: Descriptor,
) => Promise<void>;

beforeWorkspaceDependencyRemoval?: (
  workspace: Workspace,
  target: suggestUtils.Target,
  descriptor: Descriptor,
) => Promise<void>;

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant