@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
@@ -0,0 +1,11 @@
1
+ import { ChildProcessWithoutNullStreams } from "node:child_process";
2
+ import { Logger, LoggerOptions } from "winston";
3
+ declare type ClientLog = Readonly<{
4
+ level: string;
5
+ ts: string;
6
+ msg: string;
7
+ }>;
8
+ export declare const createManagerLogger: (options: LoggerOptions) => Logger;
9
+ export declare const createClientLogger: (options: LoggerOptions, filename?: string) => Logger;
10
+ export declare const setupClientOutputLogger: (childProcess: ChildProcessWithoutNullStreams, callback: (log: ClientLog) => void) => void;
11
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupClientOutputLogger = exports.createClientLogger = exports.createManagerLogger = void 0;
4
+ const node_readline_1 = require("node:readline");
5
+ const winston_1 = require("winston");
6
+ const logFormatConsole = (prefix) => winston_1.format.combine(winston_1.format.colorize(), winston_1.format.timestamp(), winston_1.format.printf(({ timestamp, level, message }) => `${prefix.padEnd(25)} ${timestamp}\t${level}\t${message}`));
7
+ const logFormatFile = () => winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.printf(({ timestamp, level, message }) => `${timestamp}\t${level}\t${message}`));
8
+ const createManagerLogger = (options) => {
9
+ return (0, winston_1.createLogger)(options).add(new winston_1.transports.Console({
10
+ format: logFormatConsole("[Autify Connect Manager]"),
11
+ }));
12
+ };
13
+ exports.createManagerLogger = createManagerLogger;
14
+ const createClientLogger = (options, filename) => {
15
+ const logger = (0, winston_1.createLogger)(options);
16
+ filename
17
+ ? logger.add(new winston_1.transports.File({
18
+ format: logFormatFile(),
19
+ filename,
20
+ }))
21
+ : logger.add(new winston_1.transports.Console({
22
+ format: logFormatConsole("[Autify Connect Client] "),
23
+ }));
24
+ return logger;
25
+ };
26
+ exports.createClientLogger = createClientLogger;
27
+ const setupClientOutputLogger = (childProcess, callback) => {
28
+ // stdout
29
+ (0, node_readline_1.createInterface)({
30
+ input: childProcess.stdout,
31
+ crlfDelay: Number.POSITIVE_INFINITY,
32
+ }).on("line", (line) => {
33
+ try {
34
+ callback(JSON.parse(line));
35
+ }
36
+ catch {
37
+ // Ignore errors
38
+ }
39
+ });
40
+ // stderr
41
+ childProcess.stderr.pipe(process.stderr);
42
+ };
43
+ exports.setupClientOutputLogger = setupClientOutputLogger;
@@ -0,0 +1,54 @@
1
+ import { Interpreter } from "xstate";
2
+ import { ProcessExit } from "./ClientManager";
3
+ declare type ClientStateMachineContext = {
4
+ spawn: (debugServerPort: number) => void;
5
+ terminate: () => Promise<void>;
6
+ kill: () => void;
7
+ cleanup: () => Promise<void>;
8
+ processExit?: ProcessExit;
9
+ errors: Error[];
10
+ };
11
+ declare type ClientStateMachineEvent = {
12
+ type: "SPAWN";
13
+ debugServerPort: number;
14
+ } | {
15
+ type: "READY";
16
+ } | {
17
+ type: "TERMINATE";
18
+ } | {
19
+ type: "FAIL";
20
+ error: Error;
21
+ } | {
22
+ type: "EXIT";
23
+ processExit: ProcessExit;
24
+ };
25
+ declare type ClientStateMachineState = {
26
+ value: "init";
27
+ context: ClientStateMachineContext;
28
+ } | {
29
+ value: "starting";
30
+ context: ClientStateMachineContext;
31
+ } | {
32
+ value: "ready";
33
+ context: ClientStateMachineContext;
34
+ } | {
35
+ value: "terminating";
36
+ context: ClientStateMachineContext;
37
+ } | {
38
+ value: "killing";
39
+ context: ClientStateMachineContext;
40
+ } | {
41
+ value: "timeout";
42
+ context: ClientStateMachineContext;
43
+ } | {
44
+ value: "cleanup";
45
+ context: ClientStateMachineContext;
46
+ } | {
47
+ value: "done";
48
+ context: ClientStateMachineContext & {
49
+ processExit: ProcessExit;
50
+ };
51
+ };
52
+ export declare type ClientStateMachineService = Interpreter<ClientStateMachineContext, any, ClientStateMachineEvent, ClientStateMachineState, any>;
53
+ export declare const createService: (context: ClientStateMachineContext) => ClientStateMachineService;
54
+ export {};
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createService = void 0;
4
+ /* eslint-disable unicorn/filename-case */
5
+ const xstate_1 = require("xstate");
6
+ const ClientManager_1 = require("./ClientManager");
7
+ const createService = (context) => {
8
+ const machine = (0, xstate_1.createMachine)({
9
+ predictableActionArguments: true,
10
+ schema: {
11
+ context: {},
12
+ },
13
+ context,
14
+ initial: "init",
15
+ states: {
16
+ init: {
17
+ on: {
18
+ SPAWN: { target: "starting" },
19
+ FAIL: {
20
+ target: "cleanup",
21
+ actions: (0, xstate_1.assign)({
22
+ errors: (context, event) => {
23
+ context.errors.push(event.error);
24
+ return context.errors;
25
+ },
26
+ }),
27
+ },
28
+ },
29
+ },
30
+ starting: {
31
+ entry: (context, event) => {
32
+ if (event.type !== "SPAWN")
33
+ return;
34
+ context.spawn(event.debugServerPort);
35
+ },
36
+ on: {
37
+ READY: { target: "ready" },
38
+ TERMINATE: { target: "terminating" },
39
+ EXIT: {
40
+ target: "cleanup",
41
+ actions: (0, xstate_1.assign)({
42
+ processExit: (_, event) => event.processExit,
43
+ }),
44
+ },
45
+ },
46
+ after: {
47
+ 3000: {
48
+ target: "terminating",
49
+ actions: (0, xstate_1.assign)({
50
+ errors: (context) => {
51
+ context.errors.push(new ClientManager_1.StateMachineTimeoutError("starting"));
52
+ return context.errors;
53
+ },
54
+ }),
55
+ },
56
+ },
57
+ },
58
+ ready: {
59
+ on: {
60
+ TERMINATE: { target: "terminating" },
61
+ EXIT: {
62
+ target: "cleanup",
63
+ actions: (0, xstate_1.assign)({
64
+ processExit: (_, event) => event.processExit,
65
+ }),
66
+ },
67
+ },
68
+ },
69
+ terminating: {
70
+ invoke: {
71
+ src: (context) => context.terminate(),
72
+ },
73
+ on: {
74
+ TERMINATE: { target: "killing" },
75
+ EXIT: {
76
+ target: "cleanup",
77
+ actions: (0, xstate_1.assign)({
78
+ processExit: (_, event) => event.processExit,
79
+ }),
80
+ },
81
+ },
82
+ after: {
83
+ 3000: { target: "killing" },
84
+ },
85
+ },
86
+ killing: {
87
+ entry: (context) => context.kill(),
88
+ on: {
89
+ TERMINATE: { target: "cleanup" },
90
+ EXIT: {
91
+ target: "cleanup",
92
+ actions: (0, xstate_1.assign)({
93
+ processExit: (_, event) => event.processExit,
94
+ }),
95
+ },
96
+ },
97
+ after: {
98
+ 2000: {
99
+ target: "failed",
100
+ actions: (0, xstate_1.assign)({
101
+ errors: (context) => {
102
+ context.errors.push(new ClientManager_1.StateMachineTimeoutError("killing"));
103
+ return context.errors;
104
+ },
105
+ }),
106
+ },
107
+ },
108
+ },
109
+ cleanup: {
110
+ invoke: {
111
+ src: (context) => context.cleanup(),
112
+ onDone: [
113
+ { target: "failed", cond: (context) => context.errors.length > 0 },
114
+ { target: "done" },
115
+ ],
116
+ onError: {
117
+ target: "failed",
118
+ actions: (0, xstate_1.assign)({
119
+ errors: (context, event) => {
120
+ context.errors.push(event.data);
121
+ return context.errors;
122
+ },
123
+ }),
124
+ },
125
+ },
126
+ after: {
127
+ 2000: {
128
+ target: "failed",
129
+ actions: (0, xstate_1.assign)({
130
+ errors: (context) => {
131
+ context.errors.push(new ClientManager_1.StateMachineTimeoutError("cleanup"));
132
+ return context.errors;
133
+ },
134
+ }),
135
+ },
136
+ },
137
+ },
138
+ done: {
139
+ type: "final",
140
+ },
141
+ failed: {
142
+ type: "final",
143
+ entry: (context) => context.kill(),
144
+ },
145
+ },
146
+ });
147
+ return (0, xstate_1.interpret)(machine).start();
148
+ };
149
+ exports.createService = createService;
@@ -1,5 +1,5 @@
1
1
  import { CLIError } from "@oclif/errors";
