@bymbly/api-tools 1.3.4 → 1.4.1
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 +296 -87
- package/dist/defaults/.asyncapi-analytics +1 -0
- package/dist/defaults/node-config/production.json +1 -0
- package/dist/lib/asyncapi/build-docs.js +14 -0
- package/dist/lib/asyncapi/build-docs.js.map +1 -0
- package/dist/lib/asyncapi/bundle.js +60 -0
- package/dist/lib/asyncapi/bundle.js.map +1 -0
- package/dist/lib/asyncapi/cli.js +22 -0
- package/dist/lib/asyncapi/cli.js.map +1 -0
- package/dist/lib/asyncapi/command.js +24 -0
- package/dist/lib/asyncapi/command.js.map +1 -0
- package/dist/lib/asyncapi/format.js +59 -0
- package/dist/lib/asyncapi/format.js.map +1 -0
- package/dist/lib/asyncapi/generate/command.js +8 -0
- package/dist/lib/asyncapi/generate/command.js.map +1 -0
- package/dist/lib/asyncapi/generate/docs.js +71 -0
- package/dist/lib/asyncapi/generate/docs.js.map +1 -0
- package/dist/lib/asyncapi/generate/from-template.js +76 -0
- package/dist/lib/asyncapi/generate/from-template.js.map +1 -0
- package/dist/lib/asyncapi/lint.js +75 -0
- package/dist/lib/asyncapi/lint.js.map +1 -0
- package/dist/lib/cli/program.js +3 -1
- package/dist/lib/cli/program.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -7,11 +7,11 @@ customization through CLI options and passthrough arguments.
|
|
|
7
7
|
|
|
8
8
|
**Supports:** OpenAPI, AsyncAPI, Arazzo
|
|
9
9
|
|
|
10
|
-
**Wraps:** [Redocly](https://github.com/Redocly/redocly-cli) | [Spectral](https://github.com/stoplightio/spectral)
|
|
10
|
+
**Wraps:** [AsyncAPI](https://www.asyncapi.com/en/tools/cli) | [Redocly](https://github.com/Redocly/redocly-cli) | [Spectral](https://github.com/stoplightio/spectral)
|
|
11
11
|
|
|
12
|
-
[
|
|
14
|
-

|
|
12
|
+
[](https://github.com/bymbly/api-tools/actions/workflows/workflow.yaml)
|
|
13
|
+
[](https://www.npmjs.com/package/@bymbly/api-tools)
|
|
14
|
+
[](https://github.com/bymbly/api-tools/blob/main/LICENSE)
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
@@ -32,17 +32,24 @@ customization through CLI options and passthrough arguments.
|
|
|
32
32
|
- [Command Structure](#command-structure)
|
|
33
33
|
- [Global Options](#global-options)
|
|
34
34
|
- [Commands](#commands)
|
|
35
|
-
- [
|
|
36
|
-
- [`
|
|
37
|
-
- [`
|
|
35
|
+
- [AsyncAPI Commands](#asyncapi-commands)
|
|
36
|
+
- [`asyncapi build-docs`](#asyncapi-build-docs)
|
|
37
|
+
- [`asyncapi bundle`](#asyncapi-bundle)
|
|
38
|
+
- [`asyncapi format`](#asyncapi-format)
|
|
39
|
+
- [`asyncapi generate docs`](#asyncapi-generate-docs)
|
|
40
|
+
- [`asyncapi generate from-template`](#asyncapi-generate-from-template)
|
|
41
|
+
- [`asyncapi lint`](#asyncapi-lint)
|
|
38
42
|
- [Redocly Commands](#redocly-commands)
|
|
39
|
-
- [`redocly lint`](#redocly-lint)
|
|
40
43
|
- [`redocly build-docs`](#redocly-build-docs)
|
|
41
44
|
- [`redocly bundle`](#redocly-bundle)
|
|
42
|
-
- [`redocly join`](#redocly-join)
|
|
43
45
|
- [`redocly generate-arazzo`](#redocly-generate-arazzo)
|
|
44
|
-
- [`redocly respect`](#redocly-respect)
|
|
45
46
|
- [`redocly init`](#redocly-init)
|
|
47
|
+
- [`redocly join`](#redocly-join)
|
|
48
|
+
- [`redocly lint`](#redocly-lint)
|
|
49
|
+
- [`redocly respect`](#redocly-respect)
|
|
50
|
+
- [Spectral Commands](#spectral-commands)
|
|
51
|
+
- [`spectral init`](#spectral-init)
|
|
52
|
+
- [`spectral lint`](#spectral-lint)
|
|
46
53
|
- [Default File Locations](#default-file-locations)
|
|
47
54
|
- [Configuration Files](#configuration-files)
|
|
48
55
|
- [Auto-Discovery](#auto-discovery)
|
|
@@ -76,12 +83,15 @@ Add scripts to your `package.json`:
|
|
|
76
83
|
```json
|
|
77
84
|
{
|
|
78
85
|
"scripts": {
|
|
79
|
-
"lint": "npm run lint:spectral && npm run lint:redocly",
|
|
86
|
+
"lint": "npm run lint:spectral && npm run lint:redocly && npm run lint:asyncapi",
|
|
80
87
|
"lint:spectral": "api-tools spectral lint",
|
|
81
88
|
"lint:redocly": "api-tools redocly lint",
|
|
82
|
-
"
|
|
89
|
+
"lint:asyncapi": "api-tools asyncapi lint",
|
|
90
|
+
"bundle:openapi": "api-tools redocly bundle",
|
|
91
|
+
"bundle:asyncapi": "api-tools asyncapi bundle",
|
|
83
92
|
"join": "api-tools redocly join",
|
|
84
|
-
"docs": "api-tools redocly build-docs",
|
|
93
|
+
"docs:openapi": "api-tools redocly build-docs",
|
|
94
|
+
"docs:asyncapi": "api-tools asyncapi build-docs",
|
|
85
95
|
"arazzo:gen": "api-tools redocly generate-arazzo",
|
|
86
96
|
"test:api": "api-tools redocly respect"
|
|
87
97
|
}
|
|
@@ -91,12 +101,14 @@ Add scripts to your `package.json`:
|
|
|
91
101
|
Run:
|
|
92
102
|
|
|
93
103
|
```bash
|
|
94
|
-
npm run lint
|
|
95
|
-
npm run bundle
|
|
96
|
-
npm run
|
|
97
|
-
npm run
|
|
98
|
-
npm run
|
|
99
|
-
npm run
|
|
104
|
+
npm run lint # Lint with both Spectral and Redocly
|
|
105
|
+
npm run bundle:openapi # Bundle OpenAPI documents
|
|
106
|
+
npm run bundle:asyncapi # Bundle AsyncAPI documents
|
|
107
|
+
npm run join # Join OpenAPI documents
|
|
108
|
+
npm run docs:openapi # Generate OpenAPI HTML documentation
|
|
109
|
+
npm run docs:asyncapi # Generate AsyncAPI HTML documentation
|
|
110
|
+
npm run arazzo:gen # Generate Arazzo workflow starter
|
|
111
|
+
npm run test:api # Execute Arazzo workflow tests
|
|
100
112
|
```
|
|
101
113
|
|
|
102
114
|
## Command Structure
|
|
@@ -115,102 +127,185 @@ Available for all commands:
|
|
|
115
127
|
|
|
116
128
|
## Commands
|
|
117
129
|
|
|
118
|
-
###
|
|
130
|
+
### AsyncAPI Commands
|
|
119
131
|
|
|
120
|
-
#### `
|
|
132
|
+
#### `asyncapi build-docs`
|
|
121
133
|
|
|
122
|
-
|
|
134
|
+
Alias for `asyncapi generate docs` - builds HTML documentation from AsyncAPI documents.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
api-tools asyncapi build-docs [input] [options]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
See [`asyncapi generate docs`](#asyncapi-generate-docs) for full usage details.
|
|
141
|
+
|
|
142
|
+
#### `asyncapi bundle`
|
|
143
|
+
|
|
144
|
+
Bundle AsyncAPI documents into a single file.
|
|
123
145
|
|
|
124
146
|
**Usage:**
|
|
125
147
|
|
|
126
148
|
```bash
|
|
127
|
-
api-tools
|
|
149
|
+
api-tools asyncapi bundle [input] [options]
|
|
128
150
|
```
|
|
129
151
|
|
|
130
152
|
**Options:**
|
|
131
153
|
|
|
132
|
-
- `[input]` - Document path (default:
|
|
133
|
-
- `--
|
|
134
|
-
- `--
|
|
135
|
-
-
|
|
136
|
-
- `--
|
|
137
|
-
- Choices: `json`, `stylish`, `junit`, `html`, `text`, `teamcity`, `pretty`, `github-actions`, `sarif`, `markdown`, `gitlab`
|
|
138
|
-
- `--output <file>` - Write output to file
|
|
139
|
-
- `--ruleset <file>` - Custom ruleset (overrides auto/bundled)
|
|
140
|
-
- `--fail-severity <level>` - Fail threshold (default: `warn`)
|
|
141
|
-
- Choices: `error`, `warn`, `info`, `hint`
|
|
142
|
-
- `--display-only-failures` - Show only failing results
|
|
143
|
-
- `--verbose` - Enable verbose output
|
|
154
|
+
- `[input]` - Document path (default: `asyncapi/asyncapi.yaml`)
|
|
155
|
+
- `--output <path>` - Output file path (default: `dist/bundle/asyncapi.yaml`)
|
|
156
|
+
- `--ext <extension>` - Output extension (overrides `--output` extension)
|
|
157
|
+
- Choices: `json`, `yaml`, `yml`
|
|
158
|
+
- `--x-origin` - Generate x-origin fields with dereferenced $ref history
|
|
144
159
|
|
|
145
160
|
**Examples:**
|
|
146
161
|
|
|
147
162
|
```bash
|
|
148
|
-
#
|
|
149
|
-
api-tools
|
|
163
|
+
# Bundle with defaults
|
|
164
|
+
api-tools asyncapi bundle
|
|
150
165
|
|
|
151
|
-
#
|
|
152
|
-
api-tools
|
|
153
|
-
api-tools spectral lint --asyncapi --arazzo
|
|
166
|
+
# Bundle to JSON
|
|
167
|
+
api-tools asyncapi bundle --ext json
|
|
154
168
|
|
|
155
|
-
#
|
|
156
|
-
api-tools
|
|
169
|
+
# Bundle with x-origin tracking
|
|
170
|
+
api-tools asyncapi bundle --x-origin
|
|
157
171
|
|
|
158
|
-
#
|
|
159
|
-
api-tools
|
|
172
|
+
# Custom output
|
|
173
|
+
api-tools asyncapi bundle --output dist/api-bundle.yaml
|
|
174
|
+
```
|
|
160
175
|
|
|
161
|
-
|
|
162
|
-
api-tools spectral lint --ruleset .spectral.yaml
|
|
176
|
+
#### `asyncapi format`
|
|
163
177
|
|
|
164
|
-
|
|
165
|
-
|
|
178
|
+
Convert AsyncAPI documents between formats (YAML <---> JSON).
|
|
179
|
+
|
|
180
|
+
**Usage:**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
api-tools asyncapi format [input] [options]
|
|
166
184
|
```
|
|
167
185
|
|
|
168
|
-
|
|
186
|
+
**Options:**
|
|
169
187
|
|
|
170
|
-
|
|
188
|
+
- `[input]` - Document path (default: `asyncapi/asyncapi.yaml`)
|
|
189
|
+
- `--output <file>` - Output file path (default: `dist/format/asyncapi.json`)
|
|
190
|
+
- `--ext <extension>` - Output extension (overrides `--output` extension)
|
|
191
|
+
- Choices: `json`, `yaml`, `yml`
|
|
192
|
+
|
|
193
|
+
**Examples:**
|
|
171
194
|
|
|
172
195
|
```bash
|
|
173
|
-
|
|
196
|
+
# Convert to JSON (default)
|
|
197
|
+
api-tools asyncapi format
|
|
198
|
+
|
|
199
|
+
# Convert to YAML
|
|
200
|
+
api-tools asyncapi format --ext yaml
|
|
201
|
+
|
|
202
|
+
# Custom input and output
|
|
203
|
+
api-tools asyncapi format input.json --output output.yaml
|
|
174
204
|
```
|
|
175
205
|
|
|
176
|
-
|
|
206
|
+
#### `asyncapi generate docs`
|
|
177
207
|
|
|
178
|
-
|
|
208
|
+
Generate HTML documentation (convenience wrapper around [`from-template`](#asyncapi-generate-from-template) with HTML template).
|
|
179
209
|
|
|
180
|
-
|
|
210
|
+
**Usage:**
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
api-tools asyncapi generate docs [input] [options]
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Options:**
|
|
217
|
+
|
|
218
|
+
- `[input]` - Document path (default: `asyncapi/asyncapi.yaml`)
|
|
219
|
+
- `--output <file>` - Output HTML file (default: `dist/docs/asyncapi.html`)
|
|
220
|
+
- `--params <key=value...>` - Template parameters (can be repeated)
|
|
221
|
+
- `--single-file` - Generate single HTML file (default: `true`)
|
|
222
|
+
- `--no-single-file` - Generate multiple files
|
|
223
|
+
|
|
224
|
+
**Examples:**
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Generate single-file docs
|
|
228
|
+
api-tools asyncapi generate docs
|
|
229
|
+
|
|
230
|
+
# Generate multi-file docs
|
|
231
|
+
api-tools asyncapi generate docs --no-single-file
|
|
232
|
+
|
|
233
|
+
# Custom output and parameters
|
|
234
|
+
api-tools asyncapi generate docs --output public/api.html \
|
|
235
|
+
--params version=2.0.0
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### `asyncapi generate from-template`
|
|
239
|
+
|
|
240
|
+
Generate code or documentation from AsyncAPI documents using templates.
|
|
181
241
|
|
|
182
242
|
**Usage:**
|
|
183
243
|
|
|
184
244
|
```bash
|
|
185
|
-
api-tools
|
|
245
|
+
api-tools asyncapi generate from-template <template> [input] [options]
|
|
186
246
|
```
|
|
187
247
|
|
|
188
248
|
**Options:**
|
|
189
249
|
|
|
190
|
-
-
|
|
191
|
-
-
|
|
192
|
-
- `--
|
|
193
|
-
- `--
|
|
194
|
-
- `--
|
|
195
|
-
- Choices: `codeframe`, `stylish`, `json`, `checkstyle`, `codeclimate`, `github-actions`, `markdown`, `summary`
|
|
196
|
-
- `--config <file>` - Config file path (overrides auto/bundled)
|
|
250
|
+
- `<template>` - **REQUIRED.** Template name or URL (e.g., `@asyncapi/html-template`)
|
|
251
|
+
- `[input]` - Document path (default: `asyncapi/asyncapi.yaml`)
|
|
252
|
+
- `--output <directory>` - Output directory (default: `dist/generated/`)
|
|
253
|
+
- `--params <key=value...>` - Template parameters (can be repeated)
|
|
254
|
+
- `--force-write` - Overwrite existing files
|
|
197
255
|
|
|
198
256
|
**Examples:**
|
|
199
257
|
|
|
200
258
|
```bash
|
|
201
|
-
#
|
|
202
|
-
api-tools
|
|
259
|
+
# Generate HTML docs
|
|
260
|
+
api-tools asyncapi generate from-template @asyncapi/html-template
|
|
203
261
|
|
|
204
|
-
#
|
|
205
|
-
api-tools
|
|
262
|
+
# Generate with custom output
|
|
263
|
+
api-tools asyncapi generate from-template @asyncapi/nodejs-template \
|
|
264
|
+
--output src/generated
|
|
265
|
+
|
|
266
|
+
# Generate with parameters
|
|
267
|
+
api-tools asyncapi generate from-template @asyncapi/java-spring-template \
|
|
268
|
+
--params javaPackage=com.example.myapp.codegen maven=true
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
#### `asyncapi lint`
|
|
272
|
+
|
|
273
|
+
Validate and lint AsyncAPI documents.
|
|
274
|
+
|
|
275
|
+
**Usage:**
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
api-tools asyncapi lint [input] [options]
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Options:**
|
|
282
|
+
|
|
283
|
+
- `[input]` - Document path (default: `asyncapi/asyncapi.yaml`)
|
|
284
|
+
- `--format <format>` - Output format (default: `stylish`)
|
|
285
|
+
- Choices: `json`, `stylish`, `junit`, `html`, `teamcity`, `pretty`, `github-actions`, `sarif`,
|
|
286
|
+
`code-climate`, `gitlab`, `markdown`
|
|
287
|
+
- `--output <file>` - Write output to file
|
|
288
|
+
- `--fail-severity <level>` - Fail threshold (default: `warn`)
|
|
289
|
+
- Choices: `error`, `warn`, `info`, `hint`
|
|
290
|
+
|
|
291
|
+
**Examples:**
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Lint default AsyncAPI spec
|
|
295
|
+
api-tools asyncapi lint
|
|
296
|
+
|
|
297
|
+
# Lint specific file
|
|
298
|
+
api-tools asyncapi lint custom/spec.yaml
|
|
206
299
|
|
|
207
300
|
# JSON output
|
|
208
|
-
api-tools
|
|
301
|
+
api-tools asyncapi lint --format json --output results.json
|
|
209
302
|
|
|
210
|
-
#
|
|
211
|
-
api-tools
|
|
303
|
+
# Only fail on errors
|
|
304
|
+
api-tools asyncapi lint --fail-severity error
|
|
212
305
|
```
|
|
213
306
|
|
|
307
|
+
### Redocly Commands
|
|
308
|
+
|
|
214
309
|
#### `redocly build-docs`
|
|
215
310
|
|
|
216
311
|
Build HTML documentation from OpenAPI documents.
|
|
@@ -283,6 +378,41 @@ api-tools redocly bundle --output dist/api-bundle.yaml
|
|
|
283
378
|
api-tools redocly bundle -- --remove-unused-components
|
|
284
379
|
```
|
|
285
380
|
|
|
381
|
+
#### `redocly generate-arazzo`
|
|
382
|
+
|
|
383
|
+
Generate Arazzo workflow description from OpenAPI document.
|
|
384
|
+
|
|
385
|
+
**Usage:**
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
api-tools redocly generate-arazzo [input] [options]
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Options:**
|
|
392
|
+
|
|
393
|
+
- `[input]` - OpenAPI document path (default: `openapi/openapi.yaml`)
|
|
394
|
+
- `--output <file>` - Output file path (default: `arazzo/auto-generated.arazzo.yaml`)
|
|
395
|
+
|
|
396
|
+
**Note:** Generated Arazzo files require manual editing to be functional.
|
|
397
|
+
|
|
398
|
+
**Examples:**
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
# Generate from default OpenAPI
|
|
402
|
+
api-tools redocly generate-arazzo
|
|
403
|
+
|
|
404
|
+
# Custom output
|
|
405
|
+
api-tools redocly generate-arazzo --output arazzo/workflows.arazzo.yaml
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
#### `redocly init`
|
|
409
|
+
|
|
410
|
+
Create a default `redocly.yaml` config file.
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
api-tools redocly init [--force]
|
|
414
|
+
```
|
|
415
|
+
|
|
286
416
|
#### `redocly join`
|
|
287
417
|
|
|
288
418
|
Join multiple OpenAPI 3.x documents into a single file.
|
|
@@ -321,7 +451,8 @@ api-tools redocly join <inputs...> [options]
|
|
|
321
451
|
api-tools redocly join api-1.yaml api-2.yaml
|
|
322
452
|
|
|
323
453
|
# Join with custom output
|
|
324
|
-
api-tools redocly join users-api.yaml orders-api.yaml
|
|
454
|
+
api-tools redocly join users-api.yaml orders-api.yaml \
|
|
455
|
+
--output dist/combined-api.yaml
|
|
325
456
|
|
|
326
457
|
# Resolve component naming conflicts using version
|
|
327
458
|
api-tools redocly join museum-v1.yaml museum-v2.yaml \
|
|
@@ -342,31 +473,40 @@ api-tools redocly join api-a.yaml api-b.yaml --without-x-tag-groups
|
|
|
342
473
|
api-tools redocly join *.yaml -- --lint-config error
|
|
343
474
|
```
|
|
344
475
|
|
|
345
|
-
#### `redocly
|
|
476
|
+
#### `redocly lint`
|
|
346
477
|
|
|
347
|
-
|
|
478
|
+
Validate and lint OpenAPI, AsyncAPI, and Arazzo documents using Redocly.
|
|
348
479
|
|
|
349
480
|
**Usage:**
|
|
350
481
|
|
|
351
482
|
```bash
|
|
352
|
-
api-tools redocly
|
|
483
|
+
api-tools redocly lint [input] [options]
|
|
353
484
|
```
|
|
354
485
|
|
|
355
486
|
**Options:**
|
|
356
487
|
|
|
357
|
-
- `[input]` -
|
|
358
|
-
- `--
|
|
359
|
-
|
|
360
|
-
|
|
488
|
+
- `[input]` - Document path (default: auto-detect)
|
|
489
|
+
- `--openapi` - Lint only OpenAPI at `openapi/openapi.yaml`
|
|
490
|
+
- `--asyncapi` - Lint only AsyncAPI at `asyncapi/asyncapi.yaml`
|
|
491
|
+
- `--arazzo` - Lint only Arazzo at `arazzo/arazzo.yaml`
|
|
492
|
+
- `--format <format>` - Output format (default: `codeframe`)
|
|
493
|
+
- Choices: `codeframe`, `stylish`, `json`, `checkstyle`, `codeclimate`, `github-actions`, `markdown`, `summary`
|
|
494
|
+
- `--config <file>` - Config file path (overrides auto/bundled)
|
|
361
495
|
|
|
362
496
|
**Examples:**
|
|
363
497
|
|
|
364
498
|
```bash
|
|
365
|
-
#
|
|
366
|
-
api-tools redocly
|
|
499
|
+
# Auto-detect and lint all specs
|
|
500
|
+
api-tools redocly lint
|
|
367
501
|
|
|
368
|
-
#
|
|
369
|
-
api-tools redocly
|
|
502
|
+
# Lint only OpenAPI
|
|
503
|
+
api-tools redocly lint --openapi
|
|
504
|
+
|
|
505
|
+
# JSON output
|
|
506
|
+
api-tools redocly lint --format json
|
|
507
|
+
|
|
508
|
+
# Custom config
|
|
509
|
+
api-tools redocly lint --config custom-redocly.yaml
|
|
370
510
|
```
|
|
371
511
|
|
|
372
512
|
#### `redocly respect`
|
|
@@ -412,12 +552,62 @@ api-tools redocly respect --json-output results.json --verbose
|
|
|
412
552
|
api-tools redocly respect -- --max-steps 100 --severity '{"STATUS_CODE_CHECK":"warn"}'
|
|
413
553
|
```
|
|
414
554
|
|
|
415
|
-
|
|
555
|
+
### Spectral Commands
|
|
416
556
|
|
|
417
|
-
|
|
557
|
+
#### `spectral init`
|
|
558
|
+
|
|
559
|
+
Create a default `spectral.yaml` config file.
|
|
418
560
|
|
|
419
561
|
```bash
|
|
420
|
-
api-tools
|
|
562
|
+
api-tools spectral init [--force]
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
#### `spectral lint`
|
|
566
|
+
|
|
567
|
+
Validate and lint OpenAPI, AsyncAPI, and Arazzo documents.
|
|
568
|
+
|
|
569
|
+
**Usage:**
|
|
570
|
+
|
|
571
|
+
```bash
|
|
572
|
+
api-tools spectral lint [input] [options]
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
**Options:**
|
|
576
|
+
|
|
577
|
+
- `[input]` - Document path (default: auto-detect)
|
|
578
|
+
- `--openapi` - Lint only OpenAPI at `openapi/openapi.yaml`
|
|
579
|
+
- `--asyncapi` - Lint only AsyncAPI at `asyncapi/asyncapi.yaml`
|
|
580
|
+
- `--arazzo` - Lint only Arazzo at `arazzo/arazzo.yaml`
|
|
581
|
+
- `--format <format>` - Output format (default: `stylish`)
|
|
582
|
+
- Choices: `json`, `stylish`, `junit`, `html`, `text`, `teamcity`, `pretty`, `github-actions`, `sarif`, `markdown`, `gitlab`
|
|
583
|
+
- `--output <file>` - Write output to file
|
|
584
|
+
- `--ruleset <file>` - Custom ruleset (overrides auto/bundled)
|
|
585
|
+
- `--fail-severity <level>` - Fail threshold (default: `warn`)
|
|
586
|
+
- Choices: `error`, `warn`, `info`, `hint`
|
|
587
|
+
- `--display-only-failures` - Show only failing results
|
|
588
|
+
- `--verbose` - Enable verbose output
|
|
589
|
+
|
|
590
|
+
**Examples:**
|
|
591
|
+
|
|
592
|
+
```bash
|
|
593
|
+
# Auto-detect and lint all specs
|
|
594
|
+
api-tools spectral lint
|
|
595
|
+
|
|
596
|
+
# Lint specific spec types
|
|
597
|
+
api-tools spectral lint --openapi
|
|
598
|
+
api-tools spectral lint --asyncapi --arazzo
|
|
599
|
+
|
|
600
|
+
# Lint specific file
|
|
601
|
+
api-tools spectral lint custom/spec.yaml
|
|
602
|
+
|
|
603
|
+
# JSON output
|
|
604
|
+
api-tools spectral lint --format json --output results.json
|
|
605
|
+
|
|
606
|
+
# Custom ruleset
|
|
607
|
+
api-tools spectral lint --ruleset .spectral.yaml
|
|
608
|
+
|
|
609
|
+
# Passthrough advanced options
|
|
610
|
+
api-tools spectral lint -- --ignore-unknown-format
|
|
421
611
|
```
|
|
422
612
|
|
|
423
613
|
## Default File Locations
|
|
@@ -435,11 +625,16 @@ project/
|
|
|
435
625
|
│ └── auto-generated.arazzo.yaml # Generated starter
|
|
436
626
|
└── dist/
|
|
437
627
|
├── bundle/
|
|
438
|
-
│
|
|
628
|
+
│ ├── openapi.yaml # OpenAPI bundled output
|
|
629
|
+
│ └── asyncapi.yaml # AsyncAPI bundled output
|
|
630
|
+
├── format/
|
|
631
|
+
│ └── asyncapi.json # AsyncAPI format output
|
|
632
|
+
├── generated/ # AsyncAPI template output
|
|
439
633
|
├── join/
|
|
440
634
|
│ └── openapi.yaml # Joined output
|
|
441
635
|
└── docs/
|
|
442
|
-
|
|
636
|
+
├── openapi.html # OpenAPI docs
|
|
637
|
+
└── asyncapi.html # AsyncAPI docs (or asyncapi/ for multi-file)
|
|
443
638
|
```
|
|
444
639
|
|
|
445
640
|
## Configuration Files
|
|
@@ -551,16 +746,21 @@ api-tools spectral lint --openapi
|
|
|
551
746
|
# Lint using Redocly during development
|
|
552
747
|
api-tools redocly lint --openapi
|
|
553
748
|
|
|
749
|
+
# Lint AsyncAPI during development
|
|
750
|
+
api-tools asyncapi lint
|
|
751
|
+
|
|
554
752
|
# Generate docs for local preview
|
|
555
753
|
api-tools redocly build-docs
|
|
754
|
+
api-tools asyncapi build-docs
|
|
556
755
|
```
|
|
557
756
|
|
|
558
757
|
### Pre-commit
|
|
559
758
|
|
|
560
759
|
```bash
|
|
561
760
|
# Fast validation
|
|
562
|
-
api-tools spectral lint
|
|
761
|
+
api-tools spectral lint
|
|
563
762
|
api-tools redocly lint
|
|
763
|
+
api-tools asyncapi lint
|
|
564
764
|
```
|
|
565
765
|
|
|
566
766
|
### CI Pipeline
|
|
@@ -569,8 +769,11 @@ api-tools redocly lint
|
|
|
569
769
|
# Full validation with outputs
|
|
570
770
|
api-tools spectral lint --format github-actions
|
|
571
771
|
api-tools redocly lint --format github-actions
|
|
772
|
+
api-tools asyncapi lint --format github-actions
|
|
572
773
|
api-tools redocly bundle --output dist/openapi.yaml
|
|
774
|
+
api-tools asyncapi bundle --output dist/asyncapi.yaml
|
|
573
775
|
api-tools redocly build-docs --output dist/api-docs.html
|
|
776
|
+
api-tools asyncapi build-docs --output dist/asyncapi-docs.html
|
|
574
777
|
```
|
|
575
778
|
|
|
576
779
|
### API Testing
|
|
@@ -582,6 +785,12 @@ api-tools redocly respect \
|
|
|
582
785
|
--input apiKey=${STAGING_API_KEY} \
|
|
583
786
|
--json-output test-results.json \
|
|
584
787
|
--verbose
|
|
788
|
+
|
|
789
|
+
# Bundle AsyncAPI for deployment
|
|
790
|
+
api-tools asyncapi bundle --output dist/asyncapi-production.yaml
|
|
791
|
+
|
|
792
|
+
# Convert AsyncAPI to JSON for tooling
|
|
793
|
+
api-tools asyncapi format --ext json --output dist/asyncapi.json
|
|
585
794
|
```
|
|
586
795
|
|
|
587
796
|
## Troubleshooting
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"analyticsEnabled":"false"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { runDocs } from "./generate/docs.js";
|
|
3
|
+
export const buildDocsCommand = new Command("build-docs")
|
|
4
|
+
.description("Build HTML documentation from AsyncAPI document (alias for generate docs)")
|
|
5
|
+
.argument("[input]", "AsyncAPI document path (default: asyncapi/asyncapi.yaml)")
|
|
6
|
+
.option("--output <file>", "Output HTML file path (default: dist/docs/asyncapi.html)", "dist/docs/asyncapi.html")
|
|
7
|
+
.option("--params <key=value...>", "Additional params to pass to the template", (val, prev) => {
|
|
8
|
+
return prev.concat([val]);
|
|
9
|
+
}, [])
|
|
10
|
+
.option("--single-file", "Generate a single HTML file instead of multiple files", true)
|
|
11
|
+
.option("--no-single-file", "Generate multiple files (overrides --single-file)", false)
|
|
12
|
+
.allowExcessArguments(true)
|
|
13
|
+
.action(runDocs);
|
|
14
|
+
//# sourceMappingURL=build-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-docs.js","sourceRoot":"","sources":["../../../src/lib/asyncapi/build-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;KACtD,WAAW,CACV,2EAA2E,CAC5E;KACA,QAAQ,CACP,SAAS,EACT,0DAA0D,CAC3D;KAEA,MAAM,CACL,iBAAiB,EACjB,0DAA0D,EAC1D,yBAAyB,CAC1B;KACA,MAAM,CACL,yBAAyB,EACzB,2CAA2C,EAC3C,CAAC,GAAG,EAAE,IAAI,EAAY,EAAE;IACtB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5B,CAAC,EACD,EAAE,CACH;KACA,MAAM,CACL,eAAe,EACf,uDAAuD,EACvD,IAAI,CACL;KACA,MAAM,CACL,kBAAkB,EAClB,mDAAmD,EACnD,KAAK,CACN;KACA,oBAAoB,CAAC,IAAI,CAAC;KAC1B,MAAM,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Command, Option, } from "@commander-js/extra-typings";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { runSingleInputCommand, } from "../cli/helpers.js";
|
|
4
|
+
import { ensureDirectoryExists, isQuiet, resolveStdio, } from "../cli/runtime.js";
|
|
5
|
+
import { run } from "./cli.js";
|
|
6
|
+
const VALID_EXTENSIONS = ["json", "yaml", "yml"];
|
|
7
|
+
export const bundleCommand = new Command("bundle")
|
|
8
|
+
.description("Bundle AsyncAPI documents into a single file")
|
|
9
|
+
.argument("[input]", "Document path (default: asyncapi/asyncapi.yaml)")
|
|
10
|
+
.option("--output <file>", "Output file or directory path (default: dist/bundle/asyncapi.yaml)", "dist/bundle/asyncapi.yaml")
|
|
11
|
+
.addOption(new Option("--ext <extension>", "Output file extension (overrides extension in --output)").choices([...VALID_EXTENSIONS]))
|
|
12
|
+
.option("--x-origin", "Generate x-origin fields that contain historical values of dereferenced $ref's", false)
|
|
13
|
+
.allowExcessArguments(true)
|
|
14
|
+
.action(runBundle);
|
|
15
|
+
function runBundle(input, options, cmd) {
|
|
16
|
+
runSingleInputCommand({
|
|
17
|
+
input,
|
|
18
|
+
options,
|
|
19
|
+
cmd,
|
|
20
|
+
defaultInput: "asyncapi/asyncapi.yaml",
|
|
21
|
+
execute: bundle,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function bundle(params) {
|
|
25
|
+
const { input, options, globals } = params;
|
|
26
|
+
ensureDirectoryExists(options.output);
|
|
27
|
+
const args = buildArgs(params);
|
|
28
|
+
const stdio = resolveStdio(globals);
|
|
29
|
+
const quiet = isQuiet(globals);
|
|
30
|
+
if (!quiet) {
|
|
31
|
+
console.log(`📦 AsyncAPI bundle...`);
|
|
32
|
+
console.log(` Input: ${input}`);
|
|
33
|
+
console.log(` Output: ${options.output}`);
|
|
34
|
+
if (options.ext) {
|
|
35
|
+
console.log(` Extension: ${options.ext}`);
|
|
36
|
+
}
|
|
37
|
+
if (options.xOrigin) {
|
|
38
|
+
console.log(` x-origin: true`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return run(args, stdio);
|
|
42
|
+
}
|
|
43
|
+
function buildArgs(params) {
|
|
44
|
+
const { input, options, passthrough } = params;
|
|
45
|
+
let outputPath = options.output;
|
|
46
|
+
if (options.ext) {
|
|
47
|
+
const parsed = path.parse(options.output);
|
|
48
|
+
outputPath = path.join(parsed.dir, `${parsed.name}.${options.ext}`);
|
|
49
|
+
}
|
|
50
|
+
const args = ["bundle", input, "--output", outputPath];
|
|
51
|
+
if (options.xOrigin) {
|
|
52
|
+
args.push("--xOrigin");
|
|
53
|
+
}
|
|
54
|
+
// forward any passthrough args
|
|
55
|
+
if (passthrough.length > 0) {
|
|
56
|
+
args.push(...passthrough);
|
|
57
|
+
}
|
|
58
|
+
return args;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/lib/asyncapi/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,qBAAqB,GAEtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAU1D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,8CAA8C,CAAC;KAC3D,QAAQ,CAAC,SAAS,EAAE,iDAAiD,CAAC;KAEtE,MAAM,CACL,iBAAiB,EACjB,oEAAoE,EACpE,2BAA2B,CAC5B;KACA,SAAS,CACR,IAAI,MAAM,CACR,mBAAmB,EACnB,yDAAyD,CAC1D,CAAC,OAAO,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CACjC;KACA,MAAM,CACL,YAAY,EACZ,gFAAgF,EAChF,KAAK,CACN;KACA,oBAAoB,CAAC,IAAI,CAAC;KAC1B,MAAM,CAAC,SAAS,CAAC,CAAC;AAErB,SAAS,SAAS,CAChB,KAAyB,EACzB,OAAgB,EAChB,GAAuB;IAEvB,qBAAqB,CAAC;QACpB,KAAK;QACL,OAAO;QACP,GAAG;QACH,YAAY,EAAE,wBAAwB;QACtC,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GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzB,CAAC;IAED,+BAA+B;IAC/B,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { runCli } from "../cli/runtime.js";
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
export const BIN_PATH = "@asyncapi/cli/bin/run_bin";
|
|
7
|
+
export function run(args, stdio) {
|
|
8
|
+
const originalEnv = { ...process.env };
|
|
9
|
+
// use bundled analytics config with telemetry disabled
|
|
10
|
+
process.env.ASYNCAPI_METRICS_CONFIG_PATH = path.join(__dirname, "../../defaults/.asyncapi-analytics");
|
|
11
|
+
// satisfy `node-config` requirement for a config directory to prevent warnings
|
|
12
|
+
process.env.NODE_CONFIG_DIR = path.join(__dirname, "../../defaults/node-config");
|
|
13
|
+
// suppress `node-config` warnings about missing/empty configuration
|
|
14
|
+
process.env.SUPPRESS_NO_CONFIG_WARNING = "true";
|
|
15
|
+
try {
|
|
16
|
+
return runCli(BIN_PATH, args, stdio);
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
process.env = originalEnv;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/lib/asyncapi/cli.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAa,MAAM,mBAAmB,CAAC;AAEtD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AAEpD,MAAM,UAAU,GAAG,CAAC,IAAc,EAAE,KAAgB;IAClD,MAAM,WAAW,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAEvC,uDAAuD;IACvD,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,IAAI,CAAC,IAAI,CAClD,SAAS,EACT,oCAAoC,CACrC,CAAC;IAEF,+EAA+E;IAC/E,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CACrC,SAAS,EACT,4BAA4B,CAC7B,CAAC;IAEF,oEAAoE;IACpE,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,MAAM,CAAC;IAEhD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,GAAG,GAAG,WAAW,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { handleRawPassthrough } from "../cli/helpers.js";
|
|
3
|
+
import { buildDocsCommand } from "./build-docs.js";
|
|
4
|
+
import { bundleCommand } from "./bundle.js";
|
|
5
|
+
import { run } from "./cli.js";
|
|
6
|
+
import { formatCommand } from "./format.js";
|
|
7
|
+
import { generateCommand } from "./generate/command.js";
|
|
8
|
+
import { lintCommand } from "./lint.js";
|
|
9
|
+
export const asyncapiCommand = new Command("asyncapi")
|
|
10
|
+
.description("AsyncAPI-related commands")
|
|
11
|
+
.allowExcessArguments(true)
|
|
12
|
+
.configureHelp({
|
|
13
|
+
sortSubcommands: true,
|
|
14
|
+
sortOptions: true,
|
|
15
|
+
})
|
|
16
|
+
.action((opts, cmd) => {
|
|
17
|
+
handleRawPassthrough(opts, cmd, run);
|
|
18
|
+
})
|
|
19
|
+
.addCommand(lintCommand)
|
|
20
|
+
.addCommand(bundleCommand)
|
|
21
|
+
.addCommand(formatCommand)
|
|
22
|
+
.addCommand(generateCommand)
|
|
23
|
+
.addCommand(buildDocsCommand);
|
|
24
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/lib/asyncapi/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,WAAW,CAAC,2BAA2B,CAAC;KACxC,oBAAoB,CAAC,IAAI,CAAC;KAC1B,aAAa,CAAC;IACb,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,IAAI;CAClB,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACpB,oBAAoB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;KACD,UAAU,CAAC,WAAW,CAAC;KACvB,UAAU,CAAC,aAAa,CAAC;KACzB,UAAU,CAAC,aAAa,CAAC;KACzB,UAAU,CAAC,eAAe,CAAC;KAC3B,UAAU,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Command, Option, } from "@commander-js/extra-typings";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { runSingleInputCommand, } from "../cli/helpers.js";
|
|
4
|
+
import { ensureDirectoryExists, isQuiet, resolveStdio, } from "../cli/runtime.js";
|
|
5
|
+
import { run } from "./cli.js";
|
|
6
|
+
const VALID_EXTENSIONS = ["json", "yaml", "yml"];
|
|
7
|
+
export const formatCommand = new Command("format")
|
|
8
|
+
.description("Convert AsyncAPI documents from any format to yaml, yml or JSON")
|
|
9
|
+
.argument("[input]", "Document path (default: asyncapi/asyncapi.yaml)")
|
|
10
|
+
.option("--output <file>", "Output file path (default: dist/format/asyncapi.json)", "dist/format/asyncapi.json")
|
|
11
|
+
.addOption(new Option("--ext <extension>", "Output file extension (overrides extension in --output)").choices([...VALID_EXTENSIONS]))
|
|
12
|
+
.allowExcessArguments(true)
|
|
13
|
+
.action(runFormat);
|
|
14
|
+
function runFormat(input, options, cmd) {
|
|
15
|
+
runSingleInputCommand({
|
|
16
|
+
input,
|
|
17
|
+
options,
|
|
18
|
+
cmd,
|
|
19
|
+
defaultInput: "asyncapi/asyncapi.yaml",
|
|
20
|
+
execute: format,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function format(params) {
|
|
24
|
+
const { input, options, globals } = params;
|
|
25
|
+
ensureDirectoryExists(options.output);
|
|
26
|
+
const args = buildArgs(params);
|
|
27
|
+
const stdio = resolveStdio(globals);
|
|
28
|
+
const quiet = isQuiet(globals);
|
|
29
|
+
if (!quiet) {
|
|
30
|
+
console.log(`📝 AsyncAPI format...`);
|
|
31
|
+
console.log(` Input: ${input}`);
|
|
32
|
+
console.log(` Output: ${getOutputPath(options)}`);
|
|
33
|
+
if (options.ext) {
|
|
34
|
+
console.log(` Extension: ${options.ext}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return run(args, stdio);
|
|
38
|
+
}
|
|
39
|
+
function buildArgs(params) {
|
|
40
|
+
const { input, options, passthrough } = params;
|
|
41
|
+
const args = ["format", input];
|
|
42
|
+
args.push("--output", getOutputPath(options));
|
|
43
|
+
if (options.ext) {
|
|
44
|
+
args.push("--format", options.ext);
|
|
45
|
+
}
|
|
46
|
+
// forward any passthrough args
|
|
47
|
+
if (passthrough.length > 0) {
|
|
48
|
+
args.push(...passthrough);
|
|
49
|
+
}
|
|
50
|
+
return args;
|
|
51
|
+
}
|
|
52
|
+
function getOutputPath(options) {
|
|
53
|
+
if (options.ext) {
|
|
54
|
+
const parsed = path.parse(options.output);
|
|
55
|
+
return path.join(parsed.dir, `${parsed.name}.${options.ext}`);
|
|
56
|
+
}
|
|
57
|
+
return options.output;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/lib/asyncapi/format.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,qBAAqB,GAEtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAA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BAAiB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,SAAS,CAAC,MAAyC;IAC1D,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAE/C,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE/B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9C,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,+BAA+B;IAC/B,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,OAAgB;IACrC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { docsCommand } from "./docs.js";
|
|
3
|
+
import { fromTemplateCommand } from "./from-template.js";
|
|
4
|
+
export const generateCommand = new Command("generate")
|
|
5
|
+
.description("Generate code or documentation from AsyncAPI documents")
|
|
6
|
+
.addCommand(fromTemplateCommand)
|
|
7
|
+
.addCommand(docsCommand);
|
|
8
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/lib/asyncapi/generate/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,WAAW,CAAC,wDAAwD,CAAC;KACrE,UAAU,CAAC,mBAAmB,CAAC;KAC/B,UAAU,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { runSingleInputCommand, } from "../../cli/helpers.js";
|
|
4
|
+
import { isQuiet } from "../../cli/runtime.js";
|
|
5
|
+
import * as FromTemplateCommand from "./from-template.js";
|
|
6
|
+
export const docsCommand = new Command("docs")
|
|
7
|
+
.description("Generate HTML documentation from AsyncAPI document (convenience wrapper around from-template with HTML template)")
|
|
8
|
+
.argument("[input]", "AsyncAPI document path (default: asyncapi/asyncapi.yaml)")
|
|
9
|
+
.option("--output <file>", "Output HTML file path (default: dist/docs/asyncapi.html)", "dist/docs/asyncapi.html")
|
|
10
|
+
.option("--params <key=value...>", "Additional params to pass to the template", (val, prev) => {
|
|
11
|
+
return prev.concat([val]);
|
|
12
|
+
}, [])
|
|
13
|
+
.option("--single-file", "Generate a single HTML file instead of multiple files", true)
|
|
14
|
+
.option("--no-single-file", "Generate multiple files (overrides --single-file)", false)
|
|
15
|
+
.allowExcessArguments(true)
|
|
16
|
+
.action(runDocs);
|
|
17
|
+
export function runDocs(input, options, cmd) {
|
|
18
|
+
runSingleInputCommand({
|
|
19
|
+
input,
|
|
20
|
+
options,
|
|
21
|
+
cmd,
|
|
22
|
+
defaultInput: "asyncapi/asyncapi.yaml",
|
|
23
|
+
execute: docs,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function docs(params) {
|
|
27
|
+
const { input, options, globals } = params;
|
|
28
|
+
const args = buildArgs(params);
|
|
29
|
+
const quiet = isQuiet(globals);
|
|
30
|
+
if (!quiet) {
|
|
31
|
+
console.log(`📚 AsyncAPI generate docs...`);
|
|
32
|
+
console.log(` Input: ${input}`);
|
|
33
|
+
console.log(` Output: ${options.singleFile ? options.output : args.options.output}`);
|
|
34
|
+
if (args.options.params.length > 0) {
|
|
35
|
+
console.log(` Params: ${args.options.params.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
if (!options.singleFile) {
|
|
38
|
+
console.log(` Single file: false`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
globals.quiet = true; // prevent double logging since we're calling a command internally
|
|
42
|
+
return FromTemplateCommand.fromTemplate(args);
|
|
43
|
+
}
|
|
44
|
+
function buildArgs(params) {
|
|
45
|
+
const { options } = params;
|
|
46
|
+
const parsed = path.parse(options.output);
|
|
47
|
+
let outputDir = parsed.dir || ".";
|
|
48
|
+
const outputFilename = parsed.base;
|
|
49
|
+
const templateParams = [];
|
|
50
|
+
if (options.singleFile) {
|
|
51
|
+
templateParams.push("singleFile=true");
|
|
52
|
+
templateParams.push(`outFilename=${outputFilename}`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
outputDir = path.join(outputDir, "asyncapi");
|
|
56
|
+
}
|
|
57
|
+
if (options.params.length > 0) {
|
|
58
|
+
templateParams.push(...options.params);
|
|
59
|
+
}
|
|
60
|
+
const args = {
|
|
61
|
+
...params,
|
|
62
|
+
options: {
|
|
63
|
+
template: "@asyncapi/html-template@latest",
|
|
64
|
+
output: outputDir,
|
|
65
|
+
params: templateParams,
|
|
66
|
+
forceWrite: true,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
return args;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../../src/lib/asyncapi/generate/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,MAAM,6BAA6B,CAAC;AAC1E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,KAAK,mBAAmB,MAAM,oBAAoB,CAAC;AAQ1D,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CACV,kHAAkH,CACnH;KACA,QAAQ,CACP,SAAS,EACT,0DAA0D,CAC3D;KAEA,MAAM,CACL,iBAAiB,EACjB,0DAA0D,EAC1D,yBAAyB,CAC1B;KACA,MAAM,CACL,yBAAyB,EACzB,2CAA2C,EAC3C,CAAC,GAAG,EAAE,IAAI,EAAY,EAAE;IACtB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5B,CAAC,EACD,EAAE,CACH;KACA,MAAM,CACL,eAAe,EACf,uDAAuD,EACvD,IAAI,CACL;KACA,MAAM,CACL,kBAAkB,EAClB,mDAAmD,EACnD,KAAK,CACN;KACA,oBAAoB,CAAC,IAAI,CAAC;KAC1B,MAAM,CAAC,OAAO,CAAC,CAAC;AAEnB,MAAM,UAAU,OAAO,CACrB,KAAyB,EACzB,OAAgB,EAChB,GAAuB;IAEvB,qBAAqB,CAAC;QACpB,KAAK;QACL,OAAO;QACP,GAAG;QACH,YAAY,EAAE,wBAAwB;QACtC,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,IAAI,CAAC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,GAAa,EAAE,CAAC;IACpC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACvC,cAAc,CAAC,IAAI,CAAC,eAAe,cAAc,EAAE,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,cAAc,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,IAAI,GAA0D;QAClE,GAAG,MAAM;QACT,OAAO,EAAE;YACP,QAAQ,EAAE,gCAAgC;YAC1C,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,cAAc;YACtB,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { runSingleInputCommand, } from "../../cli/helpers.js";
|
|
3
|
+
import { isQuiet, resolveStdio } from "../../cli/runtime.js";
|
|
4
|
+
import { run } from "../cli.js";
|
|
5
|
+
export const fromTemplateCommand = new Command("from-template")
|
|
6
|
+
.description("Generates code or documentation from AsyncAPI documents using a template")
|
|
7
|
+
.argument("<template>", "Template name or URL (e.g., @asyncapi/html-template or https://github.com/asyncapi/html-template)")
|
|
8
|
+
.argument("[input]", "Document path (default: asyncapi/asyncapi.yaml)")
|
|
9
|
+
.option("--output <directory>", "Output directory path (default: dist/generated/)", "dist/generated/")
|
|
10
|
+
.option("--params <key=value...>", "Additional params to pass to the template", (val, prev) => {
|
|
11
|
+
return prev.concat([val]);
|
|
12
|
+
}, [])
|
|
13
|
+
.option("--force-write", "Overwrite existing files", false)
|
|
14
|
+
.allowExcessArguments(true)
|
|
15
|
+
.action(runFromTemplate);
|
|
16
|
+
function runFromTemplate(template, input, options, cmd) {
|
|
17
|
+
runSingleInputCommand({
|
|
18
|
+
input,
|
|
19
|
+
options: { ...options, template },
|
|
20
|
+
cmd,
|
|
21
|
+
defaultInput: "asyncapi/asyncapi.yaml",
|
|
22
|
+
execute: fromTemplate,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function fromTemplate(params) {
|
|
26
|
+
const { input, options, globals } = params;
|
|
27
|
+
const args = buildArgs(params);
|
|
28
|
+
const stdio = resolveStdio(globals);
|
|
29
|
+
const quiet = isQuiet(globals);
|
|
30
|
+
// prevent using passthrough args without input file
|
|
31
|
+
// commander gets confused since we have two args, causing commander to think
|
|
32
|
+
// the passthrough args are the input file
|
|
33
|
+
if (process.argv.indexOf("--") > 0 && input.includes("--")) {
|
|
34
|
+
console.error(`
|
|
35
|
+
❌ Error: Cannot use passthrough arguments without specifying an input file
|
|
36
|
+
|
|
37
|
+
Please provide an input file when using passthrough arguments.
|
|
38
|
+
`.trim());
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
if (!quiet) {
|
|
42
|
+
console.log(`🔄 AsyncAPI generate fromTemplate...`);
|
|
43
|
+
console.log(` Template: ${options.template}`);
|
|
44
|
+
console.log(` Input: ${input}`);
|
|
45
|
+
console.log(` Output: ${options.output}`);
|
|
46
|
+
if (options.params.length > 0) {
|
|
47
|
+
console.log(` Params: ${options.params.join(", ")}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return run(args, stdio);
|
|
51
|
+
}
|
|
52
|
+
function buildArgs(params) {
|
|
53
|
+
const { input, options, passthrough } = params;
|
|
54
|
+
const args = [
|
|
55
|
+
"generate",
|
|
56
|
+
"fromTemplate",
|
|
57
|
+
input,
|
|
58
|
+
options.template,
|
|
59
|
+
"--output",
|
|
60
|
+
options.output,
|
|
61
|
+
"--install",
|
|
62
|
+
"--no-interactive",
|
|
63
|
+
];
|
|
64
|
+
if (options.forceWrite) {
|
|
65
|
+
args.push("--force-write");
|
|
66
|
+
}
|
|
67
|
+
if (options.params.length > 0) {
|
|
68
|
+
args.push("--param", ...options.params);
|
|
69
|
+
}
|
|
70
|
+
// forward any passthrough args
|
|
71
|
+
if (passthrough.length > 0) {
|
|
72
|
+
args.push(...passthrough);
|
|
73
|
+
}
|
|
74
|
+
return args;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=from-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-template.js","sourceRoot":"","sources":["../../../../src/lib/asyncapi/generate/from-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EACL,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAYhC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;KAC5D,WAAW,CACV,0EAA0E,CAC3E;KACA,QAAQ,CACP,YAAY,EACZ,mGAAmG,CACpG;KACA,QAAQ,CAAC,SAAS,EAAE,iDAAiD,CAAC;KAEtE,MAAM,CACL,sBAAsB,EACtB,kDAAkD,EAClD,iBAAiB,CAClB;KACA,MAAM,CACL,yBAAyB,EACzB,2CAA2C,EAC3C,CAAC,GAAG,EAAE,IAAI,EAAY,EAAE;IACtB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5B,CAAC,EACD,EAAE,CACH;KACA,MAAM,CAAC,eAAe,EAAE,0BAA0B,EAAE,KAAK,CAAC;KAC1D,oBAAoB,CAAC,IAAI,CAAC;KAC1B,MAAM,CAAC,eAAe,CAAC,CAAC;AAE3B,SAAS,eAAe,CACtB,QAAgB,EAChB,KAAyB,EACzB,O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AC;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,SAAS,CAAC,MAAyC;IAC1D,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAE/C,MAAM,IAAI,GAAG;QACX,UAAU;QACV,cAAc;QACd,KAAK;QACL,OAAO,CAAC,QAAQ;QAChB,UAAU;QACV,OAAO,CAAC,MAAM;QACd,WAAW;QACX,kBAAkB;KACnB,CAAC;IAEF,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED,+BAA+B;IAC/B,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Command, Option, } from "@commander-js/extra-typings";
|
|
2
|
+
import { runSingleInputCommand, } from "../cli/helpers.js";
|
|
3
|
+
import { isQuiet, resolveStdio } from "../cli/runtime.js";
|
|
4
|
+
import { run } from "./cli.js";
|
|
5
|
+
const VALID_OUTPUT_FORMATS = [
|
|
6
|
+
"json",
|
|
7
|
+
"stylish",
|
|
8
|
+
"junit",
|
|
9
|
+
"html",
|
|
10
|
+
"teamcity",
|
|
11
|
+
"pretty",
|
|
12
|
+
"github-actions",
|
|
13
|
+
"sarif",
|
|
14
|
+
"code-climate",
|
|
15
|
+
"gitlab",
|
|
16
|
+
"markdown",
|
|
17
|
+
];
|
|
18
|
+
const VALID_FAIL_SEVERITIES = ["error", "warn", "info", "hint"];
|
|
19
|
+
export const lintCommand = new Command("lint")
|
|
20
|
+
.description("Validate and lint AsyncAPI documents")
|
|
21
|
+
.argument("[input]", "Document path (default: asyncapi/asyncapi.yaml)")
|
|
22
|
+
.addOption(new Option("--format <format>", "Output format")
|
|
23
|
+
.choices([...VALID_OUTPUT_FORMATS])
|
|
24
|
+
.default("stylish"))
|
|
25
|
+
.option("--output <file>", "Write output to a file")
|
|
26
|
+
.addOption(new Option("--fail-severity <level>", "Fail severity threshold")
|
|
27
|
+
.choices([...VALID_FAIL_SEVERITIES])
|
|
28
|
+
.default("warn"))
|
|
29
|
+
.allowExcessArguments(true)
|
|
30
|
+
.action(runLint);
|
|
31
|
+
function runLint(input, options, cmd) {
|
|
32
|
+
runSingleInputCommand({
|
|
33
|
+
input,
|
|
34
|
+
options,
|
|
35
|
+
cmd,
|
|
36
|
+
defaultInput: "asyncapi/asyncapi.yaml",
|
|
37
|
+
execute: lint,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function lint(params) {
|
|
41
|
+
const { input, options, globals } = params;
|
|
42
|
+
const args = buildArgs(params);
|
|
43
|
+
const stdio = resolveStdio(globals);
|
|
44
|
+
const quiet = isQuiet(globals);
|
|
45
|
+
if (!quiet) {
|
|
46
|
+
console.log(`🔍 AsyncAPI lint...`);
|
|
47
|
+
console.log(` Input: ${input}`);
|
|
48
|
+
console.log(` Format: ${options.format}`);
|
|
49
|
+
if (options.output) {
|
|
50
|
+
console.log(` Output: ${options.output}`);
|
|
51
|
+
}
|
|
52
|
+
console.log(` Fail severity: ${options.failSeverity}`);
|
|
53
|
+
}
|
|
54
|
+
return run(args, stdio);
|
|
55
|
+
}
|
|
56
|
+
function buildArgs(params) {
|
|
57
|
+
const { input, options, passthrough } = params;
|
|
58
|
+
const args = [
|
|
59
|
+
"validate",
|
|
60
|
+
input,
|
|
61
|
+
"--diagnostics-format",
|
|
62
|
+
options.format,
|
|
63
|
+
"--fail-severity",
|
|
64
|
+
options.failSeverity,
|
|
65
|
+
];
|
|
66
|
+
if (options.output) {
|
|
67
|
+
args.push("--save-output", options.output);
|
|
68
|
+
}
|
|
69
|
+
// forward any passthrough args
|
|
70
|
+
if (passthrough.length > 0) {
|
|
71
|
+
args.push(...passthrough);
|
|
72
|
+
}
|
|
73
|
+
return args;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=lint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../src/lib/asyncapi/lint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,GAEtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,oBAAoB,GAAG;IAC3B,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;IACN,UAAU;IACV,QAAQ;IACR,gBAAgB;IAChB,OAAO;IACP,cAAc;IACd,QAAQ;IACR,UAAU;CACF,CAAC;AAEX,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAWzE,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,sCAAsC,CAAC;KACnD,QAAQ,CAAC,SAAS,EAAE,iDAAiD,CAAC;KAEtE,SAAS,CACR,IAAI,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC;KAC7C,OAAO,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC;KAClC,OAAO,CAAC,SAAgC,CAAC,CAC7C;KACA,MAAM,CAAC,iBAAiB,EAAE,wBAAwB,CAAC;KACnD,SAAS,CACR,IAAI,MAAM,CAAC,yBAA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,GAAG,MAAM,CAAC;IAE/C,MAAM,IAAI,GAAG;QACX,UAAU;QACV,KAAK;QACL,sBAAsB;QACtB,OAAO,CAAC,MAAM;QACd,iBAAiB;QACjB,OAAO,CAAC,YAAY;KACrB,CAAC;IAEF,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,+BAA+B;IAC/B,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/lib/cli/program.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { asyncapiCommand } from "../asyncapi/command.js";
|
|
2
3
|
import { redoclyCommand } from "../redocly/command.js";
|
|
3
4
|
import { spectralCommand } from "../spectral/command.js";
|
|
4
5
|
export function buildProgram() {
|
|
@@ -18,6 +19,7 @@ export function buildProgram() {
|
|
|
18
19
|
process.chdir(opts.cwd);
|
|
19
20
|
})
|
|
20
21
|
.addCommand(spectralCommand)
|
|
21
|
-
.addCommand(redoclyCommand)
|
|
22
|
+
.addCommand(redoclyCommand)
|
|
23
|
+
.addCommand(asyncapiCommand);
|
|
22
24
|
}
|
|
23
25
|
//# sourceMappingURL=program.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../../src/lib/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAQzD,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,OAA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AAE,CAAC,WAAW,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC,CAAC;SACD,UAAU,CAAC,eAAe,CAAC;SAC3B,UAAU,CAAC,cAAc,CAAC;SAC1B,UAAU,CAAC,eAAe,CAAC,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymbly/api-tools",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.1",
|
|
5
5
|
"description": "Unified, opinionated CLI wrapper for API specification tooling.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|
|
@@ -46,9 +46,10 @@
|
|
|
46
46
|
"lint:eslint:check": "eslint .",
|
|
47
47
|
"clean": "npm run clean:dist",
|
|
48
48
|
"clean:dist": "rm -rf ./dist",
|
|
49
|
-
"copy:defaults": "
|
|
49
|
+
"copy:defaults": "mkdir -p dist/defaults && cp -a defaults/. dist/defaults/"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
+
"@asyncapi/cli": "6.0.0",
|
|
52
53
|
"@commander-js/extra-typings": "14.0.0",
|
|
53
54
|
"@redocly/cli": "2.15.0",
|
|
54
55
|
"@stoplight/spectral-cli": "6.15.0"
|
|
@@ -57,7 +58,6 @@
|
|
|
57
58
|
"@eslint/js": "9.39.2",
|
|
58
59
|
"@types/node": "24.10.9",
|
|
59
60
|
"@vitest/ui": "4.0.18",
|
|
60
|
-
"copyfiles": "2.4.1",
|
|
61
61
|
"eslint": "9.39.2",
|
|
62
62
|
"markdownlint-cli2": "0.20.0",
|
|
63
63
|
"prettier": "3.8.1",
|