cli
                                
                                 cli copied to clipboard
                                
                                    cli copied to clipboard
                            
                            
                            
                        Add `asyncapi bundle` command
This issue is for https://www.openforce.tech/ participants. If you do not participate in this even please pick up other issue from this repo, there is plenty of help needed 😄
Reason/Context
We need to enable the community to use all AsyncAPI tools in CLI if only possible -> https://github.com/asyncapi/bundler
Description
- add new command asyncapi bundlethat uses https://github.com/asyncapi/bundler and enable users to bundle multiple AsyncAPI files into one
- user should be able to pass multiple files to the bundler asyncapi bundler <context-1/filepath1/url1> <context-2/filepath2/url2> <context-3/filepath3/url>3(getting file from context or filepath or URL is already provided in CLI, you just useloadfunction)
This issue is for https://www.openforce.tech/ participants. If you do not participate in this even please pick up other issue from this repo, there is plenty of help needed 😄
@Souvikns pinging you so you are aware 😄
HI @derberg @Souvikns I am Amanpreet a contributor to OpenForce 2022. I would like to work on this issue. I would be making a PR as soon as I am done with resolving the issue. Thank you.
I just want to ask in this command the first file passed to command should be base file or not.
@Souvikns what do you think about the question from @amanbedi1 ? I'm personally not 100% sure but I think non of the files should be considered a base, but simply by default we should put bundled document in the terminal output, and there should also be an option like --output that user could use to specify where to output bundled doc as a file. Thoughts?
I just want to ask in this command the first file passed to command should be base file or not.
bundler takes an array of files but it does not read the files, so you have to read and pass in the content. And base is an option that you can pass. base is for when you want to preserve some schema objects while you are merging multiple separate specifications.
and there should also be an option like --output that user could use to specify where to output bundled doc as a file. Thoughts?
Yeah actually when bundler had a CLI it had a --output but since it is library now it just returns a document object and in the CLI interface we can implement the --output. My thought behind this was since server-api will also integrate bundler it would be easier to just bundle and then send the final document over REST.
Ok so I think I just have to output bundled file in terminal or --output  flag  specify where to output bundled doc as a file.
I will try to resolve it.
My thought behind this was since server-api will also integrate bundler it would be easier to just bundle and then send the final document over REST.
what do you mean @Souvikns
I mean there is no way to output a file to a certain directory right now in bundler. It just gives you string and JSON object. So bundler does not care about file system so tools like studio where we do not have access to the file system can also use bundler same goes for server-api which will just send the data over HTTP request.
but this is CLI where we implement bundler option, so CLI should handle the option to output bundler-provided data into a file. Same like server-api will handle sending reply with JSON object. As you wrote, bundler is just to bundle and provide JSON Object (or string) and tools that integrate it, like CLI or Studio or server-api handle rest, like post processing of bundler output.
we just need to remember that this --output flag just like --watcher should be generic, reusable, so other commands can easily use it too, like diff for example
we just need to remember that this --output flag just like --watcher should be generic, reusable, so other commands can easily use it too, like diff for example
Oh now I get you 😄, yeah definitely --output should be reusable.
Hey @derberg @Souvikns I am almost done with bundle command but there is a problem when I try to bundle below files the output is not as expected. So can you guide me how to do this. Files are attached below.
signup.yaml
asyncapi: '2.2.0'
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user Signup 
channels:
  user/signedup:
    subscribe:
      message:
        payload:
          type: object
          properties:
            displayName:
              type: string
            email:
              type: string
              format: email
login.yaml
asyncapi: '2.2.0'
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signup
channels:
  user/loggenin:
    subscribe:
      message:
        payload:
          type: object
          properties:
            displayName:
              type: string
Bundled (terminal) output
  asyncapi: '2.2.0',
  info: {
    title: 'Account Service',
    version: '1.0.0',
    description: 'This service is in charge of processing user signup'
  },
  channels: {
    'user/signedup': { subscribe: [Object] },
    'user/loggenin': { subscribe: [Object] }
  }
Expected output
asyncapi: '2.2.0'
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge for processing user authentication 
channles:
  user/signedup:
    subscribe:
      message:
        payload:
          type: object
          properties:
            displayName:
              type: string
            email:
              type: string
              format: email
  user/loggedin:
    subscribe:
      message:
        payload:
          type: object
          properties:
            displayName:
              type: string
Would be better if you open a WIP PR then I can take a look at your changes, but this is happening most probably because you are using document.json() that's why you are getting output in JSON format for YAML format you have to use document.yml()  you can refer this document to learn more https://github.com/asyncapi/bundler/blob/master/API.md#Document+yml
@Souvikns thanks its working.
hey @Souvikns @derberg I just made a PR. Please review it
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart:
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart:
:tada: This issue has been resolved in version 0.36.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
@amanbedi1 @Souvikns My yml file has
     $ref: ./components/channels/site-channels.yml#/channels/sites-change
The bundle command errors out with
ENOENT: no such file or directory,
as it doesn't get the path right.
My structure is
event-catalog2/
  event-specs/
     channels/
       site-channels.yml
     asyncpi.yml
and the command was looking for C:\BLBLA\event-catalog2\components\channels\site-channels.yml'
i.e skipped event-specs folder somehow.