@redocly/cli 0.0.0-snapshot.1741951669 → 0.0.0-snapshot.1742384755

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 (90) hide show
  1. package/lib/commands/auth.d.ts +1 -4
  2. package/lib/commands/auth.js +11 -34
  3. package/lib/commands/build-docs/utils.js +1 -1
  4. package/lib/commands/bundle.d.ts +4 -2
  5. package/lib/commands/join.js +1 -0
  6. package/lib/commands/lint.d.ts +4 -2
  7. package/lib/commands/split/index.js +3 -2
  8. package/lib/index.js +15 -181
  9. package/lib/reunite/api/api-keys.d.ts +1 -1
  10. package/lib/reunite/api/api-keys.js +3 -17
  11. package/lib/reunite/api/domains.d.ts +4 -2
  12. package/lib/reunite/api/domains.js +2 -7
  13. package/lib/reunite/commands/push-status.d.ts +3 -3
  14. package/lib/reunite/commands/push-status.js +7 -12
  15. package/lib/reunite/commands/push.d.ts +3 -4
  16. package/lib/reunite/commands/push.js +7 -14
  17. package/lib/types.d.ts +3 -15
  18. package/lib/types.js +2 -3
  19. package/lib/utils/assert-node-version.js +2 -2
  20. package/lib/utils/js-utils.js +2 -0
  21. package/lib/utils/miscellaneous.d.ts +1 -7
  22. package/lib/utils/miscellaneous.js +31 -40
  23. package/lib/utils/platform.js +1 -0
  24. package/lib/utils/spinner.js +1 -1
  25. package/lib/utils/update-version-notifier.js +10 -9
  26. package/lib/wrapper.js +0 -2
  27. package/package.json +6 -7
  28. package/lib/__mocks__/@redocly/openapi-core.d.ts +0 -99
  29. package/lib/__mocks__/@redocly/openapi-core.js +0 -84
  30. package/lib/__mocks__/documents.d.ts +0 -150
  31. package/lib/__mocks__/documents.js +0 -123
  32. package/lib/__mocks__/fs.d.ts +0 -8
  33. package/lib/__mocks__/fs.js +0 -9
  34. package/lib/__mocks__/perf_hooks.d.ts +0 -3
  35. package/lib/__mocks__/perf_hooks.js +0 -6
  36. package/lib/__mocks__/redoc.d.ts +0 -6
  37. package/lib/__mocks__/redoc.js +0 -5
  38. package/lib/__tests__/commands/build-docs.test.d.ts +0 -1
  39. package/lib/__tests__/commands/build-docs.test.js +0 -54
  40. package/lib/__tests__/commands/bundle.test.d.ts +0 -1
  41. package/lib/__tests__/commands/bundle.test.js +0 -235
  42. package/lib/__tests__/commands/join.test.d.ts +0 -1
  43. package/lib/__tests__/commands/join.test.js +0 -274
  44. package/lib/__tests__/commands/lint.test.d.ts +0 -1
  45. package/lib/__tests__/commands/lint.test.js +0 -149
  46. package/lib/__tests__/commands/push-region.test.d.ts +0 -1
  47. package/lib/__tests__/commands/push-region.test.js +0 -90
  48. package/lib/__tests__/commands/push.test.d.ts +0 -1
  49. package/lib/__tests__/commands/push.test.js +0 -496
  50. package/lib/__tests__/fetch-with-timeout.test.d.ts +0 -1
  51. package/lib/__tests__/fetch-with-timeout.test.js +0 -64
  52. package/lib/__tests__/fixtures/config.d.ts +0 -21
  53. package/lib/__tests__/fixtures/config.js +0 -24
  54. package/lib/__tests__/spinner.test.d.ts +0 -1
  55. package/lib/__tests__/spinner.test.js +0 -43
  56. package/lib/__tests__/utils.test.d.ts +0 -1
  57. package/lib/__tests__/utils.test.js +0 -594
  58. package/lib/__tests__/wrapper.test.d.ts +0 -1
  59. package/lib/__tests__/wrapper.test.js +0 -76
  60. package/lib/auth/__tests__/device-flow.test.d.ts +0 -1
  61. package/lib/auth/__tests__/device-flow.test.js +0 -62
  62. package/lib/auth/__tests__/oauth-client.test.d.ts +0 -1
  63. package/lib/auth/__tests__/oauth-client.test.js +0 -93
  64. package/lib/commands/preview-docs/index.d.ts +0 -12
  65. package/lib/commands/preview-docs/index.js +0 -127
  66. package/lib/commands/preview-docs/preview-server/default.hbs +0 -24
  67. package/lib/commands/preview-docs/preview-server/hot.js +0 -59
  68. package/lib/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
  69. package/lib/commands/preview-docs/preview-server/preview-server.d.ts +0 -5
  70. package/lib/commands/preview-docs/preview-server/preview-server.js +0 -113
  71. package/lib/commands/preview-docs/preview-server/server.d.ts +0 -22
  72. package/lib/commands/preview-docs/preview-server/server.js +0 -85
  73. package/lib/commands/push.d.ts +0 -44
  74. package/lib/commands/push.js +0 -301
  75. package/lib/commands/split/__tests__/index.test.d.ts +0 -1
  76. package/lib/commands/split/__tests__/index.test.js +0 -91
  77. package/lib/reunite/api/__tests__/api-keys.test.d.ts +0 -1
  78. package/lib/reunite/api/__tests__/api-keys.test.js +0 -26
  79. package/lib/reunite/api/__tests__/api.client.test.d.ts +0 -1
  80. package/lib/reunite/api/__tests__/api.client.test.js +0 -337
  81. package/lib/reunite/api/__tests__/domains.test.d.ts +0 -1
  82. package/lib/reunite/api/__tests__/domains.test.js +0 -32
  83. package/lib/reunite/commands/__tests__/push-status.test.d.ts +0 -1
  84. package/lib/reunite/commands/__tests__/push-status.test.js +0 -563
  85. package/lib/reunite/commands/__tests__/push.test.d.ts +0 -1
  86. package/lib/reunite/commands/__tests__/push.test.js +0 -315
  87. package/lib/reunite/commands/__tests__/utils.test.d.ts +0 -1
  88. package/lib/reunite/commands/__tests__/utils.test.js +0 -51
  89. package/lib/utils/__mocks__/miscellaneous.d.ts +0 -43
  90. package/lib/utils/__mocks__/miscellaneous.js +0 -24
