Skip to content

Commit 4589a6e

Browse files
authored
fix: resolve multiple visual issues and minor fixes (#136)
1 parent 93e6850 commit 4589a6e

22 files changed

Lines changed: 146 additions & 120 deletions

File tree

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $ npm install -g @apimatic/cli
2424
$ apimatic COMMAND
2525
running command...
2626
$ apimatic (--version)
27-
@apimatic/cli/1.1.0-alpha.14 win32-x64 node-v20.18.3
27+
@apimatic/cli/1.1.0-alpha.16 win32-x64 node-v20.18.3
2828
$ apimatic --help [COMMAND]
2929
USAGE
3030
$ apimatic COMMAND
@@ -236,7 +236,7 @@ _See code: [src/commands/portal/copilot.ts](https://github.com/apimatic/apimatic
236236

237237
## `apimatic portal:generate`
238238

239-
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://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)
239+
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)
240240

241241
```
242242
USAGE
@@ -251,9 +251,9 @@ FLAGS
251251
--zip download the generated portal as a .zip archive
252252
253253
DESCRIPTION
254-
Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a
255-
config file and optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platfo
256-
rm-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)
254+
Generate an API Documentation portal. Requires an input directory containing API specifications, a config file and
255+
optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platform-api/#/http/gu
256+
ides/generating-on-prem-api-portal/build-file-reference)
257257
258258
EXAMPLES
259259
$ apimatic portal:generate
@@ -282,7 +282,7 @@ _See code: [src/commands/portal/quickstart.ts](https://github.com/apimatic/apima
282282

283283
## `apimatic portal:recipe:new`
284284

285-
Generate an API Recipe for a static API Documentation portal.
285+
Add an API Recipe to your API Documentation portal.
286286

287287
```
288288
USAGE
@@ -294,7 +294,7 @@ FLAGS
294294
--name=<value> name for the recipe
295295
296296
DESCRIPTION
297-
Generate an API Recipe for a static API Documentation portal.
297+
Add an API Recipe to your API Documentation portal.
298298
299299
To learn more about API Recipes, visit:
300300
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes
@@ -339,7 +339,7 @@ _See code: [src/commands/portal/serve.ts](https://github.com/apimatic/apimatic-c
339339

340340
## `apimatic portal:toc:new`
341341

342-
Generates a TOC file based on the content directory and spec folder provided in your working directory
342+
Generate a Table of Contents (TOC) file for your API documentation portal
343343

344344
```
345345
USAGE
@@ -356,7 +356,7 @@ FLAGS
356356
specification in the working directory.
357357
358358
DESCRIPTION
359-
Generates a TOC file based on the content directory and spec folder provided in your working directory
359+
Generate a Table of Contents (TOC) file for your API documentation portal
360360
361361
This command generates a new Table of Contents (TOC) file used in the
362362
generation of your API documentation portal.
@@ -378,15 +378,15 @@ _See code: [src/commands/portal/toc/new.ts](https://github.com/apimatic/apimatic
378378

379379
## `apimatic sdk:generate`
380380

381-
Generates SDK for your API
381+
Generate an SDK for your API
382382

383383
```
384384
USAGE
385385
$ apimatic sdk:generate --platform csharp|java|php|python|ruby|typescript|go [--spec <value>] [-d <value>] [-f]
386386
[--zip] [-k <value>]
387387
388388
FLAGS
389-
-d, --destination=<value> [default: <input>/sdk] path where the sdk will be generated.
389+
-d, --destination=<value> [default: ./sdk/<platform>] path where the sdk will be generated.
390390
-f, --force overwrite changes without asking for user consent.
391391
-k, --auth-key=<value> override current authentication state with an authentication key.
392392
--platform=<option> (required) language platform for sdk
@@ -395,7 +395,7 @@ FLAGS
395395
--zip download the generated SDK as a .zip archive
396396
397397
DESCRIPTION
398-
Generates SDK for your API
398+
Generate an SDK for your API
399399
400400
EXAMPLES
401401
$ apimatic sdk:generate --platform="java"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@apimatic/cli",
33
"description": "The official CLI for APIMatic.",
4-
"version": "1.1.0-alpha.15",
4+
"version": "1.1.0-alpha.16",
55
"author": "APIMatic",
66
"bin": {
77
"apimatic": "./bin/run.js"
@@ -137,6 +137,9 @@
137137
},
138138
"sdk": {
139139
"description": "Generate SDKs for your APIs in multiple languages."
140+
},
141+
"portal:toc": {
142+
"description": "Generate a Table of Contents (TOC) file for your API documentation portal"
140143
}
141144
},
142145
"state": "Alpha"

src/actions/portal/copilot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class CopilotAction {
2929
return ActionResult.error("Exiting without making any change.");
3030

3131
const response = await this.apiService.getAccountInfo(this.configDir, this.authKey);
32-
if (!response.isErr()) {
32+
if (response.isErr()) {
3333
return ActionResult.error(response._unsafeUnwrapErr());
3434
}
3535
const apiCopilotKey = await this.selectCopilotKey(response._unsafeUnwrap());

src/actions/portal/recipe/new-recipe.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ export class PortalRecipeAction {
161161
this.prompts.displayContentStepInfo();
162162
let editor = process.env.EDITOR;
163163
let editorArgs: string[] = [];
164-
const tempFilePath = path.join(tmpdir(), `recipe-markdown-content-${Date.now()}.md`);
164+
const tempFilePath = path.join(tmpdir(), `recipe-markdown-content-${Date.now()}.txt`);
165165
const template = `# The Heading Goes Here\n\nThis is placeholder text for your API Recipe content step. Feel free to edit this. Save your changes and then close the file once you're done.`;
166-
await fsExtra.writeFile(tempFilePath, template);
166+
await fsExtra.writeFile(tempFilePath, template, 'utf-8');
167167

168168
try {
169169
if (!editor) {
@@ -313,7 +313,7 @@ export class PortalRecipeAction {
313313
}
314314

315315
this.prompts.stopProgressIndicatorWithMessage(
316-
"Successfully extracted endpoint groups and endpoints from the API specification."
316+
"Successfully extracted endpoint groups and endpoints from the API specification."
317317
);
318318
return Result.success(endpointGroupsResult.value!);
319319
}

src/actions/portal/toc/new-toc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class PortalNewTocAction {
6767
return Result.success(tocPath.toString());
6868
} catch (error) {
6969
this.prompts.logError(getMessageInRedColor(`${(error as Error).message}`));
70-
return Result.failure(`An unexpected error occurred while generating the TOC file.`);
70+
return Result.failure(`An unexpected error occurred while generating the TOC file.`);
7171
}
7272
}
7373

@@ -112,7 +112,7 @@ export class PortalNewTocAction {
112112
}
113113

114114
this.prompts.stopProgressIndicatorWithMessage(
115-
"Successfully extracted endpoints and/or models from the specification."
115+
"Successfully extracted endpoints and/or models from the specification."
116116
);
117117
return sdlResult.value!;
118118
}

src/actions/sdk/generate.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { SdkContext } from "../../types/sdk-context.js";
1010
import { Platforms } from "@apimatic/sdk";
1111
import { SpecContext } from "../../types/spec-context.js";
1212
import { SdkGeneratePrompts } from "../../prompts/sdk/generate.js";
13-
13+
import { LanguagePlatform } from "../../types/sdk/generate.js";
1414

1515
export class GenerateAction {
1616
private readonly prompts: SdkGeneratePrompts = new SdkGeneratePrompts();
@@ -28,17 +28,16 @@ export class GenerateAction {
2828
public readonly execute = async (
2929
specDirectory: DirectoryPath,
3030
sdkDirectory: DirectoryPath,
31-
platform: Platforms,
31+
platform: LanguagePlatform,
3232
force: boolean,
3333
zipSdk: boolean
3434
): Promise<ActionResult> => {
35-
3635
if (specDirectory.isEqual(sdkDirectory)) {
3736
return ActionResult.error(`The spec directory and sdk directory cannot be the same: "${specDirectory}"`);
3837
}
3938

4039
const specContext = new SpecContext(specDirectory);
41-
if (!await specContext.validate()) {
40+
if (!(await specContext.validate())) {
4241
return ActionResult.error(`The spec directory is either empty or invalid: "${specDirectory}"`);
4342
}
4443

@@ -55,7 +54,8 @@ export class GenerateAction {
5554
const specZipPath = new FilePath(tempDirectory, new FileName("spec.zip"));
5655
await this.zipArchiver.archive(specDirectory, specZipPath);
5756

58-
const response = await this.portalService.generateSdk(specZipPath, platform, this.configDir, this.authKey);
57+
const sdkPlatform = this.convertSimplePlatformToPlatform(platform as LanguagePlatform);
58+
const response = await this.portalService.generateSdk(specZipPath, sdkPlatform, this.configDir, this.authKey);
5959

6060
if (!response.isSuccess()) {
6161
this.prompts.displaySdkGenerationErrorMessage();
@@ -70,5 +70,26 @@ export class GenerateAction {
7070

7171
return ActionResult.success();
7272
});
73+
};
74+
75+
private convertSimplePlatformToPlatform(languagePlatform: LanguagePlatform): Platforms {
76+
switch (languagePlatform) {
77+
case LanguagePlatform.CSHARP:
78+
return Platforms.CsNetStandardLib;
79+
case LanguagePlatform.JAVA:
80+
return Platforms.JavaEclipseJreLib;
81+
case LanguagePlatform.PHP:
82+
return Platforms.PhpGenericLibV2;
83+
case LanguagePlatform.PYTHON:
84+
return Platforms.PythonGenericLib;
85+
case LanguagePlatform.RUBY:
86+
return Platforms.RubyGenericLib;
87+
case LanguagePlatform.TYPESCRIPT:
88+
return Platforms.TsGenericLib;
89+
case LanguagePlatform.GO:
90+
return Platforms.GoGenericLib;
91+
default:
92+
throw new Error(`Unknown LanguagePlatform: ${languagePlatform}`);
93+
}
7394
}
7495
}

src/application/portal/recipe/recipe-generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class PortalRecipeGenerator {
151151
generatedRecipeScript: string,
152152
generatedRecipeScriptsDirectoryPath: string,
153153
recipeFileName: string,
154-
format: boolean = true
154+
format: boolean = false
155155
): Promise<void> {
156156
if (format) {
157157
generatedRecipeScript = await this.formatScript(generatedRecipeScript);
@@ -170,7 +170,7 @@ export class PortalRecipeGenerator {
170170
}
171171

172172
private addContentStepToScript(contentConfig: ContentStepConfig): string {
173-
return `return workflowCtx.showContent(\`${contentConfig.content}\`);`;
173+
return `return workflowCtx.showContent(${JSON.stringify(contentConfig.content)});`;
174174
}
175175

176176
private addEndpointStepToScript(endpointConfig: EndpointStepConfig): string {

src/client-utils/sdk-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class SDKClient {
4545

4646
await setAuthInfo(email, authKey, isTelemetryOptedOut, new DirectoryPath(configDir));
4747

48-
return "Logged in successfully as " + email;
48+
return "Logged in successfully as " + email;
4949
}
5050

5151
public async logout(configDir: string): Promise<string> {

src/commands/portal/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const DEFAULT_WORKING_DIRECTORY = "./";
88

99
export class PortalGenerate extends Command {
1010
static description =
11-
"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://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)";
11+
"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)";
1212

1313
static flags = {
1414
...FlagsProvider.input,

0 commit comments

Comments
 (0)