@redocly/cli 1.34.4 → 2.0.0-next.1

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 (321) hide show
  1. package/README.md +34 -3
  2. package/bin/cli.js +1 -1
  3. package/lib/auth/device-flow.d.ts +1 -0
  4. package/lib/auth/device-flow.d.ts.map +1 -0
  5. package/lib/auth/device-flow.js +15 -17
  6. package/lib/auth/device-flow.js.map +1 -0
  7. package/lib/auth/oauth-client.d.ts +1 -0
  8. package/lib/auth/oauth-client.d.ts.map +1 -0
  9. package/lib/auth/oauth-client.js +21 -23
  10. package/lib/auth/oauth-client.js.map +1 -0
  11. package/lib/commands/auth.d.ts +3 -5
  12. package/lib/commands/auth.d.ts.map +1 -0
  13. package/lib/commands/auth.js +19 -44
  14. package/lib/commands/auth.js.map +1 -0
  15. package/lib/commands/build-docs/index.d.ts +4 -3
  16. package/lib/commands/build-docs/index.d.ts.map +1 -0
  17. package/lib/commands/build-docs/index.js +23 -24
  18. package/lib/commands/build-docs/index.js.map +1 -0
  19. package/lib/commands/build-docs/types.d.ts +2 -1
  20. package/lib/commands/build-docs/types.d.ts.map +1 -0
  21. package/lib/commands/build-docs/types.js +2 -2
  22. package/lib/commands/build-docs/types.js.map +1 -0
  23. package/lib/commands/build-docs/utils.d.ts +3 -2
  24. package/lib/commands/build-docs/utils.d.ts.map +1 -0
  25. package/lib/commands/build-docs/utils.js +35 -37
  26. package/lib/commands/build-docs/utils.js.map +1 -0
  27. package/lib/commands/bundle.d.ts +6 -3
  28. package/lib/commands/bundle.d.ts.map +1 -0
  29. package/lib/commands/bundle.js +34 -38
  30. package/lib/commands/bundle.js.map +1 -0
  31. package/lib/commands/eject.d.ts +3 -2
  32. package/lib/commands/eject.d.ts.map +1 -0
  33. package/lib/commands/eject.js +11 -13
  34. package/lib/commands/eject.js.map +1 -0
  35. package/lib/commands/join.d.ts +4 -3
  36. package/lib/commands/join.d.ts.map +1 -0
  37. package/lib/commands/join.js +79 -81
  38. package/lib/commands/join.js.map +1 -0
  39. package/lib/commands/lint.d.ts +8 -6
  40. package/lib/commands/lint.d.ts.map +1 -0
  41. package/lib/commands/lint.js +53 -62
  42. package/lib/commands/lint.js.map +1 -0
  43. package/lib/commands/preview-project/constants.d.ts +2 -1
  44. package/lib/commands/preview-project/constants.d.ts.map +1 -0
  45. package/lib/commands/preview-project/constants.js +4 -6
  46. package/lib/commands/preview-project/constants.js.map +1 -0
  47. package/lib/commands/preview-project/index.d.ts +3 -2
  48. package/lib/commands/preview-project/index.d.ts.map +1 -0
  49. package/lib/commands/preview-project/index.js +21 -23
  50. package/lib/commands/preview-project/index.js.map +1 -0
  51. package/lib/commands/preview-project/types.d.ts +3 -2
  52. package/lib/commands/preview-project/types.d.ts.map +1 -0
  53. package/lib/commands/preview-project/types.js +2 -2
  54. package/lib/commands/preview-project/types.js.map +1 -0
  55. package/lib/commands/split/index.d.ts +4 -3
  56. package/lib/commands/split/index.d.ts.map +1 -0
  57. package/lib/commands/split/index.js +53 -57
  58. package/lib/commands/split/index.js.map +1 -0
  59. package/lib/commands/split/types.d.ts +2 -2
  60. package/lib/commands/split/types.d.ts.map +1 -0
  61. package/lib/commands/split/types.js +11 -13
  62. package/lib/commands/split/types.js.map +1 -0
  63. package/lib/commands/stats.d.ts +3 -2
  64. package/lib/commands/stats.d.ts.map +1 -0
  65. package/lib/commands/stats.js +21 -24
  66. package/lib/commands/stats.js.map +1 -0
  67. package/lib/commands/translations.d.ts +3 -2
  68. package/lib/commands/translations.d.ts.map +1 -0
  69. package/lib/commands/translations.js +11 -13
  70. package/lib/commands/translations.js.map +1 -0
  71. package/lib/index.d.ts +2 -1
  72. package/lib/index.d.ts.map +1 -0
  73. package/lib/index.js +109 -239
  74. package/lib/index.js.map +1 -0
  75. package/lib/otel.d.ts +2 -1
  76. package/lib/otel.d.ts.map +1 -0
  77. package/lib/otel.js +22 -23
  78. package/lib/otel.js.map +1 -0
  79. package/lib/reunite/api/api-client.d.ts +4 -3
  80. package/lib/reunite/api/api-client.d.ts.map +1 -0
  81. package/lib/reunite/api/api-client.js +14 -20
  82. package/lib/reunite/api/api-client.js.map +1 -0
  83. package/lib/reunite/api/api-keys.d.ts +2 -1
  84. package/lib/reunite/api/api-keys.d.ts.map +1 -0
  85. package/lib/reunite/api/api-keys.js +4 -20
  86. package/lib/reunite/api/api-keys.js.map +1 -0
  87. package/lib/reunite/api/domains.d.ts +5 -2
  88. package/lib/reunite/api/domains.d.ts.map +1 -0
  89. package/lib/reunite/api/domains.js +6 -15
  90. package/lib/reunite/api/domains.js.map +1 -0
  91. package/lib/reunite/api/index.d.ts +4 -3
  92. package/lib/reunite/api/index.d.ts.map +1 -0
  93. package/lib/reunite/api/index.js +4 -19
  94. package/lib/reunite/api/index.js.map +1 -0
  95. package/lib/reunite/api/types.d.ts +1 -0
  96. package/lib/reunite/api/types.d.ts.map +1 -0
  97. package/lib/reunite/api/types.js +2 -2
  98. package/lib/reunite/api/types.js.map +1 -0
  99. package/lib/reunite/commands/push-status.d.ts +6 -5
  100. package/lib/reunite/commands/push-status.d.ts.map +1 -0
  101. package/lib/reunite/commands/push-status.js +31 -37
  102. package/lib/reunite/commands/push-status.js.map +1 -0
  103. package/lib/reunite/commands/push.d.ts +6 -6
  104. package/lib/reunite/commands/push.d.ts.map +1 -0
  105. package/lib/reunite/commands/push.js +31 -40
  106. package/lib/reunite/commands/push.js.map +1 -0
  107. package/lib/reunite/commands/utils.d.ts +4 -3
  108. package/lib/reunite/commands/utils.d.ts.map +1 -0
  109. package/lib/reunite/commands/utils.js +9 -12
  110. package/lib/reunite/commands/utils.js.map +1 -0
  111. package/lib/reunite/utils.d.ts +1 -0
  112. package/lib/reunite/utils.d.ts.map +1 -0
  113. package/lib/reunite/utils.js +2 -5
  114. package/lib/reunite/utils.js.map +1 -0
  115. package/lib/types.d.ts +15 -27
  116. package/lib/types.d.ts.map +1 -0
  117. package/lib/types.js +2 -5
  118. package/lib/types.js.map +1 -0
  119. package/lib/utils/assert-node-version.d.ts +1 -0
  120. package/lib/utils/assert-node-version.d.ts.map +1 -0
  121. package/lib/utils/assert-node-version.js +8 -10
  122. package/lib/utils/assert-node-version.js.map +1 -0
  123. package/lib/utils/error.d.ts +4 -0
  124. package/lib/utils/error.d.ts.map +1 -0
  125. package/lib/utils/error.js +8 -0
  126. package/lib/utils/error.js.map +1 -0
  127. package/lib/utils/fetch-with-timeout.d.ts +1 -0
  128. package/lib/utils/fetch-with-timeout.d.ts.map +1 -0
  129. package/lib/utils/fetch-with-timeout.js +6 -8
  130. package/lib/utils/fetch-with-timeout.js.map +1 -0
  131. package/lib/utils/{getCommandNameFromArgs.d.ts → get-command-name-from-args.d.ts} +1 -0
  132. package/lib/utils/get-command-name-from-args.d.ts.map +1 -0
  133. package/lib/utils/get-command-name-from-args.js +4 -0
  134. package/lib/utils/get-command-name-from-args.js.map +1 -0
  135. package/lib/utils/js-utils.d.ts +1 -0
  136. package/lib/utils/js-utils.d.ts.map +1 -0
  137. package/lib/utils/js-utils.js +8 -12
  138. package/lib/utils/js-utils.js.map +1 -0
  139. package/lib/utils/miscellaneous.d.ts +9 -48
  140. package/lib/utils/miscellaneous.d.ts.map +1 -0
  141. package/lib/utils/miscellaneous.js +131 -269
  142. package/lib/utils/miscellaneous.js.map +1 -0
  143. package/lib/utils/package.d.ts +2 -0
  144. package/lib/utils/package.d.ts.map +1 -0
  145. package/lib/utils/package.js +4 -0
  146. package/lib/utils/package.js.map +1 -0
  147. package/lib/utils/platform.d.ts +1 -0
  148. package/lib/utils/platform.d.ts.map +1 -0
  149. package/lib/utils/platform.js +5 -9
  150. package/lib/utils/platform.js.map +1 -0
  151. package/lib/utils/proxy-agent.d.ts +3 -0
  152. package/lib/utils/proxy-agent.d.ts.map +1 -0
  153. package/lib/utils/proxy-agent.js +6 -0
  154. package/lib/utils/proxy-agent.js.map +1 -0
  155. package/lib/utils/spinner.d.ts +1 -0
  156. package/lib/utils/spinner.d.ts.map +1 -0
  157. package/lib/utils/spinner.js +8 -10
  158. package/lib/utils/spinner.js.map +1 -0
  159. package/lib/utils/telemetry.d.ts +40 -0
  160. package/lib/utils/telemetry.d.ts.map +1 -0
  161. package/lib/utils/telemetry.js +138 -0
  162. package/lib/utils/telemetry.js.map +1 -0
  163. package/lib/utils/update-version-notifier.d.ts +1 -1
  164. package/lib/utils/update-version-notifier.d.ts.map +1 -0
  165. package/lib/utils/update-version-notifier.js +35 -38
  166. package/lib/utils/update-version-notifier.js.map +1 -0
  167. package/lib/utils/validate-positive-number.d.ts +2 -0
  168. package/lib/utils/validate-positive-number.d.ts.map +1 -0
  169. package/lib/utils/validate-positive-number.js +13 -0
  170. package/lib/utils/validate-positive-number.js.map +1 -0
  171. package/lib/wrapper.d.ts +3 -3
  172. package/lib/wrapper.d.ts.map +1 -0
  173. package/lib/wrapper.js +39 -26
  174. package/lib/wrapper.js.map +1 -0
  175. package/package.json +16 -17
  176. package/CHANGELOG.md +0 -777
  177. package/lib/__mocks__/@redocly/openapi-core.d.ts +0 -99
  178. package/lib/__mocks__/@redocly/openapi-core.js +0 -84
  179. package/lib/__mocks__/documents.d.ts +0 -150
  180. package/lib/__mocks__/documents.js +0 -123
  181. package/lib/__mocks__/fs.d.ts +0 -8
  182. package/lib/__mocks__/fs.js +0 -9
  183. package/lib/__mocks__/perf_hooks.d.ts +0 -3
  184. package/lib/__mocks__/perf_hooks.js +0 -6
  185. package/lib/__mocks__/redoc.d.ts +0 -6
  186. package/lib/__mocks__/redoc.js +0 -5
  187. package/lib/__tests__/commands/build-docs.test.d.ts +0 -1
  188. package/lib/__tests__/commands/build-docs.test.js +0 -54
  189. package/lib/__tests__/commands/bundle.test.d.ts +0 -1
  190. package/lib/__tests__/commands/bundle.test.js +0 -235
  191. package/lib/__tests__/commands/join.test.d.ts +0 -1
  192. package/lib/__tests__/commands/join.test.js +0 -274
  193. package/lib/__tests__/commands/lint.test.d.ts +0 -1
  194. package/lib/__tests__/commands/lint.test.js +0 -149
  195. package/lib/__tests__/commands/push-region.test.d.ts +0 -1
  196. package/lib/__tests__/commands/push-region.test.js +0 -90
  197. package/lib/__tests__/commands/push.test.d.ts +0 -1
  198. package/lib/__tests__/commands/push.test.js +0 -496
  199. package/lib/__tests__/fetch-with-timeout.test.d.ts +0 -1
  200. package/lib/__tests__/fetch-with-timeout.test.js +0 -64
  201. package/lib/__tests__/fixtures/config.d.ts +0 -21
  202. package/lib/__tests__/fixtures/config.js +0 -24
  203. package/lib/__tests__/spinner.test.d.ts +0 -1
  204. package/lib/__tests__/spinner.test.js +0 -43
  205. package/lib/__tests__/utils.test.d.ts +0 -1
  206. package/lib/__tests__/utils.test.js +0 -651
  207. package/lib/__tests__/wrapper.test.d.ts +0 -1
  208. package/lib/__tests__/wrapper.test.js +0 -76
  209. package/lib/auth/__tests__/device-flow.test.d.ts +0 -1
  210. package/lib/auth/__tests__/device-flow.test.js +0 -62
  211. package/lib/auth/__tests__/oauth-client.test.d.ts +0 -1
  212. package/lib/auth/__tests__/oauth-client.test.js +0 -93
  213. package/lib/commands/preview-docs/index.d.ts +0 -12
  214. package/lib/commands/preview-docs/index.js +0 -127
  215. package/lib/commands/preview-docs/preview-server/default.hbs +0 -24
  216. package/lib/commands/preview-docs/preview-server/hot.js +0 -59
  217. package/lib/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
  218. package/lib/commands/preview-docs/preview-server/preview-server.d.ts +0 -5
  219. package/lib/commands/preview-docs/preview-server/preview-server.js +0 -113
  220. package/lib/commands/preview-docs/preview-server/server.d.ts +0 -22
  221. package/lib/commands/preview-docs/preview-server/server.js +0 -85
  222. package/lib/commands/push.d.ts +0 -44
  223. package/lib/commands/push.js +0 -301
  224. package/lib/commands/split/__tests__/index.test.d.ts +0 -1
  225. package/lib/commands/split/__tests__/index.test.js +0 -91
  226. package/lib/reunite/api/__tests__/api-keys.test.d.ts +0 -1
  227. package/lib/reunite/api/__tests__/api-keys.test.js +0 -26
  228. package/lib/reunite/api/__tests__/api.client.test.d.ts +0 -1
  229. package/lib/reunite/api/__tests__/api.client.test.js +0 -337
  230. package/lib/reunite/api/__tests__/domains.test.d.ts +0 -1
  231. package/lib/reunite/api/__tests__/domains.test.js +0 -32
  232. package/lib/reunite/commands/__tests__/push-status.test.d.ts +0 -1
  233. package/lib/reunite/commands/__tests__/push-status.test.js +0 -563
  234. package/lib/reunite/commands/__tests__/push.test.d.ts +0 -1
  235. package/lib/reunite/commands/__tests__/push.test.js +0 -315
  236. package/lib/reunite/commands/__tests__/utils.test.d.ts +0 -1
  237. package/lib/reunite/commands/__tests__/utils.test.js +0 -51
  238. package/lib/utils/__mocks__/miscellaneous.d.ts +0 -43
  239. package/lib/utils/__mocks__/miscellaneous.js +0 -24
  240. package/lib/utils/getCommandNameFromArgs.js +0 -6
  241. package/src/__mocks__/@redocly/openapi-core.ts +0 -88
  242. package/src/__mocks__/documents.ts +0 -124
  243. package/src/__mocks__/fs.ts +0 -6
  244. package/src/__mocks__/perf_hooks.ts +0 -3
  245. package/src/__mocks__/redoc.ts +0 -2
  246. package/src/__tests__/commands/build-docs.test.ts +0 -59
  247. package/src/__tests__/commands/bundle.test.ts +0 -285
  248. package/src/__tests__/commands/join.test.ts +0 -334
  249. package/src/__tests__/commands/lint.test.ts +0 -190
  250. package/src/__tests__/commands/push-region.test.ts +0 -104
  251. package/src/__tests__/commands/push.test.ts +0 -553
  252. package/src/__tests__/fetch-with-timeout.test.ts +0 -81
  253. package/src/__tests__/fixtures/config.ts +0 -21
  254. package/src/__tests__/fixtures/openapi.json +0 -0
  255. package/src/__tests__/fixtures/openapi.yaml +0 -0
  256. package/src/__tests__/fixtures/redocly.yaml +0 -0
  257. package/src/__tests__/spinner.test.ts +0 -51
  258. package/src/__tests__/utils.test.ts +0 -781
  259. package/src/__tests__/wrapper.test.ts +0 -91
  260. package/src/auth/__tests__/device-flow.test.ts +0 -73
  261. package/src/auth/__tests__/oauth-client.test.ts +0 -117
  262. package/src/auth/device-flow.ts +0 -175
  263. package/src/auth/oauth-client.ts +0 -111
  264. package/src/commands/auth.ts +0 -66
  265. package/src/commands/build-docs/index.ts +0 -55
  266. package/src/commands/build-docs/template.hbs +0 -23
  267. package/src/commands/build-docs/types.ts +0 -25
  268. package/src/commands/build-docs/utils.ts +0 -110
  269. package/src/commands/bundle.ts +0 -154
  270. package/src/commands/eject.ts +0 -42
  271. package/src/commands/join.ts +0 -794
  272. package/src/commands/lint.ts +0 -169
  273. package/src/commands/preview-docs/index.ts +0 -183
  274. package/src/commands/preview-docs/preview-server/default.hbs +0 -24
  275. package/src/commands/preview-docs/preview-server/hot.js +0 -59
  276. package/src/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
  277. package/src/commands/preview-docs/preview-server/preview-server.ts +0 -159
  278. package/src/commands/preview-docs/preview-server/server.ts +0 -92
  279. package/src/commands/preview-project/constants.ts +0 -23
  280. package/src/commands/preview-project/index.ts +0 -71
  281. package/src/commands/preview-project/types.ts +0 -12
  282. package/src/commands/push.ts +0 -470
  283. package/src/commands/split/__tests__/fixtures/samples.json +0 -61
  284. package/src/commands/split/__tests__/fixtures/spec.json +0 -70
  285. package/src/commands/split/__tests__/fixtures/webhooks.json +0 -85
  286. package/src/commands/split/__tests__/index.test.ts +0 -156
  287. package/src/commands/split/index.ts +0 -397
  288. package/src/commands/split/types.ts +0 -60
  289. package/src/commands/stats.ts +0 -140
  290. package/src/commands/translations.ts +0 -32
  291. package/src/custom.d.ts +0 -1
  292. package/src/index.ts +0 -970
  293. package/src/otel.ts +0 -59
  294. package/src/reunite/api/__tests__/api-keys.test.ts +0 -37
  295. package/src/reunite/api/__tests__/api.client.test.ts +0 -452
  296. package/src/reunite/api/__tests__/domains.test.ts +0 -41
  297. package/src/reunite/api/api-client.ts +0 -381
  298. package/src/reunite/api/api-keys.ts +0 -26
  299. package/src/reunite/api/domains.ts +0 -23
  300. package/src/reunite/api/index.ts +0 -3
  301. package/src/reunite/api/types.ts +0 -108
  302. package/src/reunite/commands/__tests__/push-status.test.ts +0 -653
  303. package/src/reunite/commands/__tests__/push.test.ts +0 -385
  304. package/src/reunite/commands/__tests__/utils.test.ts +0 -62
  305. package/src/reunite/commands/push-status.ts +0 -325
  306. package/src/reunite/commands/push.ts +0 -235
  307. package/src/reunite/commands/utils.ts +0 -66
  308. package/src/reunite/utils.ts +0 -1
  309. package/src/types.ts +0 -64
  310. package/src/utils/__mocks__/miscellaneous.ts +0 -24
  311. package/src/utils/assert-node-version.ts +0 -19
  312. package/src/utils/fetch-with-timeout.ts +0 -30
  313. package/src/utils/getCommandNameFromArgs.ts +0 -5
  314. package/src/utils/js-utils.ts +0 -24
  315. package/src/utils/miscellaneous.ts +0 -729
  316. package/src/utils/platform.ts +0 -31
  317. package/src/utils/spinner.ts +0 -50
  318. package/src/utils/update-version-notifier.ts +0 -115
  319. package/src/wrapper.ts +0 -77
  320. package/tsconfig.json +0 -9
  321. package/tsconfig.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -16,13 +16,13 @@ Supports OpenAPI 3.1, 3.0 and OpenAPI 2.0 (legacy Swagger), AsyncAPI 3.0 and 2.6
