@apimatic/cli 1.0.2-alpha.2 → 1.1.0-alpha.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 (156) hide show
  1. package/README.md +220 -72
  2. package/bin/run.js +5 -0
  3. package/lib/actions/portal/generate.d.ts +7 -0
  4. package/lib/actions/portal/generate.js +54 -0
  5. package/lib/actions/portal/generate.js.map +1 -0
  6. package/lib/actions/portal/recipe/new-recipe.d.ts +24 -0
  7. package/lib/actions/portal/recipe/new-recipe.js +258 -0
  8. package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
  9. package/lib/actions/portal/toc/new-toc.d.ts +17 -0
  10. package/lib/actions/portal/toc/new-toc.js +130 -0
  11. package/lib/actions/portal/toc/new-toc.js.map +1 -0
  12. package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
  13. package/lib/application/portal/recipe/portal-recipe.js +33 -0
  14. package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
  15. package/lib/application/portal/recipe/recipe-generator.d.ts +16 -0
  16. package/lib/application/portal/recipe/recipe-generator.js +147 -0
  17. package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
  18. package/lib/application/portal/toc/sdl-parser.d.ts +16 -0
  19. package/lib/application/portal/toc/sdl-parser.js +74 -0
  20. package/lib/application/portal/toc/sdl-parser.js.map +1 -0
  21. package/lib/application/portal/toc/toc-content-parser.d.ts +5 -0
  22. package/lib/application/portal/toc/toc-content-parser.js +44 -0
  23. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  24. package/lib/application/portal/toc/toc-structure-generator.d.ts +6 -0
  25. package/lib/application/portal/toc/toc-structure-generator.js +84 -0
  26. package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
  27. package/lib/client-utils/auth-manager.d.ts +1 -1
  28. package/lib/client-utils/auth-manager.js +9 -13
  29. package/lib/client-utils/auth-manager.js.map +1 -0
  30. package/lib/client-utils/sdk-client.js +24 -23
  31. package/lib/client-utils/sdk-client.js.map +1 -0
  32. package/lib/commands/api/transform.d.ts +7 -7
  33. package/lib/commands/api/transform.js +44 -40
  34. package/lib/commands/api/transform.js.map +1 -0
  35. package/lib/commands/api/validate.d.ts +4 -4
  36. package/lib/commands/api/validate.js +33 -24
  37. package/lib/commands/api/validate.js.map +1 -0
  38. package/lib/commands/auth/login.d.ts +2 -2
  39. package/lib/commands/auth/login.js +33 -18
  40. package/lib/commands/auth/login.js.map +1 -0
  41. package/lib/commands/auth/logout.d.ts +1 -1
  42. package/lib/commands/auth/logout.js +6 -7
  43. package/lib/commands/auth/logout.js.map +1 -0
  44. package/lib/commands/auth/status.d.ts +1 -1
  45. package/lib/commands/auth/status.js +6 -7
  46. package/lib/commands/auth/status.js.map +1 -0
  47. package/lib/commands/portal/generate.d.ts +12 -7
  48. package/lib/commands/portal/generate.js +73 -79
  49. package/lib/commands/portal/generate.js.map +1 -0
  50. package/lib/commands/portal/quickstart.d.ts +10 -0
  51. package/lib/commands/portal/quickstart.js +77 -0
  52. package/lib/commands/portal/quickstart.js.map +1 -0
  53. package/lib/commands/portal/recipe/new.d.ts +12 -0
  54. package/lib/commands/portal/recipe/new.js +44 -0
  55. package/lib/commands/portal/recipe/new.js.map +1 -0
  56. package/lib/commands/portal/serve.d.ts +16 -0
  57. package/lib/commands/portal/serve.js +135 -0
  58. package/lib/commands/portal/serve.js.map +1 -0
  59. package/lib/commands/portal/toc/new.d.ts +15 -0
  60. package/lib/commands/portal/toc/new.js +63 -0
  61. package/lib/commands/portal/toc/new.js.map +1 -0
  62. package/lib/commands/sdk/generate.d.ts +8 -8
  63. package/lib/commands/sdk/generate.js +48 -41
  64. package/lib/commands/sdk/generate.js.map +1 -0
  65. package/lib/config/axios-config.d.ts +2 -0
  66. package/lib/config/axios-config.js +10 -0
  67. package/lib/config/axios-config.js.map +1 -0
  68. package/lib/config/env.d.ts +27 -1
  69. package/lib/config/env.js +28 -4
  70. package/lib/config/env.js.map +1 -0
  71. package/lib/controllers/api/transform.d.ts +1 -1
  72. package/lib/controllers/api/transform.js +23 -22
  73. package/lib/controllers/api/transform.js.map +1 -0
  74. package/lib/controllers/api/validate.d.ts +3 -3
  75. package/lib/controllers/api/validate.js +19 -12
  76. package/lib/controllers/api/validate.js.map +1 -0
  77. package/lib/controllers/portal/generate.d.ts +3 -2
  78. package/lib/controllers/portal/generate.js +105 -48
  79. package/lib/controllers/portal/generate.js.map +1 -0
  80. package/lib/controllers/portal/quickstart.d.ts +14 -0
  81. package/lib/controllers/portal/quickstart.js +253 -0
  82. package/lib/controllers/portal/quickstart.js.map +1 -0
  83. package/lib/controllers/portal/serve.d.ts +3 -0
  84. package/lib/controllers/portal/serve.js +133 -0
  85. package/lib/controllers/portal/serve.js.map +1 -0
  86. package/lib/controllers/sdk/generate.d.ts +4 -4
  87. package/lib/controllers/sdk/generate.js +23 -26
  88. package/lib/controllers/sdk/generate.js.map +1 -0
  89. package/lib/index.d.ts +1 -1
  90. package/lib/index.js +2 -4
  91. package/lib/index.js.map +1 -0
  92. package/lib/infrastructure/services/portal-service.d.ts +16 -0
  93. package/lib/infrastructure/services/portal-service.js +129 -0
  94. package/lib/infrastructure/services/portal-service.js.map +1 -0
  95. package/lib/prompts/portal/generate.d.ts +10 -0
  96. package/lib/prompts/portal/generate.js +57 -0
  97. package/lib/prompts/portal/generate.js.map +1 -0
  98. package/lib/prompts/portal/quickstart.d.ts +31 -0
  99. package/lib/prompts/portal/quickstart.js +212 -0
  100. package/lib/prompts/portal/quickstart.js.map +1 -0
  101. package/lib/prompts/portal/recipe/new-recipe.d.ts +23 -0
  102. package/lib/prompts/portal/recipe/new-recipe.js +193 -0
  103. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
  104. package/lib/prompts/portal/serve.d.ts +7 -0
  105. package/lib/prompts/portal/serve.js +21 -0
  106. package/lib/prompts/portal/serve.js.map +1 -0
  107. package/lib/prompts/portal/toc/new-toc.d.ts +10 -0
  108. package/lib/prompts/portal/toc/new-toc.js +42 -0
  109. package/lib/prompts/portal/toc/new-toc.js.map +1 -0
  110. package/lib/services/portal/server.d.ts +14 -0
  111. package/lib/services/portal/server.js +97 -0
  112. package/lib/services/portal/server.js.map +1 -0
  113. package/lib/types/api/transform.d.ts +19 -8
  114. package/lib/types/api/transform.js +19 -4
  115. package/lib/types/api/transform.js.map +1 -0
  116. package/lib/types/api/validate.d.ts +3 -3
  117. package/lib/types/api/validate.js +2 -2
  118. package/lib/types/api/validate.js.map +1 -0
  119. package/lib/types/common/result.d.ts +17 -0
  120. package/lib/types/common/result.js +32 -0
  121. package/lib/types/common/result.js.map +1 -0
  122. package/lib/types/portal/generate.d.ts +26 -9
  123. package/lib/types/portal/generate.js +3 -2
  124. package/lib/types/portal/generate.js.map +1 -0
  125. package/lib/types/portal/quickstart.d.ts +17 -0
  126. package/lib/types/portal/quickstart.js +2 -0
  127. package/lib/types/portal/quickstart.js.map +1 -0
  128. package/lib/types/recipe/recipe.d.ts +37 -0
  129. package/lib/types/recipe/recipe.js +6 -0
  130. package/lib/types/recipe/recipe.js.map +1 -0
  131. package/lib/types/sdk/generate.d.ts +6 -5
  132. package/lib/types/sdk/generate.js +5 -6
  133. package/lib/types/sdk/generate.js.map +1 -0
  134. package/lib/types/sdl/sdl.d.ts +12 -0
  135. package/lib/types/sdl/sdl.js +2 -0
  136. package/lib/types/sdl/sdl.js.map +1 -0
  137. package/lib/types/toc/toc.d.ts +31 -0
  138. package/lib/types/toc/toc.js +9 -0
  139. package/lib/types/toc/toc.js.map +1 -0
  140. package/lib/types/utils.d.ts +6 -2
  141. package/lib/types/utils.js +2 -2
  142. package/lib/types/utils.js.map +1 -0
  143. package/lib/utils/utils.d.ts +31 -5
  144. package/lib/utils/utils.js +316 -74
  145. package/lib/utils/utils.js.map +1 -0
  146. package/lib/validators/common/directoryValidator.d.ts +9 -0
  147. package/lib/validators/common/directoryValidator.js +49 -0
  148. package/lib/validators/common/directoryValidator.js.map +1 -0
  149. package/lib/validators/common/portValidator.d.ts +5 -0
  150. package/lib/validators/common/portValidator.js +16 -0
  151. package/lib/validators/common/portValidator.js.map +1 -0
  152. package/lib/validators/portal/serveValidator.d.ts +6 -0
  153. package/lib/validators/portal/serveValidator.js +17 -0
  154. package/lib/validators/portal/serveValidator.js.map +1 -0
  155. package/package.json +86 -38
  156. package/bin/run +0 -5