2
- export declare const AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION = "v0.6.2";
2
+ export declare const AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION = "v0.6.3";
3
3
  export declare type ClientMode = "fake" | "real";
4
4
  export declare class ConnectClientVersionMismatchError extends CLIError {
5
5
  readonly expected: string;
@@ -12,9 +12,10 @@ const node_util_1 = require("node:util");
12
12
  const node_path_1 = require("node:path");
13
13
  const unzip_stream_1 = require("unzip-stream");
14
14
  const node_child_process_1 = require("node:child_process");
15
+ const tar_1 = tslib_1.__importDefault(require("tar"));
15
16
  const config_1 = require("../../config");
16
17
  // Update whenever to bump supported version.
17
- exports.AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION = "v0.6.2";
18
+ exports.AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION = "v0.6.3";
18
19
  const getMode = (configDir) => {
19
20
  const mode = (0, config_1.get)(configDir, "AUTIFY_CONNECT_CLIENT_MODE");
20
21
  if (!mode)
@@ -70,8 +71,8 @@ const extract = async (downloadPath) => {
70
71
  ? "autifyconnect-fake"
71
72
  : "autifyconnect";
72
73
  if (file.endsWith(".tar.gz")) {
73
- // TODO: Pure JS
74
- await (0, node_util_1.promisify)(node_child_process_1.execFile)("tar", ["xvzf", file], { cwd: dir });
74
+ const streamPipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
75
+ await streamPipeline((0, node_fs_1.createReadStream)(downloadPath), tar_1.default.x({ cwd: dir }));
75
76
  return (0, node_path_1.join)(dir, binaryName);
76
77
  }
77
78
  if (file.endsWith(".zip")) {
@@ -0,0 +1,2 @@
1
+ import { MobileClient } from "@autifyhq/autify-sdk";
2
+ export declare const getMobileClient: (configDir: string, userAgent: string) => MobileClient;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMobileClient = void 0;
4
+ /* eslint-disable unicorn/filename-case */
5
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
6
+ const config_1 = require("../../config");
7
+ const getMobileClient = (configDir, userAgent) => {
8
+ var _a;
9
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
10
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
11
+ const userAgentSuffix = (_a = (0, config_1.get)(configDir, "AUTIFY_CLI_USER_AGENT_SUFFIX")) !== null && _a !== void 0 ? _a : "";
12
+ return new autify_sdk_1.MobileClient(accessToken, {
13
+ basePath,
14
+ userAgent: `${userAgent} ${userAgentSuffix}`.trim(),
15
+ });
16
+ };
17
+ exports.getMobileClient = getMobileClient;
@@ -0,0 +1,2 @@
1
+ import { WebClient } from "@autifyhq/autify-sdk";
2
+ export declare const getWebClient: (configDir: string, userAgent: string) => WebClient;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWebClient = void 0;
4
+ /* eslint-disable unicorn/filename-case */
5
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
6
+ const config_1 = require("../../config");
7
+ const getWebClient = (configDir, userAgent) => {
8
+ var _a;
9
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
10
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
11
+ const userAgentSuffix = (_a = (0, config_1.get)(configDir, "AUTIFY_CLI_USER_AGENT_SUFFIX")) !== null && _a !== void 0 ? _a : "";
12
+ return new autify_sdk_1.WebClient(accessToken, {
13
+ basePath,
14
+ userAgent: `${userAgent} ${userAgentSuffix}`.trim(),
15
+ });
16
+ };
17
+ exports.getWebClient = getWebClient;
@@ -57,14 +57,19 @@ const runTest = async (client, parsedTest, { option, name, urlReplacements, auti
57
57
  throw new errors_1.CLIError(`Running TestPlan doesn't support capability override: ${JSON.stringify(option)}`);
58
58
  if (name)
59
59
  throw new errors_1.CLIError(`Running TestPlan doesn't support --name: ${name}`);
60
- if (autifyConnectAccessPoint)
61
- throw new errors_1.CLIError("Running TestPlan doesn't support Autify Connect Access Point");
62
60
  const urlReplacementIds = [];
63
61
  for await (const urlReplacement of urlReplacements !== null && urlReplacements !== void 0 ? urlReplacements : []) {
64
62
  const res = await client.createUrlReplacement(testPlanId, urlReplacement);
65
63
  urlReplacementIds.push(res.data.id);
66
64
  }
67
- const res = await client.executeSchedule(testPlanId);
65
+ const res = await client.executeSchedule(testPlanId, {
66
+ ...(autifyConnectAccessPoint && {
67
+ // eslint-disable-next-line camelcase
68
+ autify_connect: {
69
+ name: autifyConnectAccessPoint,
70
+ },
71
+ }),
72
+ });
68
73
  for await (const urlReplacementId of urlReplacementIds) {
69
74
  await client.deleteUrlReplacement(testPlanId, urlReplacementId);
70
75
  }
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
4
3
  const core_1 = require("@oclif/core");
5
4
  const accessPointConfig_1 = require("../../../autify/connect/accessPointConfig");
6
- const config_1 = require("../../../config");
5
+ const getWebClient_1 = require("../../../autify/web/getWebClient");
7
6
  class ConnectAccessPointCreate extends core_1.Command {
8
7
  async run() {
9
8
  const { flags } = await this.parse(ConnectAccessPointCreate);
@@ -11,9 +10,7 @@ class ConnectAccessPointCreate extends core_1.Command {
11
10
  await (0, accessPointConfig_1.confirmOverwriteAccessPoint)(configDir);
12
11
  const { name, "web-workspace-id": webWorkspaceId } = flags;
13
12
  if (webWorkspaceId) {
14
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
15
- const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
16
- const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const client = (0, getWebClient_1.getWebClient)(configDir, userAgent);
17
14
  const response = await client.createAccessPoint(webWorkspaceId, {
18
15
  name,
19
16
  });
@@ -24,7 +21,7 @@ class ConnectAccessPointCreate extends core_1.Command {
24
21
  }
25
22
  }
26
23
  exports.default = ConnectAccessPointCreate;
27
- ConnectAccessPointCreate.description = "[Experimental] Create an Autify Connect Access Point";
24
+ ConnectAccessPointCreate.description = "Create an Autify Connect Access Point";
28
25
  ConnectAccessPointCreate.examples = [
29
26
  "<%= config.bin %> <%= command.id %> --name NAME --web-workspace-id ID",
30
27
  ];
@@ -34,7 +31,7 @@ ConnectAccessPointCreate.flags = {
34
31
  required: true,
35
32
  }),
36
33
  "web-workspace-id": core_1.Flags.integer({
37
- description: "Workspace ID of Autify for Web to which the Access Point belong",
34
+ description: "Workspace ID of Autify for Web to which the Access Point will belong",
38
35
  exactlyOne: ["web-workspace-id"],
39
36
  }),
40
37
  };
@@ -26,7 +26,7 @@ class ConnectAccessPointSet extends core_1.Command {
26
26
  }
27
27
  }
28
28
  exports.default = ConnectAccessPointSet;
29
- ConnectAccessPointSet.description = "[Experimental] Set Autify Connect Access Point";
29
+ ConnectAccessPointSet.description = "Set Autify Connect Access Point";
30
30
  ConnectAccessPointSet.examples = [
31
31
  "Start interactive setup:\n<%= config.bin %> <%= command.id %> --name=NAME",
32
32
  "Reading the key from file:\n<%= config.bin %> <%= command.id %> --name=NAME < key.txt",
@@ -13,7 +13,7 @@ class ConnectClientInstall extends core_1.Command {
13
13
  }
14
14
  }
15
15
  exports.default = ConnectClientInstall;
16
- ConnectClientInstall.description = "[Experimental] Install Autify Connect Client";
16
+ ConnectClientInstall.description = "Install Autify Connect Client";
17
17
  ConnectClientInstall.examples = [
18
18
  "(Recommended) Install the supported version:\n<%= config.bin %> <%= command.id %>",
19
19
  "Install a specific version:\n<%= config.bin %> <%= command.id %> v0.6.1",
@@ -1,61 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const autify_sdk_1 = require("@autifyhq/autify-sdk");
4
3
  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
- };
4
+ const ClientManager_1 = require("../../../autify/connect/client-manager/ClientManager");
18
5
  class ConnectClientStart extends core_1.Command {
19
6
  async run() {
7
+ var _a;
20
8
  const { flags } = await this.parse(ConnectClientStart);
21
9
  const { configDir, cacheDir, userAgent } = this.config;
22
- const { verbose, "file-logging": fileLogging, "web-workspace-id": webWorkspaceId, "debug-server-port": debugServerPort, } = flags;
23
- const errorHandler = (error) => {
24
- if (verbose)
25
- this.warn(error);
26
- };
27
- const ephemeralAccessPoint = createEphemeralAccessPointIfNeeded(configDir, userAgent, webWorkspaceId);
28
- const { version, versionMismatchWarning, logFile, accessPointName, waitReady, waitExit, } = await (0, spawnClient_1.spawnClient)(configDir, cacheDir, errorHandler, {
29
- verbose,
30
- fileLogging,
31
- debugServerPort,
32
- ephemeralAccessPoint,
10
+ const clientManager = await ClientManager_1.ClientManager.create({
11
+ configDir,
12
+ cacheDir,
13
+ userAgent,
14
+ verbose: flags.verbose,
15
+ fileLogging: flags["file-logging"],
16
+ debugServerPort: flags["debug-server-port"],
17
+ webWorkspaceId: flags["web-workspace-id"],
33
18
  });
34
- this.log(`Starting Autify Connect Client for Access Point "${accessPointName}" (${version})...`);
35
- if (versionMismatchWarning)
36
- this.warn(versionMismatchWarning);
37
- if (logFile)
38
- this.log(`Log file is located at ${logFile}`);
19
+ this.log("Starting Autify Connect Client...");
20
+ await clientManager.start();
39
21
  this.log("Waiting until Autify Connect Client is ready...");
40
- try {
41
- await waitReady();
42
- this.log("Autify Connect Client is ready!");
43
- }
44
- catch (error) {
45
- this.warn(error);
46
- }
47
- finally {
48
- const [code, signal, deletedAccessPointName] = await waitExit();
49
- if (deletedAccessPointName)
50
- this.log(`Autify Connect Access Point was deleted: "${deletedAccessPointName}"`);
51
- this.log(`Autify Connect Client exited (code: ${code}, signal: ${signal})`);
52
- this.exit(code !== null && code !== void 0 ? code : 1);
53
- }
22
+ await clientManager.onceReady();
23
+ this.log("Waiting for terminating (forever)...");
24
+ await clientManager.onceTerminating();
25
+ this.log("Waiting until Autify Connect Client exits...");
26
+ const exitCode = (_a = (await clientManager.onceDone())) !== null && _a !== void 0 ? _a : 1;
27
+ this.log(`Exiting this command with the same exit code(${exitCode})...`);
28
+ this.exit(exitCode);
54
29
  }
55
30
  }
56
31
  exports.default = ConnectClientStart;
57
- ConnectClientStart.description = "[Experimental] Start Autify Connect Client";
58
- ConnectClientStart.examples = ["<%= config.bin %> <%= command.id %>"];
32
+ ConnectClientStart.description = "Start Autify Connect Client";
33
+ ConnectClientStart.examples = [
34
+ "With pre-created Access Point:\n<%= config.bin %> <%= command.id %>",
35
+ "With ephemeral Access Point of Autify for Web:\n<%= config.bin %> <%= command.id %> --web-workspace-id 000",
36
+ ];
59
37
  ConnectClientStart.flags = {
60
38
  verbose: core_1.Flags.boolean({
61
39
  description: "Make the operation more talkative.",
@@ -66,9 +44,9 @@ ConnectClientStart.flags = {
66
44
  default: false,
67
45
  }),
68
46
  "debug-server-port": core_1.Flags.integer({
69
- description: `[default: ${spawnClient_1.DEFAULT_CLIENT_DEBUG_SERVER_PORT}] The server for debugging and monitoring launches on your local machine on the given port.`,
47
+ description: `The server for debugging and monitoring launches on your local machine on the given port. It will use a radom port if not specified.`,
70
48
  }),
71
49
  "web-workspace-id": core_1.Flags.integer({
72
- 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.",
50
+ 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 create/set`, instead.",
73
51
  }),
74
52
  };
@@ -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 getMobileClient_1 = require("../../../autify/mobile/getMobileClient");
6
5
  class MobileApiDescribeTestResult extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(MobileApiDescribeTestResult);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
12
- const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getMobileClient_1.getMobileClient)(configDir, userAgent);
13
10
  const res = await client.describeTestResult(flags["project-id"], flags.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 getMobileClient_1 = require("../../../autify/mobile/getMobileClient");
6
5
  class MobileApiListTestResults extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(MobileApiListTestResults);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
12
- const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getMobileClient_1.getMobileClient)(configDir, userAgent);
13
10
  const res = await client.listTestResults(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 getMobileClient_1 = require("../../../autify/mobile/getMobileClient");
6
5
  class MobileApiRunTestPlan extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(MobileApiRunTestPlan);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
12
- const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getMobileClient_1.getMobileClient)(configDir, userAgent);
13
10
  const res = await client.runTestPlan(flags["test-plan-id"], JSON.parse(flags["run-test-plan-request"]));
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 getMobileClient_1 = require("../../../autify/mobile/getMobileClient");
6
5
  class MobileApiUploadBuild extends core_1.Command {
7
6
  async run() {
8
7
  const { flags } = await this.parse(MobileApiUploadBuild);
9
8
  const { configDir, userAgent } = this.config;
10
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
11
- const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
12
- const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
9
+ const client = (0, getMobileClient_1.getMobileClient)(configDir, userAgent);
13
10
  const res = await client.uploadBuild(flags["project-id"], flags.file);
14
11
  console.log(JSON.stringify(res.data, null, 2));
15
12
  }
@@ -1,21 +1,18 @@
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 getBuildDetailUrl_1 = require("../../../autify/mobile/getBuildDetailUrl");
7
+ const getMobileClient_1 = require("../../../autify/mobile/getMobileClient");
8
8
  const uploadBuild_1 = require("../../../autify/mobile/uploadBuild");
9
- const config_1 = require("../../../config");
10
9
  class MobileBuildUpload extends core_1.Command {
11
10
  async run() {
12
11
  const { args, flags } = await this.parse(MobileBuildUpload);
13
12
  const buildPath = args["build-path"];
14
13
  const workspaceId = flags["workspace-id"];
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
- const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
15
+ const client = (0, getMobileClient_1.getMobileClient)(configDir, userAgent);
19
16
  const [buildId, os] = await (0, uploadBuild_1.uploadBuild)(client, workspaceId, buildPath);
20
17
  const buildDetailUrl = (0, getBuildDetailUrl_1.getBuildDetailUrl)(configDir, workspaceId, os, buildId);
21
18
  this.log(`${node_emoji_1.default.get("white_check_mark")} Successfully uploaded ${buildPath} (ID: ${buildId}). See ${buildDetailUrl}`);
@@ -1,13 +1,12 @@
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 errors_1 = require("@oclif/errors");
7
6
  const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
7
+ const getMobileClient_1 = require("../../../autify/mobile/getMobileClient");
8
8
  const getTestResultUrl_1 = require("../../../autify/mobile/getTestResultUrl");
9
9
  const parseTestPlanUrl_1 = require("../../../autify/mobile/parseTestPlanUrl");
10
- const config_1 = require("../../../config");
11
10
  const upload_1 = tslib_1.__importDefault(require("../build/upload"));
12
11
  const wait_1 = tslib_1.__importDefault(require("./wait"));
13
12
  class MobileTestRun extends core_1.Command {
@@ -16,9 +15,7 @@ class MobileTestRun extends core_1.Command {
16
15
  let buildId = flags["build-id"];
17
16
  const buildPath = flags["build-path"];
18
17
  const { configDir, userAgent } = this.config;
19
- const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
20
- const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
21
- const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
18
+ const client = (0, getMobileClient_1.getMobileClient)(configDir, userAgent);
22
19
  const { workspaceId, testPlanId } = (0, parseTestPlanUrl_1.parseTestPlanUrl)(args["test-plan-url"]);
23
20
  if (buildPath) {
24
21
  const uploadArgs = ["--workspace-id", workspaceId, buildPath];