appium-mac2-driver 3.2.1 → 3.2.3
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/CHANGELOG.md +15 -0
- package/build/lib/commands/record-screen.d.ts +11 -12
- package/build/lib/commands/record-screen.d.ts.map +1 -1
- package/build/lib/commands/record-screen.js +2 -0
- package/build/lib/commands/record-screen.js.map +1 -1
- package/build/lib/constraints.d.ts +56 -0
- package/build/lib/constraints.d.ts.map +1 -0
- package/build/lib/constraints.js +57 -0
- package/build/lib/constraints.js.map +1 -0
- package/build/lib/doctor/optional-checks.d.ts +12 -10
- package/build/lib/doctor/optional-checks.d.ts.map +1 -1
- package/build/lib/doctor/optional-checks.js +9 -9
- package/build/lib/doctor/optional-checks.js.map +1 -1
- package/build/lib/doctor/required-checks.d.ts +12 -10
- package/build/lib/doctor/required-checks.d.ts.map +1 -1
- package/build/lib/doctor/required-checks.js +9 -9
- package/build/lib/doctor/required-checks.js.map +1 -1
- package/build/lib/doctor/utils.d.ts +3 -3
- package/build/lib/doctor/utils.d.ts.map +1 -1
- package/build/lib/doctor/utils.js +2 -2
- package/build/lib/doctor/utils.js.map +1 -1
- package/build/lib/driver.d.ts +30 -90
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +56 -45
- package/build/lib/driver.js.map +1 -1
- package/build/lib/logger.d.ts +1 -1
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/method-map.d.ts +1 -1
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +6 -6
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/utils.d.ts +11 -11
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +6 -7
- package/build/lib/utils.js.map +1 -1
- package/lib/commands/record-screen.js +1 -1
- package/lib/constraints.ts +60 -0
- package/lib/doctor/optional-checks.ts +67 -0
- package/lib/doctor/required-checks.ts +75 -0
- package/lib/doctor/{utils.js → utils.ts} +4 -3
- package/lib/{driver.js → driver.ts} +118 -65
- package/lib/{logger.js → logger.ts} +1 -0
- package/lib/{method-map.js → method-map.ts} +7 -6
- package/lib/{utils.js → utils.ts} +8 -10
- package/npm-shrinkwrap.json +16 -16
- package/package.json +1 -1
- package/build/lib/desired-caps.d.ts +0 -66
- package/build/lib/desired-caps.d.ts.map +0 -1
- package/build/lib/desired-caps.js +0 -58
- package/build/lib/desired-caps.js.map +0 -1
- package/lib/desired-caps.js +0 -55
- package/lib/doctor/optional-checks.js +0 -64
- package/lib/doctor/required-checks.js +0 -72
package/build/lib/driver.js
CHANGED
|
@@ -40,7 +40,7 @@ exports.Mac2Driver = void 0;
|
|
|
40
40
|
const lodash_1 = __importDefault(require("lodash"));
|
|
41
41
|
const driver_1 = require("appium/driver");
|
|
42
42
|
const wda_mac_1 = require("./wda-mac");
|
|
43
|
-
const
|
|
43
|
+
const constraints_1 = __importDefault(require("./constraints"));
|
|
44
44
|
const appManagemenetCommands = __importStar(require("./commands/app-management"));
|
|
45
45
|
const appleScriptCommands = __importStar(require("./commands/applescript"));
|
|
46
46
|
const executeCommands = __importStar(require("./commands/execute"));
|
|
@@ -51,11 +51,10 @@ const recordScreenCommands = __importStar(require("./commands/record-screen"));
|
|
|
51
51
|
const screenshotCommands = __importStar(require("./commands/screenshots"));
|
|
52
52
|
const sourceCommands = __importStar(require("./commands/source"));
|
|
53
53
|
const clipboardCommands = __importStar(require("./commands/clipboard"));
|
|
54
|
+
const nativeScreenRecordingCommands = __importStar(require("./commands/native-record-screen"));
|
|
54
55
|
const logger_1 = __importDefault(require("./logger"));
|
|
55
56
|
const method_map_1 = require("./method-map");
|
|
56
57
|
const execute_method_map_1 = require("./execute-method-map");
|
|
57
|
-
const nativeScreenRecordingCommands = __importStar(require("./commands/native-record-screen"));
|
|
58
|
-
/** @type {import('@appium/types').RouteMatcher[]} */
|
|
59
58
|
const NO_PROXY = [
|
|
60
59
|
['GET', new RegExp('^/session/[^/]+/appium')],
|
|
61
60
|
['POST', new RegExp('^/session/[^/]+/appium')],
|
|
@@ -67,18 +66,16 @@ const NO_PROXY = [
|
|
|
67
66
|
['POST', new RegExp('^/session/[^/]+/timeouts$')],
|
|
68
67
|
];
|
|
69
68
|
class Mac2Driver extends driver_1.BaseDriver {
|
|
70
|
-
/** @type {boolean} */
|
|
71
69
|
isProxyActive;
|
|
72
|
-
|
|
73
|
-
wda;
|
|
74
|
-
/** @type {nativeScreenRecordingCommands.NativeVideoChunksBroadcaster} */
|
|
70
|
+
_wda;
|
|
75
71
|
_videoChunksBroadcaster;
|
|
72
|
+
_screenRecorder;
|
|
73
|
+
proxyReqRes;
|
|
76
74
|
static newMethodMap = method_map_1.newMethodMap;
|
|
77
75
|
static executeMethodMap = execute_method_map_1.executeMethodMap;
|
|
78
76
|
constructor(opts = {}) {
|
|
79
|
-
// @ts-ignore TODO: Make opts typed
|
|
80
77
|
super(opts);
|
|
81
|
-
this.desiredCapConstraints =
|
|
78
|
+
this.desiredCapConstraints = lodash_1.default.cloneDeep(constraints_1.default);
|
|
82
79
|
this.locatorStrategies = [
|
|
83
80
|
'id',
|
|
84
81
|
'name',
|
|
@@ -94,17 +91,18 @@ class Mac2Driver extends driver_1.BaseDriver {
|
|
|
94
91
|
this.settings = new driver_1.DeviceSettings({}, this.onSettingsUpdate.bind(this));
|
|
95
92
|
}
|
|
96
93
|
async onSettingsUpdate(key, value) {
|
|
97
|
-
|
|
94
|
+
if (!this._wda) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
return await this._wda.proxy.command('/appium/settings', 'POST', {
|
|
98
98
|
settings: { [key]: value }
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.
|
|
106
|
-
this._videoChunksBroadcaster = new nativeScreenRecordingCommands.NativeVideoChunksBroadcaster(this.eventEmitter, this.log);
|
|
107
|
-
this._screenRecorder = null;
|
|
101
|
+
get wda() {
|
|
102
|
+
if (!this._wda) {
|
|
103
|
+
throw new Error('WDA server is not initialized');
|
|
104
|
+
}
|
|
105
|
+
return this._wda;
|
|
108
106
|
}
|
|
109
107
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
110
108
|
proxyActive(sessionId) {
|
|
@@ -117,42 +115,44 @@ class Mac2Driver extends driver_1.BaseDriver {
|
|
|
117
115
|
canProxy() {
|
|
118
116
|
return true;
|
|
119
117
|
}
|
|
120
|
-
/**
|
|
121
|
-
*
|
|
122
|
-
* @param {string} url
|
|
123
|
-
* @param {import('@appium/types').HTTPMethod} method
|
|
124
|
-
* @param {any} body
|
|
125
|
-
* @returns {Promise<any>}
|
|
126
|
-
*/
|
|
127
118
|
async proxyCommand(url, method, body = null) {
|
|
128
|
-
|
|
119
|
+
if (!this._wda) {
|
|
120
|
+
throw new Error('WDA server is not initialized');
|
|
121
|
+
}
|
|
122
|
+
return await this._wda.proxy.command(url, method, body);
|
|
129
123
|
}
|
|
130
|
-
// @ts-ignore We know WDA response should be ok
|
|
131
124
|
async getStatus() {
|
|
132
|
-
|
|
125
|
+
if (!this._wda) {
|
|
126
|
+
throw new Error('WDA server is not initialized');
|
|
127
|
+
}
|
|
128
|
+
return await this._wda.proxy.command('/status', 'GET');
|
|
133
129
|
}
|
|
134
130
|
// needed to make image plugin work
|
|
135
131
|
async getWindowRect() {
|
|
136
|
-
|
|
132
|
+
if (!this._wda) {
|
|
133
|
+
throw new Error('WDA server is not initialized');
|
|
134
|
+
}
|
|
135
|
+
return await this._wda.proxy.command('/window/rect', 'GET');
|
|
137
136
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.
|
|
137
|
+
async createSession(w3cCaps1, w3cCaps2, w3cCaps3, driverData) {
|
|
138
|
+
const [sessionId, caps] = await super.createSession(w3cCaps1, w3cCaps2, w3cCaps3, driverData);
|
|
139
|
+
this._wda = wda_mac_1.WDA_MAC_SERVER;
|
|
140
|
+
this.caps = caps;
|
|
141
|
+
this.opts = this.opts;
|
|
143
142
|
try {
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
const prerun = caps.prerun;
|
|
144
|
+
if (prerun) {
|
|
145
|
+
if (!lodash_1.default.isString(prerun.command) && !lodash_1.default.isString(prerun.script)) {
|
|
146
146
|
throw new Error(`'prerun' capability value must either contain ` +
|
|
147
147
|
`'script' or 'command' entry of string type`);
|
|
148
148
|
}
|
|
149
149
|
logger_1.default.info('Executing prerun AppleScript');
|
|
150
|
-
const output = await this.macosExecAppleScript(
|
|
150
|
+
const output = await this.macosExecAppleScript(prerun.script, undefined, prerun.command);
|
|
151
151
|
if (lodash_1.default.trim(output)) {
|
|
152
152
|
logger_1.default.info(`Prerun script output: ${output}`);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
await this.
|
|
155
|
+
await this._wda.startSession(caps, {
|
|
156
156
|
reqBasePath: this.basePath,
|
|
157
157
|
});
|
|
158
158
|
}
|
|
@@ -160,29 +160,34 @@ class Mac2Driver extends driver_1.BaseDriver {
|
|
|
160
160
|
await this.deleteSession();
|
|
161
161
|
throw e;
|
|
162
162
|
}
|
|
163
|
-
this.proxyReqRes = this.wda.proxy.proxyReqRes.bind(this.
|
|
163
|
+
this.proxyReqRes = this.wda.proxy.proxyReqRes.bind(this._wda.proxy);
|
|
164
164
|
this.isProxyActive = true;
|
|
165
165
|
return [sessionId, caps];
|
|
166
166
|
}
|
|
167
167
|
async deleteSession() {
|
|
168
168
|
await this._screenRecorder?.stop(true);
|
|
169
169
|
if (this._videoChunksBroadcaster.hasPublishers) {
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
if (this._wda) {
|
|
171
|
+
try {
|
|
172
|
+
await this.wda.proxy.command('/wda/video/stop', 'POST', {});
|
|
173
|
+
}
|
|
174
|
+
catch { }
|
|
172
175
|
}
|
|
173
|
-
catch { }
|
|
174
176
|
await this._videoChunksBroadcaster.shutdown(5000);
|
|
175
177
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
if (this._wda) {
|
|
179
|
+
await this.wda.stopSession();
|
|
180
|
+
}
|
|
181
|
+
const postrun = this.opts.postrun;
|
|
182
|
+
if (postrun) {
|
|
183
|
+
if (!lodash_1.default.isString(postrun.command) && !lodash_1.default.isString(postrun.script)) {
|
|
179
184
|
logger_1.default.error(`'postrun' capability value must either contain ` +
|
|
180
185
|
`'script' or 'command' entry of string type`);
|
|
181
186
|
}
|
|
182
187
|
else {
|
|
183
188
|
logger_1.default.info('Executing postrun AppleScript');
|
|
184
189
|
try {
|
|
185
|
-
const output = await this.macosExecAppleScript(
|
|
190
|
+
const output = await this.macosExecAppleScript(postrun.script, undefined, postrun.command);
|
|
186
191
|
if (lodash_1.default.trim(output)) {
|
|
187
192
|
logger_1.default.info(`Postrun script output: ${output}`);
|
|
188
193
|
}
|
|
@@ -195,6 +200,12 @@ class Mac2Driver extends driver_1.BaseDriver {
|
|
|
195
200
|
this.resetState();
|
|
196
201
|
await super.deleteSession();
|
|
197
202
|
}
|
|
203
|
+
resetState() {
|
|
204
|
+
this._wda = null;
|
|
205
|
+
this.isProxyActive = false;
|
|
206
|
+
this._videoChunksBroadcaster = new nativeScreenRecordingCommands.NativeVideoChunksBroadcaster(this.eventEmitter, this.log);
|
|
207
|
+
this._screenRecorder = null;
|
|
208
|
+
}
|
|
198
209
|
macosLaunchApp = appManagemenetCommands.macosLaunchApp;
|
|
199
210
|
macosActivateApp = appManagemenetCommands.macosActivateApp;
|
|
200
211
|
macosTerminateApp = appManagemenetCommands.macosTerminateApp;
|
package/build/lib/driver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../lib/driver.
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../lib/driver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuB;AAcvB,0CAA2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AAC,oBAAoB,CAAC;IACjE,mBAAmB,GAAG,oBAAoB,CAAC,mBAAmB,CAAC;IAE/D,+BAA+B,GAAG,6BAA6B,CAAC,+BAA+B,CAAC;IAChG,iCAAiC,GAAG,6BAA6B,CAAC,iCAAiC,CAAC;IACpG,8BAA8B,GAAG,6BAA6B,CAAC,8BAA8B,CAAC;IAC9F,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC;IAEpE,gBAAgB,GAAG,kBAAkB,CAAC,gBAAgB,CAAC;IAEvD,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC;;AA1N3C,gCA2NC;AAED,kBAAe,UAAU,CAAC"}
|
package/build/lib/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,GAAG,sCAAiC,CAAC;AAE3C,eAAe,GAAG,CAAC"}
|
package/build/lib/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../lib/logger.
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":";;AAAA,4CAAwC;AAExC,MAAM,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAE3C,kBAAe,GAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-map.d.ts","sourceRoot":"","sources":["../../lib/method-map.
|
|
1
|
+
{"version":3,"file":"method-map.d.ts","sourceRoot":"","sources":["../../lib/method-map.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;CAaf,CAAC"}
|
package/build/lib/method-map.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.newMethodMap = void 0;
|
|
4
|
-
exports.newMethodMap =
|
|
4
|
+
exports.newMethodMap = {
|
|
5
5
|
'/session/:sessionId/appium/start_recording_screen': {
|
|
6
6
|
POST: {
|
|
7
7
|
command: 'startRecordingScreen',
|
|
8
|
-
payloadParams: { optional: ['options'] }
|
|
9
|
-
}
|
|
8
|
+
payloadParams: { optional: ['options'] },
|
|
9
|
+
},
|
|
10
10
|
},
|
|
11
11
|
'/session/:sessionId/appium/stop_recording_screen': {
|
|
12
12
|
POST: {
|
|
13
13
|
command: 'stopRecordingScreen',
|
|
14
|
-
payloadParams: { optional: ['options'] }
|
|
15
|
-
}
|
|
14
|
+
payloadParams: { optional: ['options'] },
|
|
15
|
+
},
|
|
16
16
|
},
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
//# sourceMappingURL=method-map.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-map.js","sourceRoot":"","sources":["../../lib/method-map.
|
|
1
|
+
{"version":3,"file":"method-map.js","sourceRoot":"","sources":["../../lib/method-map.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,mDAAmD,EAAE;QACnD,IAAI,EAAE;YACJ,OAAO,EAAE,sBAAsB;YAC/B,aAAa,EAAE,EAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAC;SACvC;KACF;IACD,kDAAkD,EAAE;QAClD,IAAI,EAAE;YACJ,OAAO,EAAE,qBAAqB;YAC9B,aAAa,EAAE,EAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAC;SACvC;KACF;CACO,CAAC"}
|
package/build/lib/utils.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* parent process identifier
|
|
3
|
+
* Calculates the path to the current module's root folder
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
7
|
-
* or an empty list if none matched
|
|
5
|
+
* @returns The full path to module root
|
|
6
|
+
* @throws If the current module root folder cannot be determined
|
|
8
7
|
*/
|
|
9
|
-
export
|
|
8
|
+
export declare const getModuleRoot: (() => string) & _.MemoizedFunction;
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
10
|
+
* Retrieves process ids of all the children processes created by the given
|
|
11
|
+
* parent process identifier
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
13
|
+
* @param parentPid parent process ID
|
|
14
|
+
* @returns the list of matched children process ids
|
|
15
|
+
* or an empty list if none matched
|
|
15
16
|
*/
|
|
16
|
-
export
|
|
17
|
-
import _ from 'lodash';
|
|
17
|
+
export declare function listChildrenProcessIds(parentPid: number | string): Promise<string[]>;
|
|
18
18
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAMvB;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAwC,MAAM,sBAMtE,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAW3F"}
|
package/build/lib/utils.js
CHANGED
|
@@ -12,23 +12,22 @@ const MODULE_NAME = 'appium-mac2-driver';
|
|
|
12
12
|
/**
|
|
13
13
|
* Calculates the path to the current module's root folder
|
|
14
14
|
*
|
|
15
|
-
* @returns
|
|
16
|
-
* @throws
|
|
15
|
+
* @returns The full path to module root
|
|
16
|
+
* @throws If the current module root folder cannot be determined
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
exports.getModuleRoot = lodash_1.default.memoize(function getModuleRoot() {
|
|
19
19
|
const root = support_1.node.getModuleRootSync(MODULE_NAME, __filename);
|
|
20
20
|
if (!root) {
|
|
21
21
|
throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);
|
|
22
22
|
}
|
|
23
23
|
return root;
|
|
24
24
|
});
|
|
25
|
-
exports.getModuleRoot = getModuleRoot;
|
|
26
25
|
/**
|
|
27
26
|
* Retrieves process ids of all the children processes created by the given
|
|
28
27
|
* parent process identifier
|
|
29
28
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @returns
|
|
29
|
+
* @param parentPid parent process ID
|
|
30
|
+
* @returns the list of matched children process ids
|
|
32
31
|
* or an empty list if none matched
|
|
33
32
|
*/
|
|
34
33
|
async function listChildrenProcessIds(parentPid) {
|
|
@@ -41,6 +40,6 @@ async function listChildrenProcessIds(parentPid) {
|
|
|
41
40
|
return [pid, lodash_1.default.last(rest)];
|
|
42
41
|
})
|
|
43
42
|
.filter(([, ppid]) => ppid === `${parentPid}`)
|
|
44
|
-
.map(([pid]) =>
|
|
43
|
+
.map(([pid]) => String(pid));
|
|
45
44
|
}
|
|
46
45
|
//# sourceMappingURL=utils.js.map
|
package/build/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":";;;;;;AA4BA,wDAWC;AAvCD,oDAAuB;AACvB,+CAAoC;AACpC,4CAAsC;AAEtC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAEzC;;;;;GAKG;AACU,QAAA,aAAa,GAAG,gBAAC,CAAC,OAAO,CAAC,SAAS,aAAa;IAC3D,MAAM,IAAI,GAAG,cAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC7D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,sCAAsC,WAAW,iBAAiB,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACI,KAAK,UAAU,sBAAsB,CAAE,SAA0B;IACtE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,mBAAI,EAAC,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,wEAAwE;IACxE,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;SACtB,MAAM,CAAC,gBAAC,CAAC,IAAI,CAAC;SACd,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE;QACpB,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,gBAAC,CAAC,IAAI,CAAC,CAAC;QAC1D,OAAO,CAAC,GAAG,EAAE,gBAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;SAC7C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {Constraints} from '@appium/types';
|
|
2
|
+
|
|
3
|
+
const MAC2_CONSTRAINTS = {
|
|
4
|
+
systemPort: {
|
|
5
|
+
isNumber: true,
|
|
6
|
+
},
|
|
7
|
+
systemHost: {
|
|
8
|
+
isString: true,
|
|
9
|
+
},
|
|
10
|
+
showServerLogs: {
|
|
11
|
+
isBoolean: true,
|
|
12
|
+
},
|
|
13
|
+
bootstrapRoot: {
|
|
14
|
+
isString: true,
|
|
15
|
+
},
|
|
16
|
+
serverStartupTimeout: {
|
|
17
|
+
isNumber: true,
|
|
18
|
+
},
|
|
19
|
+
bundleId: {
|
|
20
|
+
isString: true,
|
|
21
|
+
},
|
|
22
|
+
arguments: {
|
|
23
|
+
isArray: true,
|
|
24
|
+
},
|
|
25
|
+
environment: {
|
|
26
|
+
isObject: true,
|
|
27
|
+
},
|
|
28
|
+
noReset: {
|
|
29
|
+
isBoolean: true,
|
|
30
|
+
},
|
|
31
|
+
skipAppKill: {
|
|
32
|
+
isBoolean: true,
|
|
33
|
+
},
|
|
34
|
+
prerun: {
|
|
35
|
+
isObject: true,
|
|
36
|
+
},
|
|
37
|
+
postrun: {
|
|
38
|
+
isObject: true,
|
|
39
|
+
},
|
|
40
|
+
webDriverAgentMacUrl: {
|
|
41
|
+
isString: true,
|
|
42
|
+
},
|
|
43
|
+
appPath: {
|
|
44
|
+
isString: true,
|
|
45
|
+
},
|
|
46
|
+
appLocale: {
|
|
47
|
+
isObject: true,
|
|
48
|
+
},
|
|
49
|
+
appTimeZone: {
|
|
50
|
+
isString: true,
|
|
51
|
+
},
|
|
52
|
+
initialDeeplinkUrl: {
|
|
53
|
+
isString: true,
|
|
54
|
+
},
|
|
55
|
+
} as const satisfies Constraints;
|
|
56
|
+
|
|
57
|
+
export default MAC2_CONSTRAINTS;
|
|
58
|
+
|
|
59
|
+
export type Mac2Constraints = typeof MAC2_CONSTRAINTS;
|
|
60
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {resolveExecutablePath} from './utils';
|
|
2
|
+
import {doctor} from 'appium/support';
|
|
3
|
+
import {exec} from 'teen_process';
|
|
4
|
+
import type {IDoctorCheck, AppiumLogger, DoctorCheckResult} from '@appium/types';
|
|
5
|
+
import '@colors/colors';
|
|
6
|
+
|
|
7
|
+
export class OptionalFfmpegCheck implements IDoctorCheck {
|
|
8
|
+
log!: AppiumLogger;
|
|
9
|
+
static readonly FFMPEG_BINARY = 'ffmpeg';
|
|
10
|
+
static readonly FFMPEG_INSTALL_LINK = 'https://www.ffmpeg.org/download.html';
|
|
11
|
+
|
|
12
|
+
async diagnose(): Promise<DoctorCheckResult> {
|
|
13
|
+
const ffmpegPath = await resolveExecutablePath(OptionalFfmpegCheck.FFMPEG_BINARY);
|
|
14
|
+
|
|
15
|
+
return ffmpegPath
|
|
16
|
+
? doctor.okOptional(`${OptionalFfmpegCheck.FFMPEG_BINARY} exists at '${ffmpegPath}'`)
|
|
17
|
+
: doctor.nokOptional(`${OptionalFfmpegCheck.FFMPEG_BINARY} cannot be found`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async fix(): Promise<string> {
|
|
21
|
+
return (
|
|
22
|
+
`${`${OptionalFfmpegCheck.FFMPEG_BINARY}`.bold} is used to capture screen recordings. ` +
|
|
23
|
+
`Please read ${OptionalFfmpegCheck.FFMPEG_INSTALL_LINK}.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
hasAutofix(): boolean {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
isOptional(): boolean {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const optionalFfmpegCheck = new OptionalFfmpegCheck();
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export class OptionalAutomationModeCheck implements IDoctorCheck {
|
|
39
|
+
log!: AppiumLogger;
|
|
40
|
+
|
|
41
|
+
async diagnose(): Promise<DoctorCheckResult> {
|
|
42
|
+
let stdout: string;
|
|
43
|
+
try {
|
|
44
|
+
({stdout} = await exec('automationmodetool'));
|
|
45
|
+
} catch (err) {
|
|
46
|
+
return doctor.nokOptional(`Cannot run 'automationmodetool': ${(err as any).stderr || (err as Error).message}`);
|
|
47
|
+
}
|
|
48
|
+
if (stdout.includes('DOES NOT REQUIRE')) {
|
|
49
|
+
return doctor.okOptional(`Automation Mode does not require user authentication`);
|
|
50
|
+
}
|
|
51
|
+
return doctor.nokOptional(`Automation Mode requires user authentication`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async fix(): Promise<string> {
|
|
55
|
+
return `Run \`automationmodetool enable-automationmode-without-authentication\` to disable Automation Mode authentication`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
hasAutofix(): boolean {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
isOptional(): boolean {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export const optionalAutomationModeCheck = new OptionalAutomationModeCheck();
|
|
67
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {doctor} from 'appium/support';
|
|
2
|
+
import {exec} from 'teen_process';
|
|
3
|
+
import { getPath as getXcodePath } from 'appium-xcode';
|
|
4
|
+
import type {IDoctorCheck, AppiumLogger, DoctorCheckResult} from '@appium/types';
|
|
5
|
+
import '@colors/colors';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export class XcodeCheck implements IDoctorCheck {
|
|
9
|
+
log!: AppiumLogger;
|
|
10
|
+
|
|
11
|
+
async diagnose(): Promise<DoctorCheckResult> {
|
|
12
|
+
try {
|
|
13
|
+
const xcodePath = await getXcodePath();
|
|
14
|
+
return doctor.ok(`xCode is installed at '${xcodePath}'`);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
return doctor.nok((err as Error).message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async fix(): Promise<string> {
|
|
21
|
+
return `Manually install ${'Xcode'.bold} and configure the active developer directory path using the xcode-select tool`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
hasAutofix(): boolean {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
isOptional(): boolean {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const xcodeCheck = new XcodeCheck();
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export class XcodebuildCheck implements IDoctorCheck {
|
|
36
|
+
log!: AppiumLogger;
|
|
37
|
+
static readonly XCODE_VER_PATTERN = /^Xcode\s+([\d.]+)$/m;
|
|
38
|
+
static readonly MIN_XCODE_VERSION = 13;
|
|
39
|
+
|
|
40
|
+
async diagnose(): Promise<DoctorCheckResult> {
|
|
41
|
+
let xcodeVerMatch: RegExpExecArray | null;
|
|
42
|
+
let stdout: string;
|
|
43
|
+
let stderr: string;
|
|
44
|
+
try {
|
|
45
|
+
({stdout, stderr} = await exec('xcodebuild', ['-version']));
|
|
46
|
+
xcodeVerMatch = XcodebuildCheck.XCODE_VER_PATTERN.exec(stdout);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return doctor.nok(`Cannot run 'xcodebuild': ${(err as any).stderr || (err as Error).message}`);
|
|
49
|
+
}
|
|
50
|
+
if (!xcodeVerMatch) {
|
|
51
|
+
return doctor.nok(`Cannot determine Xcode version. stdout: ${stdout}; stderr: ${stderr}`);
|
|
52
|
+
}
|
|
53
|
+
const xcodeMajorVer = parseInt(xcodeVerMatch[1], 10);
|
|
54
|
+
if (xcodeMajorVer < XcodebuildCheck.MIN_XCODE_VERSION) {
|
|
55
|
+
return doctor.nok(`The actual Xcode version (${xcodeVerMatch[0]}) is older than the expected ` +
|
|
56
|
+
`one (${XcodebuildCheck.MIN_XCODE_VERSION})`);
|
|
57
|
+
}
|
|
58
|
+
return doctor.ok(`xcodebuild is installed and has a matching version number ` +
|
|
59
|
+
`(${xcodeVerMatch[1]} >= ${XcodebuildCheck.MIN_XCODE_VERSION})`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async fix(): Promise<string> {
|
|
63
|
+
return `Install ${'Xcode'.bold} ${XcodebuildCheck.MIN_XCODE_VERSION}+ or upgrade the existing setup`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
hasAutofix(): boolean {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
isOptional(): boolean {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export const xcodebuildCheck = new XcodebuildCheck();
|
|
75
|
+
|
|
@@ -3,10 +3,10 @@ import {fs} from 'appium/support';
|
|
|
3
3
|
/**
|
|
4
4
|
* Return an executable path of cmd
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @return
|
|
6
|
+
* @param cmd Standard output by command
|
|
7
|
+
* @return The full path of cmd. `null` if the cmd is not found.
|
|
8
8
|
*/
|
|
9
|
-
export async function resolveExecutablePath(cmd) {
|
|
9
|
+
export async function resolveExecutablePath(cmd: string): Promise<string | null> {
|
|
10
10
|
try {
|
|
11
11
|
const executablePath = await fs.which(cmd);
|
|
12
12
|
if (executablePath && (await fs.exists(executablePath))) {
|
|
@@ -15,3 +15,4 @@ export async function resolveExecutablePath(cmd) {
|
|
|
15
15
|
} catch {}
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
+
|