cli icon indicating copy to clipboard operation
cli copied to clipboard

Is it possible to put `.all-contributorsrc` in subfolders?

Open laike9m opened this issue 5 years ago • 9 comments

Is your feature request related to a problem? Please describe. Right now it seems the .all-contributorsrc file can only be placed in the root folder. I would like to put it in the .github folder, is it possible?

Describe the solution you'd like Not sure, but I feel we can relax the restriction by including .github as a valid location.

Describe alternatives you've considered N/A

Additional context N/A

laike9m avatar Oct 30 '20 06:10 laike9m

You make a good point, yeah, that feature would be useful. PR welcome.

Berkmann18 avatar Oct 31 '20 14:10 Berkmann18

Is it possible to provide some guide, like, pointers to the code that reads the config file? It would be helpful for whoever wants to work on this feature, it could be me or someone else.

laike9m avatar Oct 31 '20 14:10 laike9m

Sure, you'll need to look at https://github.com/all-contributors/all-contributors-cli and https://github.com/all-contributors/all-contributors-cli/blob/master/src/cli.js would be a good start.

Berkmann18 avatar Oct 31 '20 15:10 Berkmann18

Thanks. I plan to work on bot -> cli -> documentation, because I use bot the most.

For implementation details, I'm thinking of the most straightforward way by adding a try-catch around the getFile call

https://github.com/all-contributors/all-contributors-bot/blob/97c0eea38164ce9e7a705e120af85124dc0a5c14/src/tasks/processIssueComment/OptionsConfig/index.js#L36-L39

So it would become something like:

let content: rawOptionsFileContent;
let sha;
try {
    ({content, sha} = await this.repository.getFile(ALL_CONTRIBUTORS_RC));
} catch (error) {
    if (error instanceof ResourceNotFoundError) {
        ({content, sha} = await this.repository.getFile(".github/" + ALL_CONTRIBUTORS_RC));
    }
}

This way, no other code is affected, most of the time there's no overhead. And if users put the config file under .github/, at most there's one extra API call.

What do you think?

laike9m avatar Oct 31 '20 21:10 laike9m

Thanks. I plan to work on bot -> cli -> documentation, because I use bot the most.

It may be wiser to try doing that for the CLI first. Why? Because the bot relies on it (to an extent).

Your implementation idea looks good to me.

Berkmann18 avatar Nov 01 '20 15:11 Berkmann18

It may be wiser to try doing that for the CLI first.

Sure if that's the case. May I ask how the bot is relying on the CLI?

laike9m avatar Nov 01 '20 19:11 laike9m

./src/tasks/processIssueComment/OptionsConfig/index.js and ./src/tasks/processIssueComment/ContentFiles/index.js depends on it.

Berkmann18 avatar Nov 03 '20 19:11 Berkmann18

Hello. I wanted to know if a solution was finally found for this. I'm using All Contributors in my project but I don't want to have .all-contributorsrc in my root folder.

GaryHilares avatar Apr 02 '21 03:04 GaryHilares

@GaryNLOL No, I have not worked on it. Feel free to take over if you want to.

laike9m avatar Apr 02 '21 04:04 laike9m