Skip to content

Commit cfae452

Browse files
feat(portal): adds portal:new:toc command and other various improvements (#93)
Closes #55, Closes #56, Closes #72, Closes #73. Co-authored-by: saeedjamshaid <saeed.jamshaid@outlook.com>
1 parent 59a91fd commit cfae452

48 files changed

Lines changed: 2652 additions & 2550 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,7 @@ $RECYCLE.BIN/
174174
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
175175

176176
lib/
177-
tmp/
177+
tmp/
178+
.vscode/launch.json
179+
test-source/
180+
test-portal/

.vscode/launch.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Debug APIMatic CLI",
8+
"skipFiles": ["<node_internals>/"],
9+
"program": "${workspaceFolder}/bin/run",
10+
"args": [
11+
// "api:validate",
12+
// "--file=C:/Users/User/Desktop/spec/Errors.yaml",
13+
// "--file=https://petstore.swagger.io/v2/swagger.json"
14+
// "api:transform",
15+
// "--format=OpenApi3Json",
16+
// "--file=C:/Users/User/Desktop/test-cli/spec/Calculator.json",
17+
// "--destination=C:/Users/User/Desktop/test-cli/spec"
18+
// "auth:logout",
19+
// "auth:login",
20+
// "auth:status"
21+
// "portal:quickstart",
22+
// "portal:generate",
23+
// "portal:new:toc",
24+
//"--expand-endpoints",
25+
//"--expand-models",
26+
// "--force",
27+
// "--folder",
28+
// "test-source",
29+
// "--destination",
30+
// "test-portal",
31+
// "portal:serve",
32+
// "api:transform",
33+
// "--help"
34+
// "--folder=C:/Users/User/Desktop/demo/portal",
35+
// "--destination=C:\\Users\\User\\Desktop\\demo\\portal\\api-portal"
36+
// "--source=C:/Users/User/Desktop/demo/portal/",
37+
// "--destination=C:/Users/User/Desktop/demo/portal/api-portal2",
38+
// "--source=C:/Users/User/Desktop/demo/portal",
39+
// "--source=\"C:\\Users\\User\\Desktop\\test-cli\"",
40+
// "--destination=\"C:\\Users\\User\\Desktop\\demo\\portal\\api-portal\"",
41+
// "--destination=\"C:\\Users\\User\\Desktop\\demo\\api-portal\"",
42+
// "--source=C:/Users/User/Desktop/test-cli",
43+
// "--destination=C:/Users/User/Desktop/test-cli/api-portal",
44+
// "--source=C:\\Users\\User\\Desktop\\test-cli-2",
45+
// "--destination=C:\\Users\\User\\Desktop\\test-cli-2\\generated_portal"
46+
// "--port=70000"
47+
// "--ignore=C:/Users/User/Desktop/demo/portal/content,C:/Users/User/Desktop/demo/portal/static/images/logo.png",
48+
// "--no-reload",
49+
// "--auth-key=\"invalidApiKey\"",
50+
// "--help"
51+
],
52+
"console": "externalTerminal",
53+
"preLaunchTask": "tsc: build - tsconfig.json"
54+
},
55+
{
56+
"type": "node",
57+
"request": "launch",
58+
"name": "Debug CLI Tests",
59+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
60+
"args": [
61+
"--require",
62+
"ts-node/register",
63+
"--project",
64+
"${workspaceFolder}/tsconfig.json",
65+
"--forbid-only",
66+
"test/**/*.test.ts",
67+
"--timeout",
68+
"99999",
69+
],
70+
"cwd": "${workspaceFolder}",
71+
"runtimeArgs": [
72+
"--nolazy",
73+
"--inspect-brk",
74+
"--trace-warnings"
75+
],
76+
"internalConsoleOptions": "openOnSessionStart",
77+
"skipFiles": ["<node_internals>/**"],
78+
"console": "integratedTerminal"
79+
}
80+
]
81+
}

README.md

