Skip to content

Commit adb6d0d

Browse files
feat(portal): adds portal:recipe:new command for api recipes and migrates codebase to esm from commonjs (#103)
Closes #62 . What Migrates codebase to esm from commonjs. Adds a new apimatic portal:recipe:new command, which follows a wizard-style flow to add an API Recipe to the build input. --------- Co-authored-by: saeedjamshaid <saeed.jamshaid@outlook.com>
1 parent 2408aff commit adb6d0d

Some content is hidden

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

65 files changed

+5874
-1748
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,5 @@ lib/
177177
tmp/
178178
.vscode/launch.json
179179
test-source/
180-
test-portal/
180+
test-destination/
181+
test-portal/

.vscode/launch.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,14 @@
5656
"type": "node",
5757
"request": "launch",
5858
"name": "Debug CLI Tests",
59-
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
59+
"program": "${workspaceFolder}/node_modules/tsx/dist/cli.mjs",
6060
"args": [
61-
"--require",
62-
"ts-node/register",
63-
"--project",
64-
"${workspaceFolder}/tsconfig.json",
61+
"${workspaceFolder}/node_modules/mocha/bin/_mocha",
6562
"--forbid-only",
6663
"test/**/*.test.ts",
64+
// "${file}", // Run Tests for the currently open test file.
6765
"--timeout",
68-
"99999",
66+
"99999"
6967
],
7068
"cwd": "${workspaceFolder}",
7169
"runtimeArgs": [

README.md

Lines changed: 73 additions & 41 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.8 win32-x64 node-v23.4.0
27+
@apimatic/cli/1.1.0-alpha.10 win32-x64 node-v23.4.0
2828
$ apimatic --help [COMMAND]
2929
USAGE
3030
$ apimatic COMMAND
@@ -42,9 +42,10 @@ USAGE
4242
* [`apimatic autocomplete [SHELL]`](#apimatic-autocomplete-shell)
4343
* [`apimatic help [COMMAND]`](#apimatic-help-command)
4444
* [`apimatic portal:generate`](#apimatic-portalgenerate)
45-
* [`apimatic portal:toc:new`](#apimatic-portaltocnew)
4645
* [`apimatic portal:quickstart`](#apimatic-portalquickstart)
46+
* [`apimatic portal:recipe:new`](#apimatic-portalrecipenew)
4747
* [`apimatic portal:serve`](#apimatic-portalserve)
48+
* [`apimatic portal:toc:new`](#apimatic-portaltocnew)
4849
* [`apimatic sdk:generate`](#apimatic-sdkgenerate)
4950

5051
## `apimatic api:transform`
@@ -244,66 +245,53 @@ EXAMPLES
244245

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

247-
## `apimatic portal:toc:new`
248+
## `apimatic portal:quickstart`
248249

249-
Generates a TOC file based on the content directory and spec folder provided in your working directory
250+
Create your first API Portal using APIMatic's Docs as Code offering.
250251

251252
```
252253
USAGE
253-
$ apimatic portal:toc:new [--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.
254+
$ apimatic portal:quickstart
266255
267256
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
257+
Create your first API Portal using APIMatic's Docs as Code offering.
277258
278259
EXAMPLES
279-
$ apimatic portal:toc:new --destination="./portal/content/"
280-
A new toc file has been created at ./portal/content/toc.yml
281-
282-
$ apimatic portal:toc:new --folder="./my-project"
283-
A new toc file has been created at ./my-project/content/toc.yml
284-
285-
$ apimatic portal:toc:new --folder="./my-project" --destination="./portal/content/"
286-
A new toc file has been created at ./portal/content/toc.yml
260+
$ apimatic portal:quickstart
287261
```
288262

289-
_See code: [src/commands/portal/toc/new/toc.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/toc/new/toc.ts)_
263+
_See code: [src/commands/portal/quickstart.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/quickstart.ts)_
290264

291-
## `apimatic portal:quickstart`
265+
## `apimatic portal:recipe:new`
292266

293-
Create your first API Portal using APIMatic's Docs as Code offering.
267+
Generate an API Recipe for a static API Documentation portal.
294268

295269
```
296270
USAGE
297-
$ apimatic portal:quickstart
271+
$ apimatic portal:recipe:new [--name <value>] [--folder <value>] [--build-config <value>]
272+
273+
FLAGS
274+
--build-config=<value> path to the APIMATIC-BUILD.json file. Defaults to the APIMATIC-BUILD.json file in the build
275+
directory if not provided.
276+
--folder=<value> [default: C:\Users\Ali\Desktop\apimatic-cli] path to the build directory containing specs,
277+
content, and build config file. Defaults to the current working directory if not provided.
278+
--name=<value> name for the recipe
298279
299280
DESCRIPTION
300-
Create your first API Portal using APIMatic's Docs as Code offering.
281+
Generate an API Recipe for a static API Documentation portal.
282+
283+
To learn more about API Recipes, visit:
284+
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes
301285
302286
EXAMPLES
303-
$ apimatic portal:quickstart
287+
$ apimatic portal:recipe:new --name="My API Recipe" --folder="./build-folder" --build-config-file="./build-folder/APIMATIC-BUILD.json"
288+
Generated recipe has been added to build directory at: C:/build-folder/
289+
290+
$ apimatic portal:recipe:new
291+
Generated recipe has been added to build directory at: C:/
304292
```
305293

306-
_See code: [src/commands/portal/quickstart.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/quickstart.ts)_
294+
_See code: [src/commands/portal/recipe/new.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/recipe/new.ts)_
307295

308296
## `apimatic portal:serve`
309297

@@ -333,6 +321,50 @@ EXAMPLES
333321

334322
_See code: [src/commands/portal/serve.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/serve.ts)_
335323

324+
## `apimatic portal:toc:new`
325+
326+
Generates a TOC file based on the content directory and spec folder provided in your working directory
327+
328+
```
329+
USAGE
330+
$ apimatic portal:toc:new [--destination <value>] [--folder <value>] [--force] [--expand-endpoints]
331+
[--expand-models]
332+
333+
FLAGS
334+
--destination=<value> optional path where the generated TOC file will be saved. Defaults to the current working
335+
directory if not provided.
336+
--expand-endpoints include individual entries for each endpoint in the generated TOC. Requires a valid API
337+
specification in the working directory.
338+
--expand-models include individual entries for each model in the generated TOC. Requires a valid API
339+
specification in the working directory.
340+
--folder=<value> [default: C:\Users\Ali\Desktop\apimatic-cli] path to the working directory containing the API
341+
project files. Defaults to the current working directory if not specified.
342+
--force overwrite the TOC file if one already exists at the destination.
343+
344+
DESCRIPTION
345+
Generates a TOC file based on the content directory and spec folder provided in your working directory
346+
347+
This command generates a new Table of Contents (TOC) file used in the
348+
generation of your API documentation portal.
349+
350+
The output is a YAML file with the .yml extension.
351+
352+
To learn more about the TOC file and APIMatic build directory structure, visit:
353+
https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal
354+
355+
EXAMPLES
356+
$ apimatic portal:toc:new --destination="./portal/content/"
357+
A new toc file has been created at ./portal/content/toc.yml
358+
359+
$ apimatic portal:toc:new --folder="./my-project"
360+
A new toc file has been created at ./my-project/content/toc.yml
361+
362+
$ apimatic portal:toc:new --folder="./my-project" --destination="./portal/content/"
363+
A new toc file has been created at ./portal/content/toc.yml
364+
```
365+
366+
_See code: [src/commands/portal/toc/new.ts](https://github.com/apimatic/apimatic-cli/blob/alpha/src/commands/portal/toc/new.ts)_
367+
336368
## `apimatic sdk:generate`
337369

338370
Generate SDK for your APIs

bin/run

Lines changed: 0 additions & 9 deletions
This file was deleted.

bin/run.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
import {execute} from '@oclif/core'
4+
5+
await execute({dir: import.meta.url})

eslint.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import js from "@eslint/js";
2+
import tseslint from "@typescript-eslint/eslint-plugin";
3+
import tsparser from "@typescript-eslint/parser";
4+
5+
export default [
6+
js.configs.recommended,
7+
{
8+
files: ["**/*.ts", "**/*.tsx"],
9+
languageOptions: {
10+
parser: tsparser,
11+
ecmaVersion: 2021,
12+
sourceType: "module",
13+
globals: {
14+
NodeJS: true,
15+
},
16+
},
17+
plugins: {
18+
"@typescript-eslint": tseslint,
19+
},
20+
rules: {
21+
...tseslint.configs.recommended.rules,
22+
},
23+
},
24+
{
25+
ignores: [
26+
"lib",
27+
"node_modules"
28+
]
29+
},
30+
];

0 commit comments

Comments
 (0)