@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
|
@@ -31,7 +31,7 @@ describe('push', () => {
|
|
|
31
31
|
jest.spyOn(process.stdout, 'write').mockImplementation(() => true);
|
|
32
32
|
});
|
|
33
33
|
it('pushes definition', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
yield push_1.handlePush({
|
|
34
|
+
yield (0, push_1.handlePush)({
|
|
35
35
|
upsert: true,
|
|
36
36
|
api: 'spec.json',
|
|
37
37
|
destination: '@org/my-api@1.0.0',
|
|
@@ -56,7 +56,7 @@ describe('push', () => {
|
|
|
56
56
|
});
|
|
57
57
|
}));
|
|
58
58
|
it('fails if jobId value is an empty string', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
yield push_1.handlePush({
|
|
59
|
+
yield (0, push_1.handlePush)({
|
|
60
60
|
upsert: true,
|
|
61
61
|
api: 'spec.json',
|
|
62
62
|
destination: '@org/my-api@1.0.0',
|
|
@@ -68,7 +68,7 @@ describe('push', () => {
|
|
|
68
68
|
expect(utils_1.exitWithError).toBeCalledTimes(1);
|
|
69
69
|
}));
|
|
70
70
|
it('fails if batchSize value is less than 2', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
yield push_1.handlePush({
|
|
71
|
+
yield (0, push_1.handlePush)({
|
|
72
72
|
upsert: true,
|
|
73
73
|
api: 'spec.json',
|
|
74
74
|
destination: '@org/my-api@1.0.0',
|
|
@@ -84,7 +84,7 @@ describe('push', () => {
|
|
|
84
84
|
fs.statSync.mockImplementation(() => {
|
|
85
85
|
return { isDirectory: () => false, size: 10 };
|
|
86
86
|
});
|
|
87
|
-
yield push_1.handlePush({
|
|
87
|
+
yield (0, push_1.handlePush)({
|
|
88
88
|
upsert: true,
|
|
89
89
|
api: 'spec.json',
|
|
90
90
|
destination: '@org/my-api@1.0.0',
|
|
@@ -103,7 +103,7 @@ describe('push', () => {
|
|
|
103
103
|
expect(redoclyClient.registryApi.prepareFileUpload).toBeCalledTimes(3);
|
|
104
104
|
}));
|
|
105
105
|
it('push should fail if organization not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
yield push_1.handlePush({
|
|
106
|
+
yield (0, push_1.handlePush)({
|
|
107
107
|
upsert: true,
|
|
108
108
|
api: 'spec.json',
|
|
109
109
|
destination: 'test@v1',
|
|
@@ -117,7 +117,7 @@ describe('push', () => {
|
|
|
117
117
|
}));
|
|
118
118
|
it('push should work with organization in config', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
119
|
const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org' });
|
|
120
|
-
yield push_1.handlePush({
|
|
120
|
+
yield (0, push_1.handlePush)({
|
|
121
121
|
upsert: true,
|
|
122
122
|
api: 'spec.json',
|
|
123
123
|
destination: 'my-api@1.0.0',
|
|
@@ -142,7 +142,7 @@ describe('push', () => {
|
|
|
142
142
|
}));
|
|
143
143
|
it('push should work if destination not provided but api in config is provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
144
|
const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org', apis: { 'my-api@1.0.0': { root: 'path' } } });
|
|
145
|
-
yield push_1.handlePush({
|
|
145
|
+
yield (0, push_1.handlePush)({
|
|
146
146
|
upsert: true,
|
|
147
147
|
branchName: 'test',
|
|
148
148
|
public: true,
|
|
@@ -153,7 +153,7 @@ describe('push', () => {
|
|
|
153
153
|
}));
|
|
154
154
|
it('push should fail if apis not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
155
|
const mockConfig = { organization: 'test_org', apis: {} };
|
|
156
|
-
yield push_1.handlePush({
|
|
156
|
+
yield (0, push_1.handlePush)({
|
|
157
157
|
upsert: true,
|
|
158
158
|
branchName: 'test',
|
|
159
159
|
public: true,
|
|
@@ -165,7 +165,7 @@ describe('push', () => {
|
|
|
165
165
|
}));
|
|
166
166
|
it('push should fail if destination not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
167
167
|
const mockConfig = { organization: 'test_org', apis: {} };
|
|
168
|
-
yield push_1.handlePush({
|
|
168
|
+
yield (0, push_1.handlePush)({
|
|
169
169
|
upsert: true,
|
|
170
170
|
api: 'api.yaml',
|
|
171
171
|
branchName: 'test',
|
|
@@ -178,7 +178,7 @@ describe('push', () => {
|
|
|
178
178
|
}));
|
|
179
179
|
it('push should fail if destination format is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
180
|
const mockConfig = { organization: 'test_org', apis: {} };
|
|
181
|
-
yield push_1.handlePush({
|
|
181
|
+
yield (0, push_1.handlePush)({
|
|
182
182
|
upsert: true,
|
|
183
183
|
destination: 'name/v1',
|
|
184
184
|
branchName: 'test',
|
|
@@ -186,12 +186,12 @@ describe('push', () => {
|
|
|
186
186
|
'job-id': '123',
|
|
187
187
|
'batch-size': 2,
|
|
188
188
|
}, mockConfig);
|
|
189
|
-
expect(utils_1.exitWithError).toHaveBeenCalledWith(`Destination argument value is not valid, please use the right format: ${colorette_1.yellow('<api-name@api-version>')}`);
|
|
189
|
+
expect(utils_1.exitWithError).toHaveBeenCalledWith(`Destination argument value is not valid, please use the right format: ${(0, colorette_1.yellow)('<api-name@api-version>')}`);
|
|
190
190
|
}));
|
|
191
191
|
it('push should work and encode name with spaces', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
192
|
const encodeURIComponentSpy = jest.spyOn(global, 'encodeURIComponent');
|
|
193
193
|
const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org', apis: { 'my test api@v1': { root: 'path' } } });
|
|
194
|
-
yield push_1.handlePush({
|
|
194
|
+
yield (0, push_1.handlePush)({
|
|
195
195
|
upsert: true,
|
|
196
196
|
destination: 'my test api@v1',
|
|
197
197
|
branchName: 'test',
|
|
@@ -206,7 +206,7 @@ describe('push', () => {
|
|
|
206
206
|
describe('transformPush', () => {
|
|
207
207
|
it('should adapt the existing syntax', () => {
|
|
208
208
|
const cb = jest.fn();
|
|
209
|
-
push_1.transformPush(cb)({
|
|
209
|
+
(0, push_1.transformPush)(cb)({
|
|
210
210
|
api: 'openapi.yaml',
|
|
211
211
|
maybeDestination: '@testing_org/main@v1',
|
|
212
212
|
}, {});
|
|
@@ -217,7 +217,7 @@ describe('transformPush', () => {
|
|
|
217
217
|
});
|
|
218
218
|
it('should adapt the existing syntax (including branchName)', () => {
|
|
219
219
|
const cb = jest.fn();
|
|
220
|
-
push_1.transformPush(cb)({
|
|
220
|
+
(0, push_1.transformPush)(cb)({
|
|
221
221
|
api: 'openapi.yaml',
|
|
222
222
|
maybeDestination: '@testing_org/main@v1',
|
|
223
223
|
maybeBranchName: 'other',
|
|
@@ -230,7 +230,7 @@ describe('transformPush', () => {
|
|
|
230
230
|
});
|
|
231
231
|
it('should use --branch option firstly', () => {
|
|
232
232
|
const cb = jest.fn();
|
|
233
|
-
push_1.transformPush(cb)({
|
|
233
|
+
(0, push_1.transformPush)(cb)({
|
|
234
234
|
api: 'openapi.yaml',
|
|
235
235
|
maybeDestination: '@testing_org/main@v1',
|
|
236
236
|
maybeBranchName: 'other',
|
|
@@ -244,7 +244,7 @@ describe('transformPush', () => {
|
|
|
244
244
|
});
|
|
245
245
|
it('should work for a destination only', () => {
|
|
246
246
|
const cb = jest.fn();
|
|
247
|
-
push_1.transformPush(cb)({
|
|
247
|
+
(0, push_1.transformPush)(cb)({
|
|
248
248
|
api: '@testing_org/main@v1',
|
|
249
249
|
}, {});
|
|
250
250
|
expect(cb).toBeCalledWith({
|
|
@@ -253,7 +253,7 @@ describe('transformPush', () => {
|
|
|
253
253
|
});
|
|
254
254
|
it('should work for a api only', () => {
|
|
255
255
|
const cb = jest.fn();
|
|
256
|
-
push_1.transformPush(cb)({
|
|
256
|
+
(0, push_1.transformPush)(cb)({
|
|
257
257
|
api: 'test.yaml',
|
|
258
258
|
}, {});
|
|
259
259
|
expect(cb).toBeCalledWith({
|
|
@@ -262,7 +262,7 @@ describe('transformPush', () => {
|
|
|
262
262
|
});
|
|
263
263
|
it('should accept aliases for the old syntax', () => {
|
|
264
264
|
const cb = jest.fn();
|
|
265
|
-
push_1.transformPush(cb)({
|
|
265
|
+
(0, push_1.transformPush)(cb)({
|
|
266
266
|
api: 'alias',
|
|
267
267
|
maybeDestination: '@testing_org/main@v1',
|
|
268
268
|
}, {});
|
|
@@ -273,7 +273,7 @@ describe('transformPush', () => {
|
|
|
273
273
|
});
|
|
274
274
|
it('should use --job-id option firstly', () => {
|
|
275
275
|
const cb = jest.fn();
|
|
276
|
-
push_1.transformPush(cb)({
|
|
276
|
+
(0, push_1.transformPush)(cb)({
|
|
277
277
|
'batch-id': 'b-123',
|
|
278
278
|
'job-id': 'j-123',
|
|
279
279
|
api: 'test',
|
|
@@ -290,60 +290,60 @@ describe('transformPush', () => {
|
|
|
290
290
|
});
|
|
291
291
|
it('should accept no arguments at all', () => {
|
|
292
292
|
const cb = jest.fn();
|
|
293
|
-
push_1.transformPush(cb)({}, {});
|
|
293
|
+
(0, push_1.transformPush)(cb)({}, {});
|
|
294
294
|
expect(cb).toBeCalledWith({}, {});
|
|
295
295
|
});
|
|
296
296
|
});
|
|
297
297
|
describe('getDestinationProps', () => {
|
|
298
298
|
it('should get valid destination props for the full destination syntax', () => {
|
|
299
|
-
expect(push_1.getDestinationProps('@testing_org/main@v1', 'org-from-config')).toEqual({
|
|
299
|
+
expect((0, push_1.getDestinationProps)('@testing_org/main@v1', 'org-from-config')).toEqual({
|
|
300
300
|
organizationId: 'testing_org',
|
|
301
301
|
name: 'main',
|
|
302
302
|
version: 'v1',
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
305
|
it('should fallback the organizationId from a config for the short destination syntax', () => {
|
|
306
|
-
expect(push_1.getDestinationProps('main@v1', 'org-from-config')).toEqual({
|
|
306
|
+
expect((0, push_1.getDestinationProps)('main@v1', 'org-from-config')).toEqual({
|
|
307
307
|
organizationId: 'org-from-config',
|
|
308
308
|
name: 'main',
|
|
309
309
|
version: 'v1',
|
|
310
310
|
});
|
|
311
311
|
});
|
|
312
312
|
it('should fallback the organizationId from a config if no destination provided', () => {
|
|
313
|
-
expect(push_1.getDestinationProps(undefined, 'org-from-config')).toEqual({
|
|
313
|
+
expect((0, push_1.getDestinationProps)(undefined, 'org-from-config')).toEqual({
|
|
314
314
|
organizationId: 'org-from-config',
|
|
315
315
|
});
|
|
316
316
|
});
|
|
317
317
|
it('should return empty organizationId if there is no one found', () => {
|
|
318
|
-
expect(push_1.getDestinationProps('main@v1', undefined)).toEqual({
|
|
318
|
+
expect((0, push_1.getDestinationProps)('main@v1', undefined)).toEqual({
|
|
319
319
|
organizationId: undefined,
|
|
320
320
|
name: 'main',
|
|
321
321
|
version: 'v1',
|
|
322
322
|
});
|
|
323
323
|
});
|
|
324
324
|
it('should return organizationId from destination string', () => {
|
|
325
|
-
expect(push_1.getDestinationProps('@test-org/main@main-v1', undefined)).toEqual({
|
|
325
|
+
expect((0, push_1.getDestinationProps)('@test-org/main@main-v1', undefined)).toEqual({
|
|
326
326
|
organizationId: 'test-org',
|
|
327
327
|
name: 'main',
|
|
328
328
|
version: 'main-v1',
|
|
329
329
|
});
|
|
330
330
|
});
|
|
331
331
|
it('should return organizationId, version and empty name from destination string', () => {
|
|
332
|
-
expect(push_1.getDestinationProps('@test_org/@main_v1', undefined)).toEqual({
|
|
332
|
+
expect((0, push_1.getDestinationProps)('@test_org/@main_v1', undefined)).toEqual({
|
|
333
333
|
organizationId: 'test_org',
|
|
334
334
|
name: '',
|
|
335
335
|
version: 'main_v1',
|
|
336
336
|
});
|
|
337
337
|
});
|
|
338
338
|
it('should validate organizationId with space and version with dot', () => {
|
|
339
|
-
expect(push_1.getDestinationProps('@test org/simple_name@main.v1', undefined)).toEqual({
|
|
339
|
+
expect((0, push_1.getDestinationProps)('@test org/simple_name@main.v1', undefined)).toEqual({
|
|
340
340
|
organizationId: 'test org',
|
|
341
341
|
name: 'simple_name',
|
|
342
342
|
version: 'main.v1',
|
|
343
343
|
});
|
|
344
344
|
});
|
|
345
345
|
it('should not work with "@" in destination name', () => {
|
|
346
|
-
expect(push_1.getDestinationProps('@test org/simple@name@main.v1', undefined)).toEqual({
|
|
346
|
+
expect((0, push_1.getDestinationProps)('@test org/simple@name@main.v1', undefined)).toEqual({
|
|
347
347
|
organizationId: undefined,
|
|
348
348
|
name: undefined,
|
|
349
349
|
version: undefined,
|
|
@@ -362,9 +362,9 @@ describe('getApiRoot', () => {
|
|
|
362
362
|
},
|
|
363
363
|
};
|
|
364
364
|
it('should resolve the correct api for a valid name & version', () => {
|
|
365
|
-
expect(push_1.getApiRoot({ name: 'main', version: 'v1', config })).toEqual('openapi.yaml');
|
|
365
|
+
expect((0, push_1.getApiRoot)({ name: 'main', version: 'v1', config })).toEqual('openapi.yaml');
|
|
366
366
|
});
|
|
367
367
|
it('should resolve the latest version of api if there is no matching version', () => {
|
|
368
|
-
expect(push_1.getApiRoot({ name: 'main', version: 'latest', config })).toEqual('latest.yaml');
|
|
368
|
+
expect((0, push_1.getApiRoot)({ name: 'main', version: 'latest', config })).toEqual('latest.yaml');
|
|
369
369
|
});
|
|
370
370
|
});
|
|
@@ -21,7 +21,7 @@ describe('fetchWithTimeout', () => {
|
|
|
21
21
|
global.AbortController = undefined;
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
global.setTimeout = jest.fn();
|
|
24
|
-
yield fetch_with_timeout_1.default('url', { method: 'GET' });
|
|
24
|
+
yield (0, fetch_with_timeout_1.default)('url', { method: 'GET' });
|
|
25
25
|
expect(node_fetch_1.default).toHaveBeenCalledWith('url', { method: 'GET' });
|
|
26
26
|
expect(global.setTimeout).toHaveBeenCalledTimes(0);
|
|
27
27
|
}));
|
|
@@ -30,7 +30,7 @@ describe('fetchWithTimeout', () => {
|
|
|
30
30
|
// @ts-ignore
|
|
31
31
|
global.setTimeout = jest.fn();
|
|
32
32
|
global.clearTimeout = jest.fn();
|
|
33
|
-
yield fetch_with_timeout_1.default('url');
|
|
33
|
+
yield (0, fetch_with_timeout_1.default)('url');
|
|
34
34
|
expect(global.setTimeout).toHaveBeenCalledTimes(1);
|
|
35
35
|
expect(node_fetch_1.default).toHaveBeenCalledWith('url', { signal: 'something' });
|
|
36
36
|
expect(global.clearTimeout).toHaveBeenCalledTimes(1);
|
|
@@ -31,7 +31,7 @@ describe('isSubdir', () => {
|
|
|
31
31
|
['/foo', './bar', false],
|
|
32
32
|
['/foo', '/foo/..bar', true],
|
|
33
33
|
].forEach(([parent, child, expectRes]) => {
|
|
34
|
-
expect(utils_1.isSubdir(parent, child)).toBe(expectRes);
|
|
34
|
+
expect((0, utils_1.isSubdir)(parent, child)).toBe(expectRes);
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
it('can correctly determine if subdir for windows-based paths', () => {
|
|
@@ -42,7 +42,7 @@ describe('isSubdir', () => {
|
|
|
42
42
|
['C:\\Foo', 'C:\\Bar', false],
|
|
43
43
|
['C:\\Foo', 'D:\\Foo\\Bar', false],
|
|
44
44
|
].forEach(([parent, child, expectRes]) => {
|
|
45
|
-
expect(utils_1.isSubdir(parent, child)).toBe(expectRes);
|
|
45
|
+
expect((0, utils_1.isSubdir)(parent, child)).toBe(expectRes);
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
afterEach(() => {
|
|
@@ -51,14 +51,14 @@ describe('isSubdir', () => {
|
|
|
51
51
|
});
|
|
52
52
|
describe('pathToFilename', () => {
|
|
53
53
|
it('should use correct path separator', () => {
|
|
54
|
-
const processedPath = utils_1.pathToFilename('/user/createWithList', '_');
|
|
54
|
+
const processedPath = (0, utils_1.pathToFilename)('/user/createWithList', '_');
|
|
55
55
|
expect(processedPath).toEqual('user_createWithList');
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
describe('getFallbackApisOrExit', () => {
|
|
59
59
|
it('should find alias by filename', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
60
|
fs_1.existsSync.mockImplementationOnce(() => true);
|
|
61
|
-
const entry = yield utils_1.getFallbackApisOrExit(['./test.yaml'], {
|
|
61
|
+
const entry = yield (0, utils_1.getFallbackApisOrExit)(['./test.yaml'], {
|
|
62
62
|
apis: {
|
|
63
63
|
main: {
|
|
64
64
|
root: 'test.yaml',
|
|
@@ -82,22 +82,17 @@ describe('printConfigLintTotals', () => {
|
|
|
82
82
|
jest.spyOn(process.stderr, 'write').mockImplementation(() => true);
|
|
83
83
|
});
|
|
84
84
|
it('should print errors if such exist', () => {
|
|
85
|
-
utils_1.printConfigLintTotals(totalProblemsMock);
|
|
86
|
-
expect(process.stderr.write).toHaveBeenCalledWith('❌ Your config has 1 error
|
|
87
|
-
expect(redColoretteMocks).toHaveBeenCalledWith('❌ Your config has 1 error
|
|
88
|
-
});
|
|
89
|
-
it('should print warnign and error', () => {
|
|
90
|
-
utils_1.printConfigLintTotals(Object.assign(Object.assign({}, totalProblemsMock), { warnings: 2 }));
|
|
91
|
-
expect(process.stderr.write).toHaveBeenCalledWith('❌ Your config has 1 error and 2 warnings.\n');
|
|
92
|
-
expect(redColoretteMocks).toHaveBeenCalledWith('❌ Your config has 1 error and 2 warnings.\n');
|
|
85
|
+
(0, utils_1.printConfigLintTotals)(totalProblemsMock);
|
|
86
|
+
expect(process.stderr.write).toHaveBeenCalledWith('❌ Your config has 1 error.');
|
|
87
|
+
expect(redColoretteMocks).toHaveBeenCalledWith('❌ Your config has 1 error.');
|
|
93
88
|
});
|
|
94
89
|
it('should print warnign if no error', () => {
|
|
95
|
-
utils_1.printConfigLintTotals(Object.assign(Object.assign({}, totalProblemsMock), { errors: 0, warnings: 2 }));
|
|
96
|
-
expect(process.stderr.write).toHaveBeenCalledWith('
|
|
97
|
-
expect(yellowColoretteMocks).toHaveBeenCalledWith('
|
|
90
|
+
(0, utils_1.printConfigLintTotals)(Object.assign(Object.assign({}, totalProblemsMock), { errors: 0, warnings: 2 }));
|
|
91
|
+
expect(process.stderr.write).toHaveBeenCalledWith('⚠️ Your config has 2 warnings.\n');
|
|
92
|
+
expect(yellowColoretteMocks).toHaveBeenCalledWith('⚠️ Your config has 2 warnings.\n');
|
|
98
93
|
});
|
|
99
94
|
it('should print nothing if no error and no warnings', () => {
|
|
100
|
-
const result = utils_1.printConfigLintTotals(Object.assign(Object.assign({}, totalProblemsMock), { errors: 0 }));
|
|
95
|
+
const result = (0, utils_1.printConfigLintTotals)(Object.assign(Object.assign({}, totalProblemsMock), { errors: 0 }));
|
|
101
96
|
expect(result).toBeUndefined();
|
|
102
97
|
expect(process.stderr.write).toHaveBeenCalledTimes(0);
|
|
103
98
|
expect(yellowColoretteMocks).toHaveBeenCalledTimes(0);
|
|
@@ -129,7 +124,7 @@ describe('getFallbackApisOrExit', () => {
|
|
|
129
124
|
};
|
|
130
125
|
expect.assertions(1);
|
|
131
126
|
try {
|
|
132
|
-
yield utils_1.getFallbackApisOrExit([''], apisConfig);
|
|
127
|
+
yield (0, utils_1.getFallbackApisOrExit)([''], apisConfig);
|
|
133
128
|
}
|
|
134
129
|
catch (e) {
|
|
135
130
|
expect(e.message).toEqual('Path cannot be empty.');
|
|
@@ -139,7 +134,7 @@ describe('getFallbackApisOrExit', () => {
|
|
|
139
134
|
fs_1.existsSync.mockImplementationOnce(() => false);
|
|
140
135
|
expect.assertions(3);
|
|
141
136
|
try {
|
|
142
|
-
yield utils_1.getFallbackApisOrExit(undefined, config);
|
|
137
|
+
yield (0, utils_1.getFallbackApisOrExit)(undefined, config);
|
|
143
138
|
}
|
|
144
139
|
catch (e) {
|
|
145
140
|
expect(process.stderr.write).toHaveBeenCalledWith('\nsomeFile.yaml does not exist or is invalid.\n\n');
|
|
@@ -150,7 +145,7 @@ describe('getFallbackApisOrExit', () => {
|
|
|
150
145
|
it('should return valid array with results if such file exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
146
|
fs_1.existsSync.mockImplementationOnce(() => true);
|
|
152
147
|
jest.spyOn(path, 'resolve').mockImplementationOnce((_, path) => path);
|
|
153
|
-
const result = yield utils_1.getFallbackApisOrExit(undefined, config);
|
|
148
|
+
const result = yield (0, utils_1.getFallbackApisOrExit)(undefined, config);
|
|
154
149
|
expect(process.stderr.write).toHaveBeenCalledTimes(0);
|
|
155
150
|
expect(process.exit).toHaveBeenCalledTimes(0);
|
|
156
151
|
expect(result).toStrictEqual([
|
|
@@ -167,7 +162,7 @@ describe('getFallbackApisOrExit', () => {
|
|
|
167
162
|
fs_1.existsSync.mockImplementationOnce(() => false);
|
|
168
163
|
expect.assertions(3);
|
|
169
164
|
try {
|
|
170
|
-
yield utils_1.getFallbackApisOrExit(['someFile.yaml'], apisConfig);
|
|
165
|
+
yield (0, utils_1.getFallbackApisOrExit)(['someFile.yaml'], apisConfig);
|
|
171
166
|
}
|
|
172
167
|
catch (e) {
|
|
173
168
|
expect(process.stderr.write).toHaveBeenCalledWith('\nsomeFile.yaml does not exist or is invalid.\n\n');
|
|
@@ -182,7 +177,7 @@ describe('getFallbackApisOrExit', () => {
|
|
|
182
177
|
fs_1.existsSync.mockImplementationOnce(() => false);
|
|
183
178
|
expect.assertions(3);
|
|
184
179
|
try {
|
|
185
|
-
yield utils_1.getFallbackApisOrExit(['someFile.yaml', 'someFile2.yaml'], apisConfig);
|
|
180
|
+
yield (0, utils_1.getFallbackApisOrExit)(['someFile.yaml', 'someFile2.yaml'], apisConfig);
|
|
186
181
|
}
|
|
187
182
|
catch (e) {
|
|
188
183
|
expect(process.stderr.write).toHaveBeenCalledWith('\nsomeFile.yaml does not exist or is invalid.\n\n');
|
|
@@ -199,7 +194,7 @@ describe('getFallbackApisOrExit', () => {
|
|
|
199
194
|
const existSyncMock = fs_1.existsSync.mockImplementation((path) => path.endsWith('someFile.yaml'));
|
|
200
195
|
expect.assertions(4);
|
|
201
196
|
try {
|
|
202
|
-
yield utils_1.getFallbackApisOrExit(undefined, configStub);
|
|
197
|
+
yield (0, utils_1.getFallbackApisOrExit)(undefined, configStub);
|
|
203
198
|
}
|
|
204
199
|
catch (e) {
|
|
205
200
|
expect(process.stderr.write).toHaveBeenCalledWith('\nnotExist.yaml does not exist or is invalid.\n\n');
|
|
@@ -220,7 +215,7 @@ describe('getFallbackApisOrExit', () => {
|
|
|
220
215
|
},
|
|
221
216
|
},
|
|
222
217
|
};
|
|
223
|
-
const result = yield utils_1.getFallbackApisOrExit(undefined, apisConfig);
|
|
218
|
+
const result = yield (0, utils_1.getFallbackApisOrExit)(undefined, apisConfig);
|
|
224
219
|
expect(process.stderr.write).toHaveBeenCalledTimes(0);
|
|
225
220
|
expect(result).toStrictEqual([
|
|
226
221
|
{
|
|
@@ -241,10 +236,10 @@ describe('langToExt', () => {
|
|
|
241
236
|
['js', '.js'],
|
|
242
237
|
['python', '.py'],
|
|
243
238
|
])('should infer file extension from lang - %s', (lang, expected) => {
|
|
244
|
-
expect(utils_1.langToExt(lang)).toBe(expected);
|
|
239
|
+
expect((0, utils_1.langToExt)(lang)).toBe(expected);
|
|
245
240
|
});
|
|
246
241
|
it('should ignore case when inferring file extension', () => {
|
|
247
|
-
expect(utils_1.langToExt('JavaScript')).toBe('.js');
|
|
242
|
+
expect((0, utils_1.langToExt)('JavaScript')).toBe('.js');
|
|
248
243
|
});
|
|
249
244
|
});
|
|
250
245
|
describe('sorTopLevelKeysForOas', () => {
|
|
@@ -275,7 +270,7 @@ describe('sorTopLevelKeysForOas', () => {
|
|
|
275
270
|
'x-webhooks',
|
|
276
271
|
'components',
|
|
277
272
|
];
|
|
278
|
-
const result = utils_1.sortTopLevelKeysForOas(openApi);
|
|
273
|
+
const result = (0, utils_1.sortTopLevelKeysForOas)(openApi);
|
|
279
274
|
Object.keys(result).forEach((key, index) => {
|
|
280
275
|
expect(key).toEqual(orderedKeys[index]);
|
|
281
276
|
});
|
|
@@ -315,7 +310,7 @@ describe('sorTopLevelKeysForOas', () => {
|
|
|
315
310
|
'responses',
|
|
316
311
|
'securityDefinitions',
|
|
317
312
|
];
|
|
318
|
-
const result = utils_1.sortTopLevelKeysForOas(openApi);
|
|
313
|
+
const result = (0, utils_1.sortTopLevelKeysForOas)(openApi);
|
|
319
314
|
Object.keys(result).forEach((key, index) => {
|
|
320
315
|
expect(key).toEqual(orderedKeys[index]);
|
|
321
316
|
});
|
|
@@ -336,31 +331,31 @@ describe('handleErrors', () => {
|
|
|
336
331
|
});
|
|
337
332
|
it('should handle ResolveError', () => {
|
|
338
333
|
const resolveError = new openapi_core_1.ResolveError(new Error('File not found'));
|
|
339
|
-
expect(() => utils_1.handleError(resolveError, ref)).toThrowError(utils_1.HandledError);
|
|
334
|
+
expect(() => (0, utils_1.handleError)(resolveError, ref)).toThrowError(utils_1.HandledError);
|
|
340
335
|
expect(redColoretteMocks).toHaveBeenCalledTimes(1);
|
|
341
336
|
expect(process.stderr.write).toHaveBeenCalledWith(`Failed to resolve API description at openapi/test.yaml:\n\n - File not found.\n\n`);
|
|
342
337
|
});
|
|
343
338
|
it('should handle YamlParseError', () => {
|
|
344
339
|
const yamlParseError = new openapi_core_1.YamlParseError(new Error('Invalid yaml'), {});
|
|
345
|
-
expect(() => utils_1.handleError(yamlParseError, ref)).toThrowError(utils_1.HandledError);
|
|
340
|
+
expect(() => (0, utils_1.handleError)(yamlParseError, ref)).toThrowError(utils_1.HandledError);
|
|
346
341
|
expect(redColoretteMocks).toHaveBeenCalledTimes(1);
|
|
347
342
|
expect(process.stderr.write).toHaveBeenCalledWith(`Failed to parse API description at openapi/test.yaml:\n\n - Invalid yaml.\n\n`);
|
|
348
343
|
});
|
|
349
344
|
it('should handle CircularJSONNotSupportedError', () => {
|
|
350
345
|
const circularError = new utils_1.CircularJSONNotSupportedError(new Error('Circular json'));
|
|
351
|
-
expect(() => utils_1.handleError(circularError, ref)).toThrowError(utils_1.HandledError);
|
|
346
|
+
expect(() => (0, utils_1.handleError)(circularError, ref)).toThrowError(utils_1.HandledError);
|
|
352
347
|
expect(process.stderr.write).toHaveBeenCalledWith(`Detected circular reference which can't be converted to JSON.\n` +
|
|
353
|
-
`Try to use ${colorette_1.blue('yaml')} output or remove ${colorette_1.blue('--dereferenced')}.\n\n`);
|
|
348
|
+
`Try to use ${(0, colorette_1.blue)('yaml')} output or remove ${(0, colorette_1.blue)('--dereferenced')}.\n\n`);
|
|
354
349
|
});
|
|
355
350
|
it('should handle SyntaxError', () => {
|
|
356
351
|
const testError = new SyntaxError('Unexpected identifier');
|
|
357
352
|
testError.stack = 'test stack';
|
|
358
|
-
expect(() => utils_1.handleError(testError, ref)).toThrowError(utils_1.HandledError);
|
|
353
|
+
expect(() => (0, utils_1.handleError)(testError, ref)).toThrowError(utils_1.HandledError);
|
|
359
354
|
expect(process.stderr.write).toHaveBeenCalledWith('Syntax error: Unexpected identifier test stack\n\n');
|
|
360
355
|
});
|
|
361
356
|
it('should throw unknown error', () => {
|
|
362
357
|
const testError = new Error('Test error');
|
|
363
|
-
expect(() => utils_1.handleError(testError, ref)).toThrowError(utils_1.HandledError);
|
|
358
|
+
expect(() => (0, utils_1.handleError)(testError, ref)).toThrowError(utils_1.HandledError);
|
|
364
359
|
expect(process.stderr.write).toHaveBeenCalledWith(`Something went wrong when processing openapi/test.yaml:\n\n - Test error.\n\n`);
|
|
365
360
|
});
|
|
366
361
|
});
|
|
@@ -378,7 +373,7 @@ describe('checkIfRulesetExist', () => {
|
|
|
378
373
|
oas3_1: {},
|
|
379
374
|
async2: {},
|
|
380
375
|
};
|
|
381
|
-
expect(() => utils_1.checkIfRulesetExist(rules)).toThrowError('⚠️ No rules were configured. Learn how to configure rules: https://redocly.com/docs/cli/rules/');
|
|
376
|
+
expect(() => (0, utils_1.checkIfRulesetExist)(rules)).toThrowError('⚠️ No rules were configured. Learn how to configure rules: https://redocly.com/docs/cli/rules/');
|
|
382
377
|
});
|
|
383
378
|
it('should not throw an error if rules are provided', () => {
|
|
384
379
|
const rules = {
|
|
@@ -386,13 +381,13 @@ describe('checkIfRulesetExist', () => {
|
|
|
386
381
|
oas3_0: {},
|
|
387
382
|
oas3_1: {},
|
|
388
383
|
};
|
|
389
|
-
utils_1.checkIfRulesetExist(rules);
|
|
384
|
+
(0, utils_1.checkIfRulesetExist)(rules);
|
|
390
385
|
});
|
|
391
386
|
});
|
|
392
387
|
describe('cleanColors', () => {
|
|
393
388
|
it('should remove colors from string', () => {
|
|
394
|
-
const stringWithColors = `String for ${colorette_1.red('test')}`;
|
|
395
|
-
const result = utils_1.cleanColors(stringWithColors);
|
|
389
|
+
const stringWithColors = `String for ${(0, colorette_1.red)('test')}`;
|
|
390
|
+
const result = (0, utils_1.cleanColors)(stringWithColors);
|
|
396
391
|
expect(result).not.toMatch(/\x1b\[\d+m/g);
|
|
397
392
|
});
|
|
398
393
|
});
|
|
@@ -414,7 +409,7 @@ describe('cleanArgs', () => {
|
|
|
414
409
|
apis: ['main@v1', 'fixtures/openapi.yaml', 'http://some.url/openapi.yaml'],
|
|
415
410
|
format: 'codeframe',
|
|
416
411
|
};
|
|
417
|
-
expect(utils_1.cleanArgs(testArgs)).toEqual({
|
|
412
|
+
expect((0, utils_1.cleanArgs)(testArgs)).toEqual({
|
|
418
413
|
config: 'file-yaml',
|
|
419
414
|
apis: ['api-name@api-version', 'file-yaml', 'http://url'],
|
|
420
415
|
format: 'codeframe',
|
|
@@ -424,7 +419,7 @@ describe('cleanArgs', () => {
|
|
|
424
419
|
const testArgs = {
|
|
425
420
|
destination: '@org/name@version',
|
|
426
421
|
};
|
|
427
|
-
expect(utils_1.cleanArgs(testArgs)).toEqual({
|
|
422
|
+
expect((0, utils_1.cleanArgs)(testArgs)).toEqual({
|
|
428
423
|
destination: '@organization/api-name@api-version',
|
|
429
424
|
});
|
|
430
425
|
});
|
|
@@ -452,7 +447,7 @@ describe('cleanRawInput', () => {
|
|
|
452
447
|
'--output',
|
|
453
448
|
'fixtures',
|
|
454
449
|
];
|
|
455
|
-
expect(utils_1.cleanRawInput(rawInput)).toEqual('redocly bundle api-name@api-version file-yaml http://url --config=file-yaml --output folder');
|
|
450
|
+
expect((0, utils_1.cleanRawInput)(rawInput)).toEqual('redocly bundle api-name@api-version file-yaml http://url --config=file-yaml --output folder');
|
|
456
451
|
});
|
|
457
452
|
it('should preserve safe data from raw CLI input', () => {
|
|
458
453
|
const rawInput = [
|
|
@@ -465,6 +460,37 @@ describe('cleanRawInput', () => {
|
|
|
465
460
|
'--skip-rule',
|
|
466
461
|
'operation-4xx-response',
|
|
467
462
|
];
|
|
468
|
-
expect(utils_1.cleanRawInput(rawInput)).toEqual('redocly lint file-json --format stylish --extends=minimal --skip-rule operation-4xx-response');
|
|
463
|
+
expect((0, utils_1.cleanRawInput)(rawInput)).toEqual('redocly lint file-json --format stylish --extends=minimal --skip-rule operation-4xx-response');
|
|
464
|
+
});
|
|
465
|
+
describe('validateFileExtension', () => {
|
|
466
|
+
it('should return current file extension', () => {
|
|
467
|
+
expect((0, utils_1.getAndValidateFileExtension)('test.json')).toEqual('json');
|
|
468
|
+
});
|
|
469
|
+
it('should return yaml and print warning if file extension does not supported', () => {
|
|
470
|
+
const stderrMock = jest.spyOn(process.stderr, 'write').mockImplementation(() => true);
|
|
471
|
+
colorette_1.yellow.mockImplementation((text) => text);
|
|
472
|
+
expect((0, utils_1.getAndValidateFileExtension)('test.xml')).toEqual('yaml');
|
|
473
|
+
expect(stderrMock).toHaveBeenCalledWith(`Unsupported file extension: xml. Using yaml.\n`);
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
describe('writeToFileByExtension', () => {
|
|
477
|
+
beforeEach(() => {
|
|
478
|
+
jest.spyOn(process.stderr, 'write').mockImplementation(jest.fn());
|
|
479
|
+
colorette_1.yellow.mockImplementation((text) => text);
|
|
480
|
+
});
|
|
481
|
+
afterEach(() => {
|
|
482
|
+
jest.restoreAllMocks();
|
|
483
|
+
});
|
|
484
|
+
it('should call stringifyYaml function', () => {
|
|
485
|
+
(0, utils_1.writeToFileByExtension)('test data', 'test.yaml');
|
|
486
|
+
expect(openapi_core_1.stringifyYaml).toHaveBeenCalledWith('test data', { noRefs: false });
|
|
487
|
+
expect(process.stderr.write).toHaveBeenCalledWith(`test data`);
|
|
488
|
+
});
|
|
489
|
+
it('should call JSON.stringify function', () => {
|
|
490
|
+
const stringifySpy = jest.spyOn(JSON, 'stringify').mockImplementation((data) => data);
|
|
491
|
+
(0, utils_1.writeToFileByExtension)('test data', 'test.json');
|
|
492
|
+
expect(stringifySpy).toHaveBeenCalledWith('test data', null, 2);
|
|
493
|
+
expect(process.stderr.write).toHaveBeenCalledWith(`test data`);
|
|
494
|
+
});
|
|
469
495
|
});
|
|
470
496
|
});
|
|
@@ -29,7 +29,7 @@ describe('commandWrapper', () => {
|
|
|
29
29
|
return { telemetry: 'on', styleguide: { recommendedFallback: true } };
|
|
30
30
|
});
|
|
31
31
|
process.env.REDOCLY_TELEMETRY = 'on';
|
|
32
|
-
const wrappedHandler = wrapper_1.commandWrapper(lint_1.handleLint);
|
|
32
|
+
const wrappedHandler = (0, wrapper_1.commandWrapper)(lint_1.handleLint);
|
|
33
33
|
yield wrappedHandler({});
|
|
34
34
|
expect(lint_1.handleLint).toHaveBeenCalledTimes(1);
|
|
35
35
|
expect(utils_1.sendTelemetry).toHaveBeenCalledTimes(1);
|
|
@@ -40,7 +40,7 @@ describe('commandWrapper', () => {
|
|
|
40
40
|
return { telemetry: 'off', styleguide: { recommendedFallback: true } };
|
|
41
41
|
});
|
|
42
42
|
process.env.REDOCLY_TELEMETRY = 'on';
|
|
43
|
-
const wrappedHandler = wrapper_1.commandWrapper(lint_1.handleLint);
|
|
43
|
+
const wrappedHandler = (0, wrapper_1.commandWrapper)(lint_1.handleLint);
|
|
44
44
|
yield wrappedHandler({});
|
|
45
45
|
expect(lint_1.handleLint).toHaveBeenCalledTimes(1);
|
|
46
46
|
expect(utils_1.sendTelemetry).toHaveBeenCalledTimes(0);
|
|
@@ -51,7 +51,7 @@ describe('commandWrapper', () => {
|
|
|
51
51
|
const argv = {
|
|
52
52
|
files: filesToPush,
|
|
53
53
|
};
|
|
54
|
-
yield wrapper_1.commandWrapper(push_1.handlePush)(argv);
|
|
54
|
+
yield (0, wrapper_1.commandWrapper)(push_1.handlePush)(argv);
|
|
55
55
|
expect(loadConfigMock).toHaveBeenCalledWith(expect.objectContaining({ files: filesToPush }));
|
|
56
56
|
}));
|
|
57
57
|
});
|
|
@@ -8,7 +8,7 @@ try {
|
|
|
8
8
|
const { engines } = require(path.join(__dirname, '../package.json'));
|
|
9
9
|
const version = engines.node;
|
|
10
10
|
if (!semver.satisfies(process.version, version)) {
|
|
11
|
-
process.stderr.write(colorette_1.yellow(`\n⚠️ Warning: failed to satisfy expected node version. Expected: "${version}", Current "${process.version}"\n\n`));
|
|
11
|
+
process.stderr.write((0, colorette_1.yellow)(`\n⚠️ Warning: failed to satisfy expected node version. Expected: "${version}", Current "${process.version}"\n\n`));
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
catch (e) {
|
|
@@ -20,8 +20,8 @@ const utils_2 = require("../../utils");
|
|
|
20
20
|
const handlerBuildCommand = (argv, configFromFile) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
var _a;
|
|
22
22
|
const startedAt = perf_hooks_1.performance.now();
|
|
23
|
-
const config = openapi_core_1.getMergedConfig(configFromFile, argv.api);
|
|
24
|
-
const apis = yield utils_2.getFallbackApisOrExit(argv.api ? [argv.api] : [], config);
|
|
23
|
+
const config = (0, openapi_core_1.getMergedConfig)(configFromFile, argv.api);
|
|
24
|
+
const apis = yield (0, utils_2.getFallbackApisOrExit)(argv.api ? [argv.api] : [], config);
|
|
25
25
|
const { path: pathToApi } = apis[0];
|
|
26
26
|
const options = {
|
|
27
27
|
output: argv.o,
|
|
@@ -29,20 +29,20 @@ const handlerBuildCommand = (argv, configFromFile) => __awaiter(void 0, void 0,
|
|
|
29
29
|
disableGoogleFont: argv.disableGoogleFont,
|
|
30
30
|
templateFileName: argv.template,
|
|
31
31
|
templateOptions: argv.templateOptions || {},
|
|
32
|
-
redocOptions: utils_1.getObjectOrJSON((_a = argv.theme) === null || _a === void 0 ? void 0 : _a.openapi, config),
|
|
32
|
+
redocOptions: (0, utils_1.getObjectOrJSON)((_a = argv.theme) === null || _a === void 0 ? void 0 : _a.openapi, config),
|
|
33
33
|
};
|
|
34
34
|
const redocCurrentVersion = require('../../../package.json').dependencies.redoc.substring(1); // remove ~
|
|
35
35
|
try {
|
|
36
|
-
const elapsed = utils_2.getExecutionTime(startedAt);
|
|
37
|
-
const api = yield redoc_1.loadAndBundleSpec(openapi_core_1.isAbsoluteUrl(pathToApi) ? pathToApi : path_1.resolve(pathToApi));
|
|
38
|
-
const pageHTML = yield utils_1.getPageHTML(api, pathToApi, Object.assign(Object.assign({}, options), { redocCurrentVersion }), argv.config);
|
|
39
|
-
fs_1.mkdirSync(path_1.dirname(options.output), { recursive: true });
|
|
40
|
-
fs_1.writeFileSync(options.output, pageHTML);
|
|
36
|
+
const elapsed = (0, utils_2.getExecutionTime)(startedAt);
|
|
37
|
+
const api = yield (0, redoc_1.loadAndBundleSpec)((0, openapi_core_1.isAbsoluteUrl)(pathToApi) ? pathToApi : (0, path_1.resolve)(pathToApi));
|
|
38
|
+
const pageHTML = yield (0, utils_1.getPageHTML)(api, pathToApi, Object.assign(Object.assign({}, options), { redocCurrentVersion }), argv.config);
|
|
39
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(options.output), { recursive: true });
|
|
40
|
+
(0, fs_1.writeFileSync)(options.output, pageHTML);
|
|
41
41
|
const sizeInKiB = Math.ceil(Buffer.byteLength(pageHTML) / 1024);
|
|
42
42
|
process.stdout.write(`\n🎉 bundled successfully in: ${options.output} (${sizeInKiB} KiB) [⏱ ${elapsed}].\n`);
|
|
43
43
|
}
|
|
44
44
|
catch (e) {
|
|
45
|
-
utils_2.exitWithError(e);
|
|
45
|
+
(0, utils_2.exitWithError)(e);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
exports.handlerBuildCommand = handlerBuildCommand;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type BuildDocsOptions = {
|
|
2
2
|
watch?: boolean;
|
|
3
3
|
output?: string;
|
|
4
4
|
title?: string;
|
|
@@ -9,7 +9,7 @@ export declare type BuildDocsOptions = {
|
|
|
9
9
|
redocOptions?: any;
|
|
10
10
|
redocCurrentVersion: string;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type BuildDocsArgv = {
|
|
13
13
|
api: string;
|
|
14
14
|
o: string;
|
|
15
15
|
title?: string;
|