@wdio/appium-service 9.2.0 → 9.2.2

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/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/launcher.ts
2
+ import os from "node:os";
2
3
  import fs from "node:fs";
3
4
  import fsp from "node:fs/promises";
4
5
  import url from "node:url";
@@ -73,7 +74,7 @@ var AppiumLauncher = class _AppiumLauncher {
73
74
  command = "node";
74
75
  this._appiumCliArgs.unshift(await _AppiumLauncher._getAppiumCommand());
75
76
  }
76
- if (process.platform === "win32") {
77
+ if (os.platform() === "win32") {
77
78
  this._appiumCliArgs.unshift("/c", command);
78
79
  command = "cmd";
79
80
  }
@@ -84,11 +85,13 @@ var AppiumLauncher = class _AppiumLauncher {
84
85
  * to Appium server
85
86
  */
86
87
  _setCapabilities(port) {
88
+ let capabilityWasUpdated = false;
87
89
  if (!Array.isArray(this._capabilities)) {
88
90
  for (const [, capability] of Object.entries(this._capabilities)) {
89
91
  const cap = capability.capabilities || capability;
90
92
  const c = cap.alwaysMatch || cap;
91
93
  if (!isCloudCapability(c) && isAppiumCapability(c)) {
94
+ capabilityWasUpdated = true;
92
95
  Object.assign(
93
96
  capability,
94
97
  DEFAULT_CONNECTION,
@@ -106,6 +109,7 @@ var AppiumLauncher = class _AppiumLauncher {
106
109
  (c) => {
107
110
  const capability = c.capabilities.alwaysMatch || c.capabilities || c;
108
111
  if (!isCloudCapability(capability) && isAppiumCapability(capability)) {
112
+ capabilityWasUpdated = true;
109
113
  Object.assign(
110
114
  c,
111
115
  DEFAULT_CONNECTION,
@@ -116,6 +120,7 @@ var AppiumLauncher = class _AppiumLauncher {
116
120
  }
117
121
  );
118
122
  } else if (!isCloudCapability(w3cCap.alwaysMatch || cap) && isAppiumCapability(w3cCap.alwaysMatch || cap)) {
123
+ capabilityWasUpdated = true;
119
124
  Object.assign(
120
125
  cap,
121
126
  DEFAULT_CONNECTION,
@@ -124,38 +129,52 @@ var AppiumLauncher = class _AppiumLauncher {
124
129
  );
125
130
  }
126
131
  });
132
+ return capabilityWasUpdated;
127
133
  }
128
134
  async onPrepare() {
129
135
  if (Array.isArray(this._options.args)) {
130
136
  throw new Error("Args should be an object");
131
137
  }
132
138
  this._args.port = typeof this._args.port === "number" ? this._args.port : await getPort({ port: DEFAULT_APPIUM_PORT });
133
- this._setCapabilities(this._args.port);
139
+ const capabilityWasUpdated = this._setCapabilities(this._args.port);
140
+ if (!capabilityWasUpdated) {
141
+ log.warn("Could not identify any capability that indicates a local Appium session, skipping Appium launch");
142
+ return;
143
+ }
134
144
  this._appiumCliArgs.push(...formatCliArgs({ ...this._args }));
135
145
  const command = await this._getCommand(this._options.command);
136
146
  this._process = await this._startAppium(command, this._appiumCliArgs);
137
147
  if (this._logPath) {
138
148
  this._redirectLogStream(this._logPath);
149
+ } else {
150
+ log.info("Appium logs written to stdout");
151
+ this._process.stdout.on("data", this.#logStdout);
152
+ this._process.stderr.on("data", this.#logStderr);
139
153
  }
140
154
  }
155
+ #logStdout = (data) => {
156
+ log.debug(data.toString());
157
+ };
158
+ #logStderr = (data) => {
159
+ log.warn(data.toString());
160
+ };
141
161
  onComplete() {
142
162
  this._isShuttingDown = true;
143
163
  if (this._process && this._process.pid) {
164
+ this._process.stdout.off("data", this.#logStdout);
165
+ this._process.stderr.off("data", this.#logStderr);
144
166
  log.info("Killing entire Appium tree");
145
167
  treeKill(this._process.pid, "SIGTERM", (err) => {
146
168
  if (err) {
147
- log.warn("Failed to kill process:", err);
148
- } else {
149
- log.info(
150
- "Process and its children successfully terminated"
151
- );
169
+ return log.warn("Failed to kill process:", err);
152
170
  }
171
+ log.info("Process and its children successfully terminated");
153
172
  });
154
173
  }
155
174
  }
156
175
  _startAppium(command, args, timeout = APPIUM_START_TIMEOUT) {
157
176
  log.info(`Will spawn Appium process: ${command} ${args.join(" ")}`);
158
- const process2 = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"] });
177
+ const appiumProcess = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"] });
159
178
  let errorCaptured = false;
160
179
  let timeoutId;
161
180
  let error;
@@ -171,21 +190,25 @@ var AppiumLauncher = class _AppiumLauncher {
171
190
  reject(err);
172
191
  }
173
192
  };
174
- process2.stdout.on("data", (data) => {
193
+ const onErrorMessage = (data) => {
194
+ error = data.toString() || "Appium exited without unknown error message";
195
+ log.error(error);
196
+ rejectOnce(new Error(error));
197
+ };
198
+ const onStdout = (data) => {
175
199
  outputBuffer += data.toString();
176
200
  if (outputBuffer.includes("Appium REST http interface listener started")) {
177
201
  outputBuffer = "";
178
- log.info(`Appium started with ID: ${process2.pid}`);
202
+ log.info(`Appium started with ID: ${appiumProcess.pid}`);
179
203
  clearTimeout(timeoutId);
180
- resolve3(process2);
204
+ appiumProcess.stdout.off("data", onStdout);
205
+ appiumProcess.stderr.off("data", onErrorMessage);
206
+ resolve3(appiumProcess);
181
207
  }
182
- });
183
- process2.stderr.once("data", (data) => {
184
- error = data.toString() || "Appium exited without unknown error message";
185
- log.error(error);
186
- rejectOnce(new Error(error));
187
- });
188
- process2.once("exit", (exitCode) => {
208
+ };
209
+ appiumProcess.stdout.on("data", onStdout);
210
+ appiumProcess.stderr.once("data", onErrorMessage);
211
+ appiumProcess.once("exit", (exitCode) => {
189
212
  if (this._isShuttingDown) {
190
213
  return;
191
214
  }
@@ -1,6 +1,7 @@
1
1
  import type { Services, Capabilities, Options } from '@wdio/types';
2
2
  import type { AppiumServiceConfig } from './types.js';
3
3
  export default class AppiumLauncher implements Services.ServiceInstance {
4
+ #private;
4
5
  private _options;
5
6
  private _capabilities;
6
7
  private _config?;
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIlE,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,YAAY,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AAa,EAAE,YAAY,CAAC,sBAAsB,EAClD,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,YAAA;YAS1B,WAAW;IAqBzB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAyDlB,SAAS;IAqDf,UAAU;IA0BV,OAAO,CAAC,YAAY;YA6EN,kBAAkB;mBAeX,iBAAiB;CAezC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/appium-service",
3
- "version": "9.2.0",
3
+ "version": "9.2.2",
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",
@@ -35,18 +35,18 @@
35
35
  },
36
36
  "typeScriptVersion": "3.8.3",
37
37
  "dependencies": {
38
- "@wdio/config": "9.1.3",
38
+ "@wdio/config": "9.2.2",
39
39
  "@wdio/logger": "9.1.3",
40
- "@wdio/types": "9.1.3",
41
- "@wdio/utils": "9.1.3",
40
+ "@wdio/types": "9.2.2",
41
+ "@wdio/utils": "9.2.2",
42
42
  "change-case": "^5.4.3",
43
43
  "get-port": "^7.0.0",
44
44
  "import-meta-resolve": "^4.0.0",
45
45
  "tree-kill": "^1.2.2",
46
- "webdriverio": "9.2.0"
46
+ "webdriverio": "9.2.2"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "d19039c7166c6df2e47a02de289a66865372107e"
51
+ "gitHead": "a82feee9b819e978b0d75dc899dd8284303935e1"
52
52
  }