appium-webdriveragent 4.3.1 → 4.4.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/lib/xcodebuild.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { retryInterval } from 'asyncbox';
2
2
  import { SubProcess, exec } from 'teen_process';
3
3
  import { fs, logger, timing } from '@appium/support';
4
- import log from './logger';
4
+ import defaultLogger from './logger';
5
5
  import B from 'bluebird';
6
6
  import {
7
7
  setRealDeviceSecurity, generateXcodeConfigFile, setXctestrunFile,
@@ -33,10 +33,11 @@ const xcodeLog = logger.getLogger('Xcode');
33
33
 
34
34
 
35
35
  class XcodeBuild {
36
- constructor (xcodeVersion, device, args = {}) {
36
+ constructor (xcodeVersion, device, args = {}, log = null) {
37
37
  this.xcodeVersion = xcodeVersion;
38
38
 
39
39
  this.device = device;
40
+ this.log = log ?? defaultLogger;
40
41
 
41
42
  this.realDevice = args.realDevice;
42
43
 
@@ -121,20 +122,20 @@ class XcodeBuild {
121
122
  try {
122
123
  ({stdout} = await exec('xcodebuild', ['-project', this.agentPath, '-showBuildSettings']));
123
124
  } catch (err) {
124
- log.warn(`Cannot retrieve WDA build settings. Original error: ${err.message}`);
125
+ this.log.warn(`Cannot retrieve WDA build settings. Original error: ${err.message}`);
125
126
  return;
126
127
  }
127
128
 
128
129
  const pattern = /^\s*BUILD_DIR\s+=\s+(\/.*)/m;
129
130
  const match = pattern.exec(stdout);
130
131
  if (!match) {
131
- log.warn(`Cannot parse WDA build dir from ${_.truncate(stdout, {length: 300})}`);
132
+ this.log.warn(`Cannot parse WDA build dir from ${_.truncate(stdout, {length: 300})}`);
132
133
  return;
133
134
  }
134
- log.debug(`Parsed BUILD_DIR configuration value: '${match[1]}'`);
135
+ this.log.debug(`Parsed BUILD_DIR configuration value: '${match[1]}'`);
135
136
  // Derived data root is two levels higher over the build dir
136
137
  this.derivedDataPath = path.dirname(path.dirname(path.normalize(match[1])));
137
- log.debug(`Got derived data root: '${this.derivedDataPath}'`);
138
+ this.log.debug(`Got derived data root: '${this.derivedDataPath}'`);
138
139
  return this.derivedDataPath;
139
140
  })();
140
141
  return await this._derivedDataPathPromise;
@@ -149,7 +150,7 @@ class XcodeBuild {
149
150
 
150
151
  async prebuild () {
151
152
  // first do a build phase
152
- log.debug('Pre-building WDA before launching test');
153
+ this.log.debug('Pre-building WDA before launching test');
153
154
  this.usePrebuiltWDA = true;
154
155
  await this.start(true);
155
156
 
@@ -165,7 +166,7 @@ class XcodeBuild {
165
166
  const runnerScheme = tmpIsTvOS ? RUNNER_SCHEME_TV : RUNNER_SCHEME_IOS;
166
167
 
167
168
  for (const scheme of [libScheme, runnerScheme]) {
168
- log.debug(`Cleaning the project scheme '${scheme}' to make sure there are no leftovers from previous installs`);
169
+ this.log.debug(`Cleaning the project scheme '${scheme}' to make sure there are no leftovers from previous installs`);
169
170
  await exec('xcodebuild', [
170
171
  'clean',
171
172
  '-project', this.agentPath,
@@ -216,12 +217,12 @@ class XcodeBuild {
216
217
  if (versionMatch) {
217
218
  args.push(`IPHONEOS_DEPLOYMENT_TARGET=${versionMatch[1]}.${versionMatch[2]}`);
218
219
  } else {
219
- log.warn(`Cannot parse major and minor version numbers from platformVersion "${this.platformVersion}". ` +
220
+ this.log.warn(`Cannot parse major and minor version numbers from platformVersion "${this.platformVersion}". ` +
220
221
  'Will build for the default platform instead');
221
222
  }
222
223
 
223
224
  if (this.realDevice && this.xcodeConfigFile) {
224
- log.debug(`Using Xcode configuration file: '${this.xcodeConfigFile}'`);
225
+ this.log.debug(`Using Xcode configuration file: '${this.xcodeConfigFile}'`);
225
226
  args.push('-xcconfig', this.xcodeConfigFile);
226
227
  }
227
228
 
@@ -248,8 +249,8 @@ class XcodeBuild {
248
249
  }
249
250
 
250
251
  const {cmd, args} = this.getCommand(buildOnly);
251
- log.debug(`Beginning ${buildOnly ? 'build' : 'test'} with command '${cmd} ${args.join(' ')}' ` +
252
- `in directory '${this.bootstrapPath}'`);
252
+ this.log.debug(`Beginning ${buildOnly ? 'build' : 'test'} with command '${cmd} ${args.join(' ')}' ` +
253
+ `in directory '${this.bootstrapPath}'`);
253
254
  const env = Object.assign({}, process.env, {
254
255
  USE_PORT: this.wdaRemotePort,
255
256
  WDA_PRODUCT_BUNDLE_IDENTIFIER: this.updatedWDABundleId || WDA_RUNNER_BUNDLE_ID,
@@ -273,7 +274,7 @@ class XcodeBuild {
273
274
  const logMsg = _.isBoolean(this.showXcodeLog)
274
275
  ? `Output from xcodebuild ${this.showXcodeLog ? 'will' : 'will not'} be logged`
275
276
  : 'Output from xcodebuild will only be logged if any errors are present there';
276
- log.debug(`${logMsg}. To change this, use 'showXcodeLog' desired capability`);
277
+ this.log.debug(`${logMsg}. To change this, use 'showXcodeLog' desired capability`);
277
278
  xcodebuild.on('output', (stdout, stderr) => {
278
279
  let out = stdout || stderr;
279
280
  // we want to pull out the log file that is created, and highlight it
@@ -282,7 +283,7 @@ class XcodeBuild {
282
283
  // pull out the first line that begins with the path separator
283
284
  // which *should* be the line indicating the log file generated
284
285
  xcodebuild.logLocation = _.first(_.remove(out.trim().split('\n'), (v) => v.startsWith(path.sep)));
285
- log.debug(`Log file for xcodebuild test: ${xcodebuild.logLocation}`);
286
+ xcodeLog.debug(`Log file for xcodebuild test: ${xcodebuild.logLocation}`);
286
287
  }
287
288
 
288
289
  // if we have an error we want to output the logs
@@ -319,7 +320,7 @@ class XcodeBuild {
319
320
  // any startup errors that are thrown as events
320
321
  return await new B((resolve, reject) => {
321
322
  this.xcodebuild.on('exit', async (code, signal) => {
322
- log.error(`xcodebuild exited with code '${code}' and signal '${signal}'`);
323
+ xcodeLog.error(`xcodebuild exited with code '${code}' and signal '${signal}'`);
323
324
  // print out the xcodebuild file if users have asked for it
324
325
  if (this.showXcodeLog && this.xcodebuild.logLocation) {
325
326
  xcodeLog.error(`Contents of xcodebuild log file '${this.xcodebuild.logLocation}':`);
@@ -329,7 +330,7 @@ class XcodeBuild {
329
330
  xcodeLog.error(line);
330
331
  }
331
332
  } catch (err) {
332
- log.error(`Unable to access xcodebuild log file: '${err.message}'`);
333
+ xcodeLog.error(`Unable to access xcodebuild log file: '${err.message}'`);
333
334
  }
334
335
  }
335
336
  this.xcodebuild.processExited = true;
@@ -353,7 +354,7 @@ class XcodeBuild {
353
354
  }
354
355
  } catch (err) {
355
356
  let msg = `Unable to start WebDriverAgent: ${err}`;
356
- log.error(msg);
357
+ this.log.error(msg);
357
358
  reject(new Error(msg));
358
359
  }
359
360
  })();
@@ -362,7 +363,7 @@ class XcodeBuild {
362
363
 
363
364
  async waitForStart (timer) {
364
365
  // try to connect once every 0.5 seconds, until `launchTimeout` is up
365
- log.debug(`Waiting up to ${this.launchTimeout}ms for WebDriverAgent to start`);
366
+ this.log.debug(`Waiting up to ${this.launchTimeout}ms for WebDriverAgent to start`);
366
367
  let currentStatus = null;
367
368
  try {
368
369
  let retries = parseInt(this.launchTimeout / 500, 10);
@@ -378,8 +379,8 @@ class XcodeBuild {
378
379
  if (currentStatus && currentStatus.ios && currentStatus.ios.ip) {
379
380
  this.agentUrl = currentStatus.ios.ip;
380
381
  }
381
- log.debug(`WebDriverAgent information:`);
382
- log.debug(JSON.stringify(currentStatus, null, 2));
382
+ this.log.debug(`WebDriverAgent information:`);
383
+ this.log.debug(JSON.stringify(currentStatus, null, 2));
383
384
  } catch (err) {
384
385
  throw new Error(`Unable to connect to running WebDriverAgent: ${err.message}`);
385
386
  } finally {
@@ -392,12 +393,12 @@ class XcodeBuild {
392
393
  return currentStatus;
393
394
  }
394
395
 
395
- log.debug(`WebDriverAgent successfully started after ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);
396
+ this.log.debug(`WebDriverAgent successfully started after ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);
396
397
  } catch (err) {
397
398
  // at this point, if we have not had any errors from xcode itself (reported
398
399
  // elsewhere), we can let this go through and try to create the session
399
- log.debug(err.message);
400
- log.warn(`Getting status of WebDriverAgent on device timed out. Continuing`);
400
+ this.log.debug(err.message);
401
+ this.log.warn(`Getting status of WebDriverAgent on device timed out. Continuing`);
401
402
  }
402
403
  return currentStatus;
403
404
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.3.1",
3
+ "version": "4.4.2",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -43,23 +43,24 @@
43
43
  },
44
44
  "homepage": "https://github.com/appium/WebDriverAgent#readme",
45
45
  "devDependencies": {
46
- "@appium/gulp-plugins": "^6.0.0",
47
- "@appium/eslint-config-appium": "^5.0.0",
46
+ "@appium/gulp-plugins": "^7.0.0",
47
+ "@appium/eslint-config-appium": "^6.0.0",
48
48
  "@appium/test-support": "^1.0.0",
49
49
  "@semantic-release/git": "^10.0.1",
50
50
  "appium-xcode": "^4.0.0",
51
51
  "chai": "^4.2.0",
52
52
  "chai-as-promised": "^7.1.1",
53
- "glob": "^7.1.0",
53
+ "eslint-config-prettier": "^8.5.0",
54
+ "glob": "^8.0.1",
54
55
  "gulp": "^4.0.2",
55
56
  "ios-uicatalog": "^3.5.0",
56
- "mocha": "^9.0.0",
57
+ "mocha": "^10.0.0",
57
58
  "pre-commit": "^1.2.2",
58
59
  "semantic-release": "^19.0.2",
59
60
  "sinon": "^13.0.0"
60
61
  },
61
62
  "dependencies": {
62
- "@appium/base-driver": "^8.0.0",
63
+ "@appium/base-driver": "^8.3.0",
63
64
  "@appium/support": "^2.55.3",
64
65
  "@babel/runtime": "^7.0.0",
65
66
  "appium-ios-simulator": "^4.0.0",