@apimatic/cli 1.0.1-alpha.4 → 1.0.1-alpha.5

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/README.md CHANGED
@@ -16,7 +16,7 @@ $ npm install -g @apimatic/cli
16
16
  $ apimatic COMMAND
17
17
  running command...
18
18
  $ apimatic (-v|--version|version)
19
- @apimatic/cli/1.0.1-alpha.4 linux-x64 node-v14.18.1
19
+ @apimatic/cli/1.0.1-alpha.5 linux-x64 node-v16.13.0
20
20
  $ apimatic --help [COMMAND]
21
21
  USAGE
22
22
  $ apimatic COMMAND
@@ -51,7 +51,7 @@ EXAMPLE
51
51
  $ apimatic api --help
52
52
  ```
53
53
 
54
- _See code: [src/commands/api/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/api/index.ts)_
54
+ _See code: [src/commands/api/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/api/index.ts)_
55
55
 
56
56
  ## `apimatic api:transform`
57
57
 
@@ -62,6 +62,7 @@ USAGE
62
62
  $ apimatic api:transform
63
63
 
64
64
  OPTIONS
65
+ -f, --force overwrite if same file exist in the destination
65
66
  --auth-key=auth-key override current authentication state with an authentication key
66
67
  --destination=destination [default: ./] directory to download transformed file to
67
68
  --file=file path to the API specification file to transform
@@ -81,7 +82,7 @@ EXAMPLES
81
82
  Success! Your transformed file is located at D:/swagger_raml.yaml
82
83
  ```
83
84
 
84
- _See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/api/transform.ts)_
85
+ _See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/api/transform.ts)_
85
86
 
86
87
  ## `apimatic api:validate`
87
88
 
@@ -106,7 +107,7 @@ EXAMPLES
106
107
  Specification file provided is valid
107
108
  ```
108
109
 
109
- _See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/api/validate.ts)_
110
+ _See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/api/validate.ts)_
110
111
 
111
112
  ## `apimatic auth`
112
113
 
@@ -120,7 +121,7 @@ EXAMPLE
120
121
  $ apimatic auth --help
121
122
  ```
122
123
 
123
- _See code: [src/commands/auth/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/auth/index.ts)_
124
+ _See code: [src/commands/auth/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/auth/index.ts)_
124
125
 
125
126
  ## `apimatic auth:login`
126
127
 
@@ -144,7 +145,7 @@ EXAMPLES
144
145
  Authentication key successfully set
145
146
  ```
146
147
 
147
- _See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/auth/login.ts)_
148
+ _See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/auth/login.ts)_
148
149
 
149
150
  ## `apimatic auth:logout`
150
151
 
@@ -159,7 +160,7 @@ EXAMPLE
159
160
  Logged out
160
161
  ```
161
162
 
162
- _See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/auth/logout.ts)_
163
+ _See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/auth/logout.ts)_
163
164
 
164
165
  ## `apimatic auth:status`
165
166
 
@@ -174,7 +175,7 @@ EXAMPLE
174
175
  Currently logged in as apimatic-client@gmail.com
175
176
  ```
176
177
 
177
- _See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/auth/status.ts)_
178
+ _See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/auth/status.ts)_
178
179
 
179
180
  ## `apimatic autocomplete [SHELL]`
180
181
 
@@ -214,7 +215,7 @@ OPTIONS
214
215
  --all see all commands in CLI
215
216
  ```
216
217
 
217
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.9/src/commands/help.ts)_
218
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.10/src/commands/help.ts)_
218
219
 
219
220
  ## `apimatic portal`
220
221
 
@@ -228,7 +229,7 @@ EXAMPLE
228
229
  $apimatic portal --help
229
230
  ```
230
231
 
231
- _See code: [src/commands/portal/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/portal/index.ts)_
232
+ _See code: [src/commands/portal/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/portal/index.ts)_
232
233
 
233
234
  ## `apimatic portal:generate`
234
235
 
@@ -239,6 +240,7 @@ USAGE
239
240
  $ apimatic portal:generate
240
241
 
241
242
  OPTIONS
243
+ -f, --force overwrite if a portal exists in the destination
242
244
  --auth-key=auth-key override current authentication state with an authentication key
243
245
  --destination=destination [default: ./] path to the downloaded portal
244
246
  --folder=folder path to the input directory containing API specifications and config files
@@ -249,7 +251,7 @@ EXAMPLE
249
251
  Your portal has been generated at D:/
250
252
  ```
