@redocly/cli 1.18.0 → 1.19.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 +22 -0
- package/lib/__mocks__/@redocly/openapi-core.d.ts +2 -2
- package/lib/__mocks__/@redocly/openapi-core.js +1 -0
- package/lib/__mocks__/fs.d.ts +0 -1
- package/lib/__mocks__/perf_hooks.d.ts +0 -1
- package/lib/__mocks__/redoc.d.ts +0 -1
- package/lib/__tests__/commands/build-docs.test.js +21 -23
- package/lib/__tests__/commands/bundle.test.js +21 -30
- package/lib/__tests__/commands/join.test.js +101 -70
- package/lib/__tests__/commands/lint.test.js +54 -54
- package/lib/__tests__/commands/push-region.test.js +24 -25
- package/lib/__tests__/commands/push.test.js +269 -170
- package/lib/__tests__/fetch-with-timeout.test.js +3 -12
- package/lib/__tests__/fixtures/config.d.ts +0 -1
- package/lib/__tests__/utils.test.js +32 -37
- package/lib/__tests__/wrapper.test.js +31 -20
- package/lib/cms/api/__tests__/api.client.test.js +29 -38
- package/lib/cms/api/api-client.d.ts +0 -2
- package/lib/cms/api/api-client.js +106 -127
- package/lib/cms/api/api-keys.js +1 -2
- package/lib/cms/api/domains.js +1 -2
- package/lib/cms/commands/__tests__/push-status.test.js +251 -162
- package/lib/cms/commands/__tests__/push.test.js +120 -102
- package/lib/cms/commands/__tests__/utils.test.js +12 -21
- package/lib/cms/commands/push-status.d.ts +3 -2
- package/lib/cms/commands/push-status.js +94 -106
- package/lib/cms/commands/push.d.ts +3 -2
- package/lib/cms/commands/push.js +66 -75
- package/lib/cms/commands/utils.js +20 -34
- package/lib/commands/build-docs/index.d.ts +2 -2
- package/lib/commands/build-docs/index.js +8 -17
- package/lib/commands/build-docs/utils.js +26 -38
- package/lib/commands/bundle.d.ts +2 -2
- package/lib/commands/bundle.js +70 -94
- package/lib/commands/join.d.ts +2 -2
- package/lib/commands/join.js +377 -390
- package/lib/commands/lint.d.ts +2 -2
- package/lib/commands/lint.js +70 -78
- package/lib/commands/login.d.ts +3 -2
- package/lib/commands/login.js +9 -21
- package/lib/commands/preview-docs/index.d.ts +2 -2
- package/lib/commands/preview-docs/index.js +92 -106
- package/lib/commands/preview-docs/preview-server/preview-server.js +64 -76
- package/lib/commands/preview-docs/preview-server/server.d.ts +0 -3
- package/lib/commands/preview-docs/preview-server/server.js +6 -6
- package/lib/commands/preview-project/index.d.ts +2 -1
- package/lib/commands/preview-project/index.js +5 -14
- package/lib/commands/push.d.ts +8 -11
- package/lib/commands/push.js +177 -195
- package/lib/commands/split/__tests__/index.test.js +31 -25
- package/lib/commands/split/index.d.ts +2 -1
- package/lib/commands/split/index.js +22 -35
- package/lib/commands/stats.d.ts +2 -2
- package/lib/commands/stats.js +34 -45
- package/lib/index.js +32 -46
- package/lib/types.d.ts +2 -2
- package/lib/utils/__mocks__/miscellaneous.d.ts +0 -1
- package/lib/utils/fetch-with-timeout.js +7 -12
- package/lib/utils/getCommandNameFromArgs.js +2 -4
- package/lib/utils/js-utils.js +6 -7
- package/lib/utils/miscellaneous.d.ts +9 -5
- package/lib/utils/miscellaneous.js +150 -160
- package/lib/utils/update-version-notifier.js +4 -13
- package/lib/wrapper.d.ts +9 -2
- package/lib/wrapper.js +27 -16
- package/package.json +5 -3
- package/src/__mocks__/@redocly/openapi-core.ts +1 -0
- package/src/__tests__/commands/build-docs.test.ts +5 -4
- package/src/__tests__/commands/join.test.ts +51 -51
- package/src/__tests__/commands/push-region.test.ts +10 -8
- package/src/__tests__/commands/push.test.ts +127 -102
- package/src/__tests__/utils.test.ts +1 -0
- package/src/__tests__/wrapper.test.ts +24 -2
- package/src/cms/commands/__tests__/push-status.test.ts +70 -56
- package/src/cms/commands/__tests__/push.test.ts +30 -24
- package/src/cms/commands/push-status.ts +8 -7
- package/src/cms/commands/push.ts +19 -13
- package/src/commands/build-docs/index.ts +10 -5
- package/src/commands/bundle.ts +14 -6
- package/src/commands/join.ts +10 -6
- package/src/commands/lint.ts +20 -9
- package/src/commands/login.ts +4 -2
- package/src/commands/preview-docs/index.ts +6 -1
- package/src/commands/preview-project/index.ts +5 -4
- package/src/commands/push.ts +14 -16
- package/src/commands/split/__tests__/index.test.ts +17 -6
- package/src/commands/split/index.ts +6 -4
- package/src/commands/stats.ts +4 -2
- package/src/utils/miscellaneous.ts +55 -26
- package/src/wrapper.ts +37 -11
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -39,8 +39,8 @@ describe('build-docs', () => {
|
|
|
39
39
|
|
|
40
40
|
it('should work correctly when calling handlerBuildCommand', async () => {
|
|
41
41
|
const processExitMock = jest.spyOn(process, 'exit').mockImplementation();
|
|
42
|
-
await handlerBuildCommand(
|
|
43
|
-
{
|
|
42
|
+
await handlerBuildCommand({
|
|
43
|
+
argv: {
|
|
44
44
|
o: '',
|
|
45
45
|
title: 'test',
|
|
46
46
|
disableGoogleFont: false,
|
|
@@ -49,8 +49,9 @@ describe('build-docs', () => {
|
|
|
49
49
|
theme: { openapi: {} },
|
|
50
50
|
api: '../some-path/openapi.yaml',
|
|
51
51
|
} as BuildDocsArgv,
|
|
52
|
-
{} as any
|
|
53
|
-
|
|
52
|
+
config: {} as any,
|
|
53
|
+
version: 'cli-version',
|
|
54
|
+
});
|
|
54
55
|
expect(loadAndBundleSpec).toBeCalledTimes(1);
|
|
55
56
|
expect(getFallbackApisOrExit).toBeCalledTimes(1);
|
|
56
57
|
expect(processExitMock).toBeCalledTimes(0);
|
|
@@ -14,21 +14,21 @@ describe('handleJoin', () => {
|
|
|
14
14
|
colloreteYellowMock.mockImplementation((string: string) => string);
|
|
15
15
|
|
|
16
16
|
it('should call exitWithError because only one entrypoint', async () => {
|
|
17
|
-
await handleJoin({ apis: ['first.yaml'] }, {} as any, 'cli-version');
|
|
17
|
+
await handleJoin({ argv: { apis: ['first.yaml'] }, config: {} as any, version: 'cli-version' });
|
|
18
18
|
expect(exitWithError).toHaveBeenCalledWith(`At least 2 apis should be provided.`);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it('should call exitWithError because passed all 3 options for tags', async () => {
|
|
22
|
-
await handleJoin(
|
|
23
|
-
{
|
|
22
|
+
await handleJoin({
|
|
23
|
+
argv: {
|
|
24
24
|
apis: ['first.yaml', 'second.yaml'],
|
|
25
25
|
'prefix-tags-with-info-prop': 'something',
|
|
26
26
|
'without-x-tag-groups': true,
|
|
27
27
|
'prefix-tags-with-filename': true,
|
|
28
28
|
},
|
|
29
|
-
{} as any,
|
|
30
|
-
'cli-version'
|
|
31
|
-
);
|
|
29
|
+
config: {} as any,
|
|
30
|
+
version: 'cli-version',
|
|
31
|
+
});
|
|
32
32
|
|
|
33
33
|
expect(exitWithError).toHaveBeenCalledWith(
|
|
34
34
|
`You use prefix-tags-with-filename, prefix-tags-with-info-prop, without-x-tag-groups together.\nPlease choose only one!`
|
|
@@ -36,15 +36,15 @@ describe('handleJoin', () => {
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it('should call exitWithError because passed all 2 options for tags', async () => {
|
|
39
|
-
await handleJoin(
|
|
40
|
-
{
|
|
39
|
+
await handleJoin({
|
|
40
|
+
argv: {
|
|
41
41
|
apis: ['first.yaml', 'second.yaml'],
|
|
42
42
|
'without-x-tag-groups': true,
|
|
43
43
|
'prefix-tags-with-filename': true,
|
|
44
44
|
},
|
|
45
|
-
{} as any,
|
|
46
|
-
'cli-version'
|
|
47
|
-
);
|
|
45
|
+
config: {} as any,
|
|
46
|
+
version: 'cli-version',
|
|
47
|
+
});
|
|
48
48
|
|
|
49
49
|
expect(exitWithError).toHaveBeenCalledWith(
|
|
50
50
|
`You use prefix-tags-with-filename, without-x-tag-groups together.\nPlease choose only one!`
|
|
@@ -52,13 +52,13 @@ describe('handleJoin', () => {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
it('should call exitWithError because Only OpenAPI 3.0 and OpenAPI 3.1 are supported', async () => {
|
|
55
|
-
await handleJoin(
|
|
56
|
-
{
|
|
55
|
+
await handleJoin({
|
|
56
|
+
argv: {
|
|
57
57
|
apis: ['first.yaml', 'second.yaml'],
|
|
58
58
|
},
|
|
59
|
-
ConfigFixture as any,
|
|
60
|
-
'cli-version'
|
|
61
|
-
);
|
|
59
|
+
config: ConfigFixture as any,
|
|
60
|
+
version: 'cli-version',
|
|
61
|
+
});
|
|
62
62
|
expect(exitWithError).toHaveBeenCalledWith(
|
|
63
63
|
'Only OpenAPI 3.0 and OpenAPI 3.1 are supported: undefined.'
|
|
64
64
|
);
|
|
@@ -68,13 +68,13 @@ describe('handleJoin', () => {
|
|
|
68
68
|
(detectSpec as jest.Mock)
|
|
69
69
|
.mockImplementationOnce(() => 'oas3_0')
|
|
70
70
|
.mockImplementationOnce(() => 'oas3_1');
|
|
71
|
-
await handleJoin(
|
|
72
|
-
{
|
|
71
|
+
await handleJoin({
|
|
72
|
+
argv: {
|
|
73
73
|
apis: ['first.yaml', 'second.yaml'],
|
|
74
74
|
},
|
|
75
|
-
ConfigFixture as any,
|
|
76
|
-
'cli-version'
|
|
77
|
-
);
|
|
75
|
+
config: ConfigFixture as any,
|
|
76
|
+
version: 'cli-version',
|
|
77
|
+
});
|
|
78
78
|
|
|
79
79
|
expect(exitWithError).toHaveBeenCalledWith(
|
|
80
80
|
'All APIs must use the same OpenAPI version: undefined.'
|
|
@@ -83,13 +83,13 @@ describe('handleJoin', () => {
|
|
|
83
83
|
|
|
84
84
|
it('should call writeToFileByExtension function', async () => {
|
|
85
85
|
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
86
|
-
await handleJoin(
|
|
87
|
-
{
|
|
86
|
+
await handleJoin({
|
|
87
|
+
argv: {
|
|
88
88
|
apis: ['first.yaml', 'second.yaml'],
|
|
89
89
|
},
|
|
90
|
-
ConfigFixture as any,
|
|
91
|
-
'cli-version'
|
|
92
|
-
);
|
|
90
|
+
config: ConfigFixture as any,
|
|
91
|
+
version: 'cli-version',
|
|
92
|
+
});
|
|
93
93
|
|
|
94
94
|
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
95
95
|
expect.any(Object),
|
|
@@ -100,13 +100,13 @@ describe('handleJoin', () => {
|
|
|
100
100
|
|
|
101
101
|
it('should call writeToFileByExtension function for OpenAPI 3.1', async () => {
|
|
102
102
|
(detectSpec as jest.Mock).mockReturnValue('oas3_1');
|
|
103
|
-
await handleJoin(
|
|
104
|
-
{
|
|
103
|
+
await handleJoin({
|
|
104
|
+
argv: {
|
|
105
105
|
apis: ['first.yaml', 'second.yaml'],
|
|
106
106
|
},
|
|
107
|
-
ConfigFixture as any,
|
|
108
|
-
'cli-version'
|
|
109
|
-
);
|
|
107
|
+
config: ConfigFixture as any,
|
|
108
|
+
version: 'cli-version',
|
|
109
|
+
});
|
|
110
110
|
|
|
111
111
|
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
112
112
|
expect.any(Object),
|
|
@@ -117,14 +117,14 @@ describe('handleJoin', () => {
|
|
|
117
117
|
|
|
118
118
|
it('should call writeToFileByExtension function with custom output file', async () => {
|
|
119
119
|
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
120
|
-
await handleJoin(
|
|
121
|
-
{
|
|
120
|
+
await handleJoin({
|
|
121
|
+
argv: {
|
|
122
122
|
apis: ['first.yaml', 'second.yaml'],
|
|
123
123
|
output: 'output.yml',
|
|
124
124
|
},
|
|
125
|
-
ConfigFixture as any,
|
|
126
|
-
'cli-version'
|
|
127
|
-
);
|
|
125
|
+
config: ConfigFixture as any,
|
|
126
|
+
version: 'cli-version',
|
|
127
|
+
});
|
|
128
128
|
|
|
129
129
|
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
130
130
|
expect.any(Object),
|
|
@@ -135,13 +135,13 @@ describe('handleJoin', () => {
|
|
|
135
135
|
|
|
136
136
|
it('should call writeToFileByExtension function with json file extension', async () => {
|
|
137
137
|
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
138
|
-
await handleJoin(
|
|
139
|
-
{
|
|
138
|
+
await handleJoin({
|
|
139
|
+
argv: {
|
|
140
140
|
apis: ['first.json', 'second.yaml'],
|
|
141
141
|
},
|
|
142
|
-
ConfigFixture as any,
|
|
143
|
-
'cli-version'
|
|
144
|
-
);
|
|
142
|
+
config: ConfigFixture as any,
|
|
143
|
+
version: 'cli-version',
|
|
144
|
+
});
|
|
145
145
|
|
|
146
146
|
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
147
147
|
expect.any(Object),
|
|
@@ -152,13 +152,13 @@ describe('handleJoin', () => {
|
|
|
152
152
|
|
|
153
153
|
it('should call skipDecorators and skipPreprocessors', async () => {
|
|
154
154
|
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
155
|
-
await handleJoin(
|
|
156
|
-
{
|
|
155
|
+
await handleJoin({
|
|
156
|
+
argv: {
|
|
157
157
|
apis: ['first.yaml', 'second.yaml'],
|
|
158
158
|
},
|
|
159
|
-
ConfigFixture as any,
|
|
160
|
-
'cli-version'
|
|
161
|
-
);
|
|
159
|
+
config: ConfigFixture as any,
|
|
160
|
+
version: 'cli-version',
|
|
161
|
+
});
|
|
162
162
|
|
|
163
163
|
const config = loadConfig();
|
|
164
164
|
expect(config.styleguide.skipDecorators).toHaveBeenCalled();
|
|
@@ -168,15 +168,15 @@ describe('handleJoin', () => {
|
|
|
168
168
|
it('should handle join with prefix-components-with-info-prop and null values', async () => {
|
|
169
169
|
(detectSpec as jest.Mock).mockReturnValue('oas3_0');
|
|
170
170
|
|
|
171
|
-
await handleJoin(
|
|
172
|
-
{
|
|
171
|
+
await handleJoin({
|
|
172
|
+
argv: {
|
|
173
173
|
apis: ['first.yaml', 'second.yaml', 'third.yaml'],
|
|
174
174
|
'prefix-components-with-info-prop': 'title',
|
|
175
175
|
output: 'join-result.yaml',
|
|
176
176
|
},
|
|
177
|
-
ConfigFixture as any,
|
|
178
|
-
'cli-version'
|
|
179
|
-
);
|
|
177
|
+
config: ConfigFixture as any,
|
|
178
|
+
version: 'cli-version',
|
|
179
|
+
});
|
|
180
180
|
|
|
181
181
|
expect(writeToFileByExtension).toHaveBeenCalledWith(
|
|
182
182
|
{
|
|
@@ -28,30 +28,32 @@ describe('push-with-region', () => {
|
|
|
28
28
|
|
|
29
29
|
it('should call login with default domain when region is US', async () => {
|
|
30
30
|
redoclyClient.domain = 'redoc.ly';
|
|
31
|
-
await handlePush(
|
|
32
|
-
{
|
|
31
|
+
await handlePush({
|
|
32
|
+
argv: {
|
|
33
33
|
upsert: true,
|
|
34
34
|
api: 'spec.json',
|
|
35
35
|
destination: '@org/my-api@1.0.0',
|
|
36
36
|
branchName: 'test',
|
|
37
37
|
},
|
|
38
|
-
ConfigFixture as any
|
|
39
|
-
|
|
38
|
+
config: ConfigFixture as any,
|
|
39
|
+
version: 'cli-version',
|
|
40
|
+
});
|
|
40
41
|
expect(mockPromptClientToken).toBeCalledTimes(1);
|
|
41
42
|
expect(mockPromptClientToken).toHaveBeenCalledWith(redoclyClient.domain);
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
it('should call login with EU domain when region is EU', async () => {
|
|
45
46
|
redoclyClient.domain = 'eu.redocly.com';
|
|
46
|
-
await handlePush(
|
|
47
|
-
{
|
|
47
|
+
await handlePush({
|
|
48
|
+
argv: {
|
|
48
49
|
upsert: true,
|
|
49
50
|
api: 'spec.json',
|
|
50
51
|
destination: '@org/my-api@1.0.0',
|
|
51
52
|
branchName: 'test',
|
|
52
53
|
},
|
|
53
|
-
ConfigFixture as any
|
|
54
|
-
|
|
54
|
+
config: ConfigFixture as any,
|
|
55
|
+
version: 'cli-version',
|
|
56
|
+
});
|
|
55
57
|
expect(mockPromptClientToken).toBeCalledTimes(1);
|
|
56
58
|
expect(mockPromptClientToken).toHaveBeenCalledWith(redoclyClient.domain);
|
|
57
59
|
});
|