@asyncapi/cli 0.30.2 → 0.31.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/README.md +23 -143
- package/lib/commands/optimize.d.ts +33 -0
- package/lib/commands/optimize.js +174 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -10,15 +10,8 @@ CLI to work with your AsyncAPI files. Currently under development, we are workin
|
|
|
10
10
|
|
|
11
11
|
<!-- toc -->
|
|
12
12
|
|
|
13
|
-
- [Installation](
|
|
14
|
-
|
|
15
|
-
* [MacOS](#macos)
|
|
16
|
-
+ [Using brew](#using-brew)
|
|
17
|
-
+ [Using pkg](#using-pkg)
|
|
18
|
-
* [Linux](#linux)
|
|
19
|
-
+ [For debian based distros](#for-debian-based-distros)
|
|
20
|
-
+ [For other distros](#for-other-distros)
|
|
21
|
-
- [Usage](#usage)
|
|
13
|
+
- [Installation](/docs/installation.md)
|
|
14
|
+
- [Usage](/docs/usage.md)
|
|
22
15
|
- [Contributing](#contributing)
|
|
23
16
|
* [Set up development environment](#set-up-development-environment)
|
|
24
17
|
* [Command Structure and Patterns](#command-structure-and-patterns)
|
|
@@ -27,127 +20,11 @@ CLI to work with your AsyncAPI files. Currently under development, we are workin
|
|
|
27
20
|
<!-- tocstop -->
|
|
28
21
|
|
|
29
22
|
## Installation
|
|
30
|
-
|
|
31
|
-
### Using NPM and Node
|
|
32
|
-
|
|
33
|
-
To run `@asyncapi/cli`, you'll need Node.js >=v10
|
|
34
|
-
|
|
35
|
-
Run this terminal command to check your Node.js version:
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
node -v
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
> If you don't have Node.js installed or NPM, simply [install both via package manager](https://nodejs.org/en/download/package-manager/)
|
|
42
|
-
|
|
43
|
-
Install the CLI globaly on your system run CLI it from anywhere:
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
npm install -g @asyncapi/cli
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### MacOS
|
|
50
|
-
|
|
51
|
-
#### Using brew
|
|
52
|
-
|
|
53
|
-
You can install this CLI using [`brew`](https://brew.sh/) package manager.
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
# Install brew
|
|
57
|
-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
58
|
-
# Install AsyncAPI CLI
|
|
59
|
-
brew install asyncapi
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
#### Using pkg
|
|
63
|
-
|
|
64
|
-
Each release of CLI produces a MacOS dedicated `pkg` file that enables you to install this CLI as MacOS application.
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
# Download latest release. To download specific release, your link should look similar to https://github.com/asyncapi/cli/releases/download/v0.13.0/asyncapi.pkg. All releases are listed in https://github.com/asyncapi/cli/releases
|
|
68
|
-
curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.pkg
|
|
69
|
-
# Install AsyncAPI CLI
|
|
70
|
-
sudo installer -pkg asyncapi.pkg -target /
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Linux
|
|
74
|
-
|
|
75
|
-
#### For debian based distros
|
|
76
|
-
|
|
77
|
-
You can install this CLI using `dpkg`, a package manager for debian.
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
# Download latest release. To download specific release, your link should look similar to https://github.com/asyncapi/cli/releases/download/v0.13.0/asyncapi.deb. All releases are listed in https://github.com/asyncapi/cli/releases
|
|
81
|
-
curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.deb
|
|
82
|
-
# Install AsyncAPI CLI
|
|
83
|
-
sudo dpkg -i asyncapi.deb
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
#### For other distros
|
|
87
|
-
|
|
88
|
-
You can install this CLI using the archive(`tar.gz`) file.
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# Download latest release. To download specific release, your link should look similar to https://github.com/asyncapi/cli/releases/download/v0.13.0/asyncapi.tar.gz. All releases are listed in https://github.com/asyncapi/cli/releases
|
|
92
|
-
curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.tar.gz
|
|
93
|
-
# Untar the archive file
|
|
94
|
-
tar -xzf asyncapi.tar.gz
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
The above step will create an `asyncapi` directory in the current path.
|
|
98
|
-
|
|
99
|
-
Create a symlink to run the CLI from anywhere. We will create the symlink in `/usr/local/bin` directory since this directory is already in the `PATH`.
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
# cd into the unarchived directory
|
|
103
|
-
cd asyncapi
|
|
104
|
-
|
|
105
|
-
# get the absolute path
|
|
106
|
-
pwd
|
|
107
|
-
|
|
108
|
-
# Create a symlink
|
|
109
|
-
ln -s <absolute-path>/bin/asyncapi /usr/local/bin/asyncapi
|
|
110
|
-
|
|
111
|
-
# The `asyncapi` command should be available to be used
|
|
112
|
-
asyncapi
|
|
113
|
-
```
|
|
23
|
+
Learn how to install the AsyncAPI CLI from the [installation guide](/docs/installation.md).
|
|
114
24
|
|
|
115
25
|
## Usage
|
|
26
|
+
The [usage guide](/docs/usage.md) provides information about different ways to use the CLI.
|
|
116
27
|
|
|
117
|
-
`@asyncapi/cli` makes it easier to work with asyncpi files.
|
|
118
|
-
|
|
119
|
-
We have well-documented help commands so just run:
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
asyncapi --help
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
It should print something like:
|
|
126
|
-
|
|
127
|
-
```
|
|
128
|
-
All in one CLI for all AsyncAPI tools
|
|
129
|
-
|
|
130
|
-
USAGE
|
|
131
|
-
$ asyncapi [COMMAND]
|
|
132
|
-
|
|
133
|
-
COMMANDS
|
|
134
|
-
config access configs
|
|
135
|
-
diff find diff between two AsyncAPI files
|
|
136
|
-
new creates a new AsyncAPI file
|
|
137
|
-
start starts a new local instance of Studio
|
|
138
|
-
validate validate an AsyncAPI file
|
|
139
|
-
generate generate all kinds of stuff
|
|
140
|
-
models generate all the typed models for the message payloads defined in the AsyncAPI file
|
|
141
|
-
typescript generate the models for TypeScript
|
|
142
|
-
csharp generate the models for C#
|
|
143
|
-
golang generate the models for Go
|
|
144
|
-
java generate the models for Java
|
|
145
|
-
javascript generate the models for JavaScript
|
|
146
|
-
dart generate the models for Dart
|
|
147
|
-
python generate the models for Python
|
|
148
|
-
rust generate the models for Rust
|
|
149
|
-
fromTemplate generate whatever you want using templates compatible with AsyncAPI Generator
|
|
150
|
-
```
|
|
151
28
|
|
|
152
29
|
## Contributing
|
|
153
30
|
|
|
@@ -176,22 +53,25 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
176
53
|
<!-- prettier-ignore-start -->
|
|
177
54
|
<!-- markdownlint-disable -->
|
|
178
55
|
<table>
|
|
179
|
-
<
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
56
|
+
<tbody>
|
|
57
|
+
<tr>
|
|
58
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jotamusik"><img src="https://avatars.githubusercontent.com/u/14940638?v=4?s=100" width="100px;" alt="Jorge Aguiar Martín"/><br /><sub><b>Jorge Aguiar Martín</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=jotamusik" title="Code">💻</a> <a href="#ideas-jotamusik" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/asyncapi/cli/commits?author=jotamusik" title="Tests">⚠️</a> <a href="https://github.com/asyncapi/cli/commits?author=jotamusik" title="Documentation">📖</a></td>
|
|
59
|
+
<td align="center" valign="top" width="14.28%"><a href="https://www.brainfart.dev/"><img src="https://avatars.githubusercontent.com/u/6995927?v=4?s=100" width="100px;" alt="Lukasz Gornicki"/><br /><sub><b>Lukasz Gornicki</b></sub></a><br /><a href="#ideas-derberg" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/asyncapi/cli/commits?author=derberg" title="Code">💻</a> <a href="https://github.com/asyncapi/cli/pulls?q=is%3Apr+reviewed-by%3Aderberg" title="Reviewed Pull Requests">👀</a> <a href="#maintenance-derberg" title="Maintenance">🚧</a></td>
|
|
60
|
+
<td align="center" valign="top" width="14.28%"><a href="https://souvik.vercel.app/"><img src="https://avatars.githubusercontent.com/u/41781438?v=4?s=100" width="100px;" alt="souvik"/><br /><sub><b>souvik</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=Souvikns" title="Code">💻</a> <a href="#ideas-Souvikns" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/asyncapi/cli/commits?author=Souvikns" title="Tests">⚠️</a> <a href="https://github.com/asyncapi/cli/pulls?q=is%3Apr+reviewed-by%3ASouvikns" title="Reviewed Pull Requests">👀</a> <a href="#maintenance-Souvikns" title="Maintenance">🚧</a> <a href="https://github.com/asyncapi/cli/commits?author=Souvikns" title="Documentation">📖</a></td>
|
|
61
|
+
<td align="center" valign="top" width="14.28%"><a href="https://boyney.io/"><img src="https://avatars.githubusercontent.com/u/3268013?v=4?s=100" width="100px;" alt="David Boyne"/><br /><sub><b>David Boyne</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=boyney123" title="Code">💻</a> <a href="#ideas-boyney123" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-boyney123" title="Maintenance">🚧</a></td>
|
|
62
|
+
<td align="center" valign="top" width="14.28%"><a href="http://www.fmvilas.com/"><img src="https://avatars.githubusercontent.com/u/242119?v=4?s=100" width="100px;" alt="Fran Méndez"/><br /><sub><b>Fran Méndez</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=fmvilas" title="Code">💻</a> <a href="#ideas-fmvilas" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/asyncapi/cli/pulls?q=is%3Apr+reviewed-by%3Afmvilas" title="Reviewed Pull Requests">👀</a></td>
|
|
63
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/magicmatatjahu"><img src="https://avatars.githubusercontent.com/u/20404945?v=4?s=100" width="100px;" alt="Maciej Urbańczyk"/><br /><sub><b>Maciej Urbańczyk</b></sub></a><br /><a href="https://github.com/asyncapi/cli/pulls?q=is%3Apr+reviewed-by%3Amagicmatatjahu" title="Reviewed Pull Requests">👀</a> <a href="#maintenance-magicmatatjahu" title="Maintenance">🚧</a> <a href="#ideas-magicmatatjahu" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
64
|
+
<td align="center" valign="top" width="14.28%"><a href="https://aayushsahu.com/"><img src="https://avatars.githubusercontent.com/u/54525741?v=4?s=100" width="100px;" alt="Aayush Kumar Sahu"/><br /><sub><b>Aayush Kumar Sahu</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=aayushmau5" title="Code">💻</a> <a href="https://github.com/asyncapi/cli/commits?author=aayushmau5" title="Tests">⚠️</a></td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mihirterna"><img src="https://avatars.githubusercontent.com/u/31316452?v=4?s=100" width="100px;" alt="Mihir Kulkarni"/><br /><sub><b>Mihir Kulkarni</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=mihirterna" title="Code">💻</a></td>
|
|
68
|
+
<td align="center" valign="top" width="14.28%"><a href="https://imabp.github.io/resume/"><img src="https://avatars.githubusercontent.com/u/53480076?v=4?s=100" width="100px;" alt="Abir"/><br /><sub><b>Abir</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=imabp" title="Tests">⚠️</a> <a href="https://github.com/asyncapi/cli/commits?author=imabp" title="Code">💻</a></td>
|
|
69
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/peter-rr"><img src="https://avatars.githubusercontent.com/u/81691177?v=4?s=100" width="100px;" alt="Peter Ramos"/><br /><sub><b>Peter Ramos</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=peter-rr" title="Code">💻</a></td>
|
|
70
|
+
<td align="center" valign="top" width="14.28%"><a href="https://samridhi-98.github.io/Portfolio"><img src="https://avatars.githubusercontent.com/u/54466041?v=4?s=100" width="100px;" alt="Samriddhi"/><br /><sub><b>Samriddhi</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=Samridhi-98" title="Tests">⚠️</a></td>
|
|
71
|
+
<td align="center" valign="top" width="14.28%"><a href="https://linktr.ee/KharabePranay"><img src="https://avatars.githubusercontent.com/u/68046838?v=4?s=100" width="100px;" alt="Pranay Kharabe"/><br /><sub><b>Pranay Kharabe</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=pranay202" title="Code">💻</a></td>
|
|
72
|
+
<td align="center" valign="top" width="14.28%"><a href="https://d-m-oladele.netlify.app/"><img src="https://avatars.githubusercontent.com/u/98895460?v=4?s=100" width="100px;" alt="Damilola Oladele"/><br /><sub><b>Damilola Oladele</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=activus-d" title="Documentation">📖</a></td>
|
|
73
|
+
</tr>
|
|
74
|
+
</tbody>
|
|
195
75
|
</table>
|
|
196
76
|
|
|
197
77
|
<!-- markdownlint-restore -->
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Command from '../base';
|
|
2
|
+
import { Example } from '@oclif/core/lib/interfaces';
|
|
3
|
+
export declare enum Optimizations {
|
|
4
|
+
REMOVE_COMPONENTS = "remove-components",
|
|
5
|
+
REUSE_COMPONENTS = "reuse-components",
|
|
6
|
+
MOVE_TO_COMPONETS = "move-to-components"
|
|
7
|
+
}
|
|
8
|
+
export declare enum Outputs {
|
|
9
|
+
TERMINAL = "terminal",
|
|
10
|
+
NEW_FILE = "new-file",
|
|
11
|
+
OVERWRITE = "overwrite"
|
|
12
|
+
}
|
|
13
|
+
export default class Optimize extends Command {
|
|
14
|
+
static description: string;
|
|
15
|
+
isInteractive: boolean;
|
|
16
|
+
optimizations?: Optimizations[];
|
|
17
|
+
outputMethod?: Outputs;
|
|
18
|
+
static examples: Example[];
|
|
19
|
+
static flags: {
|
|
20
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
21
|
+
optimization: import("@oclif/core/lib/interfaces").OptionFlag<string[]>;
|
|
22
|
+
output: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
23
|
+
'no-tty': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
24
|
+
};
|
|
25
|
+
static args: {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
required: boolean;
|
|
29
|
+
}[];
|
|
30
|
+
run(): Promise<void>;
|
|
31
|
+
private showOptimizations;
|
|
32
|
+
private interactiveRun;
|
|
33
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Outputs = exports.Optimizations = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const optimizer_1 = require("@asyncapi/optimizer");
|
|
7
|
+
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
8
|
+
const validation_error_1 = require("../errors/validation-error");
|
|
9
|
+
const SpecificationFile_1 = require("../models/SpecificationFile");
|
|
10
|
+
const inquirer = tslib_1.__importStar(require("inquirer"));
|
|
11
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const { writeFile } = fs_1.promises;
|
|
14
|
+
var Optimizations;
|
|
15
|
+
(function (Optimizations) {
|
|
16
|
+
Optimizations["REMOVE_COMPONENTS"] = "remove-components";
|
|
17
|
+
Optimizations["REUSE_COMPONENTS"] = "reuse-components";
|
|
18
|
+
Optimizations["MOVE_TO_COMPONETS"] = "move-to-components";
|
|
19
|
+
})(Optimizations = exports.Optimizations || (exports.Optimizations = {}));
|
|
20
|
+
var Outputs;
|
|
21
|
+
(function (Outputs) {
|
|
22
|
+
Outputs["TERMINAL"] = "terminal";
|
|
23
|
+
Outputs["NEW_FILE"] = "new-file";
|
|
24
|
+
Outputs["OVERWRITE"] = "overwrite";
|
|
25
|
+
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
|
26
|
+
class Optimize extends base_1.default {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.isInteractive = false;
|
|
30
|
+
}
|
|
31
|
+
run() {
|
|
32
|
+
var _a, _b, _c, _d;
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const { args, flags } = yield this.parse(Optimize); //NOSONAR
|
|
35
|
+
const filePath = args['spec-file'];
|
|
36
|
+
let specFile;
|
|
37
|
+
let optimizer;
|
|
38
|
+
let report;
|
|
39
|
+
try {
|
|
40
|
+
specFile = yield (0, SpecificationFile_1.load)(filePath);
|
|
41
|
+
optimizer = new optimizer_1.Optimizer(specFile.text());
|
|
42
|
+
report = yield optimizer.getReport();
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
this.error(new validation_error_1.ValidationError({
|
|
46
|
+
type: 'invalid-file',
|
|
47
|
+
filepath: filePath,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
this.isInteractive = !flags['no-tty'];
|
|
51
|
+
this.optimizations = flags.optimization;
|
|
52
|
+
this.outputMethod = flags.output;
|
|
53
|
+
if (!(((_a = report.moveToComponents) === null || _a === void 0 ? void 0 : _a.length) || ((_b = report.removeComponents) === null || _b === void 0 ? void 0 : _b.length) || ((_c = report.reuseComponents) === null || _c === void 0 ? void 0 : _c.length))) {
|
|
54
|
+
this.log(`No optimization has been applied since ${(_d = specFile.getFilePath()) !== null && _d !== void 0 ? _d : specFile.getFileURL()} looks optimized!`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const isTTY = process.stdout.isTTY;
|
|
58
|
+
if (this.isInteractive && isTTY) {
|
|
59
|
+
yield this.interactiveRun(report);
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const optimizedDocument = optimizer.getOptimizedDocument({ rules: {
|
|
63
|
+
moveToComponents: this.optimizations.includes(Optimizations.MOVE_TO_COMPONETS),
|
|
64
|
+
removeComponents: this.optimizations.includes(Optimizations.REMOVE_COMPONENTS),
|
|
65
|
+
reuseComponents: this.optimizations.includes(Optimizations.REUSE_COMPONENTS)
|
|
66
|
+
}, output: optimizer_1.Output.YAML });
|
|
67
|
+
const specPath = specFile.getFilePath();
|
|
68
|
+
let newPath = '';
|
|
69
|
+
if (specPath) {
|
|
70
|
+
const pos = specPath.lastIndexOf('.');
|
|
71
|
+
newPath = `${specPath.substring(0, pos)}_optimized.${specPath.substring(pos + 1)}`;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
newPath = 'optimized-asyncapi.yaml';
|
|
75
|
+
}
|
|
76
|
+
if (this.outputMethod === Outputs.TERMINAL) {
|
|
77
|
+
this.log(optimizedDocument);
|
|
78
|
+
}
|
|
79
|
+
else if (this.outputMethod === Outputs.NEW_FILE) {
|
|
80
|
+
yield writeFile(newPath, optimizedDocument, { encoding: 'utf8' });
|
|
81
|
+
this.log(`Created file ${newPath}...`);
|
|
82
|
+
}
|
|
83
|
+
else if (this.outputMethod === Outputs.OVERWRITE) {
|
|
84
|
+
yield writeFile(specPath !== null && specPath !== void 0 ? specPath : 'asyncapi.yaml', optimizedDocument, { encoding: 'utf8' });
|
|
85
|
+
this.log(`Created file ${newPath}...`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
throw new validation_error_1.ValidationError({
|
|
90
|
+
type: 'parser-error',
|
|
91
|
+
err: error
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
showOptimizations(elements) {
|
|
97
|
+
if (!elements) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (let i = 0; i < elements.length; i++) {
|
|
101
|
+
const element = elements[+i];
|
|
102
|
+
if (element.action === 'move') {
|
|
103
|
+
this.log(`${chalk_1.default.green('move')} ${element.path} to ${element.target} and reference it.`);
|
|
104
|
+
}
|
|
105
|
+
else if (element.action === 'reuse') {
|
|
106
|
+
this.log(`${chalk_1.default.green('reuse')} ${element.target} in ${element.path}.`);
|
|
107
|
+
}
|
|
108
|
+
else if (element.action === 'remove') {
|
|
109
|
+
this.log(`${chalk_1.default.red('remove')} ${element.path}.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this.log('\n');
|
|
113
|
+
}
|
|
114
|
+
interactiveRun(report) {
|
|
115
|
+
var _a, _b, _c, _d, _e, _f;
|
|
116
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const canMove = (_a = report.moveToComponents) === null || _a === void 0 ? void 0 : _a.length;
|
|
118
|
+
const canRemove = (_b = report.removeComponents) === null || _b === void 0 ? void 0 : _b.length;
|
|
119
|
+
const canReuse = (_c = report.reuseComponents) === null || _c === void 0 ? void 0 : _c.length;
|
|
120
|
+
const choices = [];
|
|
121
|
+
if (canMove) {
|
|
122
|
+
const totalMove = (_d = report.moveToComponents) === null || _d === void 0 ? void 0 : _d.filter((e) => e.action === 'move').length;
|
|
123
|
+
this.log(`\n${chalk_1.default.green(totalMove)} components can be moved to the components sections.\nthe following changes will be made:`);
|
|
124
|
+
this.showOptimizations(report.moveToComponents);
|
|
125
|
+
choices.push({ name: 'move to components section', value: Optimizations.MOVE_TO_COMPONETS });
|
|
126
|
+
}
|
|
127
|
+
if (canRemove) {
|
|
128
|
+
const totalMove = (_e = report.removeComponents) === null || _e === void 0 ? void 0 : _e.length;
|
|
129
|
+
this.log(`${chalk_1.default.green(totalMove)} unused components can be removed.\nthe following changes will be made:`);
|
|
130
|
+
this.showOptimizations(report.removeComponents);
|
|
131
|
+
choices.push({ name: 'remove components', value: Optimizations.REMOVE_COMPONENTS });
|
|
132
|
+
}
|
|
133
|
+
if (canReuse) {
|
|
134
|
+
const totalMove = (_f = report.reuseComponents) === null || _f === void 0 ? void 0 : _f.length;
|
|
135
|
+
this.log(`${chalk_1.default.green(totalMove)} components can be reused.\nthe following changes will be made:`);
|
|
136
|
+
this.showOptimizations(report.reuseComponents);
|
|
137
|
+
choices.push({ name: 'reuse components', value: Optimizations.REUSE_COMPONENTS });
|
|
138
|
+
}
|
|
139
|
+
const optimizationRes = yield inquirer.prompt([{
|
|
140
|
+
name: 'optimization',
|
|
141
|
+
message: 'select the type of optimization that you want to apply:',
|
|
142
|
+
type: 'checkbox',
|
|
143
|
+
default: 'all',
|
|
144
|
+
choices
|
|
145
|
+
}]);
|
|
146
|
+
this.optimizations = optimizationRes.optimization;
|
|
147
|
+
const outputRes = yield inquirer.prompt([{
|
|
148
|
+
name: 'output',
|
|
149
|
+
message: 'where do you want to save the result:',
|
|
150
|
+
type: 'list',
|
|
151
|
+
default: 'log to terminal',
|
|
152
|
+
choices: [{ name: 'log to terminal', value: Outputs.TERMINAL }, { name: 'create new file', value: Outputs.NEW_FILE }, { name: 'update original', value: Outputs.OVERWRITE }]
|
|
153
|
+
}]);
|
|
154
|
+
this.outputMethod = outputRes.output;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.default = Optimize;
|
|
159
|
+
Optimize.description = 'optimize asyncapi specification file';
|
|
160
|
+
Optimize.examples = [
|
|
161
|
+
'asyncapi optimize ./asyncapi.yaml',
|
|
162
|
+
'asyncapi optimize ./asyncapi.yaml --no-tty',
|
|
163
|
+
'asyncapi optimize ./asyncapi.yaml --optimization=remove-components,reuse-components,move-to-components --no-tty',
|
|
164
|
+
'asyncapi optimize ./asyncapi.yaml --optimization=remove-components,reuse-components,move-to-components --output=terminal --no-tty',
|
|
165
|
+
];
|
|
166
|
+
Optimize.flags = {
|
|
167
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
168
|
+
optimization: core_1.Flags.string({ char: 'p', default: Object.values(Optimizations), options: Object.values(Optimizations), multiple: true, description: 'select the type of optimizations that you want to apply.' }),
|
|
169
|
+
output: core_1.Flags.string({ char: 'o', default: Outputs.TERMINAL, options: Object.values(Outputs), description: 'select where you want the output.' }),
|
|
170
|
+
'no-tty': core_1.Flags.boolean({ description: 'do not use an interactive terminal', default: false }),
|
|
171
|
+
};
|
|
172
|
+
Optimize.args = [
|
|
173
|
+
{ name: 'spec-file', description: 'spec path, url, or context-name', required: false },
|
|
174
|
+
];
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.30.2","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}]}}}
|
|
1
|
+
{"version":"0.31.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":[]},"optimize":{"id":"optimize","description":"optimize asyncapi specification file","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"examples":["asyncapi optimize ./asyncapi.yaml","asyncapi optimize ./asyncapi.yaml --no-tty","asyncapi optimize ./asyncapi.yaml --optimization=remove-components,reuse-components,move-to-components --no-tty","asyncapi optimize ./asyncapi.yaml --optimization=remove-components,reuse-components,move-to-components --output=terminal --no-tty"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"optimization":{"name":"optimization","type":"option","char":"p","description":"select the type of optimizations that you want to apply.","multiple":true,"options":["remove-components","reuse-components","move-to-components"],"default":["remove-components","reuse-components","move-to-components"]},"output":{"name":"output","type":"option","char":"o","description":"select where you want the output.","multiple":false,"options":["terminal","new-file","overwrite"],"default":"terminal"},"no-tty":{"name":"no-tty","type":"boolean","description":"do not use an interactive terminal","allowNo":false}},"args":[{"name":"spec-file","description":"spec path, url, or context-name","required":false}]},"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.31.0",
|
|
5
5
|
"author": "@asyncapi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"asyncapi": "./bin/run"
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"@asyncapi/converter": "^1.2.0",
|
|
12
12
|
"@asyncapi/diff": "^0.4.1",
|
|
13
13
|
"@asyncapi/generator": "^1.9.12",
|
|
14
|
+
"@asyncapi/optimizer": "^0.1.15",
|
|
14
15
|
"@asyncapi/modelina": "^1.0.0-next.40",
|
|
15
16
|
"@asyncapi/parser": "^2.0.0-next-major.11",
|
|
16
17
|
"@asyncapi/studio": "^0.16.1",
|