Skip to content

feat: bundle ASYNCAPI Command added - #260

Closed
amanbedi1 wants to merge 3 commits into
asyncapi:masterfrom
amanbedi1:219_asyncapi_bundle_command
Closed

amanbedi1 wants to merge 3 commits into
asyncapi:masterfrom
amanbedi1:219_asyncapi_bundle_command

Conversation

@amanbedi1

Copy link
Copy Markdown
Contributor

Description

  • bundle asyncapi cli command added using @asyncapi/bundle package.

  • New --output flag also added.

  • This commands take multiple files and bundled to provide output to terminal or redirect to file using --output flag.

  • Command structure:
    bundle <file1.yml> <file2.yml> <file3.yml>

    bundle <file1.yml> <file2.yml> <file3.yml> --output=output.yml

    bundle <file1.yml> <file2.yml> <file3.yml> -o output.yml

Related issue(s)
#219

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Souvikns

Souvikns commented Mar 20, 2022 •

Copy link
Copy Markdown
Member

@amanbedi1 you have lint issues, you can run npm run lint:fix to fix all the auto fixable lint errors, for the others you have to manually fix them.

@amanbedi1

Copy link
Copy Markdown
Contributor Author

@Souvikns actually there is linting error of @ts-ignore so how to resolve this.

@Souvikns Souvikns left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amanbedi1 good job 👍🏻 left some small comments

The rest of the lint errors are sonarjs errors I would suggest you can just refactor your code as per the rules.

Comment thread src/commands/bundle.ts
import fs from 'fs';
// @ts-ignore
import yaml from 'js-yaml';
// @ts-ignore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore

One thing you can do is this ⏫ for now.

Comment thread src/commands/bundle.ts
Comment on lines +61 to +67
async function loadSpecFilesfromFilePaths(filePaths:string[]) {
const specFilesPromises = filePaths.map(async filePath => {
const specFile = await load(filePath);
return specFile.text();
});
return await Promise.all(specFilesPromises);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a function for this that you can reuse -

export async function load(filePathOrContextName?: string, loadType?: LoadType): Promise<Specification> { // NOSONAR

Also you don't have to read input from argv, instead, you can use turn off strict mode and use args you can read this here https://oclif.io/docs/args by doing static strict = false. This way you still generate meaningful documentation in help.

It enables users to bundle/merge specification into one

USAGE
  $ asyncapi bundle [-h] [-o <value>]

FLAGS
  -h, --help            Show CLI help.
  -o, --output=<value>  Path to the output file

DESCRIPTION
  It enables users to bundle/merge specification into one

Right now it is a bit confusing on where to pass in the file paths.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will do required changes.

@derberg

derberg commented Apr 4, 2022

Copy link
Copy Markdown
Member

@amanbedi1 do you plan to continue working on it? Open Force ended but since you started during the event, it is ok if you complete work later

@derberg

derberg commented Jul 5, 2022

Copy link
Copy Markdown
Member

I think @amanbedi1 decided to discontinue, let me close, we can always reopen or new PR can be created

@derberg derberg closed this Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants