all-contributors/cli

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

laike9m opened this issue · 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

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

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.

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?

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.

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?

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

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.

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