all-contributors / cli

Tool to help automate adding contributor acknowledgements according to the all-contributors specification ✨
https://allcontributors.org
Other
414 stars 146 forks source link

feat: use Prettier to write config file, if possible #356

Closed JoshuaKGoldberg closed 1 year ago

JoshuaKGoldberg commented 1 year ago

What: If the user has the prettier package available in their project and has a Prettier config file (e.g. .prettierrc.json), Prettier will be used to write .allcontributorsrc files.

Why: See #347.

How: Adds prettier as an optional dependency. Augments the config writing logic to:

  1. Attempt to require('prettier')
  2. Find the nearest Prettier config for the file with prettier.resolveConfigFile.sync
  3. Use Prettier to format the file with that config ...falling back to the traditional JSON.stringify(content, null, 2) if any of that fails.

Checklist:

Are optionalDependencies the way to go? I can never keep track of the latest preferences around optionals/peers/etc.

Berkmann18 commented 1 year ago

@all-contributors Please add @JoshuaKGoldberg for ideas and code

allcontributors[bot] commented 1 year ago

@Berkmann18

I've put up a pull request to add @JoshuaKGoldberg! :tada:

all-contributors-release-bot commented 1 year ago

:tada: This PR is included in version 6.26.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

dubzzz commented 1 year ago

Not sure it's fully related (I'm still investigating) but when passing from 6.25.0 to 6.26.0 of the project the command all-contributors add username doc,code,test stopped working and fully erased the content of the file .all-contributorsrc. An easy repro is to take https://github.com/dubzzz/fast-check and run yarn contributor:add username doc,code,test on it.


UPDATE 1

No issue with version 6.25.1. Issue starts at 6.26.0.