@redocly/cli 0.0.0-snapshot.1737554067

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 (133) hide show
  1. package/README.md +114 -0
  2. package/bin/cli.js +3 -0
  3. package/lib/__mocks__/@redocly/openapi-core.d.ts +99 -0
  4. package/lib/__mocks__/@redocly/openapi-core.js +84 -0
  5. package/lib/__mocks__/documents.d.ts +150 -0
  6. package/lib/__mocks__/documents.js +123 -0
  7. package/lib/__mocks__/fs.d.ts +8 -0
  8. package/lib/__mocks__/fs.js +9 -0
  9. package/lib/__mocks__/perf_hooks.d.ts +3 -0
  10. package/lib/__mocks__/perf_hooks.js +6 -0
  11. package/lib/__mocks__/redoc.d.ts +6 -0
  12. package/lib/__mocks__/redoc.js +5 -0
  13. package/lib/__tests__/commands/build-docs.test.d.ts +1 -0
  14. package/lib/__tests__/commands/build-docs.test.js +54 -0
  15. package/lib/__tests__/commands/bundle.test.d.ts +1 -0
  16. package/lib/__tests__/commands/bundle.test.js +235 -0
  17. package/lib/__tests__/commands/join.test.d.ts +1 -0
  18. package/lib/__tests__/commands/join.test.js +274 -0
  19. package/lib/__tests__/commands/lint.test.d.ts +1 -0
  20. package/lib/__tests__/commands/lint.test.js +149 -0
  21. package/lib/__tests__/commands/push-region.test.d.ts +1 -0
  22. package/lib/__tests__/commands/push-region.test.js +55 -0
  23. package/lib/__tests__/commands/push.test.d.ts +1 -0
  24. package/lib/__tests__/commands/push.test.js +463 -0
  25. package/lib/__tests__/fetch-with-timeout.test.d.ts +1 -0
  26. package/lib/__tests__/fetch-with-timeout.test.js +44 -0
  27. package/lib/__tests__/fixtures/config.d.ts +21 -0
  28. package/lib/__tests__/fixtures/config.js +24 -0
  29. package/lib/__tests__/spinner.test.d.ts +1 -0
  30. package/lib/__tests__/spinner.test.js +43 -0
  31. package/lib/__tests__/utils.test.d.ts +1 -0
  32. package/lib/__tests__/utils.test.js +593 -0
  33. package/lib/__tests__/wrapper.test.d.ts +1 -0
  34. package/lib/__tests__/wrapper.test.js +68 -0
  35. package/lib/cms/api/__tests__/api-keys.test.d.ts +1 -0
  36. package/lib/cms/api/__tests__/api-keys.test.js +26 -0
  37. package/lib/cms/api/__tests__/api.client.test.d.ts +1 -0
  38. package/lib/cms/api/__tests__/api.client.test.js +333 -0
  39. package/lib/cms/api/__tests__/domains.test.d.ts +1 -0
  40. package/lib/cms/api/__tests__/domains.test.js +13 -0
  41. package/lib/cms/api/api-client.d.ts +75 -0
  42. package/lib/cms/api/api-client.js +225 -0
  43. package/lib/cms/api/api-keys.d.ts +1 -0
  44. package/lib/cms/api/api-keys.js +23 -0
  45. package/lib/cms/api/domains.d.ts +1 -0
  46. package/lib/cms/api/domains.js +11 -0
  47. package/lib/cms/api/index.d.ts +3 -0
  48. package/lib/cms/api/index.js +19 -0
  49. package/lib/cms/api/types.d.ts +102 -0
  50. package/lib/cms/api/types.js +2 -0
  51. package/lib/cms/commands/__tests__/push-status.test.d.ts +1 -0
  52. package/lib/cms/commands/__tests__/push-status.test.js +563 -0
  53. package/lib/cms/commands/__tests__/push.test.d.ts +1 -0
  54. package/lib/cms/commands/__tests__/push.test.js +315 -0
  55. package/lib/cms/commands/__tests__/utils.test.d.ts +1 -0
  56. package/lib/cms/commands/__tests__/utils.test.js +51 -0
  57. package/lib/cms/commands/push-status.d.ts +23 -0
  58. package/lib/cms/commands/push-status.js +206 -0
  59. package/lib/cms/commands/push.d.ts +28 -0
  60. package/lib/cms/commands/push.js +142 -0
  61. package/lib/cms/commands/utils.d.ts +25 -0
  62. package/lib/cms/commands/utils.js +46 -0
  63. package/lib/cms/utils.d.ts +2 -0
  64. package/lib/cms/utils.js +6 -0
  65. package/lib/commands/build-docs/index.d.ts +3 -0
  66. package/lib/commands/build-docs/index.js +39 -0
  67. package/lib/commands/build-docs/template.hbs +23 -0
  68. package/lib/commands/build-docs/types.d.ts +23 -0
  69. package/lib/commands/build-docs/types.js +2 -0
  70. package/lib/commands/build-docs/utils.d.ts +7 -0
  71. package/lib/commands/build-docs/utils.js +87 -0
  72. package/lib/commands/bundle.d.ts +14 -0
  73. package/lib/commands/bundle.js +91 -0
  74. package/lib/commands/eject.d.ts +9 -0
  75. package/lib/commands/eject.js +28 -0
  76. package/lib/commands/join.d.ts +11 -0
  77. package/lib/commands/join.js +565 -0
  78. package/lib/commands/lint.d.ts +13 -0
  79. package/lib/commands/lint.js +108 -0
  80. package/lib/commands/login.d.ts +9 -0
  81. package/lib/commands/login.js +23 -0
  82. package/lib/commands/preview-docs/index.d.ts +12 -0
  83. package/lib/commands/preview-docs/index.js +127 -0
  84. package/lib/commands/preview-docs/preview-server/default.hbs +24 -0
  85. package/lib/commands/preview-docs/preview-server/hot.js +59 -0
  86. package/lib/commands/preview-docs/preview-server/oauth2-redirect.html +21 -0
  87. package/lib/commands/preview-docs/preview-server/preview-server.d.ts +5 -0
  88. package/lib/commands/preview-docs/preview-server/preview-server.js +113 -0
  89. package/lib/commands/preview-docs/preview-server/server.d.ts +22 -0
  90. package/lib/commands/preview-docs/preview-server/server.js +85 -0
  91. package/lib/commands/preview-project/constants.d.ts +14 -0
  92. package/lib/commands/preview-project/constants.js +22 -0
  93. package/lib/commands/preview-project/index.d.ts +3 -0
  94. package/lib/commands/preview-project/index.js +56 -0
  95. package/lib/commands/preview-project/types.d.ts +10 -0
  96. package/lib/commands/preview-project/types.js +2 -0
  97. package/lib/commands/push.d.ts +44 -0
  98. package/lib/commands/push.js +295 -0
  99. package/lib/commands/split/__tests__/index.test.d.ts +1 -0
  100. package/lib/commands/split/__tests__/index.test.js +91 -0
  101. package/lib/commands/split/index.d.ts +13 -0
  102. package/lib/commands/split/index.js +259 -0
  103. package/lib/commands/split/types.d.ts +36 -0
  104. package/lib/commands/split/types.js +51 -0
  105. package/lib/commands/stats.d.ts +8 -0
  106. package/lib/commands/stats.js +96 -0
  107. package/lib/commands/translations.d.ts +7 -0
  108. package/lib/commands/translations.js +20 -0
  109. package/lib/index.d.ts +2 -0
  110. package/lib/index.js +733 -0
  111. package/lib/types.d.ts +43 -0
  112. package/lib/types.js +5 -0
  113. package/lib/utils/__mocks__/miscellaneous.d.ts +43 -0
  114. package/lib/utils/__mocks__/miscellaneous.js +24 -0
  115. package/lib/utils/assert-node-version.d.ts +1 -0
  116. package/lib/utils/assert-node-version.js +16 -0
  117. package/lib/utils/fetch-with-timeout.d.ts +7 -0
  118. package/lib/utils/fetch-with-timeout.js +26 -0
  119. package/lib/utils/getCommandNameFromArgs.d.ts +2 -0
  120. package/lib/utils/getCommandNameFromArgs.js +6 -0
  121. package/lib/utils/js-utils.d.ts +5 -0
  122. package/lib/utils/js-utils.js +28 -0
  123. package/lib/utils/miscellaneous.d.ts +81 -0
  124. package/lib/utils/miscellaneous.js +551 -0
  125. package/lib/utils/platform.d.ts +16 -0
  126. package/lib/utils/platform.js +34 -0
  127. package/lib/utils/spinner.d.ts +10 -0
  128. package/lib/utils/spinner.js +42 -0
  129. package/lib/utils/update-version-notifier.d.ts +3 -0
  130. package/lib/utils/update-version-notifier.js +102 -0
  131. package/lib/wrapper.d.ts +11 -0
  132. package/lib/wrapper.js +65 -0
  133. package/package.json +69 -0
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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];
21
+ }
22
+ throw new Error('No api key provided, please use environment variable REDOCLY_AUTHORIZATION.');
23
+ }
@@ -0,0 +1 @@
1
+ export declare function getDomain(): string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDomain = getDomain;
4
+ const DEFAULT_DOMAIN = 'https://app.cloud.redocly.com';
5
+ function getDomain() {
6
+ const domain = process.env.REDOCLY_DOMAIN;
7
+ if (domain) {
8
+ return domain;
9
+ }
10
+ return DEFAULT_DOMAIN;
11
+ }
@@ -0,0 +1,3 @@
1
+ export * from './api-client';
2
+ export * from './domains';
3
+ export * from './api-keys';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api-client"), exports);
18
+ __exportStar(require("./domains"), exports);
19
+ __exportStar(require("./api-keys"), exports);
@@ -0,0 +1,102 @@
1
+ export type ProjectSourceResponse = {
2
+ branchName: string;
3
+ contentPath: string;
4
+ isInternal: boolean;
5
+ };
6
+ export type UpsertRemoteResponse = {
7
+ id: string;
8
+ type: 'CICD';
9
+ mountPath: string;
10
+ mountBranchName: string;
11
+ organizationId: string;
12
+ projectId: string;
13
+ };
14
+ export type ListRemotesResponse = {
15
+ object: 'list';
16
+ page: {
17
+ endCursor: string;
18
+ startCursor: string;
19
+ haxNextPage: boolean;
20
+ hasPrevPage: boolean;
21
+ limit: number;
22
+ total: number;
23
+ };
24
+ items: Remote[];
25
+ };
26
+ export type Remote = {
27
+ mountPath: string;
28
+ type: string;
29
+ autoSync: boolean;
30
+ autoMerge: boolean;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ providerType: string;
34
+ namespaceId: string;
35
+ repositoryId: string;
36
+ projectId: string;
37
+ mountBranchName: string;
38
+ contentPath: string;
39
+ credentialId: string;
40
+ branchName: string;
41
+ contentType: string;
42
+ id: string;
43
+ };
44
+ export type PushResponse = {
45
+ id: string;
46
+ remoteId: string;
47
+ isMainBranch: boolean;
48
+ isOutdated: boolean;
49
+ hasChanges: boolean;
50
+ replace: boolean;
51
+ scoutJobId: string | null;
52
+ uploadedFiles: Array<{
53
+ path: string;
54
+ mimeType: string;
55
+ }>;
56
+ commit: {
57
+ branchName: string;
58
+ message: string;
59
+ createdAt: string | null;
60
+ namespaceId: string | null;
61
+ repositoryId: string | null;
62
+ url: string | null;
63
+ sha: string | null;
64
+ author: {
65
+ name: string;
66
+ email: string;
67
+ image: string | null;
68
+ };
69
+ statuses: Array<{
70
+ name: string;
71
+ description: string;
72
+ status: 'pending' | 'running' | 'success' | 'failed';
73
+ url: string | null;
74
+ }>;
75
+ };
76
+ remote: {
77
+ commits: {
78
+ sha: string;
79
+ branchName: string;
80
+ }[];
81
+ };
82
+ status: PushStatusResponse;
83
+ };
84
+ export type DeploymentStatusResponse = {
85
+ deploy: {
86
+ url: string | null;
87
+ status: DeploymentStatus;
88
+ };
89
+ scorecard: ScorecardItem[];
90
+ };
91
+ export type PushStatusResponse = {
92
+ preview: DeploymentStatusResponse;
93
+ production: DeploymentStatusResponse;
94
+ };
95
+ export type ScorecardItem = {
96
+ name: string;
97
+ status: PushStatusBase;
98
+ description: string;
99
+ url: string;
100
+ };
101
+ export type PushStatusBase = 'pending' | 'success' | 'running' | 'failed';
102
+ export type DeploymentStatus = 'skipped' | PushStatusBase;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};