@asyncapi/cli 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,16 @@
1
1
  import { Example } from '@oclif/core/lib/interfaces';
2
2
  import Command from '../base';
3
- import { Specification } from '../models/SpecificationFile';
4
- import { Parser } from '@asyncapi/parser';
5
3
  export default class Bundle extends Command {
6
- static description: string;
4
+ static readonly description = "Bundle one or multiple AsyncAPI Documents and their references together.";
7
5
  static strict: boolean;
8
6
  static examples: Example[];
9
7
  static flags: {
10
8
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
11
9
  output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
- 'reference-into-components': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
10
  base: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
+ baseDir: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
+ xOrigin: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
13
  };
15
- parser: Parser;
16
14
  run(): Promise<void>;
17
15
  private collectMetricsData;
18
- loadFiles(filepaths: string[]): Promise<Specification[]>;
19
16
  }
@@ -7,28 +7,19 @@ const bundler_1 = tslib_1.__importDefault(require("@asyncapi/bundler"));
7
7
  const fs_1 = require("fs");
8
8
  const path_1 = tslib_1.__importDefault(require("path"));
9
9
  const SpecificationFile_1 = require("../models/SpecificationFile");
10
- const parser_1 = require("@asyncapi/parser");
11
10
  const { writeFile } = fs_1.promises;
12
11
  class Bundle extends base_1.default {
13
- constructor() {
14
- super(...arguments);
15
- this.parser = new parser_1.Parser();
16
- }
17
12
  run() {
18
13
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
14
  const { argv, flags } = yield this.parse(Bundle);
20
15
  const output = flags.output;
21
- let baseFile;
22
16
  const outputFormat = path_1.default.extname(argv[0]);
23
- const AsyncAPIFiles = yield this.loadFiles(argv);
17
+ const AsyncAPIFiles = argv;
24
18
  this.metricsMetadata.files = AsyncAPIFiles.length;
25
- if (flags.base) {
26
- baseFile = (yield (0, SpecificationFile_1.load)(flags.base)).text();
27
- }
28
- const fileContents = AsyncAPIFiles.map((file) => file.text());
29
- const document = yield (0, bundler_1.default)(fileContents, {
30
- referenceIntoComponents: flags['reference-into-components'],
31
- base: baseFile
19
+ const document = yield (0, bundler_1.default)(AsyncAPIFiles, {
20
+ base: flags.base,
21
+ baseDir: flags.baseDir,
22
+ xOrigin: flags.xOrigin,
32
23
  });
33
24
  yield this.collectMetricsData(document);
34
25
  if (!output) {
@@ -69,29 +60,21 @@ class Bundle extends base_1.default {
69
60
  }
70
61
  });
71
62
  }
72
- loadFiles(filepaths) {
73
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
- const files = [];
75
- for (const filepath of filepaths) {
76
- const file = yield (0, SpecificationFile_1.load)(filepath);
77
- files.push(file);
78
- }
79
- return files;
80
- });
81
- }
82
63
  }
83
64
  exports.default = Bundle;
84
- Bundle.description = 'bundle one or multiple asyncapi documents and their references together.';
65
+ Bundle.description = 'Bundle one or multiple AsyncAPI Documents and their references together.';
85
66
  Bundle.strict = false;
86
67
  Bundle.examples = [
87
- 'asyncapi bundle ./asyncapi.yaml > final-asyncapi.yaml',
88
68
  'asyncapi bundle ./asyncapi.yaml --output final-asyncapi.yaml',
89
- 'asyncapi bundle ./asyncapi.yaml ./features.yaml --reference-into-components',
90
- 'asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./asyncapi.yaml --reference-into-components'
69
+ 'asyncapi bundle ./asyncapi.yaml ./features.yaml',
70
+ 'asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml',
71
+ 'asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml --xOrigin',
72
+ 'asyncapi bundle ./asyncapi.yaml -o final-asyncapi.yaml --base ../public-api/main.yaml --baseDir ./social-media/comments-service',
91
73
  ];
92
74
  Bundle.flags = {
93
75
  help: core_1.Flags.help({ char: 'h' }),
94
76
  output: core_1.Flags.string({ char: 'o', description: 'The output file name. Omitting this flag the result will be printed in the console.' }),
95
- 'reference-into-components': core_1.Flags.boolean({ char: 'r', description: 'Bundle the message $refs into components object.' }),
96
- base: core_1.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.' }),
77
+ base: core_1.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.' }),
78
+ baseDir: core_1.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.' }),
79
+ xOrigin: core_1.Flags.boolean({ char: 'x', description: 'Pass this switch to generate properties "x-origin" that will contain historical values of dereferenced "$ref"s.' }),
97
80
  };
