@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
|
@@ -1,40 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spawnClient = exports.
|
|
3
|
+
exports.spawnClient = exports.DEFAULT_CLIENT_DEBUG_SERVER_PORT = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
/* eslint-disable unicorn/filename-case */
|
|
5
6
|
const errors_1 = require("@oclif/errors");
|
|
6
|
-
const node_child_process_1 = require("node:child_process");
|
|
7
|
-
const config_1 = require("../../config");
|
|
8
7
|
const installClient_1 = require("./installClient");
|
|
9
8
|
const node_readline_1 = require("node:readline");
|
|
10
9
|
const node_events_1 = require("node:events");
|
|
11
10
|
const winston_1 = require("winston");
|
|
12
11
|
const node_path_1 = require("node:path");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
key,
|
|
22
|
-
isEphemeral,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
12
|
+
const config_1 = require("../../config");
|
|
13
|
+
const uuid_1 = require("uuid");
|
|
14
|
+
const node_process_1 = require("node:process");
|
|
15
|
+
const node_child_process_1 = require("node:child_process");
|
|
16
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
17
|
+
const promises_1 = require("node:timers/promises");
|
|
18
|
+
const is_running_1 = tslib_1.__importDefault(require("is-running"));
|
|
19
|
+
const EPHEMERAL_ACCESS_POINT_NAME_PREFIX = "autify-cli-";
|
|
25
20
|
const logger = (0, winston_1.createLogger)({
|
|
26
21
|
level: "debug",
|
|
27
22
|
});
|
|
23
|
+
const getOrCreateAccessPoint = async (configDir, ephemeralAccessPoint) => {
|
|
24
|
+
if (!ephemeralAccessPoint) {
|
|
25
|
+
const accessPointName = (0, config_1.get)(configDir, "AUTIFY_CONNECT_ACCESS_POINT_NAME");
|
|
26
|
+
const accessPointKey = (0, config_1.get)(configDir, "AUTIFY_CONNECT_ACCESS_POINT_KEY");
|
|
27
|
+
if (!accessPointName || !accessPointKey)
|
|
28
|
+
throw new errors_1.CLIError("Access Point is not set. Run `autify connect access-point set` first.");
|
|
29
|
+
return { accessPointName, accessPointKey };
|
|
30
|
+
}
|
|
31
|
+
const { webClient, workspaceId } = ephemeralAccessPoint;
|
|
32
|
+
const name = `${EPHEMERAL_ACCESS_POINT_NAME_PREFIX}${(0, uuid_1.v4)()}`;
|
|
33
|
+
const { name: accessPointName, key: accessPointKey } = (await webClient.createAccessPoint(workspaceId, { name })).data;
|
|
34
|
+
return { accessPointName, accessPointKey };
|
|
35
|
+
};
|
|
36
|
+
const deleteAccessPointIfPossible = async (accessPointName, ephemeralAccessPoint) => {
|
|
37
|
+
if (!ephemeralAccessPoint)
|
|
38
|
+
return;
|
|
39
|
+
if (!accessPointName.startsWith(EPHEMERAL_ACCESS_POINT_NAME_PREFIX))
|
|
40
|
+
return;
|
|
41
|
+
const { webClient, workspaceId } = ephemeralAccessPoint;
|
|
42
|
+
try {
|
|
43
|
+
await webClient.deleteAccessPoint(workspaceId, { name: accessPointName });
|
|
44
|
+
return accessPointName;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Ignore errors since this is best effort.
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const logFormat = (prefix) => winston_1.format.combine(winston_1.format.colorize(), winston_1.format.timestamp(), winston_1.format.align(), winston_1.format.printf(({ timestamp, level, message }) => `${prefix !== null && prefix !== void 0 ? prefix : ""}${timestamp} ${level} ${message}`));
|
|
28
51
|
const setupLogger = (logFile) => {
|
|
29
52
|
if (logFile) {
|
|
30
53
|
logger.add(new winston_1.transports.File({
|
|
31
54
|
filename: logFile,
|
|
32
|
-
format:
|
|
55
|
+
format: logFormat(),
|
|
33
56
|
}));
|
|
34
57
|
}
|
|
35
58
|
else {
|
|
36
59
|
logger.add(new winston_1.transports.Console({
|
|
37
|
-
format:
|
|
60
|
+
format: logFormat("[Autify Connect Client] "),
|
|
38
61
|
}));
|
|
39
62
|
}
|
|
40
63
|
};
|
|
@@ -54,28 +77,49 @@ const onLogMsg = (input, handler) => {
|
|
|
54
77
|
}
|
|
55
78
|
});
|
|
56
79
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
exports.DEFAULT_CLIENT_DEBUG_SERVER_PORT = 3000;
|
|
81
|
+
const requestDebugServer = async (port, path, method = "GET") => {
|
|
82
|
+
const response = await (0, node_fetch_1.default)(`http://localhost:${port}${path}`, { method });
|
|
83
|
+
if (response.ok)
|
|
84
|
+
return response.json();
|
|
85
|
+
throw new errors_1.CLIError(`Request to debug server failed: ${method} ${path} => ${response.status} ${response.statusText}`);
|
|
86
|
+
};
|
|
87
|
+
const requestDebugServerStatus = async (port) => {
|
|
88
|
+
const response = (await requestDebugServer(port, "/status"));
|
|
89
|
+
if (!response.status || !response.message)
|
|
90
|
+
return new errors_1.CLIError(`Invalid response from GET /status: ${JSON.stringify(response)}`);
|
|
91
|
+
return response;
|
|
92
|
+
};
|
|
93
|
+
const spawnClient = async (configDir, cacheDir, errorHandler, { verbose, fileLogging, debugServerPort = exports.DEFAULT_CLIENT_DEBUG_SERVER_PORT, ephemeralAccessPoint, }) => {
|
|
69
94
|
const state = new node_events_1.EventEmitter();
|
|
70
|
-
|
|
71
|
-
const
|
|
95
|
+
state.on("error", errorHandler);
|
|
96
|
+
const clientPath = (0, installClient_1.getInstallPath)(configDir, cacheDir);
|
|
97
|
+
const version = await (0, installClient_1.getInstallVersion)(clientPath);
|
|
98
|
+
let versionMismatchWarning;
|
|
99
|
+
try {
|
|
100
|
+
await (0, installClient_1.validateVersion)(version, installClient_1.AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error instanceof installClient_1.ConnectClientVersionMismatchError) {
|
|
104
|
+
versionMismatchWarning =
|
|
105
|
+
"Installed Autify Connect Client version doesn't match our supported version. " +
|
|
106
|
+
"Consider to run `autify connect client install` to install the supported version. " +
|
|
107
|
+
`(version: ${version}, supported: ${installClient_1.AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION})`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const { accessPointName, accessPointKey } = await getOrCreateAccessPoint(configDir, ephemeralAccessPoint);
|
|
111
|
+
const args = [
|
|
112
|
+
"--log-format",
|
|
113
|
+
"json",
|
|
114
|
+
"--experimental-debug-server-port",
|
|
115
|
+
debugServerPort.toString(),
|
|
116
|
+
];
|
|
72
117
|
if (verbose)
|
|
73
118
|
args.push("--verbose");
|
|
74
|
-
const version = await (0, installClient_1.getInstallVersion)(clientPath);
|
|
75
|
-
const { accessPoint, key } = getOrCreateAccessPoint(configDir);
|
|
76
119
|
const childProcess = (0, node_child_process_1.spawn)(clientPath, args, {
|
|
77
120
|
env: {
|
|
78
|
-
|
|
121
|
+
...node_process_1.env,
|
|
122
|
+
AUTIFY_CONNECT_KEY: accessPointKey,
|
|
79
123
|
},
|
|
80
124
|
});
|
|
81
125
|
const logFile = fileLogging
|
|
@@ -84,23 +128,65 @@ const spawnClient = async (configDir, cacheDir, { verbose = false, fileLogging =
|
|
|
84
128
|
setupLogger(logFile);
|
|
85
129
|
process.on("SIGINT", childProcess.kill);
|
|
86
130
|
process.on("SIGTERM", childProcess.kill);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
131
|
+
const clientReady = (0, node_events_1.once)(state, "ready");
|
|
132
|
+
const childProcessExit = (0, node_events_1.once)(childProcess, "exit");
|
|
90
133
|
childProcess.stderr.pipe(process.stderr);
|
|
91
134
|
onLogMsg(childProcess.stdout, (msg) => {
|
|
92
135
|
if (msg.includes("Successfully connected")) {
|
|
93
136
|
state.emit("ready");
|
|
94
137
|
}
|
|
95
138
|
});
|
|
139
|
+
const statusTimer = setInterval(async () => {
|
|
140
|
+
try {
|
|
141
|
+
const response = await requestDebugServerStatus(debugServerPort);
|
|
142
|
+
if (response instanceof errors_1.CLIError)
|
|
143
|
+
state.emit("error", response);
|
|
144
|
+
else
|
|
145
|
+
state.emit(response.status, response.message);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
state.emit("error", error);
|
|
149
|
+
}
|
|
150
|
+
}, 1000);
|
|
151
|
+
const kill = async () => {
|
|
152
|
+
try {
|
|
153
|
+
await requestDebugServer(debugServerPort, "/terminate", "POST");
|
|
154
|
+
for await (const start of (0, promises_1.setInterval)(1000, Date.now())) {
|
|
155
|
+
if (childProcess.pid && !(0, is_running_1.default)(childProcess.pid))
|
|
156
|
+
break;
|
|
157
|
+
if (Date.now() - start > 5000)
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// Ignore any exceptions to fallback to signal.
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
// Guardrail.
|
|
166
|
+
childProcess.kill("SIGINT");
|
|
167
|
+
}
|
|
168
|
+
};
|
|
96
169
|
return {
|
|
97
170
|
version,
|
|
171
|
+
versionMismatchWarning,
|
|
98
172
|
logFile,
|
|
99
|
-
|
|
100
|
-
kill
|
|
101
|
-
waitReady: async () =>
|
|
102
|
-
|
|
103
|
-
|
|
173
|
+
accessPointName,
|
|
174
|
+
kill,
|
|
175
|
+
waitReady: async () => {
|
|
176
|
+
try {
|
|
177
|
+
await clientReady;
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
await kill();
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
waitExit: async () => {
|
|
185
|
+
const [code, signal] = await childProcessExit;
|
|
186
|
+
clearInterval(statusTimer);
|
|
187
|
+
const deletedAccessPointName = await deleteAccessPointIfPossible(accessPointName, ephemeralAccessPoint);
|
|
188
|
+
return [code, signal, deletedAccessPointName];
|
|
189
|
+
},
|
|
104
190
|
};
|
|
105
191
|
};
|
|
106
192
|
exports.spawnClient = spawnClient;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare type TestScenario = Readonly<{
|
|
2
|
+
workspaceId: number;
|
|
3
|
+
testScenarioId: number;
|
|
4
|
+
testPlanId?: never;
|
|
5
|
+
}>;
|
|
6
|
+
export declare type TestPlan = Readonly<{
|
|
7
|
+
workspaceId: number;
|
|
8
|
+
testScenarioId?: never;
|
|
9
|
+
testPlanId: number;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const parseAutifyTestUrl: (url: string) => TestScenario | TestPlan;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAutifyTestUrl = void 0;
|
|
4
|
+
/* eslint-disable unicorn/filename-case */
|
|
5
|
+
const errors_1 = require("@oclif/errors");
|
|
6
|
+
const parseTestScenarioUrl = (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 testScenarioId = 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 || !testScenarioId)
|
|
14
|
+
return;
|
|
15
|
+
return { workspaceId, testScenarioId };
|
|
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
|
+
const parseAutifyTestUrl = (url) => {
|
|
29
|
+
const testScenario = parseTestScenarioUrl(url);
|
|
30
|
+
const testPlan = parseTestPlanUrl(url);
|
|
31
|
+
if (testScenario)
|
|
32
|
+
return testScenario;
|
|
33
|
+
if (testPlan)
|
|
34
|
+
return testPlan;
|
|
35
|
+
throw new errors_1.CLIError(`Invalid URL: ${url}`);
|
|
36
|
+
};
|
|
37
|
+
exports.parseAutifyTestUrl = parseAutifyTestUrl;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WebClient } from "@autifyhq/autify-sdk";
|
|
2
|
+
import { TestPlan, TestScenario } from "./parseAutifyTestUrl";
|
|
2
3
|
declare type CapabilityOption = Parameters<WebClient["executeScenarios"]>[1]["capabilities"][number];
|
|
3
4
|
declare type CreateUrlReplacementRequest = Parameters<WebClient["createUrlReplacement"]>[1];
|
|
4
5
|
declare type RunTestProps = Readonly<{
|
|
@@ -7,8 +8,7 @@ declare type RunTestProps = Readonly<{
|
|
|
7
8
|
urlReplacements: CreateUrlReplacementRequest[];
|
|
8
9
|
autifyConnectAccessPoint?: string;
|
|
9
10
|
}>;
|
|
10
|
-
export declare const runTest: (client: WebClient,
|
|
11
|
-
workspaceId: number;
|
|
11
|
+
export declare const runTest: (client: WebClient, parsedTest: TestScenario | TestPlan, { option, name, urlReplacements, autifyConnectAccessPoint }: RunTestProps) => Promise<{
|
|
12
12
|
resultId: number;
|
|
13
13
|
capability: string;
|
|
14
14
|
}>;
|
|
@@ -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,16 +30,14 @@ 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,
|
|
56
|
-
const
|
|
57
|
-
|
|
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:
|
|
40
|
+
scenarios: [{ id: testScenarioId }],
|
|
65
41
|
// eslint-disable-next-line camelcase
|
|
66
42
|
url_replacements: urlReplacements,
|
|
67
43
|
...(autifyConnectAccessPoint && {
|
|
@@ -72,19 +48,17 @@ const runTest = async (client, url, { option, name, urlReplacements, autifyConne
|
|
|
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 (
|
|
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
60
|
if (autifyConnectAccessPoint)
|
|
86
61
|
throw new errors_1.CLIError("Running TestPlan doesn't support Autify Connect Access Point");
|
|
87
|
-
const { workspaceId, testPlanId } = testPlan;
|
|
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(
|
|
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,11 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class ConnectAccessPointCreate extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
7
|
+
"web-workspace-id": import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
|
|
8
|
+
};
|
|
9
|
+
static args: never[];
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 accessPointConfig_1 = require("../../../autify/connect/accessPointConfig");
|
|
6
|
+
const config_1 = require("../../../config");
|
|
7
|
+
class ConnectAccessPointCreate extends core_1.Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const { flags } = await this.parse(ConnectAccessPointCreate);
|
|
10
|
+
const { configDir, userAgent } = this.config;
|
|
11
|
+
await (0, accessPointConfig_1.confirmOverwriteAccessPoint)(configDir);
|
|
12
|
+
const { name, "web-workspace-id": webWorkspaceId } = flags;
|
|
13
|
+
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 });
|
|
17
|
+
const response = await client.createAccessPoint(webWorkspaceId, {
|
|
18
|
+
name,
|
|
19
|
+
});
|
|
20
|
+
const key = response.data.key;
|
|
21
|
+
this.log(`Successfully created Access Point: (name: ${name}, web-workspace-id: ${webWorkspaceId})`);
|
|
22
|
+
this.log((0, accessPointConfig_1.saveAccessPoint)(configDir, name, key));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = ConnectAccessPointCreate;
|
|
27
|
+
ConnectAccessPointCreate.description = "[Experimental] Create an Autify Connect Access Point";
|
|
28
|
+
ConnectAccessPointCreate.examples = [
|
|
29
|
+
"<%= config.bin %> <%= command.id %> --name NAME --web-workspace-id ID",
|
|
30
|
+
];
|
|
31
|
+
ConnectAccessPointCreate.flags = {
|
|
32
|
+
name: core_1.Flags.string({
|
|
33
|
+
description: "Name of Autify Connect Access Point to be created",
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
"web-workspace-id": core_1.Flags.integer({
|
|
37
|
+
description: "Workspace ID of Autify for Web to which the Access Point belong",
|
|
38
|
+
exactlyOne: ["web-workspace-id"],
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
ConnectAccessPointCreate.args = [];
|
|
@@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const inquirer = tslib_1.__importStar(require("inquirer"));
|
|
6
|
-
const
|
|
6
|
+
const accessPointConfig_1 = require("../../../autify/connect/accessPointConfig");
|
|
7
7
|
class ConnectAccessPointSet extends core_1.Command {
|
|
8
8
|
async run() {
|
|
9
9
|
const { flags } = await this.parse(ConnectAccessPointSet);
|
|
10
|
+
const { name } = flags;
|
|
11
|
+
const { configDir } = this.config;
|
|
12
|
+
await (0, accessPointConfig_1.confirmOverwriteAccessPoint)(configDir);
|
|
10
13
|
const key = await this.readKeyFromStdin();
|
|
11
|
-
(0,
|
|
12
|
-
(0, config_1.set)(this.config.configDir, "AUTIFY_CONNECT_ACCESS_POINT_KEY", key);
|
|
14
|
+
this.log((0, accessPointConfig_1.saveAccessPoint)(configDir, name, key));
|
|
13
15
|
}
|
|
14
16
|
async readKeyFromStdin() {
|
|
15
17
|
const res = await inquirer.prompt([
|
|
@@ -3,6 +3,10 @@ export default class ConnectClientInstall extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {};
|
|
6
|
-
static args:
|
|
6
|
+
static args: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
default: string;
|
|
10
|
+
}[];
|
|
7
11
|
run(): Promise<void>;
|
|
8
12
|
}
|
|
@@ -4,14 +4,26 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const installClient_1 = require("../../../autify/connect/installClient");
|
|
5
5
|
class ConnectClientInstall extends core_1.Command {
|
|
6
6
|
async run() {
|
|
7
|
-
await this.parse(ConnectClientInstall);
|
|
8
|
-
const { cacheDir } = this.config;
|
|
9
|
-
|
|
7
|
+
const { args } = await this.parse(ConnectClientInstall);
|
|
8
|
+
const { configDir, cacheDir } = this.config;
|
|
9
|
+
core_1.CliUx.ux.action.start(`Installing Autify Connect Client (version: ${args.version})`, "installing", { stdout: true });
|
|
10
|
+
const { version, path } = await (0, installClient_1.installClient)(configDir, cacheDir, args.version);
|
|
11
|
+
core_1.CliUx.ux.action.stop();
|
|
10
12
|
this.log(`Successfully installed Autify Connect Client (path: ${path}, version: ${version})`);
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
exports.default = ConnectClientInstall;
|
|
14
|
-
ConnectClientInstall.description = "[Experimental] Install
|
|
15
|
-
ConnectClientInstall.examples = [
|
|
16
|
+
ConnectClientInstall.description = "[Experimental] Install Autify Connect Client";
|
|
17
|
+
ConnectClientInstall.examples = [
|
|
18
|
+
"(Recommended) Install the supported version:\n<%= config.bin %> <%= command.id %>",
|
|
19
|
+
"Install a specific version:\n<%= config.bin %> <%= command.id %> v0.6.1",
|
|
20
|
+
"Install a stable version:\n<%= config.bin %> <%= command.id %> stable",
|
|
21
|
+
];
|
|
16
22
|
ConnectClientInstall.flags = {};
|
|
17
|
-
ConnectClientInstall.args = [
|
|
23
|
+
ConnectClientInstall.args = [
|
|
24
|
+
{
|
|
25
|
+
name: "version",
|
|
26
|
+
description: "Specify the target version of Autify Connect Client.",
|
|
27
|
+
default: installClient_1.AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
@@ -5,6 +5,8 @@ export default class ConnectClientStart extends Command {
|
|
|
5
5
|
static flags: {
|
|
6
6
|
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
7
|
"file-logging": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
"debug-server-port": import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
|
|
9
|
+
"web-workspace-id": import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
|
|
8
10
|
};
|
|
9
11
|
run(): Promise<void>;
|
|
10
12
|
}
|
|
@@ -1,33 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const autify_sdk_1 = require("@autifyhq/autify-sdk");
|
|
3
4
|
const core_1 = require("@oclif/core");
|
|
4
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
|
+
};
|
|
5
18
|
class ConnectClientStart extends core_1.Command {
|
|
6
19
|
async run() {
|
|
7
|
-
var _a;
|
|
8
20
|
const { flags } = await this.parse(ConnectClientStart);
|
|
9
|
-
const { configDir, cacheDir } = this.config;
|
|
10
|
-
const verbose = flags
|
|
11
|
-
const
|
|
12
|
-
|
|
21
|
+
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, {
|
|
13
29
|
verbose,
|
|
14
30
|
fileLogging,
|
|
31
|
+
debugServerPort,
|
|
32
|
+
ephemeralAccessPoint,
|
|
15
33
|
});
|
|
16
|
-
this.log(`Starting Autify Connect Client for Access Point "${
|
|
34
|
+
this.log(`Starting Autify Connect Client for Access Point "${accessPointName}" (${version})...`);
|
|
35
|
+
if (versionMismatchWarning)
|
|
36
|
+
this.warn(versionMismatchWarning);
|
|
17
37
|
if (logFile)
|
|
18
38
|
this.log(`Log file is located at ${logFile}`);
|
|
39
|
+
this.log("Waiting until Autify Connect Client is ready...");
|
|
19
40
|
try {
|
|
20
|
-
this.log("Waiting until Autify Connect Client is ready...");
|
|
21
41
|
await waitReady();
|
|
22
42
|
this.log("Autify Connect Client is ready!");
|
|
23
|
-
await waitExit();
|
|
24
43
|
}
|
|
25
44
|
catch (error) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
31
53
|
}
|
|
32
54
|
}
|
|
33
55
|
}
|
|
@@ -43,4 +65,10 @@ ConnectClientStart.flags = {
|
|
|
43
65
|
description: "Logging Autify Connect Client log to a file instead of console.",
|
|
44
66
|
default: false,
|
|
45
67
|
}),
|
|
68
|
+
"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.`,
|
|
70
|
+
}),
|
|
71
|
+
"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.",
|
|
73
|
+
}),
|
|
46
74
|
};
|
|
@@ -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;
|