@@ -0,0 +1,212 @@
1
+ import fs from "fs";
2
+ import * as path from "path";
3
+ import treeify from "treeify";
4
+ import { intro, outro, text, spinner, select, multiselect, log, isCancel, cancel, password } from "@clack/prompts";
5
+ import { getMessageInCyanColor, getMessageInGreenColor, getMessageInOrangeColor, getMessageInMagentaColor, getMessageInRedColor, isValidUrl, directoryToJson } from "../../utils/utils.js";
6
+ export class PortalQuickstartPrompts {
7
+ constructor() {
8
+ this.spin = spinner();
9
+ this.vscodeExtensionUrl = "\u001b[4mhttps://marketplace.visualstudio.com/items?itemName=apimatic-developers.apimatic-for-vscode\u001b[0m";
10
+ this.serverUrl = "\u001b[4mhttp://localhost:3000\u001b[0m";
11
+ this.referenceDocumentationUrl = "\u001b[4mhttps://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal\u001b[0m";
12
+ this.customizeTheSdksUrl = "\u001b[4mhttps://docs.apimatic.io/generate-sdks/codegen-settings/codegen-settings-overview\u001b[0m";
13
+ this.defaultPortalDirectoryPath = process.cwd();
14
+ }
15
+ displayWelcomeMessage() {
16
+ intro(`Hello there 👋`);
17
+ log.message(`This wizard will help you set up an API Portal via APIMatic's Docs as Code workflow in 4 simple steps.`);
18
+ log.message(`Let's get started! 🚀`);
19
+ }
20
+ async loginPrompt() {
21
+ log.message(`Please log in to continue.`);
22
+ const email = await text({
23
+ message: "Enter your registered email:",
24
+ validate: (input) => {
25
+ if (!input) {
26
+ return getMessageInRedColor("Email is required.");
27
+ }
28
+ const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
29
+ if (!emailRegex.test(input)) {
30
+ return getMessageInRedColor("Please enter a valid email address.");
31
+ }
32
+ }
33
+ });
34
+ if (isCancel(email)) {
35
+ cancel("Operation cancelled.");
36
+ return process.exit(0);
37
+ }
38
+ const pass = await password({
39
+ message: "Enter your password:",
40
+ validate: (input) => {
41
+ if (!input) {
42
+ return getMessageInRedColor("Password is required.");
43
+ }
44
+ }
45
+ });
46
+ if (isCancel(pass)) {
47
+ cancel("Operation cancelled.");
48
+ return process.exit(0);
49
+ }
50
+ return { email: String(email).trim(), password: String(pass).trim() };
51
+ }
52
+ displayLoggingInMessage() {
53
+ this.spin.start(getMessageInMagentaColor("Logging in"));
54
+ }
55
+ displayLoggingInErrorMessage() {
56
+ this.spin.stop(getMessageInRedColor(`There was a problem logging in. Please verify your credentials and try again.`));
57
+ }
58
+ displayLoggedInMessage() {
59
+ this.spin.stop(getMessageInCyanColor("✅ Login successful!"));
60
+ }
61
+ async specPrompt() {
62
+ log.step(getMessageInOrangeColor(`Step 1 of 4: Import your OpenAPI Definition`));
63
+ const spec = await text({
64
+ message: `Provide a local path or a public URL for your OpenAPI Definition file:`,
65
+ placeholder: "Press Enter to use a sample OpenAPI file for APIMatic",
66
+ defaultValue: "",
67
+ validate: (input) => {
68
+ if (!input)
69
+ return;
70
+ if (isValidUrl(input))
71
+ return;
72
+ const dirPath = path.resolve((input !== null && input !== void 0 ? input : "").trim());
73
+ if (fs.existsSync(dirPath)) {
74
+ if (fs.statSync(dirPath).isFile()) {
75
+ return;
76
+ }
77
+ return getMessageInRedColor("Error: The specified path does not point to a valid API Definition file or a zip archive containing API definition files. Please try again.");
78
+ }
79
+ return getMessageInRedColor("Error: The specified file does not exist. Please enter a valid file path.");
80
+ }
81
+ });
82
+ if (isCancel(spec)) {
83
+ cancel("Operation cancelled.");
84
+ return process.exit(0);
85
+ }
86
+ return String(spec).trim();
87
+ }
88
+ displaySpecValidationMessage() {
89
+ log.step(getMessageInOrangeColor(`Step 2 of 4: Validate and Lint your OpenAPI file`));
90
+ this.spin.start(getMessageInMagentaColor(`Running your API Definition through APIMatic's 1200+ CodeGen Specific validation and linting rules 🔍 `));
91
+ }
92
+ displaySpecValidationSuccessMessage() {
93
+ this.spin.stop(getMessageInCyanColor(`✅ Validation Successful.`));
94
+ }
95
+ displaySpecValidationErrorMessage() {
96
+ this.spin.stop(getMessageInRedColor(`Something went wrong while validating your spec.`));
97
+ }
98
+ displaySpecValidationFailureMessage() {
99
+ this.spin.stop(getMessageInRedColor(`❗ Oops, it looks like there are some errors in your API Definition.`));
100
+ }
101
+ async specValidationFailurePrompt() {
102
+ const useSampleSpec = await select({
103
+ message: `How would you like to proceed?`,
104
+ options: [
105
+ {
106
+ value: "exit",
107
+ label: `1. Fix the issues using APIMatic's interactive VS Code Extension: ${this.vscodeExtensionUrl}`
108
+ },
109
+ { value: "continue", label: `2. Use an example API spec instead (recommended)` }
110
+ ]
111
+ });
112
+ if (isCancel(useSampleSpec)) {
113
+ cancel("Operation cancelled.");
114
+ return process.exit(0);
115
+ }
116
+ if (useSampleSpec === "exit") {
117
+ outro(getMessageInCyanColor("Good luck fixing your API definition! 🛠️ Feel free to run this command again once you're done."));
118
+ return process.exit(0);
119
+ }
120
+ }
121
+ async sdkLanguagesPrompt() {
122
+ log.step(getMessageInOrangeColor(`Step 3 of 4: Select programming languages`));
123
+ const languages = (await multiselect({
124
+ message: "💻 Your API Portal will contain SDKs and SDK Documentation in the following Languages. Press enter to continue with all languages, or use the arrow keys and spacebar to customize your selection:",
125
+ options: [
126
+ { label: "HTTP", value: "http" },
127
+ { label: "Typescript", value: "typescript" },
128
+ { label: "Ruby", value: "ruby" },
129
+ { label: "Python", value: "python" },
130
+ { label: "Java", value: "java" },
131
+ { label: "C#", value: "csharp" },
132
+ { label: "PHP", value: "php" },
133
+ { label: "Go", value: "go" }
134
+ ],
135
+ initialValues: ["http", "typescript", "ruby", "python", "java", "csharp", "php", "go"]
136
+ }));
137
+ if (isCancel(languages)) {
138
+ cancel("Operation cancelled.");
139
+ return process.exit(0);
140
+ }
141
+ return languages;
142
+ }
143
+ async buildDirectoryPrompt() {
144
+ log.step(getMessageInOrangeColor(`Step 4 of 4: Generate source files for Docs as Code`));
145
+ const directory = await text({
146
+ message: "Enter the directory path where you would like to setup the API Portal :",
147
+ placeholder: "Enter absolute path to the directory or leave it empty to use the current directory.",
148
+ defaultValue: "./",
149
+ validate: (input) => {
150
+ const dirPath = path.resolve((input !== null && input !== void 0 ? input : "").trim());
151
+ if (!fs.existsSync(dirPath) && dirPath != this.defaultPortalDirectoryPath) {
152
+ return getMessageInRedColor("Error: The specified directory path does not exist. Please try again.");
153
+ }
154
+ if (dirPath !== this.defaultPortalDirectoryPath) {
155
+ const files = fs.readdirSync(dirPath).filter((item) => !item.startsWith("."));
156
+ if (files.length > 0) {
157
+ return getMessageInRedColor("Error: The target directory is not empty. Please provide a path to an empty directory or clear its contents.");
158
+ }
159
+ }
160
+ else if (fs.existsSync(dirPath) && fs.readdirSync(dirPath).length > 0) {
161
+ return getMessageInRedColor("Error: The target directory is not empty. Please provide a path to an empty directory or clear its contents.");
162
+ }
163
+ }
164
+ });
165
+ if (isCancel(directory)) {
166
+ cancel("Operation cancelled.");
167
+ return process.exit(0);
168
+ }
169
+ if (directory === "./") {
170
+ return this.defaultPortalDirectoryPath;
171
+ }
172
+ else {
173
+ return String(directory).trim();
174
+ }
175
+ }
176
+ displayBuildDirectoryGenerationMessage() {
177
+ this.spin.start(getMessageInMagentaColor("Generating build directory... ⚙️"));
178
+ }
179
+ displayBuildDirectoryGenerationErrorMessage() {
180
+ this.spin.stop(getMessageInRedColor(`Something went wrong while setting up your build directory.`));
181
+ }
182
+ displayBuildDirectoryGenerationSuccessMessage(targetFolder) {
183
+ this.spin.stop(getMessageInCyanColor(`📁 Directory created at ${targetFolder}`));
184
+ }
185
+ displayBuildDirectoryAsTree(targetFolder) {
186
+ const buildDirectory = directoryToJson(targetFolder);
187
+ const tree = treeify.asTree(buildDirectory, true, true);
188
+ const coloredLogString = tree
189
+ .split("\n")
190
+ .map((line) => line.replace(/#.*/, (match) => getMessageInGreenColor(match)))
191
+ .join("\n");
192
+ log.info(coloredLogString);
193
+ }
194
+ displayPortalGenerationMessage() {
195
+ this.spin.start(getMessageInMagentaColor("Setting up portal"));
196
+ }
197
+ displayPortalGenerationSuccessMessage() {
198
+ this.spin.stop(getMessageInCyanColor("✅ Portal setup complete!"));
199
+ }
200
+ displayOutroMessage(directory) {
201
+ log.step(getMessageInCyanColor(`📢 Your API Portal is live at: ${this.serverUrl}\n`) +
202
+ getMessageInCyanColor(`Hot reload enabled! Edit files in ${directory} to see changes instantly reflected in your API Portal.\n`) +
203
+ getMessageInCyanColor(`Press CTRL+C to stop the server.`));
204
+ outro(getMessageInCyanColor(`What's next?\n`) +
205
+ getMessageInCyanColor(`- Check out the Interactive Playground in your API Portal.\n`) +
206
+ getMessageInCyanColor(`- Read the reference documentation to learn more about how you can customize this API Portal: ${this.referenceDocumentationUrl}`) +
207
+ getMessageInCyanColor(` \n`) +
208
+ getMessageInCyanColor(`- Review the SDK Documentation for your favourite programming language and download an SDK from the API Portal.\n`) +
209
+ getMessageInCyanColor(`- Check out how you can customize the SDKs using Code Generation settings: ${this.customizeTheSdksUrl}`));
210
+ }
211
+ }
212
+ //# sourceMappingURL=quickstart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/prompts/portal/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ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I,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;aAC5E,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC7B,CAAC;IAED,8BAA8B;QAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,qCAAqC;QACnC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,2BAA2B,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,mBAAmB,CAAC,SAAiB;QACnC,GAAG,CAAC,IAAI,CACN,qBAAqB,CAAC,mCAAmC,IAAI,CAAC,SAAS,IAAI,CAAC;YAC1E,qBAAqB,CACnB,qCAAqC,SAAS,2DAA2D,CAC1G;YACD,qBAAqB,CAAC,kCAAkC,CAAC,CAC5D,CAAC;QACF,KAAK,CACH,qBAAqB,CAAC,gBAAgB,CAAC;YACrC,qBAAqB,CAAC,8DAA8D,CAAC;YACrF,qBAAqB,CACnB,iGAAiG,IAAI,CAAC,yBAAyB,EAAE,CAClI;YACD,qBAAqB,CAAC,KAAK,CAAC;YAC5B,qBAAqB,CACnB,mHAAmH,CACpH;YACD,qBAAqB,CACnB,8EAA8E,IAAI,CAAC,mBAAmB,EAAE,CACzG,CACJ,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import treeify from "treeify";
2
+ import { SdlEndpoint } from "../../../types/sdl/sdl.js";
3
+ export declare class PortalRecipePrompts {
4
+ private readonly spin;
5
+ displayWelcomeMessage(): void;
6
+ recipeNamePrompt(): Promise<string>;
7
+ buildConfigFilePathPrompt(buildDirectoryPath: string): Promise<string>;
8
+ stepNamePrompt(defaultStepName: string): Promise<string>;
9
+ displayStepsInformation(): void;
10
+ stepTypeSelectionPrompt(): Promise<string>;
11
+ displayContentStepInfo(): void;
12
+ endpointGroupNamePrompt(endpointGroups: Map<string, SdlEndpoint[]>): Promise<string>;
13
+ endpointNamePrompt(endpointGroups: Map<string, SdlEndpoint[]>, endpointGroupName: string): Promise<string>;
14
+ endpointDescriptionPrompt(endpointGroups: Map<string, SdlEndpoint[]>, endpointGroupName: string, endpointName: string): Promise<string>;
15
+ addAnotherStepSelectionPrompt(): Promise<boolean>;
16
+ overwriteApiRecipeInTocPrompt(): Promise<boolean>;
17
+ displayStepAddedSuccessfullyMessage(): void;
18
+ displayRecipeGenerationSuccessMessage(buildDirectoryPath: string): void;
19
+ startProgressIndicatorWithMessage(message: string): void;
20
+ stopProgressIndicatorWithMessage(message: string): void;
21
+ displayBuildDirectoryStructureAsTree(buildDirectoryTreeObject: treeify.TreeObject): void;
22
+ logError(error: string): void;
23
+ }
@@ -0,0 +1,193 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import treeify from "treeify";
4
+ import { intro, spinner, select, text, cancel, isCancel, outro, log, autocomplete } from "@clack/prompts";
5
+ import { getMessageInGreenColor } from "../../../utils/utils.js";
6
+ export class PortalRecipePrompts {
7
+ constructor() {
8
+ this.spin = spinner();
9
+ }
10
+ displayWelcomeMessage() {
11
+ intro(`Welcome to the API Recipe Generation Wizard. 🪄`);
12
+ log.step(`This wizard will guide you through the process of creating an API Recipe.`);
13
+ log.message(`An API Recipe is a collection of steps that allows you to define a single use case for your API Documentation portal.`);
14
+ log.message(`ℹ️ Learn more: https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes`);
15
+ log.message(`Let's get started! 🚀`);
16
+ }
17
+ async recipeNamePrompt() {
18
+ const recipeName = await text({
19
+ message: `📘 Enter a name for your API Recipe:`,
20
+ placeholder: "There will be a tab in the navbar of your API Documentation portal of this name.",
21
+ validate: (name) => {
22
+ if (!name) {
23
+ return "Recipe name cannot be empty. Please provide a name for your API Recipe.";
24
+ }
25
+ }
26
+ });
27
+ if (isCancel(recipeName)) {
28
+ cancel("Operation cancelled.");
29
+ return process.exit(0);
30
+ }
31
+ return recipeName.trim();
32
+ }
33
+ async buildConfigFilePathPrompt(buildDirectoryPath) {
34
+ const buildConfigFilePath = await text({
35
+ message: `⚠️ APIMATIC-BUILD.json is required and was not found in "${buildDirectoryPath}".\nPlease enter the path to your build config file (relative to this directory):`,
36
+ validate: (filePath) => {
37
+ if (!filePath) {
38
+ return "Build config file path cannot be empty. Please provide a valid file path.";
39
+ }
40
+ if (!filePath.endsWith(".json")) {
41
+ return "The content file must be a JSON (.json) file. Please provide a valid file path.";
42
+ }
43
+ const resolvedPath = path.resolve(buildDirectoryPath, filePath);
44
+ if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {
45
+ return;
46
+ }
47
+ return "The specified path is either not a valid relative file path or it doesn't exist. Please provide a valid relative file path.";
48
+ }
49
+ });
50
+ if (isCancel(buildConfigFilePath)) {
51
+ cancel("Operation cancelled.");
52
+ return process.exit(0);
53
+ }
54
+ return path.resolve(buildDirectoryPath, buildConfigFilePath.trim());
55
+ }
56
+ async stepNamePrompt(defaultStepName) {
57
+ const stepName = await text({
58
+ message: `Enter a name for the step:`,
59
+ defaultValue: defaultStepName,
60
+ placeholder: `Press enter to use the default, i.e. ${defaultStepName}`
61
+ });
62
+ if (isCancel(stepName)) {
63
+ cancel("Operation cancelled.");
64
+ return process.exit(0);
65
+ }
66
+ return stepName.trim();
67
+ }
68
+ displayStepsInformation() {
69
+ log.step(`🔧 Add Steps to your Recipe:`);
70
+ log.message(`You can add:`);
71
+ log.message(`1. 📄 Content Step: Display custom content, such as instructions or information related to your API.`);
72
+ log.message(`2. 🔗 Endpoint Step: Display an API endpoint, its playground and other relevant details.`);
73
+ log.message(`💡 Steps appear in the order you add them.`);
74
+ log.message(`📝 Let's proceed to adding steps to your API Recipe. `);
75
+ }
76
+ async stepTypeSelectionPrompt() {
77
+ const stepType = await select({
78
+ message: `➕ Select the type of step you want to add:`,
79
+ options: [
80
+ { value: "content", label: "Content Step", hint: "For displaying custom content" },
81
+ { value: "endpoint", label: "Endpoint Step", hint: "For displaying an API endpoint with its details" }
82
+ ]
83
+ });
84
+ if (isCancel(stepType)) {
85
+ cancel("Operation cancelled.");
86
+ return process.exit(0);
87
+ }
88
+ return stepType;
89
+ }
90
+ displayContentStepInfo() {
91
+ log.step("📝 Opening markdown editor for you to add content in...");
92
+ }
93
+ async endpointGroupNamePrompt(endpointGroups) {
94
+ const groupNames = Array.from(endpointGroups.keys()).map((name) => ({
95
+ value: name,
96
+ label: name
97
+ }));
98
+ const endpointGroupName = await autocomplete({
99
+ message: `Select the endpoint group name:`,
100
+ maxItems: 10,
101
+ options: groupNames
102
+ });
103
+ if (isCancel(endpointGroupName)) {
104
+ cancel("Operation cancelled.");
105
+ return process.exit(0);
106
+ }
107
+ return endpointGroupName.trim();
108
+ }
109
+ async endpointNamePrompt(endpointGroups, endpointGroupName) {
110
+ const endpoints = endpointGroups.get(endpointGroupName);
111
+ const endpointName = await autocomplete({
112
+ message: `Select the name of the endpoint:`,
113
+ maxItems: 10,
114
+ options: endpoints.map((endpoint) => ({
115
+ value: endpoint.Name,
116
+ label: endpoint.Name
117
+ }))
118
+ });
119
+ if (isCancel(endpointName)) {
120
+ cancel("Operation cancelled.");
121
+ return process.exit(0);
122
+ }
123
+ return endpointName.trim();
124
+ }
125
+ async endpointDescriptionPrompt(endpointGroups, endpointGroupName, endpointName) {
126
+ const defaultDescription = endpointGroups.get(endpointGroupName).find((e) => e.Name === endpointName).Description;
127
+ const endpointDescription = await text({
128
+ message: `Enter a description for the endpoint:`,
129
+ placeholder: `Optional. Leave this empty to use the endpoint description defined in the API Specification`,
130
+ defaultValue: defaultDescription
131
+ });
132
+ if (isCancel(endpointDescription)) {
133
+ cancel("Operation cancelled.");
134
+ return process.exit(0);
135
+ }
136
+ return endpointDescription.trim();
137
+ }
138
+ async addAnotherStepSelectionPrompt() {
139
+ const addAnotherStep = await select({
140
+ message: `Do you want to add another step?`,
141
+ options: [
142
+ { value: "yes", label: "Yes" },
143
+ { value: "no", label: "No" }
144
+ ]
145
+ });
146
+ if (isCancel(addAnotherStep)) {
147
+ cancel("Operation cancelled.");
148
+ return process.exit(0);
149
+ }
150
+ return addAnotherStep === "yes";
151
+ }
152
+ async overwriteApiRecipeInTocPrompt() {
153
+ const overwriteApiRecipeInToc = await select({
154
+ message: `⚠️ A recipe with this name already exists. Do you want to overwrite it?`,
155
+ options: [
156
+ { value: "yes", label: "Yes" },
157
+ { value: "no", label: "No" }
158
+ ]
159
+ });
160
+ if (isCancel(overwriteApiRecipeInToc)) {
161
+ cancel("Operation cancelled.");
162
+ return process.exit(0);
163
+ }
164
+ return overwriteApiRecipeInToc === "yes";
165
+ }
166
+ displayStepAddedSuccessfullyMessage() {
167
+ log.step(`✅ Step has been added successfully.`);
168
+ }
169
+ displayRecipeGenerationSuccessMessage(buildDirectoryPath) {
170
+ log.step(`🎉 Recipe has been added successfully!`);
171
+ log.message(`📦 Generated recipe has been added to build directory at: ${buildDirectoryPath}`);
172
+ outro(`▶ Run the command 'apimatic portal:serve' to preview your documentation portal.`);
173
+ }
174
+ startProgressIndicatorWithMessage(message) {
175
+ this.spin.start(message);
176
+ }
177
+ stopProgressIndicatorWithMessage(message) {
178
+ this.spin.stop(message);
179
+ }
180
+ displayBuildDirectoryStructureAsTree(buildDirectoryTreeObject) {
181
+ const tree = treeify.asTree(buildDirectoryTreeObject, true, true);
182
+ const coloredLogString = tree
183
+ .split("\n")
184
+ .map((line) => line.replace(/#.*/, (match) => getMessageInGreenColor(match)))
185
+ .join("\n");
186
+ log.step(`🛠️ You can edit the following files to customize your API Recipe :\n\n` + coloredLogString);
187
+ log.message(`💡 Modify the TOC file to change the position of the API Recipes section in the navbar.`);
188
+ }
189
+ logError(error) {
190
+ outro(error);
191
+ }
192
+ }
193
+ //# sourceMappingURL=new-recipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-recipe.js","sourceRoot":"","sources":["../../../../src/prompts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C,CAAC;IAEM,mCAAmC;QACxC,GAAG,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACnD,CAAC;IAEM,qCAAqC,CAAC,kBAA0B;QACrE,GAAG,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,6DAA6D,kBAAkB,EAAE,CAAC,CAAC;QAC/F,KAAK,CACH,iFAAiF,CAClF,CAAC;IACJ,CAAC;IAEM,iCAAiC,CAAC,OAAe;QACtD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAEM,gCAAgC,CAAC,OAAe;QACrD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAEM,oCAAoC,CAAC,wBAA4C;QACtF,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,wBAAwB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAElE,MAAM,gBAAgB,GAAG,IAAI;aAC1B,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;aAC5F,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,GAAG,CAAC,IAAI,CAAC,0EAA0E,GAAG,gBAAgB,CAAC,CAAC;QACxG,GAAG,CAAC,OAAO,CAAC,yFAAyF,CAAC,CAAC;IACzG,CAAC;IAEM,QAAQ,CAAC,KAAa;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export declare class PortalServePrompts {
2
+ private readonly spin;
3
+ displayGeneratingPortalMessage(): void;
4
+ displayGeneratingPortalErrorMessage(): void;
5
+ displayGeneratedPortalMessage(portalDir: string): void;
6
+ displayOutroMessage(port: number): void;
7
+ }
@@ -0,0 +1,21 @@
1
+ import { log, outro, spinner } from "@clack/prompts";
2
+ import { getMessageInRedColor } from "../../utils/utils.js";
3
+ export class PortalServePrompts {
4
+ constructor() {
5
+ this.spin = spinner();
6
+ }
7
+ displayGeneratingPortalMessage() {
8
+ this.spin.start(`Generating portal`);
9
+ }
10
+ displayGeneratingPortalErrorMessage() {
11
+ this.spin.stop(getMessageInRedColor(`There was an error while generating the portal.`));
12
+ }
13
+ displayGeneratedPortalMessage(portalDir) {
14
+ this.spin.stop(`Portal generated successfully at ${portalDir}`);
15
+ }
16
+ displayOutroMessage(port) {
17
+ log.message(`Server started at http://localhost:${port}`);
18
+ outro(`Press CTRL+C to stop the server.`);
19
+ }
20
+ }
21
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/prompts/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,OAAO,kBAAkB;IAA/B;QACmB,SAAI,GAAG,OAAO,EAAE,CAAC;IAkBpC,CAAC;IAhBC,8BAA8B;QAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAED,mCAAmC;QACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,iDAAiD,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,6BAA6B,CAAC,SAAiB;QAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oCAAoC,SAAS,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,mBAAmB,CAAC,IAAY;QAC9B,GAAG,CAAC,OAAO,CAAC,sCAAsC,IAAI,EAAE,CAAC,CAAC;QAC1D,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC5C,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ export declare class PortalNewTocPrompts {
2
+ private readonly spin;
3
+ overwriteExistingTocPrompt(): Promise<boolean>;
4
+ startProgressIndicatorWithMessage(message: string): void;
5
+ stopProgressIndicatorWithMessage(message: string): void;
6
+ displayOutroMessage(tocPath: string): void;
7
+ logError(error: string): void;
8
+ displayWarning(message: string): void;
9
+ displayInfo(message: string): void;
10
+ }
@@ -0,0 +1,42 @@
1
+ import { cancel, outro, select, spinner, isCancel, log } from "@clack/prompts";
2
+ export class PortalNewTocPrompts {
3
+ constructor() {
4
+ this.spin = spinner();
5
+ }
6
+ async overwriteExistingTocPrompt() {
7
+ const useExistingFile = await select({
8
+ message: `A toc file already exists at the specified destination path, do you want to overwrite it?`,
9
+ options: [
10
+ { value: "yes", label: "Yes" },
11
+ { value: "no", label: "No" }
12
+ ]
13
+ });
14
+ if (isCancel(useExistingFile)) {
15
+ cancel("Operation cancelled.");
16
+ return process.exit(1);
17
+ }
18
+ if (useExistingFile === "no") {
19
+ outro("Please enter a different destination path or delete the existing toc file and try again.");
20
+ }
21
+ return useExistingFile === "yes";
22
+ }
23
+ startProgressIndicatorWithMessage(message) {
24
+ this.spin.start(message);
25
+ }
26
+ stopProgressIndicatorWithMessage(message) {
27
+ this.spin.stop(message);
28
+ }
29
+ displayOutroMessage(tocPath) {
30
+ outro(`✅ TOC file successfully created at: ${tocPath}`);
31
+ }
32
+ logError(error) {
33
+ outro(error);
34
+ }
35
+ displayWarning(message) {
36
+ log.warning(message);
37
+ }
38
+ displayInfo(message) {
39
+ log.step(message);
40
+ }
41
+ }
42
+ //# sourceMappingURL=new-toc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-toc.js","sourceRoot":"","sources":["../../../../src/prompts/portal/toc/new-toc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,gBAA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portal/quickstart.js";
2
+ export declare class PortalServerService {
3
+ private server;
4
+ private liveReloadServer;
5
+ private readonly app;
6
+ private readonly port;
7
+ private readonly liveReloadPort;
8
+ constructor();
9
+ private findAvailablePort;
10
+ private createLiveReloadServer;
11
+ setupServer(generatedPortalPath: string): Promise<void>;
12
+ startServer(config: PortalServerConfig, noReload?: boolean, displayShutdownMessages?: boolean): Promise<boolean>;
13
+ stopServer(): Promise<void>;
14
+ }