16
16
  ### Node
17
17
 
18
18
  ```sh
19
- npx @redocly/cli@v1-archive lint path-to-root-file.yaml
19
+ npx @redocly/cli@latest lint path-to-root-file.yaml
20
20
  ```
21
21
 
22
22
  Alternatively, install it globally with `npm`:
23
23
 
24
24
  ```sh
25
- npm install @redocly/cli@v1-archive -g
25
+ npm install @redocly/cli -g
26
26
  ```
27
27
 
28
28
  Then you can use it as `redocly [command] [options]`, for example:
@@ -31,7 +31,7 @@ Then you can use it as `redocly [command] [options]`, for example:
31
31
  redocly lint path-to-root-file.yaml
32
32
  ```
33
33
 
34
- The minimum required versions of Node.js and NPM are 18.17.0 and 10.8.2 respectively.
34
+ The minimum required versions of Node.js and NPM are 22.12.0 and 10.9.2 respectively.
35
35
 
36
36
  ### Docker
37
37
 
@@ -101,6 +101,37 @@ The `stylish` output is as good as it sounds, but if you need JSON, Markdown, Ch
101
101
 
102
102
  [Learn more about API standards and configuring Redocly rules](https://redocly.com/docs/cli/api-standards).
103
103
 
104
+ ### API contract testing with Respect
105
+
106
+ Ensure your APIs match their OpenAPI descriptions with **Respect**, Redocly's API contract testing system. Respect sends real HTTP requests to your API server and validates that responses match the expectations defined in your OpenAPI description and Arazzo workflows.
107
+
108
+ - Verify API responses match your OpenAPI schema
109
+ - Test complex API sequences using OpenAPI Arazzo format
110
+ - Catch API drift early in development and CI/CD
111
+ - Ensure external APIs you depend on behave as expected
112
+ - Track response times and detect anomalies
113
+
114
+ #### Quick start
115
+
116
+ ```sh
117
+ # Generate test workflows from your OpenAPI spec
118
+ redocly generate-arazzo openapi.yaml
119
+
120
+ # Run contract tests against your API
121
+ redocly respect auto-generated.arazzo.yaml --verbose
122
+ ```
123
+
124
+ #### Respect vs. Respect Monitoring
125
+
126
+ Respect is Redocly's community-edition product. Looking for something more? We also offer continuous API monitoring with additional features including:
127
+
128
+ - Real-time insights
129
+ - Automated alerts via email or Slack
130
+ - Automated API checks
131
+ - Proactive API quality assurance
132
+
133
+ Learn more about [Respect](https://redocly.com/respect) and [get started with API contract testing](https://redocly.com/docs/respect/get-started).
134
+
104
135
  ### Transform an OpenAPI description
105
136
 
106
137
  If your OpenAPI description isn't everything you hoped it would be, enhance it with the Redocly [decorators](https://redocly.com/docs/cli/decorators) feature.
package/bin/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require('../lib/index');
3
+ import '../lib/index.js';
@@ -24,3 +24,4 @@ export declare class RedoclyOAuthDeviceFlow {
24
24
  private getDeviceCode;
25
25
  private sendRequest;
26
26
  }
27
+ //# sourceMappingURL=device-flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-flow.d.ts","sourceRoot":"","sources":["../../src/auth/device-flow.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,UAAU;IAAU,OAAO,CAAC,OAAO;IAFhF,OAAO,CAAC,SAAS,CAAmB;gBAEhB,OAAO,EAAE,MAAM,EAAU,UAAU,EAAE,MAAM,EAAU,OAAO,EAAE,MAAM;IAIlF,GAAG;IA0BT,OAAO,CAAC,WAAW;IAeb,WAAW,CAAC,WAAW,EAAE,MAAM;IAY/B,YAAY,CAAC,MAAM,EAAE,MAAM;IAW3B,YAAY,CAAC,YAAY,EAAE,MAAM;;;;;YAiBzB,kBAAkB;YA4BlB,cAAc;YAQd,aAAa;YAsBb,WAAW;CAiB1B"}
@@ -1,28 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedoclyOAuthDeviceFlow = void 0;
4
- const colorette_1 = require("colorette");
5
- const childProcess = require("child_process");
6
- const api_client_1 = require("../reunite/api/api-client");
7
- class RedoclyOAuthDeviceFlow {
1
+ import { blue, green } from 'colorette';
2
+ import * as childProcess from 'node:child_process';
3
+ import { logger } from '@redocly/openapi-core';
4
+ import { ReuniteApiClient } from '../reunite/api/api-client.js';
5
+ export class RedoclyOAuthDeviceFlow {
8
6
  constructor(baseUrl, clientName, version) {
9
7
  this.baseUrl = baseUrl;
10
8
  this.clientName = clientName;
11
9
  this.version = version;
12
- this.apiClient = new api_client_1.ReuniteApiClient(this.version, 'login');
10
+ this.apiClient = new ReuniteApiClient(this.version, 'login');
13
11
  }
14
12
  async run() {
15
13
  const code = await this.getDeviceCode();
16
- process.stdout.write('Attempting to automatically open the SSO authorization page in your default browser.\n');
17
- process.stdout.write('If the browser does not open or you wish to use a different device to authorize this request, open the following URL:\n\n');
18
- process.stdout.write((0, colorette_1.blue)(code.verificationUri));
19
- process.stdout.write(`\n\n`);
20
- process.stdout.write(`Then enter the code:\n\n`);
21
- process.stdout.write((0, colorette_1.blue)(code.userCode));
22
- process.stdout.write(`\n\n`);
14
+ logger.output('Attempting to automatically open the SSO authorization page in your default browser.\n');
15
+ logger.output('If the browser does not open or you wish to use a different device to authorize this request, open the following URL:\n\n');
16
+ logger.output(blue(code.verificationUri));
17
+ logger.output(`\n\n`);
18
+ logger.output(`Then enter the code:\n\n`);
19
+ logger.output(blue(code.userCode));
20
+ logger.output(`\n\n`);
23
21
  this.openBrowser(code.verificationUriComplete);
24
22
  const accessToken = await this.pollingAccessToken(code.deviceCode, code.interval, code.expiresIn);
25
- process.stdout.write((0, colorette_1.green)('✅ Logged in\n\n'));
23
+ logger.output(green('✅ Logged in\n\n'));
26
24
  return accessToken;
27
25
  }
28
26
  openBrowser(url) {
@@ -130,4 +128,4 @@ class RedoclyOAuthDeviceFlow {
130
128
  return await response.json();
131
129
  }
132
130
  }
133
- exports.RedoclyOAuthDeviceFlow = RedoclyOAuthDeviceFlow;
131
+ //# sourceMappingURL=device-flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-flow.js","sourceRoot":"","sources":["../../src/auth/device-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAShE,MAAM,OAAO,sBAAsB;IAGjC,YAAoB,OAAe,EAAU,UAAkB,EAAU,OAAe;QAApE,YAAO,GAAP,OAAO,CAAQ;QAAU,eAAU,GAAV,UAAU,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QACtF,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM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ACtD,WAAW,EAAE,IAAI,CAAC,UAAU;SAC7B,CAAC,CAAC;QAEH,OAAO;YACL,UAAU;YACV,QAAQ;YACR,eAAe;YACf,uBAAuB;YACvB,QAAQ;YACR,SAAS;SACV,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,WAAW,CACvB,GAAW,EACX,SAAiB,KAAK,EACtB,OAA4C,SAAS,EACrD,UAAkC,EAAE;QAEpC,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE;YACjD,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;YACxC,MAAM;YACN,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,OAAO,EAAE;SAC5D,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;QACD,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;CACF"}
@@ -12,3 +12,4 @@ export declare class RedoclyOAuthClient {
12
12
  private readToken;
13
13
  private removeToken;
14
14
  }
15
+ //# sourceMappingURL=oauth-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-client.d.ts","sourceRoot":"","sources":["../../src/auth/oauth-client.ts"],"names":[],"mappings":"AAWA,qBAAa,kBAAkB;IAKjB,OAAO,CAAC,UAAU;IAAU,OAAO,CAAC,OAAO;IAJvD,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,QAAQ,CAAkB;gBAEd,UAAU,EAAE,MAAM,EAAU,OAAO,EAAE,MAAM;IAuBzD,KAAK,CAAC,OAAO,EAAE,MAAM;IAUrB,MAAM;IAQN,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;YA4BrC,SAAS;YAUT,SAAS;YAUT,WAAW;CAM1B"}
@@ -1,33 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedoclyOAuthClient = void 0;
4
- const node_os_1 = require("node:os");
5
- const path = require("node:path");
6
- const node_fs_1 = require("node:fs");
7
- const crypto = require("node:crypto");
8
- const node_buffer_1 = require("node:buffer");
9
- const device_flow_1 = require("./device-flow");
1
+ import { homedir } from 'node:os';
2
+ import * as path from 'node:path';
3
+ import { mkdirSync, existsSync, writeFileSync, readFileSync, rmSync } from 'node:fs';
4
+ import * as crypto from 'node:crypto';
5
+ import { Buffer } from 'node:buffer';
6
+ import { logger } from '@redocly/openapi-core';
7
+ import { RedoclyOAuthDeviceFlow } from './device-flow.js';
10
8
  const SALT = '4618dbc9-8aed-4e27-aaf0-225f4603e5a4';
11
9
  const CRYPTO_ALGORITHM = 'aes-256-cbc';
12
- class RedoclyOAuthClient {
10
+ export class RedoclyOAuthClient {
13
11
  constructor(clientName, version) {
14
12
  this.clientName = clientName;
15
13
  this.version = version;
16
- this.dir = path.join((0, node_os_1.homedir)(), '.redocly');
17
- if (!(0, node_fs_1.existsSync)(this.dir)) {
18
- (0, node_fs_1.mkdirSync)(this.dir);
14
+ this.dir = path.join(homedir(), '.redocly');
15
+ if (!existsSync(this.dir)) {
16
+ mkdirSync(this.dir);
19
17
  }
20
18
  const homeDirPath = process.env.HOME;
21
19
  const hash = crypto.createHash('sha256');
22
20
  hash.update(`${homeDirPath}${SALT}`);
23
21
  const hashHex = hash.digest('hex');
24
- const key = node_buffer_1.Buffer.alloc(32, node_buffer_1.Buffer.from(hashHex).toString('base64')).toString();
25
- const iv = node_buffer_1.Buffer.alloc(16, node_buffer_1.Buffer.from(process.env.HOME).toString('base64')).toString();
22
+ const key = Buffer.alloc(32, Buffer.from(hashHex).toString('base64')).toString();
23
+ const iv = Buffer.alloc(16, Buffer.from(process.env.HOME).toString('base64')).toString();
26
24
  this.cipher = crypto.createCipheriv(CRYPTO_ALGORITHM, key, iv);
27
25
  this.decipher = crypto.createDecipheriv(CRYPTO_ALGORITHM, key, iv);
28
26
  }
29
27
  async login(baseUrl) {
30
- const deviceFlow = new device_flow_1.RedoclyOAuthDeviceFlow(baseUrl, this.clientName, this.version);
28
+ const deviceFlow = new RedoclyOAuthDeviceFlow(baseUrl, this.clientName, this.version);
31
29
  const token = await deviceFlow.run();
32
30
  if (!token) {
33
31
  throw new Error('Failed to login');
@@ -43,7 +41,7 @@ class RedoclyOAuthClient {
43
41
  }
44
42
  }
45
43
  async isAuthorized(baseUrl, apiKey) {
46
- const deviceFlow = new device_flow_1.RedoclyOAuthDeviceFlow(baseUrl, this.clientName, this.version);
44
+ const deviceFlow = new RedoclyOAuthDeviceFlow(baseUrl, this.clientName, this.version);
47
45
  if (apiKey) {
48
46
  return await deviceFlow.verifyApiKey(apiKey);
49
47
  }
@@ -67,15 +65,15 @@ class RedoclyOAuthClient {
67
65
  async saveToken(token) {
68
66
  try {
69
67
  const encrypted = this.cipher.update(JSON.stringify(token), 'utf8', 'hex') + this.cipher.final('hex');
70
- (0, node_fs_1.writeFileSync)(path.join(this.dir, 'auth.json'), encrypted);
68
+ writeFileSync(path.join(this.dir, 'auth.json'), encrypted);
71
69
  }
72
70
  catch (error) {
73
- process.stderr.write('Error saving tokens:', error);
71
+ logger.error(`Error saving tokens: ${error}`);
74
72
  }
75
73
  }
76
74
  async readToken() {
77
75
  try {
78
- const token = (0, node_fs_1.readFileSync)(path.join(this.dir, 'auth.json'), 'utf8');
76
+ const token = readFileSync(path.join(this.dir, 'auth.json'), 'utf8');
79
77
  const decrypted = this.decipher.update(token, 'hex', 'utf8') + this.decipher.final('utf8');
80
78
  return decrypted ? JSON.parse(decrypted) : null;
81
79
  }
@@ -85,9 +83,9 @@ class RedoclyOAuthClient {
85
83
  }
86
84
  async removeToken() {
87
85
  const tokenPath = path.join(this.dir, 'auth.json');
88
- if ((0, node_fs_1.existsSync)(tokenPath)) {
89
- (0, node_fs_1.rmSync)(tokenPath);
86
+ if (existsSync(tokenPath)) {
87
+ rmSync(tokenPath);
90
88
  }
91
89
  }
92
90
  }
93
- exports.RedoclyOAuthClient = RedoclyOAuthClient;
91
+ //# sourceMappingURL=oauth-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-client.js","sourceRoot":"","sources":["../../src/auth/oauth-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAkB,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,MAAM,IAAI,GAAG,sCAAsC,CAAC;AACpD,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,MAAM,OAAO,kBAAkB;IAK7B,YAAoB,UAAkB,EAAU,OAAe;QAA3C,eAAU,GAAV,UAAU,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QAC7D,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,IAAc,CAAC;QAC/C,MAAM,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C,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,SAAS;QACrB,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;YACrE,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC3F,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,WAAW;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACnD,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1B,MAAM,CAAC,SAAS,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;CACF"}
@@ -1,13 +1,11 @@
1
- import type { CommandArgs } from '../wrapper';
2
- export declare function promptClientToken(domain: string): Promise<string>;
1
+ import type { CommandArgs } from '../wrapper.js';
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, config }: CommandArgs<LoginOptions>): Promise<void>;
10
7
  export type LogoutOptions = {
11
8
  config?: string;
12
9
  };
13
10
  export declare function handleLogout({ version }: CommandArgs<LogoutOptions>): Promise<void>;
11
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,YAAY,CAAC,iBAarF;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE,WAAW,CAAC,aAAa,CAAC,iBAKzE"}
@@ -1,51 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promptClientToken = promptClientToken;
4
- exports.handleLogin = handleLogin;
5
- exports.handleLogout = handleLogout;
6
- const colorette_1 = require("colorette");
7
- const openapi_core_1 = require("@redocly/openapi-core");
8
- const miscellaneous_1 = require("../utils/miscellaneous");
9
- const oauth_client_1 = require("../auth/oauth-client");
10
- 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
- }
1
+ import { logger } from '@redocly/openapi-core';
2
+ import { exitWithError } from '../utils/error.js';
3
+ import { RedoclyOAuthClient } from '../auth/oauth-client.js';
4
+ import { getReuniteUrl } from '../reunite/api/index.js';
5
+ export async function handleLogin({ argv, version, config }) {
6
+ const residency = argv.residency || config?.resolvedConfig?.residency;
7
+ const reuniteUrl = getReuniteUrl(residency);
8
+ try {
9
+ const oauthClient = new RedoclyOAuthClient('redocly-cli', version);
10
+ await oauthClient.login(reuniteUrl);
30
11
  }
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'));
12
+ catch {
13
+ if (argv.residency) {
14
+ exitWithError(`❌ Connection to ${reuniteUrl} failed.`);
39
15
  }
40
- catch (err) {
41
- (0, miscellaneous_1.exitWithError)(' ' + err?.message);
16
+ else {
17
+ exitWithError(`❌ Login failed. Please check your credentials and try again.`);
42
18
  }
43
19
  }
44
20
  }
45
- async function handleLogout({ version }) {
46
- const client = new openapi_core_1.RedoclyClient();
47
- client.logout();
48
- const oauthClient = new oauth_client_1.RedoclyOAuthClient('redocly-cli', version);
21
+ export async function handleLogout({ version }) {
22
+ const oauthClient = new RedoclyOAuthClient('redocly-cli', version);
49
23
  oauthClient.logout();
50
- process.stdout.write('Logged out from the Redocly account. ✋ \n');
24
+ logger.output('Logged out from the Redocly account. ✋ \n');
51
25
  }
26
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AASxD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAA6B;IACpF,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,EAAE,cAAc,EAAE,SAAS,CAAC;IACtE,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,kBAAkB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACnE,MAAM,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,aAAa,CAAC,mBAAmB,UAAU,UAAU,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,aAAa,CAAC,8DAA8D,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;AACH,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EAAE,OAAO,EAA8B;IACxE,MAAM,WAAW,GAAG,IAAI,kBAAkB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACnE,WAAW,CAAC,MAAM,EAAE,CAAC;IAErB,MAAM,CAAC,MAAM,CAAC,2CAA2C,CAAC,CAAC;AAC7D,CAAC"}
@@ -1,3 +1,4 @@
1
- import type { BuildDocsArgv } from './types';
2
- import type { CommandArgs } from '../../wrapper';
3
- export declare const handlerBuildCommand: ({ argv, config: configFromFile, collectSpecData, }: CommandArgs<BuildDocsArgv>) => Promise<void>;
1
+ import type { BuildDocsArgv } from './types.js';
2
+ import type { CommandArgs } from '../../wrapper.js';
3
+ export declare const handlerBuildCommand: ({ argv, config, collectSpecData, }: CommandArgs<BuildDocsArgv>) => Promise<void>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/build-docs/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,eAAO,MAAM,mBAAmB,uCAI7B,WAAW,CAAC,aAAa,CAAC,kBAwC5B,CAAC"}
@@ -1,17 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handlerBuildCommand = void 0;
4
- const redoc_1 = require("redoc");
5
- const path_1 = require("path");
6
- const fs_1 = require("fs");
7
- const perf_hooks_1 = require("perf_hooks");
8
- const openapi_core_1 = require("@redocly/openapi-core");
9
- const utils_1 = require("./utils");
10
- const miscellaneous_1 = require("../../utils/miscellaneous");
11
- const handlerBuildCommand = async ({ argv, config: configFromFile, collectSpecData, }) => {
12
- const startedAt = perf_hooks_1.performance.now();
13
- const config = (0, openapi_core_1.getMergedConfig)(configFromFile, argv.api);
14
- const apis = await (0, miscellaneous_1.getFallbackApisOrExit)(argv.api ? [argv.api] : [], config);
1
+ import { createRequire } from 'node:module';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { writeFileSync, mkdirSync } from 'node:fs';
4
+ import { default as redoc } from 'redoc';
5
+ import { performance } from 'node:perf_hooks';
6
+ import { isAbsoluteUrl, logger } from '@redocly/openapi-core';
7
+ import { getObjectOrJSON, getPageHTML } from './utils.js';
8
+ import { getExecutionTime, getFallbackApisOrExit } from '../../utils/miscellaneous.js';
9
+ import { exitWithError } from '../../utils/error.js';
10
+ const packageJson = createRequire(import.meta.url ?? __dirname)('../../../package.json');
11
+ export const handlerBuildCommand = async ({ argv, config, collectSpecData, }) => {
12
+ const startedAt = performance.now();
13
+ const apis = await getFallbackApisOrExit(argv.api ? [argv.api] : [], config);
15
14
  const { path: pathToApi } = apis[0];
16
15
  const options = {
17
16
  output: argv.o,
@@ -19,21 +18,21 @@ const handlerBuildCommand = async ({ argv, config: configFromFile, collectSpecDa
19
18
  disableGoogleFont: argv.disableGoogleFont,
20
19
  templateFileName: argv.template,
21
20
  templateOptions: argv.templateOptions || {},
22
- redocOptions: (0, utils_1.getObjectOrJSON)(argv.theme?.openapi, config),
21
+ redocOptions: getObjectOrJSON(argv.theme?.openapi, config, argv.api),
23
22
  };
24
- const redocCurrentVersion = require('../../../package.json').dependencies.redoc;
23
+ const redocCurrentVersion = packageJson.dependencies.redoc;
25
24
  try {
26
- const elapsed = (0, miscellaneous_1.getExecutionTime)(startedAt);
27
- const api = await (0, redoc_1.loadAndBundleSpec)((0, openapi_core_1.isAbsoluteUrl)(pathToApi) ? pathToApi : (0, path_1.resolve)(pathToApi));
25
+ const elapsed = getExecutionTime(startedAt);
26
+ const api = await redoc.loadAndBundleSpec(isAbsoluteUrl(pathToApi) ? pathToApi : resolve(pathToApi));
28
27
  collectSpecData?.(api);
29
- const pageHTML = await (0, utils_1.getPageHTML)(api, pathToApi, { ...options, redocCurrentVersion }, argv.config);
30
- (0, fs_1.mkdirSync)((0, path_1.dirname)(options.output), { recursive: true });
31
- (0, fs_1.writeFileSync)(options.output, pageHTML);
28
+ const pageHTML = await getPageHTML(api, pathToApi, { ...options, redocCurrentVersion }, argv.config);
29
+ mkdirSync(dirname(options.output), { recursive: true });
30
+ writeFileSync(options.output, pageHTML);
32
31
  const sizeInKiB = Math.ceil(Buffer.byteLength(pageHTML) / 1024);
33
- process.stdout.write(`\n🎉 bundled successfully in: ${options.output} (${sizeInKiB} KiB) [⏱ ${elapsed}].\n`);
32
+ logger.info(`\n🎉 bundled successfully in: ${options.output} (${sizeInKiB} KiB) [⏱ ${elapsed}].\n`);
34
33
  }
35
34
  catch (e) {
36
- (0, miscellaneous_1.exitWithError)(e);
35
+ exitWithError(e);
37
36
  }
38
37
  };
39
- exports.handlerBuildCommand = handlerBuildCommand;
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/build-docs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC,uBAAuB,CAAC,CAAC;AAEzF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,IAAI,EACJ,MAAM,EACN,eAAe,GACY,EAAE,EAAE;IAC/B,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAEpC,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC7E,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpC,M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a,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { VerifyConfigOptions } from '../../types';
1
+ import type { VerifyConfigOptions } from '../../types.js';
2
2
  export type BuildDocsOptions = {
3
3
  watch?: boolean;
4
4
  output?: string;
@@ -21,3 +21,4 @@ export type BuildDocsArgv = {
21
21
  openapi: string | Record<string, unknown>;
22
22
  };
23
23
  } & VerifyConfigOptions;
24
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/build-docs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC3C,CAAC;CACH,GAAG,mBAAmB,CAAC"}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/commands/build-docs/types.ts"],"names":[],"mappings":""}
@@ -1,7 +1,8 @@
1
1
  import type { Config } from '@redocly/openapi-core';
2
- import type { BuildDocsOptions } from './types';
3
- export declare function getObjectOrJSON(openapiOptions: string | Record<string, unknown>, config: Config): JSON | Record<string, unknown> | Config;
2
+ import type { BuildDocsOptions } from './types.js';
3
+ export declare function getObjectOrJSON(openapiOptions: string | Record<string, unknown>, config: Config, alias?: string): JSON | Record<string, unknown> | Config;
4
4
  export declare function getPageHTML(api: any, pathToApi: string, { title, disableGoogleFont, templateFileName, templateOptions, redocOptions, redocCurrentVersion, }: BuildDocsOptions, configPath?: string): Promise<string>;
5
5
  export declare function sanitizeJSONString(str: string): string;
6
6
  export declare function escapeClosingScriptTag(str: string): string;
7
7
  export declare function escapeUnicode(str: string): string;
8
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/commands/build-docs/utils.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMnD,wBAAgB,eAAe,CAC7B,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChD,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CA4BzC;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,MAAM,EACjB,EACE,KAAK,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,YAAiB,EACjB,mBAAmB,GACpB,EAAE,gBAAgB,EACnB,UAAU,CAAC,EAAE,MAAM,mBAmCpB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAGD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D;AAGD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD"}
@@ -1,62 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getObjectOrJSON = getObjectOrJSON;
4
- exports.getPageHTML = getPageHTML;
5
- exports.sanitizeJSONString = sanitizeJSONString;
6
- exports.escapeClosingScriptTag = escapeClosingScriptTag;
7
- exports.escapeUnicode = escapeUnicode;
8
- const react_1 = require("react");
9
- const redoc_1 = require("redoc");
10
- const server_1 = require("react-dom/server");
11
- const styled_components_1 = require("styled-components");
12
- const handlebars_1 = require("handlebars");
13
- const path_1 = require("path");
14
- const fs_1 = require("fs");
15
- const colorette_1 = require("colorette");
16
- const openapi_core_1 = require("@redocly/openapi-core");
17
- const miscellaneous_1 = require("../../utils/miscellaneous");
18
- function getObjectOrJSON(openapiOptions, config) {
1
+ import { createElement } from 'react';
2
+ import { default as redoc } from 'redoc';
3
+ import { renderToString } from 'react-dom/server';
4
+ import { ServerStyleSheet } from 'styled-components';
5
+ import { default as handlebars } from 'handlebars';
6
+ import * as path from 'node:path';
7
+ import { existsSync, lstatSync, readFileSync } from 'node:fs';
8
+ import { isAbsoluteUrl, logger } from '@redocly/openapi-core';
9
+ import * as url from 'node:url';
10
+ import { exitWithError } from '../../utils/error.js';
11
+ const __internalDirname = import.meta.url
12
+ ? path.dirname(url.fileURLToPath(import.meta.url))
13
+ : __dirname;
14
+ export function getObjectOrJSON(openapiOptions, config, alias) {
19
15
  switch (typeof openapiOptions) {
20
16
  case 'object':
21
17
  return openapiOptions;
22
18
  case 'string':
23
19
  try {
24
- if ((0, fs_1.existsSync)(openapiOptions) && (0, fs_1.lstatSync)(openapiOptions).isFile()) {
25
- return JSON.parse((0, fs_1.readFileSync)(openapiOptions, 'utf-8'));
20
+ if (existsSync(openapiOptions) && lstatSync(openapiOptions).isFile()) {
21
+ return JSON.parse(readFileSync(openapiOptions, 'utf-8'));
26
22
  }
27
23
  else {
28
24
  return JSON.parse(openapiOptions);
29
25
  }
30
26
  }
31
27
  catch (e) {
32
- process.stderr.write((0, colorette_1.red)(`Encountered error:\n\n${openapiOptions}\n\nis neither a file with a valid JSON object neither a stringified JSON object.`));
33
- (0, miscellaneous_1.exitWithError)(e);
28
+ logger.error(`Encountered error:\n\n${openapiOptions}\n\nis neither a file with a valid JSON object neither a stringified JSON object.`);
29
+ exitWithError(e);
34
30
  }
35
31
  break;
36
32
  default: {
37
- if (config) {
38
- process.stdout.write(`Found ${config.configFile} and using theme.openapi options\n`);
39
- return config.theme.openapi ? config.theme.openapi : {};
33
+ if (config?.configPath) {
34
+ logger.info(`Found ${config.configPath} and using theme.openapi options\n`);
35
+ const apiConfig = alias ? config.resolvedConfig.apis?.[alias] : config.resolvedConfig;
36
+ return apiConfig?.theme.openapi ? apiConfig.theme.openapi : {}; // FIXME: theme is deprecated (2.0)
40
37
  }
41
38
  return {};
42
39
  }
43
40
  }
44
41
  return {};
45
42
  }
46
- async function getPageHTML(api, pathToApi, { title, disableGoogleFont, templateFileName, templateOptions, redocOptions = {}, redocCurrentVersion, }, configPath) {
47
- process.stdout.write('Prerendering docs\n');
48
- const apiUrl = redocOptions.specUrl || ((0, openapi_core_1.isAbsoluteUrl)(pathToApi) ? pathToApi : undefined);
49
- const store = await (0, redoc_1.createStore)(api, apiUrl, redocOptions);
50
- const sheet = new styled_components_1.ServerStyleSheet();
51
- const html = (0, server_1.renderToString)(sheet.collectStyles((0, react_1.createElement)(redoc_1.Redoc, { store })));
43
+ export async function getPageHTML(api, pathToApi, { title, disableGoogleFont, templateFileName, templateOptions, redocOptions = {}, redocCurrentVersion, }, configPath) {
44
+ logger.info('Prerendering docs\n');
45
+ const apiUrl = redocOptions.specUrl || (isAbsoluteUrl(pathToApi) ? pathToApi : undefined);
46
+ const store = await redoc.createStore(api, apiUrl, redocOptions);
47
+ const sheet = new ServerStyleSheet();
48
+ const html = renderToString(sheet.collectStyles(createElement(redoc.Redoc, { store })));
52
49
  const state = await store.toJS();
53
50
  const css = sheet.getStyleTags();
54
51
  templateFileName = templateFileName
55
52
  ? templateFileName
56
53
  : redocOptions?.htmlTemplate
57
- ? (0, path_1.resolve)(configPath ? (0, path_1.dirname)(configPath) : '', redocOptions.htmlTemplate)
58
- : (0, path_1.join)(__dirname, './template.hbs');
59
- const template = (0, handlebars_1.compile)((0, fs_1.readFileSync)(templateFileName).toString());
54
+ ? path.resolve(configPath ? path.dirname(configPath) : '', redocOptions.htmlTemplate)
55
+ : path.join(__internalDirname, './template.hbs');
56
+ const template = handlebars.compile(readFileSync(templateFileName).toString());
60
57
  return template({
61
58
  redocHTML: `
62
59
  <div id="redoc">${html || ''}</div>
@@ -74,14 +71,15 @@ async function getPageHTML(api, pathToApi, { title, disableGoogleFont, templateF
74
71
  templateOptions,
75
72
  });
76
73
  }
77
- function sanitizeJSONString(str) {
74
+ export function sanitizeJSONString(str) {
78
75
  return escapeClosingScriptTag(escapeUnicode(str));
79
76
  }
80
77
  // see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/
81
- function escapeClosingScriptTag(str) {
78
+ export function escapeClosingScriptTag(str) {
82
79
  return str.replace(/<\/script>/g, '<\\/script>');
83
80
  }
84
81
  // see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/
85
- function escapeUnicode(str) {
82
+ export function escapeUnicode(str) {
86
83
  return str.replace(/\u2028|\u2029/g, (m) => '\\u202' + (m === '\u2028' ? '8' : '9'));
87
84
  }
85
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/commands/build-doc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