251
253
 
252
- _See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/portal/generate.ts)_
254
+ _See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/portal/generate.ts)_
253
255
 
254
256
  ## `apimatic sdk`
255
257
 
@@ -263,7 +265,7 @@ EXAMPLE
263
265
  $apimatic sdk --help
264
266
  ```
265
267
 
266
- _See code: [src/commands/sdk/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/sdk/index.ts)_
268
+ _See code: [src/commands/sdk/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/sdk/index.ts)_
267
269
 
268
270
  ## `apimatic sdk:generate`
269
271
 
@@ -274,6 +276,7 @@ USAGE
274
276
  $ apimatic sdk:generate
275
277
 
276
278
  OPTIONS
279
+ -f, --force overwrite if an SDK already exists in the destination
277
280
  --auth-key=auth-key override current authentication state with an authentication key
278
281
  --destination=destination [default: ./] directory to download the generated SDK to
279
282
  --file=file path to the API specification to generate SDKs for
@@ -300,5 +303,5 @@ EXAMPLES
300
303
  Success! Your SDK is located at swagger_sdk_csharp
301
304
  ```
302
305
 
303
- _See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.4/src/commands/sdk/generate.ts)_
306
+ _See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.5/src/commands/sdk/generate.ts)_
304
307
  <!-- commandsstop -->
