@apimatic/cli 1.1.0-alpha.9 → 1.1.0-beta.10

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 (341) hide show
  1. package/README.md +443 -374
  2. package/bin/run.js +5 -0
  3. package/lib/actions/action-result.d.ts +19 -0
  4. package/lib/actions/action-result.js +70 -0
  5. package/lib/actions/action-result.js.map +1 -0
  6. package/lib/actions/api/transform.d.ts +15 -0
  7. package/lib/actions/api/transform.js +48 -0
  8. package/lib/actions/api/transform.js.map +1 -0
  9. package/lib/actions/api/validate.d.ts +14 -0
  10. package/lib/actions/api/validate.js +52 -0
  11. package/lib/actions/api/validate.js.map +1 -0
  12. package/lib/actions/auth/login.d.ts +13 -0
  13. package/lib/actions/auth/login.js +55 -0
  14. package/lib/actions/auth/login.js.map +1 -0
  15. package/lib/actions/auth/logout.d.ts +8 -0
  16. package/lib/actions/auth/logout.js +15 -0
  17. package/lib/actions/auth/logout.js.map +1 -0
  18. package/lib/actions/auth/status.d.ts +11 -0
  19. package/lib/actions/auth/status.js +26 -0
  20. package/lib/actions/auth/status.js.map +1 -0
  21. package/lib/actions/portal/copilot.d.ts +16 -0
  22. package/lib/actions/portal/copilot.js +89 -0
  23. package/lib/actions/portal/copilot.js.map +1 -0
  24. package/lib/actions/portal/generate.d.ts +11 -5
  25. package/lib/actions/portal/generate.js +60 -55
  26. package/lib/actions/portal/generate.js.map +1 -0
  27. package/lib/actions/portal/quickstart.d.ts +17 -0
  28. package/lib/actions/portal/quickstart.js +169 -0
  29. package/lib/actions/portal/quickstart.js.map +1 -0
  30. package/lib/actions/portal/recipe/new-recipe.d.ts +15 -0
  31. package/lib/actions/portal/recipe/new-recipe.js +177 -0
  32. package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
  33. package/lib/actions/portal/serve.d.ts +15 -0
  34. package/lib/actions/portal/serve.js +104 -0
  35. package/lib/actions/portal/serve.js.map +1 -0
  36. package/lib/actions/portal/toc/new-toc.d.ts +17 -13
  37. package/lib/actions/portal/toc/new-toc.js +85 -123
  38. package/lib/actions/portal/toc/new-toc.js.map +1 -0
  39. package/lib/actions/quickstart.d.ts +10 -0
  40. package/lib/actions/quickstart.js +30 -0
  41. package/lib/actions/quickstart.js.map +1 -0
  42. package/lib/actions/sdk/generate.d.ts +13 -0
  43. package/lib/actions/sdk/generate.js +77 -0
  44. package/lib/actions/sdk/generate.js.map +1 -0
  45. package/lib/actions/sdk/quickstart.d.ts +17 -0
  46. package/lib/actions/sdk/quickstart.js +171 -0
  47. package/lib/actions/sdk/quickstart.js.map +1 -0
  48. package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
  49. package/lib/application/portal/recipe/portal-recipe.js +33 -0
  50. package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
  51. package/lib/application/portal/recipe/recipe-generator.d.ts +21 -0
  52. package/lib/application/portal/recipe/recipe-generator.js +145 -0
  53. package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
  54. package/lib/application/portal/toc/toc-content-parser.d.ts +1 -1
  55. package/lib/application/portal/toc/toc-content-parser.js +9 -11
  56. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  57. package/lib/application/portal/toc/toc-structure-generator.d.ts +23 -2
  58. package/lib/application/portal/toc/toc-structure-generator.js +133 -66
  59. package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
  60. package/lib/client-utils/auth-manager.d.ts +7 -2
  61. package/lib/client-utils/auth-manager.js +26 -14
  62. package/lib/client-utils/auth-manager.js.map +1 -0
  63. package/lib/commands/api/transform.d.ts +10 -7
  64. package/lib/commands/api/transform.js +51 -111
  65. package/lib/commands/api/transform.js.map +1 -0
  66. package/lib/commands/api/validate.d.ts +7 -4
  67. package/lib/commands/api/validate.js +31 -74
  68. package/lib/commands/api/validate.js.map +1 -0
  69. package/lib/commands/auth/login.d.ts +3 -1
  70. package/lib/commands/auth/login.js +26 -68
  71. package/lib/commands/auth/login.js.map +1 -0
  72. package/lib/commands/auth/logout.d.ts +3 -1
  73. package/lib/commands/auth/logout.js +14 -21
  74. package/lib/commands/auth/logout.js.map +1 -0
  75. package/lib/commands/auth/status.d.ts +1 -0
  76. package/lib/commands/auth/status.js +18 -21
  77. package/lib/commands/auth/status.js.map +1 -0
  78. package/lib/commands/portal/copilot.d.ts +13 -0
  79. package/lib/commands/portal/copilot.js +34 -0
  80. package/lib/commands/portal/copilot.js.map +1 -0
  81. package/lib/commands/portal/generate.d.ts +7 -11
  82. package/lib/commands/portal/generate.js +26 -89
  83. package/lib/commands/portal/generate.js.map +1 -0
  84. package/lib/commands/portal/recipe/new.d.ts +12 -0
  85. package/lib/commands/portal/recipe/new.js +45 -0
  86. package/lib/commands/portal/recipe/new.js.map +1 -0
  87. package/lib/commands/portal/serve.d.ts +8 -8
  88. package/lib/commands/portal/serve.js +41 -125
  89. package/lib/commands/portal/serve.js.map +1 -0
  90. package/lib/commands/portal/toc/new.d.ts +8 -7
  91. package/lib/commands/portal/toc/new.js +52 -49
  92. package/lib/commands/portal/toc/new.js.map +1 -0
  93. package/lib/commands/quickstart.d.ts +9 -0
  94. package/lib/commands/quickstart.js +37 -0
  95. package/lib/commands/quickstart.js.map +1 -0
  96. package/lib/commands/sdk/generate.d.ts +10 -8
  97. package/lib/commands/sdk/generate.js +46 -131
  98. package/lib/commands/sdk/generate.js.map +1 -0
  99. package/lib/config/axios-config.js +4 -6
  100. package/lib/config/axios-config.js.map +1 -0
  101. package/lib/hooks/not-found.d.ts +3 -0
  102. package/lib/hooks/not-found.js +52 -0
  103. package/lib/hooks/not-found.js.map +1 -0
  104. package/lib/hooks/utils.d.ts +5 -0
  105. package/lib/hooks/utils.js +51 -0
  106. package/lib/hooks/utils.js.map +1 -0
  107. package/lib/index.js +2 -5
  108. package/lib/index.js.map +1 -0
  109. package/lib/infrastructure/debounce-service.d.ts +10 -0
  110. package/lib/infrastructure/debounce-service.js +55 -0
  111. package/lib/infrastructure/debounce-service.js.map +1 -0
  112. package/lib/infrastructure/env-info.d.ts +12 -0
  113. package/lib/infrastructure/env-info.js +58 -0
  114. package/lib/infrastructure/env-info.js.map +1 -0
  115. package/lib/infrastructure/file-service.d.ts +25 -0
  116. package/lib/infrastructure/file-service.js +131 -0
  117. package/lib/infrastructure/file-service.js.map +1 -0
  118. package/lib/infrastructure/launcher-service.d.ts +9 -0
  119. package/lib/infrastructure/launcher-service.js +72 -0
  120. package/lib/infrastructure/launcher-service.js.map +1 -0
  121. package/lib/infrastructure/network-service.d.ts +3 -0
  122. package/lib/infrastructure/network-service.js +7 -0
  123. package/lib/infrastructure/network-service.js.map +1 -0
  124. package/lib/infrastructure/service-error.d.ts +16 -0
  125. package/lib/infrastructure/service-error.js +49 -0
  126. package/lib/infrastructure/service-error.js.map +1 -0
  127. package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
  128. package/lib/infrastructure/services/api-client-factory.js +20 -0
  129. package/lib/infrastructure/services/api-client-factory.js.map +1 -0
  130. package/lib/infrastructure/services/api-service.d.ts +13 -0
  131. package/lib/infrastructure/services/api-service.js +103 -0
  132. package/lib/infrastructure/services/api-service.js.map +1 -0
  133. package/lib/infrastructure/services/auth-service.d.ts +11 -0
  134. package/lib/infrastructure/services/auth-service.js +37 -0
  135. package/lib/infrastructure/services/auth-service.js.map +1 -0
  136. package/lib/infrastructure/services/file-download-service.d.ts +15 -0
  137. package/lib/infrastructure/services/file-download-service.js +104 -0
  138. package/lib/infrastructure/services/file-download-service.js.map +1 -0
  139. package/lib/infrastructure/services/portal-service.d.ts +15 -12
  140. package/lib/infrastructure/services/portal-service.js +152 -99
  141. package/lib/infrastructure/services/portal-service.js.map +1 -0
  142. package/lib/infrastructure/services/telemetry-service.d.ts +9 -0
  143. package/lib/infrastructure/services/telemetry-service.js +38 -0
  144. package/lib/infrastructure/services/telemetry-service.js.map +1 -0
  145. package/lib/infrastructure/services/transformation-service.d.ts +23 -0
  146. package/lib/infrastructure/services/transformation-service.js +56 -0
  147. package/lib/infrastructure/services/transformation-service.js.map +1 -0
  148. package/lib/infrastructure/services/validation-service.d.ts +43 -0
  149. package/lib/infrastructure/services/validation-service.js +142 -0
  150. package/lib/infrastructure/services/validation-service.js.map +1 -0
  151. package/lib/infrastructure/tmp-extensions.d.ts +2 -0
  152. package/lib/infrastructure/tmp-extensions.js +6 -0
  153. package/lib/infrastructure/tmp-extensions.js.map +1 -0
  154. package/lib/infrastructure/zip-service.d.ts +6 -0
  155. package/lib/infrastructure/zip-service.js +39 -0
  156. package/lib/infrastructure/zip-service.js.map +1 -0
  157. package/lib/prompts/api/transform.d.ts +11 -0
  158. package/lib/prompts/api/transform.js +29 -0
  159. package/lib/prompts/api/transform.js.map +1 -0
  160. package/lib/prompts/api/validate.d.ts +15 -0
  161. package/lib/prompts/api/validate.js +76 -0
  162. package/lib/prompts/api/validate.js.map +1 -0
  163. package/lib/prompts/auth/login.d.ts +10 -0
  164. package/lib/prompts/auth/login.js +22 -0
  165. package/lib/prompts/auth/login.js.map +1 -0
  166. package/lib/prompts/auth/logout.d.ts +3 -0
  167. package/lib/prompts/auth/logout.js +7 -0
  168. package/lib/prompts/auth/logout.js.map +1 -0
  169. package/lib/prompts/auth/status.d.ts +8 -0
  170. package/lib/prompts/auth/status.js +22 -0
  171. package/lib/prompts/auth/status.js.map +1 -0
  172. package/lib/prompts/format.d.ts +31 -0
  173. package/lib/prompts/format.js +89 -0
  174. package/lib/prompts/format.js.map +1 -0
  175. package/lib/prompts/portal/copilot.d.ts +18 -0
  176. package/lib/prompts/portal/copilot.js +82 -0
  177. package/lib/prompts/portal/copilot.js.map +1 -0
  178. package/lib/prompts/portal/generate.d.ts +13 -8
  179. package/lib/prompts/portal/generate.js +36 -53
  180. package/lib/prompts/portal/generate.js.map +1 -0
  181. package/lib/prompts/portal/quickstart.d.ts +31 -29
  182. package/lib/prompts/portal/quickstart.js +139 -185
  183. package/lib/prompts/portal/quickstart.js.map +1 -0
  184. package/lib/prompts/portal/recipe/new-recipe.d.ts +29 -0
  185. package/lib/prompts/portal/recipe/new-recipe.js +165 -0
  186. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
  187. package/lib/prompts/portal/serve.d.ts +9 -5
  188. package/lib/prompts/portal/serve.js +29 -19
  189. package/lib/prompts/portal/serve.js.map +1 -0
  190. package/lib/prompts/portal/toc/new-toc.d.ts +13 -8
  191. package/lib/prompts/portal/toc/new-toc.js +36 -36
  192. package/lib/prompts/portal/toc/new-toc.js.map +1 -0
  193. package/lib/prompts/prompt.d.ts +3 -0
  194. package/lib/prompts/prompt.js +37 -0
  195. package/lib/prompts/prompt.js.map +1 -0
  196. package/lib/prompts/quickstart.d.ts +6 -0
  197. package/lib/prompts/quickstart.js +25 -0
  198. package/lib/prompts/quickstart.js.map +1 -0
  199. package/lib/prompts/sdk/generate.d.ts +16 -0
  200. package/lib/prompts/sdk/generate.js +57 -0
  201. package/lib/prompts/sdk/generate.js.map +1 -0
  202. package/lib/prompts/sdk/quickstart.d.ts +35 -0
  203. package/lib/prompts/sdk/quickstart.js +177 -0
  204. package/lib/prompts/sdk/quickstart.js.map +1 -0
  205. package/lib/types/api/account.d.ts +10 -0
  206. package/lib/types/api/account.js +2 -0
  207. package/lib/types/api/account.js.map +1 -0
  208. package/lib/types/api/transform.d.ts +14 -25
  209. package/lib/types/api/transform.js +20 -23
  210. package/lib/types/api/transform.js.map +1 -0
  211. package/lib/types/build/build.d.ts +22 -0
  212. package/lib/types/build/build.js +7 -0
  213. package/lib/types/build/build.js.map +1 -0
  214. package/lib/types/build-context.d.ts +13 -0
  215. package/lib/types/build-context.js +33 -0
  216. package/lib/types/build-context.js.map +1 -0
  217. package/lib/types/common/command-metadata.d.ts +4 -0
  218. package/lib/types/common/command-metadata.js +2 -0
  219. package/lib/types/common/command-metadata.js.map +1 -0
  220. package/lib/types/events/domain-event.d.ts +8 -0
  221. package/lib/types/events/domain-event.js +11 -0
  222. package/lib/types/events/domain-event.js.map +1 -0
  223. package/lib/types/events/quickstart-completed.d.ts +7 -0
  224. package/lib/types/events/quickstart-completed.js +10 -0
  225. package/lib/types/events/quickstart-completed.js.map +1 -0
  226. package/lib/types/events/quickstart-initiated.d.ts +7 -0
  227. package/lib/types/events/quickstart-initiated.js +10 -0
  228. package/lib/types/events/quickstart-initiated.js.map +1 -0
  229. package/lib/types/events/recipe-creation-failed.d.ts +5 -0
  230. package/lib/types/events/recipe-creation-failed.js +8 -0
  231. package/lib/types/events/recipe-creation-failed.js.map +1 -0
  232. package/lib/types/events/toc-creation-failed.d.ts +5 -0
  233. package/lib/types/events/toc-creation-failed.js +8 -0
  234. package/lib/types/events/toc-creation-failed.js.map +1 -0
  235. package/lib/types/file/directory.d.ts +17 -0
  236. package/lib/types/file/directory.js +87 -0
  237. package/lib/types/file/directory.js.map +1 -0
  238. package/lib/types/file/directoryPath.d.ts +10 -0
  239. package/lib/types/file/directoryPath.js +26 -0
  240. package/lib/types/file/directoryPath.js.map +1 -0
  241. package/lib/types/file/fileName.d.ts +7 -0
  242. package/lib/types/file/fileName.js +21 -0
  243. package/lib/types/file/fileName.js.map +1 -0
  244. package/lib/types/file/filePath.d.ts +10 -0
  245. package/lib/types/file/filePath.js +32 -0
  246. package/lib/types/file/filePath.js.map +1 -0
  247. package/lib/types/file/resource-input.d.ts +5 -0
  248. package/lib/types/file/resource-input.js +42 -0
  249. package/lib/types/file/resource-input.js.map +1 -0
  250. package/lib/types/file/urlPath.d.ts +6 -0
  251. package/lib/types/file/urlPath.js +22 -0
  252. package/lib/types/file/urlPath.js.map +1 -0
  253. package/lib/types/flags-provider.d.ts +15 -0
  254. package/lib/types/flags-provider.js +34 -0
  255. package/lib/types/flags-provider.js.map +1 -0
  256. package/lib/types/portal-context.d.ts +13 -0
  257. package/lib/types/portal-context.js +38 -0
  258. package/lib/types/portal-context.js.map +1 -0
  259. package/lib/types/recipe/recipe.d.ts +22 -0
  260. package/lib/types/recipe/recipe.js +6 -0
  261. package/lib/types/recipe/recipe.js.map +1 -0
  262. package/lib/types/recipe-context.d.ts +9 -0
  263. package/lib/types/recipe-context.js +26 -0
  264. package/lib/types/recipe-context.js.map +1 -0
  265. package/lib/types/resource-context.d.ts +12 -0
  266. package/lib/types/resource-context.js +30 -0
  267. package/lib/types/resource-context.js.map +1 -0
  268. package/lib/types/sdk/generate.d.ts +9 -22
  269. package/lib/types/sdk/generate.js +25 -14
  270. package/lib/types/sdk/generate.js.map +1 -0
  271. package/lib/types/sdk-context.d.ts +14 -0
  272. package/lib/types/sdk-context.js +32 -0
  273. package/lib/types/sdk-context.js.map +1 -0
  274. package/lib/types/sdl/sdl.d.ts +27 -0
  275. package/lib/types/sdl/sdl.js +145 -3
  276. package/lib/types/sdl/sdl.js.map +1 -0
  277. package/lib/types/spec-context.d.ts +12 -0
  278. package/lib/types/spec-context.js +29 -0
  279. package/lib/types/spec-context.js.map +1 -0
  280. package/lib/types/temp-context.d.ts +11 -0
  281. package/lib/types/temp-context.js +27 -0
  282. package/lib/types/temp-context.js.map +1 -0
  283. package/lib/types/toc/toc.d.ts +31 -6
  284. package/lib/types/toc/toc.js +2 -10
  285. package/lib/types/toc/toc.js.map +1 -0
  286. package/lib/types/toc-context.d.ts +12 -0
  287. package/lib/types/toc-context.js +26 -0
  288. package/lib/types/toc-context.js.map +1 -0
  289. package/lib/types/transform-context.d.ts +13 -0
  290. package/lib/types/transform-context.js +30 -0
  291. package/lib/types/transform-context.js.map +1 -0
  292. package/lib/types/utils.d.ts +0 -9
  293. package/lib/types/utils.js +2 -3
  294. package/lib/types/utils.js.map +1 -0
  295. package/lib/types/versioned-build-context.d.ts +15 -0
  296. package/lib/types/versioned-build-context.js +28 -0
  297. package/lib/types/versioned-build-context.js.map +1 -0
  298. package/lib/utils/string-utils.d.ts +3 -0
  299. package/lib/utils/string-utils.js +79 -0
  300. package/lib/utils/string-utils.js.map +1 -0
  301. package/lib/utils/utils.d.ts +2 -44
  302. package/lib/utils/utils.js +14 -366
  303. package/lib/utils/utils.js.map +1 -0
  304. package/package.json +50 -31
  305. package/bin/run +0 -9
  306. package/lib/application/portal/toc/sdl-parser.d.ts +0 -13
  307. package/lib/application/portal/toc/sdl-parser.js +0 -53
  308. package/lib/client-utils/sdk-client.d.ts +0 -23
  309. package/lib/client-utils/sdk-client.js +0 -124
  310. package/lib/commands/portal/quickstart.d.ts +0 -10
  311. package/lib/commands/portal/quickstart.js +0 -79
  312. package/lib/config/env.d.ts +0 -27
  313. package/lib/config/env.js +0 -31
  314. package/lib/controllers/api/transform.d.ts +0 -5
  315. package/lib/controllers/api/transform.js +0 -56
  316. package/lib/controllers/api/validate.d.ts +0 -3
  317. package/lib/controllers/api/validate.js +0 -33
  318. package/lib/controllers/portal/generate.d.ts +0 -3
  319. package/lib/controllers/portal/generate.js +0 -110
  320. package/lib/controllers/portal/quickstart.d.ts +0 -14
  321. package/lib/controllers/portal/quickstart.js +0 -258
  322. package/lib/controllers/portal/serve.d.ts +0 -3
  323. package/lib/controllers/portal/serve.js +0 -138
  324. package/lib/controllers/sdk/generate.d.ts +0 -4
  325. package/lib/controllers/sdk/generate.js +0 -66
  326. package/lib/services/portal/server.d.ts +0 -14
  327. package/lib/services/portal/server.js +0 -101
  328. package/lib/types/api/validate.d.ts +0 -12
  329. package/lib/types/api/validate.js +0 -3
  330. package/lib/types/common/result.d.ts +0 -17
  331. package/lib/types/common/result.js +0 -36
  332. package/lib/types/portal/generate.d.ts +0 -26
  333. package/lib/types/portal/generate.js +0 -4
  334. package/lib/types/portal/quickstart.d.ts +0 -17
  335. package/lib/types/portal/quickstart.js +0 -3
  336. package/lib/validators/common/directoryValidator.d.ts +0 -9
  337. package/lib/validators/common/directoryValidator.js +0 -53
  338. package/lib/validators/common/portValidator.d.ts +0 -5
  339. package/lib/validators/common/portValidator.js +0 -20
  340. package/lib/validators/portal/serveValidator.d.ts +0 -6
  341. package/lib/validators/portal/serveValidator.js +0 -21