@@ -26,8 +26,6 @@ const templatesNotSupportingV3 = {
26
26
  '@asyncapi/java-spring-cloud-stream-template': 'https://github.com/asyncapi/java-spring-cloud-stream-template/issues/336',
27
27
  '@asyncapi/go-watermill-template': 'https://github.com/asyncapi/go-watermill-template/issues/243',
28
28
  '@asyncapi/java-spring-template': 'https://github.com/asyncapi/java-spring-template/issues/308',
29
- '@asyncapi/nodejs-template': 'https://github.com/asyncapi/nodejs-template/issues/215',
30
- '@asyncapi/java-template': 'https://github.com/asyncapi/java-template/issues/118',
31
29
  '@asyncapi/php-template': 'https://github.com/asyncapi/php-template/issues/191'
32
30
  };
33
31
  /**
@@ -3,12 +3,13 @@
3
3
  "bundle": {
4
4
  "aliases": [],
5
5
  "args": {},
6
- "description": "bundle one or multiple asyncapi documents and their references together.",
6
+ "description": "Bundle one or multiple AsyncAPI Documents and their references together.",
7
7
  "examples": [
8
- "asyncapi bundle ./asyncapi.yaml > final-asyncapi.yaml",
9
8
  "asyncapi bundle ./asyncapi.yaml --output final-asyncapi.yaml",
10
- "asyncapi bundle ./asyncapi.yaml ./features.yaml --reference-into-components",
11
- "asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./asyncapi.yaml --reference-into-components"
9
+ "asyncapi bundle ./asyncapi.yaml ./features.yaml",
10
+ "asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml",
11
+ "asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml --xOrigin",
12
+ "asyncapi bundle ./asyncapi.yaml -o final-asyncapi.yaml --base ../public-api/main.yaml --baseDir ./social-media/comments-service"
12
13
  ],
13
14
  "flags": {
14
15
  "help": {
@@ -26,20 +27,28 @@
26
27
  "multiple": false,
27
28
  "type": "option"
28
29
  },
29
- "reference-into-components": {
30
- "char": "r",
31
- "description": "Bundle the message $refs into components object.",
32
- "name": "reference-into-components",
33
- "allowNo": false,
34
- "type": "boolean"
35
- },
36
30
  "base": {
37
31
  "char": "b",
38
- "description": "Path to the file which will act as a base. This is required when some properties are to needed to be overwritten.",
32
+ "description": "Path to the file which will act as a base. This is required when some properties need to be overwritten.",
39
33
  "name": "base",
40
34
  "hasDynamicHelp": false,
41
35
  "multiple": false,
42
36
  "type": "option"
37
+ },
38
+ "baseDir": {
39
+ "char": "d",
40
+ "description": "One relative/absolute path to directory relative to which paths to AsyncAPI Documents that should be bundled will be resolved.",
41
+ "name": "baseDir",
42
+ "hasDynamicHelp": false,
43
+ "multiple": false,
44
+ "type": "option"
45
+ },
46
+ "xOrigin": {
47
+ "char": "x",
48
+ "description": "Pass this switch to generate properties \"x-origin\" that will contain historical values of dereferenced \"$ref\"s.",
49
+ "name": "xOrigin",
50
+ "allowNo": false,
51
+ "type": "boolean"
43
52
  }
44
53
  },
45
54
  "hasDynamicHelp": false,
@@ -1439,5 +1448,5 @@
1439
1448
  ]
1440
1449
  }
1441
1450
  },
1442
- "version": "1.12.0"
1451
+ "version": "1.12.2"
1443
1452
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@asyncapi/cli",
3
3
  "description": "All in one CLI for all AsyncAPI tools",
4
- "version": "1.12.0",
4
+ "version": "1.12.2",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"
@@ -9,7 +9,7 @@
9
9
  "bugs": "https://github.com/asyncapi/cli/issues",
10
10
  "dependencies": {
11
11
  "@asyncapi/avro-schema-parser": "^3.0.22",
12
- "@asyncapi/bundler": "^0.4.0",
12
+ "@asyncapi/bundler": "^0.5.0",
13
13
  "@asyncapi/converter": "^1.4.19",
14
14
  "@asyncapi/diff": "^0.4.1",
15
15
  "@asyncapi/generator": "^1.17.25",