@autifyhq/autify-cli 0.7.1 → 0.9.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.
@@ -3,28 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runTest = void 0;
4
4
  /* eslint-disable unicorn/filename-case */
5
5
  const errors_1 = require("@oclif/errors");
6
- const parseScenarioUrl = (url) => {
7
- var _a, _b, _c, _d;
8
- const { pathname } = new URL(url);
9
- const scenarioUrlPathRegExp = /\/projects\/(?<workspaceId>\d+)\/scenarios\/(?<scenarioId>\d+)/;
10
- const match = scenarioUrlPathRegExp.exec(pathname);
11
- const workspaceId = Number.parseInt((_b = (_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.workspaceId) !== null && _b !== void 0 ? _b : "", 10);
12
- const scenarioId = Number.parseInt((_d = (_c = match === null || match === void 0 ? void 0 : match.groups) === null || _c === void 0 ? void 0 : _c.scenarioId) !== null && _d !== void 0 ? _d : "", 10);
13
- if (!workspaceId || !scenarioId)
14
- return;
15
- return { workspaceId, scenarioId };
16
- };
17
- const parseTestPlanUrl = (url) => {
18
- var _a, _b, _c, _d;
19
- const { pathname } = new URL(url);
20
- const testPlanUrlPathRegExp = /\/projects\/(?<workspaceId>\d+)\/test_plans\/(?<testPlanId>\d+)/;
21
- const match = testPlanUrlPathRegExp.exec(pathname);
22
- const workspaceId = Number.parseInt((_b = (_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.workspaceId) !== null && _b !== void 0 ? _b : "", 10);
23
- const testPlanId = Number.parseInt((_d = (_c = match === null || match === void 0 ? void 0 : match.groups) === null || _c === void 0 ? void 0 : _c.testPlanId) !== null && _d !== void 0 ? _d : "", 10);
24
- if (!workspaceId || !testPlanId)
25
- return;
26
- return { workspaceId, testPlanId };
27
- };
28
6
  const isCapabilitySpecified = (option) => {
29
7
  return Object.values(option).some(Boolean);
30
8
  };
@@ -52,39 +30,35 @@ const capabilityToString = ({ os, os_version, browser, browser_version, device,
52
30
  .filter((s) => Boolean(s))
53
31
  .join(" ");
54
32
  };
55
- const runTest = async (client, url, { option, name, urlReplacements, autifyConnect }) => {
56
- const scenario = parseScenarioUrl(url);
57
- const testPlan = parseTestPlanUrl(url);
58
- if (scenario) {
59
- const { workspaceId, scenarioId } = scenario;
33
+ const runTest = async (client, parsedTest, { option, name, urlReplacements, autifyConnectAccessPoint }) => {
34
+ const { workspaceId, testScenarioId, testPlanId } = parsedTest;
35
+ if (testScenarioId) {
60
36
  const capability = await getCapability(client, workspaceId, option);
61
37
  const res = await client.executeScenarios(workspaceId, {
62
38
  name,
63
39
  capabilities: [capability],
64
- scenarios: [{ id: scenarioId }],
40
+ scenarios: [{ id: testScenarioId }],
65
41
  // eslint-disable-next-line camelcase
66
42
  url_replacements: urlReplacements,
67
- ...(autifyConnect && {
43
+ ...(autifyConnectAccessPoint && {
68
44
  // eslint-disable-next-line camelcase
69
45
  autify_connect: {
70
- name: autifyConnect,
46
+ name: autifyConnectAccessPoint,
71
47
  },
72
48
  }),
73
49
  });
74
50
  return {
75
- workspaceId,
76
51
  resultId: res.data.result_id,
77
52
  capability: capabilityToString(capability),
78
53
  };
79
54
  }
80
- if (testPlan) {
55
+ if (testPlanId) {
81
56
  if (isCapabilitySpecified(option))
82
57
  throw new errors_1.CLIError(`Running TestPlan doesn't support capability override: ${JSON.stringify(option)}`);
83
58
  if (name)
84
59
  throw new errors_1.CLIError(`Running TestPlan doesn't support --name: ${name}`);
85
- if (autifyConnect)
86
- throw new errors_1.CLIError(`Running TestPlan doesn't support --autify-connect-key: ${autifyConnect}`);
87
- const { workspaceId, testPlanId } = testPlan;
60
+ if (autifyConnectAccessPoint)
61
+ throw new errors_1.CLIError("Running TestPlan doesn't support Autify Connect Access Point");
88
62
  const urlReplacementIds = [];
89
63
  for await (const urlReplacement of urlReplacements !== null && urlReplacements !== void 0 ? urlReplacements : []) {
90
64
  const res = await client.createUrlReplacement(testPlanId, urlReplacement);
@@ -95,11 +69,10 @@ const runTest = async (client, url, { option, name, urlReplacements, autifyConne
95
69
  await client.deleteUrlReplacement(testPlanId, urlReplacementId);
96
70
  }
97
71
  return {
98
- workspaceId,
99
72
  resultId: res.data.data.id,
100
73
  capability: "configured by test plan",
101
74
  };
102
75
  }
103
- throw new errors_1.CLIError(`Invalid URL: ${url}`);
76
+ throw new errors_1.CLIError("testScenarioId or testPlanId is required.");
104
77
  };
105
78
  exports.runTest = runTest;
@@ -12,7 +12,16 @@ const waitUntil = async (callback, timeoutSecond, intervalSecond, verbose) => {
12
12
  {
13
13
  title: `Waiting... (timeout: ${timeoutSecond} s)`,
14
14
  task: async (ctx, task) => {
15
+ let killed;
16
+ process.on("SIGINT", (signal) => {
17
+ killed = signal;
18
+ });
19
+ process.on("SIGTERM", (signal) => {
20
+ killed = signal;
21
+ });
15
22
  for await (const startTime of (0, promises_1.setInterval)(intervalSecond * 1000, Date.now())) {
23
+ if (killed)
24
+ throw new errors_1.CLIError(`Process was killed by ${killed}.`);
16
25
  const now = Date.now();
17
26
  if (now - startTime > timeoutSecond * 1000) {
18
27
  throw new errors_1.CLIError(`Timeout after ${timeoutSecond} seconds.`);
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class ConnectAccessPointSet extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string>;
7
+ };
8
+ run(): Promise<void>;
9
+ private readKeyFromStdin;
10
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const inquirer = tslib_1.__importStar(require("inquirer"));
6
+ const config_1 = require("../../../config");
7
+ class ConnectAccessPointSet extends core_1.Command {
8
+ async run() {
9
+ const { flags } = await this.parse(ConnectAccessPointSet);
10
+ const key = await this.readKeyFromStdin();
11
+ (0, config_1.set)(this.config.configDir, "AUTIFY_CONNECT_ACCESS_POINT_NAME", flags.name);
12
+ (0, config_1.set)(this.config.configDir, "AUTIFY_CONNECT_ACCESS_POINT_KEY", key);
13
+ }
14
+ async readKeyFromStdin() {
15
+ const res = await inquirer.prompt([
16
+ {
17
+ name: "key",
18
+ message: "Enter Autify Connect Access Point Key",
19
+ type: "password",
20
+ mask: true,
21
+ },
22
+ ]);
23
+ return res.key;
24
+ }
25
+ }
26
+ exports.default = ConnectAccessPointSet;
27
+ ConnectAccessPointSet.description = "[Experimental] Set Autify Connect Access Point";
28
+ ConnectAccessPointSet.examples = [
29
+ "Start interactive setup:\n<%= config.bin %> <%= command.id %> --name=NAME",
30
+ "Reading the key from file:\n<%= config.bin %> <%= command.id %> --name=NAME < key.txt",
31
+ ];
32
+ ConnectAccessPointSet.flags = {
33
+ name: core_1.Flags.string({
34
+ description: "Name of the Autify Connect Access Point already created",
35
+ required: true,
36
+ }),
37
+ };
@@ -0,0 +1,8 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class ConnectClientInstall extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {};
6
+ static args: never[];
7
+ run(): Promise<void>;
8
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const installClient_1 = require("../../../autify/connect/installClient");
5
+ class ConnectClientInstall extends core_1.Command {
6
+ async run() {
7
+ await this.parse(ConnectClientInstall);
8
+ const { cacheDir } = this.config;
9
+ const { version, path } = await (0, installClient_1.installClient)(cacheDir);
10
+ this.log(`Successfully installed Autify Connect Client (path: ${path}, version: ${version})`);
11
+ }
12
+ }
13
+ exports.default = ConnectClientInstall;
14
+ ConnectClientInstall.description = "[Experimental] Install the latest stable version of Autify Connect Client";
15
+ ConnectClientInstall.examples = ["<%= config.bin %> <%= command.id %>"];
16
+ ConnectClientInstall.flags = {};
17
+ ConnectClientInstall.args = [];
@@ -0,0 +1,11 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class ConnectClientStart extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ "file-logging": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ "web-workspace-id": import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
4
+ const core_1 = require("@oclif/core");
5
+ const spawnClient_1 = require("../../../autify/connect/spawnClient");
6
+ const config_1 = require("../../../config");
7
+ const createEphemeralAccessPointIfNeeded = (configDir, userAgent, workspaceId) => {
8
+ if (!workspaceId)
9
+ return;
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 webClient = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ return {
14
+ webClient,
15
+ workspaceId,
16
+ };
17
+ };
18
+ class ConnectClientStart extends core_1.Command {
19
+ async run() {
20
+ const { flags } = await this.parse(ConnectClientStart);
21
+ const { configDir, cacheDir, userAgent } = this.config;
22
+ const { verbose, "file-logging": fileLogging, "web-workspace-id": webWorkspaceId, } = flags;
23
+ const ephemeralAccessPoint = createEphemeralAccessPointIfNeeded(configDir, userAgent, webWorkspaceId);
24
+ const { version, logFile, accessPointName, waitReady, waitExit } = await (0, spawnClient_1.spawnClient)(configDir, cacheDir, {
25
+ verbose,
26
+ fileLogging,
27
+ ephemeralAccessPoint,
28
+ });
29
+ this.log(`Starting Autify Connect Client for Access Point "${accessPointName}" (${version})...`);
30
+ if (logFile)
31
+ this.log(`Log file is located at ${logFile}`);
32
+ this.log("Waiting until Autify Connect Client is ready...");
33
+ await waitReady();
34
+ this.log("Autify Connect Client is ready!");
35
+ const [code, signal, deletedAccessPointName] = await waitExit();
36
+ if (deletedAccessPointName)
37
+ this.log(`Autify Connect Access Point was deleted: "${deletedAccessPointName}"`);
38
+ this.log(`Autify Connect Client exited (code: ${code}, signal: ${signal}).`);
39
+ this.exit(code !== null && code !== void 0 ? code : 1);
40
+ }
41
+ }
42
+ exports.default = ConnectClientStart;
43
+ ConnectClientStart.description = "[Experimental] Start Autify Connect Client";
44
+ ConnectClientStart.examples = ["<%= config.bin %> <%= command.id %>"];
45
+ ConnectClientStart.flags = {
46
+ verbose: core_1.Flags.boolean({
47
+ description: "Make the operation more talkative.",
48
+ default: false,
49
+ }),
50
+ "file-logging": core_1.Flags.boolean({
51
+ description: "Logging Autify Connect Client log to a file instead of console.",
52
+ default: false,
53
+ }),
54
+ "web-workspace-id": core_1.Flags.integer({
55
+ description: "Workspace ID of Autify for Web to create an ephemeral Access Point. If not specified, it will use the one configured by `autify connect access-point set`, instead.",
56
+ }),
57
+ };
@@ -8,6 +8,7 @@ export default class MobileTestRun extends Command {
8
8
  wait: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
9
  timeout: import("@oclif/core/lib/interfaces").OptionFlag<number>;
10
10
  verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ "max-retry-count": import("@oclif/core/lib/interfaces").OptionFlag<number>;
11
12
  };
12
13
  static args: {
13
14
  name: string;
@@ -25,19 +25,48 @@ class MobileTestRun extends core_1.Command {
25
25
  const uploadCommand = new upload_1.default(uploadArgs, this.config);
26
26
  buildId = (await uploadCommand.run()).buildId;
27
27
  }
28
- const res = await client.runTestPlan(testPlanId, {
29
- // eslint-disable-next-line camelcase
30
- build_id: buildId,
31
- });
32
- if (!res.data.id)
33
- throw new errors_1.CLIError(`Failed to run a test plan.`);
34
- const testResultUrl = (0, getTestResultUrl_1.getMobileTestResultUrl)(configDir, workspaceId, res.data.id);
35
- this.log(`${node_emoji_1.default.get("white_check_mark")} Successfully started: ${testResultUrl}`);
28
+ const runTestPlanOnce = async () => {
29
+ const res = await client.runTestPlan(testPlanId, {
30
+ // eslint-disable-next-line camelcase
31
+ build_id: buildId,
32
+ });
33
+ if (!res.data.id)
34
+ throw new errors_1.CLIError(`Failed to run a test plan.`);
35
+ const testResultUrl = (0, getTestResultUrl_1.getMobileTestResultUrl)(configDir, workspaceId, res.data.id);
36
+ this.log(`${node_emoji_1.default.get("white_check_mark")} Successfully started: ${testResultUrl}`);
37
+ return testResultUrl;
38
+ };
39
+ let testResultUrl = await runTestPlanOnce();
36
40
  if (flags.wait) {
37
- const waitArgs = ["--timeout", flags.timeout.toString(), testResultUrl];
38
- if (flags.verbose)
39
- waitArgs.push("--verbose");
40
- await wait_1.default.run(waitArgs);
41
+ const mobileTestWait = async (url) => {
42
+ const waitArgs = ["--timeout", flags.timeout.toString(), url];
43
+ if (flags.verbose)
44
+ waitArgs.push("--verbose");
45
+ try {
46
+ await wait_1.default.run(waitArgs);
47
+ }
48
+ catch (error) {
49
+ if (error.oclif.exit === 0)
50
+ return null;
51
+ return error;
52
+ }
53
+ throw new errors_1.CLIError(`Unexpected behavior.`);
54
+ };
55
+ const maxRetryCount = flags["max-retry-count"];
56
+ let error;
57
+ for await (const [i] of Array.from({
58
+ length: maxRetryCount + 1,
59
+ }).entries()) {
60
+ error = await mobileTestWait(testResultUrl);
61
+ if (error === null)
62
+ this.exit();
63
+ else if (i === maxRetryCount)
64
+ throw error;
65
+ else {
66
+ this.log(`${node_emoji_1.default.get("repeat")} Retrying... (attempt: ${i + 1}/${maxRetryCount})`);
67
+ testResultUrl = await runTestPlanOnce();
68
+ }
69
+ }
41
70
  }
42
71
  else {
43
72
  this.log("To wait for the test result, run the command below:");
@@ -76,6 +105,10 @@ MobileTestRun.flags = {
76
105
  description: "Verbose output",
77
106
  default: false,
78
107
  }),
108
+ "max-retry-count": core_1.Flags.integer({
109
+ description: "Maximum retry count. The command can take up to timeout * (max-retry-count + 1).",
110
+ default: 0,
111
+ }),
79
112
  };
80
113
  MobileTestRun.args = [
81
114
  {
@@ -30,7 +30,8 @@ class MobileTestWait extends core_1.Command {
30
30
  this.exit();
31
31
  }
32
32
  else {
33
- this.error(`${node_emoji_1.default.get("x")} Test didn't pass. See ${testResultUrl}: ${JSON.stringify(data)}`);
33
+ this.log(`${node_emoji_1.default.get("x")} Test didn't pass. See ${testResultUrl}: ${JSON.stringify(data)}`);
34
+ this.exit(1);
34
35
  }
35
36
  }
36
37
  }
@@ -6,6 +6,9 @@ export default class WebTestRun extends Command {
6
6
  name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
7
  "url-replacements": import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined>;
8
8
  "autify-connect": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
+ "autify-connect-client": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ "autify-connect-client-verbose": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ "autify-connect-client-file-logging": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
12
  os: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
13
  "os-version": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
14
  browser: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
@@ -14,6 +17,7 @@ export default class WebTestRun extends Command {
14
17
  wait: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
18
  timeout: import("@oclif/core/lib/interfaces").OptionFlag<number>;
16
19
  verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
20
+ "max-retry-count": import("@oclif/core/lib/interfaces").OptionFlag<number>;
17
21
  };
18
22
  static args: {
19
23
  name: string;
@@ -8,6 +8,9 @@ const config_1 = require("../../../config");
8
8
  const runTest_1 = require("../../../autify/web/runTest");
9
9
  const getTestResultUrl_1 = require("../../../autify/web/getTestResultUrl");
10
10
  const wait_1 = tslib_1.__importDefault(require("./wait"));
11
+ const spawnClient_1 = require("../../../autify/connect/spawnClient");
12
+ const errors_1 = require("@oclif/errors");
13
+ const parseAutifyTestUrl_1 = require("../../../autify/web/parseAutifyTestUrl");
11
14
  const parseUrlReplacements = (urlReplacements) => {
12
15
  return urlReplacements.map((s) => {
13
16
  // eslint-disable-next-line camelcase
@@ -41,28 +44,91 @@ class WebTestRun extends core_1.Command {
41
44
  const urlReplacements = parseUrlReplacements((_a = flags["url-replacements"]) !== null && _a !== void 0 ? _a : []);
42
45
  if (urlReplacements.length > 0)
43
46
  this.log(`${node_emoji_1.default.get("memo")} Using URL replacements: ${urlReplacementsToString(urlReplacements)}`);
44
- const autifyConnect = flags["autify-connect"];
45
- const { configDir, userAgent } = this.config;
47
+ const { configDir, cacheDir, userAgent } = this.config;
46
48
  const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
47
49
  const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
48
50
  const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
49
- const { workspaceId, resultId, capability } = await (0, runTest_1.runTest)(client, args["scenario-or-test-plan-url"], {
50
- option: capabilityOption,
51
- name: flags.name,
52
- urlReplacements,
53
- autifyConnect,
54
- });
55
- const testResultUrl = (0, getTestResultUrl_1.getWebTestResultUrl)(configDir, workspaceId, resultId);
56
- this.log(`${node_emoji_1.default.get("white_check_mark")} Successfully started: ${testResultUrl} (Capability is ${capability})`);
57
- if (flags.wait) {
58
- const waitArgs = ["--timeout", flags.timeout.toString(), testResultUrl];
59
- if (flags.verbose)
60
- waitArgs.push("--verbose");
61
- await wait_1.default.run(waitArgs);
51
+ const parsedTest = (0, parseAutifyTestUrl_1.parseAutifyTestUrl)(args["scenario-or-test-plan-url"]);
52
+ const { workspaceId } = parsedTest;
53
+ let autifyConnectAccessPoint = flags["autify-connect"];
54
+ let autifyConnectClient;
55
+ if (flags["autify-connect-client"]) {
56
+ autifyConnectClient = await (0, spawnClient_1.spawnClient)(configDir, cacheDir, {
57
+ verbose: flags["autify-connect-client-verbose"],
58
+ fileLogging: flags["autify-connect-client-file-logging"],
59
+ ephemeralAccessPoint: {
60
+ webClient: client,
61
+ workspaceId,
62
+ },
63
+ });
64
+ const { version, logFile, accessPointName, waitReady } = autifyConnectClient;
65
+ autifyConnectAccessPoint = accessPointName;
66
+ this.log(`Starting Autify Connect Client for Access Point "${accessPointName}" (${version})...`);
67
+ if (logFile)
68
+ this.log(`Autify Connect Client log file is located at ${logFile}`);
69
+ this.log("Waiting until Autify Connect Client is ready...");
70
+ await waitReady();
71
+ this.log("Autify Connect Client is ready!");
62
72
  }
63
- else {
64
- this.log("To wait for the test result, run the command below:");
65
- this.log(`${node_emoji_1.default.get("computer")} $ autify web test wait ${testResultUrl}`);
73
+ const runTestOnce = async () => {
74
+ const { resultId, capability } = await (0, runTest_1.runTest)(client, parsedTest, {
75
+ option: capabilityOption,
76
+ name: flags.name,
77
+ urlReplacements,
78
+ autifyConnectAccessPoint,
79
+ });
80
+ const testResultUrl = (0, getTestResultUrl_1.getWebTestResultUrl)(configDir, workspaceId, resultId);
81
+ this.log(`${node_emoji_1.default.get("white_check_mark")} Successfully started: ${testResultUrl} (Capability is ${capability})`);
82
+ return testResultUrl;
83
+ };
84
+ try {
85
+ let testResultUrl = await runTestOnce();
86
+ if (flags.wait) {
87
+ const webTestWait = async (url) => {
88
+ const waitArgs = ["--timeout", flags.timeout.toString(), url];
89
+ if (flags.verbose)
90
+ waitArgs.push("--verbose");
91
+ try {
92
+ await wait_1.default.run(waitArgs);
93
+ }
94
+ catch (error) {
95
+ if (error.oclif.exit === 0)
96
+ return null;
97
+ return error;
98
+ }
99
+ throw new errors_1.CLIError(`Unexpected behavior.`);
100
+ };
101
+ const maxRetryCount = flags["max-retry-count"];
102
+ let error;
103
+ for await (const [i] of Array.from({
104
+ length: maxRetryCount + 1,
105
+ }).entries()) {
106
+ error = await webTestWait(testResultUrl);
107
+ if (error === null)
108
+ this.exit();
109
+ else if (i === maxRetryCount)
110
+ throw error;
111
+ else {
112
+ this.log(`${node_emoji_1.default.get("repeat")} Retrying... (attempt: ${i + 1}/${maxRetryCount})`);
113
+ testResultUrl = await runTestOnce();
114
+ }
115
+ }
116
+ }
117
+ else {
118
+ this.log("To wait for the test result, run the command below:");
119
+ this.log(`${node_emoji_1.default.get("computer")} $ autify web test wait ${testResultUrl}`);
120
+ }
121
+ }
122
+ catch (error) {
123
+ if (autifyConnectClient) {
124
+ this.log("Waiting until Autify Connect Client exits...");
125
+ autifyConnectClient.kill();
126
+ const [code, signal, deletedAccessPointName] = await autifyConnectClient.waitExit();
127
+ if (deletedAccessPointName)
128
+ this.log(`Autify Connect Access Point was deleted: "${deletedAccessPointName}"`);
129
+ this.log(`Autify Connect Client exited (code: ${code}, signal: ${signal}).`);
130
+ }
131
+ throw error;
66
132
  }
67
133
  }
68
134
  }
@@ -89,6 +155,20 @@ WebTestRun.flags = {
89
155
  }),
90
156
  "autify-connect": core_1.Flags.string({
91
157
  description: "Name of the Autify Connect Access Point (Only for test scenario execution.)",
158
+ exclusive: ["autify-connect-client"],
159
+ }),
160
+ "autify-connect-client": core_1.Flags.boolean({
161
+ description: "[Experimental] Start Autify Connect Client (Only for test scenario execution.)",
162
+ exclusive: ["autify-connect"],
163
+ dependsOn: ["wait"],
164
+ }),
165
+ "autify-connect-client-verbose": core_1.Flags.boolean({
166
+ description: "[Experimental] Verbose output for Autify Connect Client (Only for test scenario execution.)",
167
+ dependsOn: ["autify-connect-client"],
168
+ }),
169
+ "autify-connect-client-file-logging": core_1.Flags.boolean({
170
+ description: "[Experimental] Logging Autify Connect Client log to a file instead of console.",
171
+ dependsOn: ["autify-connect-client"],
92
172
  }),
93
173
  os: core_1.Flags.string({ description: "OS to run the test" }),
94
174
  "os-version": core_1.Flags.string({ description: "OS version to run the test" }),
@@ -110,6 +190,10 @@ WebTestRun.flags = {
110
190
  description: "Verbose output",
111
191
  default: false,
112
192
  }),
193
+ "max-retry-count": core_1.Flags.integer({
194
+ description: "Maximum retry count. The command can take up to timeout * (max-retry-count + 1).",
195
+ default: 0,
196
+ }),
113
197
  };
114
198
  WebTestRun.args = [
115
199
  {
@@ -30,7 +30,8 @@ class WebTestWait extends core_1.Command {
30
30
  this.exit();
31
31
  }
32
32
  else {
33
- this.error(`${node_emoji_1.default.get("x")} Test didn't pass. See ${testResultUrl}: ${JSON.stringify(data)}`);
33
+ this.log(`${node_emoji_1.default.get("x")} Test didn't pass. See ${testResultUrl}: ${JSON.stringify(data)}`);
34
+ this.exit(1);
34
35
  }
35
36
  }
36
37
  }
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_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_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;