Skip to content

Commit

Permalink
feat: use core flags in bundle command
Browse files Browse the repository at this point in the history
  • Loading branch information
Amzani committed Jun 4, 2024
1 parent 8caa994 commit beecfb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
10 changes: 2 additions & 8 deletions src/commands/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Flags } from '@oclif/core';
import Command from '../core/base';
import bundle from '@asyncapi/bundler';
import { promises } from 'fs';
import path from 'path';
import { Specification } from '../core/models/SpecificationFile';
import { Document } from '@asyncapi/bundler/lib/document';
import { bundleFlags } from 'core/flags/bundle.flags';

const { writeFile } = promises;

Expand All @@ -21,13 +21,7 @@ export default class Bundle extends Command {
'asyncapi bundle ./asyncapi.yaml -o final-asyncapi.yaml --base ../public-api/main.yaml --baseDir ./social-media/comments-service',
];

static flags = {
help: Flags.help({ char: 'h' }),
output: Flags.string({ char: 'o', description: 'The output file name. Omitting this flag the result will be printed in the console.' }),
base: Flags.string({ char: 'b', description: 'Path to the file which will act as a base. This is required when some properties need to be overwritten.' }),
baseDir: Flags.string({ char: 'd', description: 'One relative/absolute path to directory relative to which paths to AsyncAPI Documents that should be bundled will be resolved.' }),
xOrigin: Flags.boolean({ char: 'x', description: 'Pass this switch to generate properties "x-origin" that will contain historical values of dereferenced "$ref"s.' }),
};
static flags = bundleFlags();

async run() {
const { argv, flags } = await this.parse(Bundle);
Expand Down
5 changes: 3 additions & 2 deletions src/core/flags/bundle.flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export const bundleFlags = () => {
return {
help: Flags.help({ char: 'h' }),
output: Flags.string({ char: 'o', description: 'The output file name. Omitting this flag the result will be printed in the console.' }),
'reference-into-components': Flags.boolean({ char: 'r', description: 'Bundle the message $refs into components object.' }),
base: Flags.string({ char: 'b', description: 'Path to the file which will act as a base. This is required when some properties are to needed to be overwritten.' }),
base: Flags.string({ char: 'b', description: 'Path to the file which will act as a base. This is required when some properties need to be overwritten.' }),
baseDir: Flags.string({ char: 'd', description: 'One relative/absolute path to directory relative to which paths to AsyncAPI Documents that should be bundled will be resolved.' }),
xOrigin: Flags.boolean({ char: 'x', description: 'Pass this switch to generate properties "x-origin" that will contain historical values of dereferenced "$ref"s.' }),
};
};

0 comments on commit beecfb8

Please sign in to comment.