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

Pass packageInfos into prepublish, postpublish, and postbump hooks #900

Conversation

tronguye
Copy link
Contributor

Same end goal as #896

We are trying to have our yarn 1 repo be able to:

Locally, refer to local workspace package version using the * version
At publish time, change to ^x.y.z, where x.y.z is the post-bump version

To accomplish this, we are hoping to use the prepublish hook to change the internal packages to ^x.y.z. Passing the post-bump versions to the prepublish hook would allow for this to happen without file i/o on our end

@tronguye tronguye changed the title Pass bump versions into prepublish, postpublish, and postbump hooks Pass packageInfos into prepublish, postpublish, and postbump hooks Jul 21, 2023
await hook(path.dirname(packageInfo.packageJsonPath), packageInfo.name, packageInfo.version);
const packagePath = path.dirname(packageInfo.packageJsonPath);

await hook(packagePath, packageInfo.name, packageInfo.version, packageInfos);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ecraig12345 Should we clone package infos before passing? We're susceptible to side effects by hooks in the current calling pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked param as Readonly<> in the typing of hooks. Doesn't technically stop a consumer from casting as writable and causing side effects. lmk what you think

@ecraig12345 ecraig12345 enabled auto-merge (squash) July 21, 2023 18:19
@ecraig12345 ecraig12345 merged commit 16253f8 into microsoft:master Jul 21, 2023
4 checks passed
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.

2 participants