@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.
Files changed (91) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/lib/__mocks__/@redocly/openapi-core.d.ts +2 -2
  3. package/lib/__mocks__/@redocly/openapi-core.js +1 -0
  4. package/lib/__mocks__/fs.d.ts +0 -1
  5. package/lib/__mocks__/perf_hooks.d.ts +0 -1
  6. package/lib/__mocks__/redoc.d.ts +0 -1
  7. package/lib/__tests__/commands/build-docs.test.js +21 -23
  8. package/lib/__tests__/commands/bundle.test.js +21 -30
  9. package/lib/__tests__/commands/join.test.js +101 -70
  10. package/lib/__tests__/commands/lint.test.js +54 -54
  11. package/lib/__tests__/commands/push-region.test.js +24 -25
  12. package/lib/__tests__/commands/push.test.js +269 -170
  13. package/lib/__tests__/fetch-with-timeout.test.js +3 -12
  14. package/lib/__tests__/fixtures/config.d.ts +0 -1
  15. package/lib/__tests__/utils.test.js +32 -37
  16. package/lib/__tests__/wrapper.test.js +31 -20
  17. package/lib/cms/api/__tests__/api.client.test.js +29 -38
  18. package/lib/cms/api/api-client.d.ts +0 -2
  19. package/lib/cms/api/api-client.js +106 -127
  20. package/lib/cms/api/api-keys.js +1 -2
  21. package/lib/cms/api/domains.js +1 -2
  22. package/lib/cms/commands/__tests__/push-status.test.js +251 -162
  23. package/lib/cms/commands/__tests__/push.test.js +120 -102
  24. package/lib/cms/commands/__tests__/utils.test.js +12 -21
  25. package/lib/cms/commands/push-status.d.ts +3 -2
  26. package/lib/cms/commands/push-status.js +94 -106
  27. package/lib/cms/commands/push.d.ts +3 -2
  28. package/lib/cms/commands/push.js +66 -75
  29. package/lib/cms/commands/utils.js +20 -34
  30. package/lib/commands/build-docs/index.d.ts +2 -2
  31. package/lib/commands/build-docs/index.js +8 -17
  32. package/lib/commands/build-docs/utils.js +26 -38
  33. package/lib/commands/bundle.d.ts +2 -2
  34. package/lib/commands/bundle.js +70 -94
  35. package/lib/commands/join.d.ts +2 -2
  36. package/lib/commands/join.js +377 -390
  37. package/lib/commands/lint.d.ts +2 -2
  38. package/lib/commands/lint.js +70 -78
  39. package/lib/commands/login.d.ts +3 -2
  40. package/lib/commands/login.js +9 -21
  41. package/lib/commands/preview-docs/index.d.ts +2 -2
  42. package/lib/commands/preview-docs/index.js +92 -106
  43. package/lib/commands/preview-docs/preview-server/preview-server.js +64 -76
  44. package/lib/commands/preview-docs/preview-server/server.d.ts +0 -3
  45. package/lib/commands/preview-docs/preview-server/server.js +6 -6
  46. package/lib/commands/preview-project/index.d.ts +2 -1
  47. package/lib/commands/preview-project/index.js +5 -14
  48. package/lib/commands/push.d.ts +8 -11
  49. package/lib/commands/push.js +177 -195
  50. package/lib/commands/split/__tests__/index.test.js +31 -25
  51. package/lib/commands/split/index.d.ts +2 -1
  52. package/lib/commands/split/index.js +22 -35
  53. package/lib/commands/stats.d.ts +2 -2
  54. package/lib/commands/stats.js +34 -45
  55. package/lib/index.js +32 -46
  56. package/lib/types.d.ts +2 -2
  57. package/lib/utils/__mocks__/miscellaneous.d.ts +0 -1
  58. package/lib/utils/fetch-with-timeout.js +7 -12
  59. package/lib/utils/getCommandNameFromArgs.js +2 -4
  60. package/lib/utils/js-utils.js +6 -7
  61. package/lib/utils/miscellaneous.d.ts +9 -5
  62. package/lib/utils/miscellaneous.js +150 -160
  63. package/lib/utils/update-version-notifier.js +4 -13
  64. package/lib/wrapper.d.ts +9 -2
  65. package/lib/wrapper.js +27 -16
  66. package/package.json +5 -3
  67. package/src/__mocks__/@redocly/openapi-core.ts +1 -0
  68. package/src/__tests__/commands/build-docs.test.ts +5 -4
  69. package/src/__tests__/commands/join.test.ts +51 -51
  70. package/src/__tests__/commands/push-region.test.ts +10 -8
  71. package/src/__tests__/commands/push.test.ts +127 -102
  72. package/src/__tests__/utils.test.ts +1 -0
  73. package/src/__tests__/wrapper.test.ts +24 -2
  74. package/src/cms/commands/__tests__/push-status.test.ts +70 -56
  75. package/src/cms/commands/__tests__/push.test.ts +30 -24
  76. package/src/cms/commands/push-status.ts +8 -7
  77. package/src/cms/commands/push.ts +19 -13
  78. package/src/commands/build-docs/index.ts +10 -5
  79. package/src/commands/bundle.ts +14 -6
  80. package/src/commands/join.ts +10 -6
  81. package/src/commands/lint.ts +20 -9
  82. package/src/commands/login.ts +4 -2
  83. package/src/commands/preview-docs/index.ts +6 -1
  84. package/src/commands/preview-project/index.ts +5 -4
  85. package/src/commands/push.ts +14 -16
  86. package/src/commands/split/__tests__/index.test.ts +17 -6
  87. package/src/commands/split/index.ts +6 -4
  88. package/src/commands/stats.ts +4 -2
  89. package/src/utils/miscellaneous.ts +55 -26
  90. package/src/wrapper.ts +37 -11
  91. package/tsconfig.tsbuildinfo +1 -1
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  const openapi_core_1 = require("@redocly/openapi-core");
13
4
  const push_1 = require("../../commands/push");
