@wdio/appium-service 8.24.3 → 8.24.5
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/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +44 -33
- package/package.json +6 -5
package/build/launcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIlE,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAW5E,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,QAAQ,CAAC,eAAe;IAO/D,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,OAAO,CAAC;IARpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAC,CAA+C;gBAGpD,QAAQ,EAAE,mBAAmB,EAC7B,aAAa,EAAE,YAAY,CAAC,kBAAkB,EAC9C,OAAO,CAAC,gCAAoB;YAS1B,WAAW;IAqBzB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAgDlB,SAAS;IAgCf,UAAU;IAOV,OAAO,CAAC,YAAY;YAiCN,kBAAkB;mBAeX,iBAAiB;CAezC"}
|
package/build/launcher.js
CHANGED
|
@@ -3,19 +3,19 @@ import fsp from 'node:fs/promises';
|
|
|
3
3
|
import url from 'node:url';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
|
-
import { promisify } from 'node:util';
|
|
7
6
|
import logger from '@wdio/logger';
|
|
7
|
+
import getPort from 'get-port';
|
|
8
8
|
import { resolve } from 'import-meta-resolve';
|
|
9
9
|
import { isCloudCapability } from '@wdio/config';
|
|
10
10
|
import { SevereServiceError } from 'webdriverio';
|
|
11
11
|
import { isAppiumCapability } from '@wdio/utils';
|
|
12
12
|
import { getFilePath, formatCliArgs } from './utils.js';
|
|
13
13
|
const log = logger('@wdio/appium-service');
|
|
14
|
+
const DEFAULT_APPIUM_PORT = 4723;
|
|
14
15
|
const DEFAULT_LOG_FILENAME = 'wdio-appium.log';
|
|
15
16
|
const DEFAULT_CONNECTION = {
|
|
16
17
|
protocol: 'http',
|
|
17
18
|
hostname: '127.0.0.1',
|
|
18
|
-
port: 4723,
|
|
19
19
|
path: '/'
|
|
20
20
|
};
|
|
21
21
|
export default class AppiumLauncher {
|
|
@@ -58,7 +58,7 @@ export default class AppiumLauncher {
|
|
|
58
58
|
* update capability connection options to connect
|
|
59
59
|
* to Appium server
|
|
60
60
|
*/
|
|
61
|
-
_setCapabilities() {
|
|
61
|
+
_setCapabilities(port) {
|
|
62
62
|
/**
|
|
63
63
|
* Multiremote sessions
|
|
64
64
|
*/
|
|
@@ -66,22 +66,25 @@ export default class AppiumLauncher {
|
|
|
66
66
|
for (const [, capability] of Object.entries(this._capabilities)) {
|
|
67
67
|
const cap = capability.capabilities || capability;
|
|
68
68
|
const c = cap.alwaysMatch || cap;
|
|
69
|
-
!isCloudCapability(c) && isAppiumCapability(c) && Object.assign(capability, DEFAULT_CONNECTION,
|
|
69
|
+
!isCloudCapability(c) && isAppiumCapability(c) && Object.assign(capability, DEFAULT_CONNECTION, { path: this._args.basePath, port }, { ...capability });
|
|
70
70
|
}
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
this._capabilities.forEach((cap) => {
|
|
74
|
+
const w3cCap = cap;
|
|
74
75
|
/**
|
|
75
76
|
* Parallel Multiremote
|
|
76
77
|
*/
|
|
77
78
|
if (Object.values(cap).length > 0 && Object.values(cap).every(c => typeof c === 'object' && c.capabilities)) {
|
|
78
79
|
Object.values(cap).forEach(c => {
|
|
79
|
-
const
|
|
80
|
-
!isCloudCapability(
|
|
80
|
+
const capability = c.capabilities.alwaysMatch || c.capabilities || c;
|
|
81
|
+
if (!isCloudCapability(capability) && isAppiumCapability(capability)) {
|
|
82
|
+
Object.assign(c, DEFAULT_CONNECTION, { path: this._args.basePath, port }, { ...c });
|
|
83
|
+
}
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
|
-
else {
|
|
84
|
-
|
|
86
|
+
else if (!isCloudCapability(w3cCap.alwaysMatch || cap) && isAppiumCapability(w3cCap.alwaysMatch || cap)) {
|
|
87
|
+
Object.assign(cap, DEFAULT_CONNECTION, { path: this._args.basePath, port }, { ...cap });
|
|
85
88
|
}
|
|
86
89
|
});
|
|
87
90
|
}
|
|
@@ -97,12 +100,18 @@ export default class AppiumLauncher {
|
|
|
97
100
|
* Append remaining arguments
|
|
98
101
|
*/
|
|
99
102
|
this._appiumCliArgs.push(...formatCliArgs(this._args));
|
|
100
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Get port from service option or use a random port
|
|
105
|
+
*/
|
|
106
|
+
const port = typeof this._args.port === 'number'
|
|
107
|
+
? this._args.port
|
|
108
|
+
: await getPort({ port: DEFAULT_APPIUM_PORT });
|
|
109
|
+
this._setCapabilities(port);
|
|
101
110
|
/**
|
|
102
111
|
* start Appium
|
|
103
112
|
*/
|
|
104
113
|
const command = await this._getCommand(this._options.command);
|
|
105
|
-
this._process = await
|
|
114
|
+
this._process = await this._startAppium(command, this._appiumCliArgs);
|
|
106
115
|
if (this._logPath) {
|
|
107
116
|
this._redirectLogStream(this._logPath);
|
|
108
117
|
}
|
|
@@ -113,32 +122,34 @@ export default class AppiumLauncher {
|
|
|
113
122
|
this._process.kill();
|
|
114
123
|
}
|
|
115
124
|
}
|
|
116
|
-
_startAppium(command, args
|
|
125
|
+
_startAppium(command, args) {
|
|
117
126
|
log.info(`Will spawn Appium process: ${command} ${args.join(' ')}`);
|
|
118
127
|
const process = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
119
128
|
let error;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
process.stdout.on('data', (data) => {
|
|
131
|
+
if (data.includes('Appium REST http interface listener started')) {
|
|
132
|
+
log.info(`Appium started with ID: ${process.pid}`);
|
|
133
|
+
resolve(process);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
/**
|
|
137
|
+
* only capture first error to print it in case Appium failed to start.
|
|
138
|
+
*/
|
|
139
|
+
process.stderr.once('data', (err) => { error = err; });
|
|
140
|
+
process.once('exit', exitCode => {
|
|
141
|
+
let errorMessage = `Appium exited before timeout (exit code: ${exitCode})`;
|
|
142
|
+
if (exitCode === 2) {
|
|
143
|
+
errorMessage += '\n' + (error?.toString() || 'Check that you don\'t already have a running Appium service.');
|
|
144
|
+
}
|
|
145
|
+
else if (error) {
|
|
146
|
+
errorMessage += `\n${error.toString()}`;
|
|
147
|
+
}
|
|
148
|
+
if (exitCode !== 0) {
|
|
149
|
+
log.error(errorMessage);
|
|
150
|
+
}
|
|
151
|
+
reject(new Error(errorMessage));
|
|
152
|
+
});
|
|
142
153
|
});
|
|
143
154
|
}
|
|
144
155
|
async _redirectLogStream(logPath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/appium-service",
|
|
3
|
-
"version": "8.24.
|
|
3
|
+
"version": "8.24.5",
|
|
4
4
|
"description": "A WebdriverIO service to start & stop Appium Server",
|
|
5
5
|
"author": "Morten Bjerg Gregersen <morten@mogee.dk>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-appium-service",
|
|
@@ -33,16 +33,17 @@
|
|
|
33
33
|
},
|
|
34
34
|
"typeScriptVersion": "3.8.3",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@wdio/config": "8.24.
|
|
36
|
+
"@wdio/config": "8.24.5",
|
|
37
37
|
"@wdio/logger": "8.16.17",
|
|
38
38
|
"@wdio/types": "8.24.2",
|
|
39
|
-
"@wdio/utils": "8.24.
|
|
39
|
+
"@wdio/utils": "8.24.5",
|
|
40
|
+
"get-port": "^7.0.0",
|
|
40
41
|
"import-meta-resolve": "^3.0.0",
|
|
41
42
|
"param-case": "^3.0.4",
|
|
42
|
-
"webdriverio": "8.24.
|
|
43
|
+
"webdriverio": "8.24.5"
|
|
43
44
|
},
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"access": "public"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "3272ade1b378dd0756d2c3b789198a692f5a706d"
|
|
48
49
|
}
|