feat: set fallback to read local dir for asyncapi file if no context is present#130
Conversation
|
This would be a big decision, as the overall functionality would change, I think we need to ask @derberg and @fmvilas for this. Because when we decided on the order of the fallback we agreed on this because the functionality was for the power users who would want to be using the current context if he has spent time setting it up. |
|
ah OK. Isn't this the part that would check the context? Happens before the fallback? Or are you talking about the users that setup context, but don't pass in the filepath or context name? |
|
That path figures out what that input is. Is the input a file path or a context name this does not run as we are not passing any input as the command is |
|
Yeah, this same bug hit me during my QCon presentation. I typed |
derberg
left a comment
There was a problem hiding this comment.
- there is come console.log in code
- make sure PR title follows imperative mode. Anyway title also needs review to reflect implementation
- context is still important, it is just that in case of no default context, there should not be an error like we get now, but fallback mechanism should work further and in the end the file from root should be picked
- some tests are failing
start studio command if no context is present it will fallback to read local dir for asyncapi file
|
Thanks, @derberg.
😅👀 let's pretend you didn't see anything 😂
Do you mean imperative mood? The first time I heard of this, can you give an example of what you would expect? I changed it, let me know what you think :).
OK makes sense. I changed the flow so now will check context, if that fails it will then try and read the local dir for any files. Is this what you mean? |
see what?
yes 😅 basically follow https://chris.beams.io/posts/git-commit/#imperative so we stay consistent and we don't get one commit like
yup, exactly |
Thanks, @derberg this is great and helps loads! I will amend the title 🙇
Makes perfect sense mate, thank you! |
start studio command if no context is present it will fallback to read local dir for asyncapi file
derberg
left a comment
There was a problem hiding this comment.
LGTM
@Souvikns thoughts?
We still have the problem of course that if no local file is present then ContextError: No context is set as current, please set a current context. is shown. But I think there is a bigger problem with how we are passing errors, as so far I see https://github.com/asyncapi/cli/blob/master/src/errors/validation-error.ts#L19 will never get called even if I do asyncapi validate without context or local file
If no file is present in the working directory and also there is no current context set, then
Yeah, this is not something that is supposed to happen. Ok so let me write about the issue in more details: So when I run But now this message never gets printed, and instead of this we have a error message like this This error is getting thrown here: cli/src/models/SpecificationFile.ts Line 43 in b9cc938 When we do not find any current context we are throwing
|
|
@Souvikns yeah, definitely a separate issue, created it here #148 @boyney123 just update with latest master and we get that one merged 🥳 |
|
Kudos, SonarCloud Quality Gate passed!
|
|
🎉 This PR is included in version 0.10.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |








Description
A fix for #127 it now will check the file directory before finally checking the context again (and throwing errors).