Are there any decent tutorials on creating a plugi...
# plugins
i
Are there any decent tutorials on creating a plugin in 2.8? I understand the plugin API is not stable.
h
Hello! There are a couple guides, recently updated for 2.8: https://www.pantsbuild.org/docs/common-plugin-tasks I'd love to expand this though and to make
example-plugin
repo much more useful (and up-to-date) What are you hoping to do with your plugin?
i
Primarily I want to do what the shellcheck example is doing but with prettier. The example code isn't executable.
the docs you linked seem different than what I was looking at though 🤔
I see where I went wrong. https://www.pantsbuild.org/docs/rules-api-installing-tools I was directed to this doc and never went back. ... whoops.
h
Okay yeah your best bet is to follow the formatter guide: https://www.pantsbuild.org/docs/plugins-fmt-goal Installing Prettier will probably be the most interesting part. The easiest approach is to use
BinaryPaths
to find it pre-installed on PATH - but you risk devs using different versions of Prettier. I don't see a way to install a prebuilt Prettier binary. So you might need to hook into Yarn or Npm - cc @average-australia-85137 who was looking into similar things
While you're iterating though, the simplest thing is just to use
/absolute/path/to/binary
- you can clean up the installation piece later
i
Yes I definitely want a specific version of a formatter because each version formats differently than the previous versions. I'll see where I land. Thank you.
👍 1
h
Cool, please feel free to ask questions here 🙂
a
@incalculable-yacht-75851 I have a plugin that installs webpack & runs a build script over some targets (using the installed NPM) (as Eric was saying!) If anything there sounds useful feel free to reach out! (Code here: https://github.com/compyman/pants-node)
🎉 2