Lines changed: 85 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,14 @@ To get started with APIMatic's CLI using a step by step wizard, run the followin
1717
$ apimatic portal:quickstart
1818
```
1919

20-
<!-- toc -->
21-
* [Usage](#usage)
22-
* [Commands](#commands)
23-
<!-- tocstop -->
2420
# Usage
2521
<!-- usage -->
2622
```sh-session
2723
$ npm install -g @apimatic/cli
2824
$ apimatic COMMAND
2925
running command...
3026
$ apimatic (--version)
31-
@apimatic/cli/0.0.0-alpha.0 win32-x64 node-v20.18.3
27+
@apimatic/cli/1.1.0-alpha.8 win32-x64 node-v23.4.0
3228
$ apimatic --help [COMMAND]
3329
USAGE
3430
$ apimatic COMMAND
@@ -46,6 +42,7 @@ USAGE
4642
* [`apimatic autocomplete [SHELL]`](#apimatic-autocomplete-shell)
4743
* [`apimatic help [COMMAND]`](#apimatic-help-command)
4844
* [`apimatic portal:generate`](#apimatic-portalgenerate)
45+
* [`apimatic portal:new:toc`](#apimatic-portalnewtoc)
4946
* [`apimatic portal:quickstart`](#apimatic-portalquickstart)
5047
* [`apimatic portal:serve`](#apimatic-portalserve)
5148
* [`apimatic sdk:generate`](#apimatic-sdkgenerate)
@@ -61,18 +58,13 @@ USAGE
6158
6259
FLAGS
6360
-f, --force overwrite if same file exist in the destination
64-
--auth-key=auth-key override current authentication state with an authentication key
65-
66-
--destination=destination [default: /home/runner/work/apimatic-cli/apimatic-cli/cli] directory to download
67-
transformed file to
68-
69-
--file=file path to the API specification file to transform
70-
71-
--format=format (required) specification format to transform API specification into
61+
--auth-key=<value> override current authentication state with an authentication key
62+
--destination=<value> [default: ./] directory to download transformed file to
63+
--file=<value> path to the API specification file to transform
64+
--format=<value> (required) specification format to transform API specification into
7265
APIMATIC|WADL2009|WSDL|SWAGGER10|SWAGGER20|SWAGGERYAML|OAS3|OPENAPI3YAML|APIBLUEPRINT|RAML|
7366
RAML10|POSTMAN10|POSTMAN20|GRAPHQLSCHEMA
74-
75-
--url=url URL to the API specification file to transform. Can be used in place of the --file option
67+
--url=<value> URL to the API specification file to transform. Can be used in place of the --file option
7668
if the API specification is publicly available.
7769
7870
DESCRIPTION
@@ -99,11 +91,10 @@ USAGE
9991
$ apimatic api:validate [--file <value>] [--url <value>] [--auth-key <value>]
10092
10193
FLAGS
102-
--auth-key=auth-key override current authentication state with an authentication key
103-
--file=file Path to the API specification file to validate
104-
105-
--url=url URL to the specification file to validate. Can be used in place of the --file option if the API
106-
specification is publicly available.
94+
--auth-key=<value> override current authentication state with an authentication key
95+
--file=<value> Path to the API specification file to validate
96+
--url=<value> URL to the specification file to validate. Can be used in place of the --file option if the API
97+
specification is publicly available.
10798
10899
DESCRIPTION
109100
Validate the syntactic and semantic correctness of an API specification
@@ -127,16 +118,15 @@ USAGE
127118
$ apimatic auth:login [--auth-key <value>]
128119
129120
FLAGS
130-
--auth-key=auth-key Set authentication key for all commands
121+
--auth-key=<value> Set authentication key for all commands
131122
132123
DESCRIPTION
133124
Login using your APIMatic credentials or an API Key
134125
135126
EXAMPLES
136127
$ apimatic auth:login
137-
Please enter your registered email: apimatic-user@gmail.com
128+
Enter your registered email: apimatic-user@gmail.com
138129
Please enter your password: *********
139-
140130
You have successfully logged into APIMatic
141131
142132
$ apimatic auth:login --auth-key=xxxxxx
@@ -213,10 +203,13 @@ Display help for apimatic.
213203

214204
```
215205
USAGE
216-
$ apimatic help [COMMAND]
206+
$ apimatic help [COMMAND...] [-n]
217207
218208
ARGUMENTS
219-
COMMAND command to show help for
209+
COMMAND... Command to show help for.
210+
211+
FLAGS
212+
-n, --nested-commands Include all nested commands in the output.
220213
221214
DESCRIPTION
222215
Display help for apimatic.
@@ -234,6 +227,11 @@ USAGE
234227
235228
FLAGS
236229
-f, --force overwrite if a portal exists in the destination
230+
--auth-key=<value> override current authentication state with an authentication key
231+
--destination=<value> [default: ./generated_portal] path to the downloaded portal
232+
--folder=<value> [default: ./] path to the input directory containing API specifications and config files
233+
--zip download the generated portal as a .zip archive
234+
237235
DESCRIPTION
238236
Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a
239237
config file and optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platfo
@@ -246,33 +244,78 @@ EXAMPLES
246244

247245
_See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/generate.ts)_
248246

247+
## `apimatic portal:new:toc`
248+
249+
Generates a TOC file based on the content directory and spec folder provided in your working directory
250+
251+
```
252+
USAGE
253+
$ apimatic portal:new:toc [--destination <value>] [--folder <value>] [--force] [--expand-endpoints]
254+
[--expand-models]
255+
256+
FLAGS
257+
--destination=<value> optional path where the generated TOC file will be saved. Defaults to the current working
258+
directory if not provided.
259+
--expand-endpoints include individual entries for each endpoint in the generated TOC. Requires a valid API
260+
specification in the working directory.
261+
--expand-models include individual entries for each model in the generated TOC. Requires a valid API
262+
specification in the working directory.
263+
--folder=<value> [default: ./] path to the working directory containing the API project
264+
files. Defaults to the current working directory if not specified.
265+
--force overwrite the TOC file if one already exists at the destination.
266+
267+
DESCRIPTION
268+
Generates a TOC file based on the content directory and spec folder provided in your working directory
269+
270+
This command generates a new Table of Contents (TOC) file used in the
271+
generation of your API documentation portal.
272+
273+
The output is a YAML file with the .yml extension.
274+
275+
To learn more about the TOC file and APIMatic build directory structure, visit:
276+
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal
277+
278+
EXAMPLES
279+
$ apimatic portal:new:toc --destination="./portal/content/"
280+
A new toc file has been created at ./portal/content/toc.yml
281+
282+
$ apimatic portal:new:toc --folder="./my-project"
283+
A new toc file has been created at ./my-project/content/toc.yml
284+
285+
$ apimatic portal:new:toc --folder="./my-project" --destination="./portal/content/"
286+
A new toc file has been created at ./portal/content/toc.yml
287+
```
288+
289+
_See code: [src/commands/portal/new/toc.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/new/toc.ts)_
290+
249291
## `apimatic portal:quickstart`
250292

251-
Create your first API Portal using APIMatics Docs as Code offering.
293+
Create your first API Portal using APIMatic's Docs as Code offering.
252294

253295
```
254296
USAGE
255297
$ apimatic portal:quickstart
256298
257299
DESCRIPTION
258-
Create your first API Portal using APIMatics Docs as Code offering.
300+
Create your first API Portal using APIMatic's Docs as Code offering.
259301
260302
EXAMPLES
261303
$ apimatic portal:quickstart
262304
```
263305

264-
_See code: [src/commands/portal/quickstart.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.11/src/commands/portal/quickstart.ts)_
306+
_See code: [src/commands/portal/quickstart.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/quickstart.ts)_
265307

266308
## `apimatic portal:serve`
267309

268310
Generate and deploy a Docs as Code portal with hot reload.
269311

270312
```
271313
USAGE
272-
$ apimatic portal:serve [-p <value>] [-d <value>] [-s <value>] [-o] [--no-reload] [-i <value>] [--auth-key <value>]
314+
$ apimatic portal:serve [-p <value>] [-d <value>] [-s <value>] [-o] [--no-reload] [-i <value>] [--auth-key
315+
<value>]
273316
274317
FLAGS
275-
-d, --destination=<value> [default: ./api-portal] Directory to store and serve the generated portal.
318+
-d, --destination=<value> [default: ./generated_portal] Directory to store and serve the generated portal.
276319
-i, --ignore=<value> Comma-separated list of files/directories to ignore.
277320
-o, --open Open the portal in the default browser.
278321
-p, --port=<value> [default: 3000] Port to serve the portal.
@@ -285,35 +328,30 @@ DESCRIPTION
285328
Generate and deploy a Docs as Code portal with hot reload.
286329
287330
EXAMPLES
288-
$ apimatic portal:serve --source="./" --destination="./api-portal" --port=3000 --open --no-reload
331+
$ apimatic portal:serve --source="./" --destination="./generated_portal" --port=3000 --open --no-reload
289332
```
290333

291-
_See code: [src/commands/portal/serve.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.11/src/commands/portal/serve.ts)_
334+
_See code: [src/commands/portal/serve.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/serve.ts)_
292335

293336
## `apimatic sdk:generate`
294337

295338
Generate SDK for your APIs
296339

297340
```
298341
USAGE
299-
$ apimatic sdk:generate --platform <value> [--file <value>] [--url <value>] [--destination <value>] [-f] [--zip] [--auth-key <value>]
342+
$ apimatic sdk:generate --platform <value> [--file <value>] [--url <value>] [--destination <value>] [-f] [--zip]
343+
[--auth-key <value>]
300344
301345
FLAGS
302346
-f, --force overwrite if an SDK already exists in the destination
303-
--auth-key=auth-key override current authentication state with an authentication key
304-
305-
--destination=destination [default: /home/runner/work/apimatic-cli/apimatic-cli/cli] directory to download the
306-
generated SDK to
307-
308-
--file=file path to the API specification to generate SDKs for
309-
310-
--platform=platform (required) language platform for sdk
311-
Simple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT
312-
Legacy: CS_NET_STANDARD_LIB|CS_PORTABLE_NET_LIB|CS_UNIVERSAL_WINDOWS_PLATFORM_LIB|
313-
JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB|PYTHON_GENERIC_LIB|RUBY_GENERIC_LIB|
314-
TS_GENERIC_LIB
315-
316-
--url=url URL to the API specification to generate SDKs for. Can be used in place of the --file
347+
--auth-key=<value> override current authentication state with an authentication key
348+
--destination=<value> [default: ./] directory to download the generated SDK to
349+
--file=<value> path to the API specification to generate SDKs for
350+
--platform=<value> (required) language platform for sdk
351+
Simple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT|GO
352+
Legacy: CS_NET_STANDARD_LIB|JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB_V2|PYTHON_GENERIC_LIB|RUBY
353+
_GENERIC_LIB|TS_GENERIC_LIB|GO_GENERIC_LIB
354+
--url=<value> URL to the API specification to generate SDKs for. Can be used in place of the --file
317355
option if the API specification is publicly available.
318356
--zip download the generated SDK as a .zip archive
319357

0 commit comments

Comments
 (0)