@@ -31,26 +22,34 @@ describe('push-with-region', () => {
31
22
  beforeAll(() => {
32
23
  jest.spyOn(process.stdout, 'write').mockImplementation(() => true);
33
24
  });
34
- it('should call login with default domain when region is US', () => __awaiter(void 0, void 0, void 0, function* () {
25
+ it('should call login with default domain when region is US', async () => {
35
26
  redoclyClient.domain = 'redoc.ly';
36
- yield (0, push_1.handlePush)({
37
- upsert: true,
38
- api: 'spec.json',
39
- destination: '@org/my-api@1.0.0',
40
- branchName: 'test',
41
- }, config_1.ConfigFixture);
27
+ await (0, push_1.handlePush)({
28
+ argv: {
29
+ upsert: true,
30
+ api: 'spec.json',
31
+ destination: '@org/my-api@1.0.0',
32
+ branchName: 'test',
33
+ },
34
+ config: config_1.ConfigFixture,
35
+ version: 'cli-version',
36
+ });
42
37
  expect(mockPromptClientToken).toBeCalledTimes(1);
43
38
  expect(mockPromptClientToken).toHaveBeenCalledWith(redoclyClient.domain);
44
- }));
45
- it('should call login with EU domain when region is EU', () => __awaiter(void 0, void 0, void 0, function* () {
39
+ });
40
+ it('should call login with EU domain when region is EU', async () => {
46
41
  redoclyClient.domain = 'eu.redocly.com';
47
- yield (0, push_1.handlePush)({
48
- upsert: true,
49
- api: 'spec.json',
50
- destination: '@org/my-api@1.0.0',
51
- branchName: 'test',
52
- }, config_1.ConfigFixture);
42
+ await (0, push_1.handlePush)({
43
+ argv: {
44
+ upsert: true,
45
+ api: 'spec.json',
46
+ destination: '@org/my-api@1.0.0',
47
+ branchName: 'test',
48
+ },
49
+ config: config_1.ConfigFixture,
50
+ version: 'cli-version',
51
+ });
53
52
  expect(mockPromptClientToken).toBeCalledTimes(1);
54
53
  expect(mockPromptClientToken).toHaveBeenCalledWith(redoclyClient.domain);
55
- }));
54
+ });
56
55
  });
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  const fs = require("fs");
13
4
  const openapi_core_1 = require("@redocly/openapi-core");
