@redocly/cli 1.34.4 → 2.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
@@ -1,5 +1,5 @@
1
- import type { OutputExtensions, Skips, VerifyConfigOptions } from '../types';
2
- import type { CommandArgs } from '../wrapper';
1
+ import type { OutputExtensions, VerifyConfigOptions } from '../types.js';
2
+ import type { CommandArgs } from '../wrapper.js';
3
3
  export type BundleOptions = {
4
4
  apis?: string[];
5
5
  extends?: string[];
@@ -10,5 +10,8 @@ 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>;
17
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/commands/bundle.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAU,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC,GAAG,mBAAmB,CAAC;AAExB,wBAAsB,YAAY,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,eAAe,GAChB,EAAE,WAAW,CAAC,aAAa,CAAC,iBA4G5B"}
@@ -1,36 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleBundle = handleBundle;
4
- const perf_hooks_1 = require("perf_hooks");
5
- const colorette_1 = require("colorette");
6
- const fs_1 = require("fs");
7
- const openapi_core_1 = require("@redocly/openapi-core");
8
- const miscellaneous_1 = require("../utils/miscellaneous");
9
- async function handleBundle({ argv, config, version, collectSpecData, }) {
1
+ import { performance } from 'perf_hooks';
2
+ import { blue, gray, green, yellow } from 'colorette';
3
+ import { writeFileSync } from 'fs';
4
+ import { formatProblems, getTotals, bundle, logger } from '@redocly/openapi-core';
5
+ import { dumpBundle, getExecutionTime, getFallbackApisOrExit, getOutputFileName, handleError, printUnusedWarnings, saveBundle, sortTopLevelKeysForOas, formatPath, } from '../utils/miscellaneous.js';
6
+ import { AbortFlowError } from '../utils/error.js';
7
+ export async function handleBundle({ argv, config, version, collectSpecData, }) {
10
8
  const removeUnusedComponents = argv['remove-unused-components'] ||
11
- config.rawConfig?.styleguide?.decorators?.hasOwnProperty('remove-unused-components');
12
- const apis = await (0, miscellaneous_1.getFallbackApisOrExit)(argv.apis, config);
9
+ config.resolvedConfig.decorators?.hasOwnProperty('remove-unused-components'); // FIXME: also on `apis` level
10
+ const apis = await getFallbackApisOrExit(argv.apis, config);
13
11
  const totals = { errors: 0, warnings: 0, ignored: 0 };
14
- const deprecatedOptions = [];
15
- (0, miscellaneous_1.checkForDeprecatedOptions)(argv, deprecatedOptions);
16
12
  for (const { path, alias, output } of apis) {
17
13
  try {
18
- const startedAt = perf_hooks_1.performance.now();
19
- const resolvedConfig = (0, openapi_core_1.getMergedConfig)(config, alias);
20
- const { styleguide } = resolvedConfig;
21
- styleguide.skipPreprocessors(argv['skip-preprocessor']);
22
- styleguide.skipDecorators(argv['skip-decorator']);
23
- process.stderr.write((0, colorette_1.gray)(`bundling ${(0, miscellaneous_1.formatPath)(path)}...\n`));
24
- const { bundle: result, problems, ...meta } = await (0, openapi_core_1.bundle)({
25
- config: resolvedConfig,
14
+ const startedAt = performance.now();
15
+ const aliasConfig = config.forAlias(alias);
16
+ aliasConfig.skipPreprocessors(argv['skip-preprocessor']);
17
+ aliasConfig.skipDecorators(argv['skip-decorator']);
18
+ logger.info(gray(`bundling ${formatPath(path)}...\n`));
19
+ const { bundle: result, problems, ...meta } = await bundle({
26
20
  ref: path,
21
+ config: aliasConfig,
27
22
  dereference: argv.dereferenced,
28
23
  removeUnusedComponents,
29
24
  keepUrlRefs: argv['keep-url-references'],
30
25
  collectSpecData,
31
26
  });
32
- const fileTotals = (0, openapi_core_1.getTotals)(problems);
33
- const { outputFile, ext } = (0, miscellaneous_1.getOutputFileName)({
27
+ const fileTotals = getTotals(problems);
28
+ const { outputFile, ext } = getOutputFileName({
34
29
  entrypoint: path,
35
30
  output,
36
31
  argvOutput: argv.output,
@@ -39,53 +34,54 @@ async function handleBundle({ argv, config, version, collectSpecData, }) {
39
34
  });
40
35
  if (fileTotals.errors === 0 || argv.force) {
41
36
  if (!outputFile) {
42
- const bundled = (0, miscellaneous_1.dumpBundle)((0, miscellaneous_1.sortTopLevelKeysForOas)(result.parsed), argv.ext || 'yaml', argv.dereferenced);
43
- process.stdout.write(bundled);
37
+ const bundled = dumpBundle(sortTopLevelKeysForOas(result.parsed), argv.ext || 'yaml', argv.dereferenced);
38
+ logger.output(bundled);
44
39
  }
45
40
  else {
46
- const bundled = (0, miscellaneous_1.dumpBundle)((0, miscellaneous_1.sortTopLevelKeysForOas)(result.parsed), ext, argv.dereferenced);
47
- (0, miscellaneous_1.saveBundle)(outputFile, bundled);
41
+ const bundled = dumpBundle(sortTopLevelKeysForOas(result.parsed), ext, argv.dereferenced);
42
+ saveBundle(outputFile, bundled);
48
43
  }
49
44
  }
50
45
  totals.errors += fileTotals.errors;
51
46
  totals.warnings += fileTotals.warnings;
52
47
  totals.ignored += fileTotals.ignored;
53
- (0, openapi_core_1.formatProblems)(problems, {
48
+ formatProblems(problems, {
54
49
  format: 'codeframe',
55
50
  totals: fileTotals,
56
51
  version,
57
52
  });
58
53
  if (argv.metafile) {
59
54
  if (apis.length > 1) {
60
- process.stderr.write((0, colorette_1.yellow)(`[WARNING] "--metafile" cannot be used with multiple apis. Skipping...`));
55
+ logger.warn(`[WARNING] "--metafile" cannot be used with multiple apis. Skipping...`);
61
56
  }
62
57
  {
63
- (0, fs_1.writeFileSync)(argv.metafile, JSON.stringify(meta), 'utf-8');
58
+ writeFileSync(argv.metafile, JSON.stringify(meta), 'utf-8');
64
59
  }
65
60
  }
66
- const elapsed = (0, miscellaneous_1.getExecutionTime)(startedAt);
61
+ const elapsed = getExecutionTime(startedAt);
67
62
  if (fileTotals.errors > 0) {
68
63
  if (argv.force) {
69
- process.stderr.write(`❓ Created a bundle for ${(0, colorette_1.blue)((0, miscellaneous_1.formatPath)(path))} at ${(0, colorette_1.blue)(outputFile || 'stdout')} with errors ${(0, colorette_1.green)(elapsed)}.\n${(0, colorette_1.yellow)('Errors ignored because of --force')}.\n`);
64
+ logger.info(`❓ Created a bundle for ${blue(formatPath(path))} at ${blue(outputFile || 'stdout')} with errors ${green(elapsed)}.\n${yellow('Errors ignored because of --force')}.\n`);
70
65
  }
71
66
  else {
72
- process.stderr.write(`❌ Errors encountered while bundling ${(0, colorette_1.blue)((0, miscellaneous_1.formatPath)(path))}: bundle not created (use --force to ignore errors).\n`);
67
+ logger.info(`❌ Errors encountered while bundling ${blue(formatPath(path))}: bundle not created (use --force to ignore errors).\n`);
73
68
  }
74
69
  }
75
70
  else {
76
- process.stderr.write(`📦 Created a bundle for ${(0, colorette_1.blue)((0, miscellaneous_1.formatPath)(path))} at ${(0, colorette_1.blue)(outputFile || 'stdout')} ${(0, colorette_1.green)(elapsed)}.\n`);
71
+ logger.info(`📦 Created a bundle for ${blue(formatPath(path))} at ${blue(outputFile || 'stdout')} ${green(elapsed)}.\n`);
77
72
  }
78
73
  const removedCount = meta.visitorsData?.['remove-unused-components']?.removedCount;
79
74
  if (removedCount) {
80
- process.stderr.write((0, colorette_1.gray)(`🧹 Removed ${removedCount} unused components.\n`));
75
+ logger.info(gray(`🧹 Removed ${removedCount} unused components.\n`));
81
76
  }
82
77
  }
83
78
  catch (e) {
84
- (0, miscellaneous_1.handleError)(e, path);
79
+ handleError(e, path);
85
80
  }
86
81
  }
87
- (0, miscellaneous_1.printUnusedWarnings)(config.styleguide);
82
+ printUnusedWarnings(config);
88
83
  if (!(totals.errors === 0 || argv.force)) {
89
- throw new Error('Bundle failed.');
84
+ throw new AbortFlowError('Bundle failed.');
90
85
  }
91
86
  }
87
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/commands/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAA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C,YAAY,EAAE,CAAC,0BAA0B,CAAC,EAAE,YAAY,CAAC;YACnF,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,YAAY,uBAAuB,CAAC,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5B,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { CommandArgs } from '../wrapper';
2
- import type { VerifyConfigOptions } from '../types';
1
+ import type { CommandArgs } from '../wrapper.js';
2
+ import type { VerifyConfigOptions } from '../types.js';
3
3
  export type EjectOptions = {
4
4
  type: 'component';
5
5
  path?: string;
@@ -7,3 +7,4 @@ export type EjectOptions = {
7
7
  force: boolean;
8
8
  } & VerifyConfigOptions;
9
9
  export declare const handleEject: ({ argv }: CommandArgs<EjectOptions>) => Promise<void>;
10
+ //# sourceMappingURL=eject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../../src/commands/eject.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,mBAAmB,CAAC;AAExB,eAAO,MAAM,WAAW,aAAoB,WAAW,CAAC,YAAY,CAAC,kBA4BpE,CAAC"}
@@ -1,14 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleEject = void 0;
4
- const child_process_1 = require("child_process");
5
- const platform_1 = require("../utils/platform");
6
- const handleEject = async ({ argv }) => {
7
- process.stdout.write(`\nLaunching eject using NPX.\n\n`);
8
- const { npxExecutableName, sanitize, shell } = (0, platform_1.getPlatformSpawnArgs)();
9
- const path = sanitize(argv.path, platform_1.sanitizePath);
10
- const projectDir = sanitize(argv['project-dir'], platform_1.sanitizePath);
11
- const child = (0, child_process_1.spawn)(npxExecutableName, [
1
+ import { spawn } from 'node:child_process';
2
+ import { logger } from '@redocly/openapi-core';
3
+ import { getPlatformSpawnArgs, sanitizePath } from '../utils/platform.js';
4
+ export const handleEject = async ({ argv }) => {
5
+ logger.info(`\nLaunching eject using NPX.\n\n`);
6
+ const { npxExecutableName, sanitize, shell } = getPlatformSpawnArgs();
7
+ const path = sanitize(argv.path, sanitizePath);
8
+ const projectDir = sanitize(argv['project-dir'], sanitizePath);
9
+ const child = spawn(npxExecutableName, [
12
10
  '-y',
13
11
  '@redocly/realm',
14
12
  'eject',
@@ -21,8 +19,8 @@ const handleEject = async ({ argv }) => {
21
19
  shell,
22
20
  });
23
21
  child.on('error', (error) => {
24
- process.stderr.write(`Eject launch failed: ${error.message}`);
22
+ logger.info(`Eject launch failed: ${error.message}`);
25
23
  throw new Error('Eject launch failed.');
26
24
  });
27
25
  };
28
- exports.handleEject = handleEject;
26
+ //# sourceMappingURL=eject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eject.js","sourceRoot":"","sources":["../../src/commands/eject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAY1E,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,EAAE,IAAI,EAA6B,EAAE,EAAE;IACvE,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAChD,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAEtE,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC,CAAC;IAE/D,MAAM,KAAK,GAAG,KAAK,CACjB,iBAAiB,EACjB;QACE,IAAI;QACJ,gBAAgB;QAChB,OAAO;QACP,GAAG,IAAI,CAAC,IAAI,EAAE;QACd,IAAI;QACJ,MAAM,UAAU,EAAE;QAClB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE;KAC1C,EACD;QACE,KAAK,EAAE,SAAS;QAChB,KAAK;KACN,CACF,CAAC;IAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { CommandArgs } from '../wrapper';
2
- import type { VerifyConfigOptions } from '../types';
1
+ import type { CommandArgs } from '../wrapper.js';
2
+ import type { VerifyConfigOptions } from '../types.js';
3
3
  export type JoinOptions = {
4
4
  apis: string[];
5
5
  'prefix-tags-with-info-prop'?: string;
@@ -8,4 +8,5 @@ export type JoinOptions = {
8
8
  'without-x-tag-groups'?: boolean;
9
9
  output?: string;
10
10
  } & VerifyConfigOptions;
11
- export declare function handleJoin({ argv, config, version: packageVersion, collectSpecData, }: CommandArgs<JoinOptions>): Promise<void>;
11
+ export declare function handleJoin({ argv, config, version: packageVersion, collectSpecData, }: CommandArgs<JoinOptions>): Promise<undefined>;
12
+ //# sourceMappingURL=join.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../src/commands/join.ts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAgBvD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,kCAAkC,CAAC,EAAE,MAAM,CAAC;IAC5C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,mBAAmB,CAAC;AAExB,wBAAsB,UAAU,CAAC,EAC/B,IAAI,EACJ,MAAM,EACN,OAAO,EAAE,cAAc,EACvB,eAAe,GAChB,EAAE,WAAW,CAAC,WAAW,CAAC,sBA4jB1B"}
@@ -1,20 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleJoin = handleJoin;
4
- const path = require("path");
5
- const colorette_1 = require("colorette");
6
- const perf_hooks_1 = require("perf_hooks");
7
- const openapi_core_1 = require("@redocly/openapi-core");
8
- const utils_1 = require("@redocly/openapi-core/lib/utils");
9
- const miscellaneous_1 = require("../utils/miscellaneous");
10
- const js_utils_1 = require("../utils/js-utils");
11
- const types_1 = require("./split/types");
12
- const split_1 = require("./split");
1
+ import * as path from 'node:path';
2
+ import { red, blue, yellow, green } from 'colorette';
3
+ import { performance } from 'node:perf_hooks';
4
+ import { SpecVersion, BaseResolver, formatProblems, getTotals, detectSpec, bundleDocument, isRef, dequal, logger, } from '@redocly/openapi-core';
5
+ import { getFallbackApisOrExit, printExecutionTime, sortTopLevelKeysForOas, getAndValidateFileExtension, writeToFileByExtension, } from '../utils/miscellaneous.js';
6
+ import { exitWithError } from '../utils/error.js';
7
+ import { isObject, isString, keysOf } from '../utils/js-utils.js';
8
+ import { COMPONENTS, OPENAPI3_METHOD } from './split/types.js';
9
+ import { crawl, startsWithComponents } from './split/index.js';
13
10
  const Tags = 'tags';
14
11
  const xTagGroups = 'x-tagGroups';
15
12
  let potentialConflictsTotal = 0;
16
- async function handleJoin({ argv, config, version: packageVersion, collectSpecData, }) {
17
- const startedAt = perf_hooks_1.performance.now();
13
+ export async function handleJoin({ argv, config, version: packageVersion, collectSpecData, }) {
14
+ const startedAt = performance.now();
18
15
  const { 'prefix-components-with-info-prop': prefixComponentsWithInfoProp, 'prefix-tags-with-filename': prefixTagsWithFilename, 'prefix-tags-with-info-prop': prefixTagsWithInfoProp, 'without-x-tag-groups': withoutXTagGroups, output, } = argv;
19
16
  const usedTagsOptions = [
20
17
  prefixTagsWithFilename && 'prefix-tags-with-filename',
@@ -22,60 +19,60 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
22
19
  withoutXTagGroups && 'without-x-tag-groups',
23
20
  ].filter(Boolean);
24
21
  if (usedTagsOptions.length > 1) {
25
- return (0, miscellaneous_1.exitWithError)(`You use ${(0, colorette_1.yellow)(usedTagsOptions.join(', '))} together.\nPlease choose only one!`);
22
+ return exitWithError(`You use ${yellow(usedTagsOptions.join(', '))} together.\nPlease choose only one!`);
26
23
  }
27
- const apis = await (0, miscellaneous_1.getFallbackApisOrExit)(argv.apis, config);
24
+ const apis = await getFallbackApisOrExit(argv.apis, config);
28
25
  if (apis.length < 2) {
29
- return (0, miscellaneous_1.exitWithError)(`At least 2 APIs should be provided.`);
26
+ return exitWithError(`At least 2 APIs should be provided.`);
30
27
  }
31
- const fileExtension = (0, miscellaneous_1.getAndValidateFileExtension)(output || apis[0].path);
28
+ const fileExtension = getAndValidateFileExtension(output || apis[0].path);
32
29
  const specFilename = output || `openapi.${fileExtension}`;
33
- const externalRefResolver = new openapi_core_1.BaseResolver(config.resolve);
30
+ const externalRefResolver = new BaseResolver(config.resolve);
34
31
  const documents = await Promise.all(apis.map(({ path }) => externalRefResolver.resolveDocument(null, path, true)));
35
32
  const decorators = new Set([
36
- ...Object.keys(config.styleguide.decorators.oas3_0),
37
- ...Object.keys(config.styleguide.decorators.oas3_1),
38
- ...Object.keys(config.styleguide.decorators.oas2),
33
+ ...Object.keys(config.decorators.oas3_0),
34
+ ...Object.keys(config.decorators.oas3_1),
35
+ ...Object.keys(config.decorators.oas2),
39
36
  ]);
40
- config.styleguide.skipDecorators(Array.from(decorators));
37
+ config.skipDecorators(Array.from(decorators));
41
38
  const preprocessors = new Set([
42
- ...Object.keys(config.styleguide.preprocessors.oas3_0),
43
- ...Object.keys(config.styleguide.preprocessors.oas3_1),
44
- ...Object.keys(config.styleguide.preprocessors.oas2),
39
+ ...Object.keys(config.preprocessors.oas3_0),
40
+ ...Object.keys(config.preprocessors.oas3_1),
41
+ ...Object.keys(config.preprocessors.oas2),
45
42
  ]);
46
- config.styleguide.skipPreprocessors(Array.from(preprocessors));
47
- const bundleResults = await Promise.all(documents.map((document) => (0, openapi_core_1.bundleDocument)({
43
+ config.skipPreprocessors(Array.from(preprocessors));
44
+ const bundleResults = await Promise.all(documents.map((document) => bundleDocument({
48
45
  document,
49
- config: config.styleguide,
50
- externalRefResolver: new openapi_core_1.BaseResolver(config.resolve),
46
+ config,
47
+ externalRefResolver: new BaseResolver(config.resolve),
51
48
  }).catch((e) => {
52
- (0, miscellaneous_1.exitWithError)(`${e.message}: ${(0, colorette_1.blue)(document.source.absoluteRef)}`);
49
+ exitWithError(`${e.message}: ${blue(document.source.absoluteRef)}`);
53
50
  })));
54
51
  for (const { problems, bundle: document } of bundleResults) {
55
- const fileTotals = (0, openapi_core_1.getTotals)(problems);
52
+ const fileTotals = getTotals(problems);
56
53
  if (fileTotals.errors) {
57
- (0, openapi_core_1.formatProblems)(problems, {
54
+ formatProblems(problems, {
58
55
  totals: fileTotals,
59
56
  version: packageVersion,
60
57
  });
61
- (0, miscellaneous_1.exitWithError)(`❌ Errors encountered while bundling ${(0, colorette_1.blue)(document.source.absoluteRef)}: join will not proceed.`);
58
+ exitWithError(`❌ Errors encountered while bundling ${blue(document.source.absoluteRef)}: join will not proceed.`);
62
59
  }
63
60
  }
64
61
  let oasVersion = null;
65
62
  for (const document of documents) {
66
63
  try {
67
- const version = (0, openapi_core_1.detectSpec)(document.parsed);
64
+ const version = detectSpec(document.parsed);
68
65
  collectSpecData?.(document.parsed);
69
- if (version !== openapi_core_1.SpecVersion.OAS3_0 && version !== openapi_core_1.SpecVersion.OAS3_1) {
70
- return (0, miscellaneous_1.exitWithError)(`Only OpenAPI 3.0 and OpenAPI 3.1 are supported: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
66
+ if (version !== SpecVersion.OAS3_0 && version !== SpecVersion.OAS3_1) {
67
+ return exitWithError(`Only OpenAPI 3.0 and OpenAPI 3.1 are supported: ${blue(document.source.absoluteRef)}.`);
71
68
  }
72
69
  oasVersion = oasVersion ?? version;
73
70
  if (oasVersion !== version) {
74
- return (0, miscellaneous_1.exitWithError)(`All APIs must use the same OpenAPI version: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
71
+ return exitWithError(`All APIs must use the same OpenAPI version: ${blue(document.source.absoluteRef)}.`);
75
72
  }
76
73
  }
77
74
  catch (e) {
78
- return (0, miscellaneous_1.exitWithError)(`${e.message}: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
75
+ return exitWithError(`${e.message}: ${blue(document.source.absoluteRef)}.`);
79
76
  }
80
77
  }
81
78
  const joinedDef = {};
@@ -94,9 +91,9 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
94
91
  const tagsPrefix = prefixTagsWithFilename
95
92
  ? apiFilename
96
93
  : getInfoPrefix(info, prefixTagsWithInfoProp, 'tags');
97
- const componentsPrefix = getInfoPrefix(info, prefixComponentsWithInfoProp, types_1.COMPONENTS);
94
+ const componentsPrefix = getInfoPrefix(info, prefixComponentsWithInfoProp, COMPONENTS);
98
95
  if (openapi.hasOwnProperty('x-tagGroups')) {
99
- process.stderr.write((0, colorette_1.yellow)(`warning: x-tagGroups at ${(0, colorette_1.blue)(api)} will be skipped \n`));
96
+ logger.warn(`warning: x-tagGroups at ${blue(api)} will be skipped \n`);
100
97
  }
101
98
  const context = {
102
99
  api,
@@ -122,10 +119,10 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
122
119
  iteratePotentialConflicts(potentialConflicts, withoutXTagGroups);
123
120
  const noRefs = true;
124
121
  if (potentialConflictsTotal) {
125
- return (0, miscellaneous_1.exitWithError)(`Please fix conflicts before running ${(0, colorette_1.yellow)('join')}.`);
122
+ return exitWithError(`Please fix conflicts before running ${yellow('join')}.`);
126
123
  }
127
- (0, miscellaneous_1.writeToFileByExtension)((0, miscellaneous_1.sortTopLevelKeysForOas)(joinedDef), specFilename, noRefs);
128
- (0, miscellaneous_1.printExecutionTime)('join', startedAt, specFilename);
124
+ writeToFileByExtension(sortTopLevelKeysForOas(joinedDef), specFilename, noRefs);
125
+ printExecutionTime('join', startedAt, specFilename);
129
126
  function populateTags({ api, apiFilename, apiTitle, tags, potentialConflicts, tagsPrefix, componentsPrefix, }) {
130
127
  if (!joinedDef.hasOwnProperty(Tags)) {
131
128
  joinedDef[Tags] = [];
@@ -210,7 +207,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
210
207
  const { externalDocs } = openapi;
211
208
  if (externalDocs) {
212
209
  if (joinedDef.hasOwnProperty('externalDocs')) {
213
- process.stderr.write((0, colorette_1.yellow)(`warning: skip externalDocs from ${(0, colorette_1.blue)(path.basename(api))} \n`));
210
+ logger.warn(`warning: skip externalDocs from ${blue(path.basename(api))} \n`);
214
211
  return;
215
212
  }
216
213
  joinedDef['externalDocs'] = externalDocs;
@@ -218,12 +215,12 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
218
215
  }
219
216
  function collectPaths(openapi, { apiFilename, apiTitle, api, potentialConflicts, tagsPrefix, componentsPrefix, }) {
220
217
  const { paths } = openapi;
221
- const operationsSet = new Set((0, js_utils_1.keysOf)(types_1.OPENAPI3_METHOD));
218
+ const operationsSet = new Set(keysOf(OPENAPI3_METHOD));
222
219
  if (paths) {
223
220
  if (!joinedDef.hasOwnProperty('paths')) {
224
221
  joinedDef['paths'] = {};
225
222
  }
226
- for (const path of (0, js_utils_1.keysOf)(paths)) {
223
+ for (const path of keysOf(paths)) {
227
224
  if (!joinedDef.paths.hasOwnProperty(path)) {
228
225
  joinedDef.paths[path] = {};
229
226
  }
@@ -231,7 +228,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
231
228
  potentialConflicts.paths[path] = {};
232
229
  }
233
230
  const pathItem = paths[path];
234
- for (const field of (0, js_utils_1.keysOf)(pathItem)) {
231
+ for (const field of keysOf(pathItem)) {
235
232
  if (operationsSet.has(field)) {
236
233
  collectPathOperation(pathItem, path, field);
237
234
  }
@@ -251,7 +248,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
251
248
  const fieldValue = pathItem[field];
252
249
  if (joinedDef.paths[path].hasOwnProperty(field) &&
253
250
  joinedDef.paths[path][field] !== fieldValue) {
254
- process.stderr.write((0, colorette_1.yellow)(`warning: different ${field} values in ${path}\n`));
251
+ logger.warn(`warning: different ${field} values in ${path}\n`);
255
252
  return;
256
253
  }
257
254
  joinedDef.paths[path][field] = fieldValue;
@@ -268,7 +265,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
268
265
  for (const pathServer of joinedDef.paths[path].servers) {
269
266
  if (pathServer.url === server.url) {
270
267
  if (!isServersEqual(pathServer, server)) {
271
- (0, miscellaneous_1.exitWithError)(`Different server values for (${server.url}) in ${path}.`);
268
+ exitWithError(`Different server values for (${server.url}) in ${path}.`);
272
269
  }
273
270
  isFoundServer = true;
274
271
  }
@@ -290,16 +287,16 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
290
287
  for (const pathParameter of joinedDef.paths[path]
291
288
  .parameters) {
292
289
  // Compare $ref only if both are reference objects
293
- if ((0, openapi_core_1.isRef)(pathParameter) && (0, openapi_core_1.isRef)(parameter)) {
290
+ if (isRef(pathParameter) && isRef(parameter)) {
294
291
  if (pathParameter['$ref'] === parameter['$ref']) {
295
292
  isFoundParameter = true;
296
293
  }
297
294
  }
298
295
  // Compare properties only if both are reference objects
299
- if (!(0, openapi_core_1.isRef)(pathParameter) && !(0, openapi_core_1.isRef)(parameter)) {
296
+ if (!isRef(pathParameter) && !isRef(parameter)) {
300
297
  if (pathParameter.name === parameter.name && pathParameter.in === parameter.in) {
301
- if (!(0, utils_1.dequal)(pathParameter.schema, parameter.schema)) {
302
- (0, miscellaneous_1.exitWithError)(`Different parameter schemas for (${parameter.name}) in ${path}.`);
298
+ if (!dequal(pathParameter.schema, parameter.schema)) {
299
+ exitWithError(`Different parameter schemas for (${parameter.name}) in ${path}.`);
303
300
  }
304
301
  isFoundParameter = true;
305
302
  }
@@ -365,20 +362,20 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
365
362
  }
366
363
  function isServersEqual(serverOne, serverTwo) {
367
364
  if (serverOne.description === serverTwo.description) {
368
- return (0, utils_1.dequal)(serverOne.variables, serverTwo.variables);
365
+ return dequal(serverOne.variables, serverTwo.variables);
369
366
  }
370
367
  return false;
371
368
  }
372
369
  function collectComponents(openapi, { api, potentialConflicts, componentsPrefix }) {
373
370
  const { components } = openapi;
374
371
  if (components) {
375
- if (!joinedDef.hasOwnProperty(types_1.COMPONENTS)) {
376
- joinedDef[types_1.COMPONENTS] = {};
372
+ if (!joinedDef.hasOwnProperty(COMPONENTS)) {
373
+ joinedDef[COMPONENTS] = {};
377
374
  }
378
375
  for (const [component, componentObj] of Object.entries(components)) {
379
- if (!potentialConflicts[types_1.COMPONENTS].hasOwnProperty(component)) {
380
- potentialConflicts[types_1.COMPONENTS][component] = {};
381
- joinedDef[types_1.COMPONENTS][component] = {};
376
+ if (!potentialConflicts[COMPONENTS].hasOwnProperty(component)) {
377
+ potentialConflicts[COMPONENTS][component] = {};
378
+ joinedDef[COMPONENTS][component] = {};
382
379
  }
383
380
  for (const item of Object.keys(componentObj)) {
384
381
  const componentPrefix = addPrefix(item, componentsPrefix);
@@ -392,7 +389,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
392
389
  }
393
390
  }
394
391
  function collectWebhooks(oasVersion, openapi, { apiFilename, apiTitle, api, potentialConflicts, tagsPrefix, componentsPrefix, }) {
395
- const webhooks = oasVersion === openapi_core_1.SpecVersion.OAS3_1 ? 'webhooks' : 'x-webhooks';
392
+ const webhooks = oasVersion === SpecVersion.OAS3_1 ? 'webhooks' : 'x-webhooks';
396
393
  const openapiWebhooks = openapi[webhooks];
397
394
  if (openapiWebhooks) {
398
395
  if (!joinedDef.hasOwnProperty(webhooks)) {
@@ -430,11 +427,11 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
430
427
  function addInfoSectionAndSpecVersion(documents, prefixComponentsWithInfoProp) {
431
428
  const firstApi = documents[0];
432
429
  const openapi = firstApi.parsed;
433
- const componentsPrefix = getInfoPrefix(openapi.info, prefixComponentsWithInfoProp, types_1.COMPONENTS);
430
+ const componentsPrefix = getInfoPrefix(openapi.info, prefixComponentsWithInfoProp, COMPONENTS);
434
431
  if (!openapi.openapi)
435
- (0, miscellaneous_1.exitWithError)('Version of specification is not found.');
432
+ exitWithError('Version of specification is not found.');
436
433
  if (!openapi.info)
437
- (0, miscellaneous_1.exitWithError)('Info section is not found in specification.');
434
+ exitWithError('Info section is not found in specification.');
438
435
  if (openapi.info?.description) {
439
436
  openapi.info.description = addComponentsPrefix(openapi.info.description, componentsPrefix);
440
437
  }
@@ -443,7 +440,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
443
440
  }
444
441
  }
445
442
  function doesComponentsDiffer(curr, next) {
446
- return !(0, utils_1.dequal)(Object.values(curr)[0], Object.values(next)[0]);
443
+ return !dequal(Object.values(curr)[0], Object.values(next)[0]);
447
444
  }
448
445
  function validateComponentsDifference(files) {
449
446
  let isDiffer = false;
@@ -460,11 +457,11 @@ function iteratePotentialConflicts(potentialConflicts, withoutXTagGroups) {
460
457
  for (const [key, value] of Object.entries(potentialConflicts[group])) {
461
458
  const conflicts = filterConflicts(value);
462
459
  if (conflicts.length) {
463
- if (group === types_1.COMPONENTS) {
460
+ if (group === COMPONENTS) {
464
461
  for (const [_, conflict] of Object.entries(conflicts)) {
465
462
  if (validateComponentsDifference(conflict[1])) {
466
463
  conflict[1] = conflict[1].map((c) => Object.keys(c)[0]);
467
- showConflicts((0, colorette_1.green)(group) + ' => ' + key, [conflict]);
464
+ showConflicts(green(group) + ' => ' + key, [conflict]);
468
465
  potentialConflictsTotal += 1;
469
466
  }
470
467
  }
@@ -475,7 +472,7 @@ function iteratePotentialConflicts(potentialConflicts, withoutXTagGroups) {
475
472
  }
476
473
  else {
477
474
  potentialConflictsTotal += conflicts.length;
478
- showConflicts((0, colorette_1.green)(group) + ' => ' + key, conflicts);
475
+ showConflicts(green(group) + ' => ' + key, conflicts);
479
476
  }
480
477
  }
481
478
  if (group === 'tags' && !withoutXTagGroups) {
@@ -487,15 +484,15 @@ function iteratePotentialConflicts(potentialConflicts, withoutXTagGroups) {
487
484
  }
488
485
  function duplicateTagDescriptionWarning(conflicts) {
489
486
  const tagsKeys = conflicts.map(([tagName]) => `\`${tagName}\``);
490
- const joinString = (0, colorette_1.yellow)(', ');
491
- process.stderr.write((0, colorette_1.yellow)(`\nwarning: ${tagsKeys.length} conflict(s) on the ${(0, colorette_1.red)(tagsKeys.join(joinString))} tags description.\n`));
487
+ const joinString = yellow(', ');
488
+ logger.warn(`\nwarning: ${tagsKeys.length} conflict(s) on the ${red(tagsKeys.join(joinString))} tags description.\n`);
492
489
  }
493
490
  function prefixTagSuggestion(conflictsLength) {
494
- process.stderr.write((0, colorette_1.green)(`\n${conflictsLength} conflict(s) on tags.\nSuggestion: please use ${(0, colorette_1.blue)('prefix-tags-with-filename')}, ${(0, colorette_1.blue)('prefix-tags-with-info-prop')} or ${(0, colorette_1.blue)('without-x-tag-groups')} to prevent naming conflicts.\n\n`));
491
+ logger.info(green(`\n${conflictsLength} conflict(s) on tags.\nSuggestion: please use ${blue('prefix-tags-with-filename')}, ${blue('prefix-tags-with-info-prop')} or ${blue('without-x-tag-groups')} to prevent naming conflicts.\n\n`));
495
492
  }
496
493
  function showConflicts(key, conflicts) {
497
494
  for (const [path, files] of conflicts) {
498
- process.stderr.write((0, colorette_1.yellow)(`Conflict on ${key} : ${(0, colorette_1.red)(path)} in files: ${(0, colorette_1.blue)(files)} \n`));
495
+ logger.warn(`Conflict on ${key} : ${red(path)} in files: ${blue(files)} \n`);
499
496
  }
500
497
  }
501
498
  function filterConflicts(entities) {
@@ -531,26 +528,26 @@ function getInfoPrefix(info, prefixArg, type) {
531
528
  if (!prefixArg)
532
529
  return '';
533
530
  if (!info)
534
- (0, miscellaneous_1.exitWithError)('Info section is not found in specification.');
531
+ exitWithError('Info section is not found in specification.');
535
532
  if (!info[prefixArg])
536
- (0, miscellaneous_1.exitWithError)(`${(0, colorette_1.yellow)(`prefix-${type}-with-info-prop`)} argument value is not found in info section.`);
537
- if (!(0, js_utils_1.isString)(info[prefixArg]))
538
- (0, miscellaneous_1.exitWithError)(`${(0, colorette_1.yellow)(`prefix-${type}-with-info-prop`)} argument value should be string.`);
533
+ exitWithError(`${yellow(`prefix-${type}-with-info-prop`)} argument value is not found in info section.`);
534
+ if (!isString(info[prefixArg]))
535
+ exitWithError(`${yellow(`prefix-${type}-with-info-prop`)} argument value should be string.`);
539
536
  if (info[prefixArg].length > 50)
540
- (0, miscellaneous_1.exitWithError)(`${(0, colorette_1.yellow)(`prefix-${type}-with-info-prop`)} argument value length should not exceed 50 characters.`);
537
+ exitWithError(`${yellow(`prefix-${type}-with-info-prop`)} argument value length should not exceed 50 characters.`);
541
538
  return info[prefixArg].replaceAll(/\s/g, '_');
542
539
  }
543
540
  function replace$Refs(obj, componentsPrefix) {
544
- (0, split_1.crawl)(obj, (node) => {
545
- if (node.$ref && typeof node.$ref === 'string' && (0, split_1.startsWithComponents)(node.$ref)) {
541
+ crawl(obj, (node) => {
542
+ if (node.$ref && typeof node.$ref === 'string' && startsWithComponents(node.$ref)) {
546
543
  const name = path.basename(node.$ref);
547
544
  node.$ref = node.$ref.replace(name, componentsPrefix + '_' + name);
548
545
  }
549
- else if ((0, js_utils_1.isObject)(node.discriminator) && (0, js_utils_1.isObject)(node.discriminator.mapping)) {
546
+ else if (isObject(node.discriminator) && isObject(node.discriminator.mapping)) {
550
547
  const { mapping } = node.discriminator;
551
548
  for (const name of Object.keys(mapping)) {
552
549
  const mappingPointer = mapping[name];
553
- if (typeof mappingPointer === 'string' && (0, split_1.startsWithComponents)(mappingPointer)) {
550
+ if (typeof mappingPointer === 'string' && startsWithComponents(mappingPointer)) {
554
551
  mapping[name] = mappingPointer
555
552
  .split('/')
556
553
  .map((name, i, arr) => {
@@ -564,3 +561,4 @@ function replace$Refs(obj, componentsPrefix) {
564
561
  }
565
562
  });
566
563
  }
564
+ //# sourceMappingURL=join.js.map