@apimatic/cli 1.1.0-alpha.2 → 1.1.0-alpha.20

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 (251) hide show
  1. package/README.md +249 -99
  2. package/bin/run.js +5 -0
  3. package/lib/actions/action-result.d.ts +8 -0
  4. package/lib/actions/action-result.js +25 -0
  5. package/lib/actions/action-result.js.map +1 -0
  6. package/lib/actions/auth/login.d.ts +12 -0
  7. package/lib/actions/auth/login.js +63 -0
  8. package/lib/actions/auth/login.js.map +1 -0
  9. package/lib/actions/portal/copilot.d.ts +11 -0
  10. package/lib/actions/portal/copilot.js +49 -0
  11. package/lib/actions/portal/copilot.js.map +1 -0
  12. package/lib/actions/portal/generate.d.ts +13 -0
  13. package/lib/actions/portal/generate.js +61 -0
  14. package/lib/actions/portal/generate.js.map +1 -0
  15. package/lib/actions/portal/recipe/new-recipe.d.ts +24 -0
  16. package/lib/actions/portal/recipe/new-recipe.js +250 -0
  17. package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
  18. package/lib/actions/portal/serve.d.ts +14 -0
  19. package/lib/actions/portal/serve.js +24 -0
  20. package/lib/actions/portal/serve.js.map +1 -0
  21. package/lib/actions/portal/toc/new-toc.d.ts +20 -0
  22. package/lib/actions/portal/toc/new-toc.js +133 -0
  23. package/lib/actions/portal/toc/new-toc.js.map +1 -0
  24. package/lib/actions/sdk/generate.d.ts +14 -0
  25. package/lib/actions/sdk/generate.js +72 -0
  26. package/lib/actions/sdk/generate.js.map +1 -0
  27. package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
  28. package/lib/application/portal/recipe/portal-recipe.js +33 -0
  29. package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
  30. package/lib/application/portal/recipe/recipe-generator.d.ts +16 -0
  31. package/lib/application/portal/recipe/recipe-generator.js +147 -0
  32. package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
  33. package/lib/application/portal/serve/portal-watcher.d.ts +11 -0
  34. package/lib/application/portal/serve/portal-watcher.js +64 -0
  35. package/lib/application/portal/serve/portal-watcher.js.map +1 -0
  36. package/lib/application/portal/serve/serve-handler.d.ts +16 -0
  37. package/lib/application/portal/serve/serve-handler.js +91 -0
  38. package/lib/application/portal/serve/serve-handler.js.map +1 -0
  39. package/lib/application/portal/serve/watcher-handler.d.ts +10 -0
  40. package/lib/application/portal/serve/watcher-handler.js +51 -0
  41. package/lib/application/portal/serve/watcher-handler.js.map +1 -0
  42. package/lib/application/portal/toc/sdl-parser.d.ts +19 -0
  43. package/lib/application/portal/toc/sdl-parser.js +90 -0
  44. package/lib/application/portal/toc/sdl-parser.js.map +1 -0
  45. package/lib/application/portal/toc/toc-content-parser.d.ts +5 -0
  46. package/lib/application/portal/toc/toc-content-parser.js +44 -0
  47. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  48. package/lib/application/portal/toc/toc-structure-generator.d.ts +6 -0
  49. package/lib/application/portal/toc/toc-structure-generator.js +84 -0
  50. package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
  51. package/lib/client-utils/auth-manager.d.ts +8 -3
  52. package/lib/client-utils/auth-manager.js +23 -10
  53. package/lib/client-utils/auth-manager.js.map +1 -0
  54. package/lib/client-utils/sdk-client.d.ts +0 -1
  55. package/lib/client-utils/sdk-client.js +25 -55
  56. package/lib/client-utils/sdk-client.js.map +1 -0
  57. package/lib/commands/api/transform.d.ts +7 -7
  58. package/lib/commands/api/transform.js +43 -51
  59. package/lib/commands/api/transform.js.map +1 -0
  60. package/lib/commands/api/validate.d.ts +4 -4
  61. package/lib/commands/api/validate.js +26 -33
  62. package/lib/commands/api/validate.js.map +1 -0
  63. package/lib/commands/auth/login.d.ts +3 -2
  64. package/lib/commands/auth/login.js +22 -53
  65. package/lib/commands/auth/login.js.map +1 -0
  66. package/lib/commands/auth/logout.d.ts +1 -1
  67. package/lib/commands/auth/logout.js +8 -13
  68. package/lib/commands/auth/logout.js.map +1 -0
  69. package/lib/commands/auth/status.d.ts +1 -1
  70. package/lib/commands/auth/status.js +9 -13
  71. package/lib/commands/auth/status.js.map +1 -0
  72. package/lib/commands/portal/copilot.d.ts +12 -0
  73. package/lib/commands/portal/copilot.js +32 -0
  74. package/lib/commands/portal/copilot.js.map +1 -0
  75. package/lib/commands/portal/generate.d.ts +10 -8
  76. package/lib/commands/portal/generate.js +28 -107
  77. package/lib/commands/portal/generate.js.map +1 -0
  78. package/lib/commands/portal/quickstart.d.ts +10 -0
  79. package/lib/commands/portal/quickstart.js +105 -0
  80. package/lib/commands/portal/quickstart.js.map +1 -0
  81. package/lib/commands/portal/recipe/new.d.ts +10 -0
  82. package/lib/commands/portal/recipe/new.js +38 -0
  83. package/lib/commands/portal/recipe/new.js.map +1 -0
  84. package/lib/commands/portal/serve.d.ts +16 -0
  85. package/lib/commands/portal/serve.js +80 -0
  86. package/lib/commands/portal/serve.js.map +1 -0
  87. package/lib/commands/portal/toc/new.d.ts +14 -0
  88. package/lib/commands/portal/toc/new.js +52 -0
  89. package/lib/commands/portal/toc/new.js.map +1 -0
  90. package/lib/commands/sdk/generate.d.ts +9 -8
  91. package/lib/commands/sdk/generate.js +39 -128
  92. package/lib/commands/sdk/generate.js.map +1 -0
  93. package/lib/config/axios-config.d.ts +2 -0
  94. package/lib/config/axios-config.js +10 -0
  95. package/lib/config/axios-config.js.map +1 -0
  96. package/lib/config/env.d.ts +26 -1
  97. package/lib/config/env.js +27 -4
  98. package/lib/config/env.js.map +1 -0
  99. package/lib/controllers/api/transform.d.ts +1 -1
  100. package/lib/controllers/api/transform.js +23 -22
  101. package/lib/controllers/api/transform.js.map +1 -0
  102. package/lib/controllers/api/validate.d.ts +3 -3
  103. package/lib/controllers/api/validate.js +19 -12
  104. package/lib/controllers/api/validate.js.map +1 -0
  105. package/lib/controllers/portal/quickstart.d.ts +15 -0
  106. package/lib/controllers/portal/quickstart.js +217 -0
  107. package/lib/controllers/portal/quickstart.js.map +1 -0
  108. package/lib/index.d.ts +1 -1
  109. package/lib/index.js +2 -4
  110. package/lib/index.js.map +1 -0
  111. package/lib/infrastructure/api-utils.d.ts +9 -0
  112. package/lib/infrastructure/api-utils.js +33 -0
  113. package/lib/infrastructure/api-utils.js.map +1 -0
  114. package/lib/infrastructure/env-info.d.ts +8 -0
  115. package/lib/infrastructure/env-info.js +37 -0
  116. package/lib/infrastructure/env-info.js.map +1 -0
  117. package/lib/infrastructure/file-service.d.ts +18 -0
  118. package/lib/infrastructure/file-service.js +76 -0
  119. package/lib/infrastructure/file-service.js.map +1 -0
  120. package/lib/infrastructure/services/api-service.d.ts +10 -0
  121. package/lib/infrastructure/services/api-service.js +54 -0
  122. package/lib/infrastructure/services/api-service.js.map +1 -0
  123. package/lib/infrastructure/services/auth-service.d.ts +11 -0
  124. package/lib/infrastructure/services/auth-service.js +33 -0
  125. package/lib/infrastructure/services/auth-service.js.map +1 -0
  126. package/lib/infrastructure/services/portal-service.d.ts +20 -0
  127. package/lib/infrastructure/services/portal-service.js +163 -0
  128. package/lib/infrastructure/services/portal-service.js.map +1 -0
  129. package/lib/infrastructure/services/telemetry-service.d.ts +8 -0
  130. package/lib/infrastructure/services/telemetry-service.js +40 -0
  131. package/lib/infrastructure/services/telemetry-service.js.map +1 -0
  132. package/lib/infrastructure/tmp-extensions.d.ts +2 -0
  133. package/lib/infrastructure/tmp-extensions.js +6 -0
  134. package/lib/infrastructure/tmp-extensions.js.map +1 -0
  135. package/lib/infrastructure/zip-service.d.ts +6 -0
  136. package/lib/infrastructure/zip-service.js +39 -0
  137. package/lib/infrastructure/zip-service.js.map +1 -0
  138. package/lib/prompts/auth/login.d.ts +5 -0
  139. package/lib/prompts/auth/login.js +13 -0
  140. package/lib/prompts/auth/login.js.map +1 -0
  141. package/lib/prompts/portal/common/base-prompts.d.ts +7 -0
  142. package/lib/prompts/portal/common/base-prompts.js +19 -0
  143. package/lib/prompts/portal/common/base-prompts.js.map +1 -0
  144. package/lib/prompts/portal/copilot.d.ts +8 -0
  145. package/lib/prompts/portal/copilot.js +54 -0
  146. package/lib/prompts/portal/copilot.js.map +1 -0
  147. package/lib/prompts/portal/generate.d.ts +11 -0
  148. package/lib/prompts/portal/generate.js +42 -0
  149. package/lib/prompts/portal/generate.js.map +1 -0
  150. package/lib/prompts/portal/quickstart.d.ts +30 -0
  151. package/lib/prompts/portal/quickstart.js +240 -0
  152. package/lib/prompts/portal/quickstart.js.map +1 -0
  153. package/lib/prompts/portal/recipe/new-recipe.d.ts +24 -0
  154. package/lib/prompts/portal/recipe/new-recipe.js +203 -0
  155. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
  156. package/lib/prompts/portal/serve.d.ts +4 -0
  157. package/lib/prompts/portal/serve.js +14 -0
  158. package/lib/prompts/portal/serve.js.map +1 -0
  159. package/lib/prompts/portal/toc/new-toc.d.ts +11 -0
  160. package/lib/prompts/portal/toc/new-toc.js +39 -0
  161. package/lib/prompts/portal/toc/new-toc.js.map +1 -0
  162. package/lib/prompts/sdk/generate.d.ts +11 -0
  163. package/lib/prompts/sdk/generate.js +42 -0
  164. package/lib/prompts/sdk/generate.js.map +1 -0
  165. package/lib/types/api/account.d.ts +10 -0
  166. package/lib/types/api/account.js +2 -0
  167. package/lib/types/api/account.js.map +1 -0
  168. package/lib/types/api/transform.d.ts +19 -4
  169. package/lib/types/api/transform.js +19 -4
  170. package/lib/types/api/transform.js.map +1 -0
  171. package/lib/types/api/validate.d.ts +3 -3
  172. package/lib/types/api/validate.js +2 -2
  173. package/lib/types/api/validate.js.map +1 -0
  174. package/lib/types/build/build.d.ts +14 -0
  175. package/lib/types/build/build.js +4 -0
  176. package/lib/types/build/build.js.map +1 -0
  177. package/lib/types/build-context.d.ts +13 -0
  178. package/lib/types/build-context.js +30 -0
  179. package/lib/types/build-context.js.map +1 -0
  180. package/lib/types/common/result.d.ts +17 -0
  181. package/lib/types/common/result.js +32 -0
  182. package/lib/types/common/result.js.map +1 -0
  183. package/lib/types/events/domain-event.d.ts +8 -0
  184. package/lib/types/events/domain-event.js +11 -0
  185. package/lib/types/events/domain-event.js.map +1 -0
  186. package/lib/types/events/recipe-creation-failed.d.ts +5 -0
  187. package/lib/types/events/recipe-creation-failed.js +8 -0
  188. package/lib/types/events/recipe-creation-failed.js.map +1 -0
  189. package/lib/types/events/toc-creation-failed.d.ts +5 -0
  190. package/lib/types/events/toc-creation-failed.js +8 -0
  191. package/lib/types/events/toc-creation-failed.js.map +1 -0
  192. package/lib/types/file/directoryPath.d.ts +7 -0
  193. package/lib/types/file/directoryPath.js +16 -0
  194. package/lib/types/file/directoryPath.js.map +1 -0
  195. package/lib/types/file/fileName.d.ts +5 -0
  196. package/lib/types/file/fileName.js +9 -0
  197. package/lib/types/file/fileName.js.map +1 -0
  198. package/lib/types/file/filePath.d.ts +8 -0
  199. package/lib/types/file/filePath.js +11 -0
  200. package/lib/types/file/filePath.js.map +1 -0
  201. package/lib/types/flags-provider.d.ts +15 -0
  202. package/lib/types/flags-provider.js +34 -0
  203. package/lib/types/flags-provider.js.map +1 -0
  204. package/lib/types/portal/generate.d.ts +13 -9
  205. package/lib/types/portal/generate.js +3 -2
  206. package/lib/types/portal/generate.js.map +1 -0
  207. package/lib/types/portal/quickstart.d.ts +17 -0
  208. package/lib/types/portal/quickstart.js +2 -0
  209. package/lib/types/portal/quickstart.js.map +1 -0
  210. package/lib/types/portal/serve.d.ts +12 -0
  211. package/lib/types/portal/serve.js +2 -0
  212. package/lib/types/portal/serve.js.map +1 -0
  213. package/lib/types/portal-context.d.ts +11 -0
  214. package/lib/types/portal-context.js +28 -0
  215. package/lib/types/portal-context.js.map +1 -0
  216. package/lib/types/recipe/recipe.d.ts +37 -0
  217. package/lib/types/recipe/recipe.js +6 -0
  218. package/lib/types/recipe/recipe.js.map +1 -0
  219. package/lib/types/sdk/generate.d.ts +11 -10
  220. package/lib/types/sdk/generate.js +11 -12
  221. package/lib/types/sdk/generate.js.map +1 -0
  222. package/lib/types/sdk-context.d.ts +13 -0
  223. package/lib/types/sdk-context.js +28 -0
  224. package/lib/types/sdk-context.js.map +1 -0
  225. package/lib/types/sdl/sdl.d.ts +12 -0
  226. package/lib/types/sdl/sdl.js +2 -0
  227. package/lib/types/sdl/sdl.js.map +1 -0
  228. package/lib/types/spec-context.d.ts +7 -0
  229. package/lib/types/spec-context.js +12 -0
  230. package/lib/types/spec-context.js.map +1 -0
  231. package/lib/types/toc/toc.d.ts +31 -0
  232. package/lib/types/toc/toc.js +9 -0
  233. package/lib/types/toc/toc.js.map +1 -0
  234. package/lib/types/utils.d.ts +3 -3
  235. package/lib/types/utils.js +2 -2
  236. package/lib/types/utils.js.map +1 -0
  237. package/lib/utils/utils.d.ts +16 -7
  238. package/lib/utils/utils.js +142 -86
  239. package/lib/utils/utils.js.map +1 -0
  240. package/lib/validators/common/directoryValidator.d.ts +5 -0
  241. package/lib/validators/common/directoryValidator.js +22 -0
  242. package/lib/validators/common/directoryValidator.js.map +1 -0
  243. package/lib/validators/portal/serve-validator.d.ts +6 -0
  244. package/lib/validators/portal/serve-validator.js +15 -0
  245. package/lib/validators/portal/serve-validator.js.map +1 -0
  246. package/package.json +96 -40
  247. package/bin/run +0 -5
  248. package/lib/controllers/portal/generate.d.ts +0 -2
  249. package/lib/controllers/portal/generate.js +0 -49
  250. package/lib/controllers/sdk/generate.d.ts +0 -4
  251. package/lib/controllers/sdk/generate.js +0 -64
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/commands/api/transform.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAoC,MAAM,eAAe,CAAC;AAG3F,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,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{ flags, Command } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class Validate extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- file: flags.IOptionFlag<string>;
7
- url: flags.IOptionFlag<string>;
8
- "auth-key": flags.IOptionFlag<string | undefined>;
6
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ url: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
9
  };
