appium-espresso-driver 2.1.2 → 2.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.
@@ -1,7 +1,6 @@
1
1
  import { SubProcess } from 'teen_process';
2
- import { fs, logger, system } from '@appium/support';
2
+ import { fs, system } from '@appium/support';
3
3
  import _ from 'lodash';
4
- import log from './logger';
5
4
  import path from 'path';
6
5
  import { EOL } from 'os';
7
6
  import { updateDependencyLines } from './utils';
@@ -22,11 +21,10 @@ const VERSION_KEYS = [
22
21
  'kotlin',
23
22
  'sourceCompatibility',
24
23
  'targetCompatibility',
25
- 'jvmTarget'
24
+ 'jvmTarget',
25
+ 'composeVersion'
26
26
  ];
27
27
 
28
- const gradleLog = logger.getLogger('Gradle');
29
-
30
28
  function buildServerSigningConfig (args) {
31
29
  return {
32
30
  zipAlign: true,
@@ -38,7 +36,8 @@ function buildServerSigningConfig (args) {
38
36
  }
39
37
 
40
38
  class ServerBuilder {
41
- constructor (args = {}) {
39
+ constructor (log, args = {}) {
40
+ this.log = log;
42
41
  this.serverPath = args.serverPath;
43
42
  this.showGradleLog = args.showGradleLog;
44
43
 
@@ -73,7 +72,7 @@ class ServerBuilder {
73
72
  }
74
73
 
75
74
  getCommand () {
76
- const cmd = system.isWindows() ? 'gradlew.bat' : './gradlew';
75
+ const cmd = system.isWindows() ? 'gradlew.bat' : path.resolve(this.serverPath, 'gradlew');
77
76
  const buildProperty = (key, value) => value ? `-P${key}=${value}` : null;
78
77
  let args = VERSION_KEYS
79
78
  .filter((key) => key !== GRADLE_VERSION_KEY)
@@ -150,7 +149,7 @@ class ServerBuilder {
150
149
  continue;
151
150
  }
152
151
 
153
- log.info(`Adding the following ${propName} to build.gradle.kts: ${deps}`);
152
+ this.log.info(`Adding the following ${propName} to build.gradle.kts: ${deps}`);
154
153
  configuration = updateDependencyLines(configuration, propName, deps);
155
154
  }
156
155
  await fs.writeFile(buildPath, configuration, 'utf8');
@@ -158,7 +157,7 @@ class ServerBuilder {
158
157
 
159
158
  async runBuildProcess () {
160
159
  const {cmd, args} = this.getCommand();
161
- log.debug(`Beginning build with command '${cmd} ${args.join(' ')}' ` +
160
+ this.log.debug(`Beginning build with command '${cmd} ${args.join(' ')}' ` +
162
161
  `in directory '${this.serverPath}'`);
163
162
  const gradlebuild = new SubProcess(cmd, args, {
164
163
  cwd: this.serverPath,
@@ -168,13 +167,13 @@ class ServerBuilder {
168
167
  let buildLastLines = [];
169
168
 
170
169
  const logMsg = `Output from Gradle ${this.showGradleLog ? 'will' : 'will not'} be logged`;
171
- log.debug(`${logMsg}. To change this, use 'showGradleLog' desired capability`);
170
+ this.log.debug(`${logMsg}. To change this, use 'showGradleLog' desired capability`);
172
171
  gradlebuild.on('stream-line', (line) => {
173
172
  if (this.showGradleLog) {
174
173
  if (line.startsWith('[STDERR]')) {
175
- gradleLog.warn(line);
174
+ this.log.warn(`[Gradle] ${line}`);
176
175
  } else {
177
- gradleLog.info(line);
176
+ this.log.info(`[Gradle] ${line}`);
178
177
  }
179
178
  }
180
179
  buildLastLines.push(`${EOL}${line}`);
@@ -189,7 +188,7 @@ class ServerBuilder {
189
188
  } catch (err) {
190
189
  let msg = `Unable to build Espresso server - ${err.message}\n` +
191
190
  `Gradle error message:${EOL}${buildLastLines}`;
192
- log.errorAndThrow(msg);
191
+ this.log.errorAndThrow(msg);
193
192
  }
194
193
  }
195
194
  }