@@ -30,16 +21,20 @@ describe('push', () => {
30
21
  beforeEach(() => {
31
22
  jest.spyOn(process.stdout, 'write').mockImplementation(() => true);
32
23
  });
33
- it('pushes definition', () => __awaiter(void 0, void 0, void 0, function* () {
34
- yield (0, push_1.handlePush)({
35
- upsert: true,
36
- api: 'spec.json',
37
- destination: '@org/my-api@1.0.0',
38
- branchName: 'test',
39
- public: true,
40
- 'job-id': '123',
41
- 'batch-size': 2,
42
- }, config_1.ConfigFixture);
24
+ it('pushes definition', async () => {
25
+ await (0, push_1.handlePush)({
26
+ argv: {
27
+ upsert: true,
28
+ api: 'spec.json',
29
+ destination: '@org/my-api@1.0.0',
30
+ branchName: 'test',
31
+ public: true,
32
+ 'job-id': '123',
33
+ 'batch-size': 2,
34
+ },
35
+ config: config_1.ConfigFixture,
36
+ version: 'cli-version',
37
+ });
43
38
  expect(redoclyClient.registryApi.prepareFileUpload).toBeCalledTimes(1);
44
39
  expect(redoclyClient.registryApi.pushApi).toBeCalledTimes(1);
45
40
  expect(redoclyClient.registryApi.pushApi).toHaveBeenLastCalledWith({
@@ -54,43 +49,55 @@ describe('push', () => {
54
49
  batchId: '123',
55
50
  batchSize: 2,
56
51
  });
57
- }));
58
- it('fails if jobId value is an empty string', () => __awaiter(void 0, void 0, void 0, function* () {
59
- yield (0, push_1.handlePush)({
60
- upsert: true,
61
- api: 'spec.json',
62
- destination: '@org/my-api@1.0.0',
63
- branchName: 'test',
64
- public: true,
65
- 'job-id': ' ',
66
- 'batch-size': 2,
67
- }, config_1.ConfigFixture);
52
+ });
53
+ it('fails if jobId value is an empty string', async () => {
54
+ await (0, push_1.handlePush)({
55
+ argv: {
56
+ upsert: true,
57
+ api: 'spec.json',
58
+ destination: '@org/my-api@1.0.0',
59
+ branchName: 'test',
60
+ public: true,
61
+ 'job-id': ' ',
62
+ 'batch-size': 2,
63
+ },
64
+ config: config_1.ConfigFixture,
65
+ version: 'cli-version',
66
+ });
68
67
  expect(miscellaneous_1.exitWithError).toBeCalledTimes(1);
69
- }));
70
- it('fails if batchSize value is less than 2', () => __awaiter(void 0, void 0, void 0, function* () {
71
- yield (0, push_1.handlePush)({
72
- upsert: true,
73
- api: 'spec.json',
74
- destination: '@org/my-api@1.0.0',
75
- branchName: 'test',
76
- public: true,
77
- 'job-id': '123',
78
- 'batch-size': 1,
79
- }, config_1.ConfigFixture);
68
+ });
69
+ it('fails if batchSize value is less than 2', async () => {
70
+ await (0, push_1.handlePush)({
71
+ argv: {
72
+ upsert: true,
73
+ api: 'spec.json',
74
+ destination: '@org/my-api@1.0.0',
75
+ branchName: 'test',
76
+ public: true,
77
+ 'job-id': '123',
78
+ 'batch-size': 1,
79
+ },
80
+ config: config_1.ConfigFixture,
81
+ version: 'cli-version',
82
+ });
80
83
  expect(miscellaneous_1.exitWithError).toBeCalledTimes(1);
81
- }));
82
- it('push with --files', () => __awaiter(void 0, void 0, void 0, function* () {
83
- const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { files: ['./resouces/1.md', './resouces/2.md'] });
84
+ });
85
+ it('push with --files', async () => {
86
+ const mockConfig = { ...config_1.ConfigFixture, files: ['./resouces/1.md', './resouces/2.md'] };
84
87
  fs.statSync.mockImplementation(() => {
85
88
  return { isDirectory: () => false, size: 10 };
86
89
  });
87
- yield (0, push_1.handlePush)({
88
- upsert: true,
89
- api: 'spec.json',
90
- destination: '@org/my-api@1.0.0',
91
- public: true,
92
- files: ['./resouces/1.md', './resouces/2.md'],
93
- }, mockConfig);
90
+ await (0, push_1.handlePush)({
91
+ argv: {
92
+ upsert: true,
93
+ api: 'spec.json',
94
+ destination: '@org/my-api@1.0.0',
95
+ public: true,
96
+ files: ['./resouces/1.md', './resouces/2.md'],
97
+ },
98
+ config: mockConfig,
99
+ version: 'cli-version',
100
+ });
94
101
  expect(redoclyClient.registryApi.pushApi).toHaveBeenLastCalledWith({
95
102
  filePaths: ['filePath', 'filePath', 'filePath'],
96
103
  isUpsert: true,
@@ -101,31 +108,39 @@ describe('push', () => {
101
108
  version: '1.0.0',
102
109
  });
103
110
  expect(redoclyClient.registryApi.prepareFileUpload).toBeCalledTimes(3);
104
- }));
105
- it('push should fail if organization not provided', () => __awaiter(void 0, void 0, void 0, function* () {
106
- yield (0, push_1.handlePush)({
107
- upsert: true,
108
- api: 'spec.json',
109
- destination: 'test@v1',
110
- branchName: 'test',
111
- public: true,
112
- 'job-id': '123',
113
- 'batch-size': 2,
114
- }, config_1.ConfigFixture);
111
+ });
112
+ it('push should fail if organization not provided', async () => {
113
+ await (0, push_1.handlePush)({
114
+ argv: {
115
+ upsert: true,
116
+ api: 'spec.json',
117
+ destination: 'test@v1',
118
+ branchName: 'test',
119
+ public: true,
120
+ 'job-id': '123',
121
+ 'batch-size': 2,
122
+ },
123
+ config: config_1.ConfigFixture,
124
+ version: 'cli-version',
125
+ });
115
126
  expect(miscellaneous_1.exitWithError).toBeCalledTimes(1);
116
127
  expect(miscellaneous_1.exitWithError).toBeCalledWith(`No organization provided, please use --organization option or specify the 'organization' field in the config file.`);
117
- }));
118
- it('push should work with organization in config', () => __awaiter(void 0, void 0, void 0, function* () {
119
- const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org' });
120
- yield (0, push_1.handlePush)({
121
- upsert: true,
122
- api: 'spec.json',
123
- destination: 'my-api@1.0.0',
124
- branchName: 'test',
125
- public: true,
126
- 'job-id': '123',
127
- 'batch-size': 2,
128
- }, mockConfig);
128
+ });
129
+ it('push should work with organization in config', async () => {
130
+ const mockConfig = { ...config_1.ConfigFixture, organization: 'test_org' };
131
+ await (0, push_1.handlePush)({
132
+ argv: {
133
+ upsert: true,
134
+ api: 'spec.json',
135
+ destination: 'my-api@1.0.0',
136
+ branchName: 'test',
137
+ public: true,
138
+ 'job-id': '123',
139
+ 'batch-size': 2,
140
+ },
141
+ config: mockConfig,
142
+ version: 'cli-version',
143
+ });
129
144
  expect(redoclyClient.registryApi.pushApi).toBeCalledTimes(1);
130
145
  expect(redoclyClient.registryApi.pushApi).toHaveBeenLastCalledWith({
131
146
  branch: 'test',
@@ -139,153 +154,237 @@ describe('push', () => {
139
154
  batchId: '123',
140
155
  batchSize: 2,
141
156
  });
142
- }));
143
- it('push should work if destination not provided but api in config is provided', () => __awaiter(void 0, void 0, void 0, function* () {
144
- const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org', apis: { 'my-api@1.0.0': { root: 'path' } } });
145
- yield (0, push_1.handlePush)({
146
- upsert: true,
147
- branchName: 'test',
148
- public: true,
149
- 'job-id': '123',
150
- 'batch-size': 2,
151
- }, mockConfig);
157
+ });
158
+ it('push should work if destination not provided but api in config is provided', async () => {
159
+ const mockConfig = {
160
+ ...config_1.ConfigFixture,
161
+ organization: 'test_org',
162
+ apis: { 'my-api@1.0.0': { root: 'path' } },
163
+ };
164
+ await (0, push_1.handlePush)({
165
+ argv: {
166
+ upsert: true,
167
+ branchName: 'test',
168
+ public: true,
169
+ 'job-id': '123',
170
+ 'batch-size': 2,
171
+ },
172
+ config: mockConfig,
173
+ version: 'cli-version',
174
+ });
152
175
  expect(redoclyClient.registryApi.pushApi).toBeCalledTimes(1);
153
- }));
154
- it('push should fail if apis not provided', () => __awaiter(void 0, void 0, void 0, function* () {
176
+ });
177
+ it('push should fail if apis not provided', async () => {
155
178
  const mockConfig = { organization: 'test_org', apis: {} };
156
- yield (0, push_1.handlePush)({
157
- upsert: true,
158
- branchName: 'test',
159
- public: true,
160
- 'job-id': '123',
161
- 'batch-size': 2,
162
- }, mockConfig);
179
+ await (0, push_1.handlePush)({
180
+ argv: {
181
+ upsert: true,
182
+ branchName: 'test',
183
+ public: true,
184
+ 'job-id': '123',
185
+ 'batch-size': 2,
186
+ },
187
+ config: mockConfig,
188
+ version: 'cli-version',
189
+ });
163
190
  expect(miscellaneous_1.exitWithError).toBeCalledTimes(1);
164
191
  expect(miscellaneous_1.exitWithError).toHaveBeenLastCalledWith('Api not found. Please make sure you have provided the correct data in the config file.');
165
- }));
166
- it('push should fail if destination not provided', () => __awaiter(void 0, void 0, void 0, function* () {
192
+ });
193
+ it('push should fail if destination not provided', async () => {
167
194
  const mockConfig = { organization: 'test_org', apis: {} };
168
- yield (0, push_1.handlePush)({
169
- upsert: true,
170
- api: 'api.yaml',
171
- branchName: 'test',
172
- public: true,
173
- 'job-id': '123',
174
- 'batch-size': 2,
175
- }, mockConfig);
195
+ await (0, push_1.handlePush)({
196
+ argv: {
197
+ upsert: true,
198
+ api: 'api.yaml',
199
+ branchName: 'test',
200
+ public: true,
201
+ 'job-id': '123',
202
+ 'batch-size': 2,
203
+ },
204
+ config: mockConfig,
205
+ version: 'cli-version',
206
+ });
176
207
  expect(miscellaneous_1.exitWithError).toBeCalledTimes(1);
177
208
  expect(miscellaneous_1.exitWithError).toHaveBeenLastCalledWith('No destination provided, please use --destination option to provide destination.');
178
- }));
179
- it('push should fail if destination format is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
209
+ });
210
+ it('push should fail if destination format is not valid', async () => {
180
211
  const mockConfig = { organization: 'test_org', apis: {} };
181
- yield (0, push_1.handlePush)({
182
- upsert: true,
183
- destination: 'name/v1',
184
- branchName: 'test',
185
- public: true,
186
- 'job-id': '123',
187
- 'batch-size': 2,
188
- }, mockConfig);
212
+ await (0, push_1.handlePush)({
213
+ argv: {
214
+ upsert: true,
215
+ destination: 'name/v1',
216
+ branchName: 'test',
217
+ public: true,
218
+ 'job-id': '123',
219
+ 'batch-size': 2,
220
+ },
221
+ config: mockConfig,
222
+ version: 'cli-version',
223
+ });
189
224
  expect(miscellaneous_1.exitWithError).toHaveBeenCalledWith(`Destination argument value is not valid, please use the right format: ${(0, colorette_1.yellow)('<api-name@api-version>')}.`);
190
- }));
191
- it('push should work and encode name with spaces', () => __awaiter(void 0, void 0, void 0, function* () {
225
+ });
226
+ it('push should work and encode name with spaces', async () => {
192
227
  const encodeURIComponentSpy = jest.spyOn(global, 'encodeURIComponent');
193
- const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org', apis: { 'my test api@v1': { root: 'path' } } });
194
- yield (0, push_1.handlePush)({
195
- upsert: true,
196
- destination: 'my test api@v1',
197
- branchName: 'test',
198
- public: true,
199
- 'job-id': '123',
200
- 'batch-size': 2,
201
- }, mockConfig);
228
+ const mockConfig = {
229
+ ...config_1.ConfigFixture,
230
+ organization: 'test_org',
231
+ apis: { 'my test api@v1': { root: 'path' } },
232
+ };
233
+ await (0, push_1.handlePush)({
234
+ argv: {
235
+ upsert: true,
236
+ destination: 'my test api@v1',
237
+ branchName: 'test',
238
+ public: true,
239
+ 'job-id': '123',
240
+ 'batch-size': 2,
241
+ },
242
+ config: mockConfig,
243
+ version: 'cli-version',
244
+ });
202
245
  expect(encodeURIComponentSpy).toHaveReturnedWith('my%20test%20api');
203
246
  expect(redoclyClient.registryApi.pushApi).toBeCalledTimes(1);
204
- }));
247
+ });
205
248
  });
206
249
  describe('transformPush', () => {
207
250
  it('should adapt the existing syntax', () => {
208
251
  const cb = jest.fn();
209
252
  (0, push_1.transformPush)(cb)({
210
- apis: ['openapi.yaml', '@testing_org/main@v1'],
211
- }, {});
253
+ argv: {
254
+ apis: ['openapi.yaml', '@testing_org/main@v1'],
255
+ },
256
+ config: {},
257
+ version: 'cli-version',
258
+ });
212
259
  expect(cb).toBeCalledWith({
213
- api: 'openapi.yaml',
214
- destination: '@testing_org/main@v1',
215
- }, {});
260
+ argv: {
261
+ api: 'openapi.yaml',
262
+ destination: '@testing_org/main@v1',
263
+ },
264
+ config: {},
265
+ version: 'cli-version',
266
+ });
216
267
  });
217
268
  it('should adapt the existing syntax (including branchName)', () => {
218
269
  const cb = jest.fn();
219
270
  (0, push_1.transformPush)(cb)({
220
- apis: ['openapi.yaml', '@testing_org/main@v1', 'other'],
221
- }, {});
271
+ argv: {
272
+ apis: ['openapi.yaml', '@testing_org/main@v1', 'other'],
273
+ },
274
+ config: {},
275
+ version: 'cli-version',
276
+ });
222
277
  expect(cb).toBeCalledWith({
223
- api: 'openapi.yaml',
224
- destination: '@testing_org/main@v1',
225
- branchName: 'other',
226
- }, {});
278
+ argv: {
279
+ api: 'openapi.yaml',
280
+ destination: '@testing_org/main@v1',
281
+ branchName: 'other',
282
+ },
283
+ config: {},
284
+ version: 'cli-version',
285
+ });
227
286
  });