10
10
  run(): Promise<void>;
11
11
  }
@@ -1,28 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs = require("fs-extra");
4
- const command_1 = require("@oclif/command");
5
- const sdk_1 = require("@apimatic/sdk");
6
- const sdk_client_1 = require("../../client-utils/sdk-client");
7
- const validate_1 = require("../../controllers/api/validate");
8
- const utils_1 = require("../../utils/utils");
9
- class Validate extends command_1.Command {
1
+ import fsExtra from "fs-extra";
2
+ import { ux, Flags, Command } from "@oclif/core";
3
+ import { ApiValidationExternalApisController } from "@apimatic/sdk";
4
+ import { SDKClient } from "../../client-utils/sdk-client.js";
5
+ import { getValidationSummary } from "../../controllers/api/validate.js";
6
+ import { printValidationMessages, replaceHTML } from "../../utils/utils.js";
7
+ import { FlagsProvider } from "../../types/flags-provider.js";
8
+ class Validate extends Command {
10
9
  async run() {
11
- const { flags } = this.parse(Validate);
10
+ const { flags } = await this.parse(Validate);
12
11
  try {
13
- if (flags.file && !(await fs.pathExists(flags.file))) {
12
+ if (flags.file && !(await fsExtra.pathExists(flags.file))) {
14
13
  throw new Error(`Validation file: ${flags.file} does not exist`);
15
14
  }
16
15
  const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
17
- const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
18
- const apiValidationController = new sdk_1.APIValidationExternalApisController(client);
19
- const validationSummary = await validate_1.getValidation(flags, apiValidationController);
16
+ const client = await SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
17
+ const apiValidationController = new ApiValidationExternalApisController(client);
18
+ ux.action.start("Validating specification file");
19
+ const validationSummary = await getValidationSummary(flags, apiValidationController);
20
+ ux.action.stop();
20
21
  const logFunctions = {
21
- log: this.log,
22
- warn: this.warn,
23
- error: this.error
22
+ log: (message) => this.log(message),
23
+ warn: (message) => this.warn(message),
24
+ error: (message) => this.error(message)
24
25
  };
25
- utils_1.printValidationMessages(validationSummary, logFunctions);
26
+ printValidationMessages(validationSummary, logFunctions);
26
27
  validationSummary.success
27
28
  ? this.log("Specification file provided is valid")
28
29
  : this.error("Specification file provided is invalid");
@@ -32,7 +33,7 @@ class Validate extends command_1.Command {
32
33
  const apiError = error;
33
34
  const result = apiError.result;
34
35
  if (result.modelState["exception Error"] && apiError.statusCode === 400) {
35
- this.error(utils_1.replaceHTML(result.modelState["exception Error"][0]));
36
+ this.error(replaceHTML(result.modelState["exception Error"][0]));
36
37
  }
37
38
  else if (error.body && apiError.statusCode === 401) {
38
39
  this.error("You are not authorized to perform this action");
@@ -55,22 +56,14 @@ class Validate extends command_1.Command {
55
56
  }
56
57
  }
57
58
  }
58
- exports.default = Validate;
59
59
  Validate.description = "Validate the syntactic and semantic correctness of an API specification";
60
60
  Validate.examples = [
61
- `$ apimatic api:validate --file="./specs/sample.json"
62
- Specification file provided is valid
63
- `,
64
- `$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json
65
- Specification file provided is valid
66
- `
61
+ `apimatic api:validate --file="./specs/sample.json"`,
62
+ `apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json`
67
63
  ];
68
- Validate.flags = {
69
- file: command_1.flags.string({ default: "", description: "Path to the API specification file to validate" }),
70
- url: command_1.flags.string({
64
+ Validate.flags = Object.assign({ file: Flags.string({ default: "", description: "Path to the API specification file to validate" }), url: Flags.string({
71
65
  default: "",
72
66
  description: "URL to the specification file to validate. Can be used in place of the --file option if the API specification is publicly available."
73
- }),
74
- // docs: flags.boolean({ default: false, description: "Validate specification for docs generation" }), // Next tier, not included in API spec
75
- "auth-key": command_1.flags.string({ description: "override current authentication state with an authentication key" })
76
- };
67
+ }) }, FlagsProvider.authKey);
68
+ export default Validate;
69
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAY,mCAAmC,EAAgC,MAAM,eAAe,CAAC;AAG5G,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,MAAqB,QAAS,SAAQ,OAAO;IAmB3C,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE7C,IAAI,CAAC;YACH,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAC1D,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,CAAC,IAAI,iBAAiB,CAAC,CAAC;YACnE,CAAC;YACD,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACrE,MAAM,MAAM,GAAW,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AC,CAAC,CAAC,CAAC;gBACnE,CAAC;qBAAM,IAAK,KAA4B,CAAC,IAAI,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;oBAC7E,IAAI,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;gBAC9D,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;iBAAM,IAAK,KAA6B,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;gBAC7D,IAAI,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;YAC9D,CAAC;iBAAM,IACJ,KAA6B,CAAC,UAAU,KAAK,GAAG;gBAChD,KAA6B,CAAC,IAAI;gBACnC,OAAQ,KAA6B,CAAC,IAAI,KAAK,QAAQ,EACvD,CAAC;gBACD,IAAI,CAAC,KAAK,CAAE,KAA6B,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,GAAI,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;;AApEM,oBAAW,GAAG,yEAAyE,CAAC;AAExF,iBAAQ,GAAG;IAChB,oDAAoD;IACpD,yEAAyE;CAC1E,CAAC;AAEK,cAAK,mBACV,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC,EAClG,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC;QAChB,OAAO,EAAE,EAAE;QACX,WAAW,EACT,sIAAsI;KACzI,CAAC,IAEC,aAAa,CAAC,OAAO,EACxB;eAjBiB,QAAQ"}
@@ -1,9 +1,10 @@
1
- import { flags, Command } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class Login extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- "auth-key": flags.IOptionFlag<string>;
6
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
7
  };
8
+ private readonly prompts;
8
9
  run(): Promise<void>;
9
10
  }
@@ -1,60 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_ux_1 = require("cli-ux");
4
- const command_1 = require("@oclif/command");
5
- const utils_1 = require("../../utils/utils");
6
- const sdk_client_1 = require("../../client-utils/sdk-client");
7
- class Login extends command_1.Command {
1
+ import { Command, Flags } from "@oclif/core";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { LoginPrompts } from "../../prompts/auth/login.js";
4
+ import { LoginAction } from "../../actions/auth/login.js";
5
+ class Login extends Command {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.prompts = new LoginPrompts();
9
+ }
8
10
  async run() {
9
- const { flags } = this.parse(Login);
10
- const configDir = this.config.configDir;
11
- try {
12
- const client = sdk_client_1.SDKClient.getInstance();
13
- // If user is setting auth key
14
- if (flags["auth-key"]) {
15
- const response = client.setAuthKey(flags["auth-key"], configDir);
16
- return this.log(response);
17
- }
18
- else {
19
- // If user logs in with email and password
20
- const email = await cli_ux_1.cli.prompt("Please enter your registered email");
21
- const password = await cli_ux_1.cli.prompt("Please enter your password", {
22
- type: "hide"
23
- });
24
- const response = await client.login(email, password, configDir);
25
- this.log(response);
26
- }
27
- }
28
- catch (error) {
29
- if (error && error.response) {
30
- const apiError = error;
31
- const apiResponse = apiError.response;
32
- if (apiResponse) {
33
- const responseData = apiResponse.data;
34
- if (apiResponse.status === 403 && responseData) {
35
- return this.error(utils_1.replaceHTML(responseData));
36
- }
37
- else {
38
- return this.error(apiError.message);
39
- }
40
- }
41
- }
42
- this.error(error.message);
11
+ const { flags: { "auth-key": authKey } } = await this.parse(Login);
12
+ if (authKey === "") {
13
+ this.error("Flag --auth-key must not be empty when provided.");
43
14
  }
15
+ const loginAction = new LoginAction(new DirectoryPath(this.config.configDir));
16
+ const result = await loginAction.execute(authKey);
17
+ result.match((email) => this.prompts.loginSuccessful(email), (error) => this.prompts.logError(error));
44
18
  }
45
19
  }
46
- exports.default = Login;
47
20
  Login.description = "Login using your APIMatic credentials or an API Key";
48
- Login.examples = [
49
- `$ apimatic auth:login
50
- Please enter your registered email: apimatic-user@gmail.com
51
- Please enter your password: *********
52
-
53
- You have successfully logged into APIMatic
54
- `,
55
- `$ apimatic auth:login --auth-key=xxxxxx
56
- Authentication key successfully set`
57
- ];
21
+ Login.examples = [`apimatic auth:login`, `apimatic auth:login --auth-key={api-key}`];
58
22
  Login.flags = {
59
- "auth-key": command_1.flags.string({ default: "", description: "Set authentication key for all commands" })
23
+ "auth-key": Flags.string({
24
+ char: "k",
25
+ description: "Sets authentication key for all commands.",
26
+ })
60
27
  };
28
+ export default Login;
29
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAqB,KAAM,SAAQ,OAAO;IAA1C;;QAYmB,YAAO,GAAG,IAAI,YAAY,EAAE,CAAC;IAkBhD,CAAC;IAhBC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAC/B,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE5B,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAC9E,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,CAAC,KAAK,CACV,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAC9C,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CACxC,CAAC;IACJ,CAAC;;AA5BM,iBAAW,GAAG,qDAAqD,AAAxD,CAAyD;AAEpE,cAAQ,GAAG,CAAC,qBAAqB,EAAE,0CAA0C,CAAC,AAAtE,CAAuE;AAE/E,WAAK,GAAG;IACb,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,2CAA2C;KACzD,CAAC;CACH,AALW,CAKV;eAViB,KAAK"}
@@ -1,4 +1,4 @@
1
- import { Command } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class Login extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
@@ -1,11 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const sdk_client_1 = require("../../client-utils/sdk-client");
5
- class Login extends command_1.Command {
1
+ import { Command } from "@oclif/core";
2
+ import { SDKClient } from "../../client-utils/sdk-client.js";
3
+ class Login extends Command {
6
4
  async run() {
7
5
  try {
8
- const client = sdk_client_1.SDKClient.getInstance();
6
+ const client = SDKClient.getInstance();
9
7
  const response = await client.logout(this.config.configDir);
10
8
  this.log(response);
11
9
  }
@@ -14,10 +12,7 @@ class Login extends command_1.Command {
14
12
  }
15
13
  }
16
14
  }
17
- exports.default = Login;
18
- Login.description = "Clear local login credentials";
19
- Login.examples = [
20
- `$ apimatic auth:logout
21
- Logged out
22
- `
23
- ];
15
+ Login.description = "Clears the local login credentials.";
16
+ Login.examples = [`apimatic auth:logout`];
17
+ export default Login;
18
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,KAAM,SAAQ,OAAO;IAKxC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAbM,iBAAW,GAAG,qCAAqC,CAAC;AAEpD,cAAQ,GAAG,CAAC,sBAAsB,CAAC,CAAC;eAHxB,KAAK"}
@@ -1,4 +1,4 @@
1
- import { Command } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class Status extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
@@ -1,11 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const sdk_client_1 = require("../../client-utils/sdk-client");
5
- class Status extends command_1.Command {
1
+ import { Command } from "@oclif/core";
2
+ import { SDKClient } from "../../client-utils/sdk-client.js";
3
+ class Status extends Command {
6
4
  async run() {
7
5
  try {
8
- const client = sdk_client_1.SDKClient.getInstance();
6
+ const client = SDKClient.getInstance();
7
+ // TODO: Add validation for auth key from the server.
9
8
  const response = await client.status(this.config.configDir);
10
9
  this.log(response);
11
10
  }
@@ -14,10 +13,7 @@ class Status extends command_1.Command {
14
13
  }
15
14
  }
16
15
  }
17
- exports.default = Status;
18
- Status.description = "View current authentication state";
19
- Status.examples = [
20
- `$ apimatic auth:status
21
- Currently logged in as apimatic-client@gmail.com
22
- `
23
- ];
16
+ Status.description = "View the currently logged in user.";
17
+ Status.examples = [`apimatic auth:status`];
18
+ export default Status;
19
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,MAAO,SAAQ,OAAO;IAKzC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,qDAAqD;YACrD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAdM,kBAAW,GAAG,oCAAoC,CAAC;AAEnD,eAAQ,GAAG,CAAC,sBAAsB,CAAC,CAAC;eAHxB,MAAM"}
@@ -0,0 +1,12 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalCopilotEnable extends Command {
3
+ static summary: string;
4
+ static description: string;
5
+ static flags: {
6
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ disable: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ };
9
+ static examples: string[];
10
+ private readonly prompts;
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,32 @@
1
+ import { Command, Flags } from "@oclif/core";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { PortalCopilotPrompts } from "../../prompts/portal/copilot.js";
4
+ import { FlagsProvider } from "../../types/flags-provider.js";
5
+ import { CopilotAction } from "../../actions/portal/copilot.js";
6
+ const DEFAULT_WORKING_DIRECTORY = "./";
7
+ class PortalCopilotEnable extends Command {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.prompts = new PortalCopilotPrompts();
11
+ }
12
+ async run() {
13
+ const { flags: { input, "auth-key": authKey, disable } } = await this.parse(PortalCopilotEnable);
14
+ const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
15
+ const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
16
+ const copilotConfigAction = new CopilotAction(new DirectoryPath(this.config.configDir), authKey);
17
+ const result = await copilotConfigAction.execute(buildDirectory, !disable);
18
+ result.map((message) => this.prompts.logError(message));
19
+ }
20
+ }
21
+ PortalCopilotEnable.summary = "Configure API Copilot for your API Documentation portal";
22
+ PortalCopilotEnable.description = "Displays available API Copilots associated with your account and allows you to select which one to integrate with your portal. Each APIMatic account includes one Copilot by default. The selected Copilot will be added to your APIMATIC-BUILD.json file";
23
+ PortalCopilotEnable.flags = Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), { disable: Flags.boolean({
24
+ default: false,
25
+ description: "marks the API Copilot as disabled in the configuration"
26
+ }) }), FlagsProvider.authKey);
27
+ PortalCopilotEnable.examples = [
28
+ `apimatic portal:copilot --input="./"`,
29
+ `apimatic portal:copilot --input="./" --disable`,
30
+ ];
31
+ export default PortalCopilotEnable;
32
+ //# sourceMappingURL=copilot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../src/commands/portal/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KA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AAA9P,CAA+P;AAE1Q,yBAAK,iDACP,aAAa,CAAC,KAAK,KACtB,OAAO,EAAG,KAAK,CAAC,OAAO,CAAC;QACtB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,wDAAwD;KACtE,CAAC,KACC,aAAa,CAAC,OAAO,CANd,CAOV;AAEK,4BAAQ,GAAG;IAChB,sCAAsC;IACtC,gDAAgD;CACjD,AAHc,CAGb;eAlBiB,mBAAmB"}
@@ -1,13 +1,15 @@
1
- import { Command, flags } from "@oclif/command";
2
- export default class PortalGenerate extends Command {
1
+ import { Command, Config } from "@oclif/core";
2
+ export declare class PortalGenerate extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- folder: flags.IOptionFlag<string>;
6
- destination: flags.IOptionFlag<string>;
7
- force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
- zip: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
- "auth-key": flags.IOptionFlag<string>;
5
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
9
  };
11
10
  static examples: string[];
12
- run(): Promise<undefined>;
11
+ private readonly prompts;
12
+ constructor(argv: string[], config: Config);
13
+ run(): Promise<void>;
14
+ private getConfigDir;
13
15
  }
@@ -1,110 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path = require("path");
4
- const fs = require("fs-extra");
5
- const command_1 = require("@oclif/command");
6
- const sdk_1 = require("@apimatic/sdk");
7
- const sdk_client_1 = require("../../client-utils/sdk-client");
8
- const generate_1 = require("../../controllers/portal/generate");
9
- const utils_1 = require("../../utils/utils");
10
- class PortalGenerate extends command_1.Command {
1
+ import { Command, Flags } from "@oclif/core";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { GenerateAction } from "../../actions/portal/generate.js";
4
+ import { PortalGeneratePrompts } from "../../prompts/portal/generate.js";
5
+ import { FlagsProvider } from "../../types/flags-provider.js";
6
+ const DEFAULT_WORKING_DIRECTORY = "./";
7
+ export class PortalGenerate extends Command {
8
+ constructor(argv, config) {
9
+ super(argv, config);
10
+ this.getConfigDir = () => {
11
+ return new DirectoryPath(this.config.configDir);
12
+ };
13
+ this.prompts = new PortalGeneratePrompts();
14
+ }
11
15
  async run() {
12
- const { flags } = this.parse(PortalGenerate);
13
- const zip = flags.zip;
14
- const sourceFolderPath = flags.folder;
15
- const portalFolderPath = path.join(flags.destination, "generated_portal");
16
- const zippedPortalPath = path.join(flags.destination, "generated_portal.zip");
17
- const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
18
- // Check if at destination, portal already exists and throw error if force flag is not set for both zip and extracted
19
- if (fs.existsSync(portalFolderPath) && !flags.force && !zip) {
20
- throw new Error(`Can't download portal to path ${portalFolderPath}, because it already exists`);
21
- }
22
- else if (fs.existsSync(zippedPortalPath) && !flags.force && zip) {
23
- throw new Error(`Can't download portal to path ${zippedPortalPath}, because it already exists`);
24
- }
25
- try {
26
- if (!(await fs.pathExists(flags.destination))) {
27
- throw new Error(`Destination path ${flags.destination} does not exist`);
28
- }
29
- else if (!(await fs.pathExists(flags.folder))) {
30
- throw new Error(`Portal build folder ${flags.folder} does not exist`);
31
- }
32
- const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
33
- const docsPortalController = new sdk_1.DocsPortalManagementController(client);
34
- const zippedBuildFilePath = await utils_1.zipDirectory(sourceFolderPath, flags.destination);
35
- const generatePortalParams = {
36
- zippedBuildFilePath,
37
- portalFolderPath,
38
- zippedPortalPath,
39
- docsPortalController,
40
- overrideAuthKey,
41
- zip
42
- };
43
- const generatedPortalPath = await generate_1.downloadDocsPortal(generatePortalParams, this.config.configDir);
44
- this.log(`Your portal has been generated at ${generatedPortalPath}`);
45
- }
46
- catch (error) {
47
- if (error && error.response) {
48
- const apiError = error;
49
- const apiResponse = apiError.response;
50
- if (apiResponse) {
51
- const responseData = apiResponse.data.toString();
52
- if (apiResponse.status === 422 && responseData.length > 0 && utils_1.isJSONParsable(responseData)) {
53
- const nestedErrors = JSON.parse(responseData);
54
- if (nestedErrors.error) {
55
- return this.error(utils_1.replaceHTML(nestedErrors.error));
56
- }
57
- else if (nestedErrors.message) {
58
- return this.error(utils_1.replaceHTML(nestedErrors.message));
59
- }
60
- }
61
- else if (apiResponse.status === 401 && responseData.length > 0) {
62
- this.error("You are not authorized to perform this action");
63
- }
64
- else if (apiResponse.status === 403 && apiResponse.statusText) {
65
- return this.error("Your subscription does not allow on premise portal generation");
66
- }
67
- else {
68
- return this.error(apiError.message);
69
- }
70
- }
71
- }
72
- else if (error.statusCode === 401) {
73
- this.error("You are not authorized to perform this action");
74
- }
75
- else if (error.statusCode === 402 &&
76
- error.body &&
77
- typeof error.body === "string") {
78
- this.error(error.body);
79
- }
80
- else {
81
- this.error(`${error.message}`);
82
- }
83
- }
16
+ const { flags: { input, destination, force, zip: zipPortal, "auth-key": authKey } } = await this.parse(PortalGenerate);
17
+ const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
18
+ const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
19
+ const portalDirectory = destination ? new DirectoryPath(destination) : workingDirectory.join("portal");
20
+ const action = new GenerateAction(this.getConfigDir(), authKey);
21
+ const result = await action.execute(buildDirectory, portalDirectory, force, zipPortal);
22
+ result.mapAll(() => this.prompts.displayOutroMessage(portalDirectory.toString()), (message) => this.prompts.logError(message));
84
23
  }
85
24
  }
86
- exports.default = PortalGenerate;
87
- PortalGenerate.description = "Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://portal-api-docs.apimatic.io/#/http/generating-api-portal/build-file)";
88
- PortalGenerate.flags = {
89
- folder: command_1.flags.string({
90
- parse: (input) => path.resolve(input),
91
- default: "./",
92
- description: "path to the input directory containing API specifications and config files"
93
- }),
94
- destination: command_1.flags.string({
95
- parse: (input) => path.resolve(input),
96
- default: path.resolve("./"),
97
- description: "path to the downloaded portal"
98
- }),
99
- force: command_1.flags.boolean({ char: "f", default: false, description: "overwrite if a portal exists in the destination" }),
100
- zip: command_1.flags.boolean({ default: false, description: "download the generated portal as a .zip archive" }),
101
- "auth-key": command_1.flags.string({
102
- default: "",
103
- description: "override current authentication state with an authentication key"
104
- })
105
- };
106
- PortalGenerate.examples = [
107
- `$ apimatic portal:generate --folder="./portal/" --destination="D:/"
108
- Your portal has been generated at D:/
109
- `
110
- ];
25
+ PortalGenerate.description = "Generate an API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)";
26
+ PortalGenerate.flags = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), FlagsProvider.destination("portal", "portal")), FlagsProvider.force), { zip: Flags.boolean({
27
+ default: false,
28
+ description: "download the generated portal as a .zip archive"
29
+ }) }), FlagsProvider.authKey);
30
+ PortalGenerate.examples = [`apimatic portal:generate`, `apimatic portal:generate --input="./" --destination="./portal"`];
31
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/portal/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;A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,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,EAClE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAC5C,CAAC;IACJ,CAAC;;AAtCM,0BAAW,GAChB,mSAAmS,AADnR,CACoR;AAE/R,oBAAK,6EACP,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAC7C,aAAa,CAAC,KAAK,KACtB,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;QACjB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,iDAAiD;KAC/D,CAAC,KACC,aAAa,CAAC,OAAO,CARd,CASV;AAEK,uBAAQ,GAAG,CAAC,0BAA0B,EAAE,gEAAgE,CAAC,AAAjG,CAAkG"}
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalQuickstart extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ private getSpecFile;
6
+ private getSpecValidationSummary;
7
+ private getWorkingDirectory;
8
+ run(): Promise<void>;
9
+ private getServerPort;
10
+ }