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

[RUMF-1357] Add a peer dependency between rum and logs packages #1668

Merged
merged 4 commits into from
Aug 16, 2022

Conversation

agrobbin
Copy link
Contributor

@agrobbin agrobbin commented Aug 2, 2022

Motivation

I suggested this, so made the PR too! This closes #1666.

Changes

The RUM docs (here and here) state that it is recommended to match versions, so this seems like a beneficial addition!

I also believe (though I'm having a hard time fully parsing the Dependabot source to be sure) it will force Dependabot to update both @datadog/rum and @datadog/logs in tandem if both are included dependencies of a project.

Testing

My primary concern from a "testing" perspective is whether Lerna will know to update these when a new version is released. I'm not familiar w/ Lerna, or the configuration for it, but hopefully this is a starting point!

@agrobbin agrobbin requested review from a team as code owners August 2, 2022 11:39
@bits-bot
Copy link

bits-bot commented Aug 2, 2022

CLA assistant check
All committers have signed the CLA.

@BenoitZugmeyer
Copy link
Member

BenoitZugmeyer commented Aug 2, 2022

Thank you for your PR! Could you make those peer dependencies "optional" with peerDependenciesMeta?

As you guessed, lerna will be an issue for that. They intentionally removed support for it, and closed a feature request asking for an option to bump them on publish. I think we'll need to tweak our version script to bump it separately.

You can try it yourself with something like npx lerna version --no-push --no-git-tag-version -y major

@agrobbin agrobbin force-pushed the rum-logs-peer-dependencies branch from 81517cc to 2bf4c5e Compare August 2, 2022 17:47
@agrobbin
Copy link
Contributor Author

agrobbin commented Aug 2, 2022

@BenoitZugmeyer good call, I just added peerDependenciesMeta. I'm not sure what the idea might be re: the cli script. It'd be ideal to programmatically manipulate the contents of package.json, but I'm not terribly familiar with that landscape. A quick Google suggests npe, json, and a few others, but I'm definitely open to some suggestions here!

Additionally, after reading some of the comments in lerna/lerna#1575, I do want to confirm that this is the correct usage of peerDependencies. I still think it makes sense, but this isn't my project. 😆

@agrobbin agrobbin force-pushed the rum-logs-peer-dependencies branch from 2bf4c5e to b443795 Compare August 2, 2022 18:03
@BenoitZugmeyer
Copy link
Member

I just added peerDependenciesMeta.

Thank you!

I'm not sure what the idea might be re: the cli script. It'd be ideal to programmatically manipulate the contents of package.json, but I'm not terribly familiar with that landscape. A quick Google suggests npe, json, and a few others, but I'm definitely open to some suggestions here!

Mmh I was thinking about a simple "find and replace" script (ex: with sed), or if we want to do something fancier, a 3 lines nodejs script like:

const pkg = JSON.parse(fs.readFileSync('package.json'))
pkg.peerDependencies["@browser-logs"] = pkg.version
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2))

But don't worry about that, we can take over your PR to make the final adjustments 🙂

Additionally, after reading some of the comments in lerna/lerna#1575, I do want to confirm that this is the correct usage of peerDependencies. I still think it makes sense, but this isn't my project. 😆

I agree that it still makes sense for us. I think arguments are a bit outdated, for example “peerDependencies themselves only warn, not auto-install” is not true anymore: it either don't warn (optional) or auto-install (required). It made sense when peer dependencies were kind of required, but we want our packages to be optional.

@agrobbin agrobbin force-pushed the rum-logs-peer-dependencies branch from b443795 to e78d3f9 Compare August 4, 2022 15:25
@agrobbin
Copy link
Contributor Author

agrobbin commented Aug 4, 2022

@BenoitZugmeyer ah got it, that makes sense! I've enabled maintainer editing access on my branch, which hopefully is what you need to finalize the bin/cli script changes. Let me know if there is anything else I need to do.

@BenoitZugmeyer BenoitZugmeyer changed the title Add a peer dependency between rum and logs packages [RUMF-1357] Add a peer dependency between rum and logs packages Aug 10, 2022
@agrobbin
Copy link
Contributor Author

@BenoitZugmeyer love it!

Copy link
Contributor

@liywjl liywjl left a comment

Choose a reason for hiding this comment

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

Nice work!

Comment on lines +4 to +12
// This script updates the peer dependency versions between rum and logs packages to match the new
// version during a release.
//
// Lerna [intentionally removed support for it][1], and [closed a feature request asking for an
// option to bump them on publish][2], but we still want to make sure this version is updated as
// well to warn users who use different versions of RUM and Logs packages.
//
// [1]: https://github.com/lerna/lerna/commit/bdbfc62966e5351abfeac77830f9d47b6d69f1b1
// [2]: https://github.com/lerna/lerna/issues/1575
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use JSDoc?

@BenoitZugmeyer BenoitZugmeyer merged commit 33f310f into DataDog:main Aug 16, 2022
@BenoitZugmeyer
Copy link
Member

BenoitZugmeyer commented Aug 16, 2022

Thank you again for your contribution @agrobbin , this will be released shortly.

@agrobbin
Copy link
Contributor Author

Awesome, thanks @BenoitZugmeyer!

@agrobbin
Copy link
Contributor Author

Well, looks like I was wrong about Dependabot bumping these together. 😢

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.

Establish peer dependency between rum and logs packages?
5 participants