Coder Social home page Coder Social logo

Add `asyncapi bundle` command about cli HOT 17 CLOSED

asyncapi avatar asyncapi commented on July 28, 2024 2
Add `asyncapi bundle` command

from cli.

Comments (17)

Souvikns avatar Souvikns commented on July 28, 2024 1

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.

from cli.

amanbedi1 avatar amanbedi1 commented on July 28, 2024 1

@Souvikns thanks its working.

from cli.

amanbedi1 avatar amanbedi1 commented on July 28, 2024

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.

from cli.

amanbedi1 avatar amanbedi1 commented on July 28, 2024

I just want to ask in this command the first file passed to command should be base file or not.

from cli.

derberg avatar derberg commented on July 28, 2024

@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?

from cli.

Souvikns avatar Souvikns commented on July 28, 2024

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.

from cli.

amanbedi1 avatar amanbedi1 commented on July 28, 2024

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.

from cli.

derberg avatar derberg commented on July 28, 2024

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

from cli.

Souvikns avatar Souvikns commented on July 28, 2024

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.

from cli.

derberg avatar derberg commented on July 28, 2024

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

from cli.

amanbedi1 avatar amanbedi1 commented on July 28, 2024

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

from cli.

Souvikns avatar Souvikns commented on July 28, 2024

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

from cli.

amanbedi1 avatar amanbedi1 commented on July 28, 2024

hey @Souvikns @derberg I just made a PR. Please review it

from cli.

github-actions avatar github-actions commented on July 28, 2024

This issue has been automatically marked as stale because it has not had recent activity 😴

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 ❤️

from cli.

github-actions avatar github-actions commented on July 28, 2024

This issue has been automatically marked as stale because it has not had recent activity 😴

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 ❤️

from cli.

asyncapi-bot avatar asyncapi-bot commented on July 28, 2024

🎉 This issue has been resolved in version 0.36.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from cli.

s1mrankaur avatar s1mrankaur commented on July 28, 2024

@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.

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.