@redocly/cli 1.0.0-beta.127 → 1.0.0-beta.128
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/lib/__tests__/utils.test.js +12 -0
- package/lib/index.js +1 -1
- package/lib/utils.js +6 -3
- package/package.json +2 -2
|
@@ -320,6 +320,18 @@ describe('handleErrors', () => {
|
|
|
320
320
|
expect(process.stderr.write).toHaveBeenCalledWith(`Detected circular reference which can't be converted to JSON.\n` +
|
|
321
321
|
`Try to use ${colorette_1.blue('yaml')} output or remove ${colorette_1.blue('--dereferenced')}.\n\n`);
|
|
322
322
|
});
|
|
323
|
+
it('should handle SyntaxError', () => {
|
|
324
|
+
const testError = new SyntaxError('Unexpected identifier');
|
|
325
|
+
testError.stack = 'test stack';
|
|
326
|
+
try {
|
|
327
|
+
utils_1.handleError(testError, ref);
|
|
328
|
+
}
|
|
329
|
+
catch (e) {
|
|
330
|
+
expect(e).toEqual(testError);
|
|
331
|
+
}
|
|
332
|
+
expect(process.exit).toHaveBeenCalledWith(1);
|
|
333
|
+
expect(process.stderr.write).toHaveBeenCalledWith('Syntax error: Unexpected identifier test stack\n\n');
|
|
334
|
+
});
|
|
323
335
|
it('should throw unknown error', () => {
|
|
324
336
|
const testError = new Error('Test error');
|
|
325
337
|
try {
|
package/lib/index.js
CHANGED
|
@@ -331,7 +331,7 @@ yargs
|
|
|
331
331
|
process.env.REDOCLY_CLI_COMMAND = 'preview-docs';
|
|
332
332
|
preview_docs_1.previewDocs(argv);
|
|
333
333
|
})
|
|
334
|
-
.command('build-docs [api]', 'build definition into
|
|
334
|
+
.command('build-docs [api]', 'build definition into an HTML file', (yargs) => yargs
|
|
335
335
|
.positional('api', { type: 'string' })
|
|
336
336
|
.options({
|
|
337
337
|
o: {
|
package/lib/utils.js
CHANGED
|
@@ -202,6 +202,7 @@ function pluralize(label, num) {
|
|
|
202
202
|
}
|
|
203
203
|
exports.pluralize = pluralize;
|
|
204
204
|
function handleError(e, ref) {
|
|
205
|
+
var _a, _b;
|
|
205
206
|
switch (e.constructor) {
|
|
206
207
|
case openapi_core_1.ResolveError:
|
|
207
208
|
return exitWithError(`Failed to resolve api definition at ${ref}:\n\n - ${e.message}.`);
|
|
@@ -213,9 +214,11 @@ function handleError(e, ref) {
|
|
|
213
214
|
`Try to use ${colorette_1.blue('yaml')} output or remove ${colorette_1.blue('--dereferenced')}.\n\n`);
|
|
214
215
|
return process.exit(1);
|
|
215
216
|
}
|
|
217
|
+
case SyntaxError:
|
|
218
|
+
return exitWithError(`Syntax error: ${e.message} ${(_b = (_a = e.stack) === null || _a === void 0 ? void 0 : _a.split('\n\n')) === null || _b === void 0 ? void 0 : _b[0]}`);
|
|
216
219
|
default: {
|
|
217
|
-
process.stderr.write(`Something went wrong when processing ${ref}:\n\n - ${e.message}.\n\n`);
|
|
218
|
-
process.
|
|
220
|
+
process.stderr.write(colorette_1.red(`Something went wrong when processing ${ref}:\n\n - ${e.message}.\n\n`));
|
|
221
|
+
process.exit(1);
|
|
219
222
|
throw e;
|
|
220
223
|
}
|
|
221
224
|
}
|
|
@@ -314,7 +317,7 @@ function loadConfigAndHandleErrors(options = {}) {
|
|
|
314
317
|
return yield openapi_core_1.loadConfig(options);
|
|
315
318
|
}
|
|
316
319
|
catch (e) {
|
|
317
|
-
|
|
320
|
+
handleError(e, '');
|
|
318
321
|
return new openapi_core_1.Config({ apis: {}, styleguide: {} });
|
|
319
322
|
}
|
|
320
323
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.128",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"Roman Hotsiy <roman@redoc.ly> (https://redoc.ly/)"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@redocly/openapi-core": "1.0.0-beta.
|
|
36
|
+
"@redocly/openapi-core": "1.0.0-beta.128",
|
|
37
37
|
"assert-node-version": "^1.0.3",
|
|
38
38
|
"chokidar": "^3.5.1",
|
|
39
39
|
"colorette": "^1.2.0",
|