228
287
  it('should use --branch option firstly', () => {
229
288
  const cb = jest.fn();
230
289
  (0, push_1.transformPush)(cb)({
231
- apis: ['openapi.yaml', '@testing_org/main@v1', 'other'],
232
- branch: 'priority-branch',
233
- }, {});
290
+ argv: {
291
+ apis: ['openapi.yaml', '@testing_org/main@v1', 'other'],
292
+ branch: 'priority-branch',
293
+ },
294
+ config: {},
295
+ version: 'cli-version',
296
+ });
234
297
  expect(cb).toBeCalledWith({
235
- api: 'openapi.yaml',
236
- destination: '@testing_org/main@v1',
237
- branchName: 'priority-branch',
238
- }, {});
298
+ argv: {
299
+ api: 'openapi.yaml',
300
+ destination: '@testing_org/main@v1',
301
+ branchName: 'priority-branch',
302
+ },
303
+ config: {},
304
+ version: 'cli-version',
305
+ });
239
306
  });
240
307
  it('should work for a destination only', () => {
241
308
  const cb = jest.fn();
242
309
  (0, push_1.transformPush)(cb)({
243
- apis: ['main@v1'],
244
- }, {});
310
+ argv: {
311
+ apis: ['main@v1'],
312
+ },
313
+ config: {},
314
+ version: 'cli-version',
315
+ });
245
316
  expect(cb).toBeCalledWith({
246
- destination: 'main@v1',
247
- }, {});
317
+ argv: {
318
+ destination: 'main@v1',
319
+ },
320
+ config: {},
321
+ version: 'cli-version',
322
+ });
248
323
  });
