@redocly/cli 1.2.1 → 1.4.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 +23 -0
- package/lib/__mocks__/@redocly/openapi-core.d.ts +1 -0
- package/lib/__mocks__/@redocly/openapi-core.js +4 -3
- package/lib/__mocks__/utils.d.ts +2 -0
- package/lib/__mocks__/utils.js +3 -1
- package/lib/__tests__/commands/build-docs.test.js +2 -2
- package/lib/__tests__/commands/bundle.test.js +7 -7
- package/lib/__tests__/commands/join.test.js +25 -18
- package/lib/__tests__/commands/lint.test.js +15 -15
- package/lib/__tests__/commands/push-region.test.js +2 -2
- package/lib/__tests__/commands/push.test.js +30 -30
- package/lib/__tests__/fetch-with-timeout.test.js +2 -2
- package/lib/__tests__/utils.test.js +67 -41
- package/lib/__tests__/wrapper.test.js +3 -3
- package/lib/assert-node-version.js +1 -1
- package/lib/commands/build-docs/index.js +9 -9
- package/lib/commands/build-docs/types.d.ts +2 -2
- package/lib/commands/build-docs/utils.js +10 -10
- package/lib/commands/bundle.d.ts +1 -1
- package/lib/commands/bundle.js +25 -25
- package/lib/commands/join.d.ts +3 -3
- package/lib/commands/join.js +49 -48
- package/lib/commands/lint.d.ts +1 -1
- package/lib/commands/lint.js +27 -23
- package/lib/commands/login.d.ts +1 -1
- package/lib/commands/login.js +3 -3
- package/lib/commands/preview-docs/index.d.ts +1 -1
- package/lib/commands/preview-docs/index.js +7 -7
- package/lib/commands/preview-docs/preview-server/hot.js +19 -2
- package/lib/commands/preview-docs/preview-server/preview-server.js +15 -14
- package/lib/commands/preview-docs/preview-server/server.d.ts +3 -1
- package/lib/commands/preview-docs/preview-server/server.js +2 -2
- package/lib/commands/push.d.ts +2 -2
- package/lib/commands/push.js +31 -31
- package/lib/commands/split/__tests__/index.test.js +9 -9
- package/lib/commands/split/index.d.ts +2 -2
- package/lib/commands/split/index.js +41 -40
- package/lib/commands/split/types.d.ts +2 -2
- package/lib/commands/split/types.js +2 -2
- package/lib/commands/stats.d.ts +1 -1
- package/lib/commands/stats.js +9 -9
- package/lib/fetch-with-timeout.js +5 -2
- package/lib/index.js +46 -12
- package/lib/types.d.ts +6 -6
- package/lib/update-version-notifier.js +18 -18
- package/lib/utils.d.ts +6 -3
- package/lib/utils.js +69 -40
- package/lib/wrapper.js +5 -5
- package/package.json +3 -3
- package/src/__mocks__/@redocly/openapi-core.ts +1 -0
- package/src/__mocks__/utils.ts +2 -0
- package/src/__tests__/commands/join.test.ts +37 -7
- package/src/__tests__/utils.test.ts +49 -13
- package/src/commands/join.ts +10 -4
- package/src/commands/lint.ts +6 -1
- package/src/commands/preview-docs/preview-server/hot.js +19 -2
- package/src/commands/preview-docs/preview-server/preview-server.ts +6 -4
- package/src/commands/preview-docs/preview-server/server.ts +2 -2
- package/src/commands/split/__tests__/index.test.ts +14 -5
- package/src/commands/split/index.ts +25 -17
- package/src/fetch-with-timeout.ts +3 -0
- package/src/index.ts +35 -1
- package/src/utils.ts +45 -9
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -24,24 +24,25 @@ function handleSplit(argv) {
|
|
|
24
24
|
const startedAt = perf_hooks_1.performance.now();
|
|
25
25
|
const { api, outDir, separator } = argv;
|
|
26
26
|
validateDefinitionFileName(api);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const ext = (0, utils_1.getAndValidateFileExtension)(api);
|
|
28
|
+
const openapi = (0, utils_1.readYaml)(api);
|
|
29
|
+
splitDefinition(openapi, outDir, separator, ext);
|
|
30
|
+
process.stderr.write(`🪓 Document: ${(0, colorette_1.blue)(api)} ${(0, colorette_1.green)('is successfully split')}
|
|
31
|
+
and all related files are saved to the directory: ${(0, colorette_1.blue)(outDir)} \n`);
|
|
32
|
+
(0, utils_1.printExecutionTime)('split', startedAt, api);
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
exports.handleSplit = handleSplit;
|
|
35
|
-
function splitDefinition(openapi, openapiDir, pathSeparator) {
|
|
36
|
+
function splitDefinition(openapi, openapiDir, pathSeparator, ext) {
|
|
36
37
|
fs.mkdirSync(openapiDir, { recursive: true });
|
|
37
38
|
const componentsFiles = {};
|
|
38
|
-
iterateComponents(openapi, openapiDir, componentsFiles);
|
|
39
|
-
iteratePathItems(openapi.paths, openapiDir, path.join(openapiDir, 'paths'), componentsFiles, pathSeparator);
|
|
39
|
+
iterateComponents(openapi, openapiDir, componentsFiles, ext);
|
|
40
|
+
iteratePathItems(openapi.paths, openapiDir, path.join(openapiDir, 'paths'), componentsFiles, pathSeparator, undefined, ext);
|
|
40
41
|
const webhooks = openapi.webhooks || openapi['x-webhooks'];
|
|
41
42
|
// use webhook_ prefix for code samples to prevent potential name-clashes with paths samples
|
|
42
|
-
iteratePathItems(webhooks, openapiDir, path.join(openapiDir, 'webhooks'), componentsFiles, pathSeparator, 'webhook_');
|
|
43
|
+
iteratePathItems(webhooks, openapiDir, path.join(openapiDir, 'webhooks'), componentsFiles, pathSeparator, 'webhook_', ext);
|
|
43
44
|
replace$Refs(openapi, openapiDir, componentsFiles);
|
|
44
|
-
utils_1.
|
|
45
|
+
(0, utils_1.writeToFileByExtension)(openapi, path.join(openapiDir, `openapi.${ext}`));
|
|
45
46
|
}
|
|
46
47
|
function isStartsWithComponents(node) {
|
|
47
48
|
return node.startsWith(types_1.componentsPath);
|
|
@@ -51,20 +52,20 @@ function isNotYaml(filename) {
|
|
|
51
52
|
}
|
|
52
53
|
function loadFile(fileName) {
|
|
53
54
|
try {
|
|
54
|
-
return openapi_core_1.parseYaml(fs.readFileSync(fileName, 'utf8'));
|
|
55
|
+
return (0, openapi_core_1.parseYaml)(fs.readFileSync(fileName, 'utf8'));
|
|
55
56
|
}
|
|
56
57
|
catch (e) {
|
|
57
|
-
return utils_1.exitWithError(e.message);
|
|
58
|
+
return (0, utils_1.exitWithError)(e.message);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
function validateDefinitionFileName(fileName) {
|
|
61
62
|
if (!fs.existsSync(fileName))
|
|
62
|
-
utils_1.exitWithError(`File ${colorette_1.blue(fileName)} does not exist \n`);
|
|
63
|
+
(0, utils_1.exitWithError)(`File ${(0, colorette_1.blue)(fileName)} does not exist \n`);
|
|
63
64
|
const file = loadFile(fileName);
|
|
64
65
|
if (file.swagger)
|
|
65
|
-
utils_1.exitWithError('OpenAPI 2 is not supported by this command');
|
|
66
|
+
(0, utils_1.exitWithError)('OpenAPI 2 is not supported by this command');
|
|
66
67
|
if (!file.openapi)
|
|
67
|
-
utils_1.exitWithError('File does not conform to the OpenAPI Specification. OpenAPI version is not specified');
|
|
68
|
+
(0, utils_1.exitWithError)('File does not conform to the OpenAPI Specification. OpenAPI version is not specified');
|
|
68
69
|
return true;
|
|
69
70
|
}
|
|
70
71
|
function traverseDirectoryDeep(directory, callback, componentsFiles) {
|
|
@@ -84,12 +85,12 @@ function traverseDirectoryDeep(directory, callback, componentsFiles) {
|
|
|
84
85
|
function traverseDirectoryDeepCallback(filename, directory, componentsFiles) {
|
|
85
86
|
if (isNotYaml(filename))
|
|
86
87
|
return;
|
|
87
|
-
const pathData = utils_1.readYaml(filename);
|
|
88
|
+
const pathData = (0, utils_1.readYaml)(filename);
|
|
88
89
|
replace$Refs(pathData, directory, componentsFiles);
|
|
89
|
-
utils_1.
|
|
90
|
+
(0, utils_1.writeToFileByExtension)(pathData, filename);
|
|
90
91
|
}
|
|
91
92
|
function crawl(object, visitor) {
|
|
92
|
-
if (!js_utils_1.isObject(object))
|
|
93
|
+
if (!(0, js_utils_1.isObject)(object))
|
|
93
94
|
return;
|
|
94
95
|
for (const key of Object.keys(object)) {
|
|
95
96
|
visitor(object, key);
|
|
@@ -98,15 +99,15 @@ function crawl(object, visitor) {
|
|
|
98
99
|
}
|
|
99
100
|
function replace$Refs(obj, relativeFrom, componentFiles = {}) {
|
|
100
101
|
crawl(obj, (node) => {
|
|
101
|
-
if (node.$ref && js_utils_1.isString(node.$ref) && isStartsWithComponents(node.$ref)) {
|
|
102
|
+
if (node.$ref && (0, js_utils_1.isString)(node.$ref) && isStartsWithComponents(node.$ref)) {
|
|
102
103
|
replace(node, '$ref');
|
|
103
104
|
}
|
|
104
105
|
else if (node.discriminator &&
|
|
105
106
|
node.discriminator.mapping &&
|
|
106
|
-
js_utils_1.isObject(node.discriminator.mapping)) {
|
|
107
|
+
(0, js_utils_1.isObject)(node.discriminator.mapping)) {
|
|
107
108
|
const { mapping } = node.discriminator;
|
|
108
109
|
for (const name of Object.keys(mapping)) {
|
|
109
|
-
if (js_utils_1.isString(mapping[name]) && isStartsWithComponents(mapping[name])) {
|
|
110
|
+
if ((0, js_utils_1.isString)(mapping[name]) && isStartsWithComponents(mapping[name])) {
|
|
110
111
|
replace(node.discriminator.mapping, name);
|
|
111
112
|
}
|
|
112
113
|
}
|
|
@@ -137,7 +138,7 @@ function implicitlyReferenceDiscriminator(obj, defName, filename, schemaFiles) {
|
|
|
137
138
|
implicitMapping[name] = res.startsWith('.') ? res : '.' + path.sep + res;
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
|
-
if (js_utils_1.isEmptyObject(implicitMapping))
|
|
141
|
+
if ((0, js_utils_1.isEmptyObject)(implicitMapping))
|
|
141
142
|
return;
|
|
142
143
|
const discriminatorPropSchema = obj.properties[obj.discriminator.propertyName];
|
|
143
144
|
const discriminatorEnum = discriminatorPropSchema && discriminatorPropSchema.enum;
|
|
@@ -147,7 +148,7 @@ function implicitlyReferenceDiscriminator(obj, defName, filename, schemaFiles) {
|
|
|
147
148
|
continue;
|
|
148
149
|
}
|
|
149
150
|
if (mapping[name] && mapping[name] !== implicitMapping[name]) {
|
|
150
|
-
process.stderr.write(colorette_1.yellow(`warning: explicit mapping overlaps with local mapping entry ${colorette_1.red(name)} at ${colorette_1.blue(filename)}. Please check it.`));
|
|
151
|
+
process.stderr.write((0, colorette_1.yellow)(`warning: explicit mapping overlaps with local mapping entry ${(0, colorette_1.red)(name)} at ${(0, colorette_1.blue)(filename)}. Please check it.`));
|
|
151
152
|
}
|
|
152
153
|
mapping[name] = implicitMapping[name];
|
|
153
154
|
}
|
|
@@ -159,13 +160,13 @@ function findComponentTypes(components) {
|
|
|
159
160
|
return types_1.OPENAPI3_COMPONENT_NAMES.filter((item) => isNotSecurityComponentType(item) && Object.keys(components).includes(item));
|
|
160
161
|
}
|
|
161
162
|
function doesFileDiffer(filename, componentData) {
|
|
162
|
-
return fs.existsSync(filename) && !isEqual(utils_1.readYaml(filename), componentData);
|
|
163
|
+
return fs.existsSync(filename) && !isEqual((0, utils_1.readYaml)(filename), componentData);
|
|
163
164
|
}
|
|
164
165
|
function removeEmptyComponents(openapi, componentType) {
|
|
165
|
-
if (openapi.components && js_utils_1.isEmptyObject(openapi.components[componentType])) {
|
|
166
|
+
if (openapi.components && (0, js_utils_1.isEmptyObject)(openapi.components[componentType])) {
|
|
166
167
|
delete openapi.components[componentType];
|
|
167
168
|
}
|
|
168
|
-
if (js_utils_1.isEmptyObject(openapi.components)) {
|
|
169
|
+
if ((0, js_utils_1.isEmptyObject)(openapi.components)) {
|
|
169
170
|
delete openapi.components;
|
|
170
171
|
}
|
|
171
172
|
}
|
|
@@ -177,8 +178,8 @@ function createComponentDir(componentDirPath, componentType) {
|
|
|
177
178
|
function extractFileNameFromPath(filename) {
|
|
178
179
|
return path.basename(filename, path.extname(filename));
|
|
179
180
|
}
|
|
180
|
-
function getFileNamePath(componentDirPath, componentName) {
|
|
181
|
-
return path.join(componentDirPath, componentName) +
|
|
181
|
+
function getFileNamePath(componentDirPath, componentName, ext) {
|
|
182
|
+
return path.join(componentDirPath, componentName) + `.${ext}`;
|
|
182
183
|
}
|
|
183
184
|
function gatherComponentsFiles(components, componentsFiles, componentType, componentName, filename) {
|
|
184
185
|
var _a, _b;
|
|
@@ -191,14 +192,14 @@ function gatherComponentsFiles(components, componentsFiles, componentType, compo
|
|
|
191
192
|
componentsFiles[componentType] = componentsFiles[componentType] || {};
|
|
192
193
|
componentsFiles[componentType][componentName] = { inherits, filename };
|
|
193
194
|
}
|
|
194
|
-
function iteratePathItems(pathItems, openapiDir, outDir, componentsFiles, pathSeparator, codeSamplesPathPrefix = '') {
|
|
195
|
+
function iteratePathItems(pathItems, openapiDir, outDir, componentsFiles, pathSeparator, codeSamplesPathPrefix = '', ext) {
|
|
195
196
|
if (!pathItems)
|
|
196
197
|
return;
|
|
197
198
|
fs.mkdirSync(outDir, { recursive: true });
|
|
198
199
|
for (const pathName of Object.keys(pathItems)) {
|
|
199
|
-
const pathFile = `${path.join(outDir, utils_1.pathToFilename(pathName, pathSeparator))}
|
|
200
|
+
const pathFile = `${path.join(outDir, (0, utils_1.pathToFilename)(pathName, pathSeparator))}.${ext}`;
|
|
200
201
|
const pathData = pathItems[pathName];
|
|
201
|
-
if (openapi_core_1.isRef(pathData))
|
|
202
|
+
if ((0, openapi_core_1.isRef)(pathData))
|
|
202
203
|
continue;
|
|
203
204
|
for (const method of types_1.OPENAPI3_METHOD_NAMES) {
|
|
204
205
|
const methodData = pathData[method];
|
|
@@ -209,25 +210,25 @@ function iteratePathItems(pathItems, openapiDir, outDir, componentsFiles, pathSe
|
|
|
209
210
|
for (const sample of methodDataXCode) {
|
|
210
211
|
if (sample.source && sample.source.$ref)
|
|
211
212
|
continue;
|
|
212
|
-
const sampleFileName = path.join(openapiDir, 'code_samples', utils_1.escapeLanguageName(sample.lang), codeSamplesPathPrefix + utils_1.pathToFilename(pathName, pathSeparator), method + utils_1.langToExt(sample.lang));
|
|
213
|
+
const sampleFileName = path.join(openapiDir, 'code_samples', (0, utils_1.escapeLanguageName)(sample.lang), codeSamplesPathPrefix + (0, utils_1.pathToFilename)(pathName, pathSeparator), method + (0, utils_1.langToExt)(sample.lang));
|
|
213
214
|
fs.mkdirSync(path.dirname(sampleFileName), { recursive: true });
|
|
214
215
|
fs.writeFileSync(sampleFileName, sample.source);
|
|
215
216
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
216
217
|
// @ts-ignore
|
|
217
218
|
sample.source = {
|
|
218
|
-
$ref: openapi_core_1.slash(path.relative(outDir, sampleFileName)),
|
|
219
|
+
$ref: (0, openapi_core_1.slash)(path.relative(outDir, sampleFileName)),
|
|
219
220
|
};
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
|
-
utils_1.
|
|
223
|
+
(0, utils_1.writeToFileByExtension)(pathData, pathFile);
|
|
223
224
|
pathItems[pathName] = {
|
|
224
|
-
$ref: openapi_core_1.slash(path.relative(openapiDir, pathFile)),
|
|
225
|
+
$ref: (0, openapi_core_1.slash)(path.relative(openapiDir, pathFile)),
|
|
225
226
|
};
|
|
226
227
|
traverseDirectoryDeep(outDir, traverseDirectoryDeepCallback, componentsFiles);
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
exports.iteratePathItems = iteratePathItems;
|
|
230
|
-
function iterateComponents(openapi, openapiDir, componentsFiles) {
|
|
231
|
+
function iterateComponents(openapi, openapiDir, componentsFiles, ext) {
|
|
231
232
|
const { components } = openapi;
|
|
232
233
|
if (components) {
|
|
233
234
|
const componentsDir = path.join(openapiDir, types_1.COMPONENTS);
|
|
@@ -239,7 +240,7 @@ function iterateComponents(openapi, openapiDir, componentsFiles) {
|
|
|
239
240
|
function iterateAndGatherComponentsFiles(componentType) {
|
|
240
241
|
const componentDirPath = path.join(componentsDir, componentType);
|
|
241
242
|
for (const componentName of Object.keys((components === null || components === void 0 ? void 0 : components[componentType]) || {})) {
|
|
242
|
-
const filename = getFileNamePath(componentDirPath, componentName);
|
|
243
|
+
const filename = getFileNamePath(componentDirPath, componentName, ext);
|
|
243
244
|
gatherComponentsFiles(components, componentsFiles, componentType, componentName, filename);
|
|
244
245
|
}
|
|
245
246
|
}
|
|
@@ -249,15 +250,15 @@ function iterateComponents(openapi, openapiDir, componentsFiles) {
|
|
|
249
250
|
const componentDirPath = path.join(componentsDir, componentType);
|
|
250
251
|
createComponentDir(componentDirPath, componentType);
|
|
251
252
|
for (const componentName of Object.keys((components === null || components === void 0 ? void 0 : components[componentType]) || {})) {
|
|
252
|
-
const filename = getFileNamePath(componentDirPath, componentName);
|
|
253
|
+
const filename = getFileNamePath(componentDirPath, componentName, ext);
|
|
253
254
|
const componentData = (_a = components === null || components === void 0 ? void 0 : components[componentType]) === null || _a === void 0 ? void 0 : _a[componentName];
|
|
254
255
|
replace$Refs(componentData, path.dirname(filename), componentsFiles);
|
|
255
256
|
implicitlyReferenceDiscriminator(componentData, extractFileNameFromPath(filename), filename, componentsFiles.schemas || {});
|
|
256
257
|
if (doesFileDiffer(filename, componentData)) {
|
|
257
|
-
process.stderr.write(colorette_1.yellow(`warning: conflict for ${componentName} - file already exists with different content: ${colorette_1.blue(filename)} ... Skip.\n`));
|
|
258
|
+
process.stderr.write((0, colorette_1.yellow)(`warning: conflict for ${componentName} - file already exists with different content: ${(0, colorette_1.blue)(filename)} ... Skip.\n`));
|
|
258
259
|
}
|
|
259
260
|
else {
|
|
260
|
-
utils_1.
|
|
261
|
+
(0, utils_1.writeToFileByExtension)(componentData, filename);
|
|
261
262
|
}
|
|
262
263
|
if (isNotSecurityComponentType(componentType)) {
|
|
263
264
|
// security schemas must referenced from components
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Oas3Schema, Oas3_1Schema, Oas3Definition, Oas3_1Definition, Oas3Components, Oas3PathItem, Oas3Paths, Oas3ComponentName, Oas3_1Webhooks, Oas2Definition, Referenced } from '@redocly/openapi-core';
|
|
2
2
|
export { Oas3_1Definition, Oas3Definition, Oas2Definition, Oas3Components, Oas3Paths, Oas3PathItem, Oas3ComponentName, Oas3_1Schema, Oas3Schema, Oas3_1Webhooks, Referenced, };
|
|
3
|
-
export
|
|
3
|
+
export type Definition = Oas3_1Definition | Oas3Definition | Oas2Definition;
|
|
4
4
|
export interface ComponentsFiles {
|
|
5
5
|
[schemas: string]: any;
|
|
6
6
|
}
|
|
@@ -11,7 +11,7 @@ export declare const COMPONENTS = "components";
|
|
|
11
11
|
export declare const PATHS = "paths";
|
|
12
12
|
export declare const WEBHOOKS = "webhooks";
|
|
13
13
|
export declare const xWEBHOOKS = "x-webhooks";
|
|
14
|
-
export declare const componentsPath
|
|
14
|
+
export declare const componentsPath = "#/components/";
|
|
15
15
|
export declare enum OPENAPI3_METHOD {
|
|
16
16
|
get = "get",
|
|
17
17
|
put = "put",
|
|
@@ -16,7 +16,7 @@ var OPENAPI3_METHOD;
|
|
|
16
16
|
OPENAPI3_METHOD["head"] = "head";
|
|
17
17
|
OPENAPI3_METHOD["patch"] = "patch";
|
|
18
18
|
OPENAPI3_METHOD["trace"] = "trace";
|
|
19
|
-
})(OPENAPI3_METHOD
|
|
19
|
+
})(OPENAPI3_METHOD || (exports.OPENAPI3_METHOD = OPENAPI3_METHOD = {}));
|
|
20
20
|
exports.OPENAPI3_METHOD_NAMES = [
|
|
21
21
|
OPENAPI3_METHOD.get,
|
|
22
22
|
OPENAPI3_METHOD.put,
|
|
@@ -38,7 +38,7 @@ var OPENAPI3_COMPONENT;
|
|
|
38
38
|
OPENAPI3_COMPONENT["Links"] = "links";
|
|
39
39
|
OPENAPI3_COMPONENT["Callbacks"] = "callbacks";
|
|
40
40
|
OPENAPI3_COMPONENT["SecuritySchemes"] = "securitySchemes";
|
|
41
|
-
})(OPENAPI3_COMPONENT
|
|
41
|
+
})(OPENAPI3_COMPONENT || (exports.OPENAPI3_COMPONENT = OPENAPI3_COMPONENT = {}));
|
|
42
42
|
exports.OPENAPI3_COMPONENT_NAMES = [
|
|
43
43
|
OPENAPI3_COMPONENT.RequestBodies,
|
|
44
44
|
OPENAPI3_COMPONENT.Schemas,
|
package/lib/commands/stats.d.ts
CHANGED
package/lib/commands/stats.js
CHANGED
|
@@ -54,31 +54,31 @@ function printStats(statsAccumulator, api, format) {
|
|
|
54
54
|
}
|
|
55
55
|
function handleStats(argv, config) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const [{ path }] = yield utils_1.getFallbackApisOrExit(argv.api ? [argv.api] : [], config);
|
|
57
|
+
const [{ path }] = yield (0, utils_1.getFallbackApisOrExit)(argv.api ? [argv.api] : [], config);
|
|
58
58
|
const externalRefResolver = new openapi_core_1.BaseResolver(config.resolve);
|
|
59
|
-
const { bundle: document } = yield openapi_core_1.bundle({ config, ref: path });
|
|
59
|
+
const { bundle: document } = yield (0, openapi_core_1.bundle)({ config, ref: path });
|
|
60
60
|
const lintConfig = config.styleguide;
|
|
61
|
-
const specVersion = openapi_core_1.detectSpec(document.parsed);
|
|
62
|
-
const types = openapi_core_1.normalizeTypes(lintConfig.extendTypes(openapi_core_1.getTypes(specVersion), specVersion), lintConfig);
|
|
61
|
+
const specVersion = (0, openapi_core_1.detectSpec)(document.parsed);
|
|
62
|
+
const types = (0, openapi_core_1.normalizeTypes)(lintConfig.extendTypes((0, openapi_core_1.getTypes)(specVersion), specVersion), lintConfig);
|
|
63
63
|
const startedAt = perf_hooks_1.performance.now();
|
|
64
64
|
const ctx = {
|
|
65
65
|
problems: [],
|
|
66
66
|
oasVersion: specVersion,
|
|
67
67
|
visitorsData: {},
|
|
68
68
|
};
|
|
69
|
-
const resolvedRefMap = yield openapi_core_1.resolveDocument({
|
|
69
|
+
const resolvedRefMap = yield (0, openapi_core_1.resolveDocument)({
|
|
70
70
|
rootDocument: document,
|
|
71
71
|
rootType: types.Root,
|
|
72
72
|
externalRefResolver,
|
|
73
73
|
});
|
|
74
|
-
const statsVisitor = openapi_core_1.normalizeVisitors([
|
|
74
|
+
const statsVisitor = (0, openapi_core_1.normalizeVisitors)([
|
|
75
75
|
{
|
|
76
76
|
severity: 'warn',
|
|
77
77
|
ruleId: 'stats',
|
|
78
|
-
visitor: openapi_core_1.Stats(statsAccumulator),
|
|
78
|
+
visitor: (0, openapi_core_1.Stats)(statsAccumulator),
|
|
79
79
|
},
|
|
80
80
|
], types);
|
|
81
|
-
openapi_core_1.walkDocument({
|
|
81
|
+
(0, openapi_core_1.walkDocument)({
|
|
82
82
|
document,
|
|
83
83
|
rootType: types.Root,
|
|
84
84
|
normalizedVisitors: statsVisitor,
|
|
@@ -86,7 +86,7 @@ function handleStats(argv, config) {
|
|
|
86
86
|
ctx,
|
|
87
87
|
});
|
|
88
88
|
printStats(statsAccumulator, path, argv.format);
|
|
89
|
-
utils_2.printExecutionTime('stats', startedAt, path);
|
|
89
|
+
(0, utils_2.printExecutionTime)('stats', startedAt, path);
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
exports.handleStats = handleStats;
|
|
@@ -14,13 +14,16 @@ const TIMEOUT = 3000;
|
|
|
14
14
|
exports.default = (url, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
try {
|
|
16
16
|
if (!global.AbortController) {
|
|
17
|
-
return node_fetch_1.default(url, options);
|
|
17
|
+
return (0, node_fetch_1.default)(url, options);
|
|
18
18
|
}
|
|
19
19
|
const controller = new AbortController();
|
|
20
20
|
const timeout = setTimeout(() => {
|
|
21
21
|
controller.abort();
|
|
22
22
|
}, TIMEOUT);
|
|
23
|
-
|
|
23
|
+
// FIXME: fix this (possibly along with this issue: https://github.com/Redocly/redocly-cli/issues/1260)
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
const res = yield (0, node_fetch_1.default)(url, Object.assign({ signal: controller.signal }, options));
|
|
24
27
|
clearTimeout(timeout);
|
|
25
28
|
return res;
|
|
26
29
|
}
|
package/lib/index.js
CHANGED
|
@@ -29,13 +29,18 @@ const update_version_notifier_2 = require("./update-version-notifier");
|
|
|
29
29
|
if (!('replaceAll' in String.prototype)) {
|
|
30
30
|
require('core-js/actual/string/replace-all');
|
|
31
31
|
}
|
|
32
|
-
update_version_notifier_1.cacheLatestVersion();
|
|
32
|
+
(0, update_version_notifier_1.cacheLatestVersion)();
|
|
33
33
|
yargs
|
|
34
34
|
.version('version', 'Show version number.', update_version_notifier_2.version)
|
|
35
35
|
.help('help', 'Show help.')
|
|
36
36
|
.parserConfiguration({ 'greedy-arrays': false, 'camel-case-expansion': false })
|
|
37
37
|
.command('stats [api]', 'Show statistics for an API description.', (yargs) => yargs.positional('api', { type: 'string' }).option({
|
|
38
38
|
config: { description: 'Path to the config file.', type: 'string' },
|
|
39
|
+
'lint-config': {
|
|
40
|
+
description: 'Severity level for config file linting.',
|
|
41
|
+
choices: ['warn', 'error', 'off'],
|
|
42
|
+
default: 'warn',
|
|
43
|
+
},
|
|
39
44
|
format: {
|
|
40
45
|
description: 'Use a specific output format.',
|
|
41
46
|
choices: ['stylish', 'json'],
|
|
@@ -43,7 +48,7 @@ yargs
|
|
|
43
48
|
},
|
|
44
49
|
}), (argv) => {
|
|
45
50
|
process.env.REDOCLY_CLI_COMMAND = 'stats';
|
|
46
|
-
wrapper_1.commandWrapper(stats_1.handleStats)(argv);
|
|
51
|
+
(0, wrapper_1.commandWrapper)(stats_1.handleStats)(argv);
|
|
47
52
|
})
|
|
48
53
|
.command('split [api]', 'Split an API description into a multi-file structure.', (yargs) => yargs
|
|
49
54
|
.positional('api', {
|
|
@@ -67,10 +72,15 @@ yargs
|
|
|
67
72
|
requiresArg: true,
|
|
68
73
|
type: 'string',
|
|
69
74
|
},
|
|
75
|
+
'lint-config': {
|
|
76
|
+
description: 'Severity level for config file linting.',
|
|
77
|
+
choices: ['warn', 'error', 'off'],
|
|
78
|
+
default: 'warn',
|
|
79
|
+
},
|
|
70
80
|
})
|
|
71
81
|
.demandOption('api'), (argv) => {
|
|
72
82
|
process.env.REDOCLY_CLI_COMMAND = 'split';
|
|
73
|
-
wrapper_1.commandWrapper(split_1.handleSplit)(argv);
|
|
83
|
+
(0, wrapper_1.commandWrapper)(split_1.handleSplit)(argv);
|
|
74
84
|
})
|
|
75
85
|
.command('join [apis...]', 'Join definitions [experimental].', (yargs) => yargs
|
|
76
86
|
.positional('apis', {
|
|
@@ -105,16 +115,20 @@ yargs
|
|
|
105
115
|
describe: 'Output file',
|
|
106
116
|
alias: 'o',
|
|
107
117
|
type: 'string',
|
|
108
|
-
default: 'openapi.yaml',
|
|
109
118
|
},
|
|
110
119
|
config: {
|
|
111
120
|
description: 'Path to the config file.',
|
|
112
121
|
requiresArg: true,
|
|
113
122
|
type: 'string',
|
|
114
123
|
},
|
|
124
|
+
'lint-config': {
|
|
125
|
+
description: 'Severity level for config file linting.',
|
|
126
|
+
choices: ['warn', 'error', 'off'],
|
|
127
|
+
default: 'warn',
|
|
128
|
+
},
|
|
115
129
|
}), (argv) => {
|
|
116
130
|
process.env.REDOCLY_CLI_COMMAND = 'join';
|
|
117
|
-
wrapper_1.commandWrapper(join_1.handleJoin)(argv);
|
|
131
|
+
(0, wrapper_1.commandWrapper)(join_1.handleJoin)(argv);
|
|
118
132
|
})
|
|
119
133
|
.command('push [api] [maybeDestination] [maybeBranchName]', 'Push an API description to the Redocly API registry.', (yargs) => yargs
|
|
120
134
|
.usage('push [api]')
|
|
@@ -175,6 +189,11 @@ yargs
|
|
|
175
189
|
array: true,
|
|
176
190
|
type: 'string',
|
|
177
191
|
},
|
|
192
|
+
'lint-config': {
|
|
193
|
+
description: 'Severity level for config file linting.',
|
|
194
|
+
choices: ['warn', 'error', 'off'],
|
|
195
|
+
default: 'warn',
|
|
196
|
+
},
|
|
178
197
|
})
|
|
179
198
|
.deprecateOption('batch-id', 'use --job-id')
|
|
180
199
|
.deprecateOption('maybeDestination')
|
|
@@ -182,7 +201,7 @@ yargs
|
|
|
182
201
|
.implies('batch-id', 'batch-size')
|
|
183
202
|
.implies('batch-size', 'job-id'), (argv) => {
|
|
184
203
|
process.env.REDOCLY_CLI_COMMAND = 'push';
|
|
185
|
-
wrapper_1.commandWrapper(push_1.transformPush(push_1.handlePush))(argv);
|
|
204
|
+
(0, wrapper_1.commandWrapper)((0, push_1.transformPush)(push_1.handlePush))(argv);
|
|
186
205
|
})
|
|
187
206
|
.command('lint [apis...]', 'Lint definition.', (yargs) => yargs.positional('apis', { array: true, type: 'string', demandOption: true }).option({
|
|
188
207
|
format: {
|
|
@@ -235,7 +254,7 @@ yargs
|
|
|
235
254
|
},
|
|
236
255
|
}), (argv) => {
|
|
237
256
|
process.env.REDOCLY_CLI_COMMAND = 'lint';
|
|
238
|
-
wrapper_1.commandWrapper(lint_1.handleLint)(argv);
|
|
257
|
+
(0, wrapper_1.commandWrapper)(lint_1.handleLint)(argv);
|
|
239
258
|
})
|
|
240
259
|
.command('bundle [apis...]', 'Bundle definition.', (yargs) => yargs.positional('apis', { array: true, type: 'string', demandOption: true }).options({
|
|
241
260
|
output: { type: 'string', alias: 'o' },
|
|
@@ -309,9 +328,14 @@ yargs
|
|
|
309
328
|
type: 'boolean',
|
|
310
329
|
alias: 'k',
|
|
311
330
|
},
|
|
331
|
+
'lint-config': {
|
|
332
|
+
description: 'Severity level for config file linting.',
|
|
333
|
+
choices: ['warn', 'error', 'off'],
|
|
334
|
+
default: 'warn',
|
|
335
|
+
},
|
|
312
336
|
}), (argv) => {
|
|
313
337
|
process.env.REDOCLY_CLI_COMMAND = 'bundle';
|
|
314
|
-
wrapper_1.commandWrapper(bundle_1.handleBundle)(argv);
|
|
338
|
+
(0, wrapper_1.commandWrapper)(bundle_1.handleBundle)(argv);
|
|
315
339
|
})
|
|
316
340
|
.command('login', 'Login to the Redocly API registry with an access token.', (yargs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
317
341
|
return yargs.options({
|
|
@@ -332,11 +356,11 @@ yargs
|
|
|
332
356
|
});
|
|
333
357
|
}), (argv) => {
|
|
334
358
|
process.env.REDOCLY_CLI_COMMAND = 'login';
|
|
335
|
-
wrapper_1.commandWrapper(login_1.handleLogin)(argv);
|
|
359
|
+
(0, wrapper_1.commandWrapper)(login_1.handleLogin)(argv);
|
|
336
360
|
})
|
|
337
361
|
.command('logout', 'Clear your stored credentials for the Redocly API registry.', (yargs) => yargs, (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
338
362
|
process.env.REDOCLY_CLI_COMMAND = 'logout';
|
|
339
|
-
yield wrapper_1.commandWrapper(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
363
|
+
yield (0, wrapper_1.commandWrapper)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
340
364
|
const client = new openapi_core_1.RedoclyClient();
|
|
341
365
|
client.logout();
|
|
342
366
|
process.stdout.write('Logged out from the Redocly account. ✋\n');
|
|
@@ -378,9 +402,14 @@ yargs
|
|
|
378
402
|
description: 'Path to the config file.',
|
|
379
403
|
type: 'string',
|
|
380
404
|
},
|
|
405
|
+
'lint-config': {
|
|
406
|
+
description: 'Severity level for config file linting.',
|
|
407
|
+
choices: ['warn', 'error', 'off'],
|
|
408
|
+
default: 'warn',
|
|
409
|
+
},
|
|
381
410
|
}), (argv) => {
|
|
382
411
|
process.env.REDOCLY_CLI_COMMAND = 'preview-docs';
|
|
383
|
-
wrapper_1.commandWrapper(preview_docs_1.previewDocs)(argv);
|
|
412
|
+
(0, wrapper_1.commandWrapper)(preview_docs_1.previewDocs)(argv);
|
|
384
413
|
})
|
|
385
414
|
.command('build-docs [api]', 'Produce API documentation as an HTML file', (yargs) => yargs
|
|
386
415
|
.positional('api', { type: 'string' })
|
|
@@ -415,6 +444,11 @@ yargs
|
|
|
415
444
|
describe: 'Path to the config file.',
|
|
416
445
|
type: 'string',
|
|
417
446
|
},
|
|
447
|
+
'lint-config': {
|
|
448
|
+
description: 'Severity level for config file linting.',
|
|
449
|
+
choices: ['warn', 'error', 'off'],
|
|
450
|
+
default: 'warn',
|
|
451
|
+
},
|
|
418
452
|
})
|
|
419
453
|
.check((argv) => {
|
|
420
454
|
var _a;
|
|
@@ -423,7 +457,7 @@ yargs
|
|
|
423
457
|
return true;
|
|
424
458
|
}), (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
425
459
|
process.env.REDOCLY_CLI_COMMAND = 'build-docs';
|
|
426
|
-
wrapper_1.commandWrapper(build_docs_1.handlerBuildCommand)(argv);
|
|
460
|
+
(0, wrapper_1.commandWrapper)(build_docs_1.handlerBuildCommand)(argv);
|
|
427
461
|
}))
|
|
428
462
|
.completion('completion', 'Generate completion script.')
|
|
429
463
|
.demandCommand(1)
|
package/lib/types.d.ts
CHANGED
|
@@ -8,22 +8,22 @@ import type { StatsOptions } from './commands/stats';
|
|
|
8
8
|
import type { SplitOptions } from './commands/split';
|
|
9
9
|
import type { PreviewDocsOptions } from './commands/preview-docs';
|
|
10
10
|
import type { BuildDocsArgv } from './commands/build-docs/types';
|
|
11
|
-
export
|
|
11
|
+
export type Totals = {
|
|
12
12
|
errors: number;
|
|
13
13
|
warnings: number;
|
|
14
14
|
ignored: number;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type Entrypoint = {
|
|
17
17
|
path: string;
|
|
18
18
|
alias?: string;
|
|
19
19
|
};
|
|
20
20
|
export declare const outputExtensions: readonly BundleOutputFormat[];
|
|
21
|
-
export
|
|
21
|
+
export type OutputExtensions = 'json' | 'yaml' | 'yml' | undefined;
|
|
22
22
|
export declare const regionChoices: readonly Region[];
|
|
23
|
-
export
|
|
24
|
-
export
|
|
23
|
+
export type CommandOptions = StatsOptions | SplitOptions | JoinOptions | PushOptions | LintOptions | BundleOptions | LoginOptions | PreviewDocsOptions | BuildDocsArgv;
|
|
24
|
+
export type Skips = {
|
|
25
25
|
'skip-rule'?: string[];
|
|
26
26
|
'skip-decorator'?: string[];
|
|
27
27
|
'skip-preprocessor'?: string[];
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type ConfigApis = Pick<Config, 'apis' | 'configFile'>;
|
|
@@ -28,7 +28,7 @@ const notifyUpdateCliVersion = () => {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
try {
|
|
31
|
-
const latestVersion = fs_1.readFileSync(path_1.join(os_1.tmpdir(), VERSION_CACHE_FILE)).toString();
|
|
31
|
+
const latestVersion = (0, fs_1.readFileSync)((0, path_1.join)((0, os_1.tmpdir)(), VERSION_CACHE_FILE)).toString();
|
|
32
32
|
if (isNewVersionAvailable(exports.version, latestVersion)) {
|
|
33
33
|
renderUpdateBanner(exports.version, latestVersion);
|
|
34
34
|
}
|
|
@@ -38,10 +38,10 @@ const notifyUpdateCliVersion = () => {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
exports.notifyUpdateCliVersion = notifyUpdateCliVersion;
|
|
41
|
-
const isNewVersionAvailable = (current, latest) => semver_1.compare(current, latest) < 0;
|
|
41
|
+
const isNewVersionAvailable = (current, latest) => (0, semver_1.compare)(current, latest) < 0;
|
|
42
42
|
const getLatestVersion = (packageName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
43
|
const latestUrl = `http://registry.npmjs.org/${packageName}/latest`;
|
|
44
|
-
const response = yield fetch_with_timeout_1.default(latestUrl);
|
|
44
|
+
const response = yield (0, fetch_with_timeout_1.default)(latestUrl);
|
|
45
45
|
if (!response)
|
|
46
46
|
return;
|
|
47
47
|
const info = yield response.json();
|
|
@@ -54,8 +54,8 @@ const cacheLatestVersion = () => {
|
|
|
54
54
|
getLatestVersion(exports.name)
|
|
55
55
|
.then((version) => {
|
|
56
56
|
if (version) {
|
|
57
|
-
const lastCheckFile = path_1.join(os_1.tmpdir(), VERSION_CACHE_FILE);
|
|
58
|
-
fs_1.writeFileSync(lastCheckFile, version);
|
|
57
|
+
const lastCheckFile = (0, path_1.join)((0, os_1.tmpdir)(), VERSION_CACHE_FILE);
|
|
58
|
+
(0, fs_1.writeFileSync)(lastCheckFile, version);
|
|
59
59
|
}
|
|
60
60
|
})
|
|
61
61
|
.catch(() => { });
|
|
@@ -63,39 +63,39 @@ const cacheLatestVersion = () => {
|
|
|
63
63
|
exports.cacheLatestVersion = cacheLatestVersion;
|
|
64
64
|
const renderUpdateBanner = (current, latest) => {
|
|
65
65
|
const messageLines = [
|
|
66
|
-
`A new version of ${colorette_1.cyan('Redocly CLI')} (${colorette_1.green(latest)}) is available.`,
|
|
67
|
-
`Update now: \`${colorette_1.cyan('npm i -g @redocly/cli@latest')}\`.`,
|
|
66
|
+
`A new version of ${(0, colorette_1.cyan)('Redocly CLI')} (${(0, colorette_1.green)(latest)}) is available.`,
|
|
67
|
+
`Update now: \`${(0, colorette_1.cyan)('npm i -g @redocly/cli@latest')}\`.`,
|
|
68
68
|
`Changelog: https://redocly.com/docs/cli/changelog/`,
|
|
69
69
|
];
|
|
70
|
-
const maxLength = Math.max(...messageLines.map((line) => utils_1.cleanColors(line).length));
|
|
71
|
-
const border = colorette_1.yellow('═'.repeat(maxLength + SPACE_TO_BORDER));
|
|
70
|
+
const maxLength = Math.max(...messageLines.map((line) => (0, utils_1.cleanColors)(line).length));
|
|
71
|
+
const border = (0, colorette_1.yellow)('═'.repeat(maxLength + SPACE_TO_BORDER));
|
|
72
72
|
const banner = `
|
|
73
|
-
${colorette_1.yellow('╔' + border + '╗')}
|
|
74
|
-
${colorette_1.yellow('║' + ' '.repeat(maxLength + SPACE_TO_BORDER) + '║')}
|
|
73
|
+
${(0, colorette_1.yellow)('╔' + border + '╗')}
|
|
74
|
+
${(0, colorette_1.yellow)('║' + ' '.repeat(maxLength + SPACE_TO_BORDER) + '║')}
|
|
75
75
|
${messageLines
|
|
76
76
|
.map((line, index) => {
|
|
77
77
|
return getLineWithPadding(maxLength, line, index);
|
|
78
78
|
})
|
|
79
79
|
.join('\n')}
|
|
80
|
-
${colorette_1.yellow('║' + ' '.repeat(maxLength + SPACE_TO_BORDER) + '║')}
|
|
81
|
-
${colorette_1.yellow('╚' + border + '╝')}
|
|
80
|
+
${(0, colorette_1.yellow)('║' + ' '.repeat(maxLength + SPACE_TO_BORDER) + '║')}
|
|
81
|
+
${(0, colorette_1.yellow)('╚' + border + '╝')}
|
|
82
82
|
`;
|
|
83
83
|
process.stderr.write(banner);
|
|
84
84
|
};
|
|
85
85
|
const getLineWithPadding = (maxLength, line, index) => {
|
|
86
|
-
const padding = ' '.repeat(maxLength - utils_1.cleanColors(line).length);
|
|
86
|
+
const padding = ' '.repeat(maxLength - (0, utils_1.cleanColors)(line).length);
|
|
87
87
|
const extraSpaces = index !== 0 ? ' '.repeat(SPACE_TO_BORDER) : '';
|
|
88
|
-
return `${extraSpaces}${colorette_1.yellow('║')} ${line}${padding} ${colorette_1.yellow('║')}`;
|
|
88
|
+
return `${extraSpaces}${(0, colorette_1.yellow)('║')} ${line}${padding} ${(0, colorette_1.yellow)('║')}`;
|
|
89
89
|
};
|
|
90
90
|
const isNeedToBeCached = () => {
|
|
91
91
|
try {
|
|
92
92
|
// Last version from npm is stored in a file in the OS temp folder
|
|
93
|
-
const versionFile = path_1.join(os_1.tmpdir(), VERSION_CACHE_FILE);
|
|
94
|
-
if (!fs_1.existsSync(versionFile)) {
|
|
93
|
+
const versionFile = (0, path_1.join)((0, os_1.tmpdir)(), VERSION_CACHE_FILE);
|
|
94
|
+
if (!(0, fs_1.existsSync)(versionFile)) {
|
|
95
95
|
return true;
|
|
96
96
|
}
|
|
97
97
|
const now = new Date().getTime();
|
|
98
|
-
const stats = fs_1.statSync(versionFile);
|
|
98
|
+
const stats = (0, fs_1.statSync)(versionFile);
|
|
99
99
|
const lastCheck = stats.mtime.getTime();
|
|
100
100
|
return now - lastCheck >= INTERVAL_TO_CHECK;
|
|
101
101
|
}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BundleOutputFormat, StyleguideConfig, RawConfig, Region, Config, Oas3Definition, Oas2Definition } from '@redocly/openapi-core';
|
|
2
|
-
import { Totals, Entrypoint, ConfigApis, CommandOptions } from './types';
|
|
2
|
+
import { Totals, Entrypoint, ConfigApis, CommandOptions, OutputExtensions } from './types';
|
|
3
3
|
import { Arguments } from 'yargs';
|
|
4
4
|
export declare function getFallbackApisOrExit(argsApis: string[] | undefined, config: ConfigApis): Promise<Entrypoint[]>;
|
|
5
5
|
export declare function getExecutionTime(startedAt: number): string;
|
|
@@ -15,7 +15,10 @@ export declare function dumpBundle(obj: any, format: BundleOutputFormat, derefer
|
|
|
15
15
|
export declare function saveBundle(filename: string, output: string): void;
|
|
16
16
|
export declare function promptUser(query: string, hideUserInput?: boolean): Promise<string>;
|
|
17
17
|
export declare function readYaml(filename: string): unknown;
|
|
18
|
+
export declare function writeToFileByExtension(data: unknown, filePath: string, noRefs?: boolean): void;
|
|
18
19
|
export declare function writeYaml(data: any, filename: string, noRefs?: boolean): void;
|
|
20
|
+
export declare function writeJson(data: unknown, filename: string): void;
|
|
21
|
+
export declare function getAndValidateFileExtension(fileName: string): NonNullable<OutputExtensions>;
|
|
19
22
|
export declare function pluralize(label: string, num: number): string;
|
|
20
23
|
export declare function handleError(e: Error, ref: string): void;
|
|
21
24
|
export declare class HandledError extends Error {
|
|
@@ -43,8 +46,8 @@ export declare function sortTopLevelKeysForOas(document: Oas3Definition | Oas2De
|
|
|
43
46
|
export declare function checkIfRulesetExist(rules: typeof StyleguideConfig.prototype.rules): void;
|
|
44
47
|
export declare function cleanColors(input: string): string;
|
|
45
48
|
export declare function sendTelemetry(argv: Arguments | undefined, exit_code: ExitCode, has_config: boolean | undefined): Promise<void>;
|
|
46
|
-
export
|
|
47
|
-
export
|
|
49
|
+
export type ExitCode = 0 | 1 | 2;
|
|
50
|
+
export type Analytics = {
|
|
48
51
|
event: string;
|
|
49
52
|
event_time: string;
|
|
50
53
|
logged_in: boolean;
|