@autifyhq/autify-cli 0.8.0 → 0.10.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.
- package/README.md +79 -28
- package/bin/dev.cmd +16 -2
- package/bin/run.cmd +16 -2
- package/dist/autify/connect/accessPointConfig.d.ts +2 -0
- package/dist/autify/connect/accessPointConfig.js +33 -0
- package/dist/autify/connect/installClient.d.ts +11 -2
- package/dist/autify/connect/installClient.js +65 -28
- package/dist/autify/connect/spawnClient.d.ts +18 -11
- package/dist/autify/connect/spawnClient.js +128 -42
- package/dist/autify/web/parseAutifyTestUrl.d.ts +11 -0
- package/dist/autify/web/parseAutifyTestUrl.js +37 -0
- package/dist/autify/web/runTest.d.ts +2 -2
- package/dist/autify/web/runTest.js +6 -33
- package/dist/autify/web/waitTestResult.js +9 -0
- package/dist/commands/connect/access-point/create.d.ts +11 -0
- package/dist/commands/connect/access-point/create.js +41 -0
- package/dist/commands/connect/access-point/set.js +5 -3
- package/dist/commands/connect/client/install.d.ts +5 -1
- package/dist/commands/connect/client/install.js +18 -6
- package/dist/commands/connect/client/start.d.ts +2 -0
- package/dist/commands/connect/client/start.js +41 -13
- package/dist/commands/mobile/test/run.d.ts +1 -0
- package/dist/commands/mobile/test/run.js +45 -12
- package/dist/commands/mobile/test/wait.js +2 -1
- package/dist/commands/web/test/run.d.ts +4 -0
- package/dist/commands/web/test/run.js +87 -37
- package/dist/commands/web/test/wait.js +2 -1
- package/dist/config.d.ts +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -19,8 +19,9 @@ See our official document: https://help.autify.com/docs/autify-command-line-inte
|
|
|
19
19
|
# Commands
|
|
20
20
|
|
|
21
21
|
<!-- commands -->
|
|
22
|
+
* [`autify connect access-point create`](#autify-connect-access-point-create)
|
|
22
23
|
* [`autify connect access-point set`](#autify-connect-access-point-set)
|
|
23
|
-
* [`autify connect client install`](#autify-connect-client-install)
|
|
24
|
+
* [`autify connect client install [VERSION]`](#autify-connect-client-install-version)
|
|
24
25
|
* [`autify connect client start`](#autify-connect-client-start)
|
|
25
26
|
* [`autify help [COMMAND]`](#autify-help-command)
|
|
26
27
|
* [`autify mobile api describe-test-result`](#autify-mobile-api-describe-test-result)
|
|
@@ -47,6 +48,25 @@ See our official document: https://help.autify.com/docs/autify-command-line-inte
|
|
|
47
48
|
* [`autify web test run SCENARIO-OR-TEST-PLAN-URL`](#autify-web-test-run-scenario-or-test-plan-url)
|
|
48
49
|
* [`autify web test wait TEST-RESULT-URL`](#autify-web-test-wait-test-result-url)
|
|
49
50
|
|
|
51
|
+
## `autify connect access-point create`
|
|
52
|
+
|
|
53
|
+
[Experimental] Create an Autify Connect Access Point
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
USAGE
|
|
57
|
+
$ autify connect access-point create --name <value> [--web-workspace-id <value>]
|
|
58
|
+
|
|
59
|
+
FLAGS
|
|
60
|
+
--name=<value> (required) Name of Autify Connect Access Point to be created
|
|
61
|
+
--web-workspace-id=<value> Workspace ID of Autify for Web to which the Access Point belong
|
|
62
|
+
|
|
63
|
+
DESCRIPTION
|
|
64
|
+
[Experimental] Create an Autify Connect Access Point
|
|
65
|
+
|
|
66
|
+
EXAMPLES
|
|
67
|
+
$ autify connect access-point create --name NAME --web-workspace-id ID
|
|
68
|
+
```
|
|
69
|
+
|
|
50
70
|
## `autify connect access-point set`
|
|
51
71
|
|
|
52
72
|
[Experimental] Set Autify Connect Access Point
|
|
@@ -71,19 +91,32 @@ EXAMPLES
|
|
|
71
91
|
$ autify connect access-point set --name=NAME < key.txt
|
|
72
92
|
```
|
|
73
93
|
|
|
74
|
-
## `autify connect client install`
|
|
94
|
+
## `autify connect client install [VERSION]`
|
|
75
95
|
|
|
76
|
-
[Experimental] Install
|
|
96
|
+
[Experimental] Install Autify Connect Client
|
|
77
97
|
|
|
78
98
|
```
|
|
79
99
|
USAGE
|
|
80
|
-
$ autify connect client install
|
|
100
|
+
$ autify connect client install [VERSION]
|
|
101
|
+
|
|
102
|
+
ARGUMENTS
|
|
103
|
+
VERSION [default: v0.6.2] Specify the target version of Autify Connect Client.
|
|
81
104
|
|
|
82
105
|
DESCRIPTION
|
|
83
|
-
[Experimental] Install
|
|
106
|
+
[Experimental] Install Autify Connect Client
|
|
84
107
|
|
|
85
108
|
EXAMPLES
|
|
86
|
-
|
|
109
|
+
(Recommended) Install the supported version:
|
|
110
|
+
|
|
111
|
+
$ autify connect client install
|
|
112
|
+
|
|
113
|
+
Install a specific version:
|
|
114
|
+
|
|
115
|
+
$ autify connect client install v0.6.1
|
|
116
|
+
|
|
117
|
+
Install a stable version:
|
|
118
|
+
|
|
119
|
+
$ autify connect client install stable
|
|
87
120
|
```
|
|
88
121
|
|
|
89
122
|
## `autify connect client start`
|
|
@@ -92,11 +125,15 @@ EXAMPLES
|
|
|
92
125
|
|
|
93
126
|
```
|
|
94
127
|
USAGE
|
|
95
|
-
$ autify connect client start [--verbose] [--file-logging]
|
|
128
|
+
$ autify connect client start [--verbose] [--file-logging] [--debug-server-port <value>] [--web-workspace-id <value>]
|
|
96
129
|
|
|
97
130
|
FLAGS
|
|
98
|
-
--
|
|
99
|
-
|
|
131
|
+
--debug-server-port=<value> [default: 3000] The server for debugging and monitoring launches on your local machine on
|
|
132
|
+
the given port.
|
|
133
|
+
--file-logging Logging Autify Connect Client log to a file instead of console.
|
|
134
|
+
--verbose Make the operation more talkative.
|
|
135
|
+
--web-workspace-id=<value> Workspace ID of Autify for Web to create an ephemeral Access Point. If not specified, it
|
|
136
|
+
will use the one configured by `autify connect access-point set`, instead.
|
|
100
137
|
|
|
101
138
|
DESCRIPTION
|
|
102
139
|
[Experimental] Start Autify Connect Client
|
|
@@ -264,16 +301,18 @@ Run a test plan.
|
|
|
264
301
|
```
|
|
265
302
|
USAGE
|
|
266
303
|
$ autify mobile test run [TEST-PLAN-URL] [--build-id <value> | --build-path <value>] [-w] [-t <value>] [-v]
|
|
304
|
+
[--max-retry-count <value>]
|
|
267
305
|
|
|
268
306
|
ARGUMENTS
|
|
269
307
|
TEST-PLAN-URL Test plan URL e.g. https://mobile-app.autify.com/projects/<ID>/test_plans/<ID>
|
|
270
308
|
|
|
271
309
|
FLAGS
|
|
272
|
-
-t, --timeout=<value>
|
|
273
|
-
-v, --verbose
|
|
274
|
-
-w, --wait
|
|
275
|
-
--build-id=<value>
|
|
276
|
-
--build-path=<value>
|
|
310
|
+
-t, --timeout=<value> [default: 300] Timeout seconds when waiting for the finish of the test execution.
|
|
311
|
+
-v, --verbose Verbose output
|
|
312
|
+
-w, --wait Wait until the test finishes.
|
|
313
|
+
--build-id=<value> ID of the already uploaded build.
|
|
314
|
+
--build-path=<value> File path to the iOS app (*.app) or Android app (*.apk).
|
|
315
|
+
--max-retry-count=<value> Maximum retry count. The command can take up to timeout * (max-retry-count + 1).
|
|
277
316
|
|
|
278
317
|
DESCRIPTION
|
|
279
318
|
Run a test plan.
|
|
@@ -600,26 +639,38 @@ Run a scenario or test plan.
|
|
|
600
639
|
```
|
|
601
640
|
USAGE
|
|
602
641
|
$ autify web test run [SCENARIO-OR-TEST-PLAN-URL] [-n <value>] [-r <value>] [--autify-connect <value> |
|
|
603
|
-
--autify-connect-client] [--
|
|
604
|
-
<value>] [
|
|
642
|
+
--autify-connect-client] [--autify-connect-client-verbose ] [--autify-connect-client-file-logging ]
|
|
643
|
+
[--autify-connect-client-debug-server-port <value> ] [--os <value>] [--os-version <value>] [--browser <value>]
|
|
644
|
+
[--device <value>] [--device-type <value>] [-w] [-t <value>] [-v] [--max-retry-count <value>]
|
|
605
645
|
|
|
606
646
|
ARGUMENTS
|
|
607
647
|
SCENARIO-OR-TEST-PLAN-URL Scenario URL or Test plan URL e.g.
|
|
608
648
|
https://app.autify.com/projects/<ID>/(scenarios|test_plans)/<ID>
|
|
609
649
|
|
|
610
650
|
FLAGS
|
|
611
|
-
-n, --name=<value>
|
|
612
|
-
-r, --url-replacements=<value>...
|
|
613
|
-
-t, --timeout=<value>
|
|
614
|
-
|
|
615
|
-
-
|
|
616
|
-
|
|
617
|
-
--autify-connect
|
|
618
|
-
|
|
619
|
-
--
|
|
620
|
-
|
|
621
|
-
--
|
|
622
|
-
|
|
651
|
+
-n, --name=<value> Name of the test execution. (Only for test scenario execution.)
|
|
652
|
+
-r, --url-replacements=<value>... URL replacements. Example: http://example.com=http://example.net
|
|
653
|
+
-t, --timeout=<value> [default: 300] Timeout seconds when waiting for the finish of the
|
|
654
|
+
test execution.
|
|
655
|
+
-v, --verbose Verbose output
|
|
656
|
+
-w, --wait Wait until the test finishes.
|
|
657
|
+
--autify-connect=<value> Name of the Autify Connect Access Point (Only for test scenario
|
|
658
|
+
execution.)
|
|
659
|
+
--autify-connect-client [Experimental] Start Autify Connect Client (Only for test scenario
|
|
660
|
+
execution.)
|
|
661
|
+
--autify-connect-client-debug-server-port=<value> [Experimental] [default: 3000] Port for Autify Connect Client debug
|
|
662
|
+
server.
|
|
663
|
+
--autify-connect-client-file-logging [Experimental] Logging Autify Connect Client log to a file instead
|
|
664
|
+
of console.
|
|
665
|
+
--autify-connect-client-verbose [Experimental] Verbose output for Autify Connect Client (Only for
|
|
666
|
+
test scenario execution.)
|
|
667
|
+
--browser=<value> Browser to run the test
|
|
668
|
+
--device=<value> Device to run the test
|
|
669
|
+
--device-type=<value> Device type to run the test
|
|
670
|
+
--max-retry-count=<value> Maximum retry count. The command can take up to timeout *
|
|
671
|
+
(max-retry-count + 1).
|
|
672
|
+
--os=<value> OS to run the test
|
|
673
|
+
--os-version=<value> OS version to run the test
|
|
623
674
|
|
|
624
675
|
DESCRIPTION
|
|
625
676
|
Run a scenario or test plan.
|
package/bin/dev.cmd
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
@
|
|
1
|
+
@ECHO off
|
|
2
|
+
GOTO start
|
|
3
|
+
:find_dp0
|
|
4
|
+
SET dp0=%~dp0
|
|
5
|
+
EXIT /b
|
|
6
|
+
:start
|
|
7
|
+
SETLOCAL
|
|
8
|
+
CALL :find_dp0
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
IF EXIST "%dp0%\node.exe" (
|
|
11
|
+
SET "_prog=%dp0%\node.exe"
|
|
12
|
+
) ELSE (
|
|
13
|
+
SET "_prog=node"
|
|
14
|
+
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\dev" %*
|
package/bin/run.cmd
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
@
|
|
1
|
+
@ECHO off
|
|
2
|
+
GOTO start
|
|
3
|
+
:find_dp0
|
|
4
|
+
SET dp0=%~dp0
|
|
5
|
+
EXIT /b
|
|
6
|
+
:start
|
|
7
|
+
SETLOCAL
|
|
8
|
+
CALL :find_dp0
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
IF EXIST "%dp0%\node.exe" (
|
|
11
|
+
SET "_prog=%dp0%\node.exe"
|
|
12
|
+
) ELSE (
|
|
13
|
+
SET "_prog=node"
|
|
14
|
+
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\run" %*
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.saveAccessPoint = exports.confirmOverwriteAccessPoint = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/* eslint-disable unicorn/filename-case */
|
|
6
|
+
const errors_1 = require("@oclif/errors");
|
|
7
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
|
+
const config_1 = require("../../config");
|
|
9
|
+
const confirmOverwriteAccessPoint = async (configDir) => {
|
|
10
|
+
const existingName = (0, config_1.get)(configDir, "AUTIFY_CONNECT_ACCESS_POINT_NAME");
|
|
11
|
+
if (existingName) {
|
|
12
|
+
const message = `You've already set an Access Point at ${configDir} (name: ${existingName}). Are you ok to clear its configuration from this machine?`;
|
|
13
|
+
const res = await inquirer_1.default.prompt([
|
|
14
|
+
{
|
|
15
|
+
name: "confirmed",
|
|
16
|
+
message,
|
|
17
|
+
type: "confirm",
|
|
18
|
+
default: false,
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
if (!res.confirmed) {
|
|
22
|
+
throw new errors_1.CLIError(`Cancelled to overwrite the existing Access Point. It stays as is (name: ${existingName})`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.confirmOverwriteAccessPoint = confirmOverwriteAccessPoint;
|
|
27
|
+
const saveAccessPoint = (configDir, name, key) => {
|
|
28
|
+
(0, config_1.set)(configDir, "AUTIFY_CONNECT_ACCESS_POINT_NAME", name);
|
|
29
|
+
(0, config_1.set)(configDir, "AUTIFY_CONNECT_ACCESS_POINT_KEY", key);
|
|
30
|
+
return (`Access Point name (${name}) and key (****) are stored in ${configDir}. ` +
|
|
31
|
+
"Execute `autify connect client start` to start a client with this Access Point.");
|
|
32
|
+
};
|
|
33
|
+
exports.saveAccessPoint = saveAccessPoint;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { CLIError } from "@oclif/errors";
|
|
2
|
+
export declare const AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION = "v0.6.2";
|
|
3
|
+
export declare type ClientMode = "fake" | "real";
|
|
4
|
+
export declare class ConnectClientVersionMismatchError extends CLIError {
|
|
5
|
+
readonly expected: string;
|
|
6
|
+
readonly reality: string;
|
|
7
|
+
constructor(expected: string, reality: string);
|
|
8
|
+
}
|
|
9
|
+
export declare const validateVersion: (versionString: string, version: string) => Promise<void>;
|
|
10
|
+
export declare const getInstallPath: (configDir: string, cacheDir: string) => string;
|
|
2
11
|
export declare const getInstallVersion: (path: string) => Promise<string>;
|
|
3
|
-
export declare const installClient: (cacheDir: string) => Promise<{
|
|
12
|
+
export declare const installClient: (configDir: string, cacheDir: string, version: string) => Promise<{
|
|
4
13
|
version: string;
|
|
5
14
|
path: string;
|
|
6
15
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installClient = exports.getInstallVersion = exports.getInstallPath = void 0;
|
|
3
|
+
exports.installClient = exports.getInstallVersion = exports.getInstallPath = exports.validateVersion = exports.ConnectClientVersionMismatchError = exports.AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/* eslint-disable unicorn/filename-case */
|
|
6
6
|
const errors_1 = require("@oclif/errors");
|
|
@@ -10,8 +10,19 @@ const node_fs_1 = require("node:fs");
|
|
|
10
10
|
const node_stream_1 = require("node:stream");
|
|
11
11
|
const node_util_1 = require("node:util");
|
|
12
12
|
const node_path_1 = require("node:path");
|
|
13
|
-
const node_child_process_1 = require("node:child_process");
|
|
14
13
|
const unzip_stream_1 = require("unzip-stream");
|
|
14
|
+
const node_child_process_1 = require("node:child_process");
|
|
15
|
+
const config_1 = require("../../config");
|
|
16
|
+
// Update whenever to bump supported version.
|
|
17
|
+
exports.AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION = "v0.6.2";
|
|
18
|
+
const getMode = (configDir) => {
|
|
19
|
+
const mode = (0, config_1.get)(configDir, "AUTIFY_CONNECT_CLIENT_MODE");
|
|
20
|
+
if (!mode)
|
|
21
|
+
return "real";
|
|
22
|
+
if (!["fake", "real"].includes(mode))
|
|
23
|
+
throw new errors_1.CLIError(`Unknown value is specified by AUTIFY_CONNECT_CLIENT_MODE: ${mode}`);
|
|
24
|
+
return mode;
|
|
25
|
+
};
|
|
15
26
|
const getOs = () => {
|
|
16
27
|
const os = node_process_1.platform;
|
|
17
28
|
if (os === "linux")
|
|
@@ -32,15 +43,18 @@ const getArch = () => {
|
|
|
32
43
|
throw new errors_1.CLIError(`Unsupported Architecture: ${node_process_1.arch}`);
|
|
33
44
|
};
|
|
34
45
|
const getExt = () => (getOs() === "windows" ? "zip" : "tar.gz");
|
|
35
|
-
const
|
|
36
|
-
const
|
|
46
|
+
const realBaseUrl = "https://autifyconnect.s3.ap-northeast-1.amazonaws.com/autifyconnect/versions";
|
|
47
|
+
const fakeBaseUrl = "https://autifyconnect.s3.ap-northeast-1.amazonaws.com/fake/versions";
|
|
48
|
+
const getUrl = (mode, version) => {
|
|
49
|
+
const baseUrl = mode === "fake" ? fakeBaseUrl : realBaseUrl;
|
|
50
|
+
const prefix = mode === "fake" ? "autifyconnect-fake" : "autifyconnect";
|
|
37
51
|
const os = getOs();
|
|
38
52
|
const arch = getArch();
|
|
39
53
|
const ext = getExt();
|
|
40
|
-
return new URL(`${baseUrl}
|
|
54
|
+
return new URL(`${baseUrl}/${version}/${prefix}_${os}_${arch}.${ext}`);
|
|
41
55
|
};
|
|
42
|
-
const download = async (workspaceDir) => {
|
|
43
|
-
const url = getUrl();
|
|
56
|
+
const download = async (workspaceDir, mode, version) => {
|
|
57
|
+
const url = getUrl(mode, version);
|
|
44
58
|
const downloadPath = (0, node_path_1.join)(workspaceDir, (0, node_path_1.basename)(url.pathname));
|
|
45
59
|
const response = await (0, node_fetch_1.default)(url);
|
|
46
60
|
if (!response.ok)
|
|
@@ -52,56 +66,79 @@ const download = async (workspaceDir) => {
|
|
|
52
66
|
const extract = async (downloadPath) => {
|
|
53
67
|
const file = (0, node_path_1.basename)(downloadPath);
|
|
54
68
|
const dir = (0, node_path_1.dirname)(downloadPath);
|
|
69
|
+
const binaryName = file.startsWith("autifyconnect-fake")
|
|
70
|
+
? "autifyconnect-fake"
|
|
71
|
+
: "autifyconnect";
|
|
55
72
|
if (file.endsWith(".tar.gz")) {
|
|
56
|
-
|
|
57
|
-
(0, node_child_process_1.
|
|
58
|
-
return (0, node_path_1.join)(dir,
|
|
73
|
+
// TODO: Pure JS
|
|
74
|
+
await (0, node_util_1.promisify)(node_child_process_1.execFile)("tar", ["xvzf", file], { cwd: dir });
|
|
75
|
+
return (0, node_path_1.join)(dir, binaryName);
|
|
59
76
|
}
|
|
60
77
|
if (file.endsWith(".zip")) {
|
|
61
78
|
const streamPipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
|
|
62
79
|
await streamPipeline((0, node_fs_1.createReadStream)(downloadPath),
|
|
63
80
|
// eslint-disable-next-line new-cap
|
|
64
81
|
(0, unzip_stream_1.Extract)({ path: dir }));
|
|
65
|
-
return (0, node_path_1.join)(dir,
|
|
82
|
+
return (0, node_path_1.join)(dir, `${binaryName}.exe`);
|
|
66
83
|
}
|
|
67
84
|
throw new errors_1.CLIError(`Unsupported file format: ${downloadPath}`);
|
|
68
85
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
throw new errors_1.CLIError(`Autify Connect Client binary doesn't work properly (path: ${path}, error: ${error})`);
|
|
86
|
+
class ConnectClientVersionMismatchError extends errors_1.CLIError {
|
|
87
|
+
constructor(expected, reality) {
|
|
88
|
+
super(`Autify Connect Client version mismatch: ${reality} !== ${expected} (expected)`);
|
|
89
|
+
this.expected = expected;
|
|
90
|
+
this.reality = reality;
|
|
75
91
|
}
|
|
92
|
+
}
|
|
93
|
+
exports.ConnectClientVersionMismatchError = ConnectClientVersionMismatchError;
|
|
94
|
+
const validateVersion = async (versionString, version) => {
|
|
95
|
+
// No need to validate version if it's installed as "stable".
|
|
96
|
+
if (version === "stable")
|
|
97
|
+
return;
|
|
98
|
+
// Format example: Autify Connect version v0.6.1, build ca0972e
|
|
99
|
+
if (!versionString.includes(version + ","))
|
|
100
|
+
throw new ConnectClientVersionMismatchError(version, versionString);
|
|
76
101
|
};
|
|
102
|
+
exports.validateVersion = validateVersion;
|
|
77
103
|
const getWorkspaceDir = (cacheDir) => (0, node_path_1.join)(cacheDir, "autifyconnect-install-workspace");
|
|
78
|
-
const getInstallPath = (cacheDir) =>
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
const getInstallPath = (configDir, cacheDir) => {
|
|
105
|
+
const mode = getMode(configDir);
|
|
106
|
+
const binaryName = mode === "fake" ? "autifyconnect-fake" : "autifyconnect";
|
|
107
|
+
return getOs() === "windows"
|
|
108
|
+
? (0, node_path_1.join)(cacheDir, `${binaryName}.exe`)
|
|
109
|
+
: (0, node_path_1.join)(cacheDir, binaryName);
|
|
110
|
+
};
|
|
81
111
|
exports.getInstallPath = getInstallPath;
|
|
82
112
|
const getInstallVersion = async (path) => {
|
|
83
|
-
if (!(0, node_fs_1.existsSync)(path))
|
|
113
|
+
if (!(0, node_fs_1.existsSync)(path)) {
|
|
84
114
|
throw new errors_1.CLIError(`Autify Connect Client isn't installed yet at ${path}. Run \`autify connect client install\` first.`);
|
|
85
|
-
|
|
115
|
+
}
|
|
116
|
+
const { stderr } = await (0, node_util_1.promisify)(node_child_process_1.execFile)(path, ["--version"], {
|
|
117
|
+
env: node_process_1.env,
|
|
118
|
+
});
|
|
86
119
|
const version = stderr.trim();
|
|
87
120
|
if (version === "")
|
|
88
121
|
throw new errors_1.CLIError("Version is empty");
|
|
89
122
|
return version;
|
|
90
123
|
};
|
|
91
124
|
exports.getInstallVersion = getInstallVersion;
|
|
92
|
-
const installClient = async (cacheDir) => {
|
|
125
|
+
const installClient = async (configDir, cacheDir, version) => {
|
|
126
|
+
const mode = getMode(configDir);
|
|
93
127
|
const workspaceDir = getWorkspaceDir(cacheDir);
|
|
94
128
|
// Clean up workspace in case something is left by previous command.
|
|
95
129
|
if ((0, node_fs_1.existsSync)(workspaceDir))
|
|
96
130
|
(0, node_fs_1.rmSync)(workspaceDir, { recursive: true, force: true });
|
|
97
131
|
(0, node_fs_1.mkdirSync)(workspaceDir);
|
|
98
|
-
const downloadPath = await download(workspaceDir);
|
|
132
|
+
const downloadPath = await download(workspaceDir, mode, version);
|
|
99
133
|
const extractPath = await extract(downloadPath);
|
|
100
134
|
// Pre-install validation
|
|
101
|
-
await
|
|
102
|
-
|
|
135
|
+
const preInstalledVersionString = await (0, exports.getInstallVersion)(extractPath);
|
|
136
|
+
await (0, exports.validateVersion)(preInstalledVersionString, version);
|
|
137
|
+
const installPath = (0, exports.getInstallPath)(configDir, cacheDir);
|
|
103
138
|
(0, node_fs_1.renameSync)(extractPath, installPath);
|
|
104
|
-
|
|
139
|
+
// Re-validate against the final path
|
|
140
|
+
const versionString = await (0, exports.getInstallVersion)(installPath);
|
|
141
|
+
await (0, exports.validateVersion)(versionString, version);
|
|
105
142
|
// Clean up workspace. Ignore any exception as install is already done.
|
|
106
143
|
try {
|
|
107
144
|
(0, node_fs_1.rmSync)(workspaceDir, { recursive: true, force: true });
|
|
@@ -110,7 +147,7 @@ const installClient = async (cacheDir) => {
|
|
|
110
147
|
console.error(`Workspace clean up failed. Ignoring because already installed. (error: ${error})`);
|
|
111
148
|
}
|
|
112
149
|
return {
|
|
113
|
-
version,
|
|
150
|
+
version: versionString,
|
|
114
151
|
path: installPath,
|
|
115
152
|
};
|
|
116
153
|
};
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { WebClient } from "@autifyhq/autify-sdk";
|
|
3
|
+
declare type EphemeralAccessPoint = Readonly<{
|
|
4
|
+
webClient: WebClient;
|
|
5
|
+
workspaceId: number;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const DEFAULT_CLIENT_DEBUG_SERVER_PORT = 3000;
|
|
8
|
+
declare type ProcessExit = [code: number | null, signal: NodeJS.Signals | null];
|
|
8
9
|
export declare type AutifyConnectClient = Readonly<{
|
|
9
10
|
version: string;
|
|
11
|
+
versionMismatchWarning?: string;
|
|
10
12
|
logFile?: string;
|
|
11
|
-
|
|
12
|
-
kill: () => void
|
|
13
|
-
waitReady: () => Promise<
|
|
14
|
-
waitExit: () => Promise<
|
|
13
|
+
accessPointName: string;
|
|
14
|
+
kill: () => Promise<void>;
|
|
15
|
+
waitReady: () => Promise<void>;
|
|
16
|
+
waitExit: () => Promise<[
|
|
17
|
+
...ProcessExit,
|
|
18
|
+
...[deletedAccessPointName?: string]
|
|
19
|
+
]>;
|
|
15
20
|
}>;
|
|
16
21
|
declare type SpawnClientOptions = Readonly<{
|
|
17
22
|
verbose?: boolean;
|
|
18
23
|
fileLogging?: boolean;
|
|
24
|
+
debugServerPort?: number;
|
|
25
|
+
ephemeralAccessPoint?: EphemeralAccessPoint;
|
|
19
26
|
}>;
|
|
20
|
-
export declare const spawnClient: (configDir: string, cacheDir: string, { verbose, fileLogging }: SpawnClientOptions) => Promise<AutifyConnectClient>;
|
|
27
|
+
export declare const spawnClient: (configDir: string, cacheDir: string, errorHandler: (error: Error) => void, { verbose, fileLogging, debugServerPort, ephemeralAccessPoint, }: SpawnClientOptions) => Promise<AutifyConnectClient>;
|
|
21
28
|
export {};
|