@autifyhq/autify-cli 0.10.1 → 0.12.0

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.
Files changed (54) hide show
  1. package/README.md +104 -34
  2. package/dist/autify/connect/client-manager/AccessPoint.d.ts +16 -0
  3. package/dist/autify/connect/client-manager/AccessPoint.js +26 -0
  4. package/dist/autify/connect/client-manager/ClientManager.d.ts +57 -0
  5. package/dist/autify/connect/client-manager/ClientManager.js +242 -0
  6. package/dist/autify/connect/client-manager/DebugServerClient.d.ts +16 -0
  7. package/dist/autify/connect/client-manager/DebugServerClient.js +55 -0
  8. package/dist/autify/connect/client-manager/Logger.d.ts +11 -0
  9. package/dist/autify/connect/client-manager/Logger.js +43 -0
  10. package/dist/autify/connect/client-manager/StateMachine.d.ts +54 -0
  11. package/dist/autify/connect/client-manager/StateMachine.js +149 -0
  12. package/dist/autify/connect/installClient.d.ts +1 -1
  13. package/dist/autify/connect/installClient.js +4 -3
  14. package/dist/autify/mobile/getMobileClient.d.ts +2 -0
  15. package/dist/autify/mobile/getMobileClient.js +17 -0
  16. package/dist/autify/web/getWebClient.d.ts +2 -0
  17. package/dist/autify/web/getWebClient.js +17 -0
  18. package/dist/autify/web/runTest.js +8 -3
  19. package/dist/commands/connect/access-point/create.js +4 -7
  20. package/dist/commands/connect/access-point/set.js +1 -1
  21. package/dist/commands/connect/client/install.js +1 -1
  22. package/dist/commands/connect/client/start.js +26 -48
  23. package/dist/commands/mobile/api/describe-test-result.js +2 -5
  24. package/dist/commands/mobile/api/list-test-results.js +2 -5
  25. package/dist/commands/mobile/api/run-test-plan.js +2 -5
  26. package/dist/commands/mobile/api/upload-build.js +2 -5
  27. package/dist/commands/mobile/build/upload.js +2 -5
  28. package/dist/commands/mobile/test/run.js +2 -5
  29. package/dist/commands/mobile/test/wait.js +2 -5
  30. package/dist/commands/web/api/create-access-point.d.ts +10 -0
  31. package/dist/commands/web/api/create-access-point.js +26 -0
  32. package/dist/commands/web/api/create-url-replacement.js +2 -5
  33. package/dist/commands/web/api/delete-access-point.d.ts +10 -0
  34. package/dist/commands/web/api/delete-access-point.js +26 -0
  35. package/dist/commands/web/api/delete-url-replacement.js +2 -5
  36. package/dist/commands/web/api/describe-result.js +2 -5
  37. package/dist/commands/web/api/describe-scenario.js +2 -5
  38. package/dist/commands/web/api/execute-scenarios.js +2 -5
  39. package/dist/commands/web/api/execute-schedule.d.ts +1 -0
  40. package/dist/commands/web/api/execute-schedule.js +9 -6
  41. package/dist/commands/web/api/list-access-points.d.ts +10 -0
  42. package/dist/commands/web/api/list-access-points.js +26 -0
  43. package/dist/commands/web/api/list-capabilities.js +2 -5
  44. package/dist/commands/web/api/list-results.js +2 -5
  45. package/dist/commands/web/api/list-scenarios.js +2 -5
  46. package/dist/commands/web/api/list-url-replacements.js +2 -5
  47. package/dist/commands/web/api/update-url-replacement.js +2 -5
  48. package/dist/commands/web/test/run.js +41 -42
  49. package/dist/commands/web/test/wait.js +2 -5
  50. package/dist/config.d.ts +1 -1
  51. package/oclif.manifest.json +1 -1
  52. package/package.json +13 -9
  53. package/dist/autify/connect/spawnClient.d.ts +0 -28
  54. package/dist/autify/connect/spawnClient.js +0 -192
@@ -1,22 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
4
  const core_1 = require("@oclif/core");
6
5
  const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
7
6
  const getWaitIntervalSecond_1 = require("../../../autify/getWaitIntervalSecond");
7
+ const getMobileClient_1 = require("../../../autify/mobile/getMobileClient");
8
8
  const getTestResultUrl_1 = require("../../../autify/mobile/getTestResultUrl");
9
9
  const parseTestResultUrl_1 = require("../../../autify/mobile/parseTestResultUrl");
10
10
  const waitTestResult_1 = require("../../../autify/mobile/waitTestResult");
