feat(config): Automatically detect GitHub config when missing - #208
Conversation
4de0ecd to
7563748
Compare
We don't need people to explicitly state `github` global configuration as it can be detected from `git` itself. Since we rely on the presence of a `git` repo in `publish` and `prepare` we can safely rely on this too and remove another piece of redundant configuration. This patch also adds tests around this.
fa5eb63 to
4966757
Compare
|
I will add the tests for this new functionality separately as they cause some very hard to debug import errors. I'm guessing it has something to do with Jest and mocking but I've already spent multiple full days on debugging without any luck and now this PR blocks #209 (due to its |
| config: TargetConfig, | ||
| artifactProvider: BaseArtifactProvider | ||
| artifactProvider: BaseArtifactProvider, | ||
| githubRepo: GithubGlobalConfig |
There was a problem hiding this comment.
Can we default this to null/undefined to avoid having to modify every target, since most targets don't need this?
There was a problem hiding this comment.
I'm not a fan of that as then we need to do non-null checks down the line. This will especially be pronounced in publish where we get all the targets without knowing the exact target type (as it is determined at runtime).
There was a problem hiding this comment.
Do we? Why would we need to check for null if the only targets that use githubRepo are the ones that will actually have it in the constructor?
There was a problem hiding this comment.
Even if they have it in the constructor, the type system will force us to make sure it is not null. We may be able to overcome this so I'll look into that later.
We don't need people to explicitly state
githubglobal configurationas it can be detected from
gititself. Since we rely on the presenceof a
gitrepo inpublishandpreparewe can safely rely on thistoo and remove another piece of redundant configuration.
Most of the changes in this patch are related to the conversion of
getGlobalGithubConfigfrom a sync function to an async function. There were also a few places which relied onconfig.githubdirectly which is also removed now.Ideally we'd abstract the raw config object in the future and provide a global, normalized configuration to all downstream dependent code.
This patch also adds tests around this new functionality.