Comments (10)
Yeah, cli first tries to load context from the global context store and if it fails it checks in the file system for a file naming asyncapi.yml
, asyncapi.yaml
or asyncapi.json
.
Use context anyway (think its checking for defaults not sure?)
@boyney123 here the CLI persists some files paths in the context which is just a .asyncapi
file in the homedir. If file path is not present then cli checks this to determine the file path and if this file is missing or not yet created then it looks in the working directory.
So if you have no context created and you have an asyncapi.yml
file in your working directory then cli should pick up the asyncapi.yml
file.
Will check this 👍🏻
from cli.
Any thoughts on this @jonaslagoni @Souvikns?
Or maybe I'm not understanding how context works
from cli.
Good question, I see pros and cons for both tbh.
I guess the question falls back to, what is the best user experience when you need to perform actions with specific (or multiple) AsyncAPI documents.
I could see it as being a mix tbh. Where if you want to use context use that, or if you want to specifically provide an input to a specific command, you should be able to do that.
Regarding this issue, I would not assume the CLI to automatically look for a local file, as it is quite error-prone, cause I think it would rarely be called asyncapi.yml
, so going through all files would be, too much IMO 😄
from cli.
asyncapi start studio
should be consistent with the rest of the CLI. There was and I hope still is 😄 a fallback mechanism for loading AsyncAPI file, it basically looks for context, default file asyncapi.yml
in the context of where command is run, etc!
so yes, we should do automatic for the use, same as in other commands, but also allow to pass --file
or --context
flags to overwrite defaults. And yes, we should not force user to learn about context
concept but throw a full help message that explains what different options user can pick, now I see ContextError: No context is set as current, please set a current context.
but I'm 100% sure there was a better error displayed with full help text, but don't see it anymore 😢
from cli.
Ahh yeah I just was reading around and found that is already does fall back to files (well tries too).
https://github.com/asyncapi/cli/blob/master/src/models/SpecificationFile.ts#L43
Looks like this line is happening before https://github.com/asyncapi/cli/blob/master/src/models/SpecificationFile.ts#L50
When nothing it passed it will go to load context and just fail if nothing is there, I think this fix is moving those two around.
So flow:
- Use file/context if provided
- Check for local file
I think the current flow is :
- Use file or context name if provided
- Use context anyway (think its checking for defaults not sure?)
- Fall back to file system
But the bug is that set 2 throws the error and never falls back to reading the file system.
from cli.
Yeah, I checked, and even if you don't have the .asyncapi
file in your homedir it is not looking into the working directory but failing instead.
And this is happening because of this
cli/src/models/SpecificationFile.ts
Lines 42 to 48 in a5311ff
specifically in line
cli/src/models/SpecificationFile.ts
Line 45 in a5311ff
when when no input is passed and it does not find the current context it fails and does not look in the working directory.
from cli.
Thanks for looking @Souvikns
when when no input is passed and it does not find the current context it fails and does not look in the working directory.
Yeah I think the fix would be just moving the two parts around, I can raise a PR for this to see what you think
from cli.
Made a fix here : #130
from cli.
I think we can close this issue now right?
from cli.
Yeah thanks @Souvikns
from cli.
Related Issues (20)
- JavaFileGenerator in the generate models command ONLY generates the java model classes correctly if the openapi specs follow the java naming conventions HOT 9
- Chocolatey release workflow is not working. HOT 2
- Integration of AsyncAPI CLI with studio.asyncapi.com via WebSocket/HTTP Server HOT 1
- Enable new feature from Generator to support templates hosted as private packages HOT 2
- Request/reply semantics not clear in generated html HOT 2
- Studio started with AsyncAPI cli tools does not support version 3.0 HOT 3
- Add a lifecycle file to the default glee example HOT 2
- Unclear usage of `asyncapi start` HOT 4
- Validate command output is polluted by noisy messages HOT 2
- Add codeclimate diagnostics-format to validate command
- Old version of Studio wrapped in CLI HOT 1
- Ability to score quality of async api specification file HOT 10
- CLI is unable to bundle spec V3 documents using bundle command HOT 4
- [DART] We need a flag to generate models with json annotation HOT 1
- [CLI] Measure AsyncAPI DX metrics HOT 2
- Divide "Maintainer" role into two categories: Triager and Committer HOT 3
- Docker image fails to support Glee HOT 1
- When installed as debian package "asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template" silently returns 1 HOT 5
- CLI cannot generate fromTemplate when specification contains file path $refs HOT 2
- Having invalid examples in spec fails CLI build HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.