@redocly/cli 1.10.5 → 1.11.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 +20 -0
- package/lib/__tests__/commands/bundle.test.js +3 -32
- package/lib/__tests__/commands/join.test.js +0 -11
- package/lib/commands/bundle.d.ts +1 -4
- package/lib/commands/bundle.js +2 -32
- package/lib/commands/join.d.ts +0 -3
- package/lib/commands/join.js +13 -36
- package/lib/commands/lint.js +3 -1
- package/lib/index.js +73 -26
- package/lib/types.d.ts +5 -1
- package/lib/utils/getCommandNameFromArgs.d.ts +2 -0
- package/lib/utils/getCommandNameFromArgs.js +8 -0
- package/lib/utils/miscellaneous.d.ts +1 -1
- package/lib/utils/miscellaneous.js +4 -1
- package/lib/wrapper.d.ts +1 -1
- package/lib/wrapper.js +3 -1
- package/package.json +2 -2
- package/src/__tests__/commands/bundle.test.ts +4 -37
- package/src/__tests__/commands/join.test.ts +0 -17
- package/src/commands/bundle.ts +3 -53
- package/src/commands/join.ts +13 -49
- package/src/commands/lint.ts +5 -1
- package/src/index.ts +96 -26
- package/src/types.ts +6 -0
- package/src/utils/getCommandNameFromArgs.ts +5 -0
- package/src/utils/miscellaneous.ts +3 -1
- package/src/wrapper.ts +4 -2
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @redocly/cli
|
|
2
2
|
|
|
3
|
+
## 1.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Removed additional operations from the `join` command; use `lint` and/or `bundle` for operations such as `lint` and `decorate`.
|
|
8
|
+
- Removed lint support from the bundle command to support a wider range of use cases. Users should update to [run lint and bundle separately](https://redocly.com/docs/cli/guides/lint-and-bundle/).
|
|
9
|
+
- Added support for a `github-actions` output format for the `lint` command to annotate reported problems on files when used in a GitHub Actions workflow.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fixed [`no-invalid-media-type-examples`](https://redocly.com/docs/cli/rules/no-invalid-media-type-examples/) rule `externalValue` example validation.
|
|
14
|
+
- Updated @redocly/openapi-core to v1.11.0.
|
|
15
|
+
|
|
16
|
+
## 1.10.6
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Added `check-config` command to validate a Redocly configuration file.
|
|
21
|
+
- Updated @redocly/openapi-core to v1.10.6.
|
|
22
|
+
|
|
3
23
|
## 1.10.5
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -28,18 +28,15 @@ describe('bundle', () => {
|
|
|
28
28
|
jest.spyOn(process.stderr, 'write').mockImplementation(() => true);
|
|
29
29
|
});
|
|
30
30
|
afterEach(() => {
|
|
31
|
-
openapi_core_1.lint.mockClear();
|
|
32
31
|
openapi_core_1.bundle.mockClear();
|
|
33
32
|
openapi_core_1.getTotals.mockReset();
|
|
34
33
|
});
|
|
35
|
-
it('bundles definitions
|
|
34
|
+
it('bundles definitions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
35
|
const apis = ['foo.yaml', 'bar.yaml'];
|
|
37
36
|
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
38
37
|
apis,
|
|
39
38
|
ext: 'yaml',
|
|
40
|
-
format: 'codeframe',
|
|
41
39
|
});
|
|
42
|
-
expect(openapi_core_1.lint).toBeCalledTimes(0);
|
|
43
40
|
expect(openapi_core_1.bundle).toBeCalledTimes(apis.length);
|
|
44
41
|
}));
|
|
45
42
|
it('exits with code 0 when bundles definitions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -47,39 +44,20 @@ describe('bundle', () => {
|
|
|
47
44
|
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
48
45
|
apis,
|
|
49
46
|
ext: 'yaml',
|
|
50
|
-
format: 'codeframe',
|
|
51
47
|
});
|
|
52
48
|
yield (exitCb === null || exitCb === void 0 ? void 0 : exitCb());
|
|
53
49
|
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
54
50
|
}));
|
|
55
|
-
it('bundles definitions w/
|
|
56
|
-
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
|
|
57
|
-
openapi_core_1.getTotals.mockReturnValue({
|
|
58
|
-
errors: 0,
|
|
59
|
-
warnings: 0,
|
|
60
|
-
ignored: 0,
|
|
61
|
-
});
|
|
62
|
-
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
63
|
-
apis,
|
|
64
|
-
ext: 'yaml',
|
|
65
|
-
format: 'codeframe',
|
|
66
|
-
lint: true,
|
|
67
|
-
});
|
|
68
|
-
expect(openapi_core_1.lint).toBeCalledTimes(apis.length);
|
|
69
|
-
expect(openapi_core_1.bundle).toBeCalledTimes(apis.length);
|
|
70
|
-
}));
|
|
71
|
-
it('exits with code 0 when bundles definitions w/linting w/o errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
it('exits with code 0 when bundles definitions w/o errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
52
|
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
|
|
73
53
|
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
74
54
|
apis,
|
|
75
55
|
ext: 'yaml',
|
|
76
|
-
format: 'codeframe',
|
|
77
|
-
lint: true,
|
|
78
56
|
});
|
|
79
57
|
yield (exitCb === null || exitCb === void 0 ? void 0 : exitCb());
|
|
80
58
|
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
81
59
|
}));
|
|
82
|
-
it('exits with code 1 when bundles definitions w/
|
|
60
|
+
it('exits with code 1 when bundles definitions w/errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
61
|
const apis = ['foo.yaml'];
|
|
84
62
|
openapi_core_1.getTotals.mockReturnValue({
|
|
85
63
|
errors: 1,
|
|
@@ -89,10 +67,7 @@ describe('bundle', () => {
|
|
|
89
67
|
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
90
68
|
apis,
|
|
91
69
|
ext: 'yaml',
|
|
92
|
-
format: 'codeframe',
|
|
93
|
-
lint: true,
|
|
94
70
|
});
|
|
95
|
-
expect(openapi_core_1.lint).toBeCalledTimes(apis.length);
|
|
96
71
|
yield (exitCb === null || exitCb === void 0 ? void 0 : exitCb());
|
|
97
72
|
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
98
73
|
}));
|
|
@@ -104,8 +79,6 @@ describe('bundle', () => {
|
|
|
104
79
|
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
105
80
|
apis,
|
|
106
81
|
ext: 'json',
|
|
107
|
-
format: 'codeframe',
|
|
108
|
-
lint: false,
|
|
109
82
|
});
|
|
110
83
|
expect(miscellaneous_1.handleError).toHaveBeenCalledTimes(1);
|
|
111
84
|
expect(miscellaneous_1.handleError).toHaveBeenCalledWith(new Error('Invalid definition'), 'invalid.json');
|
|
@@ -120,8 +93,6 @@ describe('bundle', () => {
|
|
|
120
93
|
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
121
94
|
apis,
|
|
122
95
|
ext: 'yaml',
|
|
123
|
-
format: 'codeframe',
|
|
124
|
-
lint: false,
|
|
125
96
|
});
|
|
126
97
|
expect(miscellaneous_1.handleError).toHaveBeenCalledTimes(0);
|
|
127
98
|
}));
|
|
@@ -94,17 +94,6 @@ describe('handleJoin', () => {
|
|
|
94
94
|
expect(config.styleguide.skipDecorators).toHaveBeenCalled();
|
|
95
95
|
expect(config.styleguide.skipPreprocessors).toHaveBeenCalled();
|
|
96
96
|
}));
|
|
97
|
-
it('should not call skipDecorators and skipPreprocessors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
-
openapi_core_1.detectSpec.mockReturnValue('oas3_0');
|
|
99
|
-
yield (0, join_1.handleJoin)({
|
|
100
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
101
|
-
decorate: true,
|
|
102
|
-
preprocess: true,
|
|
103
|
-
}, config_1.ConfigFixture, 'cli-version');
|
|
104
|
-
const config = (0, openapi_core_2.loadConfig)();
|
|
105
|
-
expect(config.styleguide.skipDecorators).not.toHaveBeenCalled();
|
|
106
|
-
expect(config.styleguide.skipPreprocessors).not.toHaveBeenCalled();
|
|
107
|
-
}));
|
|
108
97
|
it('should handle join with prefix-components-with-info-prop and null values', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
98
|
openapi_core_1.detectSpec.mockReturnValue('oas3_0');
|
|
110
99
|
yield (0, join_1.handleJoin)({
|
package/lib/commands/bundle.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { Config
|
|
1
|
+
import { Config } from '@redocly/openapi-core';
|
|
2
2
|
import type { OutputExtensions, Skips } from '../types';
|
|
3
3
|
export type BundleOptions = {
|
|
4
4
|
apis?: string[];
|
|
5
|
-
'max-problems'?: number;
|
|
6
5
|
extends?: string[];
|
|
7
6
|
config?: string;
|
|
8
|
-
format?: OutputFormat;
|
|
9
7
|
output?: string;
|
|
10
8
|
ext: OutputExtensions;
|
|
11
9
|
dereferenced?: boolean;
|
|
12
10
|
force?: boolean;
|
|
13
|
-
lint?: boolean;
|
|
14
11
|
metafile?: string;
|
|
15
12
|
'remove-unused-components'?: boolean;
|
|
16
13
|
'keep-url-references'?: boolean;
|
package/lib/commands/bundle.js
CHANGED
|
@@ -34,44 +34,15 @@ function handleBundle(argv, config, version) {
|
|
|
34
34
|
((_c = (_b = (_a = config.rawConfig) === null || _a === void 0 ? void 0 : _a.styleguide) === null || _b === void 0 ? void 0 : _b.decorators) === null || _c === void 0 ? void 0 : _c.hasOwnProperty('remove-unused-components'));
|
|
35
35
|
const apis = yield (0, miscellaneous_1.getFallbackApisOrExit)(argv.apis, config);
|
|
36
36
|
const totals = { errors: 0, warnings: 0, ignored: 0 };
|
|
37
|
-
const
|
|
38
|
-
const deprecatedOptions = [
|
|
39
|
-
'lint',
|
|
40
|
-
'format',
|
|
41
|
-
'skip-rule',
|
|
42
|
-
'extends',
|
|
43
|
-
'max-problems',
|
|
44
|
-
];
|
|
37
|
+
const deprecatedOptions = [];
|
|
45
38
|
(0, miscellaneous_2.checkForDeprecatedOptions)(argv, deprecatedOptions);
|
|
46
39
|
for (const { path, alias } of apis) {
|
|
47
40
|
try {
|
|
48
41
|
const startedAt = perf_hooks_1.performance.now();
|
|
49
42
|
const resolvedConfig = (0, openapi_core_1.getMergedConfig)(config, alias);
|
|
50
43
|
const { styleguide } = resolvedConfig;
|
|
51
|
-
styleguide.skipRules(argv['skip-rule']);
|
|
52
44
|
styleguide.skipPreprocessors(argv['skip-preprocessor']);
|
|
53
45
|
styleguide.skipDecorators(argv['skip-decorator']);
|
|
54
|
-
if (argv.lint) {
|
|
55
|
-
(0, miscellaneous_1.checkIfRulesetExist)(styleguide.rules);
|
|
56
|
-
if (config.styleguide.recommendedFallback) {
|
|
57
|
-
process.stderr.write(`No configurations were provided -- using built in ${(0, colorette_1.blue)('recommended')} configuration by default.\n\n`);
|
|
58
|
-
}
|
|
59
|
-
const results = yield (0, openapi_core_1.lint)({
|
|
60
|
-
ref: path,
|
|
61
|
-
config: resolvedConfig,
|
|
62
|
-
});
|
|
63
|
-
const fileLintTotals = (0, openapi_core_1.getTotals)(results);
|
|
64
|
-
totals.errors += fileLintTotals.errors;
|
|
65
|
-
totals.warnings += fileLintTotals.warnings;
|
|
66
|
-
totals.ignored += fileLintTotals.ignored;
|
|
67
|
-
(0, openapi_core_1.formatProblems)(results, {
|
|
68
|
-
format: argv.format || 'codeframe',
|
|
69
|
-
totals: fileLintTotals,
|
|
70
|
-
version,
|
|
71
|
-
maxProblems: maxProblems,
|
|
72
|
-
});
|
|
73
|
-
(0, miscellaneous_1.printLintTotals)(fileLintTotals, 2);
|
|
74
|
-
}
|
|
75
46
|
process.stderr.write((0, colorette_1.gray)(`bundling ${path}...\n`));
|
|
76
47
|
const _f = yield (0, openapi_core_1.bundle)({
|
|
77
48
|
config: resolvedConfig,
|
|
@@ -96,8 +67,7 @@ function handleBundle(argv, config, version) {
|
|
|
96
67
|
totals.warnings += fileTotals.warnings;
|
|
97
68
|
totals.ignored += fileTotals.ignored;
|
|
98
69
|
(0, openapi_core_1.formatProblems)(problems, {
|
|
99
|
-
format:
|
|
100
|
-
maxProblems: maxProblems,
|
|
70
|
+
format: 'codeframe',
|
|
101
71
|
totals: fileTotals,
|
|
102
72
|
version,
|
|
103
73
|
});
|
package/lib/commands/join.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import { Config } from '@redocly/openapi-core';
|
|
|
2
2
|
import type { RuleSeverity } from '@redocly/openapi-core';
|
|
3
3
|
export type JoinOptions = {
|
|
4
4
|
apis: string[];
|
|
5
|
-
lint?: boolean;
|
|
6
|
-
decorate?: boolean;
|
|
7
|
-
preprocess?: boolean;
|
|
8
5
|
'prefix-tags-with-info-prop'?: string;
|
|
9
6
|
'prefix-tags-with-filename'?: boolean;
|
|
10
7
|
'prefix-components-with-info-prop'?: string;
|
package/lib/commands/join.js
CHANGED
|
@@ -28,7 +28,6 @@ function handleJoin(argv, config, packageVersion) {
|
|
|
28
28
|
if (argv.apis.length < 2) {
|
|
29
29
|
return (0, miscellaneous_1.exitWithError)(`At least 2 apis should be provided. \n\n`);
|
|
30
30
|
}
|
|
31
|
-
(0, miscellaneous_1.checkForDeprecatedOptions)(argv, ['lint']);
|
|
32
31
|
const fileExtension = (0, miscellaneous_1.getAndValidateFileExtension)(argv.output || argv.apis[0]);
|
|
33
32
|
const { 'prefix-components-with-info-prop': prefixComponentsWithInfoProp, 'prefix-tags-with-filename': prefixTagsWithFilename, 'prefix-tags-with-info-prop': prefixTagsWithInfoProp, 'without-x-tag-groups': withoutXTagGroups, output: specFilename = `openapi.${fileExtension}`, } = argv;
|
|
34
33
|
const usedTagsOptions = [
|
|
@@ -42,22 +41,18 @@ function handleJoin(argv, config, packageVersion) {
|
|
|
42
41
|
const apis = yield (0, miscellaneous_1.getFallbackApisOrExit)(argv.apis, config);
|
|
43
42
|
const externalRefResolver = new openapi_core_1.BaseResolver(config.resolve);
|
|
44
43
|
const documents = yield Promise.all(apis.map(({ path }) => externalRefResolver.resolveDocument(null, path, true)));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
...Object.keys(config.styleguide.preprocessors.oas2),
|
|
58
|
-
]);
|
|
59
|
-
config.styleguide.skipPreprocessors(Array.from(preprocessors));
|
|
60
|
-
}
|
|
44
|
+
const decorators = new Set([
|
|
45
|
+
...Object.keys(config.styleguide.decorators.oas3_0),
|
|
46
|
+
...Object.keys(config.styleguide.decorators.oas3_1),
|
|
47
|
+
...Object.keys(config.styleguide.decorators.oas2),
|
|
48
|
+
]);
|
|
49
|
+
config.styleguide.skipDecorators(Array.from(decorators));
|
|
50
|
+
const preprocessors = new Set([
|
|
51
|
+
...Object.keys(config.styleguide.preprocessors.oas3_0),
|
|
52
|
+
...Object.keys(config.styleguide.preprocessors.oas3_1),
|
|
53
|
+
...Object.keys(config.styleguide.preprocessors.oas2),
|
|
54
|
+
]);
|
|
55
|
+
config.styleguide.skipPreprocessors(Array.from(preprocessors));
|
|
61
56
|
const bundleResults = yield Promise.all(documents.map((document) => (0, openapi_core_1.bundleDocument)({
|
|
62
57
|
document,
|
|
63
58
|
config: config.styleguide,
|
|
@@ -70,7 +65,7 @@ function handleJoin(argv, config, packageVersion) {
|
|
|
70
65
|
if (fileTotals.errors) {
|
|
71
66
|
(0, openapi_core_1.formatProblems)(problems, {
|
|
72
67
|
totals: fileTotals,
|
|
73
|
-
version:
|
|
68
|
+
version: packageVersion,
|
|
74
69
|
});
|
|
75
70
|
(0, miscellaneous_1.exitWithError)(`❌ Errors encountered while bundling ${(0, colorette_1.blue)(document.source.absoluteRef)}: join will not proceed.\n`);
|
|
76
71
|
}
|
|
@@ -91,11 +86,6 @@ function handleJoin(argv, config, packageVersion) {
|
|
|
91
86
|
return (0, miscellaneous_1.exitWithError)(`${e.message}: ${(0, colorette_1.blue)(document.source.absoluteRef)}`);
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
|
-
if (argv.lint) {
|
|
95
|
-
for (const document of documents) {
|
|
96
|
-
yield validateApi(document, config.styleguide, externalRefResolver, packageVersion);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
89
|
const joinedDef = {};
|
|
100
90
|
const potentialConflicts = {
|
|
101
91
|
tags: {},
|
|
@@ -561,19 +551,6 @@ function getInfoPrefix(info, prefixArg, type) {
|
|
|
561
551
|
(0, miscellaneous_1.exitWithError)(`${(0, colorette_1.yellow)(`prefix-${type}-with-info-prop`)} argument value length should not exceed 50 characters. \n\n`);
|
|
562
552
|
return info[prefixArg].replaceAll(/\s/g, '_');
|
|
563
553
|
}
|
|
564
|
-
function validateApi(document, config, externalRefResolver, packageVersion) {
|
|
565
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
566
|
-
try {
|
|
567
|
-
const results = yield (0, openapi_core_1.lintDocument)({ document, config, externalRefResolver });
|
|
568
|
-
const fileTotals = (0, openapi_core_1.getTotals)(results);
|
|
569
|
-
(0, openapi_core_1.formatProblems)(results, { format: 'stylish', totals: fileTotals, version: packageVersion });
|
|
570
|
-
(0, miscellaneous_1.printLintTotals)(fileTotals, 2);
|
|
571
|
-
}
|
|
572
|
-
catch (err) {
|
|
573
|
-
(0, miscellaneous_1.handleError)(err, document.parsed);
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
554
|
function replace$Refs(obj, componentsPrefix) {
|
|
578
555
|
(0, split_1.crawl)(obj, (node) => {
|
|
579
556
|
if (node.$ref && typeof node.$ref === 'string' && (0, split_1.startsWithComponents)(node.$ref)) {
|
package/lib/commands/lint.js
CHANGED
|
@@ -15,6 +15,7 @@ const config_1 = require("@redocly/openapi-core/lib/config");
|
|
|
15
15
|
const miscellaneous_1 = require("../utils/miscellaneous");
|
|
16
16
|
const colorette_1 = require("colorette");
|
|
17
17
|
const perf_hooks_1 = require("perf_hooks");
|
|
18
|
+
const getCommandNameFromArgs_1 = require("../utils/getCommandNameFromArgs");
|
|
18
19
|
function handleLint(argv, config, version) {
|
|
19
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
21
|
const apis = yield (0, miscellaneous_1.getFallbackApisOrExit)(argv.apis, config);
|
|
@@ -103,7 +104,8 @@ function lintConfigCallback(argv, version) {
|
|
|
103
104
|
totals: fileTotals,
|
|
104
105
|
version,
|
|
105
106
|
});
|
|
106
|
-
(0,
|
|
107
|
+
const command = argv ? (0, getCommandNameFromArgs_1.getCommandNameFromArgs)(argv) : undefined;
|
|
108
|
+
(0, miscellaneous_1.printConfigLintTotals)(fileTotals, command);
|
|
107
109
|
if (fileTotals.errors > 0) {
|
|
108
110
|
throw new config_1.ConfigValidationError();
|
|
109
111
|
}
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
require("./utils/assert-node-version");
|
|
14
14
|
const yargs = require("yargs");
|
|
15
|
+
const colors = require("colorette");
|
|
15
16
|
const types_1 = require("./types");
|
|
16
17
|
const openapi_core_1 = require("@redocly/openapi-core");
|
|
17
18
|
const preview_docs_1 = require("./commands/preview-docs");
|
|
@@ -92,9 +93,6 @@ yargs
|
|
|
92
93
|
demandOption: true,
|
|
93
94
|
})
|
|
94
95
|
.option({
|
|
95
|
-
lint: { description: 'Lint descriptions', type: 'boolean', default: false, hidden: true },
|
|
96
|
-
decorate: { description: 'Run decorators', type: 'boolean', default: false },
|
|
97
|
-
preprocess: { description: 'Run preprocessors', type: 'boolean', default: false },
|
|
98
96
|
'prefix-tags-with-info-prop': {
|
|
99
97
|
description: 'Prefix tags with property value from info object.',
|
|
100
98
|
requiresArg: true,
|
|
@@ -129,7 +127,34 @@ yargs
|
|
|
129
127
|
choices: ['warn', 'error', 'off'],
|
|
130
128
|
default: 'warn',
|
|
131
129
|
},
|
|
130
|
+
lint: {
|
|
131
|
+
hidden: true,
|
|
132
|
+
deprecated: true,
|
|
133
|
+
},
|
|
134
|
+
decorate: {
|
|
135
|
+
hidden: true,
|
|
136
|
+
deprecated: true,
|
|
137
|
+
},
|
|
138
|
+
preprocess: {
|
|
139
|
+
hidden: true,
|
|
140
|
+
deprecated: true,
|
|
141
|
+
},
|
|
132
142
|
}), (argv) => {
|
|
143
|
+
const DEPRECATED_OPTIONS = ['lint', 'preprocess', 'decorate'];
|
|
144
|
+
const DECORATORS_DOCUMENTATION_LINK = 'https://redocly.com/docs/cli/decorators/#decorators';
|
|
145
|
+
const JOIN_COMMAND_DOCUMENTATION_LINK = 'https://redocly.com/docs/cli/commands/join/#join';
|
|
146
|
+
DEPRECATED_OPTIONS.forEach((option) => {
|
|
147
|
+
if (argv[option]) {
|
|
148
|
+
process.stdout.write(`${colors.red(`Option --${option} is no longer supported. Please review join command documentation ${JOIN_COMMAND_DOCUMENTATION_LINK}.`)}`);
|
|
149
|
+
process.stdout.write('\n\n');
|
|
150
|
+
if (['preprocess', 'decorate'].includes(option)) {
|
|
151
|
+
process.stdout.write(`${colors.red(`If you are looking for decorators, please review the decorators documentation ${DECORATORS_DOCUMENTATION_LINK}.`)}`);
|
|
152
|
+
process.stdout.write('\n\n');
|
|
153
|
+
}
|
|
154
|
+
yargs.showHelp();
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
133
158
|
process.env.REDOCLY_CLI_COMMAND = 'join';
|
|
134
159
|
(0, wrapper_1.commandWrapper)(join_1.handleJoin)(argv);
|
|
135
160
|
})
|
|
@@ -328,6 +353,7 @@ yargs
|
|
|
328
353
|
'checkstyle',
|
|
329
354
|
'codeclimate',
|
|
330
355
|
'summary',
|
|
356
|
+
'github-actions',
|
|
331
357
|
],
|
|
332
358
|
default: 'codeframe',
|
|
333
359
|
},
|
|
@@ -377,28 +403,11 @@ yargs
|
|
|
377
403
|
description: 'Output file.',
|
|
378
404
|
alias: 'o',
|
|
379
405
|
},
|
|
380
|
-
format: {
|
|
381
|
-
description: 'Use a specific output format.',
|
|
382
|
-
choices: ['stylish', 'codeframe', 'json', 'checkstyle'],
|
|
383
|
-
hidden: true,
|
|
384
|
-
},
|
|
385
|
-
'max-problems': {
|
|
386
|
-
requiresArg: true,
|
|
387
|
-
description: 'Reduce output to a maximum of N problems.',
|
|
388
|
-
type: 'number',
|
|
389
|
-
hidden: true,
|
|
390
|
-
},
|
|
391
406
|
ext: {
|
|
392
407
|
description: 'Bundle file extension.',
|
|
393
408
|
requiresArg: true,
|
|
394
409
|
choices: types_1.outputExtensions,
|
|
395
410
|
},
|
|
396
|
-
'skip-rule': {
|
|
397
|
-
description: 'Ignore certain rules.',
|
|
398
|
-
array: true,
|
|
399
|
-
type: 'string',
|
|
400
|
-
hidden: true,
|
|
401
|
-
},
|
|
402
411
|
'skip-preprocessor': {
|
|
403
412
|
description: 'Ignore certain preprocessors.',
|
|
404
413
|
array: true,
|
|
@@ -423,12 +432,6 @@ yargs
|
|
|
423
432
|
description: 'Path to the config file.',
|
|
424
433
|
type: 'string',
|
|
425
434
|
},
|
|
426
|
-
lint: {
|
|
427
|
-
description: 'Lint API descriptions',
|
|
428
|
-
type: 'boolean',
|
|
429
|
-
default: false,
|
|
430
|
-
hidden: true,
|
|
431
|
-
},
|
|
432
435
|
metafile: {
|
|
433
436
|
description: 'Produce metadata about the bundle',
|
|
434
437
|
type: 'string',
|
|
@@ -455,9 +458,53 @@ yargs
|
|
|
455
458
|
choices: ['warn', 'error', 'off'],
|
|
456
459
|
default: 'warn',
|
|
457
460
|
},
|
|
461
|
+
format: {
|
|
462
|
+
hidden: true,
|
|
463
|
+
deprecated: true,
|
|
464
|
+
},
|
|
465
|
+
lint: {
|
|
466
|
+
hidden: true,
|
|
467
|
+
deprecated: true,
|
|
468
|
+
},
|
|
469
|
+
'skip-rule': {
|
|
470
|
+
hidden: true,
|
|
471
|
+
deprecated: true,
|
|
472
|
+
array: true,
|
|
473
|
+
type: 'string',
|
|
474
|
+
},
|
|
475
|
+
'max-problems': {
|
|
476
|
+
hidden: true,
|
|
477
|
+
deprecated: true,
|
|
478
|
+
},
|
|
458
479
|
}), (argv) => {
|
|
480
|
+
const DEPRECATED_OPTIONS = ['lint', 'format', 'skip-rule', 'max-problems'];
|
|
481
|
+
const LINT_AND_BUNDLE_DOCUMENTATION_LINK = 'https://redocly.com/docs/cli/guides/lint-and-bundle/#lint-and-bundle-api-descriptions-with-redocly-cli';
|
|
482
|
+
DEPRECATED_OPTIONS.forEach((option) => {
|
|
483
|
+
if (argv[option]) {
|
|
484
|
+
process.stdout.write(`${colors.red(`Option --${option} is no longer supported. Please use separate commands, as described in the ${LINT_AND_BUNDLE_DOCUMENTATION_LINK}.`)}`);
|
|
485
|
+
process.stdout.write('\n\n');
|
|
486
|
+
yargs.showHelp();
|
|
487
|
+
process.exit(1);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
459
490
|
process.env.REDOCLY_CLI_COMMAND = 'bundle';
|
|
460
491
|
(0, wrapper_1.commandWrapper)(bundle_1.handleBundle)(argv);
|
|
492
|
+
})
|
|
493
|
+
.command('check-config', 'Lint the Redocly configuration file.', (yargs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
494
|
+
return yargs.option({
|
|
495
|
+
config: {
|
|
496
|
+
description: 'Path to the config file.',
|
|
497
|
+
type: 'string',
|
|
498
|
+
},
|
|
499
|
+
'lint-config': {
|
|
500
|
+
description: 'Severity level for config file linting.',
|
|
501
|
+
choices: ['warn', 'error'],
|
|
502
|
+
default: 'error',
|
|
503
|
+
},
|
|
504
|
+
});
|
|
505
|
+
}), (argv) => {
|
|
506
|
+
process.env.REDOCLY_CLI_COMMAND = 'check-config';
|
|
507
|
+
(0, wrapper_1.commandWrapper)()(argv);
|
|
461
508
|
})
|
|
462
509
|
.command('login', 'Login to the Redocly API registry with an access token.', (yargs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
463
510
|
return yargs.options({
|
package/lib/types.d.ts
CHANGED
|
@@ -25,7 +25,11 @@ export type Entrypoint = {
|
|
|
25
25
|
export declare const outputExtensions: readonly BundleOutputFormat[];
|
|
26
26
|
export type OutputExtensions = 'json' | 'yaml' | 'yml' | undefined;
|
|
27
27
|
export declare const regionChoices: readonly Region[];
|
|
28
|
-
export type CommandOptions = StatsOptions | SplitOptions | JoinOptions | PushOptions | PushBhOptions | LintOptions | BundleOptions | LoginOptions | PreviewDocsOptions | BuildDocsArgv | PushStatusOptions | PreviewProjectOptions;
|
|
28
|
+
export type CommandOptions = StatsOptions | SplitOptions | JoinOptions | PushOptions | PushBhOptions | LintOptions | BundleOptions | LoginOptions | PreviewDocsOptions | BuildDocsArgv | PushStatusOptions | VerifyConfigOptions | PreviewProjectOptions;
|
|
29
|
+
export type VerifyConfigOptions = {
|
|
30
|
+
config?: string;
|
|
31
|
+
'lint-config'?: 'warning' | 'error' | 'off';
|
|
32
|
+
};
|
|
29
33
|
export type Skips = {
|
|
30
34
|
'skip-rule'?: string[];
|
|
31
35
|
'skip-decorator'?: string[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCommandNameFromArgs = void 0;
|
|
4
|
+
function getCommandNameFromArgs(argv) {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
return (_b = (_a = argv === null || argv === void 0 ? void 0 : argv._) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '';
|
|
7
|
+
}
|
|
8
|
+
exports.getCommandNameFromArgs = getCommandNameFromArgs;
|
|
@@ -25,7 +25,7 @@ export declare function handleError(e: Error, ref: string): void;
|
|
|
25
25
|
export declare class HandledError extends Error {
|
|
26
26
|
}
|
|
27
27
|
export declare function printLintTotals(totals: Totals, definitionsCount: number): void;
|
|
28
|
-
export declare function printConfigLintTotals(totals: Totals): void;
|
|
28
|
+
export declare function printConfigLintTotals(totals: Totals, command?: string | number): void;
|
|
29
29
|
export declare function getOutputFileName(entrypoint: string, entries: number, output?: string, ext?: BundleOutputFormat): {
|
|
30
30
|
outputFile: string;
|
|
31
31
|
ext: BundleOutputFormat;
|
|
@@ -312,13 +312,16 @@ function printLintTotals(totals, definitionsCount) {
|
|
|
312
312
|
process.stderr.write('\n');
|
|
313
313
|
}
|
|
314
314
|
exports.printLintTotals = printLintTotals;
|
|
315
|
-
function printConfigLintTotals(totals) {
|
|
315
|
+
function printConfigLintTotals(totals, command) {
|
|
316
316
|
if (totals.errors > 0) {
|
|
317
317
|
process.stderr.write((0, colorette_1.red)(`❌ Your config has ${totals.errors} ${pluralize('error', totals.errors)}.`));
|
|
318
318
|
}
|
|
319
319
|
else if (totals.warnings > 0) {
|
|
320
320
|
process.stderr.write((0, colorette_1.yellow)(`⚠️ Your config has ${totals.warnings} ${pluralize('warning', totals.warnings)}.\n`));
|
|
321
321
|
}
|
|
322
|
+
else if (command === 'check-config') {
|
|
323
|
+
process.stderr.write((0, colorette_1.green)('✅ Your config is valid.\n'));
|
|
324
|
+
}
|
|
322
325
|
}
|
|
323
326
|
exports.printConfigLintTotals = printConfigLintTotals;
|
|
324
327
|
function getOutputFileName(entrypoint, entries, output, ext) {
|
package/lib/wrapper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Config } from '@redocly/openapi-core';
|
|
2
2
|
import type { Arguments } from 'yargs';
|
|
3
3
|
import type { CommandOptions } from './types';
|
|
4
|
-
export declare function commandWrapper<T extends CommandOptions>(commandHandler
|
|
4
|
+
export declare function commandWrapper<T extends CommandOptions>(commandHandler?: (argv: T, config: Config, version: string) => Promise<void>): (argv: Arguments<T>) => Promise<void>;
|
package/lib/wrapper.js
CHANGED
|
@@ -33,7 +33,9 @@ function commandWrapper(commandHandler) {
|
|
|
33
33
|
telemetry = config.telemetry;
|
|
34
34
|
hasConfig = !config.styleguide.recommendedFallback;
|
|
35
35
|
code = 1;
|
|
36
|
-
|
|
36
|
+
if (typeof commandHandler === 'function') {
|
|
37
|
+
yield commandHandler(argv, config, update_version_notifier_1.version);
|
|
38
|
+
}
|
|
37
39
|
code = 0;
|
|
38
40
|
}
|
|
39
41
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"Roman Hotsiy <roman@redoc.ly> (https://redoc.ly/)"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@redocly/openapi-core": "1.
|
|
39
|
+
"@redocly/openapi-core": "1.11.0",
|
|
40
40
|
"abort-controller": "^3.0.0",
|
|
41
41
|
"chokidar": "^3.5.1",
|
|
42
42
|
"colorette": "^1.2.0",
|