@apimatic/cli 1.0.1-alpha.1 → 1.0.1-alpha.2

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.0.1-alpha.2](https://github.com/apimatic/apimatic-cli/compare/v1.0.1-alpha.1...v1.0.1-alpha.2) (2021-11-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **refactor:** refactor code ([d7cb486](https://github.com/apimatic/apimatic-cli/commit/d7cb4863bcfd44f297f0525e0c7eae7ecef12695))
7
+
1
8
  ## [1.0.1-alpha.1](https://github.com/apimatic/apimatic-cli/compare/v1.0.0...v1.0.1-alpha.1) (2021-11-26)
2
9
 
3
10
 
package/README.md CHANGED
@@ -19,7 +19,7 @@ $ npm install -g @apimatic/cli
19
19
  $ apimatic COMMAND
20
20
  running command...
21
21
  $ apimatic (-v|--version|version)
22
- @apimatic/cli/1.0.1-alpha.1 linux-x64 node-v14.18.1
22
+ @apimatic/cli/1.0.1-alpha.2 linux-x64 node-v14.18.1
23
23
  $ apimatic --help [COMMAND]
24
24
  USAGE
25
25
  $ apimatic COMMAND
@@ -55,7 +55,7 @@ EXAMPLE
55
55
  $ apimatic api --help
56
56
  ```
57
57
 
58
- _See code: [src/commands/api/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/api/index.ts)_
58
+ _See code: [src/commands/api/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/api/index.ts)_
59
59
 
60
60
  ## `apimatic api:transform`
61
61
 
@@ -84,7 +84,7 @@ EXAMPLE
84
84
  Success! Your transformed file is located at D:/Transformed_OpenApi3Json.json
85
85
  ```
86
86
 
87
- _See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/api/transform.ts)_
87
+ _See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/api/transform.ts)_
88
88
 
89
89
  ## `apimatic api:validate`
90
90
 
@@ -104,7 +104,7 @@ EXAMPLE
104
104
  Specification file provided is valid
105
105
  ```
106
106
 
107
- _See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/api/validate.ts)_
107
+ _See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/api/validate.ts)_
108
108
 
109
109
  ## `apimatic auth`
110
110
 
@@ -118,7 +118,7 @@ EXAMPLE
118
118
  $ apimatic auth --help
119
119
  ```
120
120
 
121
- _See code: [src/commands/auth/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/auth/index.ts)_
121
+ _See code: [src/commands/auth/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/auth/index.ts)_
122
122
 
123
123
  ## `apimatic auth:login`
124
124
 
@@ -139,7 +139,7 @@ EXAMPLE
139
139
  You have successfully logged into APIMatic
140
140
  ```
141
141
 
142
- _See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/auth/login.ts)_
142
+ _See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/auth/login.ts)_
143
143
 
144
144
  ## `apimatic auth:logout`
145
145
 
@@ -154,7 +154,7 @@ EXAMPLE
154
154
  Logged out
155
155
  ```
156
156
 
157
- _See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/auth/logout.ts)_
157
+ _See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/auth/logout.ts)_
158
158
 
159
159
  ## `apimatic auth:status`
160
160
 
@@ -169,7 +169,7 @@ EXAMPLE
169
169
  Currently logged in as apimatic-client@gmail.com
170
170
  ```
171
171
 
172
- _See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/auth/status.ts)_
172
+ _See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/auth/status.ts)_
173
173
 
174
174
  ## `apimatic autocomplete [SHELL]`
175
175
 
@@ -209,7 +209,7 @@ OPTIONS
209
209
  --all see all commands in CLI
210
210
  ```
211
211
 
212
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.7/src/commands/help.ts)_
212
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.9/src/commands/help.ts)_
213
213
 
214
214
  ## `apimatic portal`
215
215
 
@@ -223,7 +223,7 @@ EXAMPLE
223
223
  $apimatic portal --help
224
224
  ```
225
225
 
226
- _See code: [src/commands/portal/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/portal/index.ts)_
226
+ _See code: [src/commands/portal/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/portal/index.ts)_
227
227
 
228
228
  ## `apimatic portal:generate`
229
229
 
@@ -244,7 +244,7 @@ EXAMPLE
244
244
  Your portal has been generated at D:/
245
245
  ```
246
246
 
247
- _See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/portal/generate.ts)_
247
+ _See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/portal/generate.ts)_
248
248
 
249
249
  ## `apimatic sdk`
250
250
 
@@ -258,7 +258,7 @@ EXAMPLE
258
258
  $apimatic sdk --help
259
259
  ```
260
260
 
261
- _See code: [src/commands/sdk/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/sdk/index.ts)_
261
+ _See code: [src/commands/sdk/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/sdk/index.ts)_
262
262
 
263
263
  ## `apimatic sdk:generate`
264
264
 
@@ -288,5 +288,5 @@ EXAMPLE
288
288
  SDK generated successfully
289
289
  ```
290
290
 
291
- _See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.1/src/commands/sdk/generate.ts)_
291
+ _See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.2/src/commands/sdk/generate.ts)_
292
292
  <!-- commandsstop -->
package/bin/run CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ /* eslint-disable no-undef */
3
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
4
 
3
- require('@oclif/command').run()
4
- .then(require('@oclif/command/flush'))
5
- .catch(require('@oclif/errors/handle'))
5
+ require("@oclif/command").run().then(require("@oclif/command/flush")).catch(require("@oclif/errors/handle"));
@@ -1,4 +1,3 @@
1
- import { ApiValidationSummary } from "@apimatic/apimatic-sdk-for-js";
2
1
  import { flags, Command } from "@oclif/command";
3
2
  export default class Transform extends Command {
4
3
  static description: string;
@@ -10,6 +9,5 @@ export default class Transform extends Command {
10
9
  destination: flags.IOptionFlag<string>;
11
10
  "auth-key": flags.IOptionFlag<string | undefined>;
12
11
  };
13
- printValidationMessages: (apiValidationSummary: ApiValidationSummary | undefined) => void;
14
12
  run(): Promise<void>;
15
13
  }
@@ -7,80 +7,13 @@ const apimatic_sdk_for_js_1 = require("@apimatic/apimatic-sdk-for-js");
7
7
  const command_1 = require("@oclif/command");
8
8
  const sdk_client_1 = require("../../client-utils/sdk-client");
