@redocly/cli 1.10.6 → 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 +13 -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/index.js +57 -26
- 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/index.ts +76 -26
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
3
16
|
## 1.10.6
|
|
4
17
|
|
|
5
18
|
### 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/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,7 +458,35 @@ 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);
|
|
461
492
|
})
|
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",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bundle, getTotals, getMergedConfig } from '@redocly/openapi-core';
|
|
2
2
|
|
|
3
3
|
import { BundleOptions, handleBundle } from '../../commands/bundle';
|
|
4
4
|
import { handleError } from '../../utils/miscellaneous';
|
|
@@ -25,21 +25,18 @@ describe('bundle', () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
afterEach(() => {
|
|
28
|
-
(lint as jest.Mock).mockClear();
|
|
29
28
|
(bundle as jest.Mock).mockClear();
|
|
30
29
|
(getTotals as jest.Mock).mockReset();
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
it('bundles definitions
|
|
32
|
+
it('bundles definitions', async () => {
|
|
34
33
|
const apis = ['foo.yaml', 'bar.yaml'];
|
|
35
34
|
|
|
36
35
|
await commandWrapper(handleBundle)({
|
|
37
36
|
apis,
|
|
38
37
|
ext: 'yaml',
|
|
39
|
-
format: 'codeframe',
|
|
40
38
|
} as Arguments<BundleOptions>);
|
|
41
39
|
|
|
42
|
-
expect(lint).toBeCalledTimes(0);
|
|
43
40
|
expect(bundle).toBeCalledTimes(apis.length);
|
|
44
41
|
});
|
|
45
42
|
|
|
@@ -49,48 +46,25 @@ describe('bundle', () => {
|
|
|
49
46
|
await commandWrapper(handleBundle)({
|
|
50
47
|
apis,
|
|
51
48
|
ext: 'yaml',
|
|
52
|
-
format: 'codeframe',
|
|
53
49
|
} as Arguments<BundleOptions>);
|
|
54
50
|
|
|
55
51
|
await exitCb?.();
|
|
56
52
|
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
57
53
|
});
|
|
58
54
|
|
|
59
|
-
it('bundles definitions w/
|
|
60
|
-
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
|
|
61
|
-
|
|
62
|
-
(getTotals as jest.Mock).mockReturnValue({
|
|
63
|
-
errors: 0,
|
|
64
|
-
warnings: 0,
|
|
65
|
-
ignored: 0,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
await commandWrapper(handleBundle)({
|
|
69
|
-
apis,
|
|
70
|
-
ext: 'yaml',
|
|
71
|
-
format: 'codeframe',
|
|
72
|
-
lint: true,
|
|
73
|
-
} as Arguments<BundleOptions>);
|
|
74
|
-
|
|
75
|
-
expect(lint).toBeCalledTimes(apis.length);
|
|
76
|
-
expect(bundle).toBeCalledTimes(apis.length);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('exits with code 0 when bundles definitions w/linting w/o errors', async () => {
|
|
55
|
+
it('exits with code 0 when bundles definitions w/o errors', async () => {
|
|
80
56
|
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
|
|
81
57
|
|
|
82
58
|
await commandWrapper(handleBundle)({
|
|
83
59
|
apis,
|
|
84
60
|
ext: 'yaml',
|
|
85
|
-
format: 'codeframe',
|
|
86
|
-
lint: true,
|
|
87
61
|
} as Arguments<BundleOptions>);
|
|
88
62
|
|
|
89
63
|
await exitCb?.();
|
|
90
64
|
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
91
65
|
});
|
|
92
66
|
|
|
93
|
-
it('exits with code 1 when bundles definitions w/
|
|
67
|
+
it('exits with code 1 when bundles definitions w/errors', async () => {
|
|
94
68
|
const apis = ['foo.yaml'];
|
|
95
69
|
|
|
96
70
|
(getTotals as jest.Mock).mockReturnValue({
|
|
@@ -102,11 +76,8 @@ describe('bundle', () => {
|
|
|
102
76
|
await commandWrapper(handleBundle)({
|
|
103
77
|
apis,
|
|
104
78
|
ext: 'yaml',
|
|
105
|
-
format: 'codeframe',
|
|
106
|
-
lint: true,
|
|
107
79
|
} as Arguments<BundleOptions>);
|
|
108
80
|
|
|
109
|
-
expect(lint).toBeCalledTimes(apis.length);
|
|
110
81
|
await exitCb?.();
|
|
111
82
|
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
112
83
|
});
|
|
@@ -121,8 +92,6 @@ describe('bundle', () => {
|
|
|
121
92
|
await commandWrapper(handleBundle)({
|
|
122
93
|
apis,
|
|
123
94
|
ext: 'json',
|
|
124
|
-
format: 'codeframe',
|
|
125
|
-
lint: false,
|
|
126
95
|
} as Arguments<BundleOptions>);
|
|
127
96
|
|
|
128
97
|
expect(handleError).toHaveBeenCalledTimes(1);
|
|
@@ -141,8 +110,6 @@ describe('bundle', () => {
|
|
|
141
110
|
await commandWrapper(handleBundle)({
|
|
142
111
|
apis,
|
|
143
112
|
ext: 'yaml',
|
|
144
|
-
format: 'codeframe',
|
|
145
|
-
lint: false,
|
|
146
113
|
} as Arguments<BundleOptions>);
|
|
147
114
|
|
|
148
115
|
expect(handleError).toHaveBeenCalledTimes(0);
|
|
@@ -165,23 +165,6 @@ describe('handleJoin', () => {
|
|
|
165
165
|
expect(config.styleguide.skipPreprocessors).toHaveBeenCalled();
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
it('should not call skipDecorators and skipPreprocessors', async () => {
|
|
169
|
-
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
170
|
-
await handleJoin(
|
|
171
|
-
{
|
|
172
|
-
apis: ['first.yaml', 'second.yaml'],
|
|
173
|
-
decorate: true,
|
|
174
|
-
preprocess: true,
|
|
175
|
-
},
|
|
176
|
-
ConfigFixture as any,
|
|
177
|
-
'cli-version'
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
const config = loadConfig();
|
|
181
|
-
expect(config.styleguide.skipDecorators).not.toHaveBeenCalled();
|
|
182
|
-
expect(config.styleguide.skipPreprocessors).not.toHaveBeenCalled();
|
|
183
|
-
});
|
|
184
|
-
|
|
185
168
|
it('should handle join with prefix-components-with-info-prop and null values', async () => {
|
|
186
169
|
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
187
170
|
|