11
- const config_1 = require("../../../config");
12
11
  class MobileTestWait extends core_1.Command {
13
12
  async run() {
14
13
  const { args, flags } = await this.parse(MobileTestWait);
15
14
  const { configDir, userAgent } = this.config;
16
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
17
- const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
18
15
  const waitIntervalSecond = (0, getWaitIntervalSecond_1.getWaitIntervalSecond)(configDir);
19
- const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
16
+ const client = (0, getMobileClient_1.getMobileClient)(configDir, userAgent);
20
17
  const { workspaceId, resultId } = (0, parseTestResultUrl_1.parseTestResultUrl)(args["test-result-url"]);
21
18
  const testResultUrl = (0, getTestResultUrl_1.getMobileTestResultUrl)(configDir, workspaceId, resultId);
22
19
  this.log(`${node_emoji_1.default.get("clock1")} Waiting for the test result: ${testResultUrl}`);
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiCreateAccessPoint extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ "create-access-point-request": import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
5
+ class WebApiCreateAccessPoint extends core_1.Command {
6
+ async run() {
7
+ const { flags } = await this.parse(WebApiCreateAccessPoint);
8
+ const { configDir, userAgent } = this.config;
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
10
+ const res = await client.createAccessPoint(flags["project-id"], JSON.parse(flags["create-access-point-request"]));
11
+ console.log(JSON.stringify(res.data, null, 2));
12
+ }
13
+ }
14
+ exports.default = WebApiCreateAccessPoint;
15
+ WebApiCreateAccessPoint.description = "You can generate a new access point by passing in its name.";
16
+ WebApiCreateAccessPoint.examples = ["<%= config.bin %> <%= command.id %>"];
17
+ WebApiCreateAccessPoint.flags = {
18
+ "project-id": core_1.Flags.integer({
19
+ description: "For example, 1 for the following URL: https://app.autify.com/projects/1/scenarios",
20
+ required: true,
21
+ }),
22
+ "create-access-point-request": core_1.Flags.string({
23
+ description: "The name of the access point to be created",
24
+ required: true,
25
+ }),
26
+ };
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiCreateUrlReplacement extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiCreateUrlReplacement);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.createUrlReplacement(flags["test-plan-id"], JSON.parse(flags["create-url-replacement-request"]));
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiDeleteAccessPoint extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ "delete-access-point-request": import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
5
+ class WebApiDeleteAccessPoint extends core_1.Command {
6
+ async run() {
7
+ const { flags } = await this.parse(WebApiDeleteAccessPoint);
8
+ const { configDir, userAgent } = this.config;
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
10
+ const res = await client.deleteAccessPoint(flags["project-id"], JSON.parse(flags["delete-access-point-request"]));
11
+ console.log(JSON.stringify(res.data, null, 2));
12
+ }
13
+ }
14
+ exports.default = WebApiDeleteAccessPoint;
15
+ WebApiDeleteAccessPoint.description = "You can delete an access point by passing in its name.";
16
+ WebApiDeleteAccessPoint.examples = ["<%= config.bin %> <%= command.id %>"];
17
+ WebApiDeleteAccessPoint.flags = {
18
+ "project-id": core_1.Flags.integer({
19
+ description: "For example, 1 for the following URL: https://app.autify.com/projects/1/scenarios",
20
+ required: true,
21
+ }),
22
+ "delete-access-point-request": core_1.Flags.string({
23
+ description: "The name of the access point to be deleted",
24
+ required: true,
25
+ }),
26
+ };
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiDeleteUrlReplacement extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiDeleteUrlReplacement);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.deleteUrlReplacement(flags["test-plan-id"], flags["url-replacement-id"]);
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiDescribeResult extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiDescribeResult);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.describeResult(flags["project-id"], flags["result-id"]);
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiDescribeScenario extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiDescribeScenario);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.describeScenario(flags["project-id"], flags["scenario-id"]);
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiExecuteScenarios extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiExecuteScenarios);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.executeScenarios(flags["project-id"], JSON.parse(flags["execute-scenarios-request"]));
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -4,6 +4,7 @@ export default class WebApiExecuteSchedule extends Command {
4
4
  static examples: string[];
5
5
  static flags: {
6
6
  "schedule-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ "execute-schedule-request": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
8
  };
8
9
  run(): Promise<void>;
9
10
  }
@@ -1,16 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiExecuteSchedule extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiExecuteSchedule);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
- const res = await client.executeSchedule(flags["schedule-id"]);
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
10
+ const res = await client.executeSchedule(flags["schedule-id"], flags["execute-schedule-request"]
11
+ ? JSON.parse(flags["execute-schedule-request"])
12
+ : undefined);
14
13
  console.log(JSON.stringify(res.data, null, 2));
