@asyncapi/cli 0.28.0 → 0.30.0
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.
- package/lib/commands/diff.d.ts +3 -0
- package/lib/commands/diff.js +22 -14
- package/lib/commands/generate/fromTemplate.js +1 -1
- package/lib/commands/generate/models.d.ts +3 -0
- package/lib/commands/generate/models.js +20 -25
- package/lib/commands/validate.d.ts +3 -0
- package/lib/commands/validate.js +4 -23
- package/lib/globals.d.ts +2 -2
- package/lib/globals.js +3 -1
- package/lib/models/SpecificationFile.d.ts +4 -0
- package/lib/models/SpecificationFile.js +21 -3
- package/lib/parser.d.ts +25 -0
- package/lib/parser.js +99 -0
- package/oclif.manifest.json +1 -1
- package/package.json +5 -3
package/lib/commands/diff.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import Command from '../base';
|
|
|
3
3
|
export default class Diff extends Command {
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
6
|
+
'log-diagnostics': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
'diagnostics-format': import("@oclif/core/lib/interfaces").OptionFlag<import("@stoplight/spectral-cli/dist/services/config").OutputFormat>;
|
|
8
|
+
'fail-severity': import("@oclif/core/lib/interfaces").OptionFlag<import("../parser").SeveritytKind>;
|
|
6
9
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
7
10
|
format: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
8
11
|
type: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
package/lib/commands/diff.js
CHANGED
|
@@ -4,7 +4,6 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
/* eslint-disable sonarjs/no-duplicate-string */
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
6
|
const diff = tslib_1.__importStar(require("@asyncapi/diff"));
|
|
7
|
-
const parser = tslib_1.__importStar(require("@asyncapi/parser"));
|
|
8
7
|
const fs_1 = require("fs");
|
|
9
8
|
const SpecificationFile_1 = require("../models/SpecificationFile");
|
|
10
9
|
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
@@ -13,6 +12,7 @@ const specification_file_1 = require("../errors/specification-file");
|
|
|
13
12
|
const diff_error_1 = require("../errors/diff-error");
|
|
14
13
|
const globals_1 = require("../globals");
|
|
15
14
|
const flags_1 = require("../flags");
|
|
15
|
+
const parser_1 = require("../parser");
|
|
16
16
|
const { readFile } = fs_1.promises;
|
|
17
17
|
class Diff extends base_1.default {
|
|
18
18
|
run() {
|
|
@@ -73,9 +73,11 @@ class Diff extends base_1.default {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
try {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
const parsed = yield parseDocuments(this, firstDocument, secondDocument, flags);
|
|
77
|
+
if (!parsed) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const diffOutput = diff.diff(parsed.firstDocumentParsed.json(), parsed.secondDocumentParsed.json(), {
|
|
79
81
|
override: overrides,
|
|
80
82
|
outputType: outputFormat, // NOSONAR
|
|
81
83
|
});
|
|
@@ -134,26 +136,20 @@ class Diff extends base_1.default {
|
|
|
134
136
|
}
|
|
135
137
|
exports.default = Diff;
|
|
136
138
|
Diff.description = 'Find diff between two asyncapi files';
|
|
137
|
-
Diff.flags = {
|
|
138
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
139
|
-
format: core_1.Flags.string({
|
|
139
|
+
Diff.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), format: core_1.Flags.string({
|
|
140
140
|
char: 'f',
|
|
141
141
|
description: 'format of the output',
|
|
142
142
|
default: 'yaml',
|
|
143
143
|
options: ['json', 'yaml', 'yml'],
|
|
144
|
-
}),
|
|
145
|
-
type: core_1.Flags.string({
|
|
144
|
+
}), type: core_1.Flags.string({
|
|
146
145
|
char: 't',
|
|
147
146
|
description: 'type of the output',
|
|
148
147
|
default: 'all',
|
|
149
148
|
options: ['breaking', 'non-breaking', 'unclassified', 'all'],
|
|
150
|
-
}),
|
|
151
|
-
overrides: core_1.Flags.string({
|
|
149
|
+
}), overrides: core_1.Flags.string({
|
|
152
150
|
char: 'o',
|
|
153
151
|
description: 'path to JSON file containing the override properties',
|
|
154
|
-
}),
|
|
155
|
-
watch: (0, flags_1.watchFlag)(),
|
|
156
|
-
};
|
|
152
|
+
}), watch: (0, flags_1.watchFlag)() }, (0, parser_1.validationFlags)({ logDiagnostics: false }));
|
|
157
153
|
Diff.args = [
|
|
158
154
|
{
|
|
159
155
|
name: 'old',
|
|
@@ -166,6 +162,18 @@ Diff.args = [
|
|
|
166
162
|
required: true,
|
|
167
163
|
},
|
|
168
164
|
];
|
|
165
|
+
function parseDocuments(command, firstDocument, secondDocument, flags) {
|
|
166
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const { document: newFirstDocumentParsed, status: firstDocumentStatus } = yield (0, parser_1.parse)(command, firstDocument, flags);
|
|
168
|
+
const { document: newSecondDocumentParsed, status: secondDocumentStatus } = yield (0, parser_1.parse)(command, secondDocument, flags);
|
|
169
|
+
if (!newFirstDocumentParsed || !newSecondDocumentParsed || firstDocumentStatus === 'invalid' || secondDocumentStatus === 'invalid') {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const firstDocumentParsed = (0, parser_1.convertToOldAPI)(newFirstDocumentParsed);
|
|
173
|
+
const secondDocumentParsed = (0, parser_1.convertToOldAPI)(newSecondDocumentParsed);
|
|
174
|
+
return { firstDocumentParsed, secondDocumentParsed };
|
|
175
|
+
});
|
|
176
|
+
}
|
|
169
177
|
/**
|
|
170
178
|
* Reads the file from give path and parses it as JSON
|
|
171
179
|
* @param path The path to override file
|
|
@@ -271,7 +271,7 @@ Template.flags = {
|
|
|
271
271
|
}),
|
|
272
272
|
'map-base-url': core_1.Flags.string({
|
|
273
273
|
description: 'Maps all schema references from base url to local folder'
|
|
274
|
-
})
|
|
274
|
+
}),
|
|
275
275
|
};
|
|
276
276
|
Template.args = [
|
|
277
277
|
{ name: 'asyncapi', description: '- Local path, url or context-name pointing to AsyncAPI file', required: true },
|
|
@@ -13,6 +13,9 @@ export default class Models extends Command {
|
|
|
13
13
|
options?: undefined;
|
|
14
14
|
})[];
|
|
15
15
|
static flags: {
|
|
16
|
+
'log-diagnostics': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
'diagnostics-format': import("@oclif/core/lib/interfaces").OptionFlag<import("@stoplight/spectral-cli/dist/services/config").OutputFormat>;
|
|
18
|
+
'fail-severity': import("@oclif/core/lib/interfaces").OptionFlag<import("../../parser").SeveritytKind>;
|
|
16
19
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
17
20
|
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
18
21
|
/**
|
|
@@ -5,7 +5,7 @@ const modelina_1 = require("@asyncapi/modelina");
|
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
6
|
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
7
7
|
const SpecificationFile_1 = require("../../models/SpecificationFile");
|
|
8
|
-
const parser_1 = require("
|
|
8
|
+
const parser_1 = require("../../parser");
|
|
9
9
|
var Languages;
|
|
10
10
|
(function (Languages) {
|
|
11
11
|
Languages["typescript"] = "typescript";
|
|
@@ -25,7 +25,10 @@ class Models extends base_1.default {
|
|
|
25
25
|
const { tsModelType, tsEnumType, tsModuleSystem, tsExportType, namespace, packageName, output } = flags;
|
|
26
26
|
const { language, file } = args;
|
|
27
27
|
const inputFile = (yield (0, SpecificationFile_1.load)(file)) || (yield (0, SpecificationFile_1.load)());
|
|
28
|
-
const
|
|
28
|
+
const { document, status } = yield (0, parser_1.parse)(this, inputFile, flags);
|
|
29
|
+
if (!document || status === 'invalid') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
29
32
|
modelina_1.Logger.setLogger({
|
|
30
33
|
info: (message) => {
|
|
31
34
|
this.log(message);
|
|
@@ -101,22 +104,20 @@ class Models extends base_1.default {
|
|
|
101
104
|
default:
|
|
102
105
|
throw new Error(`Could not determine generator for language ${language}, are you using one of the following values ${possibleLanguageValues}?`);
|
|
103
106
|
}
|
|
104
|
-
let models;
|
|
105
107
|
if (output) {
|
|
106
|
-
models = yield fileGenerator.generateToFiles(
|
|
108
|
+
const models = yield fileGenerator.generateToFiles(document, output, Object.assign({}, fileOptions));
|
|
107
109
|
const generatedModels = models.map((model) => { return model.modelName; });
|
|
108
110
|
this.log(`Successfully generated the following models: ${generatedModels.join(', ')}`);
|
|
111
|
+
return;
|
|
109
112
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return `
|
|
113
|
+
const models = yield fileGenerator.generateCompleteModels(document, Object.assign({}, fileOptions));
|
|
114
|
+
const generatedModels = models.map((model) => {
|
|
115
|
+
return `
|
|
114
116
|
## Model name: ${model.modelName}
|
|
115
117
|
${model.result}
|
|
116
118
|
`;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
119
|
+
});
|
|
120
|
+
this.log(`Successfully generated the following models: ${generatedModels.join('\n')}`);
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
123
|
}
|
|
@@ -131,13 +132,11 @@ Models.args = [
|
|
|
131
132
|
},
|
|
132
133
|
{ name: 'file', description: 'Path or URL to the AsyncAPI document, or context-name', required: true },
|
|
133
134
|
];
|
|
134
|
-
Models.flags = {
|
|
135
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
136
|
-
output: core_1.Flags.string({
|
|
135
|
+
Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), output: core_1.Flags.string({
|
|
137
136
|
char: 'o',
|
|
138
137
|
description: 'The output directory where the models should be written to. Omitting this flag will write the models to `stdout`.',
|
|
139
138
|
required: false
|
|
140
|
-
}),
|
|
139
|
+
}),
|
|
141
140
|
/**
|
|
142
141
|
* TypeScript specific options
|
|
143
142
|
*/
|
|
@@ -146,37 +145,33 @@ Models.flags = {
|
|
|
146
145
|
options: ['class', 'interface'],
|
|
147
146
|
description: 'TypeScript specific, define which type of model needs to be generated.',
|
|
148
147
|
required: false,
|
|
149
|
-
}),
|
|
150
|
-
tsEnumType: core_1.Flags.string({
|
|
148
|
+
}), tsEnumType: core_1.Flags.string({
|
|
151
149
|
type: 'option',
|
|
152
150
|
options: ['enum', 'union'],
|
|
153
151
|
description: 'TypeScript specific, define which type of enums needs to be generated.',
|
|
154
152
|
required: false,
|
|
155
|
-
}),
|
|
156
|
-
tsModuleSystem: core_1.Flags.string({
|
|
153
|
+
}), tsModuleSystem: core_1.Flags.string({
|
|
157
154
|
type: 'option',
|
|
158
155
|
options: ['ESM', 'CJS'],
|
|
159
156
|
description: 'TypeScript specific, define the module system to be used.',
|
|
160
157
|
required: false,
|
|
161
|
-
}),
|
|
162
|
-
tsExportType: core_1.Flags.string({
|
|
158
|
+
}), tsExportType: core_1.Flags.string({
|
|
163
159
|
type: 'option',
|
|
164
160
|
options: ['default', 'named'],
|
|
165
161
|
description: 'TypeScript specific, define which type of export needs to be generated.',
|
|
166
162
|
required: false,
|
|
167
|
-
}),
|
|
163
|
+
}),
|
|
168
164
|
/**
|
|
169
165
|
* Go and Java specific package name to use for the generated models
|
|
170
166
|
*/
|
|
171
167
|
packageName: core_1.Flags.string({
|
|
172
168
|
description: 'Go and Java specific, define the package to use for the generated models. This is required when language is `go` or `java`.',
|
|
173
169
|
required: false
|
|
174
|
-
}),
|
|
170
|
+
}),
|
|
175
171
|
/**
|
|
176
172
|
* C# specific options
|
|
177
173
|
*/
|
|
178
174
|
namespace: core_1.Flags.string({
|
|
179
175
|
description: 'C# specific, define the namespace to use for the generated models. This is required when language is `csharp`.',
|
|
180
176
|
required: false
|
|
181
|
-
}),
|
|
182
|
-
};
|
|
177
|
+
}) }, (0, parser_1.validationFlags)({ logDiagnostics: false }));
|
|
@@ -2,6 +2,9 @@ import Command from '../base';
|
|
|
2
2
|
export default class Validate extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
|
+
'log-diagnostics': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
'diagnostics-format': import("@oclif/core/lib/interfaces").OptionFlag<import("@stoplight/spectral-cli/dist/services/config").OutputFormat>;
|
|
7
|
+
'fail-severity': import("@oclif/core/lib/interfaces").OptionFlag<import("../parser").SeveritytKind>;
|
|
5
8
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
6
9
|
watch: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
10
|
};
|
package/lib/commands/validate.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
-
const parser = tslib_1.__importStar(require("@asyncapi/parser"));
|
|
6
5
|
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
7
|
-
const
|
|
6
|
+
const parser_1 = require("../parser");
|
|
8
7
|
const SpecificationFile_1 = require("../models/SpecificationFile");
|
|
9
8
|
const globals_1 = require("../globals");
|
|
10
9
|
const flags_1 = require("../flags");
|
|
@@ -13,36 +12,18 @@ class Validate extends base_1.default {
|
|
|
13
12
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
13
|
const { args, flags } = yield this.parse(Validate); //NOSONAR
|
|
15
14
|
const filePath = args['spec-file'];
|
|
16
|
-
const watchMode = flags
|
|
15
|
+
const watchMode = flags.watch;
|
|
17
16
|
const specFile = yield (0, SpecificationFile_1.load)(filePath);
|
|
18
17
|
if (watchMode) {
|
|
19
18
|
(0, globals_1.specWatcher)({ spec: specFile, handler: this, handlerName: 'validate' });
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
if (specFile.getFilePath()) {
|
|
23
|
-
yield parser.parse(specFile.text());
|
|
24
|
-
this.log(`File ${specFile.getFilePath()} successfully validated!`);
|
|
25
|
-
}
|
|
26
|
-
else if (specFile.getFileURL()) {
|
|
27
|
-
yield parser.parse(specFile.text());
|
|
28
|
-
this.log(`URL ${specFile.getFileURL()} successfully validated`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
throw new validation_error_1.ValidationError({
|
|
33
|
-
type: 'parser-error',
|
|
34
|
-
err: error
|
|
35
|
-
});
|
|
36
|
-
}
|
|
20
|
+
yield (0, parser_1.validate)(this, specFile, flags);
|
|
37
21
|
});
|
|
38
22
|
}
|
|
39
23
|
}
|
|
40
24
|
exports.default = Validate;
|
|
41
25
|
Validate.description = 'validate asyncapi file';
|
|
42
|
-
Validate.flags = {
|
|
43
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
44
|
-
watch: (0, flags_1.watchFlag)()
|
|
45
|
-
};
|
|
26
|
+
Validate.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), watch: (0, flags_1.watchFlag)() }, (0, parser_1.validationFlags)());
|
|
46
27
|
Validate.args = [
|
|
47
28
|
{ name: 'spec-file', description: 'spec path, url, or context-name', required: false },
|
|
48
29
|
];
|
package/lib/globals.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Command from './base';
|
|
2
2
|
import { Specification } from './models/SpecificationFile';
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type SpecWatcherParams = {
|
|
4
4
|
spec: Specification;
|
|
5
5
|
handler: Command;
|
|
6
6
|
handlerName: string;
|
|
7
7
|
label?: string;
|
|
8
8
|
docVersion?: 'old' | 'new';
|
|
9
9
|
};
|
|
10
|
-
export declare const specWatcher: (params:
|
|
10
|
+
export declare const specWatcher: (params: SpecWatcherParams) => void;
|
package/lib/globals.js
CHANGED
|
@@ -28,7 +28,9 @@ const specWatcher = (params) => {
|
|
|
28
28
|
chokidar_1.default
|
|
29
29
|
.watch(filePath, CHOKIDAR_CONFIG)
|
|
30
30
|
.on('change', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
|
|
31
|
+
if (params.handlerName) {
|
|
32
|
+
WATCH_MESSAGES.logOnChange(params.handlerName);
|
|
33
|
+
}
|
|
32
34
|
try {
|
|
33
35
|
yield params.handler.run();
|
|
34
36
|
}
|
|
@@ -2,6 +2,7 @@ export declare class Specification {
|
|
|
2
2
|
private readonly spec;
|
|
3
3
|
private readonly filePath?;
|
|
4
4
|
private readonly fileURL?;
|
|
5
|
+
private readonly kind?;
|
|
5
6
|
constructor(spec: string, options?: {
|
|
6
7
|
filepath?: string;
|
|
7
8
|
fileURL?: string;
|
|
@@ -9,6 +10,9 @@ export declare class Specification {
|
|
|
9
10
|
text(): string;
|
|
10
11
|
getFilePath(): string | undefined;
|
|
11
12
|
getFileURL(): string | undefined;
|
|
13
|
+
getKind(): "file" | "url" | undefined;
|
|
14
|
+
getSource(): string | undefined;
|
|
15
|
+
toSourceString(): string;
|
|
12
16
|
static fromFile(filepath: string): Promise<Specification>;
|
|
13
17
|
static fromURL(URLpath: string): Promise<Specification>;
|
|
14
18
|
}
|
|
@@ -19,10 +19,16 @@ const TYPE_CONTEXT_NAME = 'context-name';
|
|
|
19
19
|
const TYPE_FILE_PATH = 'file-path';
|
|
20
20
|
const TYPE_URL = 'url-path';
|
|
21
21
|
class Specification {
|
|
22
|
-
constructor(spec, options) {
|
|
22
|
+
constructor(spec, options = {}) {
|
|
23
23
|
this.spec = spec;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
if (options.filepath) {
|
|
25
|
+
this.filePath = options.filepath;
|
|
26
|
+
this.kind = 'file';
|
|
27
|
+
}
|
|
28
|
+
else if (options.fileURL) {
|
|
29
|
+
this.fileURL = options.fileURL;
|
|
30
|
+
this.kind = 'url';
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
33
|
text() {
|
|
28
34
|
return this.spec;
|
|
@@ -33,6 +39,18 @@ class Specification {
|
|
|
33
39
|
getFileURL() {
|
|
34
40
|
return this.fileURL;
|
|
35
41
|
}
|
|
42
|
+
getKind() {
|
|
43
|
+
return this.kind;
|
|
44
|
+
}
|
|
45
|
+
getSource() {
|
|
46
|
+
return this.getFilePath() || this.getFileURL();
|
|
47
|
+
}
|
|
48
|
+
toSourceString() {
|
|
49
|
+
if (this.kind === 'file') {
|
|
50
|
+
return `File ${this.filePath}`;
|
|
51
|
+
}
|
|
52
|
+
return `URL ${this.fileURL}`;
|
|
53
|
+
}
|
|
36
54
|
static fromFile(filepath) {
|
|
37
55
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
38
56
|
let spec;
|
package/lib/parser.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { convertToOldAPI } from '@asyncapi/parser/cjs';
|
|
2
|
+
import { OutputFormat } from '@stoplight/spectral-cli/dist/services/config';
|
|
3
|
+
import type Command from './base';
|
|
4
|
+
import type { Specification } from './models/SpecificationFile';
|
|
5
|
+
export declare type SeveritytKind = 'error' | 'warn' | 'info' | 'hint';
|
|
6
|
+
export { convertToOldAPI };
|
|
7
|
+
export interface ValidationFlagsOptions {
|
|
8
|
+
logDiagnostics?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function validationFlags({ logDiagnostics }?: ValidationFlagsOptions): {
|
|
11
|
+
'log-diagnostics': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
'diagnostics-format': import("@oclif/core/lib/interfaces").OptionFlag<OutputFormat>;
|
|
13
|
+
'fail-severity': import("@oclif/core/lib/interfaces").OptionFlag<SeveritytKind>;
|
|
14
|
+
};
|
|
15
|
+
interface ValidateOptions {
|
|
16
|
+
'log-diagnostics'?: boolean;
|
|
17
|
+
'diagnostics-format'?: `${OutputFormat}`;
|
|
18
|
+
'fail-severity'?: SeveritytKind;
|
|
19
|
+
}
|
|
20
|
+
export declare function validate(command: Command, specFile: Specification, options?: ValidateOptions): Promise<"valid" | "invalid">;
|
|
21
|
+
export declare function parse(command: Command, specFile: Specification, options?: ValidateOptions): Promise<{
|
|
22
|
+
document: import("@asyncapi/parser/cjs").AsyncAPIDocumentInterface | undefined;
|
|
23
|
+
diagnostics: import("@stoplight/spectral-core").ISpectralDiagnostic[];
|
|
24
|
+
status: "valid" | "invalid";
|
|
25
|
+
}>;
|
package/lib/parser.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parse = exports.validate = exports.validationFlags = exports.convertToOldAPI = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const cjs_1 = require("@asyncapi/parser/cjs");
|
|
7
|
+
Object.defineProperty(exports, "convertToOldAPI", { enumerable: true, get: function () { return cjs_1.convertToOldAPI; } });
|
|
8
|
+
const avro_schema_parser_1 = require("@asyncapi/parser/cjs/schema-parser/avro-schema-parser");
|
|
9
|
+
const openapi_schema_parser_1 = require("@asyncapi/parser/cjs/schema-parser/openapi-schema-parser");
|
|
10
|
+
const raml_schema_parser_1 = require("@asyncapi/parser/cjs/schema-parser/raml-schema-parser");
|
|
11
|
+
const spectral_core_1 = require("@stoplight/spectral-core");
|
|
12
|
+
const formatters_1 = require("@stoplight/spectral-cli/dist/formatters");
|
|
13
|
+
const config_1 = require("@stoplight/spectral-cli/dist/services/config");
|
|
14
|
+
const parser = new cjs_1.Parser({
|
|
15
|
+
__unstable: {
|
|
16
|
+
resolver: {
|
|
17
|
+
cache: false,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
parser.registerSchemaParser((0, avro_schema_parser_1.AvroSchemaParser)());
|
|
22
|
+
parser.registerSchemaParser((0, openapi_schema_parser_1.OpenAPISchemaParser)());
|
|
23
|
+
parser.registerSchemaParser((0, raml_schema_parser_1.RamlSchemaParser)());
|
|
24
|
+
function validationFlags({ logDiagnostics = true } = {}) {
|
|
25
|
+
return {
|
|
26
|
+
'log-diagnostics': core_1.Flags.boolean({
|
|
27
|
+
description: 'log validation diagnostics or not',
|
|
28
|
+
default: logDiagnostics,
|
|
29
|
+
allowNo: true,
|
|
30
|
+
}),
|
|
31
|
+
'diagnostics-format': core_1.Flags.enum({
|
|
32
|
+
description: 'format to use for validation diagnostics',
|
|
33
|
+
options: Object.values(config_1.OutputFormat),
|
|
34
|
+
default: config_1.OutputFormat.STYLISH,
|
|
35
|
+
}),
|
|
36
|
+
'fail-severity': core_1.Flags.enum({
|
|
37
|
+
description: 'diagnostics of this level or above will trigger a failure exit code',
|
|
38
|
+
options: ['error', 'warn', 'info', 'hint'],
|
|
39
|
+
default: 'error',
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.validationFlags = validationFlags;
|
|
44
|
+
function validate(command, specFile, options = {}) {
|
|
45
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const diagnostics = yield parser.validate(specFile.text(), { source: specFile.getSource() });
|
|
47
|
+
return logDiagnostics(diagnostics, command, specFile, options);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.validate = validate;
|
|
51
|
+
function parse(command, specFile, options = {}) {
|
|
52
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const { document, diagnostics } = yield parser.parse(specFile.text(), { source: specFile.getSource() });
|
|
54
|
+
const status = logDiagnostics(diagnostics, command, specFile, options);
|
|
55
|
+
return { document, diagnostics, status };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.parse = parse;
|
|
59
|
+
function logDiagnostics(diagnostics, command, specFile, options = {}) {
|
|
60
|
+
const logDiagnostics = options['log-diagnostics'];
|
|
61
|
+
const failSeverity = options['fail-severity'] || 'error';
|
|
62
|
+
const diagnosticsFormat = options['diagnostics-format'] || 'stylish';
|
|
63
|
+
const sourceString = specFile.toSourceString();
|
|
64
|
+
if (diagnostics.length) {
|
|
65
|
+
if (hasFailSeverity(diagnostics, failSeverity)) {
|
|
66
|
+
if (logDiagnostics) {
|
|
67
|
+
command.logToStderr(`\n${sourceString} and/or referenced documents have governance issues.`);
|
|
68
|
+
command.logToStderr(formatOutput(diagnostics, diagnosticsFormat, failSeverity));
|
|
69
|
+
}
|
|
70
|
+
command.exit(1);
|
|
71
|
+
return 'invalid';
|
|
72
|
+
}
|
|
73
|
+
if (logDiagnostics) {
|
|
74
|
+
command.log(`\n${sourceString} is valid but has (itself and/or referenced documents) governance issues.`);
|
|
75
|
+
command.log(formatOutput(diagnostics, diagnosticsFormat, failSeverity));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (logDiagnostics) {
|
|
79
|
+
command.log(`\n${sourceString} is valid! ${sourceString} and referenced documents don't have governance issues.`);
|
|
80
|
+
}
|
|
81
|
+
return 'valid';
|
|
82
|
+
}
|
|
83
|
+
function formatOutput(diagnostics, format, failSeverity) {
|
|
84
|
+
const options = { failSeverity: (0, spectral_core_1.getDiagnosticSeverity)(failSeverity) };
|
|
85
|
+
switch (format) {
|
|
86
|
+
case 'stylish': return (0, formatters_1.stylish)(diagnostics, options);
|
|
87
|
+
case 'json': return (0, formatters_1.json)(diagnostics, options);
|
|
88
|
+
case 'junit': return (0, formatters_1.junit)(diagnostics, options);
|
|
89
|
+
case 'html': return (0, formatters_1.html)(diagnostics, options);
|
|
90
|
+
case 'text': return (0, formatters_1.text)(diagnostics, options);
|
|
91
|
+
case 'teamcity': return (0, formatters_1.teamcity)(diagnostics, options);
|
|
92
|
+
case 'pretty': return (0, formatters_1.pretty)(diagnostics, options);
|
|
93
|
+
default: return (0, formatters_1.stylish)(diagnostics, options);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function hasFailSeverity(diagnostics, failSeverity) {
|
|
97
|
+
const diagnosticSeverity = (0, spectral_core_1.getDiagnosticSeverity)(failSeverity);
|
|
98
|
+
return diagnostics.some(diagnostic => diagnostic.severity <= diagnosticSeverity);
|
|
99
|
+
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.28.0","commands":{"convert":{"id":"convert","description":"Convert asyncapi documents older to newer versions","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"output":{"name":"output","type":"option","char":"o","description":"path to the file where the result is saved","multiple":false},"target-version":{"name":"target-version","type":"option","char":"t","description":"asyncapi version to convert to","multiple":false,"default":"2.5.0"}},"args":[{"name":"spec-file","description":"spec path, url, or context-name","required":false}]},"diff":{"id":"diff","description":"Find diff between two asyncapi files","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"format":{"name":"format","type":"option","char":"f","description":"format of the output","multiple":false,"options":["json","yaml","yml"],"default":"yaml"},"type":{"name":"type","type":"option","char":"t","description":"type of the output","multiple":false,"options":["breaking","non-breaking","unclassified","all"],"default":"all"},"overrides":{"name":"overrides","type":"option","char":"o","description":"path to JSON file containing the override properties","multiple":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Enable watch mode","allowNo":false}},"args":[{"name":"old","description":"old spec path, URL or context-name","required":true},{"name":"new","description":"new spec path, URL or context-name","required":true}]},"new":{"id":"new","description":"Creates a new asyncapi file","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"file-name":{"name":"file-name","type":"option","char":"n","description":"name of the file","multiple":false},"example":{"name":"example","type":"option","char":"e","description":"name of the example to use","multiple":false},"studio":{"name":"studio","type":"boolean","char":"s","description":"open in Studio","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio","multiple":false},"no-tty":{"name":"no-tty","type":"boolean","description":"do not use an interactive terminal","allowNo":false}},"args":[]},"validate":{"id":"validate","description":"validate asyncapi file","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Enable watch mode","allowNo":false}},"args":[{"name":"spec-file","description":"spec path, url, or context-name","required":false}]},"config":{"id":"config","description":"CLI config settings","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"generate:fromTemplate":{"id":"generate:fromTemplate","description":"Generates whatever you want using templates compatible with AsyncAPI Generator.","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"examples":["asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --param version=1.0.0 singleFile=true --output ./docs --force-write"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"disable-hook":{"name":"disable-hook","type":"option","char":"d","description":"Disable a specific hook type or hooks from a given hook type","multiple":true},"install":{"name":"install","type":"boolean","char":"i","description":"Installs the template and its dependencies (defaults to false)","allowNo":false},"debug":{"name":"debug","type":"boolean","description":"Enable more specific errors in the console","allowNo":false},"no-overwrite":{"name":"no-overwrite","type":"option","char":"n","description":"Glob or path of the file(s) to skip when regenerating","multiple":true},"output":{"name":"output","type":"option","char":"o","description":"Directory where to put the generated files (defaults to current directory)","multiple":false},"force-write":{"name":"force-write","type":"boolean","description":"Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory.","allowNo":false},"param":{"name":"param","type":"option","char":"p","description":"Additional param to pass to templates","multiple":true},"map-base-url":{"name":"map-base-url","type":"option","description":"Maps all schema references from base url to local folder","multiple":false}},"args":[{"name":"asyncapi","description":"- Local path, url or context-name pointing to AsyncAPI file","required":true},{"name":"template","description":"- Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template","required":true}]},"generate":{"id":"generate","description":"Generate typed models or other things like clients, applications or docs using AsyncAPI Generator templates.","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"generate:models":{"id":"generate:models","description":"Generates typed models","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"output":{"name":"output","type":"option","char":"o","description":"The output directory where the models should be written to. Omitting this flag will write the models to `stdout`.","required":false,"multiple":false},"tsModelType":{"name":"tsModelType","type":"option","description":"TypeScript specific, define which type of model needs to be generated.","required":false,"multiple":false,"options":["class","interface"]},"tsEnumType":{"name":"tsEnumType","type":"option","description":"TypeScript specific, define which type of enums needs to be generated.","required":false,"multiple":false,"options":["enum","union"]},"tsModuleSystem":{"name":"tsModuleSystem","type":"option","description":"TypeScript specific, define the module system to be used.","required":false,"multiple":false,"options":["ESM","CJS"]},"tsExportType":{"name":"tsExportType","type":"option","description":"TypeScript specific, define which type of export needs to be generated.","required":false,"multiple":false,"options":["default","named"]},"packageName":{"name":"packageName","type":"option","description":"Go and Java specific, define the package to use for the generated models. This is required when language is `go` or `java`.","required":false,"multiple":false},"namespace":{"name":"namespace","type":"option","description":"C# specific, define the namespace to use for the generated models. This is required when language is `csharp`.","required":false,"multiple":false}},"args":[{"name":"language","description":"The language you want the typed models generated for.","required":true,"options":["typescript","csharp","golang","java","javascript","dart","python","rust"]},{"name":"file","description":"Path or URL to the AsyncAPI document, or context-name","required":true}]},"start":{"id":"start","description":"Start asyncapi studio","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"start:studio":{"id":"start:studio","description":"starts a new local instance of Studio","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"file":{"name":"file","type":"option","char":"f","description":"path to the AsyncAPI file to link with Studio","multiple":false},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio","multiple":false}},"args":[]},"config:context:add":{"id":"config:context:add","description":"Add or modify a context in the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"context name","required":true},{"name":"spec-file-path","description":"file path of the spec file","required":true}]},"config:context:current":{"id":"config:context:current","description":"Shows the current context that is being used","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"config:context":{"id":"config:context","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"config:context:list":{"id":"config:context:list","description":"List all the stored context in the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"config:context:remove":{"id":"config:context:remove","description":"Delete a context from the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"Name of the context to delete","required":true}]},"config:context:use":{"id":"config:context:use","description":"Set a context as current","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"name of the saved context","required":true}]}}}
|
|
1
|
+
{"version":"0.30.0","commands":{"convert":{"id":"convert","description":"Convert asyncapi documents older to newer versions","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"output":{"name":"output","type":"option","char":"o","description":"path to the file where the result is saved","multiple":false},"target-version":{"name":"target-version","type":"option","char":"t","description":"asyncapi version to convert to","multiple":false,"default":"2.5.0"}},"args":[{"name":"spec-file","description":"spec path, url, or context-name","required":false}]},"diff":{"id":"diff","description":"Find diff between two asyncapi files","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"format":{"name":"format","type":"option","char":"f","description":"format of the output","multiple":false,"options":["json","yaml","yml"],"default":"yaml"},"type":{"name":"type","type":"option","char":"t","description":"type of the output","multiple":false,"options":["breaking","non-breaking","unclassified","all"],"default":"all"},"overrides":{"name":"overrides","type":"option","char":"o","description":"path to JSON file containing the override properties","multiple":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Enable watch mode","allowNo":false},"log-diagnostics":{"name":"log-diagnostics","type":"boolean","description":"log validation diagnostics or not","allowNo":true},"diagnostics-format":{"name":"diagnostics-format","type":"option","description":"format to use for validation diagnostics","helpValue":"(json|stylish|junit|html|text|teamcity|pretty)","multiple":false,"options":["json","stylish","junit","html","text","teamcity","pretty"],"default":"stylish"},"fail-severity":{"name":"fail-severity","type":"option","description":"diagnostics of this level or above will trigger a failure exit code","helpValue":"(error|warn|info|hint)","multiple":false,"options":["error","warn","info","hint"],"default":"error"}},"args":[{"name":"old","description":"old spec path, URL or context-name","required":true},{"name":"new","description":"new spec path, URL or context-name","required":true}]},"new":{"id":"new","description":"Creates a new asyncapi file","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"file-name":{"name":"file-name","type":"option","char":"n","description":"name of the file","multiple":false},"example":{"name":"example","type":"option","char":"e","description":"name of the example to use","multiple":false},"studio":{"name":"studio","type":"boolean","char":"s","description":"open in Studio","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio","multiple":false},"no-tty":{"name":"no-tty","type":"boolean","description":"do not use an interactive terminal","allowNo":false}},"args":[]},"validate":{"id":"validate","description":"validate asyncapi file","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Enable watch mode","allowNo":false},"log-diagnostics":{"name":"log-diagnostics","type":"boolean","description":"log validation diagnostics or not","allowNo":true},"diagnostics-format":{"name":"diagnostics-format","type":"option","description":"format to use for validation diagnostics","helpValue":"(json|stylish|junit|html|text|teamcity|pretty)","multiple":false,"options":["json","stylish","junit","html","text","teamcity","pretty"],"default":"stylish"},"fail-severity":{"name":"fail-severity","type":"option","description":"diagnostics of this level or above will trigger a failure exit code","helpValue":"(error|warn|info|hint)","multiple":false,"options":["error","warn","info","hint"],"default":"error"}},"args":[{"name":"spec-file","description":"spec path, url, or context-name","required":false}]},"config":{"id":"config","description":"CLI config settings","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"generate:fromTemplate":{"id":"generate:fromTemplate","description":"Generates whatever you want using templates compatible with AsyncAPI Generator.","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"examples":["asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --param version=1.0.0 singleFile=true --output ./docs --force-write"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"disable-hook":{"name":"disable-hook","type":"option","char":"d","description":"Disable a specific hook type or hooks from a given hook type","multiple":true},"install":{"name":"install","type":"boolean","char":"i","description":"Installs the template and its dependencies (defaults to false)","allowNo":false},"debug":{"name":"debug","type":"boolean","description":"Enable more specific errors in the console","allowNo":false},"no-overwrite":{"name":"no-overwrite","type":"option","char":"n","description":"Glob or path of the file(s) to skip when regenerating","multiple":true},"output":{"name":"output","type":"option","char":"o","description":"Directory where to put the generated files (defaults to current directory)","multiple":false},"force-write":{"name":"force-write","type":"boolean","description":"Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory.","allowNo":false},"param":{"name":"param","type":"option","char":"p","description":"Additional param to pass to templates","multiple":true},"map-base-url":{"name":"map-base-url","type":"option","description":"Maps all schema references from base url to local folder","multiple":false}},"args":[{"name":"asyncapi","description":"- Local path, url or context-name pointing to AsyncAPI file","required":true},{"name":"template","description":"- Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template","required":true}]},"generate":{"id":"generate","description":"Generate typed models or other things like clients, applications or docs using AsyncAPI Generator templates.","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"generate:models":{"id":"generate:models","description":"Generates typed models","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"output":{"name":"output","type":"option","char":"o","description":"The output directory where the models should be written to. Omitting this flag will write the models to `stdout`.","required":false,"multiple":false},"tsModelType":{"name":"tsModelType","type":"option","description":"TypeScript specific, define which type of model needs to be generated.","required":false,"multiple":false,"options":["class","interface"]},"tsEnumType":{"name":"tsEnumType","type":"option","description":"TypeScript specific, define which type of enums needs to be generated.","required":false,"multiple":false,"options":["enum","union"]},"tsModuleSystem":{"name":"tsModuleSystem","type":"option","description":"TypeScript specific, define the module system to be used.","required":false,"multiple":false,"options":["ESM","CJS"]},"tsExportType":{"name":"tsExportType","type":"option","description":"TypeScript specific, define which type of export needs to be generated.","required":false,"multiple":false,"options":["default","named"]},"packageName":{"name":"packageName","type":"option","description":"Go and Java specific, define the package to use for the generated models. This is required when language is `go` or `java`.","required":false,"multiple":false},"namespace":{"name":"namespace","type":"option","description":"C# specific, define the namespace to use for the generated models. This is required when language is `csharp`.","required":false,"multiple":false},"log-diagnostics":{"name":"log-diagnostics","type":"boolean","description":"log validation diagnostics or not","allowNo":true},"diagnostics-format":{"name":"diagnostics-format","type":"option","description":"format to use for validation diagnostics","helpValue":"(json|stylish|junit|html|text|teamcity|pretty)","multiple":false,"options":["json","stylish","junit","html","text","teamcity","pretty"],"default":"stylish"},"fail-severity":{"name":"fail-severity","type":"option","description":"diagnostics of this level or above will trigger a failure exit code","helpValue":"(error|warn|info|hint)","multiple":false,"options":["error","warn","info","hint"],"default":"error"}},"args":[{"name":"language","description":"The language you want the typed models generated for.","required":true,"options":["typescript","csharp","golang","java","javascript","dart","python","rust"]},{"name":"file","description":"Path or URL to the AsyncAPI document, or context-name","required":true}]},"start":{"id":"start","description":"Start asyncapi studio","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"start:studio":{"id":"start:studio","description":"starts a new local instance of Studio","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"file":{"name":"file","type":"option","char":"f","description":"path to the AsyncAPI file to link with Studio","multiple":false},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio","multiple":false}},"args":[]},"config:context:add":{"id":"config:context:add","description":"Add or modify a context in the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"context name","required":true},{"name":"spec-file-path","description":"file path of the spec file","required":true}]},"config:context:current":{"id":"config:context:current","description":"Shows the current context that is being used","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"config:context":{"id":"config:context","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"config:context:list":{"id":"config:context:list","description":"List all the stored context in the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"config:context:remove":{"id":"config:context:remove","description":"Delete a context from the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"Name of the context to delete","required":true}]},"config:context:use":{"id":"config:context:use","description":"Set a context as current","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"name of the saved context","required":true}]}}}
|
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": "0.
|
|
4
|
+
"version": "0.30.0",
|
|
5
5
|
"author": "@asyncapi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"asyncapi": "./bin/run"
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
"@asyncapi/diff": "^0.4.1",
|
|
13
13
|
"@asyncapi/generator": "^1.9.12",
|
|
14
14
|
"@asyncapi/modelina": "^1.0.0-next.40",
|
|
15
|
-
"@asyncapi/parser": "^
|
|
15
|
+
"@asyncapi/parser": "^2.0.0-next-major.11",
|
|
16
16
|
"@asyncapi/studio": "^0.15.4",
|
|
17
17
|
"@oclif/core": "^1.18.0",
|
|
18
18
|
"@oclif/errors": "^1.3.5",
|
|
19
19
|
"@oclif/plugin-not-found": "^2.3.1",
|
|
20
|
+
"@stoplight/spectral-cli": "6.6.0",
|
|
20
21
|
"ajv": "^8.12.0",
|
|
21
22
|
"chalk": "^4.1.0",
|
|
22
23
|
"chokidar": "^3.5.2",
|
|
@@ -159,7 +160,8 @@
|
|
|
159
160
|
"pretest:coverage": "npm run build",
|
|
160
161
|
"release": "semantic-release",
|
|
161
162
|
"pretest": "npm run build",
|
|
162
|
-
"test": "
|
|
163
|
+
"test": "npm run test:unit",
|
|
164
|
+
"test:unit": "cross-env NODE_ENV=development TEST=1 CONTEXT_FILENAME=\"./test.asyncapi\" CONTEXT_FILE_PATH=\"./\" jest --coverage -i",
|
|
163
165
|
"get-version": "echo $npm_package_version"
|
|
164
166
|
},
|
|
165
167
|
"types": "lib/index.d.ts"
|