249
324
  it('should work for a api only', () => {
250
325
  const cb = jest.fn();
251
326
  (0, push_1.transformPush)(cb)({
252
- apis: ['test.yaml'],
253
- }, {});
327
+ argv: {
328
+ apis: ['test.yaml'],
329
+ },
330
+ config: {},
331
+ version: 'cli-version',
332
+ });
254
333
  expect(cb).toBeCalledWith({
255
- api: 'test.yaml',
256
- }, {});
334
+ argv: {
335
+ api: 'test.yaml',
336
+ },
337
+ config: {},
338
+ version: 'cli-version',
339
+ });
257
340
  });
258
341
  it('should use destination from option', () => {
259
342
  const cb = jest.fn();
260
343
  (0, push_1.transformPush)(cb)({
261
- apis: ['test.yaml', 'test@v1'],
262
- destination: 'main@v1',
263
- }, {});
344
+ argv: {
345
+ apis: ['test.yaml', 'test@v1'],
346
+ destination: 'main@v1',
347
+ },
348
+ config: {},
349
+ version: 'cli-version',
350
+ });
264
351
  expect(cb).toBeCalledWith({
265
- destination: 'main@v1',
266
- api: 'test.yaml',
267
- }, {});
352
+ argv: {
353
+ destination: 'main@v1',
354
+ api: 'test.yaml',
355
+ },
356
+ config: {},
357
+ version: 'cli-version',
358
+ });
268
359
  });
