ref(core): Refactor options validation#104
Conversation
| if (auto || (repo && commit)) { | ||
| await ctx.cli.releases.setCommits(options.release, { |
There was a problem hiding this comment.
After seeing that the unit tests fail, I'm realizing that although with this PR we can rely on the global validation, this check here still served a purpose for this unit of code... (hence the unit tests that check for the portions of invalid option here and in addDeploy fail).
Which makes me think... do we prefer central validation (like in this PR currently) or local validation? I could also refactor this and only validate in the respective steps. Open for opinions on this before I adapt tests.
I think the downside of local validation would be that users could end up with a release pipeline that went halfway through before failing (or skipping) e.g. commit or deploy info attachment.
There was a problem hiding this comment.
I like the idea of global validation, because then we can also adjust our types as it flows through the cli pipeline. For example, validateOptions could return a type predicate that states what kind of exact fields are defined on the options object.
There was a problem hiding this comment.
I don't have a strong preference either way. IMHO central validation is fine here and maybe a bit easier to follow, but I'm ok either way.
There was a problem hiding this comment.
Then central validation it is, thanks!
There was a problem hiding this comment.
After discussing this offline, we settled on global validation but with limited TS checks because in this particular situation it's quite tricky and would probably require complex typing.
I made however a small adjustment to the user-facing setCommits type to make it clearer that auto and (repo && commit) are supposed to be mutually exclusive. Nevertheless, I left the checks in place and added a warning in case all three options are provided.
Will mark this PR as ready to review once #104 is merged and I rebased
2bfa590 to
35a95db
Compare
18dfe23 to
d377f81
Compare
This PR refactors the validation of the plugin options. Since Sentry CLI does most of the validation work out of the box, we only need to take care of a few special cases. Therefore:
releasevalue as it simply has to be present to continue with release injection and the release creation pipelineref #91