@@ -1,58 +1,63 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PortalGenerateAction = void 0;
4
- const path = require("path");
5
- const fs = require("fs-extra");
6
- const portal_service_1 = require("../../infrastructure/services/portal-service");
7
- const result_1 = require("../../types/common/result");
8
- const utils_1 = require("../../utils/utils");
9
- const generate_1 = require("../../prompts/portal/generate");
10
- class PortalGenerateAction {
11
- constructor() {
12
- this.prompts = new generate_1.PortalGeneratePrompts();
13
- }
14
- async generatePortal(paths, flags, configDir) {
15
- var _a;
16
- this.prompts.displayPortalGenerationMessage();
17
- const pathsToIgnore = (0, utils_1.getGeneratedFilesPaths)(paths.sourceFolderPath, paths.generatedPortalArtifactsFolderPath);
18
- //TODO: Refactor this method, carries dual responsibility.
19
- const sourceBuildInputZipFilePath = await (0, utils_1.validateAndZipPortalSource)(paths.sourceFolderPath, path.join(paths.sourceFolderPath, ".portal_source.zip"), pathsToIgnore);
20
- const generatePortalParams = {
21
- sourceBuildInputZipFilePath: sourceBuildInputZipFilePath,
22
- generatedPortalArtifactsFolderPath: paths.generatedPortalArtifactsFolderPath,
23
- generatedPortalArtifactsZipFilePath: paths.generatedPortalArtifactsZipFilePath,
24
- overrideAuthKey: (_a = flags["auth-key"]) !== null && _a !== void 0 ? _a : null,
25
- generateZipFile: flags.zip
26
- };
27
- const docsPortalService = new portal_service_1.PortalService();
28
- const portalGenerationResult = await docsPortalService.generateOnPremPortal(generatePortalParams, configDir);
29
- await (0, utils_1.deleteFile)(sourceBuildInputZipFilePath);
30
- if (portalGenerationResult.isSuccess()) {
31
- await this.saveGeneratedPortalStreamToZipFile(portalGenerationResult.value, paths.generatedPortalArtifactsZipFilePath);
32
- if (flags.zip) {
33
- this.prompts.displayPortalGenerationSuccessMessage();
34
- this.prompts.displayOutroMessage(paths.generatedPortalArtifactsZipFilePath);
35
- return;
1
+ import { PortalGeneratePrompts } from "../../prompts/portal/generate.js";
2
+ import { PortalService } from "../../infrastructure/services/portal-service.js";
3
+ import { ActionResult } from "../action-result.js";
4
+ import { BuildContext } from "../../types/build-context.js";
5
+ import { PortalContext } from "../../types/portal-context.js";
6
+ import { withDirPath } from "../../infrastructure/tmp-extensions.js";
7
+ import { LauncherService } from "../../infrastructure/launcher-service.js";
8
+ import { TempContext } from "../../types/temp-context.js";
9
+ import { ServiceError } from "../../infrastructure/service-error.js";
10
+ export class GenerateAction {
11
+ constructor(configDir, commandMetadata, authKey = null) {
12
+ this.prompts = new PortalGeneratePrompts();
13
+ this.launcherService = new LauncherService();
14
+ this.portalService = new PortalService();
15
+ this.execute = async (buildDirectory, portalDirectory, force, zipPortal, displayMessages = true) => {
16
+ if (buildDirectory.isEqual(portalDirectory)) {
17
+ this.prompts.directoryCannotBeSame(portalDirectory);
18
+ return ActionResult.failed();
36
19
  }
37
- await (0, utils_1.extractZipFile)(paths.generatedPortalArtifactsZipFilePath, paths.generatedPortalArtifactsFolderPath);
38
- await (0, utils_1.deleteFile)(paths.generatedPortalArtifactsZipFilePath);
39
- this.prompts.displayPortalGenerationSuccessMessage();
40
- this.prompts.displayOutroMessage(paths.generatedPortalArtifactsFolderPath);
41
- }
42
- else {
43
- this.prompts.displayPortalGenerationErrorMessage();
44
- this.prompts.logError((0, utils_1.getMessageInRedColor)(`${portalGenerationResult.error}`));
45
- }
46
- }
47
- async saveGeneratedPortalStreamToZipFile(data, generatedPortalArtifactsZipFilePath) {
48
- const writeStream = fs.createWriteStream(generatedPortalArtifactsZipFilePath);
49
- await new Promise((resolve, reject) => {
50
- data
51
- .pipe(writeStream)
52
- .on("finish", () => resolve())
53
- .on("error", (error) => reject(result_1.Result.failure(`Failed to save downloaded portal to file: ${error.message}`)));
54
- });
20
+ const buildContext = new BuildContext(buildDirectory);
21
+ if (!(await buildContext.validate())) {
22
+ this.prompts.srcDirectoryEmpty(buildDirectory);
23
+ return ActionResult.failed();
24
+ }
25
+ const portalContext = new PortalContext(portalDirectory);
26
+ if (!force && (await portalContext.exists()) && !(await this.prompts.overwritePortal(portalDirectory))) {
27
+ this.prompts.portalDirectoryNotEmpty();
28
+ return ActionResult.cancelled();
29
+ }
30
+ return await withDirPath(async (tempDirectory) => {
31
+ const tempContext = new TempContext(tempDirectory);
32
+ const buildZipPath = await tempContext.zip(buildDirectory);
33
+ const response = await this.prompts.generatePortal(this.portalService.generatePortal(buildZipPath, this.configDir, this.commandMetadata, this.authKey));
34
+ if (response.isErr()) {
35
+ const error = response.error;
36
+ if (error instanceof ServiceError) {
37
+ this.prompts.portalGenerationServiceError(error);
38
+ }
39
+ else if (typeof error === "string") {
40
+ this.prompts.portalGenerationError(error);
41
+ }
42
+ else {
43
+ const errorZipPath = await tempContext.save(error);
44
+ const reportPath = await portalContext.saveError(errorZipPath);
45
+ await this.launcherService.openFile(reportPath);
46
+ this.prompts.portalGenerationErrorWithReport(reportPath);
47
+ }
48
+ return ActionResult.failed();
49
+ }
50
+ const tempPortalZipPath = await tempContext.save(response.value);
51
+ await portalContext.save(tempPortalZipPath, zipPortal);
52
+ if (displayMessages) {
53
+ this.prompts.portalGenerated(portalDirectory);
54
+ }
55
+ return ActionResult.success();
56
+ });
57
+ };
58
+ this.configDir = configDir;
59
+ this.commandMetadata = commandMetadata;
60
+ this.authKey = authKey;
55
61
  }
56
62
  }
57
- exports.PortalGenerateAction = PortalGenerateAction;
58
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYWN0aW9ucy9wb3J0YWwvZ2VuZXJhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsNkJBQTZCO0FBQzdCLCtCQUErQjtBQUMvQixpRkFBNkU7QUFFN0Usc0RBQW1EO0FBQ25ELDZDQU0yQjtBQUMzQiw0REFBc0U7QUFFdEUsTUFBYSxvQkFBb0I7SUFHL0I7UUFDRSxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksZ0NBQXFCLEVBQUUsQ0FBQztJQUM3QyxDQUFDO0lBRUQsS0FBSyxDQUFDLGNBQWMsQ0FBQyxLQU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C;CA4DF"}
@@ -0,0 +1,17 @@
1
+ import { DirectoryPath } from '../../types/file/directoryPath.js';
2
+ import { ActionResult } from '../action-result.js';
3
+ import { CommandMetadata } from '../../types/common/command-metadata.js';
4
+ export declare class PortalQuickstartAction {
5
+ private readonly prompts;
6
+ private readonly zipService;
7
+ private readonly fileService;
8
+ private readonly configDir;
9
+ private readonly commandMetadata;
10
+ private readonly fileDownloadService;
11
+ private readonly buildFileUrl;
12
+ private readonly defaultSpecUrl;
13
+ private readonly repositoryFolderName;
14
+ private readonly validationService;
15
+ constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata);
16
+ readonly execute: () => Promise<ActionResult>;
17
+ }
@@ -0,0 +1,169 @@
1
+ import { getAuthInfo } from '../../client-utils/auth-manager.js';
2
+ import { FileService } from '../../infrastructure/file-service.js';
3
+ import { withDirPath } from '../../infrastructure/tmp-extensions.js';
4
+ import { ZipService } from '../../infrastructure/zip-service.js';
5
+ import { PortalQuickstartPrompts } from '../../prompts/portal/quickstart.js';
6
+ import { UrlPath } from '../../types/file/urlPath.js';
7
+ import { LoginAction } from '../auth/login.js';
8
+ import { ActionResult } from '../action-result.js';
9
+ import { PortalServeAction } from './serve.js';
10
+ import { ValidateAction } from '../api/validate.js';
11
+ import { BuildContext } from '../../types/build-context.js';
12
+ import { TempContext } from '../../types/temp-context.js';
13
+ import { FileDownloadService } from '../../infrastructure/services/file-download-service.js';
14
+ import { getLanguagesConfig } from '../../types/build/build.js';
15
+ import { SpecContext } from '../../types/spec-context.js';
16
+ import { ValidationService } from '../../infrastructure/services/validation-service.js';
17
+ import { FileName } from '../../types/file/fileName.js';
18
+ const defaultPort = 3000;
19
+ export class PortalQuickstartAction {
20
+ constructor(configDir, commandMetadata) {
21
+ this.prompts = new PortalQuickstartPrompts();
22
+ this.zipService = new ZipService();
23
+ this.fileService = new FileService();
24
+ this.fileDownloadService = new FileDownloadService();
25
+ this.buildFileUrl = new UrlPath(`https://github.com/apimatic/sample-docs-as-code-portal/archive/refs/heads/master.zip`);
26
+ this.defaultSpecUrl = new UrlPath(`https://raw.githubusercontent.com/apimatic/sample-docs-as-code-portal/refs/heads/master/src/spec/openapi.json`);
27
+ this.repositoryFolderName = 'sample-docs-as-code-portal-master/src';
28
+ this.execute = async () => {
29
+ const storedAuth = await getAuthInfo(this.configDir.toString());
30
+ if (!(storedAuth === null || storedAuth === void 0 ? void 0 : storedAuth.authKey)) {
31
+ const loginResult = await new LoginAction(this.configDir, this.commandMetadata).execute();
32
+ if (loginResult.isFailed()) {
33
+ return ActionResult.failed();
34
+ }
35
+ }
36
+ return await withDirPath(async (tempDirectory) => {
37
+ var _a;
38
+ // Step 1/4
39
+ this.prompts.importSpecStep();
40
+ let specPath;
41
+ while (!specPath) {
42
+ const inputPath = await this.prompts.specPathPrompt(this.defaultSpecUrl);
43
+ if (!inputPath) {
44
+ this.prompts.noSpecSpecified();
45
+ return ActionResult.cancelled();
46
+ }
47
+ if (inputPath instanceof UrlPath) {
48
+ const downloadFileResult = await this.prompts.downloadSpecFile(this.fileDownloadService.downloadFile(inputPath));
49
+ if (downloadFileResult.isErr()) {
50
+ this.prompts.serviceError(downloadFileResult.error);
51
+ }
52
+ else {
53
+ const specContext = new SpecContext(tempDirectory);
54
+ specPath = await specContext.save(downloadFileResult.value.stream, downloadFileResult.value.filename);
55
+ }
56
+ }
57
+ else {
58
+ const fileExists = await this.fileService.fileExists(inputPath);
59
+ if (!fileExists) {
60
+ this.prompts.specFileDoesNotExist();
61
+ }
62
+ else {
63
+ specPath = inputPath;
64
+ }
65
+ }
66
+ }
67
+ // Step 2/4
68
+ this.prompts.validateSpecStep();
69
+ const validateAction = new ValidateAction(this.configDir, this.commandMetadata);
70
+ const validationResult = await validateAction.execute(specPath, false);
71
+ if (validationResult.isFailed()) {
72
+ this.prompts.specValidationFailed();
73
+ if (!(await this.prompts.useDefaultSpecPrompt())) {
74
+ this.prompts.fixYourSpec();
75
+ return ActionResult.cancelled();
76
+ }
77
+ const downloadFileResult = await this.prompts.downloadSpecFile(this.fileDownloadService.downloadFile(this.defaultSpecUrl));
78
+ if (downloadFileResult.isErr()) {
79
+ this.prompts.serviceError(downloadFileResult.error);
80
+ }
81
+ else {
82
+ const specContext = new SpecContext(tempDirectory);
83
+ specPath = await specContext.save(downloadFileResult.value.stream, downloadFileResult.value.filename);
84
+ }
85
+ }
86
+ if (validationResult.isSuccess()) {
87
+ const unallowed = validationResult.getValue();
88
+ if (unallowed && (((_a = unallowed.Features) === null || _a === void 0 ? void 0 : _a.length) > 0 || unallowed.EndpointCount > unallowed.EndpointLimit)) {
89
+ const config = {
90
+ features: unallowed.Features.filter((name) => !!name),
91
+ endpointsToKeep: unallowed.EndpointLimit
92
+ };
93
+ const stripUnallowedFeaturesResult = await this.validationService.stripUnallowedFeatures(specPath, config);
94
+ if (stripUnallowedFeaturesResult.isErr()) {
95
+ this.prompts.splitSpecDetected(unallowed);
96
+ return ActionResult.failed();
97
+ }
98
+ else {
99
+ this.prompts.stripUnallowedFeaturesStep(unallowed);
100
+ const specContext = new SpecContext(tempDirectory);
101
+ specPath = await specContext.save(stripUnallowedFeaturesResult.value, new FileName('pruned-spec.zip'));
102
+ }
103
+ }
104
+ }
105
+ // Step 3/4
106
+ this.prompts.selectLanguagesStep();
107
+ const languages = await this.prompts.selectLanguagesPrompt();
108
+ if (!languages) {
109
+ this.prompts.noLanguagesSelected();
110
+ return ActionResult.cancelled();
111
+ }
112
+ // Step 4/4
113
+ this.prompts.selectInputDirectoryStep();
114
+ let inputDirectory;
115
+ while (true) {
116
+ inputDirectory = await this.prompts.inputDirectoryPathPrompt();
117
+ if (!inputDirectory) {
118
+ this.prompts.noInputDirectoryProvided();
119
+ return ActionResult.cancelled();
120
+ }
121
+ if (!(await this.fileService.directoryExists(inputDirectory))) {
122
+ this.prompts.inputDirectoryPathDoesNotExist(inputDirectory);
123
+ // TODO: Prompt user if he wants to create the directory
124
+ continue;
125
+ }
126
+ if (!(await this.fileService.directoryEmpty(inputDirectory))) {
127
+ this.prompts.inputDirectoryNotEmpty(inputDirectory);
128
+ continue;
129
+ }
130
+ break;
131
+ }
132
+ const masterBuildFile = await this.prompts.downloadBuildDirectory(this.fileDownloadService.downloadFile(this.buildFileUrl));
133
+ if (masterBuildFile.isErr()) {
134
+ this.prompts.serviceError(masterBuildFile.error);
135
+ return ActionResult.failed();
136
+ }
137
+ const tempContext = new TempContext(tempDirectory);
138
+ const masterBuildFilePath = await tempContext.save(masterBuildFile.value.stream);
139
+ await this.zipService.unArchive(masterBuildFilePath, tempDirectory);
140
+ const extractedFolder = tempDirectory.join(this.repositoryFolderName);
141
+ const tempBuildContext = new BuildContext(extractedFolder);
142
+ await tempBuildContext.deleteWorkflowDir();
143
+ const buildFile = await tempBuildContext.getBuildFileContents();
144
+ buildFile.generatePortal.languageConfig = getLanguagesConfig(languages);
145
+ await tempBuildContext.updateBuildFileContents(buildFile);
146
+ const sourceDirectory = inputDirectory.join('src');
147
+ await this.fileService.copyDirectoryContents(extractedFolder, sourceDirectory);
148
+ const specDirectory = sourceDirectory.join('spec');
149
+ const specContext = new SpecContext(specDirectory);
150
+ await specContext.replaceDefaultSpec(specPath);
151
+ const buildDirectoryStructure = await this.fileService.getDirectory(sourceDirectory);
152
+ this.prompts.printDirectoryStructure(inputDirectory, buildDirectoryStructure);
153
+ const portalDirectory = inputDirectory.join('portal');
154
+ const portalServeAction = new PortalServeAction(this.configDir, this.commandMetadata, null);
155
+ const result = await portalServeAction.execute(sourceDirectory, portalDirectory, defaultPort, true, false, () => {
156
+ this.prompts.nextSteps();
157
+ });
158
+ if (result.isFailed()) {
159
+ return ActionResult.failed();
160
+ }
161
+ return ActionResult.success();
162
+ });
163
+ };
164
+ this.configDir = configDir;
165
+ this.commandMetadata = commandMetadata;
166
+ this.validationService = new ValidationService(this.configDir);
167
+ }
168
+ }
169
+ //# sourceMappingURL=quickstart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/actions/portal/quickst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AM,WAAW,GAAG,IAAI,WAAW,CAAC,aAAa,CAAC,CAAC;gBACnD,MAAM,WAAW,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;gBAE/C,MAAM,uBAAuB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;gBACrF,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;gBAE9E,MAAM,eAAe,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACtD,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;gBAC5F,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;oBAC9G,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;gBAC3B,CAAC,CAAC,CAAC;gBAEH,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;oBACtB,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC/B,CAAC;gBAED,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAhKA,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;CA8JF"}
@@ -0,0 +1,15 @@
1
+ import { DirectoryPath } from "../../../types/file/directoryPath.js";
2
+ import { CommandMetadata } from "../../../types/common/command-metadata.js";
3
+ import { ActionResult } from "../../action-result.js";
4
+ export declare class PortalRecipeAction {
5
+ private readonly configDirectory;
6
+ private readonly commandMetadata;
7
+ private readonly prompts;
8
+ private readonly launcherService;
9
+ private readonly fileService;
10
+ private readonly portalService;
11
+ constructor(configDirectory: DirectoryPath, commandMetadata: CommandMetadata);
12
+ execute(buildDirectory: DirectoryPath, name?: string): Promise<ActionResult>;
13
+ private promptForContent;
14
+ private getTocStructure;
15
+ }
@@ -0,0 +1,177 @@
1
+ import { PortalRecipePrompts } from "../../../prompts/portal/recipe/new-recipe.js";
2
+ import { StepType } from "../../../types/recipe/recipe.js";
3
+ import { PortalService } from "../../../infrastructure/services/portal-service.js";
4
+ import { getEndpointDescription, getEndpointGroupsFromSdl } from "../../../types/sdl/sdl.js";
5
+ import { ActionResult } from "../../action-result.js";
6
+ import { TocContext } from "../../../types/toc-context.js";
7
+ import { FileName } from "../../../types/file/fileName.js";
8
+ import { PortalRecipe } from "../../../application/portal/recipe/portal-recipe.js";
9
+ import { PortalRecipeGenerator } from "../../../application/portal/recipe/recipe-generator.js";
10
+ import { BuildContext } from "../../../types/build-context.js";
11
+ import { ContentContext } from "../toc/new-toc.js";
12
+ import { SpecContext } from "../../../types/spec-context.js";
13
+ import { LauncherService } from "../../../infrastructure/launcher-service.js";
14
+ import { FileService } from "../../../infrastructure/file-service.js";
15
+ import { FilePath } from "../../../types/file/filePath.js";
16
+ import { withDirPath } from "../../../infrastructure/tmp-extensions.js";
17
+ import { TempContext } from "../../../types/temp-context.js";
18
+ import { RecipeContext } from "../../../types/recipe-context.js";
19
+ export class PortalRecipeAction {
20
+ constructor(configDirectory, commandMetadata) {
21
+ this.configDirectory = configDirectory;
22
+ this.commandMetadata = commandMetadata;
23
+ this.prompts = new PortalRecipePrompts();
24
+ this.launcherService = new LauncherService();
25
+ this.fileService = new FileService();
26
+ this.portalService = new PortalService();
27
+ }
28
+ async execute(buildDirectory, name) {
29
+ this.prompts.displayWelcomeMessage();
30
+ const buildContext = new BuildContext(buildDirectory);
31
+ if (!(await buildContext.validate())) {
32
+ this.prompts.invalidBuildDirectory(buildDirectory);
33
+ return ActionResult.failed();
34
+ }
35
+ const recipeName = name !== null && name !== void 0 ? name : (await this.prompts.recipeNamePrompt());
36
+ if (!recipeName) {
37
+ this.prompts.recipeNameEmpty();
38
+ return ActionResult.cancelled();
39
+ }
40
+ const contentDirectory = buildDirectory.join("content");
41
+ const contentContext = new ContentContext(contentDirectory);
42
+ if (!(await contentContext.exists())) {
43
+ this.prompts.contentFolderNotFound();
44
+ return ActionResult.failed();
45
+ }
46
+ const specDirectory = buildDirectory.join("spec");
47
+ const specContext = new SpecContext(specDirectory);
48
+ if (!(await specContext.validate())) {
49
+ this.prompts.specFileEmptyInvalid();
50
+ return ActionResult.failed();
51
+ }
52
+ // Setup TOC context
53
+ const tocContext = new TocContext(contentDirectory);
54
+ const tocData = await tocContext.parseTocData();
55
+ // Setup recipe context
56
+ const recipeContext = new RecipeContext(recipeName);
57
+ const recipeScriptFileName = recipeContext.getRecipeScriptFileName();
58
+ const recipeMarkdownFileName = recipeContext.getRecipeMarkdownFileName();
59
+ // Check if the recipe already exists
60
+ const recipeAlreadyExists = recipeContext.exists(tocData, recipeName, recipeMarkdownFileName);
61
+ if (recipeAlreadyExists && !(await this.prompts.overwriteApiRecipeInTocPrompt(recipeName))) {
62
+ return ActionResult.cancelled();
63
+ }
64
+ // Build the recipe
65
+ const recipe = new PortalRecipe(recipeName);
66
+ let stepIndex = 0;
67
+ this.prompts.displayStepsInformation();
68
+ let endpointGroups;
69
+ do {
70
+ const stepType = await this.prompts.stepTypeSelectionPrompt();
71
+ if (!stepType)
72
+ return ActionResult.cancelled();
73
+ const stepName = await this.prompts.stepNamePrompt(`Step ${++stepIndex}`);
74
+ if (!stepName)
75
+ return ActionResult.cancelled();
76
+ switch (stepType) {
77
+ case StepType.Content: {
78
+ const contentResult = await this.promptForContent();
79
+ recipe.addContentStep(stepName, contentResult);
80
+ this.prompts.displayStepAddedSuccessfullyMessage();
81
+ break;
82
+ }
83
+ case StepType.Endpoint: {
84
+ if (!endpointGroups) {
85
+ const sdlResult = await withDirPath(async (tempDirectory) => {
86
+ const tempContext = new TempContext(tempDirectory);
87
+ const specZipPath = await tempContext.zip(specDirectory);
88
+ const specFileStream = await this.fileService.getStream(specZipPath);
89
+ try {
90
+ return await this.prompts.generateSdl(this.portalService.generateSdl(specFileStream, this.configDirectory, this.commandMetadata));
91
+ }
92
+ finally {
93
+ specFileStream.close();
94
+ }
95
+ });
96
+ if (sdlResult.isErr()) {
97
+ this.prompts.serviceError(sdlResult.error);
98
+ return ActionResult.failed();
99
+ }
100
+ endpointGroups = getEndpointGroupsFromSdl(sdlResult.value);
101
+ }
102
+ const endpointGroupName = await this.prompts.endpointGroupNamePrompt(endpointGroups);
103
+ if (!endpointGroupName)
104
+ return ActionResult.cancelled();
105
+ const endpointName = await this.prompts.endpointNamePrompt(endpointGroups, endpointGroupName);
106
+ if (!endpointName)
107
+ return ActionResult.cancelled();
108
+ const defaultDescription = getEndpointDescription(endpointGroups, endpointGroupName, endpointName);
109
+ const description = await this.prompts.endpointDescriptionPrompt(defaultDescription);
110
+ if (!description)
111
+ return ActionResult.cancelled();
112
+ recipe.addEndpointStep(stepName, description, endpointGroupName, endpointName);
113
+ this.prompts.displayStepAddedSuccessfullyMessage();
114
+ break;
115
+ }
116
+ }
117
+ } while (await this.prompts.addAnotherStepSelectionPrompt());
118
+ const serializableRecipe = recipe.toSerializableRecipe();
119
+ // Generate the recipe
120
+ const recipeGenerator = new PortalRecipeGenerator();
121
+ await recipeGenerator.createRecipe(serializableRecipe, tocData, tocContext.tocPath, recipeName, recipeScriptFileName, recipeMarkdownFileName, buildContext, buildDirectory);
122
+ const tocStructure = this.getTocStructure(recipeScriptFileName);
123
+ this.prompts.recipeCreated();
124
+ this.prompts.displayRecipeStructure(tocStructure);
125
+ this.prompts.nextSteps();
126
+ return ActionResult.success();
127
+ }
128
+ async promptForContent() {
129
+ return await withDirPath(async (tempDir) => {
130
+ const tempFile = new FilePath(tempDir, new FileName(`recipe-markdown-content.md`));
131
+ const defaultContent = "# The Heading Goes Here\n\n" +
132
+ "This is placeholder text for your API Recipe content step. " +
133
+ "Feel free to edit this. Save your changes and then close the file once you're done.";
134
+ await this.fileService.writeContents(tempFile, defaultContent);
135
+ this.prompts.openRecipeMarkdownEditor();
136
+ await this.launcherService.openInEditor(tempFile);
137
+ const fileContent = await this.fileService.getContents(tempFile);
138
+ return fileContent.replace(/\r\n|\r/g, "\n");
139
+ });
140
+ }
141
+ getTocStructure(recipeFileName) {
142
+ return {
143
+ name: "src",
144
+ items: [
145
+ {
146
+ name: "content",
147
+ items: [
148
+ {
149
+ name: "toc.yml",
150
+ description: "# Contains the API Recipes group with a new page for your API recipe"
151
+ }
152
+ ]
153
+ },
154
+ {
155
+ name: "static",
156
+ items: [
157
+ {
158
+ name: "scripts",
159
+ items: [
160
+ {
161
+ name: "recipes",
162
+ items: [
163
+ {
164
+ name: `${recipeFileName}`,
165
+ description: "# Generated recipe script file containing all of the steps"
166
+ }
167
+ ]
168
+ }
169
+ ]
170
+ }
171
+ ]
172
+ }
173
+ ]
174
+ };
175
+ }
176
+ }
177
+ //# sourceMappingURL=new-recipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-recipe.js","sourceRoot":"","sources":["../../../../src/actions/portal/recipe/new-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAe,MAAM,2BAA2B,CAAC;AAG1G,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AACnF,OAAO,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AO,CAAC,wBAAwB,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAClD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACjE,OAAO,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,eAAe,CAAC,cAAwB;QAC9C,OAAO;YACL,IAAI,EAAE,KAAK;YACX,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,SAAS;4BACf,WAAW,EAAE,sEAAsE;yBACpF;qBACF;iBACF;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,SAAS;4BACf,KAAK,EAAE;gCACL;oCACE,IAAI,EAAE,SAAS;oCACf,KAAK,EAAE;wCACL;4CACE,IAAI,EAAE,GAAG,cAAc,EAAE;4CACzB,WAAW,EAAE,4DAA4D;yCAC1E;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { ActionResult } from "../action-result.js";
3
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
4
+ export declare class PortalServeAction {
5
+ private readonly prompts;
6
+ private readonly networkService;
7
+ private readonly launcherService;
8
+ private readonly application;
9
+ private readonly configDir;
10
+ private readonly commandMetadata;
11
+ private readonly authKey;
12
+ constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
13
+ execute(buildDirectory: DirectoryPath, portalDirectory: DirectoryPath, port: number, openInBrowser: boolean, hotReload: boolean, onAfterServe?: () => void): Promise<ActionResult>;
14
+ private clearStandardInput;
15
+ }