269
360
  it('should use --job-id option firstly', () => {
270
361
  const cb = jest.fn();
271
362
  (0, push_1.transformPush)(cb)({
272
- 'batch-id': 'b-123',
273
- 'job-id': 'j-123',
274
- apis: ['test'],
275
- branch: 'test',
276
- destination: 'main@v1',
277
- }, {});
363
+ argv: {
364
+ 'batch-id': 'b-123',
365
+ 'job-id': 'j-123',
366
+ apis: ['test'],
367
+ branch: 'test',
368
+ destination: 'main@v1',
369
+ },
370
+ config: {},
371
+ version: 'cli-version',
372
+ });
278
373
  expect(cb).toBeCalledWith({
279
- 'job-id': 'j-123',
280
- api: 'test',
281
- branchName: 'test',
282
- destination: 'main@v1',
283
- }, {});
374
+ argv: {
375
+ 'job-id': 'j-123',
376
+ api: 'test',
377
+ branchName: 'test',
378
+ destination: 'main@v1',
379
+ },
380
+ config: {},
381
+ version: 'cli-version',
382
+ });
284
383
  });
285
384
  it('should accept no arguments at all', () => {
286
385
  const cb = jest.fn();
287
- (0, push_1.transformPush)(cb)({}, {});
288
- expect(cb).toBeCalledWith({}, {});
386
+ (0, push_1.transformPush)(cb)({ argv: {}, config: {}, version: 'cli-version' });
387
+ expect(cb).toBeCalledWith({ argv: {}, config: {}, version: 'cli-version' });
289
388
  });
