appium-espresso-driver 3.0.0 → 3.2.0

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 CHANGED
@@ -1,3 +1,15 @@
1
+ ## [3.2.0](https://github.com/appium/appium-espresso-driver/compare/v3.1.0...v3.2.0) (2024-07-15)
2
+
3
+ ### Features
4
+
5
+ * Add proper info to the /status API response ([#1022](https://github.com/appium/appium-espresso-driver/issues/1022)) ([4602a6f](https://github.com/appium/appium-espresso-driver/commit/4602a6fe4a03915a96db9f33dfa7f5b0d77e121d))
6
+
7
+ ## [3.1.0](https://github.com/appium/appium-espresso-driver/compare/v3.0.0...v3.1.0) (2024-07-11)
8
+
9
+ ### Features
10
+
11
+ * Publish Espresso server library to JitPack ([#1021](https://github.com/appium/appium-espresso-driver/issues/1021)) ([9445667](https://github.com/appium/appium-espresso-driver/commit/94456673880e591808e06db57da1d21ec823ec0c))
12
+
1
13
  ## [3.0.0](https://github.com/appium/appium-espresso-driver/compare/v2.44.2...v3.0.0) (2024-07-10)
2
14
 
3
15
  ### ⚠ BREAKING CHANGES
@@ -1,6 +1,7 @@
1
1
  plugins {
2
2
  id("com.android.library")
3
3
  kotlin("android")
4
+ `maven-publish`
4
5
  }
5
6
 
6
7
  val appiumCompileSdk: String by project
@@ -51,6 +52,22 @@ android {
51
52
  targetSdk = appiumTargetSdk.toInt()
52
53
  unitTests.isReturnDefaultValues = true
53
54
  }
55
+
56
+ publishing {
57
+ singleVariant("release") {
58
+ withSourcesJar()
59
+ }
60
+ }
61
+ }
62
+
63
+ publishing {
64
+ publications {
65
+ register<MavenPublication>("release") {
66
+ afterEvaluate {
67
+ from(components["release"])
68
+ }
69
+ }
70
+ }
54
71
  }
55
72
 
56
73
  dependencies {
@@ -16,11 +16,22 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
+ import androidx.test.platform.app.InstrumentationRegistry
20
+ import io.appium.espressoserver.lib.helpers.getEspressoServerVersion
19
21
  import io.appium.espressoserver.lib.model.AppiumParams
22
+ import io.appium.espressoserver.lib.model.BuildInfo
20
23
 
21
- class Status : RequestHandler<AppiumParams, Void?>, NoSessionCommandHandler {
22
24
 
23
- override fun handleInternal(params: AppiumParams): Void? {
24
- return null
25
+ class Status : RequestHandler<AppiumParams, io.appium.espressoserver.lib.model.Status>, NoSessionCommandHandler {
26
+
27
+ override fun handleInternal(params: AppiumParams): io.appium.espressoserver.lib.model.Status {
28
+ return io.appium.espressoserver.lib.model.Status(
29
+ ready = true,
30
+ message = "The server is ready to accept new connections",
31
+ build = BuildInfo(
32
+ version = getEspressoServerVersion(),
33
+ packageName = InstrumentationRegistry.getInstrumentation().targetContext.packageName
34
+ )
35
+ )
25
36
  }
26
37
  }
@@ -0,0 +1,7 @@
1
+ package io.appium.espressoserver.lib.helpers
2
+
3
+ // This value is updated automatically by the NPM versioning script
4
+ // It should be in sync with the NPM module version from package.json
5
+ private const val VERSION = "3.2.0"
6
+
7
+ fun getEspressoServerVersion() = VERSION
@@ -21,6 +21,7 @@ import com.google.gson.JsonParseException
21
21
  import fi.iki.elonen.NanoHTTPD.Method
22
22
  import io.appium.espressoserver.lib.handlers.*
23
23
  import io.appium.espressoserver.lib.handlers.PointerEventHandler.TouchType.*
24
+ import io.appium.espressoserver.lib.handlers.Status
24
25
  import io.appium.espressoserver.lib.handlers.TouchAction
25
26
  import io.appium.espressoserver.lib.handlers.exceptions.*
26
27
  import io.appium.espressoserver.lib.helpers.AndroidLogger
@@ -16,6 +16,7 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.model
18
18
 
19
+ import com.google.gson.annotations.Expose
19
20
  import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
20
21
 
21
22
 
@@ -23,7 +24,8 @@ const val SESSION_ID_PARAM_NAME = "sessionId"
23
24
  const val ELEMENT_ID_PARAM_NAME = "elementId"
24
25
 
25
26
  open class AppiumParams {
26
- var uriParams:MutableMap<String, String>? = null
27
+ @Expose(serialize = false, deserialize = true)
28
+ private var uriParams: MutableMap<String, String>? = null
27
29
 
28
30
  val sessionId: String?
29
31
  get() = getUriParameterValue(SESSION_ID_PARAM_NAME)
@@ -16,4 +16,7 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.model
18
18
 
19
- data class Location(var x: Int? = null, var y: Int? = null) : AppiumParams()
19
+ data class Location(
20
+ val x: Int,
21
+ val y: Int
22
+ )
@@ -18,12 +18,12 @@ package io.appium.espressoserver.lib.model
18
18
 
19
19
  import android.graphics.Rect
20
20
 
21
- class Rect(
22
- var x: Int? = null,
23
- var y: Int? = null,
24
- var width: Int? = null,
25
- var height: Int? = null
26
- ) : AppiumParams() {
21
+ data class Rect(
22
+ var x: Int,
23
+ var y: Int,
24
+ var width: Int,
25
+ var height: Int
26
+ ) {
27
27
  companion object {
28
28
  fun fromBounds(bounds: Rect): io.appium.espressoserver.lib.model.Rect =
29
29
  io.appium.espressoserver.lib.model.Rect(
@@ -19,4 +19,4 @@ package io.appium.espressoserver.lib.model
19
19
  data class Size(
20
20
  val width: Int,
21
21
  val height: Int
22
- ) : AppiumParams()
22
+ )
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.model
18
+
19
+ data class Status(
20
+ val ready: Boolean,
21
+ val message: String,
22
+ val build: BuildInfo
23
+ )
24
+
25
+ data class BuildInfo(
26
+ val version: String,
27
+ val packageName: String
28
+ )
@@ -21,4 +21,4 @@ data class WindowRect(
21
21
  val height: Int,
22
22
  val x: Int,
23
23
  val y: Int
24
- ) : AppiumParams()
24
+ )
@@ -19,4 +19,4 @@ package io.appium.espressoserver.lib.model
19
19
  data class WindowSize(
20
20
  val width: Int,
21
21
  val height: Int
22
- ) : AppiumParams()
22
+ )
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appium-espresso-driver",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-espresso-driver",
9
- "version": "3.0.0",
9
+ "version": "3.2.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "appium-adb": "^12.4.0",
@@ -42,6 +42,7 @@
42
42
  "mocha": "^10.0.0",
43
43
  "rimraf": "^5.0.0",
44
44
  "semantic-release": "^24.0.0",
45
+ "semver": "^7.3.7",
45
46
  "sinon": "^17.0.0",
46
47
  "ts-node": "^10.9.1",
47
48
  "typescript": "^5.4.2",
@@ -764,13 +765,13 @@
764
765
  }
765
766
  },
766
767
  "node_modules/appium-android-driver": {
767
- "version": "9.7.4",
768
- "resolved": "https://registry.npmjs.org/appium-android-driver/-/appium-android-driver-9.7.4.tgz",
769
- "integrity": "sha512-hOjcpFT57PrhzxglrG7KpIJSXHVQ9Hlw5yGcRC4RpymBvUZjcvWflvord6oaYb0juGV/7X0d7NltrX2jPAUhhg==",
768
+ "version": "9.7.5",
769
+ "resolved": "https://registry.npmjs.org/appium-android-driver/-/appium-android-driver-9.7.5.tgz",
770
+ "integrity": "sha512-A/XU3RiueOp6RCtfJSfJ16iRwmNNLb98zNjBbTOnPetWWav9nEIEGkZzuDNdMEtBv4xviFXH/4wsdnUWtHKTFw==",
770
771
  "dependencies": {
771
772
  "@appium/support": "^5.0.3",
772
773
  "@colors/colors": "^1.6.0",
773
- "appium-adb": "^12.3.0",
774
+ "appium-adb": "^12.5.0",
774
775
  "appium-chromedriver": "^5.5.1",
775
776
  "asyncbox": "^3.0.0",
776
777
  "axios": "^1.x",
@@ -1223,9 +1224,9 @@
1223
1224
  }
1224
1225
  },
1225
1226
  "node_modules/compare-versions": {
1226
- "version": "6.1.0",
1227
- "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-6.1.0.tgz",
1228
- "integrity": "sha512-LNZQXhqUvqUTotpZ00qLSaify3b4VFD588aRr8MKFw4CMUr98ytzCW5wDH5qx/DEY5kCDXcbcRuCqL0szEf2tg=="
1227
+ "version": "6.1.1",
1228
+ "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-6.1.1.tgz",
1229
+ "integrity": "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg=="
1229
1230
  },
1230
1231
  "node_modules/compress-commons": {
1231
1232
  "version": "6.0.2",
@@ -2026,9 +2027,9 @@
2026
2027
  }
2027
2028
  },
2028
2029
  "node_modules/io.appium.settings": {
2029
- "version": "5.12.5",
2030
- "resolved": "https://registry.npmjs.org/io.appium.settings/-/io.appium.settings-5.12.5.tgz",
2031
- "integrity": "sha512-yZQ/bkv4W1BYde5oVvlMwtPgYUWs+iFXeGjGGw8nZbWHCWbF2IzwlZx6yWpGCgEr1CM9Wc9YNoggiMUD/wPsSQ==",
2030
+ "version": "5.12.6",
2031
+ "resolved": "https://registry.npmjs.org/io.appium.settings/-/io.appium.settings-5.12.6.tgz",
2032
+ "integrity": "sha512-BFLzG0s7o6rR2Wfkzn72HEHmbLxZEpKG32VrvZmgJdZcO4kRoKyYkDVZRwvzDEEs+qk42OzsLdFZDLf8s5gJaw==",
2032
2033
  "dependencies": {
2033
2034
  "@appium/logger": "^1.3.0",
2034
2035
  "asyncbox": "^3.0.0",
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "automated testing",
8
8
  "android"
9
9
  ],
10
- "version": "3.0.0",
10
+ "version": "3.2.0",
11
11
  "author": "Appium Contributors",
12
12
  "license": "Apache-2.0",
13
13
  "repository": {
@@ -98,9 +98,11 @@
98
98
  "lint:server": "cd espresso-server && ./gradlew lint || cd ..",
99
99
  "lint:fix": "npm run lint -- --fix",
100
100
  "prepare": "npm run rebuild",
101
+ "sync-version": "node ./scripts/sync-version.js --package-version=${npm_package_version}",
101
102
  "test": "npm run test:node",
102
103
  "test:node": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.js\"",
103
104
  "test:server": "cd espresso-server && ./gradlew test --stacktrace || cd ..",
105
+ "version": "npm run sync-version && npm run build:server",
104
106
  "e2e-test": "mocha --exit --timeout 5m \"./test/functional/**/*-specs.js\""
105
107
  },
106
108
  "peerDependencies": {
@@ -130,6 +132,7 @@
130
132
  "rimraf": "^5.0.0",
131
133
  "semantic-release": "^24.0.0",
132
134
  "sinon": "^17.0.0",
135
+ "semver": "^7.3.7",
133
136
  "ts-node": "^10.9.1",
134
137
  "typescript": "^5.4.2",
135
138
  "webdriverio": "^8.0.2",
@@ -0,0 +1,47 @@
1
+ const path = require('node:path');
2
+ const { logger, fs } = require('appium/support');
3
+ const semver = require('semver');
4
+
5
+ const LOG = logger.getLogger('VersionSync');
6
+
7
+ const ROOT_DIR = path.resolve(__dirname, '..');
8
+ const ESPRESSO_SERVER_ROOT = path.join(ROOT_DIR, 'espresso-server');
9
+ const VERSION_FILE = path.join(
10
+ ESPRESSO_SERVER_ROOT, 'library', 'src', 'main', 'java',
11
+ 'io', 'appium', 'espressoserver',
12
+ 'lib', 'helpers', 'Version.kt'
13
+ );
14
+ const VERSION_PATTERN = /VERSION\s*=\s*"([0-9.]+)"/;
15
+
16
+ function parseArgValue (argName) {
17
+ const argNamePattern = new RegExp(`^--${argName}\\b`);
18
+ for (let i = 1; i < process.argv.length; ++i) {
19
+ const arg = process.argv[i];
20
+ if (argNamePattern.test(arg)) {
21
+ return arg.includes('=') ? arg.split('=')[1] : process.argv[i + 1];
22
+ }
23
+ }
24
+ return null;
25
+ }
26
+
27
+ async function syncModuleVersion () {
28
+ const origContent = await fs.readFile(VERSION_FILE, 'utf8');
29
+ const espressoVersionMatch = VERSION_PATTERN.exec(origContent);
30
+ if (!espressoVersionMatch) {
31
+ throw new Error(`Could not parse Espresso module version from '${VERSION_FILE}'`);
32
+ }
33
+ const packageVersion = parseArgValue('package-version');
34
+ if (!packageVersion) {
35
+ throw new Error('No package version argument (use `--package-version=xxx`)');
36
+ }
37
+ if (!semver.valid(packageVersion)) {
38
+ throw new Error(
39
+ `Invalid version specified '${packageVersion}'. Version should be in the form '1.2.3'`
40
+ );
41
+ }
42
+ const updatedContent = origContent.replace(espressoVersionMatch[1], packageVersion);
43
+ await fs.writeFile(VERSION_FILE, updatedContent, 'utf8');
44
+ LOG.info(`Synchronized module version '${packageVersion}' to '${VERSION_FILE}'`);
45
+ }
46
+
47
+ (async () => await syncModuleVersion())();