@@ -1,4 +1,4 @@
1
- import { Client } from "@apimatic/js-sdk";
1
+ import { Client } from "@apimatic/sdk";
2
2
  export declare class SDKClient {
3
3
  private static instance;
4
4
  private static authAPI;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDKClient = void 0;
4
4
  const base64 = require("base-64");
5
5
  const axios_1 = require("axios");
6
- const js_sdk_1 = require("@apimatic/js-sdk");
6
+ const sdk_1 = require("@apimatic/sdk");
7
7
  const auth_manager_1 = require("./auth-manager");
8
8
  const env_1 = require("../config/env");
9
9
  class SDKClient {
@@ -84,7 +84,7 @@ class SDKClient {
84
84
  }
85
85
  async getClient(overrideAuthKey, configDir) {
86
86
  if (overrideAuthKey) {
87
- return new js_sdk_1.Client({
87
+ return new sdk_1.Client({
88
88
  timeout: 0,
89
89
  authorization: `X-Auth-Key ${overrideAuthKey}`
90
90
  });
@@ -95,7 +95,7 @@ class SDKClient {
95
95
  storedAuthInfo = { email: "", authKey: "" };
96
96
  }
97
97
  if (storedAuthInfo.authKey !== "") {
98
- return new js_sdk_1.Client({
98
+ return new sdk_1.Client({
99
99
  timeout: 0,
100
100
  authorization: `X-Auth-Key ${storedAuthInfo.authKey}`
101
101
  });
@@ -7,6 +7,7 @@ export default class Transform extends Command {
7
7
  file: flags.IOptionFlag<string>;
8
8
  url: flags.IOptionFlag<string>;
9
9
  destination: flags.IOptionFlag<string>;
10
+ force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
11
  "auth-key": flags.IOptionFlag<string | undefined>;
11
12
  };
12
13
  run(): Promise<void>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const fs = require("fs-extra");
4
4
  const path = require("path");
5
5
  const cli_ux_1 = require("cli-ux");
6
- const js_sdk_1 = require("@apimatic/js-sdk");
6
+ const sdk_1 = require("@apimatic/sdk");
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");
@@ -15,10 +15,12 @@ class Transform extends command_1.Command {
15
15
  const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
16
16
  const destinationFormat = transform_1.DestinationFormats[flags.format];
17
17
  const destinationFilePath = path.join(flags.destination, `${fileName}_${flags.format}.${destinationFormat}`.toLowerCase());
18
- if (fs.existsSync(destinationFilePath)) {
18
+ // Check if destination file already exist and throw error if force flag is not set
19
+ if (fs.existsSync(destinationFilePath) && !flags.force) {
19
20
  throw new Error(`Can't download transformed file to path ${destinationFilePath}, because it already exists`);
20
21
  }
21
22
  try {
23
+ // Check if paths provided are valid
22
24
  if (flags.file && !(await fs.pathExists(flags.file))) {
23
25
  throw new Error(`Transformation file: ${flags.file} does not exist`);
24
26
  }
@@ -27,7 +29,7 @@ class Transform extends command_1.Command {
27
29
  }
28
30
  const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
29
31
  const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
30
- const transformationController = new js_sdk_1.TransformationController(client);
32
+ const transformationController = new sdk_1.TransformationController(client);
31
33
  const { id, apiValidationSummary } = await transform_2.getTransformationId(flags, transformationController);
32
34
  transform_2.printValidationMessages(apiValidationSummary, this.warn, this.error);
33
35
  const savedTransformationFile = await transform_2.downloadTransformationFile({
@@ -92,5 +94,6 @@ Swagger10|Swagger20|SwaggerYaml|RAML|RAML10|Postman10|Postman20)`
92
94
  description: "URL to the API specification file to transform. Can be used in place of the --file option if the API specification is publicly available."
93
95
  }),
94
96
  destination: command_1.flags.string({ default: "./", description: "directory to download transformed file to" }),
97
+ force: command_1.flags.boolean({ char: "f", default: false, description: "overwrite if same file exist in the destination" }),
95
98
  "auth-key": command_1.flags.string({ description: "override current authentication state with an authentication key" })
96
99
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const fs = require("fs-extra");
4
- const js_sdk_1 = require("@apimatic/js-sdk");
4
+ const sdk_1 = require("@apimatic/sdk");
5
5
  const command_1 = require("@oclif/command");
6
6
  const sdk_client_1 = require("../../client-utils/sdk-client");
7
7
  const utils_1 = require("../../utils/utils");
@@ -16,7 +16,7 @@ class Validate extends command_1.Command {
16
16
  }
17
17
  const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
18
18
  const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
19
- const apiValidationController = new js_sdk_1.APIValidationExternalApisController(client);
19
+ const apiValidationController = new sdk_1.APIValidationExternalApisController(client);
20
20
  const validationSummary = await validate_1.getValidation(flags, apiValidationController);
21
21
  transform_1.printValidationMessages(validationSummary, this.warn, this.error);
22
22
  validationSummary.success
@@ -4,6 +4,7 @@ export default class PortalGenerate extends Command {
4
4
  static flags: {
5
5
  folder: flags.IOptionFlag<string>;
6
6
  destination: flags.IOptionFlag<string>;
7
+ force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
7
8
  zip: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
9
  "auth-key": flags.IOptionFlag<string>;
9
10
  };
@@ -4,7 +4,7 @@ const fs = require("fs-extra");
4
4
  const path = require("path");
5
5
  const cli_ux_1 = require("cli-ux");
6
6
  const command_1 = require("@oclif/command");
7
- const js_sdk_1 = require("@apimatic/js-sdk");
7
+ const sdk_1 = require("@apimatic/sdk");
8
8
  const sdk_client_1 = require("../../client-utils/sdk-client");
9
9
  const generate_1 = require("../../controllers/portal/generate");
10
10
  const utils_1 = require("../../utils/utils");
@@ -12,9 +12,17 @@ class PortalGenerate extends command_1.Command {
12
12
  async run() {
13
13
  const { flags } = this.parse(PortalGenerate);
14
14
  const zip = flags.zip;
15
- const portalFolderPath = flags.folder;
16
- const generatedPortalFolderPath = flags.destination;
15
+ const sourceFolderPath = flags.folder;
16
+ const portalFolderPath = path.join(flags.destination, "generated_portal");
17
+ const zippedPortalPath = path.join(flags.destination, "generated_portal.zip");
17
18
  const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
19
+ // Check if at destination, portal already exists and throw error if force flag is not set for both zip and extracted
20
+ if (fs.existsSync(portalFolderPath) && !flags.force && !zip) {
21
+ throw new Error(`Can't download portal to path ${portalFolderPath}, because it already exists`);
22
+ }
23
+ else if (fs.existsSync(zippedPortalPath) && !flags.force && zip) {
24
+ throw new Error(`Can't download portal to path ${zippedPortalPath}, because it already exists`);
25
+ }
18
26
  try {
19
27
  if (!(await fs.pathExists(flags.destination))) {
20
28
  throw new Error(`Destination path ${flags.destination} does not exist`);
@@ -23,11 +31,12 @@ class PortalGenerate extends command_1.Command {
23
31
  throw new Error(`Portal build folder ${flags.folder} does not exist`);
24
32
  }
25
33
  const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
26
- const docsPortalController = new js_sdk_1.DocsPortalManagementController(client);
27
- const zippedBuildFilePath = await utils_1.zipDirectory(portalFolderPath, generatedPortalFolderPath);
34
+ const docsPortalController = new sdk_1.DocsPortalManagementController(client);
35
+ const zippedBuildFilePath = await utils_1.zipDirectory(sourceFolderPath, flags.destination);
28
36
  const generatePortalParams = {
29
37
  zippedBuildFilePath,
30
- generatedPortalFolderPath,
38
+ portalFolderPath,
39
+ zippedPortalPath,
31
40
  docsPortalController,
32
41
  overrideAuthKey,
33
42
  zip
@@ -81,6 +90,7 @@ PortalGenerate.flags = {
81
90
  default: "./",
82
91
  description: "path to the downloaded portal"
83
92
  }),
93
+ force: command_1.flags.boolean({ char: "f", default: false, description: "overwrite if a portal exists in the destination" }),
84
94
  zip: command_1.flags.boolean({ default: false, description: "download the generated portal as a .zip archive" }),
85
95
  "auth-key": command_1.flags.string({
86
96
  default: "",
@@ -6,6 +6,7 @@ export default class SdkGenerate extends Command {
6
6
  file: flags.IOptionFlag<string>;
7
7
  url: flags.IOptionFlag<string>;
8
8
  destination: flags.IOptionFlag<string>;
9
+ force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
10
  zip: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
11
  "auth-key": flags.IOptionFlag<string>;
11
12
  };
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const fs = require("fs-extra");
4
4
  const path = require("path");
5
5
  const cli_ux_1 = require("cli-ux");
6
- const js_sdk_1 = require("@apimatic/js-sdk");
6
+ const sdk_1 = require("@apimatic/sdk");
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");
@@ -12,6 +12,16 @@ class SdkGenerate extends command_1.Command {
12
12
  async run() {
13
13
  const { flags } = this.parse(SdkGenerate);
14
14
  const zip = flags.zip;
15
+ const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
16
+ const sdkFolderPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}`.toLowerCase());
17
+ const zippedSDKPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}.zip`.toLowerCase());
18
+ // Check if at destination, SDK already exists and throw error if force flag is not set for both zip and extracted
19
+ if (fs.existsSync(sdkFolderPath) && !flags.force && !zip) {
20
+ throw new Error(`Can't download SDK to path ${sdkFolderPath}, because it already exists`);
21
+ }
22
+ else if (fs.existsSync(zippedSDKPath) && !flags.force && zip) {
23
+ throw new Error(`Can't download SDK to path ${zippedSDKPath}, because it already exists`);
24
+ }
15
25
  try {
16
26
  if (!(await fs.pathExists(path.resolve(flags.destination)))) {
17
27
  throw new Error(`Destination path ${flags.destination} does not exist`);
@@ -19,18 +29,9 @@ class SdkGenerate extends command_1.Command {
19
29
  else if (!(await fs.pathExists(path.resolve(flags.file)))) {
20
30
  throw new Error(`Specification file ${flags.file} does not exist`);
21
31
  }
22
- const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
23
- const sdkFolderPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}`.toLowerCase());
24
- const zippedSDKPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}.zip`.toLowerCase());
25
- if (fs.existsSync(zippedSDKPath) && zip) {
26
- throw new Error(`Can't generate SDK to path ${zippedSDKPath}, because it already exists`);
27
- }
28
- else if (fs.existsSync(sdkFolderPath) && !zip) {
29
- throw new Error(`Can't generate SDK to path ${sdkFolderPath}, because it already exists`);
30
- }
31
32
  const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
32
33
  const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
33
- const sdkGenerationController = new js_sdk_1.CodeGenerationExternalApisController(client);
34
+ const sdkGenerationController = new sdk_1.CodeGenerationExternalApisController(client);
34
35
  // Get generation id for the specification and platform
35
36
  const codeGenId = await generate_1.getSDKGenerationId(flags, sdkGenerationController);
36
37
  // If user wanted to download the SDK as well
@@ -105,6 +106,11 @@ Legacy: CS_NET_STANDARD_LIB|CS_PORTABLE_NET_LIB|CS_UNIVERSAL_WINDOWS_PLATFORM_LI
105
106
  default: "./",
106
107
  description: "directory to download the generated SDK to"
107
108
  }),
109
+ force: command_1.flags.boolean({
110
+ char: "f",
111
+ default: false,
112
+ description: "overwrite if an SDK already exists in the destination"
113
+ }),
108
114
  zip: command_1.flags.boolean({ default: false, description: "download the generated SDK as a .zip archive" }),
109
115
  "auth-key": command_1.flags.string({
110
116
  default: "",
@@ -1,5 +1,5 @@
1
1
  import Command from "@oclif/command";
2
- import { ApiValidationSummary, ExportFormats, Transformation, TransformationController } from "@apimatic/js-sdk";
2
+ import { ApiValidationSummary, ExportFormats, Transformation, TransformationController } from "@apimatic/sdk";
3
3
  import { DownloadTransformationParams, TransformationIdParams } from "../../types/api/transform";
4
4
  export declare const getTransformationId: ({ file, url, format }: TransformationIdParams, transformationController: TransformationController) => Promise<Transformation>;
5
5
  export declare const downloadTransformationFile: ({ id, destinationFilePath, transformationController }: DownloadTransformationParams) => Promise<string>;
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.printValidationMessages = exports.getValidFormat = exports.downloadTransformationFile = exports.getTransformationId = void 0;
4
4
  const cli_ux_1 = require("cli-ux");
5
5
  const fs = require("fs-extra");
6
- const js_sdk_1 = require("@apimatic/js-sdk");
6
+ const sdk_1 = require("@apimatic/sdk");
7
7
  const utils_1 = require("../../utils/utils");
8
8
  exports.getTransformationId = async ({ file, url, format }, transformationController) => {
9
9
  cli_ux_1.default.action.start("Transforming API specification");
10
10
  let generation;
11
11
  if (file) {
12
- const fileDescriptor = new js_sdk_1.FileWrapper(fs.createReadStream(file));
12
+ const fileDescriptor = new sdk_1.FileWrapper(fs.createReadStream(file));
13
13
  generation = await transformationController.transformViaFile(fileDescriptor, format);
14
14
  }
15
15
  else if (url) {
@@ -39,11 +39,11 @@ exports.downloadTransformationFile = async ({ id, destinationFilePath, transform
39
39
  };
40
40
  // Get valid platform from user's input, convert simple platform to valid Platforms enum value
41
41
  exports.getValidFormat = (format) => {
42
- if (Object.keys(js_sdk_1.ExportFormats).find((exportFormat) => exportFormat === format)) {
43
- return js_sdk_1.ExportFormats[format];
42
+ if (Object.keys(sdk_1.ExportFormats).find((exportFormat) => exportFormat === format)) {
43
+ return sdk_1.ExportFormats[format];
44
44
  }
45
45
  else {
46
- const formats = Object.keys(js_sdk_1.ExportFormats).join("|");
46
+ const formats = Object.keys(sdk_1.ExportFormats).join("|");
47
47
  throw new Error(`Please provide a valid platform i.e. ${formats}`);
48
48
  }
49
49
  };
@@ -1,5 +1,5 @@
1
1
  import Command from "@oclif/command";
2
- import { APIValidationExternalApisController, ApiValidationSummary } from "@apimatic/js-sdk";
2
+ import { APIValidationExternalApisController, ApiValidationSummary } from "@apimatic/sdk";
3
3
  import { GetValidationParams } from "../../types/api/validate";
4
4
  export declare const getValidation: ({ file, url }: GetValidationParams, apiValidationController: APIValidationExternalApisController) => Promise<ApiValidationSummary>;
5
5
  export declare const printValidationMessages: ({ warnings, errors }: ApiValidationSummary, warn: Command["warn"], error: Command["error"]) => void;
@@ -1,2 +1,2 @@
1
1
  import { GeneratePortalParams } from "../../types/portal/generate";
2
- export declare const downloadDocsPortal: ({ zippedBuildFilePath, generatedPortalFolderPath, overrideAuthKey, zip }: GeneratePortalParams, configDir: string) => Promise<string>;
2
+ export declare const downloadDocsPortal: ({ zippedBuildFilePath, portalFolderPath, zippedPortalPath, overrideAuthKey, zip }: GeneratePortalParams, configDir: string) => Promise<string>;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.downloadDocsPortal = void 0;
4
4
  const fs = require("fs-extra");
5
5
  const FormData = require("form-data");
6
- const path = require("path");
7
6
  const cli_ux_1 = require("cli-ux");
8
7
  const auth_manager_1 = require("../../client-utils/auth-manager");
9
8
  const env_1 = require("../../config/env");
@@ -22,9 +21,7 @@ const downloadPortalAxios = async (zippedBuildFilePath, overrideAuthKey, configD
22
21
  return data;
23
22
  };
24
23
  // 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");
24
+ exports.downloadDocsPortal = async ({ zippedBuildFilePath, portalFolderPath, zippedPortalPath, overrideAuthKey, zip }, configDir) => {
28
25
  cli_ux_1.default.action.start("Downloading portal");
29
26
  // Check if the build file exists for the user or not
30
27
  if (!(await fs.pathExists(zippedBuildFilePath))) {
@@ -41,11 +38,11 @@ exports.downloadDocsPortal = async ({ zippedBuildFilePath, generatedPortalFolder
41
38
  // if ((data as NodeJS.ReadableStream).readable) {
42
39
  // await writeFileUsingReadableStream(data as NodeJS.ReadableStream, zippedPortalPath);
43
40
  if (!zip) {
44
- await utils_1.unzipFile(fs.createReadStream(zippedPortalPath), portalPath);
41
+ await utils_1.unzipFile(fs.createReadStream(zippedPortalPath), portalFolderPath);
45
42
  await utils_1.deleteFile(zippedPortalPath);
46
43
  }
47
44
  cli_ux_1.default.action.stop();
48
- return zip ? zippedPortalPath : portalPath;
45
+ return zip ? zippedPortalPath : portalFolderPath;
49
46
  // } else {
50
47
  // throw new Error("Couldn't download the portal");
51
48
  // }
@@ -1,4 +1,4 @@
1
- import { CodeGenerationExternalApisController } from "@apimatic/js-sdk";
1
+ import { CodeGenerationExternalApisController } from "@apimatic/sdk";
2
2
  import { GenerationIdParams, DownloadSDKParams } from "../../types/sdk/generate";
3
3
  export declare const getSDKGenerationId: ({ file, url, platform }: GenerationIdParams, sdkGenerationController: CodeGenerationExternalApisController) => Promise<string>;
4
4
  export declare const downloadGeneratedSDK: ({ codeGenId, zippedSDKPath, sdkFolderPath, zip }: DownloadSDKParams, sdkGenerationController: CodeGenerationExternalApisController) => Promise<string>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.downloadGeneratedSDK = exports.getSDKGenerationId = void 0;
4
4
  const fs = require("fs-extra");
5
5
  const cli_ux_1 = require("cli-ux");
6
- const js_sdk_1 = require("@apimatic/js-sdk");
6
+ const sdk_1 = require("@apimatic/sdk");
7
7
  const core_1 = require("@apimatic/core");
8
8
  const generate_1 = require("../../types/sdk/generate");
9
9
  const utils_1 = require("../../utils/utils");
@@ -34,11 +34,11 @@ const getSDKPlatform = (platform) => {
34
34
  if (Object.keys(generate_1.SimplePlatforms).includes(platform)) {
35
35
  return generate_1.SimplePlatforms[platform];
36
36
  }
37
- else if (Object.values(js_sdk_1.Platforms).includes(platform)) {
37
+ else if (Object.values(sdk_1.Platforms).includes(platform)) {
38
38
  return platform;
39
39
  }
40
40
  else {
41
- const platforms = Object.keys(generate_1.SimplePlatforms).concat(Object.values(js_sdk_1.Platforms)).join("|");
41
+ const platforms = Object.keys(generate_1.SimplePlatforms).concat(Object.values(sdk_1.Platforms)).join("|");
42
42
  throw new Error(`Please provide a valid platform i.e. ${platforms}`);
43
43
  }
44
44
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { TransformationController } from "@apimatic/js-sdk";
2
+ import { TransformationController } from "@apimatic/sdk";
3
3
  export declare type AuthenticationError = {
4
4
  statusCode: number;
5
5
  body: string;
@@ -1,7 +1,8 @@
1
- import { DocsPortalManagementController } from "@apimatic/js-sdk";
1
+ import { DocsPortalManagementController } from "@apimatic/sdk";
2
2
  export declare type GeneratePortalParams = {
3
3
  zippedBuildFilePath: string;
4
- generatedPortalFolderPath: string;
4
+ portalFolderPath: string;
5
+ zippedPortalPath: string;
5
6
  docsPortalController: DocsPortalManagementController;
6
7
  overrideAuthKey: string | null;
7
8
  zip: boolean;
@@ -1 +1 @@
1
- {"version":"1.0.1-alpha.4","commands":{"api":{"id":"api","description":"Manage APIs","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api --help"],"flags":{},"args":[]},"api:transform":{"id":"api:transform","description":"Transform API specifications from one format to another. Supports [10+ different formats](https://www.apimatic.io/transformer/#supported-formats) including OpenApi/Swagger, RAML, WSDL and Postman Collections.","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","$ apimatic api:transform --format=RAML --url=\"https://petstore.swagger.io/v2/swagger.json\" --destination=\"D:/\"\nSuccess! Your transformed file is located at D:/swagger_raml.yaml\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. Can be used in place of the --file option if the API specification is publicly available.","default":""},"destination":{"name":"destination","type":"option","description":"directory to download transformed file to","default":"./"},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key"}},"args":[]},"api:validate":{"id":"api:validate","description":"Validate the syntactic and semantic correctness of an API specification","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api:validate --file=\"./specs/sample.json\"\nSpecification file provided is valid\n","$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.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. Can be used in place of the --file option if the API specification is publicly available.","default":""},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key"}},"args":[]},"auth":{"id":"auth","description":"Manage this CLI's authentication state.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth --help"],"flags":{},"args":[]},"auth:login":{"id":"auth:login","description":"Login using your APIMatic credentials or an API Key","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","$ apimatic auth:login --auth-key=xxxxxx\nAuthentication key successfully set"],"flags":{"auth-key":{"name":"auth-key","type":"option","description":"Set authentication key for all commands","default":""}},"args":[]},"auth:logout":{"id":"auth:logout","description":"Clear local login credentials","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:logout\nLogged out\n"],"flags":{},"args":[]},"auth:status":{"id":"auth:status","description":"View current authentication state","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 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://portal-api-docs.apimatic.io/#/http/generating-api-portal/build-file)","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":"path to the input directory containing API specifications and config files","default":""},"destination":{"name":"destination","type":"option","description":"path to the downloaded portal","default":"./"},"zip":{"name":"zip","type":"boolean","description":"download the generated portal as a .zip archive","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key","default":""}},"args":[]},"portal":{"id":"portal","description":"Manage API documentation portals","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\"\nGenerating SDK... done\nDownloading SDK... done\nSuccess! Your SDK is located at swagger_sdk_csharp","$ apimatic sdk:generate --platform=\"CSHARP\" --url=https://petstore.swagger.io/v2/swagger.json\nGenerating SDK... done\nDownloading SDK... done\nSuccess! Your SDK is located at swagger_sdk_csharp\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 SDKs for","default":""},"url":{"name":"url","type":"option","description":"URL to the API specification to generate SDKs for. Can be used in place of the --file option if the API specification is publicly available.","default":""},"destination":{"name":"destination","type":"option","description":"directory to download the generated SDK to","default":"./"},"zip":{"name":"zip","type":"boolean","description":"download the generated SDK as a .zip archive","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key","default":""}},"args":[]},"sdk":{"id":"sdk","description":"Generate and manage SDKs for APIs","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$apimatic sdk --help"],"flags":{},"args":[]}}}
1
+ {"version":"1.0.1-alpha.5","commands":{"api":{"id":"api","description":"Manage APIs","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api --help"],"flags":{},"args":[]},"api:transform":{"id":"api:transform","description":"Transform API specifications from one format to another. Supports [10+ different formats](https://www.apimatic.io/transformer/#supported-formats) including OpenApi/Swagger, RAML, WSDL and Postman Collections.","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","$ apimatic api:transform --format=RAML --url=\"https://petstore.swagger.io/v2/swagger.json\" --destination=\"D:/\"\nSuccess! Your transformed file is located at D:/swagger_raml.yaml\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. Can be used in place of the --file option if the API specification is publicly available.","default":""},"destination":{"name":"destination","type":"option","description":"directory to download transformed file to","default":"./"},"force":{"name":"force","type":"boolean","char":"f","description":"overwrite if same file exist in the destination","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key"}},"args":[]},"api:validate":{"id":"api:validate","description":"Validate the syntactic and semantic correctness of an API specification","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api:validate --file=\"./specs/sample.json\"\nSpecification file provided is valid\n","$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.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. Can be used in place of the --file option if the API specification is publicly available.","default":""},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key"}},"args":[]},"auth":{"id":"auth","description":"Manage this CLI's authentication state.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth --help"],"flags":{},"args":[]},"auth:login":{"id":"auth:login","description":"Login using your APIMatic credentials or an API Key","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","$ apimatic auth:login --auth-key=xxxxxx\nAuthentication key successfully set"],"flags":{"auth-key":{"name":"auth-key","type":"option","description":"Set authentication key for all commands","default":""}},"args":[]},"auth:logout":{"id":"auth:logout","description":"Clear local login credentials","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:logout\nLogged out\n"],"flags":{},"args":[]},"auth:status":{"id":"auth:status","description":"View current authentication state","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 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://portal-api-docs.apimatic.io/#/http/generating-api-portal/build-file)","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":"path to the input directory containing API specifications and config files","default":""},"destination":{"name":"destination","type":"option","description":"path to the downloaded portal","default":"./"},"force":{"name":"force","type":"boolean","char":"f","description":"overwrite if a portal exists in the destination","allowNo":false},"zip":{"name":"zip","type":"boolean","description":"download the generated portal as a .zip archive","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key","default":""}},"args":[]},"portal":{"id":"portal","description":"Manage API documentation portals","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\"\nGenerating SDK... done\nDownloading SDK... done\nSuccess! Your SDK is located at swagger_sdk_csharp","$ apimatic sdk:generate --platform=\"CSHARP\" --url=https://petstore.swagger.io/v2/swagger.json\nGenerating SDK... done\nDownloading SDK... done\nSuccess! Your SDK is located at swagger_sdk_csharp\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 SDKs for","default":""},"url":{"name":"url","type":"option","description":"URL to the API specification to generate SDKs for. Can be used in place of the --file option if the API specification is publicly available.","default":""},"destination":{"name":"destination","type":"option","description":"directory to download the generated SDK to","default":"./"},"force":{"name":"force","type":"boolean","char":"f","description":"overwrite if an SDK already exists in the destination","allowNo":false},"zip":{"name":"zip","type":"boolean","description":"download the generated SDK as a .zip archive","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key","default":""}},"args":[]},"sdk":{"id":"sdk","description":"Generate and manage SDKs for APIs","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.4",
4
+ "version": "1.0.1-alpha.5",
5
5
  "author": "APIMatic",
6
6
  "bin": {
7
7
  "apimatic": "./bin/run"
@@ -45,7 +45,7 @@
45
45
  "lint:fix": "eslint --fix \"src/**/*.{js,ts}\" --quiet"
46
46
  },
47
47
  "dependencies": {
48
- "@apimatic/js-sdk": "^0.0.3-alpha.1",
48
+ "@apimatic/sdk": "^0.0.1-alpha.1",
49
49
  "@oclif/command": "^1.8.0",
50
50
  "@oclif/config": "^1.17.0",
51
51
  "@oclif/plugin-autocomplete": "^0.3.0",
package/CHANGELOG.md DELETED
@@ -1,27 +0,0 @@
1
- ## [1.0.1-alpha.4](https://github.com/apimatic/apimatic-cli/compare/v1.0.1-alpha.3...v1.0.1-alpha.4) (2021-12-01)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * **documentation:** improve messages for each command ([a2c0bfb](https://github.com/apimatic/apimatic-cli/commit/a2c0bfbd5c1867302cf27170dc3b2d3ca5bd64ca))
7
-
8
- ## [1.0.1-alpha.3](https://github.com/apimatic/apimatic-cli/compare/v1.0.1-alpha.2...v1.0.1-alpha.3) (2021-12-01)
9
-
10
-
11
- ### Bug Fixes
12
-
13
- * **sdk package:** get sdk package from npm ([4c8e178](https://github.com/apimatic/apimatic-cli/commit/4c8e1787eb21f04d81cab95b5a58e3133a61f7af))
14
-
15
- ## [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)
16
-
17
-
18
- ### Bug Fixes
19
-
20
- * **refactor:** refactor code ([d7cb486](https://github.com/apimatic/apimatic-cli/commit/d7cb4863bcfd44f297f0525e0c7eae7ecef12695))
21
-
22
- ## [1.0.1-alpha.1](https://github.com/apimatic/apimatic-cli/compare/v1.0.0...v1.0.1-alpha.1) (2021-11-26)
23
-
24
-
25
- ### Bug Fixes
26
-
27
- * **release:** add lock file to gitignore restore check_build workflow ([2eb959a](https://github.com/apimatic/apimatic-cli/commit/2eb959afc2a7ee2317959fc8525930acde2989dc))