290
389
  });
291
390
  describe('getDestinationProps', () => {
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  const abort_controller_1 = require("abort-controller");
13
4
  const fetch_with_timeout_1 = require("../utils/fetch-with-timeout");
@@ -17,13 +8,13 @@ describe('fetchWithTimeout', () => {
17
8
  afterEach(() => {
18
9
  jest.clearAllMocks();
19
10
  });
20
- it('should call node-fetch with signal', () => __awaiter(void 0, void 0, void 0, function* () {
11
+ it('should call node-fetch with signal', async () => {
21
12
  // @ts-ignore
22
13
  global.setTimeout = jest.fn();
23
14
  global.clearTimeout = jest.fn();
24
- yield (0, fetch_with_timeout_1.default)('url');
15
+ await (0, fetch_with_timeout_1.default)('url');
25
16
  expect(global.setTimeout).toHaveBeenCalledTimes(1);
26
17
  expect(node_fetch_1.default).toHaveBeenCalledWith('url', { signal: new abort_controller_1.default().signal });
27
18
  expect(global.clearTimeout).toHaveBeenCalledTimes(1);
28
- }));
19
+ });
29
20
  });
@@ -1,4 +1,3 @@
1
- /// <reference types="jest" />
2
1
  export declare const ConfigFixture: {
3
2
  configFile: null;
4
3
  styleguide: {