9
9
  const utils_1 = require("../../utils/utils");
10
- const DestinationFormats = {
11
- OpenApi3Json: "json",
12
- OpenApi3Yaml: "yaml",
13
- APIMATIC: "json",
14
- WADL2009: "xml",
15
- WSDL: "xml",
16
- Swagger10: "json",
17
- Swagger20: "json",
18
- SwaggerYaml: "yaml",
19
- RAML: "yaml",
20
- RAML10: "yaml",
21
- Postman10: "json",
22
- Postman20: "json"
23
- };
24
- async function getTransformationId({ file, url, format }, transformationController) {
25
- cli_ux_1.default.action.start("Transforming API specification");
26
- let generation;
27
- if (file) {
28
- const fileDescriptor = new apimatic_sdk_for_js_1.FileWrapper(fs.createReadStream(file));
29
- generation = await transformationController.transformViaFile(fileDescriptor, format);
30
- }
31
- else if (url) {
32
- const body = {
33
- url: url,
34
- exportFormat: format
35
- };
36
- generation = await transformationController.transformViaURL(body);
37
- }
38
- else {
39
- throw new Error("Please provide a specification file");
40
- }
41
- cli_ux_1.default.action.stop();
42
- return generation.result;
43
- }
44
- async function downloadTransformationFile({ id, destinationFilePath, transformationController }) {
45
- cli_ux_1.default.action.start("Downloading Transformed file");
46
- const { result } = await transformationController.downloadTransformedFile(id);
47
- if (result.readable) {
48
- await utils_1.writeFileUsingReadableStream(result, destinationFilePath);
49
- }
50
- else {
51
- throw new Error("Couldn't save transformation file");
52
- }
53
- cli_ux_1.default.action.stop();
54
- return destinationFilePath;
55
- }
56
- // Get valid platform from user's input, convert simple platform to valid Platforms enum value
57
- function getValidFormat(format) {
58
- if (Object.keys(apimatic_sdk_for_js_1.ExportFormats).find((exportFormat) => exportFormat === format)) {
59
- return apimatic_sdk_for_js_1.ExportFormats[format];
60
- }
61
- else {
62
- const formats = Object.keys(apimatic_sdk_for_js_1.ExportFormats).join("|");
63
- throw new Error(`Please provide a valid platform i.e. ${formats}`);
64
- }
65
- }
10
+ const transform_1 = require("../../types/api/transform");
11
+ const transform_2 = require("../../controllers/api/transform");
66
12
  class Transform extends command_1.Command {
67
- constructor() {
68
- super(...arguments);
69
- this.printValidationMessages = (apiValidationSummary) => {
70
- const warnings = (apiValidationSummary === null || apiValidationSummary === void 0 ? void 0 : apiValidationSummary.warnings) || [];
71
- const errors = (apiValidationSummary === null || apiValidationSummary === void 0 ? void 0 : apiValidationSummary.errors.join("\n")) || "";
72
- warnings.forEach((warning) => {
73
- this.warn(utils_1.replaceHTML(warning));
74
- });
75
- if (apiValidationSummary && apiValidationSummary.errors.length > 0) {
76
- this.error(utils_1.replaceHTML(errors));
77
- }
78
- };
79
- }
80
13
  async run() {
81
14
  const { flags } = this.parse(Transform);
82
15
  const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
83
- const destinationFormat = DestinationFormats[flags.format];
16
+ const destinationFormat = transform_1.DestinationFormats[flags.format];
84
17
  const destinationFilePath = path.join(flags.destination, `${fileName}_${flags.format}.${destinationFormat}`.toLowerCase());
85
18
  if (fs.existsSync(destinationFilePath)) {
86
19
  throw new Error(`Can't download transformed file to path ${destinationFilePath}, because it already exists`);
@@ -95,9 +28,9 @@ class Transform extends command_1.Command {
95
28
  const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
96
29
  const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
97
30
  const transformationController = new apimatic_sdk_for_js_1.TransformationController(client);
98
- const { id, apiValidationSummary } = await getTransformationId(flags, transformationController);
99
- this.printValidationMessages(apiValidationSummary);
100
- const savedTransformationFile = await downloadTransformationFile({
31
+ const { id, apiValidationSummary } = await transform_2.getTransformationId(flags, transformationController);
32
+ transform_2.printValidationMessages(apiValidationSummary, this.warn, this.error);
33
+ const savedTransformationFile = await transform_2.downloadTransformationFile({
101
34
  id,
102
35
  destinationFilePath,
103
36
  transformationController
@@ -144,7 +77,7 @@ Success! Your transformed file is located at D:/Transformed_OpenApi3Json.json
144
77
  ];
145
78
  Transform.flags = {
146
79
  format: command_1.flags.string({
147
- parse: (format) => getValidFormat(format.toUpperCase()),
80
+ parse: (format) => transform_2.getValidFormat(format.toUpperCase()),
148
81
  required: true,
149
82
  description: `specification format to transform API specification into
150
83
  (OpenApi3Json|OpenApi3Yaml|APIMATIC|WADL2009|WADL2006|WSDL|
@@ -1,4 +1,3 @@
1
- import { ApiValidationSummary } from "@apimatic/apimatic-sdk-for-js";
2
1
  import { flags, Command } from "@oclif/command";
3
2
  export default class Validate extends Command {
4
3
  static description: string;
@@ -8,6 +7,5 @@ export default class Validate extends Command {
8
7
  url: flags.IOptionFlag<string>;
9
8
  "auth-key": flags.IOptionFlag<string | undefined>;
10
9
  };
11
- printValidationMessages: ({ warnings, errors }: ApiValidationSummary) => void;
12
10
  run(): Promise<void>;
13
11
  }
@@ -1,40 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const fs = require("fs-extra");
4
- const cli_ux_1 = require("cli-ux");
5
4
  const apimatic_sdk_for_js_1 = require("@apimatic/apimatic-sdk-for-js");
6
5
  const command_1 = require("@oclif/command");
7
6
  const sdk_client_1 = require("../../client-utils/sdk-client");
8
7
  const utils_1 = require("../../utils/utils");
9
- async function getValidation({ file, url }, apiValidationController) {
10
- let validation;
11
- cli_ux_1.default.action.start("Validating specification file");
12
- if (file) {
13
- const fileDescriptor = new apimatic_sdk_for_js_1.FileWrapper(fs.createReadStream(file));
14
- validation = await apiValidationController.validateAPIViaFile(fileDescriptor);
15
- }
16
- else if (url) {
17
- validation = await apiValidationController.validateAPIViaURL(url);
18
- }
19
- else {
20
- throw new Error("Please provide a specification file");
21
- }
22
- cli_ux_1.default.action.stop();
23
- return validation.result;
24
- }
8
+ const transform_1 = require("../../controllers/api/transform");
9
+ const validate_1 = require("../../controllers/api/validate");
25
10
  class Validate extends command_1.Command {
26
- constructor() {
27
- super(...arguments);
28
- this.printValidationMessages = ({ warnings, errors }) => {
29
- warnings.forEach((warning) => {
30
- this.warn(`${utils_1.replaceHTML(warning)}`);
31
- });
32
- if (errors.length > 0) {
33
- const singleLineError = errors.join("\n");
34
- this.error(utils_1.replaceHTML(singleLineError));
35
- }
36
- };
37
- }
38
11
  async run() {
39
12
  const { flags } = this.parse(Validate);
40
13
  try {
@@ -44,8 +17,8 @@ class Validate extends command_1.Command {
44
17
  const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
45
18
  const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
46
19
  const apiValidationController = new apimatic_sdk_for_js_1.APIValidationExternalApisController(client);
47
- const validationSummary = await getValidation(flags, apiValidationController);
48
- this.printValidationMessages(validationSummary);
20
+ const validationSummary = await validate_1.getValidation(flags, apiValidationController);
21
+ transform_1.printValidationMessages(validationSummary, this.warn, this.error);
49
22
  validationSummary.success
50
23
  ? this.log("Specification file provided is valid")
51
24
  : this.error("Specification file provided is invalid");
@@ -1,12 +1,4 @@
1
- import { DocsPortalManagementController } from "@apimatic/apimatic-sdk-for-js";
2
1
  import { Command, flags } from "@oclif/command";
3
- declare type GeneratePortalParams = {
4
- zippedBuildFilePath: string;
5
- generatedPortalFolderPath: string;
6
- docsPortalController: DocsPortalManagementController;
7
- overrideAuthKey: string | null;
8
- zip: boolean;
9
- };
10
2
  export default class PortalGenerate extends Command {
11
3
  static description: string;
12
4
  static flags: {
@@ -16,8 +8,5 @@ export default class PortalGenerate extends Command {
16
8
  "auth-key": flags.IOptionFlag<string>;
17
9
  };
18
10
  static examples: string[];
19
- downloadPortalAxios: (zippedBuildFilePath: string, overrideAuthKey: string | null) => Promise<any>;
20
- downloadDocsPortal: ({ zippedBuildFilePath, generatedPortalFolderPath, overrideAuthKey, zip }: GeneratePortalParams) => Promise<string>;
21
11
  run(): Promise<undefined>;
22
12
  }
23
- export {};
@@ -1,61 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const fs = require("fs-extra");
4
- const FormData = require("form-data");
5
4
  const path = require("path");
6
5
  const cli_ux_1 = require("cli-ux");
7
- const apimatic_sdk_for_js_1 = require("@apimatic/apimatic-sdk-for-js");
8
6
  const command_1 = require("@oclif/command");
7
+ const apimatic_sdk_for_js_1 = require("@apimatic/apimatic-sdk-for-js");
9
8
  const sdk_client_1 = require("../../client-utils/sdk-client");
10
- const env_1 = require("../../config/env");
9
+ const generate_1 = require("../../controllers/portal/generate");
11
10
  const utils_1 = require("../../utils/utils");
12
- const auth_manager_1 = require("../../client-utils/auth-manager");
13
- const axios_1 = require("axios");
14
11
  class PortalGenerate extends command_1.Command {
15
- constructor() {
16
- super(...arguments);
17
- // TODO: Remove after SDK is patched
18
- this.downloadPortalAxios = async (zippedBuildFilePath, overrideAuthKey) => {
19
- const formData = new FormData();
20
- const authInfo = await auth_manager_1.getAuthInfo(this.config.configDir);
21
- formData.append("file", fs.createReadStream(zippedBuildFilePath));
22
- const config = {
23
- headers: Object.assign({ Authorization: authInfo ? `X-Auth-Key ${overrideAuthKey || authInfo.authKey.trim()}` : "", "Content-Type": "multipart/form-data" }, formData.getHeaders()),
24
- responseType: "arraybuffer"
25
- };
26
- const { data } = await axios_1.default.post(`${env_1.baseURL}/portal`, formData, config);
27
- return data;
28
- };
29
- // Download Docs Portal
30
- this.downloadDocsPortal = async ({ zippedBuildFilePath, generatedPortalFolderPath, overrideAuthKey, zip }) => {
31
- const zippedPortalPath = path.join(generatedPortalFolderPath, "generated_portal.zip");
32
- const portalPath = path.join(generatedPortalFolderPath, "generated_portal");
33
- cli_ux_1.default.action.start("Downloading portal");
34
- // Check if the build file exists for the user or not
35
- if (!(await fs.pathExists(zippedBuildFilePath))) {
36
- throw new Error("Build file doesn't exist");
37
- }
38
- // TODO: ***CRITICAL*** Remove this call once the SDK is patched
39
- const data = await this.downloadPortalAxios(zippedBuildFilePath, overrideAuthKey);
40
- await utils_1.deleteFile(zippedBuildFilePath);
41
- await fs.writeFile(zippedPortalPath, data);
42
- // TODO: Uncomment this code block when the SDK is patched
43
- // const file: FileWrapper = new FileWrapper(fs.createReadStream(zippedBuildFilePath));
44
- // const { result }: ApiResponse<NodeJS.ReadableStream | Blob> =
45
- // await docsPortalController.generateOnPremPortalViaBuildInput(file);
46
- // if ((data as NodeJS.ReadableStream).readable) {
47
- // await writeFileUsingReadableStream(data as NodeJS.ReadableStream, zippedPortalPath);
48
- if (!zip) {
49
- await utils_1.unzipFile(fs.createReadStream(zippedPortalPath), portalPath);
50
- await utils_1.deleteFile(zippedPortalPath);
51
- }
52
- cli_ux_1.default.action.stop();
53
- return portalPath;
54
- // } else {
55
- // throw new Error("Couldn't download the portal");
56
- // }
57
- };
58
- }
59
12
  async run() {
60
13
  const { flags } = this.parse(PortalGenerate);
61
14
  const zip = flags.zip;
@@ -79,8 +32,8 @@ class PortalGenerate extends command_1.Command {
79
32
  overrideAuthKey,
80
33
  zip
81
34
  };
82
- const generatedPortalPath = await this.downloadDocsPortal(generatePortalParams);
83
- this.log(`Your portal has been generated at ${generatedPortalPath}${flags.zip ? ".zip" : ""}`);
35
+ const generatedPortalPath = await generate_1.downloadDocsPortal(generatePortalParams, this.config.configDir);
36
+ this.log(`Your portal has been generated at ${generatedPortalPath}`);
84
37
  }
85
38
  catch (error) {
86
39
  cli_ux_1.default.action.stop();
@@ -7,70 +7,7 @@ const apimatic_sdk_for_js_1 = require("@apimatic/apimatic-sdk-for-js");
7
7
  const command_1 = require("@oclif/command");
8
8
  const sdk_client_1 = require("../../client-utils/sdk-client");
9
9
  const utils_1 = require("../../utils/utils");
10
- var SimplePlatforms;
11
- (function (SimplePlatforms) {
12
- SimplePlatforms["CSHARP"] = "CS_NET_STANDARD_LIB";
13
- SimplePlatforms["JAVA"] = "JAVA_ECLIPSE_JRE_LIB";
14
- SimplePlatforms["PHP"] = "PHP_GENERIC_LIB";
15
- SimplePlatforms["PYTHON"] = "PYTHON_GENERIC_LIB";
16
- SimplePlatforms["RUBY"] = "RUBY_GENERIC_LIB";
17
- SimplePlatforms["TYPESCRIPT"] = "TS_GENERIC_LIB";
18
- })(SimplePlatforms || (SimplePlatforms = {}));
19
- async function getSDKGenerationId({ file, url, platform }, sdkGenerationController) {
20
- cli_ux_1.default.action.start("Generating SDK");
21
- let generation;
22
- const sdkPlatform = getSDKPlatform(platform);
23
- if (file) {
24
- const fileDescriptor = new apimatic_sdk_for_js_1.FileWrapper(fs.createReadStream(file));
25
- generation = await sdkGenerationController.generateSDKViaFile(fileDescriptor, sdkPlatform);
26
- }
27
- else if (url) {
28
- // If url to spec file is provided
29
- const body = {
30
- url: url,
31
- template: sdkPlatform
32
- };
33
- generation = await sdkGenerationController.generateSDKViaURL(body);
34
- }
35
- else {
36
- throw new Error("Please provide a specification file");
37
- }
38
- cli_ux_1.default.action.stop();
39
- return generation.result.id;
40
- }
41
- // Get valid platform from user's input, convert simple platform to valid Platforms enum value
42
- function getSDKPlatform(platform) {
43
- if (Object.keys(SimplePlatforms).includes(platform)) {
44
- return SimplePlatforms[platform];
45
- }
46
- else if (Object.values(apimatic_sdk_for_js_1.Platforms).includes(platform)) {
47
- return platform;
48
- }
49
- else {
50
- const platforms = Object.keys(SimplePlatforms).concat(Object.values(apimatic_sdk_for_js_1.Platforms)).join("|");
51
- throw new Error(`Please provide a valid platform i.e. ${platforms}`);
52
- }
53
- }
54
- // Download Platform
55
- async function downloadGeneratedSDK({ codeGenId, zippedSDKPath, sdkFolderPath, zip }, sdkGenerationController) {
56
- cli_ux_1.default.action.start("Downloading SDK");
57
- const { result } = await sdkGenerationController.downloadSDK(codeGenId);
58
- if (result.readable) {
59
- if (!zip) {
60
- await utils_1.unzipFile(result, sdkFolderPath);
61
- cli_ux_1.default.action.stop();
62
- return sdkFolderPath;
63
- }
64
- else {
65
- await utils_1.writeFileUsingReadableStream(result, zippedSDKPath);
66
- cli_ux_1.default.action.stop();
67
- return zippedSDKPath;
68
- }
69
- }
70
- else {
71
- throw new Error("Couldn't download the SDK");
72
- }
73
- }
10
+ const generate_1 = require("../../controllers/sdk/generate");
74
11
  class SdkGenerate extends command_1.Command {
75
12
  async run() {
76
13
  const { flags } = this.parse(SdkGenerate);
@@ -95,7 +32,7 @@ class SdkGenerate extends command_1.Command {
95
32
  const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
96
33
  const sdkGenerationController = new apimatic_sdk_for_js_1.CodeGenerationExternalApisController(client);
97
34
  // Get generation id for the specification and platform
98
- const codeGenId = await getSDKGenerationId(flags, sdkGenerationController);
35
+ const codeGenId = await generate_1.getSDKGenerationId(flags, sdkGenerationController);
99
36
  // If user wanted to download the SDK as well
100
37
  const sdkDownloadParams = {
101
38
  codeGenId,
@@ -103,7 +40,7 @@ class SdkGenerate extends command_1.Command {
103
40
  sdkFolderPath,
104
41
  zip
105
42
  };
106
- const sdkPath = await downloadGeneratedSDK(sdkDownloadParams, sdkGenerationController);
43
+ const sdkPath = await generate_1.downloadGeneratedSDK(sdkDownloadParams, sdkGenerationController);
107
44
  this.log(`Success! Your SDK is located at ${sdkPath}`);
108
45
  }
109
46
  catch (error) {
@@ -0,0 +1,7 @@
1
+ import Command from "@oclif/command";
2
+ import { ApiValidationSummary, ExportFormats, Transformation, TransformationController } from "@apimatic/apimatic-sdk-for-js";
3
+ import { DownloadTransformationParams, TransformationIdParams } from "../../types/api/transform";
4
+ export declare const getTransformationId: ({ file, url, format }: TransformationIdParams, transformationController: TransformationController) => Promise<Transformation>;
5
+ export declare const downloadTransformationFile: ({ id, destinationFilePath, transformationController }: DownloadTransformationParams) => Promise<string>;
6
+ export declare const getValidFormat: (format: string) => ExportFormats;
7
+ export declare const printValidationMessages: (apiValidationSummary: ApiValidationSummary | undefined, warn: Command["warn"], error: Command["error"]) => void;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printValidationMessages = exports.getValidFormat = exports.downloadTransformationFile = exports.getTransformationId = void 0;
4
+ const cli_ux_1 = require("cli-ux");
5
+ const fs = require("fs-extra");
6
+ const apimatic_sdk_for_js_1 = require("@apimatic/apimatic-sdk-for-js");
7
+ const utils_1 = require("../../utils/utils");
8
+ exports.getTransformationId = async ({ file, url, format }, transformationController) => {
9
+ cli_ux_1.default.action.start("Transforming API specification");
10
+ let generation;
11
+ if (file) {
12
+ const fileDescriptor = new apimatic_sdk_for_js_1.FileWrapper(fs.createReadStream(file));
13
+ generation = await transformationController.transformViaFile(fileDescriptor, format);
14
+ }
15
+ else if (url) {
16
+ const body = {
17
+ url: url,
18
+ exportFormat: format
19
+ };
20
+ generation = await transformationController.transformViaURL(body);
21
+ }
22
+ else {
23
+ throw new Error("Please provide a specification file");
24
+ }
25
+ cli_ux_1.default.action.stop();
26
+ return generation.result;
27
+ };
28
+ exports.downloadTransformationFile = async ({ id, destinationFilePath, transformationController }) => {
29
+ cli_ux_1.default.action.start("Downloading Transformed file");
30
+ const { result } = await transformationController.downloadTransformedFile(id);
31
+ if (result.readable) {
32
+ await utils_1.writeFileUsingReadableStream(result, destinationFilePath);
33
+ }
34
+ else {
35
+ throw new Error("Couldn't save transformation file");
36
+ }
37
+ cli_ux_1.default.action.stop();
38
+ return destinationFilePath;
39
+ };
40
+ // Get valid platform from user's input, convert simple platform to valid Platforms enum value
41
+ exports.getValidFormat = (format) => {
42
+ if (Object.keys(apimatic_sdk_for_js_1.ExportFormats).find((exportFormat) => exportFormat === format)) {
43
+ return apimatic_sdk_for_js_1.ExportFormats[format];
44
+ }
45
+ else {
46
+ const formats = Object.keys(apimatic_sdk_for_js_1.ExportFormats).join("|");
47
+ throw new Error(`Please provide a valid platform i.e. ${formats}`);
48
+ }
49
+ };
50
+ exports.printValidationMessages = (apiValidationSummary, warn, error) => {
51
+ const warnings = (apiValidationSummary === null || apiValidationSummary === void 0 ? void 0 : apiValidationSummary.warnings) || [];
52
+ const errors = (apiValidationSummary === null || apiValidationSummary === void 0 ? void 0 : apiValidationSummary.errors.join("\n")) || "";
53
+ warnings.forEach((warning) => {
54
+ warn(utils_1.replaceHTML(warning));
55
+ });
56
+ if (apiValidationSummary && apiValidationSummary.errors.length > 0) {
57
+ error(utils_1.replaceHTML(errors));
58
+ }
59
+ };
@@ -0,0 +1,5 @@
1
+ import Command from "@oclif/command";
2
+ import { APIValidationExternalApisController, ApiValidationSummary } from "@apimatic/apimatic-sdk-for-js";
3
+ import { GetValidationParams } from "../../types/api/validate";
4
+ export declare const getValidation: ({ file, url }: GetValidationParams, apiValidationController: APIValidationExternalApisController) => Promise<ApiValidationSummary>;
5
+ export declare const printValidationMessages: ({ warnings, errors }: ApiValidationSummary, warn: Command["warn"], error: Command["error"]) => void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printValidationMessages = exports.getValidation = void 0;
4
+ const cli_ux_1 = require("cli-ux");
5
+ const fs = require("fs-extra");
6
+ const core_1 = require("@apimatic/core");
7
+ const utils_1 = require("../../utils/utils");
8
+ exports.getValidation = async ({ file, url }, apiValidationController) => {
9
+ let validation;
10
+ cli_ux_1.default.action.start("Validating specification file");
11
+ if (file) {
12
+ const fileDescriptor = new core_1.FileWrapper(fs.createReadStream(file));
13
+ validation = await apiValidationController.validateAPIViaFile(fileDescriptor);
14
+ }
15
+ else if (url) {
16
+ validation = await apiValidationController.validateAPIViaURL(url);
17
+ }
18
+ else {
19
+ throw new Error("Please provide a specification file");
20
+ }
21
+ cli_ux_1.default.action.stop();
22
+ return validation.result;
23
+ };
24
+ exports.printValidationMessages = ({ warnings, errors }, warn, error) => {
25
+ warnings.forEach((warning) => {
26
+ warn(`${utils_1.replaceHTML(warning)}`);
27
+ });
28
+ if (errors.length > 0) {
29
+ const singleLineError = errors.join("\n");
30
+ error(utils_1.replaceHTML(singleLineError));
31
+ }
32
+ };
@@ -0,0 +1,2 @@
1
+ import { GeneratePortalParams } from "../../types/portal/generate";
2
+ export declare const downloadDocsPortal: ({ zippedBuildFilePath, generatedPortalFolderPath, overrideAuthKey, zip }: GeneratePortalParams, configDir: string) => Promise<string>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.downloadDocsPortal = void 0;
4
+ const fs = require("fs-extra");
5
+ const FormData = require("form-data");
6
+ const path = require("path");
7
+ const cli_ux_1 = require("cli-ux");
8
+ const auth_manager_1 = require("../../client-utils/auth-manager");
9
+ const env_1 = require("../../config/env");
10
+ const utils_1 = require("../../utils/utils");
11
+ const axios_1 = require("axios");
12
+ // TODO: Remove after SDK is patched
13
+ const downloadPortalAxios = async (zippedBuildFilePath, overrideAuthKey, configDir) => {
14
+ const formData = new FormData();
15
+ const authInfo = await auth_manager_1.getAuthInfo(configDir);
16
+ formData.append("file", fs.createReadStream(zippedBuildFilePath));
17
+ const config = {
18
+ headers: Object.assign({ Authorization: authInfo ? `X-Auth-Key ${overrideAuthKey || authInfo.authKey.trim()}` : "", "Content-Type": "multipart/form-data" }, formData.getHeaders()),
19
+ responseType: "arraybuffer"
20
+ };
21
+ const { data } = await axios_1.default.post(`${env_1.baseURL}/portal`, formData, config);
22
+ return data;
23
+ };
24
+ // Download Docs Portal
25
+ exports.downloadDocsPortal = async ({ zippedBuildFilePath, generatedPortalFolderPath, overrideAuthKey, zip }, configDir) => {
26
+ const zippedPortalPath = path.join(generatedPortalFolderPath, "generated_portal.zip");
27
+ const portalPath = path.join(generatedPortalFolderPath, "generated_portal");
28
+ cli_ux_1.default.action.start("Downloading portal");
29
+ // Check if the build file exists for the user or not
30
+ if (!(await fs.pathExists(zippedBuildFilePath))) {
31
+ throw new Error("Build file doesn't exist");
32
+ }
33
+ // TODO: ***CRITICAL*** Remove this call once the SDK is patched
34
+ const data = await downloadPortalAxios(zippedBuildFilePath, overrideAuthKey, configDir);
35
+ await utils_1.deleteFile(zippedBuildFilePath);
36
+ await fs.writeFile(zippedPortalPath, data);
37
+ // TODO: Uncomment this code block when the SDK is patched
38
+ // const file: FileWrapper = new FileWrapper(fs.createReadStream(zippedBuildFilePath));
39
+ // const { result }: ApiResponse<NodeJS.ReadableStream | Blob> =
40
+ // await docsPortalController.generateOnPremPortalViaBuildInput(file);
41
+ // if ((data as NodeJS.ReadableStream).readable) {
42
+ // await writeFileUsingReadableStream(data as NodeJS.ReadableStream, zippedPortalPath);
43
+ if (!zip) {
44
+ await utils_1.unzipFile(fs.createReadStream(zippedPortalPath), portalPath);
45
+ await utils_1.deleteFile(zippedPortalPath);
46
+ }
47
+ cli_ux_1.default.action.stop();
48
+ return zip ? zippedPortalPath : portalPath;
49
+ // } else {
50
+ // throw new Error("Couldn't download the portal");
51
+ // }
52
+ };
@@ -0,0 +1,4 @@
1
+ import { CodeGenerationExternalApisController } from "@apimatic/apimatic-sdk-for-js";
2
+ import { GenerationIdParams, DownloadSDKParams } from "../../types/sdk/generate";
3
+ export declare const getSDKGenerationId: ({ file, url, platform }: GenerationIdParams, sdkGenerationController: CodeGenerationExternalApisController) => Promise<string>;
4
+ export declare const downloadGeneratedSDK: ({ codeGenId, zippedSDKPath, sdkFolderPath, zip }: DownloadSDKParams, sdkGenerationController: CodeGenerationExternalApisController) => Promise<string>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.downloadGeneratedSDK = exports.getSDKGenerationId = void 0;
4
+ const fs = require("fs-extra");
5
+ const cli_ux_1 = require("cli-ux");
6
+ const apimatic_sdk_for_js_1 = require("@apimatic/apimatic-sdk-for-js");
7
+ const core_1 = require("@apimatic/core");
8
+ const generate_1 = require("../../types/sdk/generate");
9
+ const utils_1 = require("../../utils/utils");
10
+ exports.getSDKGenerationId = async ({ file, url, platform }, sdkGenerationController) => {
11
+ cli_ux_1.default.action.start("Generating SDK");
12
+ let generation;
13
+ const sdkPlatform = getSDKPlatform(platform);
14
+ if (file) {
15
+ const fileDescriptor = new core_1.FileWrapper(fs.createReadStream(file));
16
+ generation = await sdkGenerationController.generateSDKViaFile(fileDescriptor, sdkPlatform);
17
+ }
18
+ else if (url) {
19
+ // If url to spec file is provided
20
+ const body = {
21
+ url: url,
22
+ template: sdkPlatform
23
+ };
24
+ generation = await sdkGenerationController.generateSDKViaURL(body);
25
+ }
26
+ else {
27
+ throw new Error("Please provide a specification file");
28
+ }
29
+ cli_ux_1.default.action.stop();
30
+ return generation.result.id;
31
+ };
32
+ // Get valid platform from user's input, convert simple platform to valid Platforms enum value
33
+ const getSDKPlatform = (platform) => {
34
+ if (Object.keys(generate_1.SimplePlatforms).includes(platform)) {
35
+ return generate_1.SimplePlatforms[platform];
36
+ }
37
+ else if (Object.values(apimatic_sdk_for_js_1.Platforms).includes(platform)) {
38
+ return platform;
39
+ }
40
+ else {
41
+ const platforms = Object.keys(generate_1.SimplePlatforms).concat(Object.values(apimatic_sdk_for_js_1.Platforms)).join("|");
42
+ throw new Error(`Please provide a valid platform i.e. ${platforms}`);
43
+ }
44
+ };
45
+ // Download Platform
46
+ exports.downloadGeneratedSDK = async ({ codeGenId, zippedSDKPath, sdkFolderPath, zip }, sdkGenerationController) => {
47
+ cli_ux_1.default.action.start("Downloading SDK");
48
+ const { result } = await sdkGenerationController.downloadSDK(codeGenId);
49
+ if (result.readable) {
50
+ if (!zip) {
51
+ await utils_1.unzipFile(result, sdkFolderPath);
52
+ cli_ux_1.default.action.stop();
53
+ return sdkFolderPath;
54
+ }
55
+ else {
56
+ await utils_1.writeFileUsingReadableStream(result, zippedSDKPath);
57
+ cli_ux_1.default.action.stop();
58
+ return zippedSDKPath;
59
+ }
60
+ }
61
+ else {
62
+ throw new Error("Couldn't download the SDK");
63
+ }
64
+ };
@@ -0,0 +1,33 @@
1
+ /// <reference types="node" />
2
+ import { TransformationController } from "@apimatic/apimatic-sdk-for-js";
3
+ export declare type AuthenticationError = {
4
+ statusCode: number;
5
+ body: string;
6
+ };
7
+ export declare type TransformationIdParams = {
8
+ file: string;
9
+ url: string;
10
+ format: string;
11
+ };
12
+ export declare type DownloadTransformationParams = {
13
+ id: string;
14
+ destinationFilePath: string;
15
+ transformationController: TransformationController;
16
+ };
17
+ export declare type TransformationData = {
18
+ result: NodeJS.ReadableStream | Blob;
19
+ };
20
+ export declare const DestinationFormats: {
21
+ OpenApi3Json: string;
22
+ OpenApi3Yaml: string;
23
+ APIMATIC: string;
24
+ WADL2009: string;
25
+ WSDL: string;
26
+ Swagger10: string;
27
+ Swagger20: string;
28
+ SwaggerYaml: string;
29
+ RAML: string;
30
+ RAML10: string;
31
+ Postman10: string;
32
+ Postman20: string;
33
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DestinationFormats = void 0;
4
+ exports.DestinationFormats = {
5
+ OpenApi3Json: "json",
6
+ OpenApi3Yaml: "yaml",
7
+ APIMATIC: "json",
8
+ WADL2009: "xml",
9
+ WSDL: "xml",
10
+ Swagger10: "json",
11
+ Swagger20: "json",
12
+ SwaggerYaml: "yaml",
13
+ RAML: "yaml",
14
+ RAML10: "yaml",
15
+ Postman10: "json",
16
+ Postman20: "json"
17
+ };
@@ -0,0 +1,12 @@
1
+ export declare type GetValidationParams = {
2
+ file: string;
3
+ url: string;
4
+ };
5
+ export declare type APIValidateError = {
6
+ modelState: {
7
+ "exception Error": string[];
8
+ };
9
+ };
10
+ export declare type AuthorizationError = {
11
+ body: string;
12
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { DocsPortalManagementController } from "@apimatic/apimatic-sdk-for-js";
2
+ export declare type GeneratePortalParams = {
3
+ zippedBuildFilePath: string;
4
+ generatedPortalFolderPath: string;
5
+ docsPortalController: DocsPortalManagementController;
6
+ overrideAuthKey: string | null;
7
+ zip: boolean;
8
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ export declare type GenerationIdParams = {
2
+ file: string;
3
+ url: string;
4
+ platform: string;
5
+ };
6
+ export declare type DownloadSDKParams = {
7
+ codeGenId: string;
8
+ zip: boolean;
9
+ zippedSDKPath: string;
10
+ sdkFolderPath: string;
11
+ };
12
+ export declare type SDKGenerateUnprocessableError = {
13
+ message: string;
14
+ };
15
+ export declare enum SimplePlatforms {
16
+ CSHARP = "CS_NET_STANDARD_LIB",
17
+ JAVA = "JAVA_ECLIPSE_JRE_LIB",
18
+ PHP = "PHP_GENERIC_LIB",
19
+ PYTHON = "PYTHON_GENERIC_LIB",
20
+ RUBY = "RUBY_GENERIC_LIB",
21
+ TYPESCRIPT = "TS_GENERIC_LIB"
22
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SimplePlatforms = void 0;
4
+ var SimplePlatforms;
5
+ (function (SimplePlatforms) {
6
+ SimplePlatforms["CSHARP"] = "CS_NET_STANDARD_LIB";
7
+ SimplePlatforms["JAVA"] = "JAVA_ECLIPSE_JRE_LIB";
8
+ SimplePlatforms["PHP"] = "PHP_GENERIC_LIB";
9
+ SimplePlatforms["PYTHON"] = "PYTHON_GENERIC_LIB";
10
+ SimplePlatforms["RUBY"] = "RUBY_GENERIC_LIB";
11
+ SimplePlatforms["TYPESCRIPT"] = "TS_GENERIC_LIB";
12
+ })(SimplePlatforms = exports.SimplePlatforms || (exports.SimplePlatforms = {}));
@@ -1 +1 @@
1
- {"version":"1.0.1-alpha.1","commands":{"api":{"id":"api","description":"lists all commands related to the APIMatic API.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api --help"],"flags":{},"args":[]},"api:transform":{"id":"api:transform","description":"Transforms your API specification to any supported format of your choice from amongst[10+ different formats](https://www.apimatic.io/transformer/#supported-formats).","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api:transform --format=\"OpenApi3Json\" --file=\"./specs/sample.json\" --destination=\"D:/\"\nSuccess! Your transformed file is located at D:/Transformed_OpenApi3Json.json\n"],"flags":{"format":{"name":"format","type":"option","description":"specification format to transform API specification into\n(OpenApi3Json|OpenApi3Yaml|APIMATIC|WADL2009|WADL2006|WSDL|\nSwagger10|Swagger20|SwaggerYaml|RAML|RAML10|Postman10|Postman20)","required":true},"file":{"name":"file","type":"option","description":"path to the API specification file to transform","default":""},"url":{"name":"url","type":"option","description":"URL to the API specification file to transform","default":""},"destination":{"name":"destination","type":"option","description":"path to transformed file","default":"/home/runner/work/apimatic-cli/apimatic-cli/cli/src/commands/api"},"auth-key":{"name":"auth-key","type":"option","description":"override current auth-key"}},"args":[]},"api:validate":{"id":"api:validate","description":"Validates the provided API specification file for any syntactical and semantic errors","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api:validate --file=\"./specs/sample.json\"\nSpecification file provided is valid\n"],"flags":{"file":{"name":"file","type":"option","description":"path to the API specification file to validate","default":""},"url":{"name":"url","type":"option","description":"URL to the specification file to validate","default":""},"auth-key":{"name":"auth-key","type":"option","description":"override current auth-key"}},"args":[]},"auth":{"id":"auth","description":"invokes subcommands related to authentication.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth --help"],"flags":{},"args":[]},"auth:login":{"id":"auth:login","description":"login to your APIMatic account","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:login\nPlease enter your registered email: apimatic-user@gmail.com\nPlease enter your password: *********\n\nYou have successfully logged into APIMatic\n"],"flags":{"auth-key":{"name":"auth-key","type":"option","description":"Set authentication key for all commands","default":""}},"args":[]},"auth:logout":{"id":"auth:logout","description":"logout of APIMatic","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:logout\nLogged out\n"],"flags":{},"args":[]},"auth:status":{"id":"auth:status","description":"checks current logged-in account","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:status\nCurrently logged in as apimatic-client@gmail.com\n"],"flags":{},"args":[]},"portal:generate":{"id":"portal:generate","description":"Generate static docs portal on premise","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic portal:generate --folder=\"./portal/\" --destination=\"D:/\"\nYour portal has been generated at D:/\n"],"flags":{"folder":{"name":"folder","type":"option","description":"folder to generate the portal with","default":""},"destination":{"name":"destination","type":"option","description":"path to the downloaded portal","default":"./"},"zip":{"name":"zip","type":"boolean","description":"zip the portal","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current auth-key","default":""}},"args":[]},"portal":{"id":"portal","description":"invokes subcommands related to the API Portal.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$apimatic portal --help"],"flags":{},"args":[]},"sdk:generate":{"id":"sdk:generate","description":"Generate SDK for your APIs","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic sdk:generate --platform=\"CSHARP\" --file=\"./specs/sample.json\"\nSDK generated successfully\n"],"flags":{"platform":{"name":"platform","type":"option","description":"language platform for sdk\nSimple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT\nLegacy: CS_NET_STANDARD_LIB|CS_PORTABLE_NET_LIB|CS_UNIVERSAL_WINDOWS_PLATFORM_LIB|\n JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB|PYTHON_GENERIC_LIB|RUBY_GENERIC_LIB|\n TS_GENERIC_LIB","required":true},"file":{"name":"file","type":"option","description":"path to the API specification to generate SDK","default":""},"url":{"name":"url","type":"option","description":"URL to the API specification to generate SDK","default":""},"destination":{"name":"destination","type":"option","description":"path to downloaded SDK (used with download flag)","default":"./"},"zip":{"name":"zip","type":"boolean","description":"zip the SDK (used with download flag)","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current auth-key","default":""}},"args":[]},"sdk":{"id":"sdk","description":"invokes subcommands related to your SDKs.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$apimatic sdk --help"],"flags":{},"args":[]}}}
1
+ {"version":"1.0.1-alpha.2","commands":{"api":{"id":"api","description":"lists all commands related to the APIMatic API.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api --help"],"flags":{},"args":[]},"api:transform":{"id":"api:transform","description":"Transforms your API specification to any supported format of your choice from amongst[10+ different formats](https://www.apimatic.io/transformer/#supported-formats).","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api:transform --format=\"OpenApi3Json\" --file=\"./specs/sample.json\" --destination=\"D:/\"\nSuccess! Your transformed file is located at D:/Transformed_OpenApi3Json.json\n"],"flags":{"format":{"name":"format","type":"option","description":"specification format to transform API specification into\n(OpenApi3Json|OpenApi3Yaml|APIMATIC|WADL2009|WADL2006|WSDL|\nSwagger10|Swagger20|SwaggerYaml|RAML|RAML10|Postman10|Postman20)","required":true},"file":{"name":"file","type":"option","description":"path to the API specification file to transform","default":""},"url":{"name":"url","type":"option","description":"URL to the API specification file to transform","default":""},"destination":{"name":"destination","type":"option","description":"path to transformed file","default":"/home/runner/work/apimatic-cli/apimatic-cli/cli/src/commands/api"},"auth-key":{"name":"auth-key","type":"option","description":"override current auth-key"}},"args":[]},"api:validate":{"id":"api:validate","description":"Validates the provided API specification file for any syntactical and semantic errors","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api:validate --file=\"./specs/sample.json\"\nSpecification file provided is valid\n"],"flags":{"file":{"name":"file","type":"option","description":"path to the API specification file to validate","default":""},"url":{"name":"url","type":"option","description":"URL to the specification file to validate","default":""},"auth-key":{"name":"auth-key","type":"option","description":"override current auth-key"}},"args":[]},"auth":{"id":"auth","description":"invokes subcommands related to authentication.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth --help"],"flags":{},"args":[]},"auth:login":{"id":"auth:login","description":"login to your APIMatic account","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:login\nPlease enter your registered email: apimatic-user@gmail.com\nPlease enter your password: *********\n\nYou have successfully logged into APIMatic\n"],"flags":{"auth-key":{"name":"auth-key","type":"option","description":"Set authentication key for all commands","default":""}},"args":[]},"auth:logout":{"id":"auth:logout","description":"logout of APIMatic","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:logout\nLogged out\n"],"flags":{},"args":[]},"auth:status":{"id":"auth:status","description":"checks current logged-in account","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:status\nCurrently logged in as apimatic-client@gmail.com\n"],"flags":{},"args":[]},"portal:generate":{"id":"portal:generate","description":"Generate static docs portal on premise","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic portal:generate --folder=\"./portal/\" --destination=\"D:/\"\nYour portal has been generated at D:/\n"],"flags":{"folder":{"name":"folder","type":"option","description":"folder to generate the portal with","default":""},"destination":{"name":"destination","type":"option","description":"path to the downloaded portal","default":"./"},"zip":{"name":"zip","type":"boolean","description":"zip the portal","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current auth-key","default":""}},"args":[]},"portal":{"id":"portal","description":"invokes subcommands related to the API Portal.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$apimatic portal --help"],"flags":{},"args":[]},"sdk:generate":{"id":"sdk:generate","description":"Generate SDK for your APIs","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic sdk:generate --platform=\"CSHARP\" --file=\"./specs/sample.json\"\nSDK generated successfully\n"],"flags":{"platform":{"name":"platform","type":"option","description":"language platform for sdk\nSimple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT\nLegacy: CS_NET_STANDARD_LIB|CS_PORTABLE_NET_LIB|CS_UNIVERSAL_WINDOWS_PLATFORM_LIB|\n JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB|PYTHON_GENERIC_LIB|RUBY_GENERIC_LIB|\n TS_GENERIC_LIB","required":true},"file":{"name":"file","type":"option","description":"path to the API specification to generate SDK","default":""},"url":{"name":"url","type":"option","description":"URL to the API specification to generate SDK","default":""},"destination":{"name":"destination","type":"option","description":"path to downloaded SDK (used with download flag)","default":"./"},"zip":{"name":"zip","type":"boolean","description":"zip the SDK (used with download flag)","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current auth-key","default":""}},"args":[]},"sdk":{"id":"sdk","description":"invokes subcommands related to your SDKs.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$apimatic sdk --help"],"flags":{},"args":[]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apimatic/cli",
3
3
  "description": "The official CLI for APIMatic.",
4
- "version": "1.0.1-alpha.1",
4
+ "version": "1.0.1-alpha.2",
5
5
  "author": "APIMatic",
6
6
  "bin": {
7
7
  "apimatic": "./bin/run"