15
14
  }
16
15
  }
@@ -22,4 +21,8 @@ WebApiExecuteSchedule.flags = {
22
21
  description: "For example, 3 for the following URL: https://app.autify.com/projects/1/test_plans/3",
23
22
  required: true,
24
23
  }),
24
+ "execute-schedule-request": core_1.Flags.string({
25
+ description: "The options to execute a test plan.",
26
+ required: false,
27
+ }),
25
28
  };
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiListAccessPoints extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ page: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
5
+ class WebApiListAccessPoints extends core_1.Command {
6
+ async run() {
7
+ const { flags } = await this.parse(WebApiListAccessPoints);
8
+ const { configDir, userAgent } = this.config;
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
10
+ const res = await client.listAccessPoints(flags["project-id"], flags.page);
11
+ console.log(JSON.stringify(res.data, null, 2));
12
+ }
13
+ }
14
+ exports.default = WebApiListAccessPoints;
15
+ WebApiListAccessPoints.description = "List access points for the project.";
16
+ WebApiListAccessPoints.examples = ["<%= config.bin %> <%= command.id %>"];
17
+ WebApiListAccessPoints.flags = {
18
+ "project-id": core_1.Flags.integer({
19
+ description: "For example, 1 for the following URL: https://app.autify.com/projects/1/scenarios",
20
+ required: true,
21
+ }),
22
+ page: core_1.Flags.integer({
23
+ description: "The number of page returns.",
24
+ required: false,
25
+ }),
26
+ };
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiListCapabilities extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiListCapabilities);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.listCapabilities(flags["project-id"], flags.os, flags.browser, flags["device-type"]);
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiListResults extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiListResults);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.listResults(flags["project-id"], flags.page, flags["per-page"], flags["test-plan-id"]);
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiListScenarios extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiListScenarios);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.listScenarios(flags["project-id"], flags.page);
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiListUrlReplacements extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiListUrlReplacements);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.listUrlReplacements(flags["test-plan-id"]);
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
- const config_1 = require("../../../config");
4
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
6
5
  class WebApiUpdateUrlReplacement extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(WebApiUpdateUrlReplacement);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
13
10
  const res = await client.updateUrlReplacement(flags["test-plan-id"], flags["url-replacement-id"], JSON.parse(flags["update-url-replacement-request"]));
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
6
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
7
- const config_1 = require("../../../config");
8
6
  const runTest_1 = require("../../../autify/web/runTest");
9
7
  const getTestResultUrl_1 = require("../../../autify/web/getTestResultUrl");
10
8
  const wait_1 = tslib_1.__importDefault(require("./wait"));
11
- const spawnClient_1 = require("../../../autify/connect/spawnClient");
12
9
  const errors_1 = require("@oclif/errors");
13
10
  const parseAutifyTestUrl_1 = require("../../../autify/web/parseAutifyTestUrl");