@@ -1,12 +1,9 @@
1
1
  import type { CommandArgs } from '../wrapper';
2
- export declare function promptClientToken(domain: string): Promise<string>;
3
2
  export type LoginOptions = {
4
- verbose?: boolean;
5
3
  residency?: string;
6
4
  config?: string;
7
- next?: boolean;
8
5
  };
9
- export declare function handleLogin({ argv, config, version }: CommandArgs<LoginOptions>): Promise<void>;
6
+ export declare function handleLogin({ argv, version }: CommandArgs<LoginOptions>): Promise<void>;
10
7
  export type LogoutOptions = {
11
8
  config?: string;
12
9
  };
@@ -1,50 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promptClientToken = promptClientToken;
4
3
  exports.handleLogin = handleLogin;
5
4
  exports.handleLogout = handleLogout;
6
- const colorette_1 = require("colorette");
7
- const openapi_core_1 = require("@redocly/openapi-core");
8
5
  const miscellaneous_1 = require("../utils/miscellaneous");
9
6
  const oauth_client_1 = require("../auth/oauth-client");
10
7
  const api_1 = require("../reunite/api");
11
- function promptClientToken(domain) {
12
- return (0, miscellaneous_1.promptUser)((0, colorette_1.green)(`\n 🔑 Copy your API key from ${(0, colorette_1.blue)(`https://app.${domain}/profile`)} and paste it below`) + (0, colorette_1.yellow)(' (if you want to log in with Reunite, please run `redocly login --next` instead)'), true);
13
- }
14
- async function handleLogin({ argv, config, version }) {
15
- if (argv.next) {
16
- try {
17
- const reuniteUrl = (0, api_1.getReuniteUrl)(argv.residency);
18
- const oauthClient = new oauth_client_1.RedoclyOAuthClient('redocly-cli', version);
19
- await oauthClient.login(reuniteUrl);
20
- }
21
- catch {
22
- if (argv.residency) {
23
- const reuniteUrl = (0, api_1.getReuniteUrl)(argv.residency);
24
- (0, miscellaneous_1.exitWithError)(`❌ Connection to ${reuniteUrl} failed.`);
25
- }
26
- else {
27
- (0, miscellaneous_1.exitWithError)(`❌ Login failed. Please check your credentials and try again.`);
28
- }
29
- }
8
+ async function handleLogin({ argv, version }) {
9
+ try {
10
+ const reuniteUrl = (0, api_1.getReuniteUrl)(argv.residency);
11
+ const oauthClient = new oauth_client_1.RedoclyOAuthClient('redocly-cli', version);
12
+ await oauthClient.login(reuniteUrl);
30
13
  }
31
- else {
32
- try {
33
- const region = argv.residency || config.region;
34
- const client = new openapi_core_1.RedoclyClient(region);
35
- const clientToken = await promptClientToken(client.domain);
36
- process.stdout.write((0, colorette_1.gray)('\n Logging in...\n'));
37
- await client.login(clientToken, argv.verbose);
38
- process.stdout.write((0, colorette_1.green)(' Authorization confirmed. ✅\n\n'));
14
+ catch {
15
+ if (argv.residency) {
16
+ const reuniteUrl = (0, api_1.getReuniteUrl)(argv.residency);
17
+ (0, miscellaneous_1.exitWithError)(`❌ Connection to ${reuniteUrl} failed.`);
39
18
  }
40
- catch (err) {
41
- (0, miscellaneous_1.exitWithError)(' ' + err?.message);
19
+ else {
20
+ (0, miscellaneous_1.exitWithError)(`❌ Login failed. Please check your credentials and try again.`);
42
21
  }
43
22
  }
44
23
  }
45
24
  async function handleLogout({ version }) {
46
- const client = new openapi_core_1.RedoclyClient();
47
- client.logout();
48
25
  const oauthClient = new oauth_client_1.RedoclyOAuthClient('redocly-cli', version);
49
26
  oauthClient.logout();
50
27
  process.stdout.write('Logged out from the Redocly account. ✋ \n');
@@ -36,7 +36,7 @@ function getObjectOrJSON(openapiOptions, config) {
36
36
  default: {
37
37
  if (config) {
38
38
  process.stdout.write(`Found ${config.configFile} and using theme.openapi options\n`);
39
- return config.theme.openapi ? config.theme.openapi : {};
39
+ return config.theme.openapi ? config.theme.openapi : {}; // FIXME: ? theme is deprecated
40
40
  }
41
41
  return {};
42
42
  }
@@ -1,4 +1,4 @@
1
- import type { OutputExtensions, Skips, VerifyConfigOptions } from '../types';
1
+ import type { OutputExtensions, VerifyConfigOptions } from '../types';
2
2
  import type { CommandArgs } from '../wrapper';
3
3
  export type BundleOptions = {
4
4
  apis?: string[];
@@ -10,5 +10,7 @@ export type BundleOptions = {
10
10
  metafile?: string;
11
11
  'remove-unused-components'?: boolean;
12
12
  'keep-url-references'?: boolean;
13
- } & Skips & VerifyConfigOptions;
13
+ 'skip-decorator'?: string[];
14
+ 'skip-preprocessor'?: string[];
15
+ } & VerifyConfigOptions;
14
16
  export declare function handleBundle({ argv, config, version, collectSpecData, }: CommandArgs<BundleOptions>): Promise<void>;
@@ -24,6 +24,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
24
24
  if (usedTagsOptions.length > 1) {
25
25
  return (0, miscellaneous_1.exitWithError)(`You use ${(0, colorette_1.yellow)(usedTagsOptions.join(', '))} together.\nPlease choose only one!`);
26
26
  }
27
+ // FIXME: decide on the behaviour. Can we join by aliases? If yes, then I'd expect decorators to be applied
27
28
  const apis = await (0, miscellaneous_1.getFallbackApisOrExit)(argv.apis, config);
28
29
  if (apis.length < 2) {
29
30
  return (0, miscellaneous_1.exitWithError)(`At least 2 APIs should be provided.`);
@@ -1,6 +1,6 @@
1
1
  import type { OutputFormat } from '@redocly/openapi-core';
2
2
  import type { RawConfigProcessor } from '@redocly/openapi-core/lib/config';
3
- import type { CommandOptions, Skips, VerifyConfigOptions } from '../types';
3
+ import type { CommandOptions, VerifyConfigOptions } from '../types';
4
4
  import type { CommandArgs } from '../wrapper';
5
5
  export type LintOptions = {
6
6
  apis?: string[];
@@ -8,6 +8,8 @@ export type LintOptions = {
8
8
  extends?: string[];
9
9
  format: OutputFormat;
10
10
  'generate-ignore-file'?: boolean;
11
- } & Omit<Skips, 'skip-decorator'> & VerifyConfigOptions;
11
+ 'skip-rule'?: string[];
12
+ 'skip-preprocessor'?: string[];
13
+ } & VerifyConfigOptions;
12
14
  export declare function handleLint({ argv, config, version, collectSpecData, }: CommandArgs<LintOptions>): Promise<void>;
13
15
  export declare function lintConfigCallback(argv: CommandOptions & Record<string, undefined>, version: string): RawConfigProcessor | undefined;
@@ -5,10 +5,11 @@ exports.startsWithComponents = startsWithComponents;
5
5
  exports.crawl = crawl;
6
6
  exports.iteratePathItems = iteratePathItems;
7
7
  const colorette_1 = require("colorette");
8
- const fs = require("fs");
8
+ const fs = require("node:fs");
9
+ const process = require("node:process");
9
10
  const openapi_core_1 = require("@redocly/openapi-core");
10
11
  const utils_1 = require("@redocly/openapi-core/lib/utils");
11
- const path = require("path");
12
+ const path = require("node:path");
12
13
  const perf_hooks_1 = require("perf_hooks");
13
14
  const miscellaneous_1 = require("../../utils/miscellaneous");
14
15
  const js_utils_1 = require("../../utils/js-utils");
package/lib/index.js CHANGED
@@ -7,10 +7,10 @@ require("./utils/assert-node-version");
7
7
  const yargs = require("yargs");
8
8
  const colors = require("colorette");
9
9
  const types_1 = require("./types");
10
- const preview_docs_1 = require("./commands/preview-docs");
11
10
  const stats_1 = require("./commands/stats");
12
11
  const split_1 = require("./commands/split");
13
12
  const join_1 = require("./commands/join");
13
+ const push_1 = require("./reunite/commands/push");
14
14
  const push_status_1 = require("./reunite/commands/push-status");
15
15
  const lint_1 = require("./commands/lint");
16
16
  const bundle_1 = require("./commands/bundle");
@@ -22,7 +22,6 @@ const preview_project_1 = require("./commands/preview-project");
22
22
  const translations_1 = require("./commands/translations");
23
23
  const eject_1 = require("./commands/eject");
24
24
  const constants_1 = require("./commands/preview-project/constants");
25
- const push_1 = require("./commands/push");
26
25
  dotenv.config({ path: path.resolve(process.cwd(), './.env') });
27
26
  if (!('replaceAll' in String.prototype)) {
28
27
  require('core-js/actual/string/replace-all');
@@ -121,42 +120,14 @@ yargs
121
120
  choices: ['warn', 'error', 'off'],
122
121
  default: 'warn',
123
122
  },
124
- lint: {
125
- hidden: true,
126
- deprecated: true,
127
- },
128
- decorate: {
129
- hidden: true,
130
- deprecated: true,
131
- },
132
- preprocess: {
133
- hidden: true,
134
- deprecated: true,
135
- },
136
123
  }), (argv) => {
137
- const DEPRECATED_OPTIONS = ['lint', 'preprocess', 'decorate'];
138
- const DECORATORS_DOCUMENTATION_LINK = 'https://redocly.com/docs/cli/decorators/#decorators';
139
- const JOIN_COMMAND_DOCUMENTATION_LINK = 'https://redocly.com/docs/cli/commands/join/#join';
140
- DEPRECATED_OPTIONS.forEach((option) => {
141
- if (argv[option]) {
142
- process.stdout.write(`${colors.red(`Option --${option} is no longer supported. Please review join command documentation ${JOIN_COMMAND_DOCUMENTATION_LINK}.`)}`);
143
- process.stdout.write('\n\n');
144
- if (['preprocess', 'decorate'].includes(option)) {
145
- process.stdout.write(`${colors.red(`If you are looking for decorators, please review the decorators documentation ${DECORATORS_DOCUMENTATION_LINK}.`)}`);
146
- process.stdout.write('\n\n');
147
- }
148
- yargs.showHelp();
149
- process.exit(1);
150
- }
151
- });
152
- process.env.REDOCLY_CLI_COMMAND = 'join';
153
124
  (0, wrapper_1.commandWrapper)(join_1.handleJoin)(argv);
154
125
  })
155
126
  .command('push-status [pushId]', false, (yargs) => yargs
156
127
  .positional('pushId', {
157
128
  description: 'Push id.',
158
129
  type: 'string',
159
- required: true,
130
+ demandOption: true,
160
131
  })
161
132
  .implies('max-execution-time', 'wait')
162
133
  .option({
@@ -164,6 +135,7 @@ yargs
164
135
  description: 'Name of the organization to push to.',
165
136
  type: 'string',
166
137
  alias: 'o',
138
+ required: true,
167
139
  },
168
140
  project: {
169
141
  description: 'Name of the project to push to.',
@@ -195,79 +167,18 @@ yargs
195
167
  process.env.REDOCLY_CLI_COMMAND = 'push-status';
196
168
  (0, wrapper_1.commandWrapper)(push_status_1.handlePushStatus)(argv);
197
169
  })
198
- .command('push [apis...]', 'Push an API description to the Redocly API registry.', (yargs) => yargs
199
- .positional('apis', {
170
+ .command('push [files...]', 'Push documents to Reunite.', (yargs) => yargs
171
+ .positional('files', {
200
172
  type: 'string',
201
173
  array: true,
202
- required: true,
203
- default: [],
174
+ demandOption: true,
204
175
  })
205
- .hide('project')
206
- .hide('domain')
207
- .hide('mount-path')
208
- .hide('author')
209
- .hide('message')
210
- .hide('default-branch')
211
- .hide('verbose')
212
- .hide('commit-sha')
213
- .hide('commit-url')
214
- .hide('namespace')
215
- .hide('repository')
216
- .hide('wait-for-deployment')
217
- .hide('created-at')
218
- .hide('max-execution-time')
219
- .deprecateOption('batch-id', 'use --job-id')
220
- .implies('job-id', 'batch-size')
221
- .implies('batch-id', 'batch-size')
222
- .implies('batch-size', 'job-id')
223
- .implies('max-execution-time', 'wait-for-deployment')
224
176
  .option({
225
- destination: {
226
- description: 'API name and version in the format `name@version`.',
227
- type: 'string',
228
- alias: 'd',
229
- },
230
177
  branch: {
231
178
  description: 'Branch name to push to.',
232
179
  type: 'string',
233
180
  alias: 'b',
234
- },
235
- upsert: {
236
- description: "Create the specified API version if it doesn't exist, update if it does exist.",
237
- type: 'boolean',
238
- alias: 'u',
239
- },
240
- 'batch-id': {
241
- description: 'Specifies the ID of the CI job that the current push will be associated with.',
242
- type: 'string',
243
- requiresArg: true,
244
- deprecated: true,
245
- hidden: true,
246
- },
247
- 'job-id': {
248
- description: 'ID of the CI job that the current push will be associated with.',
249
- type: 'string',
250
- requiresArg: true,
251
- },
252
- 'batch-size': {
253
- description: 'Number of CI pushes to expect in a batch.',
254
- type: 'number',
255
- requiresArg: true,
256
- },
257
- region: { description: 'Specify a region.', alias: 'r', choices: types_1.regionChoices },
258
- 'skip-decorator': {
259
- description: 'Ignore certain decorators.',
260
- array: true,
261
- type: 'string',
262
- },
263
- public: {
264
- description: 'Make the API description available to the public',
265
- type: 'boolean',
266
- },
267
- files: {
268
- description: 'List of other folders and files to upload',
269
- array: true,
270
- type: 'string',
181
+ required: true,
271
182
  },
272
183
  'lint-config': {
273
184
  description: 'Severity level for config file linting.',
@@ -278,26 +189,31 @@ yargs
278
189
  description: 'Name of the organization to push to.',
279
190
  type: 'string',
280
191
  alias: 'o',
192
+ required: true,
281
193
  },
282
194
  project: {
283
195
  description: 'Name of the project to push to.',
284
196
  type: 'string',
285
197
  alias: 'p',
198
+ required: true,
286
199
  },
287
200
  'mount-path': {
288
201
  description: 'The path files should be pushed to.',
289
202
  type: 'string',
290
203
  alias: 'mp',
204
+ required: true,
291
205
  },
292
206
  author: {
293
207
  description: 'Author of the commit.',
294
208
  type: 'string',
295
209
  alias: 'a',
210
+ required: true,
296
211
  },
297
212
  message: {
298
213
  description: 'Commit message.',
299
214
  type: 'string',
300
215
  alias: 'm',
216
+ required: true,
301
217
  },
302
218
  'commit-sha': {
303
219
  description: 'Commit SHA.',
@@ -351,7 +267,7 @@ yargs
351
267
  },
352
268
  }), (argv) => {
353
269
  process.env.REDOCLY_CLI_COMMAND = 'push';
354
- (0, wrapper_1.commandWrapper)((0, push_1.commonPushHandler)(argv))(argv);
270
+ (0, wrapper_1.commandWrapper)(push_1.handlePush)(argv);
355
271
  })
356
272
  .command('lint [apis...]', 'Lint an API or Arazzo description.', (yargs) => yargs.positional('apis', { array: true, type: 'string', demandOption: true }).option({
357
273
  format: {
@@ -471,24 +387,6 @@ yargs
471
387
  choices: ['warn', 'error', 'off'],
472
388
  default: 'warn',
473
389
  },
474
- format: {
475
- hidden: true,
476
- deprecated: true,
477
- },
478
- lint: {
479
- hidden: true,
480
- deprecated: true,
481
- },
482
- 'skip-rule': {
483
- hidden: true,
484
- deprecated: true,
485
- array: true,
486
- type: 'string',
487
- },
488
- 'max-problems': {
489
- hidden: true,
490
- deprecated: true,
491
- },
492
390
  })
493
391
  .check((argv) => {
494
392
  if (argv.output && (!argv.apis || argv.apis.length === 0)) {
@@ -496,17 +394,6 @@ yargs
496
394
  }
497
395
  return true;
498
396
  }), (argv) => {
499
- const DEPRECATED_OPTIONS = ['lint', 'format', 'skip-rule', 'max-problems'];
500
- const LINT_AND_BUNDLE_DOCUMENTATION_LINK = 'https://redocly.com/docs/cli/guides/lint-and-bundle/#lint-and-bundle-api-descriptions-with-redocly-cli';
501
- DEPRECATED_OPTIONS.forEach((option) => {
502
- if (argv[option]) {
503
- process.stdout.write(`${colors.red(`Option --${option} is no longer supported. Please use separate commands, as described in the ${LINT_AND_BUNDLE_DOCUMENTATION_LINK}.`)}`);
504
- process.stdout.write('\n\n');
505
- yargs.showHelp();
506
- process.exit(1);
507
- }
508
- });
509
- process.env.REDOCLY_CLI_COMMAND = 'bundle';
510
397
  (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)(argv);
511
398
  })
512
399
  .command('check-config', 'Lint the Redocly configuration file.', async (yargs) => yargs.option({
@@ -524,13 +411,9 @@ yargs
524
411
  (0, wrapper_1.commandWrapper)()(argv);
525
412
  })
526
413
  .command('login', 'Log in to Redocly.', async (yargs) => yargs.options({
527
- verbose: {
528
- description: 'Include additional output.',
529
- type: 'boolean',
530
- },
531
414
  residency: {
532
415
  description: 'Residency of the application. Defaults to `us`.',
533
- alias: ['r', 'region'],
416
+ alias: ['r'],
534
417
  type: 'string',
535
418
  },
536
419
  config: {
@@ -538,15 +421,11 @@ yargs
538
421
  requiresArg: true,
539
422
  type: 'string',
540
423
  },
541
- next: {
542
- description: 'Use Reunite application to login.',
543
- type: 'boolean',
544
- },
545
424
  }), (argv) => {
546
425
  process.env.REDOCLY_CLI_COMMAND = 'login';
547
426
  (0, wrapper_1.commandWrapper)(auth_1.handleLogin)(argv);
548
427
  })
549
- .command('logout', 'Clear your stored credentials for the Redocly API registry.', (yargs) => yargs, (argv) => {
428
+ .command('logout', 'Clear your stored credentials.', (yargs) => yargs, (argv) => {
550
429
  process.env.REDOCLY_CLI_COMMAND = 'logout';
551
430
  (0, wrapper_1.commandWrapper)(auth_1.handleLogout)(argv);
552
431
  })
@@ -583,51 +462,6 @@ yargs
583
462
  process.stderr.write(colors.red('Option --source-dir is deprecated and will be removed soon. Use --project-dir instead.\n'));
584
463
  }
585
464
  (0, wrapper_1.commandWrapper)(preview_project_1.previewProject)(argv);
586
- })
587
- .command('preview-docs [api]', 'Preview API reference docs for an API description.', (yargs) => yargs.positional('api', { type: 'string' }).options({
588
- port: {
589
- alias: 'p',
590
- type: 'number',
591
- default: 8080,
592
- description: 'Preview port.',
593
- },
594
- host: {
595
- alias: 'h',
596
- type: 'string',
597
- default: '127.0.0.1',
598
- description: 'Preview host.',
599
- },
600
- 'skip-preprocessor': {
601
- description: 'Ignore certain preprocessors.',
602
- array: true,
603
- type: 'string',
604
- },
605
- 'skip-decorator': {
606
- description: 'Ignore certain decorators.',
607
- array: true,
608
- type: 'string',
609
- },
610
- 'use-community-edition': {
611
- description: 'Use Redoc CE for documentation preview.',
612
- type: 'boolean',
613
- },
614
- force: {
615
- alias: 'f',
616
- type: 'boolean',
617
- description: 'Produce bundle output even when errors occur.',
618
- },
619
- config: {
620
- description: 'Path to the config file.',
621
- type: 'string',
622
- },
623
- 'lint-config': {
624
- description: 'Severity level for config file linting.',
625
- choices: ['warn', 'error', 'off'],
626
- default: 'warn',
627
- },
628
- }), (argv) => {
629
- process.env.REDOCLY_CLI_COMMAND = 'preview-docs';
630
- (0, wrapper_1.commandWrapper)(preview_docs_1.previewDocs)(argv);
631
465
  })
632
466
  .command('build-docs [api]', 'Produce API documentation as an HTML file', (yargs) => yargs
633
467
  .positional('api', { type: 'string' })
@@ -1 +1 @@
1
- export declare function getApiKeys(domain: string): any;
1
+ export declare function getApiKeys(): string;
@@ -1,23 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getApiKeys = getApiKeys;
4
- const path_1 = require("path");
5
- const os_1 = require("os");
6
- const fs_1 = require("fs");
7
- const utils_1 = require("@redocly/openapi-core/lib/utils");
8
- const redocly_1 = require("@redocly/openapi-core/lib/redocly");
9
- function readCredentialsFile(credentialsPath) {
10
- return (0, fs_1.existsSync)(credentialsPath) ? JSON.parse((0, fs_1.readFileSync)(credentialsPath, 'utf-8')) : {};
11
- }
12
- function getApiKeys(domain) {
13
- const apiKey = process.env.REDOCLY_AUTHORIZATION;
14
- if (apiKey) {
15
- return apiKey;
16
- }
17
- const credentialsPath = (0, path_1.resolve)((0, os_1.homedir)(), redocly_1.TOKEN_FILENAME);
18
- const credentials = readCredentialsFile(credentialsPath);
19
- if ((0, utils_1.isNotEmptyObject)(credentials) && credentials[domain]) {
20
- return credentials[domain];
4
+ function getApiKeys() {
5
+ if (process.env.REDOCLY_AUTHORIZATION) {
6
+ return process.env.REDOCLY_AUTHORIZATION;
21
7
  }
22
8
  throw new Error('No api key provided, please use environment variable REDOCLY_AUTHORIZATION.');
23
9
  }
@@ -1,4 +1,6 @@
1
- import type { Region } from '@redocly/openapi-core';
2
- export declare const REUNITE_URLS: Record<Region, string>;
1
+ export declare const REUNITE_URLS: {
2
+ readonly us: "https://app.cloud.redocly.com";
3
+ readonly eu: "https://app.cloud.eu.redocly.com";
4
+ };
3
5
  export declare function getDomain(): string;
4
6
  export declare function getReuniteUrl(residency?: string): string;
@@ -10,13 +10,8 @@ exports.REUNITE_URLS = {
10
10
  function getDomain() {
11
11
  return process.env.REDOCLY_DOMAIN || exports.REUNITE_URLS.us;
12
12
  }
13
- function getReuniteUrl(residency) {
14
- if (!residency)
15
- residency = 'us';
16
- let reuniteUrl = exports.REUNITE_URLS[residency];
17
- if (!reuniteUrl) {
18
- reuniteUrl = residency;
19
- }
13
+ function getReuniteUrl(residency = 'us') {
14
+ const reuniteUrl = exports.REUNITE_URLS[residency] || residency;
20
15
  const url = new URL('/api', reuniteUrl).toString();
21
16
  return url;
22
17
  }
@@ -1,12 +1,12 @@
1
1
  import type { OutputFormat } from '@redocly/openapi-core';
2
2
  import type { CommandArgs } from '../../wrapper';
3
3
  import type { DeploymentStatusResponse, PushResponse } from '../api/types';
4
+ import type { VerifyConfigOptions } from '../../types';
4
5
  export type PushStatusOptions = {
5
6
  organization: string;
6
7
  project: string;
7
8
  pushId: string;
8
9
  domain?: string;
9
- config?: string;
10
10
  format?: Extract<OutputFormat, 'stylish'>;
11
11
  wait?: boolean;
12
12
  'max-execution-time'?: number;
@@ -14,10 +14,10 @@ export type PushStatusOptions = {
14
14
  'start-time'?: number;
15
15
  'continue-on-deploy-failures'?: boolean;
16
16
  onRetry?: (lasSummary: PushStatusSummary) => void;
17
- };
17
+ } & VerifyConfigOptions;
18
18
  export interface PushStatusSummary {
19
19
  preview: DeploymentStatusResponse;
20
20
  production: DeploymentStatusResponse | null;
21
21
  commit: PushResponse['commit'];
22
22
  }
23
- export declare function handlePushStatus({ argv, config, version, }: CommandArgs<PushStatusOptions>): Promise<PushStatusSummary | void>;
23
+ export declare function handlePushStatus({ argv, version, }: CommandArgs<PushStatusOptions>): Promise<PushStatusSummary | void>;
@@ -9,15 +9,10 @@ const api_1 = require("../api");
9
9
  const js_utils_1 = require("../../utils/js-utils");
10
10
  const utils_2 = require("./utils");
11
11
  const RETRY_INTERVAL_MS = 5000; // 5 sec
12
- async function handlePushStatus({ argv, config, version, }) {
12
+ async function handlePushStatus({ argv, version, }) {
13
13
  const startedAt = performance.now();
14
14
  const spinner = new spinner_1.Spinner();
15
15
  const { organization, project: projectId, pushId, wait } = argv;
16
- const orgId = organization || config.organization;
17
- if (!orgId) {
18
- (0, miscellaneous_1.exitWithError)(`No organization provided, please use --organization option or specify the 'organization' field in the config file.`);
19
- return;
20
- }
21
16
  const domain = argv.domain || (0, api_1.getDomain)();
22
17
  const maxExecutionTime = argv['max-execution-time'] || 1200; // 20 min
23
18
  const retryIntervalMs = argv['retry-interval']
@@ -27,12 +22,12 @@ async function handlePushStatus({ argv, config, version, }) {
27
22
  const retryTimeoutMs = maxExecutionTime * 1000;
28
23
  const continueOnDeployFailures = argv['continue-on-deploy-failures'] || false;
29
24
  try {
30
- const apiKey = (0, api_1.getApiKeys)(domain);
25
+ const apiKey = (0, api_1.getApiKeys)();
31
26
  const client = new api_1.ReuniteApi({ domain, apiKey, version, command: 'push-status' });
32
27
  let pushResponse;
33
28
  pushResponse = await (0, utils_2.retryUntilConditionMet)({
34
29
  operation: () => client.remotes.getPush({
35
- organizationId: orgId,
30
+ organizationId: organization,
36
31
  projectId,
37
32
  pushId,
38
33
  }),
@@ -76,7 +71,7 @@ async function handlePushStatus({ argv, config, version, }) {
76
71
  if (shouldWaitForProdDeployment) {
77
72
  pushResponse = await (0, utils_2.retryUntilConditionMet)({
78
73
  operation: () => client.remotes.getPush({
79
- organizationId: orgId,
74
+ organizationId: organization,
80
75
  projectId,
81
76
  pushId,
82
77
  }),
@@ -118,7 +113,7 @@ async function handlePushStatus({ argv, config, version, }) {
118
113
  });
119
114
  printScorecard(pushResponse.status.production.scorecard);
120
115
  }
121
- printPushStatusInfo({ orgId, projectId, pushId, startedAt });
116
+ printPushStatusInfo({ organization, projectId, pushId, startedAt });
122
117
  client.reportSunsetWarnings();
123
118
  const summary = {
124
119
  preview: pushResponse.status.preview,
@@ -135,8 +130,8 @@ async function handlePushStatus({ argv, config, version, }) {
135
130
  spinner.stop(); // Spinner can block process exit, so we need to stop it explicitly.
136
131
  }
137
132
  }
138
- function printPushStatusInfo({ orgId, projectId, pushId, startedAt, }) {
139
- process.stderr.write(`\nProcessed push-status for ${colors.yellow(orgId)}, ${colors.yellow(projectId)} and pushID ${colors.yellow(pushId)}.\n`);
133
+ function printPushStatusInfo({ organization, projectId, pushId, startedAt, }) {
134
+ process.stderr.write(`\nProcessed push-status for ${colors.yellow(organization)}, ${colors.yellow(projectId)} and pushID ${colors.yellow(pushId)}.\n`);
140
135
  (0, miscellaneous_1.printExecutionTime)('push-status', startedAt, 'Finished');
141
136
  }
142
137
  function printPushStatus({ buildType, spinner, push, continueOnDeployFailures, }) {
@@ -2,8 +2,8 @@ import type { OutputFormat } from '@redocly/openapi-core';
2
2
  import type { CommandArgs } from '../../wrapper';
3
3
  import type { VerifyConfigOptions } from '../../types';
4
4
  export type PushOptions = {
5
- apis?: string[];
6
- organization?: string;
5
+ files: string[];
6
+ organization: string;
7
7
  project: string;
8
8
  'mount-path': string;
9
9
  branch: string;
@@ -14,11 +14,10 @@ export type PushOptions = {
14
14
  namespace?: string;
15
15
  repository?: string;
16
16
  'created-at'?: string;
17
- files: string[];
18
17
  'default-branch': string;
19
18
  domain?: string;
20
19
  'wait-for-deployment'?: boolean;
21
- 'max-execution-time': number;
20
+ 'max-execution-time'?: number;
22
21
  'continue-on-deploy-failures'?: boolean;
23
22
  verbose?: boolean;
24
23
  format?: Extract<OutputFormat, 'stylish'>;