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

Add a Plugin system #237

Merged
merged 4 commits into from
May 15, 2023
Merged

Add a Plugin system #237

merged 4 commits into from
May 15, 2023

Conversation

mansona
Copy link
Contributor

@mansona mansona commented Jul 1, 2022

hello again folks 👋

I know it has been a little while since I submitted #171 but I am back! and I have finally implemented a version of the plugin system that you recommended 🎉

This PR add the --plugin option to the cli and as you suggested it will look for a locally installed package auto-changelog-github if you pass --plugin github

I have implemented my previous PR as a plugin and you can see it here https://github.com/mansona/auto-changelog-github

I know we should probably add this to the documentation but I wanted to submit my first draft so that we can discuss it before finalising the design 👍

(side note: I live-streamed this implementation on twitch if you want to catch the VOD before it gets deleted in 2 weeks 😂 https://twitch.tv/real_ate )

@@ -45,6 +45,7 @@
"dependencies": {
"commander": "^7.2.0",
"handlebars": "^4.7.7",
"import-cwd": "^3.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

we should not depend on packages from this author; they've committed to making them all ESM-only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

eh... I don't really want to weigh in on a "don't use packages from sindresorhus" conversation regardless of what I personally think about the topic but this isn't an issue for import-cwd anyway since it's not possible to actually "import from cwd" in ESM land 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

it definitely is, with dynamic import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so... I don't understand what is happening here. I am submitting a feature in good faith (based on a suggestion in my previous PR review) and suddenly things have gotten incredibly hostile. And I don't understand why you're brining this up @ljharb, are you a maintainer of this project or just a "concerned bystander"?

And on the point of it not being possible to "import from cwd" I get the impression that we're talking past each other here. I was implicitly saying that you can't "import from cwd" without changing the structure of the code significantly. As it turns out we're doing a dynamic require here anyway and already in an async function so it's possible to do import with a dynamic import here but that's not the point I was trying to make. If you want some more context you can follow the thread through the following links:

sindresorhus/import-cwd#3
sindresorhus/import-from#9
nodejs/node#36396
https://github.com/nodejs/loaders

Copy link
Contributor

Choose a reason for hiding this comment

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

I’m bringing it up because I’m a very concerned bystander - i use this project heavily, and it affects me greatly to have it add a dependency that adds an undue maintenance burden. I’m sorry this is coming across as hostile; I’m merely reviewing a PR and providing a suggestion based on my extensive experience.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's right. The safer alternative i to either use a different author's package, or to write it ourselves with fs.readdir.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cookpete yes that's my perspective on this, it won't start failing overnight unless we update a major version of the dependency. My personal view is that this library is working as-is and we shouldn't "prematurely optimise" our approach based on a hypothetical future 🤷

But I'm more interested in getting this PR merged than having any philosophical or political debates so if you say that you would prefer me to remove this library then I'll do it 👍

Copy link
Owner

Choose a reason for hiding this comment

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

If there’s an easy replacement that makes more sense, let’s use that. If not then let’s just go with import-cwd and deal with the fallout if anything ever happens. The repo hasn‘t been touched for 3 years, and it’s been over 1.5 years since the commitment (and backlash) to convert everything to ESM. I get @ljharb’s concern but I’m also keen to not leave too much stuff floating around for too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey folks 👋 I'm still interested in getting this merged. It's been almost a year and import-cwd hasn't gone "esm only" so I guess we're safe?

Is there anything else I need to do to get this PR merged?

Copy link
Contributor

Choose a reason for hiding this comment

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

We're still not safe; he plans to migrate all of them eventually, but it's fine to land it as long as we're aware that we'll want to migrate off it ASAP.

@cookpete
Copy link
Owner

Finally got a chance to look through this. I like the idea – I’m just not keen on the pattern of mutating the passed in array. It feels a bit untidy? Is there a nicer way that lets the plugin return a new array instead?

@cookpete
Copy link
Owner

Ok, I had another look and I can make peace with mutating the data. I think alternatives would be more complex than it’s worth. I can also make peace with the import-cwd concerns.

I’ve tidied some bits up and changed the option to --plugins plural (just seemed more sensible).

Nice work!

@cookpete cookpete merged commit 37cdfed into cookpete:master May 15, 2023
@mansona
Copy link
Contributor Author

mansona commented Jun 3, 2023

omg thanks for merging this 🎉 you've made my day

Any chance of a release?

@storageddd
Copy link

Hey, guys! When release is coming?

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.

4 participants