11
+ const ClientManager_1 = require("../../../autify/connect/client-manager/ClientManager");
12
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
14
13
  const parseUrlReplacements = (urlReplacements) => {
15
14
  return urlReplacements.map((s) => {
16
15
  // eslint-disable-next-line camelcase
@@ -45,13 +44,11 @@ class WebTestRun extends core_1.Command {
45
44
  if (urlReplacements.length > 0)
46
45
  this.log(`${node_emoji_1.default.get("memo")} Using URL replacements: ${urlReplacementsToString(urlReplacements)}`);
47
46
  const { configDir, cacheDir, userAgent } = this.config;
48
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
49
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
50
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
47
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
51
48
  const parsedTest = (0, parseAutifyTestUrl_1.parseAutifyTestUrl)(args["scenario-or-test-plan-url"]);
52
49
  const { workspaceId } = parsedTest;
53
50
  let autifyConnectAccessPoint = flags["autify-connect"];
54
- let autifyConnectClient;
51
+ let autifyConnectClientManager;
55
52
  const runTestOnce = async () => {
56
53
  const { resultId, capability } = await (0, runTest_1.runTest)(client, parsedTest, {
57
54
  option: capabilityOption,
@@ -65,28 +62,20 @@ class WebTestRun extends core_1.Command {
65
62
  };
66
63
  try {
67
64
  if (flags["autify-connect-client"]) {
68
- const errorHandler = (error) => {
69
- if (flags.verbose)
70
- this.warn(error);
71
- };
72
- autifyConnectClient = await (0, spawnClient_1.spawnClient)(configDir, cacheDir, errorHandler, {
65
+ autifyConnectClientManager = await ClientManager_1.ClientManager.create({
66
+ configDir,
67
+ cacheDir,
68
+ userAgent,
73
69
  verbose: flags["autify-connect-client-verbose"],
74
70
  fileLogging: flags["autify-connect-client-file-logging"],
75
71
  debugServerPort: flags["autify-connect-client-debug-server-port"],
76
- ephemeralAccessPoint: {
77
- webClient: client,
78
- workspaceId,
79
- },
72
+ webWorkspaceId: workspaceId,
80
73
  });
81
- const { version, versionMismatchWarning, logFile, accessPointName, waitReady, } = autifyConnectClient;
82
- autifyConnectAccessPoint = accessPointName;
83
- this.log(`Starting Autify Connect Client for Access Point "${accessPointName}" (${version})...`);
84
- if (versionMismatchWarning)
85
- this.warn(versionMismatchWarning);
86
- if (logFile)
87
- this.log(`Autify Connect Client log file is located at ${logFile}`);
74
+ autifyConnectAccessPoint = autifyConnectClientManager.accessPointName;
75
+ this.log("Starting Autify Connect Client...");
76
+ await autifyConnectClientManager.start();
88
77
  this.log("Waiting until Autify Connect Client is ready...");
89
- await waitReady();
78
+ await autifyConnectClientManager.onceReady();
90
79
  this.log("Autify Connect Client is ready!");
91
80
  }
92
81
  let testResultUrl = await runTestOnce();
@@ -127,13 +116,12 @@ class WebTestRun extends core_1.Command {
127
116
  }
128
117
  }
129
118
  catch (error) {
130
- if (autifyConnectClient) {
119
+ if (autifyConnectClientManager) {
131
120
  this.log("Waiting until Autify Connect Client exits...");
132
- await autifyConnectClient.kill();
133
- const [code, signal, deletedAccessPointName] = await autifyConnectClient.waitExit();
134
- if (deletedAccessPointName)
135
- this.log(`Autify Connect Access Point was deleted: "${deletedAccessPointName}"`);
136
- this.log(`Autify Connect Client exited (code: ${code}, signal: ${signal})`);
121
+ await autifyConnectClientManager.exit({
122
+ ignoreError: true,
123
+ });
124
+ this.log("Autify Connect Client exited.");
137
125
  }
138
126
  throw error;
139
127
  }
@@ -149,11 +137,12 @@ WebTestRun.examples = [
149
137
  "With URL replacements:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 -r http://example.com=http://example.net -r http://example.org=http://example.net",
150
138
  'Run a test with specifying the execution name:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --name "Sample execution"',
151
139
  "Run a test scenario with Autify Connect:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --autify-connect NAME",
140
+ "Run a test scenario with Autify Connect Client:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --wait --autify-connect-client",
152
141
  ];
153
142
  WebTestRun.flags = {
154
143
  name: core_1.Flags.string({
155
144
  char: "n",
156
- description: "Name of the test execution. (Only for test scenario execution.)",
145
+ description: "[Only for test scenario] Name of the test execution.",
157
146
  }),
158
147
  "url-replacements": core_1.Flags.string({
159
148
  char: "r",
@@ -161,31 +150,41 @@ WebTestRun.flags = {
161
150
  multiple: true,
162
151
  }),
163
152
  "autify-connect": core_1.Flags.string({
164
- description: "Name of the Autify Connect Access Point (Only for test scenario execution.)",
153
+ description: "Name of the Autify Connect Access Point.",
165
154
  exclusive: ["autify-connect-client"],
166
155
  }),
167
156
  "autify-connect-client": core_1.Flags.boolean({
168
- description: "[Experimental] Start Autify Connect Client (Only for test scenario execution.)",
157
+ description: "Start Autify Connect Client",
169
158
  exclusive: ["autify-connect"],
170
159
  dependsOn: ["wait"],
171
160
  }),
172
161
  "autify-connect-client-verbose": core_1.Flags.boolean({
173
- description: "[Experimental] Verbose output for Autify Connect Client (Only for test scenario execution.)",
162
+ description: "Verbose output for Autify Connect Client.",
174
163
  dependsOn: ["autify-connect-client"],
175
164
  }),
176
165
  "autify-connect-client-file-logging": core_1.Flags.boolean({
177
- description: "[Experimental] Logging Autify Connect Client log to a file instead of console.",
166
+ description: "Logging Autify Connect Client log to a file instead of console.",
178
167
  dependsOn: ["autify-connect-client"],
179
168
  }),
180
169
  "autify-connect-client-debug-server-port": core_1.Flags.integer({
181
- description: `[Experimental] [default: ${spawnClient_1.DEFAULT_CLIENT_DEBUG_SERVER_PORT}] Port for Autify Connect Client debug server.`,
170
+ description: "Port for Autify Connect Client debug server. A random port will be used if not specified.",
182
171
  dependsOn: ["autify-connect-client"],
183
172
  }),
184
- os: core_1.Flags.string({ description: "OS to run the test" }),
185
- "os-version": core_1.Flags.string({ description: "OS version to run the test" }),
186
- browser: core_1.Flags.string({ description: "Browser to run the test" }),
187
- device: core_1.Flags.string({ description: "Device to run the test" }),
188
- "device-type": core_1.Flags.string({ description: "Device type to run the test" }),
173
+ os: core_1.Flags.string({
174
+ description: "[Only for test scenario] OS to run the test",
175
+ }),
176
+ "os-version": core_1.Flags.string({
177
+ description: "[Only for test scenario] OS version to run the test",
178
+ }),
179
+ browser: core_1.Flags.string({
180
+ description: "[Only for test scenario] Browser to run the test",
181
+ }),
182
+ device: core_1.Flags.string({
183
+ description: "[Only for test scenario] Device to run the test",
184
+ }),
185
+ "device-type": core_1.Flags.string({
186
+ description: "[Only for test scenario] Device type to run the test",
187
+ }),
189
188
  wait: core_1.Flags.boolean({
190
189
  char: "w",
191
190
  description: "Wait until the test finishes.",
@@ -202,7 +201,7 @@ WebTestRun.flags = {
202
201
  default: false,
203
202
  }),
204
203
  "max-retry-count": core_1.Flags.integer({
205
- description: "Maximum retry count. The command can take up to timeout * (max-retry-count + 1).",
204
+ description: "Maximum retry count while waiting. The command can take up to `timeout * (max-retry-count + 1)`. Only effective with `--wait`.",
206
205
  default: 0,
207
206
  }),
208
207
  };
@@ -3,20 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
6
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
7
- const config_1 = require("../../../config");
8
6
  const parseTestResultUrl_1 = require("../../../autify/web/parseTestResultUrl");
9
7
  const waitTestResult_1 = require("../../../autify/web/waitTestResult");
10
8
  const getTestResultUrl_1 = require("../../../autify/web/getTestResultUrl");
11
9
  const getWaitIntervalSecond_1 = require("../../../autify/getWaitIntervalSecond");
10
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
12
11
  class WebTestWait extends core_1.Command {
13
12
  async run() {
14
13
  const { args, flags } = await this.parse(WebTestWait);
15
14
  const { configDir, userAgent } = this.config;
16
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
17
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
18
15
  const waitIntervalSecond = (0, getWaitIntervalSecond_1.getWaitIntervalSecond)(configDir);
19
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
16
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
20
17
  const { workspaceId, resultId } = (0, parseTestResultUrl_1.parseTestResultUrl)(args["test-result-url"]);
21
18
  const testResultUrl = (0, getTestResultUrl_1.getWebTestResultUrl)(configDir, workspaceId, resultId);
22
19
  this.log(`${node_emoji_1.default.get("clock1")} Waiting for the test result: ${testResultUrl}`);
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare type Variable = "AUTIFY_WEB_ACCESS_TOKEN" | "AUTIFY_WEB_BASE_PATH" | "AUTIFY_MOBILE_ACCESS_TOKEN" | "AUTIFY_MOBILE_BASE_PATH" | "AUTIFY_CONNECT_ACCESS_POINT_NAME" | "AUTIFY_CONNECT_ACCESS_POINT_KEY" | "AUTIFY_CONNECT_CLIENT_MODE" | "AUTIFY_TEST_WAIT_INTERVAL_SECOND";
1
+ declare type Variable = "AUTIFY_WEB_ACCESS_TOKEN" | "AUTIFY_WEB_BASE_PATH" | "AUTIFY_MOBILE_ACCESS_TOKEN" | "AUTIFY_MOBILE_BASE_PATH" | "AUTIFY_CONNECT_ACCESS_POINT_NAME" | "AUTIFY_CONNECT_ACCESS_POINT_KEY" | "AUTIFY_CONNECT_CLIENT_MODE" | "AUTIFY_CLI_USER_AGENT_SUFFIX" | "AUTIFY_TEST_WAIT_INTERVAL_SECOND";
2
2
  export declare const set: (configDir: string, key: Variable, value: string | undefined) => void;
3
3
  export declare const get: (configDir: string, key: Variable) => string | undefined;
4
4
  export declare const getOrThrow: (configDir: string, key: Variable) => string;