@redocly/cli 1.30.0 → 1.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/CHANGELOG.md +12 -1
- package/README.md +36 -16
- package/lib/index.js +89 -0
- package/lib/types.d.ts +2 -1
- package/lib/utils/miscellaneous.js +5 -5
- package/package.json +6 -4
- package/src/index.ts +101 -1
- package/src/types.ts +4 -1
- package/src/utils/miscellaneous.ts +3 -4
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @redocly/cli
|
|
2
2
|
|
|
3
|
+
## 1.31.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added the `generate-arazzo` command to scaffold Arazzo description templates out of OpenAPI descriptions.
|
|
8
|
+
- Added the `respect` command to test APIs against Arazzo description files.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated @redocly/openapi-core to v1.31.0.
|
|
13
|
+
|
|
3
14
|
## 1.30.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -237,7 +248,7 @@
|
|
|
237
248
|
|
|
238
249
|
### Minor Changes
|
|
239
250
|
|
|
240
|
-
- Added
|
|
251
|
+
- Added Respect and Arazzo rules: `no-criteria-xpath`, `no-actions-type-end`, `criteria-unique`.
|
|
241
252
|
|
|
242
253
|
### Patch Changes
|
|
243
254
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Redocly CLI
|
|
2
2
|
|
|
3
|
-
[@Redocly](https://redocly.com) CLI is your all-in-one OpenAPI utility.
|
|
3
|
+
[@Redocly](https://redocly.com) CLI is your all-in-one OpenAPI utility.
|
|
4
|
+
It builds, manages, improves, and quality-checks your OpenAPI descriptions, all of which comes in handy for various phases of the API Lifecycle.
|
|
5
|
+
Create your own rulesets to make API governance easy, publish beautiful API reference documentation, and more.
|
|
6
|
+
Supports OpenAPI 3.1, 3.0 and OpenAPI 2.0 (legacy Swagger), AsyncAPI 3.0 and 2.6, Arazzo 1.0.
|
|
4
7
|
|
|
5
8
|

|
|
6
9
|

|
|
@@ -32,9 +35,8 @@ The minimum required versions of Node.js and NPM are 18.17.0 and 10.8.2 respecti
|
|
|
32
35
|
|
|
33
36
|
### Docker
|
|
34
37
|
|
|
35
|
-
To give the Docker container access to the OpenAPI description files, you need to
|
|
36
|
-
|
|
37
|
-
in the current working directory, you need the following command:
|
|
38
|
+
To give the Docker container access to the OpenAPI description files, you need to mount the containing directory as a volume.
|
|
39
|
+
Assuming the API description is rooted in the current working directory, you need the following command:
|
|
38
40
|
|
|
39
41
|
```sh
|
|
40
42
|
docker run --rm -v $PWD:/spec redocly/cli lint path-to-root-file.yaml
|
|
@@ -51,25 +53,36 @@ docker run --rm -v $PWD:/spec redocly/cli lint path-to-root-file.yaml
|
|
|
51
53
|
|
|
52
54
|
### Generate API reference documentation
|
|
53
55
|
|
|
54
|
-
Redocly CLI is a great way to render API reference documentation.
|
|
56
|
+
Redocly CLI is a great way to render API reference documentation.
|
|
57
|
+
It uses open source [Redoc](https://github.com/redocly/redoc) to build your documentation.
|
|
58
|
+
Use a command like this:
|
|
55
59
|
|
|
56
60
|
```sh
|
|
57
61
|
redocly build-docs openapi.yaml
|
|
58
62
|
```
|
|
59
63
|
|
|
60
|
-
Your API reference docs are in `redoc-static.html` by default.
|
|
64
|
+
Your API reference docs are in `redoc-static.html` by default.
|
|
65
|
+
You can customize this in many ways.
|
|
66
|
+
[Read the main docs](https://redocly.com/docs/cli/commands/build-docs) for more information.
|
|
61
67
|
|
|
62
|
-
> :bulb: Redocly also has [hosted API reference docs](https://redocly.com/docs/api-registry/guides/api-registry-quickstart/), a (commercial) alternative to Redoc.
|
|
68
|
+
> :bulb: Redocly also has [hosted API reference docs](https://redocly.com/docs/api-registry/guides/api-registry-quickstart/), a (commercial) alternative to Redoc.
|
|
69
|
+
> Both Redoc and Redocly API reference docs can be worked on locally using the `preview-docs` command.
|
|
63
70
|
|
|
64
71
|
### Bundle multiple OpenAPI documents
|
|
65
72
|
|
|
66
|
-
Having one massive OpenAPI description can be annoying, so most people split them up into multiple documents via `$ref`, only to later find out some tools don't support `$ref` or don't support multiple documents.
|
|
73
|
+
Having one massive OpenAPI description can be annoying, so most people split them up into multiple documents via `$ref`, only to later find out some tools don't support `$ref` or don't support multiple documents.
|
|
74
|
+
Redocly CLI to the rescue! It has a `bundle` command you can use to recombine all of those documents back into one single document.
|
|
75
|
+
The bundled output that Redocly CLI provides is clean, tidy, and looks like a human made it.
|
|
67
76
|
|
|
68
77
|
### Automate API guidelines with Linting
|
|
69
78
|
|
|
70
|
-
Check that your API matches the expected API guidelines by using the `lint` command.
|
|
79
|
+
Check that your API matches the expected API guidelines by using the `lint` command.
|
|
80
|
+
API guidelines are an important piece of API governance. They help to keep APIs consistent by enforcing the same standards and naming conventions, and they can also guide API teams through potential security hazards and other pitfalls.
|
|
81
|
+
Automating API guidelines means you can keep APIs consistent and secure throughout their lifecycle.
|
|
82
|
+
Even better, you can shape the design of the API before it even exists by combining API linting with a design-first API workflow.
|
|
71
83
|
|
|
72
|
-
Our API linter is designed for speed on even large documents, and it's easy to run locally, in CI, or anywhere you need it.
|
|
84
|
+
Our API linter is designed for speed on even large documents, and it's easy to run locally, in CI, or anywhere you need it.
|
|
85
|
+
It's also designed for humans, with meaningful error messages to help you get your API right every time.
|
|
73
86
|
|
|
74
87
|
Try it like this:
|
|
75
88
|
|
|
@@ -77,9 +90,12 @@ Try it like this:
|
|
|
77
90
|
redocly lint openapi.yaml
|
|
78
91
|
```
|
|
79
92
|
|
|
80
|
-
**Configure the rules** as you wish.
|
|
93
|
+
**Configure the rules** as you wish.
|
|
94
|
+
Other API Linters use complicated identifiers like JSONPath, but Redocly makes life easy with simple expressions that understand the OpenAPI structure.
|
|
95
|
+
You can either use the [built-in rules](https://redocly.com/docs/cli/rules) to mix-and-match your ideal API guidelines, or break out the tools to build your own.
|
|
81
96
|
|
|
82
|
-
**Format the output** in whatever way you need.
|
|
97
|
+
**Format the output** in whatever way you need.
|
|
98
|
+
The `stylish` output is as good as it sounds, but if you need JSON or Checkstyle outputs to integrate with other tools, the `lint` command can output those too.
|
|
83
99
|
|
|
84
100
|
**Multiple files supported** so you don't need to bundle your API description to lint it; just point Redocly CLI at the "entry point" (e.g.: `openapi.yaml`) and it handles the rest.
|
|
85
101
|
|
|
@@ -87,7 +103,8 @@ redocly lint openapi.yaml
|
|
|
87
103
|
|
|
88
104
|
### Transform an OpenAPI description
|
|
89
105
|
|
|
90
|
-
If your OpenAPI description isn't everything you hoped it would be, enhance it with the Redocly [decorators](https://redocly.com/docs/cli/decorators) feature.
|
|
106
|
+
If your OpenAPI description isn't everything you hoped it would be, enhance it with the Redocly [decorators](https://redocly.com/docs/cli/decorators) feature.
|
|
107
|
+
This allows you to:
|
|
91
108
|
|
|
92
109
|
- Publish reference docs with a subset of endpoints for public use
|
|
93
110
|
- Improve the docs by adding examples and descriptions
|
|
@@ -95,11 +112,13 @@ If your OpenAPI description isn't everything you hoped it would be, enhance it w
|
|
|
95
112
|
|
|
96
113
|
## Data collection
|
|
97
114
|
|
|
98
|
-
This tool [collects data](./docs/usage-data.md) to help Redocly improve our products and services.
|
|
115
|
+
This tool [collects data](./docs/usage-data.md) to help Redocly improve our products and services.
|
|
116
|
+
You can opt out by setting the `REDOCLY_TELEMETRY` environment variable to `off`.
|
|
99
117
|
|
|
100
118
|
## Update notifications
|
|
101
119
|
|
|
102
|
-
Redocly CLI checks for updates on startup.
|
|
120
|
+
Redocly CLI checks for updates on startup.
|
|
121
|
+
You can disable this by setting the `REDOCLY_SUPPRESS_UPDATE_NOTICE` environment variable to `true`.
|
|
103
122
|
|
|
104
123
|
## More resources
|
|
105
124
|
|
|
@@ -111,4 +130,5 @@ Thanks to [graphql-js](https://github.com/graphql/graphql-js) and [eslint](https
|
|
|
111
130
|
|
|
112
131
|
## Development
|
|
113
132
|
|
|
114
|
-
Contributions are welcome!
|
|
133
|
+
Contributions are welcome!
|
|
134
|
+
All the information you need is in [CONTRIBUTING.md](CONTRIBUTING.md).
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const dotenv = require("dotenv");
|
|
4
6
|
require("./utils/assert-node-version");
|
|
5
7
|
const yargs = require("yargs");
|
|
6
8
|
const colors = require("colorette");
|
|
@@ -21,6 +23,7 @@ const translations_1 = require("./commands/translations");
|
|
|
21
23
|
const eject_1 = require("./commands/eject");
|
|
22
24
|
const constants_1 = require("./commands/preview-project/constants");
|
|
23
25
|
const push_1 = require("./commands/push");
|
|
26
|
+
dotenv.config({ path: path.resolve(process.cwd(), './.env') });
|
|
24
27
|
if (!('replaceAll' in String.prototype)) {
|
|
25
28
|
require('core-js/actual/string/replace-all');
|
|
26
29
|
}
|
|
@@ -725,6 +728,92 @@ yargs
|
|
|
725
728
|
}), (argv) => {
|
|
726
729
|
process.env.REDOCLY_CLI_COMMAND = 'eject';
|
|
727
730
|
(0, wrapper_1.commandWrapper)(eject_1.handleEject)(argv);
|
|
731
|
+
})
|
|
732
|
+
.command('respect [files...]', 'Run Arazzo tests.', (yargs) => {
|
|
733
|
+
return yargs
|
|
734
|
+
.positional('files', {
|
|
735
|
+
describe: 'Test files or glob pattern.',
|
|
736
|
+
type: 'string',
|
|
737
|
+
array: true,
|
|
738
|
+
default: [],
|
|
739
|
+
})
|
|
740
|
+
.env('REDOCLY_CLI_RESPECT')
|
|
741
|
+
.options({
|
|
742
|
+
input: {
|
|
743
|
+
alias: 'i',
|
|
744
|
+
describe: 'Input parameters.',
|
|
745
|
+
type: 'string',
|
|
746
|
+
},
|
|
747
|
+
server: {
|
|
748
|
+
alias: 'S',
|
|
749
|
+
describe: 'Server parameters.',
|
|
750
|
+
type: 'string',
|
|
751
|
+
},
|
|
752
|
+
workflow: {
|
|
753
|
+
alias: 'w',
|
|
754
|
+
describe: 'Workflow name.',
|
|
755
|
+
type: 'string',
|
|
756
|
+
array: true,
|
|
757
|
+
},
|
|
758
|
+
skip: {
|
|
759
|
+
alias: 's',
|
|
760
|
+
describe: 'Workflow to skip.',
|
|
761
|
+
type: 'string',
|
|
762
|
+
array: true,
|
|
763
|
+
},
|
|
764
|
+
verbose: {
|
|
765
|
+
alias: 'v',
|
|
766
|
+
describe: 'Apply verbose mode.',
|
|
767
|
+
type: 'boolean',
|
|
768
|
+
},
|
|
769
|
+
'har-output': {
|
|
770
|
+
describe: 'Har file output name.',
|
|
771
|
+
type: 'string',
|
|
772
|
+
},
|
|
773
|
+
'json-output': {
|
|
774
|
+
describe: 'JSON file output name.',
|
|
775
|
+
type: 'string',
|
|
776
|
+
},
|
|
777
|
+
'client-cert': {
|
|
778
|
+
describe: 'Mutual TLS client certificate.',
|
|
779
|
+
type: 'string',
|
|
780
|
+
},
|
|
781
|
+
'client-key': {
|
|
782
|
+
describe: 'Mutual TLS client key.',
|
|
783
|
+
type: 'string',
|
|
784
|
+
},
|
|
785
|
+
'ca-cert': {
|
|
786
|
+
describe: 'Mutual TLS CA certificate.',
|
|
787
|
+
type: 'string',
|
|
788
|
+
},
|
|
789
|
+
severity: {
|
|
790
|
+
describe: 'Severity of the check.',
|
|
791
|
+
type: 'string',
|
|
792
|
+
},
|
|
793
|
+
});
|
|
794
|
+
}, async (argv) => {
|
|
795
|
+
process.env.REDOCLY_CLI_COMMAND = 'respect';
|
|
796
|
+
const { handleRun } = await Promise.resolve().then(() => require('@redocly/respect-core'));
|
|
797
|
+
(0, wrapper_1.commandWrapper)(handleRun)(argv);
|
|
798
|
+
})
|
|
799
|
+
.command('generate-arazzo <descriptionPath>', 'Auto-generate arazzo description file from an API description.', (yargs) => {
|
|
800
|
+
return yargs
|
|
801
|
+
.positional('descriptionPath', {
|
|
802
|
+
describe: 'Description file path.',
|
|
803
|
+
type: 'string',
|
|
804
|
+
})
|
|
805
|
+
.env('REDOCLY_CLI_RESPECT')
|
|
806
|
+
.options({
|
|
807
|
+
'output-file': {
|
|
808
|
+
alias: 'o',
|
|
809
|
+
describe: 'Output File name.',
|
|
810
|
+
type: 'string',
|
|
811
|
+
},
|
|
812
|
+
});
|
|
813
|
+
}, async (argv) => {
|
|
814
|
+
process.env.REDOCLY_CLI_COMMAND = 'generate-arazzo';
|
|
815
|
+
const { handleGenerate } = await Promise.resolve().then(() => require('@redocly/respect-core'));
|
|
816
|
+
(0, wrapper_1.commandWrapper)(handleGenerate)(argv);
|
|
728
817
|
})
|
|
729
818
|
.completion('completion', 'Generate autocomplete script for `redocly` command.')
|
|
730
819
|
.demandCommand(1)
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BundleOutputFormat, Region, Config, RuleSeverity } from '@redocly/openapi-core';
|
|
2
|
+
import type { RespectOptions, GenerateArazzoFileOptions } from '@redocly/respect-core';
|
|
2
3
|
import type { ArgumentsCamelCase } from 'yargs';
|
|
3
4
|
import type { LintOptions } from './commands/lint';
|
|
4
5
|
import type { BundleOptions } from './commands/bundle';
|
|
@@ -27,7 +28,7 @@ export type Entrypoint = {
|
|
|
27
28
|
export declare const outputExtensions: ReadonlyArray<BundleOutputFormat>;
|
|
28
29
|
export type OutputExtensions = 'json' | 'yaml' | 'yml' | undefined;
|
|
29
30
|
export declare const regionChoices: ReadonlyArray<Region>;
|
|
30
|
-
export type CommandOptions = StatsOptions | SplitOptions | JoinOptions | PushOptions | CMSPushOptions | LintOptions | BundleOptions | LoginOptions | LogoutOptions | PreviewDocsOptions | BuildDocsArgv | PushStatusOptions | PreviewProjectOptions | TranslationsOptions | EjectOptions;
|
|
31
|
+
export type CommandOptions = StatsOptions | SplitOptions | JoinOptions | PushOptions | CMSPushOptions | LintOptions | BundleOptions | LoginOptions | LogoutOptions | PreviewDocsOptions | BuildDocsArgv | PushStatusOptions | PreviewProjectOptions | TranslationsOptions | EjectOptions | RespectOptions | GenerateArazzoFileOptions;
|
|
31
32
|
export type VerifyConfigOptions = {
|
|
32
33
|
config?: string;
|
|
33
34
|
'lint-config'?: RuleSeverity;
|
|
@@ -49,9 +49,7 @@ const reference_docs_config_schema_1 = require("@redocly/config/lib/reference-do
|
|
|
49
49
|
const types_1 = require("../types");
|
|
50
50
|
const update_version_notifier_1 = require("./update-version-notifier");
|
|
51
51
|
const push_1 = require("../commands/push");
|
|
52
|
-
const oauth_client_1 = require("../auth/oauth-client");
|
|
53
52
|
const api_1 = require("../reunite/api");
|
|
54
|
-
const otel_1 = require("../otel");
|
|
55
53
|
async function getFallbackApisOrExit(argsApis, config) {
|
|
56
54
|
const { apis } = config;
|
|
57
55
|
const shouldFallbackToAllDefinitions = !(0, utils_1.isNotEmptyArray)(argsApis) && (0, utils_1.isNotEmptyObject)(apis);
|
|
@@ -443,7 +441,6 @@ function cleanColors(input) {
|
|
|
443
441
|
// eslint-disable-next-line no-control-regex
|
|
444
442
|
return input.replace(/\x1b\[\d+m/g, '');
|
|
445
443
|
}
|
|
446
|
-
otel_1.otelTelemetry.init();
|
|
447
444
|
async function sendTelemetry(argv, exit_code, has_config, spec_version, spec_keyword, spec_full_version) {
|
|
448
445
|
try {
|
|
449
446
|
if (!argv) {
|
|
@@ -452,7 +449,8 @@ async function sendTelemetry(argv, exit_code, has_config, spec_version, spec_key
|
|
|
452
449
|
const { _: [command], $0: _, ...args } = argv;
|
|
453
450
|
const event_time = new Date().toISOString();
|
|
454
451
|
const redoclyClient = new openapi_core_1.RedoclyClient();
|
|
455
|
-
const
|
|
452
|
+
const { RedoclyOAuthClient } = await Promise.resolve().then(() => require('../auth/oauth-client'));
|
|
453
|
+
const oauthClient = new RedoclyOAuthClient('redocly-cli', update_version_notifier_1.version);
|
|
456
454
|
const reuniteUrl = (0, api_1.getReuniteUrl)(argv.residency);
|
|
457
455
|
const logged_in = redoclyClient.hasTokens() || (await oauthClient.isAuthorized(reuniteUrl));
|
|
458
456
|
const data = {
|
|
@@ -474,7 +472,9 @@ async function sendTelemetry(argv, exit_code, has_config, spec_version, spec_key
|
|
|
474
472
|
spec_keyword,
|
|
475
473
|
spec_full_version,
|
|
476
474
|
};
|
|
477
|
-
|
|
475
|
+
const { otelTelemetry } = await Promise.resolve().then(() => require('../otel'));
|
|
476
|
+
otelTelemetry.init();
|
|
477
|
+
otelTelemetry.send(data.command, data);
|
|
478
478
|
}
|
|
479
479
|
catch (err) {
|
|
480
480
|
// Do nothing.
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"redocly": "bin/cli.js",
|
|
8
|
+
"openapi": "bin/cli.js"
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18.17.0",
|
|
@@ -30,17 +30,19 @@
|
|
|
30
30
|
"OpenAPI linter",
|
|
31
31
|
"Swagger linter",
|
|
32
32
|
"AsyncAPI linter",
|
|
33
|
+
"Arazzo linter",
|
|
33
34
|
"oas"
|
|
34
35
|
],
|
|
35
36
|
"contributors": [
|
|
36
37
|
"Roman Hotsiy <roman@redocly.com> (https://redocly.com/)"
|
|
37
38
|
],
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@redocly/openapi-core": "1.
|
|
40
|
+
"@redocly/openapi-core": "1.31.0",
|
|
40
41
|
"abort-controller": "^3.0.0",
|
|
41
42
|
"chokidar": "^3.5.1",
|
|
42
43
|
"colorette": "^1.2.0",
|
|
43
44
|
"core-js": "^3.32.1",
|
|
45
|
+
"dotenv": "^16.4.7",
|
|
44
46
|
"form-data": "^4.0.0",
|
|
45
47
|
"get-port-please": "^3.0.1",
|
|
46
48
|
"glob": "^7.1.6",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as dotenv from 'dotenv';
|
|
3
4
|
import './utils/assert-node-version';
|
|
4
5
|
import * as yargs from 'yargs';
|
|
5
6
|
import * as colors from 'colorette';
|
|
@@ -27,11 +28,14 @@ import { commonPushHandler } from './commands/push';
|
|
|
27
28
|
|
|
28
29
|
import type { Arguments } from 'yargs';
|
|
29
30
|
import type { OutputFormat, RuleSeverity } from '@redocly/openapi-core';
|
|
31
|
+
import type { GenerateArazzoFileOptions, RespectOptions } from '@redocly/respect-core';
|
|
30
32
|
import type { BuildDocsArgv } from './commands/build-docs/types';
|
|
31
33
|
import type { PushStatusOptions } from './reunite/commands/push-status';
|
|
32
34
|
import type { PushArguments } from './types';
|
|
33
35
|
import type { EjectOptions } from './commands/eject';
|
|
34
36
|
|
|
37
|
+
dotenv.config({ path: path.resolve(process.cwd(), './.env') });
|
|
38
|
+
|
|
35
39
|
if (!('replaceAll' in String.prototype)) {
|
|
36
40
|
require('core-js/actual/string/replace-all');
|
|
37
41
|
}
|
|
@@ -863,6 +867,102 @@ yargs
|
|
|
863
867
|
commandWrapper(handleEject)(argv as Arguments<EjectOptions>);
|
|
864
868
|
}
|
|
865
869
|
)
|
|
870
|
+
.command(
|
|
871
|
+
'respect [files...]',
|
|
872
|
+
'Run Arazzo tests.',
|
|
873
|
+
(yargs) => {
|
|
874
|
+
return yargs
|
|
875
|
+
.positional('files', {
|
|
876
|
+
describe: 'Test files or glob pattern.',
|
|
877
|
+
type: 'string',
|
|
878
|
+
array: true,
|
|
879
|
+
default: [],
|
|
880
|
+
})
|
|
881
|
+
.env('REDOCLY_CLI_RESPECT')
|
|
882
|
+
.options({
|
|
883
|
+
input: {
|
|
884
|
+
alias: 'i',
|
|
885
|
+
describe: 'Input parameters.',
|
|
886
|
+
type: 'string',
|
|
887
|
+
},
|
|
888
|
+
server: {
|
|
889
|
+
alias: 'S',
|
|
890
|
+
describe: 'Server parameters.',
|
|
891
|
+
type: 'string',
|
|
892
|
+
},
|
|
893
|
+
workflow: {
|
|
894
|
+
alias: 'w',
|
|
895
|
+
describe: 'Workflow name.',
|
|
896
|
+
type: 'string',
|
|
897
|
+
array: true,
|
|
898
|
+
},
|
|
899
|
+
skip: {
|
|
900
|
+
alias: 's',
|
|
901
|
+
describe: 'Workflow to skip.',
|
|
902
|
+
type: 'string',
|
|
903
|
+
array: true,
|
|
904
|
+
},
|
|
905
|
+
verbose: {
|
|
906
|
+
alias: 'v',
|
|
907
|
+
describe: 'Apply verbose mode.',
|
|
908
|
+
type: 'boolean',
|
|
909
|
+
},
|
|
910
|
+
'har-output': {
|
|
911
|
+
describe: 'Har file output name.',
|
|
912
|
+
type: 'string',
|
|
913
|
+
},
|
|
914
|
+
'json-output': {
|
|
915
|
+
describe: 'JSON file output name.',
|
|
916
|
+
type: 'string',
|
|
917
|
+
},
|
|
918
|
+
'client-cert': {
|
|
919
|
+
describe: 'Mutual TLS client certificate.',
|
|
920
|
+
type: 'string',
|
|
921
|
+
},
|
|
922
|
+
'client-key': {
|
|
923
|
+
describe: 'Mutual TLS client key.',
|
|
924
|
+
type: 'string',
|
|
925
|
+
},
|
|
926
|
+
'ca-cert': {
|
|
927
|
+
describe: 'Mutual TLS CA certificate.',
|
|
928
|
+
type: 'string',
|
|
929
|
+
},
|
|
930
|
+
severity: {
|
|
931
|
+
describe: 'Severity of the check.',
|
|
932
|
+
type: 'string',
|
|
933
|
+
},
|
|
934
|
+
});
|
|
935
|
+
},
|
|
936
|
+
async (argv) => {
|
|
937
|
+
process.env.REDOCLY_CLI_COMMAND = 'respect';
|
|
938
|
+
const { handleRun } = await import('@redocly/respect-core');
|
|
939
|
+
commandWrapper(handleRun)(argv as Arguments<RespectOptions>);
|
|
940
|
+
}
|
|
941
|
+
)
|
|
942
|
+
.command(
|
|
943
|
+
'generate-arazzo <descriptionPath>',
|
|
944
|
+
'Auto-generate arazzo description file from an API description.',
|
|
945
|
+
(yargs) => {
|
|
946
|
+
return yargs
|
|
947
|
+
.positional('descriptionPath', {
|
|
948
|
+
describe: 'Description file path.',
|
|
949
|
+
type: 'string',
|
|
950
|
+
})
|
|
951
|
+
.env('REDOCLY_CLI_RESPECT')
|
|
952
|
+
.options({
|
|
953
|
+
'output-file': {
|
|
954
|
+
alias: 'o',
|
|
955
|
+
describe: 'Output File name.',
|
|
956
|
+
type: 'string',
|
|
957
|
+
},
|
|
958
|
+
});
|
|
959
|
+
},
|
|
960
|
+
async (argv) => {
|
|
961
|
+
process.env.REDOCLY_CLI_COMMAND = 'generate-arazzo';
|
|
962
|
+
const { handleGenerate } = await import('@redocly/respect-core');
|
|
963
|
+
commandWrapper(handleGenerate)(argv as Arguments<GenerateArazzoFileOptions>);
|
|
964
|
+
}
|
|
965
|
+
)
|
|
866
966
|
.completion('completion', 'Generate autocomplete script for `redocly` command.')
|
|
867
967
|
.demandCommand(1)
|
|
868
968
|
.middleware([notifyUpdateCliVersion])
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BundleOutputFormat, Region, Config, RuleSeverity } from '@redocly/openapi-core';
|
|
2
|
+
import type { RespectOptions, GenerateArazzoFileOptions } from '@redocly/respect-core';
|
|
2
3
|
import type { ArgumentsCamelCase } from 'yargs';
|
|
3
4
|
import type { LintOptions } from './commands/lint';
|
|
4
5
|
import type { BundleOptions } from './commands/bundle';
|
|
@@ -43,7 +44,9 @@ export type CommandOptions =
|
|
|
43
44
|
| PushStatusOptions
|
|
44
45
|
| PreviewProjectOptions
|
|
45
46
|
| TranslationsOptions
|
|
46
|
-
| EjectOptions
|
|
47
|
+
| EjectOptions
|
|
48
|
+
| RespectOptions
|
|
49
|
+
| GenerateArazzoFileOptions;
|
|
47
50
|
|
|
48
51
|
export type VerifyConfigOptions = {
|
|
49
52
|
config?: string;
|
|
@@ -29,9 +29,7 @@ import { deprecatedRefDocsSchema } from '@redocly/config/lib/reference-docs-conf
|
|
|
29
29
|
import { outputExtensions } from '../types';
|
|
30
30
|
import { version } from './update-version-notifier';
|
|
31
31
|
import { DESTINATION_REGEX } from '../commands/push';
|
|
32
|
-
import { RedoclyOAuthClient } from '../auth/oauth-client';
|
|
33
32
|
import { getReuniteUrl } from '../reunite/api';
|
|
34
|
-
import { otelTelemetry } from '../otel';
|
|
35
33
|
|
|
36
34
|
import type { Arguments } from 'yargs';
|
|
37
35
|
import type {
|
|
@@ -549,8 +547,6 @@ export function cleanColors(input: string): string {
|
|
|
549
547
|
return input.replace(/\x1b\[\d+m/g, '');
|
|
550
548
|
}
|
|
551
549
|
|
|
552
|
-
otelTelemetry.init();
|
|
553
|
-
|
|
554
550
|
export async function sendTelemetry(
|
|
555
551
|
argv: Arguments | undefined,
|
|
556
552
|
exit_code: ExitCode,
|
|
@@ -570,6 +566,7 @@ export async function sendTelemetry(
|
|
|
570
566
|
} = argv;
|
|
571
567
|
const event_time = new Date().toISOString();
|
|
572
568
|
const redoclyClient = new RedoclyClient();
|
|
569
|
+
const { RedoclyOAuthClient } = await import('../auth/oauth-client');
|
|
573
570
|
const oauthClient = new RedoclyOAuthClient('redocly-cli', version);
|
|
574
571
|
const reuniteUrl = getReuniteUrl(argv.residency as string | undefined);
|
|
575
572
|
const logged_in = redoclyClient.hasTokens() || (await oauthClient.isAuthorized(reuniteUrl));
|
|
@@ -592,6 +589,8 @@ export async function sendTelemetry(
|
|
|
592
589
|
spec_keyword,
|
|
593
590
|
spec_full_version,
|
|
594
591
|
};
|
|
592
|
+
const { otelTelemetry } = await import('../otel');
|
|
593
|
+
otelTelemetry.init();
|
|
595
594
|
otelTelemetry.send(data.command, data);
|
|
596
595
|
} catch (err) {
|
|
597
596
|
// Do nothing.
|