appium-espresso-driver 10.3.0 → 10.4.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/lib/commands/orientation.d.ts +33 -0
  3. package/build/lib/commands/orientation.d.ts.map +1 -0
  4. package/build/lib/commands/orientation.js +34 -0
  5. package/build/lib/commands/orientation.js.map +1 -0
  6. package/build/lib/driver.d.ts.map +1 -1
  7. package/build/lib/driver.js +13 -0
  8. package/build/lib/driver.js.map +1 -1
  9. package/build/lib/execute-method-map.d.ts +4 -0
  10. package/build/lib/execute-method-map.d.ts.map +1 -1
  11. package/espresso-server/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk +0 -0
  12. package/espresso-server/buildSrc/.gradle/9.7.1/executionHistory/executionHistory.bin +0 -0
  13. package/espresso-server/buildSrc/.gradle/9.7.1/executionHistory/executionHistory.lock +0 -0
  14. package/espresso-server/buildSrc/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  15. package/espresso-server/buildSrc/.gradle/buildOutputCleanup/cache.properties +1 -1
  16. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin +0 -0
  17. package/espresso-server/library/src/main/java/io/appium/espressoserver/lib/helpers/Version.kt +1 -1
  18. package/lib/commands/orientation.ts +49 -0
  19. package/lib/driver.ts +14 -0
  20. package/node_modules/appium-android-driver/CHANGELOG.md +51 -0
  21. package/node_modules/appium-android-driver/build/lib/commands/find.js +2 -2
  22. package/node_modules/appium-android-driver/build/lib/commands/find.js.map +1 -1
  23. package/node_modules/appium-android-driver/build/lib/commands/log.d.ts +4 -0
  24. package/node_modules/appium-android-driver/build/lib/commands/log.d.ts.map +1 -1
  25. package/node_modules/appium-android-driver/build/lib/commands/log.js +2 -0
  26. package/node_modules/appium-android-driver/build/lib/commands/log.js.map +1 -1
  27. package/node_modules/appium-android-driver/build/lib/commands/media-stream/constants.d.ts +3 -0
  28. package/node_modules/appium-android-driver/build/lib/commands/media-stream/constants.d.ts.map +1 -1
  29. package/node_modules/appium-android-driver/build/lib/commands/media-stream/constants.js +4 -0
  30. package/node_modules/appium-android-driver/build/lib/commands/media-stream/constants.js.map +1 -1
  31. package/node_modules/appium-android-driver/build/lib/commands/media-stream/exports.d.ts +10 -4
  32. package/node_modules/appium-android-driver/build/lib/commands/media-stream/exports.d.ts.map +1 -1
  33. package/node_modules/appium-android-driver/build/lib/commands/media-stream/exports.js +37 -17
  34. package/node_modules/appium-android-driver/build/lib/commands/media-stream/exports.js.map +1 -1
  35. package/node_modules/appium-android-driver/build/lib/commands/media-stream/stream.d.ts +34 -2
  36. package/node_modules/appium-android-driver/build/lib/commands/media-stream/stream.d.ts.map +1 -1
  37. package/node_modules/appium-android-driver/build/lib/commands/media-stream/stream.js +89 -43
  38. package/node_modules/appium-android-driver/build/lib/commands/media-stream/stream.js.map +1 -1
  39. package/node_modules/appium-android-driver/build/lib/driver.d.ts +5 -0
  40. package/node_modules/appium-android-driver/build/lib/driver.d.ts.map +1 -1
  41. package/node_modules/appium-android-driver/build/lib/driver.js +1 -0
  42. package/node_modules/appium-android-driver/build/lib/driver.js.map +1 -1
  43. package/node_modules/appium-android-driver/build/lib/execute-method-map.d.ts +4 -0
  44. package/node_modules/appium-android-driver/build/lib/execute-method-map.d.ts.map +1 -1
  45. package/node_modules/appium-android-driver/build/lib/execute-method-map.js +5 -0
  46. package/node_modules/appium-android-driver/build/lib/execute-method-map.js.map +1 -1
  47. package/node_modules/appium-android-driver/lib/commands/find.ts +2 -2
  48. package/node_modules/appium-android-driver/lib/commands/log.ts +4 -0
  49. package/node_modules/appium-android-driver/lib/commands/media-stream/constants.ts +4 -0
  50. package/node_modules/appium-android-driver/lib/commands/media-stream/exports.ts +51 -17
  51. package/node_modules/appium-android-driver/lib/commands/media-stream/stream.ts +90 -43
  52. package/node_modules/appium-android-driver/lib/driver.ts +1 -0
  53. package/node_modules/appium-android-driver/lib/execute-method-map.ts +6 -0
  54. package/node_modules/appium-android-driver/package.json +4 -4
  55. package/node_modules/asyncbox/README.md +7 -3
  56. package/node_modules/asyncbox/build/lib/shared/errors.d.ts +18 -2
  57. package/node_modules/asyncbox/build/lib/shared/errors.d.ts.map +1 -1
  58. package/node_modules/asyncbox/build/lib/shared/errors.js +24 -8
  59. package/node_modules/asyncbox/build/lib/shared/errors.js.map +1 -1
  60. package/node_modules/asyncbox/lib/shared/errors.ts +34 -8
  61. package/node_modules/asyncbox/package.json +1 -1
  62. package/node_modules/bare-fs/package.json +2 -2
  63. package/node_modules/bare-fs/prebuilds/android-arm/bare-fs.bare +0 -0
  64. package/node_modules/bare-fs/prebuilds/android-arm64/bare-fs.bare +0 -0
  65. package/node_modules/bare-fs/prebuilds/android-ia32/bare-fs.bare +0 -0
  66. package/node_modules/bare-fs/prebuilds/android-x64/bare-fs.bare +0 -0
  67. package/node_modules/bare-fs/prebuilds/darwin-arm64/bare-fs.bare +0 -0
  68. package/node_modules/bare-fs/prebuilds/darwin-x64/bare-fs.bare +0 -0
  69. package/node_modules/bare-fs/prebuilds/ios-arm64/bare-fs.bare +0 -0
  70. package/node_modules/bare-fs/prebuilds/ios-arm64-simulator/bare-fs.bare +0 -0
  71. package/node_modules/bare-fs/prebuilds/ios-x64-simulator/bare-fs.bare +0 -0
  72. package/node_modules/bare-fs/prebuilds/linux-arm64/bare-fs.bare +0 -0
  73. package/node_modules/bare-fs/prebuilds/linux-x64/bare-fs.bare +0 -0
  74. package/node_modules/bare-fs/prebuilds/win32-arm64/bare-fs.bare +0 -0
  75. package/node_modules/bare-fs/prebuilds/win32-x64/bare-fs.bare +0 -0
  76. package/node_modules/io.appium.settings/CHANGELOG.md +14 -0
  77. package/node_modules/io.appium.settings/apks/settings_apk-debug.apk +0 -0
  78. package/node_modules/io.appium.settings/package.json +2 -2
  79. package/node_modules/plist/dist/parse-binary.d.ts.map +1 -1
  80. package/node_modules/plist/dist/parse-binary.js +37 -9
  81. package/node_modules/plist/dist/parse-binary.js.map +1 -1
  82. package/node_modules/plist/package.json +1 -1
  83. package/package.json +4 -4
  84. package/scripts/lib/dependency-versions/apk-meta-inf.mjs +0 -13
  85. package/scripts/lib/dependency-versions/comparison.mjs +17 -47
  86. package/scripts/lib/dependency-versions/gradle-scan.mjs +77 -87
  87. package/scripts/lib/dependency-versions/index.mjs +1 -1
  88. package/scripts/lib/dependency-versions/report.mjs +4 -4
  89. package/scripts/lib/dependency-versions/tracked-modules.mjs +2 -42
  90. package/scripts/lib/dependency-versions/types.mjs +2 -1
  91. package/scripts/lib/dependency-versions/version-utils.mjs +124 -2
  92. package/scripts/lib/diagnose/app-input.mjs +4 -1
  93. package/scripts/lib/diagnose/checks/compile-sdk.mjs +6 -2
  94. package/scripts/lib/diagnose/checks/dependency.mjs +1 -1
  95. package/scripts/lib/diagnose/checks/index.mjs +0 -3
  96. package/scripts/lib/diagnose/checks/obfuscation.mjs +1 -1
  97. package/scripts/lib/diagnose/diagnosis.mjs +2 -7
  98. package/scripts/lib/diagnose/report.mjs +2 -2
  99. package/scripts/lib/diagnose/checks/androidx.mjs +0 -40
  100. package/scripts/lib/diagnose/checks/lifecycle-extensions.mjs +0 -23
  101. package/scripts/lib/diagnose/checks/startup-provider.mjs +0 -41
@@ -31,33 +31,25 @@ export function compareModuleVersions(serverVersion, appVersion) {
31
31
  /**
32
32
  * @param {Record<string, string>} serverVersions
33
33
  * @param {Record<string, string[]>} appVersions
34
- * @param {{proguardLikely?: boolean, minifyEnabled?: boolean | null, detectionSource?: 'apk' | 'project'}} context
34
+ * @param {{proguardLikely?: boolean, minifyEnabled?: boolean | null, detectionSource?: 'apk' | 'project', composeDetected?: boolean}} context
35
35
  * @returns {import('./types.mjs').ComparisonReport}
36
36
  */
37
37
  export function buildComparisonReport(serverVersions, appVersions, context = {}) {
38
38
  const proguardLikely = Boolean(context.proguardLikely);
39
39
  const minifyEnabled = context.minifyEnabled ?? null;
40
40
  const detectionSource = context.detectionSource ?? 'project';
41
+ const composeDetected = Boolean(context.composeDetected);
41
42
  /** @type {import('./types.mjs').ModuleComparison[]} */
42
43
  const modules = [];
43
44
 
44
45
  for (const mod of TRACKED_MODULES) {
46
+ if (mod.onlyWithCompose && !composeDetected) {
47
+ continue;
48
+ }
45
49
  const serverVersion = serverVersions[mod.id];
46
50
  const appCandidates = appVersions[mod.id] ?? [];
47
51
  const appVersion = appCandidates[0] ?? null;
48
52
 
49
- if (mod.testOnly) {
50
- modules.push({
51
- ...mod,
52
- serverVersion: serverVersion ?? null,
53
- appVersions: appCandidates,
54
- appVersion,
55
- diff: appVersion ? 'present' : 'absent',
56
- recommendation: buildTestOnlyRecommendation(mod, appCandidates),
57
- });
58
- continue;
59
- }
60
-
61
53
  const diff = compareModuleVersions(serverVersion, appVersion);
62
54
  modules.push({
63
55
  ...mod,
@@ -68,6 +60,7 @@ export function buildComparisonReport(serverVersions, appVersions, context = {})
68
60
  recommendation: buildVersionRecommendation(mod, diff, appVersion, serverVersion, {
69
61
  proguardLikely,
70
62
  detectionSource,
63
+ composeDetected,
71
64
  }),
72
65
  });
73
66
  }
@@ -75,39 +68,12 @@ export function buildComparisonReport(serverVersions, appVersions, context = {})
75
68
  return {
76
69
  proguardLikely,
77
70
  minifyEnabled,
71
+ composeDetected,
78
72
  modules,
79
73
  summary: summarizeReport(modules, {proguardLikely, minifyEnabled}),
80
74
  };
81
75
  }
82
76
 
83
- /**
84
- * @param {string[]} appVersions
85
- * @returns {string}
86
- */
87
- function formatDetectedVersions(appVersions) {
88
- return appVersions.length ? appVersions.join(', ') : 'detected';
89
- }
90
-
91
- /**
92
- * @param {import('./types.mjs').TrackedModule} mod
93
- * @param {string[]} appVersions
94
- * @returns {import('./types.mjs').Recommendation}
95
- */
96
- function buildTestOnlyRecommendation(mod, appVersions) {
97
- if (appVersions.length) {
98
- const versions = formatDetectedVersions(appVersions);
99
- return {
100
- level: 'warning',
101
- message:
102
- `Detected ${mod.label} (${versions}) in the application under test. ` +
103
- 'The main app should not be built as an instrumented-test artifact and is not expected to ' +
104
- 'bundle Espresso, AndroidX Test, or UiAutomator dependencies; doing so ' +
105
- 'can cause classpath conflicts with the Espresso server.',
106
- };
107
- }
108
- return {level: 'ok', message: 'Not detected in the app; no action needed.'};
109
- }
110
-
111
77
  /**
112
78
  * @param {import('./types.mjs').TrackedModule} mod
113
79
  * @param {string} appVersion
@@ -125,7 +91,7 @@ function toolsVersionsOverride(mod, appVersion) {
125
91
  * @param {import('./types.mjs').VersionDiffKind} diff
126
92
  * @param {string | null} appVersion
127
93
  * @param {string | undefined} serverVersion
128
- * @param {{proguardLikely: boolean, detectionSource: 'apk' | 'project'}} ctx
94
+ * @param {{proguardLikely: boolean, detectionSource: 'apk' | 'project', composeDetected: boolean}} ctx
129
95
  * @returns {import('./types.mjs').Recommendation}
130
96
  */
131
97
  function buildVersionRecommendation(mod, diff, appVersion, serverVersion, ctx) {
@@ -140,6 +106,14 @@ function buildVersionRecommendation(mod, diff, appVersion, serverVersion, ctx) {
140
106
  };
141
107
  }
142
108
  if (!appVersion) {
109
+ if (mod.id === 'compose' && ctx.detectionSource === 'project' && ctx.composeDetected) {
110
+ return {
111
+ level: 'info',
112
+ message:
113
+ 'The app uses Jetpack Compose, but its version could not be read from the Gradle files (e.g. it comes from a BOM). ' +
114
+ `Set toolsVersions.${mod.toolsVersionKey} in espressoBuildConfig to the version the app resolves to if it differs from the server's.`,
115
+ };
116
+ }
143
117
  if (mod.id === 'compose' && ctx.detectionSource === 'project') {
144
118
  return {
145
119
  level: 'suggestion',
@@ -194,15 +168,11 @@ function buildVersionRecommendation(mod, diff, appVersion, serverVersion, ctx) {
194
168
  * @param {{proguardLikely: boolean, minifyEnabled: boolean | null}} ctx
195
169
  */
196
170
  function summarizeReport(modules, ctx) {
197
- const testPresence = modules.filter((m) => m.testOnly && m.recommendation.level === 'warning');
198
- const warnings = modules.filter((m) => !m.testOnly && m.recommendation.level === 'warning');
171
+ const warnings = modules.filter((m) => m.recommendation.level === 'warning');
199
172
  const suggestions = modules.filter((m) => m.recommendation.level === 'suggestion');
200
173
  if (ctx.proguardLikely) {
201
174
  return 'APK appears minified/obfuscated; dependency versions from the APK may be incomplete. Espresso server defaults are listed below.';
202
175
  }
203
- if (testPresence.length) {
204
- return `${testPresence.length} test/instrumentation librar${testPresence.length === 1 ? 'y' : 'ies'} detected in the application under test — review warnings below.`;
205
- }
206
176
  if (warnings.length) {
207
177
  return `${warnings.length} module(s) have a large version mismatch — review warnings below.`;
208
178
  }
@@ -6,46 +6,12 @@ import {findFiles} from '../find-files.mjs';
6
6
  import {TRACKED_MODULES, createEmptyVersionSets} from './tracked-modules.mjs';
7
7
  import {
8
8
  normalizeVersion,
9
+ parseCatalogAccessors,
9
10
  parseVersionsToml,
10
11
  versionFromPatternMatch,
11
12
  versionSetsToSortedRecords,
12
13
  } from './version-utils.mjs';
13
14
 
14
- /** @type {RegExp} Gradle configs that do not affect the main/release app artifact. */
15
- const NON_MAIN_DEP_CONFIG_LINE = /^\s*(?:androidTest|test)(?:Implementation|Api|CompileOnly|RuntimeOnly|WearApp)\b/;
16
-
17
- /**
18
- * Keeps dependency declarations that can affect the main app artifact (implementation, api, …).
19
- * Strips androidTest* and test* configuration blocks/lines.
20
- * @param {string} text
21
- * @returns {string}
22
- */
23
- export function extractMainAppDependencyScopes(text) {
24
- const lines = text.split('\n');
25
- /** @type {string[]} */
26
- const kept = [];
27
- let skipDepth = 0;
28
-
29
- for (const line of lines) {
30
- if (skipDepth > 0) {
31
- skipDepth += parenDelta(line);
32
- if (skipDepth <= 0) {
33
- skipDepth = 0;
34
- }
35
- continue;
36
- }
37
- if (NON_MAIN_DEP_CONFIG_LINE.test(line)) {
38
- const delta = parenDelta(line);
39
- if (delta > 0) {
40
- skipDepth = delta;
41
- }
42
- continue;
43
- }
44
- kept.push(line);
45
- }
46
- return kept.join('\n');
47
- }
48
-
49
15
  /**
50
16
  * @param {string} root
51
17
  * @param {number} [maxDepth]
@@ -59,6 +25,53 @@ export async function findGradleFiles(root, maxDepth = 6) {
59
25
  });
60
26
  }
61
27
 
28
+ /**
29
+ * Drops block, `//` and full-line `#` (TOML, properties) comments.
30
+ * @param {string} text
31
+ * @returns {string}
32
+ */
33
+ export function stripComments(text) {
34
+ return text
35
+ .replace(/\/\*[\s\S]*?\*\//g, '')
36
+ .replace(/(^|[^:])\/\/.*$/gm, '$1')
37
+ .replace(/^\s*#.*$/gm, '');
38
+ }
39
+
40
+ /**
41
+ * Whether Gradle files (build scripts, version catalogs) show that the app uses Jetpack Compose,
42
+ * whatever the way it is declared: the Compose compiler plugin, `buildFeatures`, a BOM or a catalog reference.
43
+ * @param {string} text
44
+ * @returns {boolean}
45
+ */
46
+ export function usesCompose(text) {
47
+ // `apply false` only declares the plugin for subprojects (usually in the root script)
48
+ const code = stripComments(text).replace(/^.*\bapply\s+false\b.*$/gm, '');
49
+ return /\bcompose\s*=\s*true\b|kotlin\.plugin\.compose|androidx[.-]compose|\blibs\.[\w.]*compose|compose-?bom/i.test(
50
+ code,
51
+ );
52
+ }
53
+
54
+ /**
55
+ * @param {string} text
56
+ * @param {string} accessor
57
+ * @returns {boolean}
58
+ */
59
+ function isReferenced(text, accessor) {
60
+ // the exact accessor, optionally followed by a provider method (`libs.ui` is not `libs.ui.core`)
61
+ const methods = 'get|getOrNull|getOrElse|asProvider|orNull|map|flatMap|zip|isPresent';
62
+ return new RegExp(`(?<![\\w.])${accessor.replace(/\./g, '\\.')}(?!\\w)(?!\\.(?!(?:${methods})\\b)\\w)`).test(text);
63
+ }
64
+
65
+ /**
66
+ * The directory of the Gradle build a version catalog belongs to.
67
+ * @param {string} catalogPath
68
+ * @returns {string}
69
+ */
70
+ function catalogBuildRoot(catalogPath) {
71
+ const dir = path.dirname(catalogPath);
72
+ return path.basename(dir) === 'gradle' ? path.dirname(dir) : dir;
73
+ }
74
+
62
75
  /**
63
76
  * @param {string} projectRoot
64
77
  * @returns {Promise<{versions: Record<string, string[]>, minifyEnabled: boolean | null, sources: string[]}>}
@@ -67,12 +80,18 @@ export async function collectAppVersionsFromProject(projectRoot) {
67
80
  const gradleFiles = await findGradleFiles(projectRoot);
68
81
  const found = createEmptyVersionSets();
69
82
  let minifyEnabled = null;
83
+ /** @type {{root: string, text: string}[]} */
84
+ const catalogs = [];
85
+ /** @type {{dir: string, text: string}[]} */
86
+ const scripts = [];
70
87
 
71
88
  for (const filePath of gradleFiles) {
72
89
  const text = await fs.readFile(filePath, 'utf8');
73
- const rel = path.relative(projectRoot, filePath);
74
- if (!rel.endsWith('libs.versions.toml')) {
75
- collectVersionsFromGradleText(text, TRACKED_MODULES, found);
90
+ if (filePath.endsWith('libs.versions.toml')) {
91
+ catalogs.push({root: catalogBuildRoot(filePath), text});
92
+ } else {
93
+ scripts.push({dir: path.dirname(filePath), text: stripComments(text)});
94
+ collectVersionsFromGradleText(stripComments(text), TRACKED_MODULES, found);
76
95
  }
77
96
  if (/\bisMinifyEnabled\s*=\s*true\b/.test(text) || /\bminifyEnabled\s+true\b/.test(text)) {
78
97
  minifyEnabled = true;
@@ -82,19 +101,25 @@ export async function collectAppVersionsFromProject(projectRoot) {
82
101
  minifyEnabled = false;
83
102
  }
84
103
  }
85
- if (rel.endsWith('libs.versions.toml')) {
86
- const tomlVersions = parseVersionsToml(text);
87
- for (const mod of TRACKED_MODULES) {
88
- if (mod.testOnly) {
89
- continue;
90
- }
91
- const v = tomlVersions[mod.catalogKey];
92
- if (v) {
93
- const normalized = normalizeVersion(v);
94
- if (normalized) {
95
- found[mod.id].add(normalized);
96
- }
97
- }
104
+ }
105
+
106
+ // A catalog version counts only if a script of the build owning the catalog consumes it
107
+ const roots = catalogs.map((c) => c.root);
108
+ const ownerOf = (/** @type {string} */ dir) =>
109
+ roots
110
+ .filter((root) => dir === root || dir.startsWith(root + path.sep))
111
+ .reduce((best, root) => (root.length > best.length ? root : best), '');
112
+ for (const {root, text: catalogText} of catalogs) {
113
+ const ownScripts = scripts
114
+ .filter((s) => ownerOf(s.dir) === root)
115
+ .map((s) => s.text)
116
+ .join('\n');
117
+ const catalogVersions = parseVersionsToml(catalogText);
118
+ const accessors = parseCatalogAccessors(catalogText);
119
+ for (const mod of TRACKED_MODULES) {
120
+ const normalized = normalizeVersion(catalogVersions[mod.catalogKey]);
121
+ if (normalized && (accessors[mod.catalogKey] ?? []).some((acc) => isReferenced(ownScripts, acc))) {
122
+ found[mod.id].add(normalized);
98
123
  }
99
124
  }
100
125
  }
@@ -106,37 +131,6 @@ export async function collectAppVersionsFromProject(projectRoot) {
106
131
  };
107
132
  }
108
133
 
109
- /**
110
- * Net change in parenthesis depth outside of string literals.
111
- * @param {string} line
112
- * @returns {number}
113
- */
114
- function parenDelta(line) {
115
- let depth = 0;
116
- let inString = false;
117
- let quote = '';
118
- for (let i = 0; i < line.length; i++) {
119
- const c = line[i];
120
- if (inString) {
121
- if (c === quote && line[i - 1] !== '\\') {
122
- inString = false;
123
- }
124
- continue;
125
- }
126
- if (c === '"' || c === "'") {
127
- inString = true;
128
- quote = c;
129
- continue;
130
- }
131
- if (c === '(') {
132
- depth++;
133
- } else if (c === ')') {
134
- depth--;
135
- }
136
- }
137
- return depth;
138
- }
139
-
140
134
  /**
141
135
  * @param {string} text
142
136
  * @param {import('./types.mjs').TrackedModule[]} modules
@@ -144,14 +138,10 @@ function parenDelta(line) {
144
138
  */
145
139
  function collectVersionsFromGradleText(text, modules, found) {
146
140
  for (const mod of modules) {
147
- const corpus = mod.testOnly ? extractMainAppDependencyScopes(text) : text;
148
- if (mod.testOnly && !corpus.trim()) {
149
- continue;
150
- }
151
141
  for (const pattern of mod.patterns) {
152
142
  pattern.lastIndex = 0;
153
143
  let match;
154
- while ((match = pattern.exec(corpus)) !== null) {
144
+ while ((match = pattern.exec(text)) !== null) {
155
145
  const version = versionFromPatternMatch(match);
156
146
  if (version) {
157
147
  found[mod.id].add(version);
@@ -7,7 +7,7 @@ export {
7
7
  versionFromPatternMatch,
8
8
  versionSetsToSortedRecords,
9
9
  } from './version-utils.mjs';
10
- export {collectAppVersionsFromProject, extractMainAppDependencyScopes, findGradleFiles} from './gradle-scan.mjs';
10
+ export {collectAppVersionsFromProject, findGradleFiles, usesCompose} from './gradle-scan.mjs';
11
11
  export {collectAppVersionsFromApk} from './apk-scan.mjs';
12
12
  export {mapMetaInfVersionBaseToModule, mergeMetaInfEmbeddedVersions} from './apk-meta-inf.mjs';
13
13
  export {mergeKotlinMetadataVersionsFromDex, parseKotlinMetadataVersionsFromDexdump} from './apk-kotlin-metadata.mjs';
@@ -34,8 +34,9 @@ export function formatReport(report, opts = {}) {
34
34
  }
35
35
  const lines = [];
36
36
  if (!opts.compact) {
37
- lines.push('Espresso dependency compatibility report');
38
- lines.push('======================================');
37
+ const title = 'Espresso server compatibility report';
38
+ lines.push(title);
39
+ lines.push('='.repeat(title.length));
39
40
  lines.push('');
40
41
  }
41
42
  lines.push(report.summary);
@@ -63,8 +64,7 @@ export function formatReport(report, opts = {}) {
63
64
  lines.push(`${mod.label} (${mod.id})`);
64
65
  lines.push(` Server: ${mod.serverVersion ?? 'n/a'}`);
65
66
  if (mod.appVersions.length) {
66
- const suffix = mod.testOnly ? '' : ` (using ${mod.appVersion} for comparison)`;
67
- lines.push(` App: ${mod.appVersions.join(', ')}${suffix}`);
67
+ lines.push(` App: ${mod.appVersions.join(', ')} (using ${mod.appVersion} for comparison)`);
68
68
  } else {
69
69
  lines.push(' App: not detected');
70
70
  }
@@ -11,53 +11,13 @@ export const TRACKED_MODULES = [
11
11
  /compose-ui-test[^:]*:([\d.]+)/gi,
12
12
  /compose\.ui:ui-test[^:]*:([\d.]+)/gi,
13
13
  /["']androidx\.compose\.ui:ui-test(?:-junit4)?["'][^:]*:([\d.]+)/gi,
14
- /composeBom\s*=\s*["']([^"']+)["']/gi,
15
- /compose-bom:([\d.]+)/gi,
16
- /androidx\.compose:compose-bom:([\d.]+)/gi,
17
14
  ],
18
15
  },
19
16
  {
20
- id: 'espresso',
21
- label: 'Espresso',
22
- testOnly: true,
23
- toolsVersionKey: 'espressoVersion',
24
- catalogKey: 'espresso',
25
- gradleProperty: 'appiumEspressoVersion',
26
- patterns: [
27
- /\bespresso\s*=\s*["']([^"']+)["']/gi,
28
- /androidx\.test\.espresso:espresso-[\w-]+:([\d.]+)/gi,
29
- /espresso-core:([\d.]+)/gi,
30
- ],
31
- },
32
- {
33
- id: 'annotation',
34
- label: 'AndroidX Annotation',
35
- toolsVersionKey: 'annotationVersion',
36
- catalogKey: 'annotation',
37
- gradleProperty: 'appiumAnnotationVersion',
38
- patterns: [/\bannotation\s*=\s*["']([^"']+)["']/gi, /androidx\.annotation:annotation:([\d.]+)/gi],
39
- },
40
- {
41
- id: 'androidxTest',
42
- label: 'AndroidX Test',
43
- testOnly: true,
44
- toolsVersionKey: null,
45
- catalogKey: 'androidxTest',
46
- gradleProperty: 'appiumAndroidxTestVersion',
47
- patterns: [/androidxTest\s*=\s*["']([^"']+)["']/gi, /androidx\.test:(?:core|runner|rules|ext):[\w-]*:([\d.]+)/gi],
48
- },
49
- {
50
- id: 'uiautomator',
51
- label: 'UiAutomator',
52
- testOnly: true,
53
- toolsVersionKey: null,
54
- catalogKey: 'uiautomator',
55
- gradleProperty: 'appiumUiAutomatorVersion',
56
- patterns: [/\buiautomator\s*=\s*["']([^"']+)["']/gi, /androidx\.test\.uiautomator:uiautomator:([\d.]+)/gi],
57
- },
58
- {
17
+ // Kotlin stays shared with the app together with Compose, so its version matters only for Compose apps
59
18
  id: 'kotlin',
60
19
  label: 'Kotlin',
20
+ onlyWithCompose: true,
61
21
  toolsVersionKey: 'kotlin',
62
22
  catalogKey: 'kotlin',
63
23
  gradleProperty: 'appiumKotlin',
@@ -15,7 +15,7 @@
15
15
  * @property {string | null} toolsVersionKey
16
16
  * @property {string} catalogKey
17
17
  * @property {string} gradleProperty
18
- * @property {boolean} [testOnly] When true, only warn if detected in the AUT (no version comparison).
18
+ * @property {boolean} [onlyWithCompose] When true, the module is compared only if the app uses Compose.
19
19
  * @property {RegExp[]} patterns
20
20
  */
21
21
 
@@ -33,6 +33,7 @@
33
33
  * @typedef {Object} ComparisonReport
34
34
  * @property {boolean} proguardLikely
35
35
  * @property {boolean | null} minifyEnabled
36
+ * @property {boolean} composeDetected
36
37
  * @property {ModuleComparison[]} modules
37
38
  * @property {string} summary
38
39
  */
@@ -21,11 +21,11 @@ export function parseVersionsToml(text) {
21
21
  let inVersionsSection = false;
22
22
  for (const line of text.split(/\r?\n/)) {
23
23
  const trimmed = line.trim();
24
- if (trimmed === '[versions]') {
24
+ if (/^\[versions\]\s*(#.*)?$/.test(trimmed)) {
25
25
  inVersionsSection = true;
26
26
  continue;
27
27
  }
28
- if (trimmed.startsWith('[') && trimmed !== '[versions]') {
28
+ if (trimmed.startsWith('[')) {
29
29
  inVersionsSection = false;
30
30
  continue;
31
31
  }
@@ -40,6 +40,128 @@ export function parseVersionsToml(text) {
40
40
  return versions;
41
41
  }
42
42
 
43
+ /**
44
+ * Maps each `[versions]` key of a version catalog to the accessors (`libs.x.y`) through which
45
+ * the catalog exposes it: the version itself and the libraries/plugins that reference it.
46
+ * @param {string} text
47
+ * @returns {Record<string, string[]>}
48
+ */
49
+ export function parseCatalogAccessors(text) {
50
+ const prefixes = {versions: 'libs.versions', libraries: 'libs', plugins: 'libs.plugins', bundles: 'libs.bundles'};
51
+ const dotted = (/** @type {string} */ name) => name.replace(/[-_]/g, '.');
52
+ /** Drops the trailing comment and counts the open brackets, both outside of strings. */
53
+ const scanLine = (/** @type {string} */ line) => {
54
+ let quote = '';
55
+ let delta = 0;
56
+ for (let i = 0; i < line.length; i++) {
57
+ const ch = line[i];
58
+ if (quote) {
59
+ if (ch === '\\' && quote === '"') {
60
+ i++;
61
+ } else if (ch === quote) {
62
+ quote = '';
63
+ }
64
+ } else if (ch === '"' || ch === "'") {
65
+ quote = ch;
66
+ } else if (ch === '#') {
67
+ return {code: line.slice(0, i), delta};
68
+ } else if (ch === '{' || ch === '[') {
69
+ delta++;
70
+ } else if (ch === '}' || ch === ']') {
71
+ delta--;
72
+ }
73
+ }
74
+ return {code: line, delta};
75
+ };
76
+ /** @typedef {{section: string, alias: string, body: string}} CatalogEntry */
77
+ /** @type {CatalogEntry[]} */
78
+ const entries = [];
79
+ /** @type {CatalogEntry | null} */
80
+ let current = null;
81
+ let section = '';
82
+ let depth = 0;
83
+
84
+ const finish = () => {
85
+ if (current) {
86
+ entries.push(current);
87
+ current = null;
88
+ }
89
+ depth = 0;
90
+ };
91
+
92
+ for (const rawLine of text.split(/\r?\n/)) {
93
+ const {code, delta: lineDelta} = scanLine(rawLine);
94
+ const trimmed = code.trim();
95
+ if (!trimmed) {
96
+ continue;
97
+ }
98
+ if (depth > 0 && current) {
99
+ // continuation of a multiline inline table or array
100
+ current.body += ` ${trimmed}`;
101
+ depth += lineDelta;
102
+ if (depth <= 0) {
103
+ finish();
104
+ }
105
+ continue;
106
+ }
107
+ // `[libraries.alias]` tables carry the entry's keys on the following lines
108
+ const header = trimmed.match(/^\[(\w+)(?:\.([\w.-]+))?\]$/);
109
+ if (header) {
110
+ finish();
111
+ section = header[1];
112
+ current = header[2] ? {section, alias: header[2], body: ''} : null;
113
+ continue;
114
+ }
115
+ const kv = trimmed.match(/^([A-Za-z0-9_.-]+)\s*=\s*(.*)$/);
116
+ if (!kv) {
117
+ continue;
118
+ }
119
+ if (current) {
120
+ current.body += ` ${trimmed}`;
121
+ continue;
122
+ }
123
+ current = {section, alias: kv[1], body: kv[2]};
124
+ depth = scanLine(kv[2]).delta;
125
+ if (depth <= 0) {
126
+ finish();
127
+ }
128
+ }
129
+ finish();
130
+
131
+ const versionRef = (/** @type {CatalogEntry} */ entry) =>
132
+ entry.body.match(/version\.ref\s*=\s*["']([^"']+)["']/)?.[1];
133
+ /** @type {Record<string, string[]>} */
134
+ const accessors = {};
135
+ /** @type {Record<string, string>} */
136
+ const libraryRefs = {};
137
+ const add = (/** @type {string | undefined} */ key, /** @type {CatalogEntry} */ entry) => {
138
+ if (key) {
139
+ (accessors[key] ??= []).push(
140
+ `${prefixes[/** @type {keyof typeof prefixes} */ (entry.section)]}.${dotted(entry.alias)}`,
141
+ );
142
+ }
143
+ };
144
+ for (const entry of entries) {
145
+ if (entry.section === 'versions') {
146
+ add(entry.alias, entry);
147
+ } else if (entry.section === 'libraries' || entry.section === 'plugins') {
148
+ const ref = versionRef(entry);
149
+ add(ref, entry);
150
+ if (ref && entry.section === 'libraries') {
151
+ libraryRefs[entry.alias] = ref;
152
+ }
153
+ }
154
+ }
155
+ // a bundle exposes the versions of its member libraries
156
+ for (const entry of entries.filter((e) => e.section === 'bundles')) {
157
+ const members = [...entry.body.matchAll(/["']([^"']+)["']/g)].map((m) => m[1]);
158
+ for (const key of new Set(members.map((alias) => libraryRefs[alias]))) {
159
+ add(key, entry);
160
+ }
161
+ }
162
+ return accessors;
163
+ }
164
+
43
165
  /**
44
166
  * @param {string | undefined} raw
45
167
  * @returns {string | null}
@@ -38,7 +38,10 @@ export async function loadEspressoServerDefaults(espressoServerRoot, driverRoot)
38
38
  */
39
39
  export async function collectAppInputFromProject(projectRoot) {
40
40
  const {versions, minifyEnabled, sources} = await collectAppVersionsFromProject(projectRoot);
41
- const gradleFiles = sources.map((rel) => path.join(projectRoot, rel));
41
+ // Version catalogs only declare libraries; usage is judged from the build scripts
42
+ const gradleFiles = sources
43
+ .filter((rel) => !rel.endsWith('libs.versions.toml'))
44
+ .map((rel) => path.join(projectRoot, rel));
42
45
  const gradleCorpus = (await Promise.all(gradleFiles.map((f) => fs.readFile(f, 'utf8').catch(() => '')))).join('\n');
43
46
  const manifestTexts = await findManifestTexts(projectRoot);
44
47
 
@@ -14,7 +14,11 @@ export function checkCompileSdk(appInput, serverDefaults, dependencyReport) {
14
14
  }
15
15
  const appCompileSdk = parseCompileSdkFromCorpus(appInput.gradleCorpus ?? '');
16
16
  const serverCompileSdk = serverDefaults.compileSdk ? parseInt(serverDefaults.compileSdk, 10) : null;
17
- const composeVersion = dependencyReport.modules.find((m) => m.id === 'compose')?.appVersion;
17
+ const compose = dependencyReport.modules.find((m) => m.id === 'compose');
18
+ // An unresolved version (e.g. from a BOM) means the server's Compose, built with the server's compileSdk
19
+ const resolved = Boolean(compose?.appVersion);
20
+ const composeVersion = compose?.appVersion ?? (dependencyReport.composeDetected ? compose?.serverVersion : null);
21
+ const checkedCompileSdk = resolved ? appCompileSdk : serverCompileSdk;
18
22
  const composeMinor = composeVersion ? semver.coerce(composeVersion)?.minor : null;
19
23
  const minComposeCompileSdk = composeMinor != null && composeMinor >= 11 ? 35 : null;
20
24
 
@@ -38,7 +42,7 @@ export function checkCompileSdk(appInput, serverDefaults, dependencyReport) {
38
42
  });
39
43
  }
40
44
 
41
- if (minComposeCompileSdk && appCompileSdk && appCompileSdk < minComposeCompileSdk) {
45
+ if (minComposeCompileSdk && checkedCompileSdk && checkedCompileSdk < minComposeCompileSdk) {
42
46
  checks.push({
43
47
  id: 'compose-compile-sdk',
44
48
  title: 'Compose compileSdk requirement',
@@ -22,7 +22,7 @@ export function mapDependencyChecks(dependencyReport, appInput) {
22
22
 
23
23
  return /** @type {import('../types.mjs').DiagnosticCheck} */ ({
24
24
  id: `dependency-${mod.id}`,
25
- title: mod.testOnly ? `${mod.label} in app` : `${mod.label} version`,
25
+ title: `${mod.label} version`,
26
26
  status,
27
27
  message: mod.recommendation.message,
28
28
  espressoBuildConfig: mod.recommendation.espressoBuildConfig,
@@ -1,8 +1,5 @@
1
1
  export {checkPrecompileInputKind} from './input-kind.mjs';
2
2
  export {checkInternetPermission} from './internet-permission.mjs';
3
3
  export {checkObfuscation} from './obfuscation.mjs';
4
- export {checkAndroidX} from './androidx.mjs';
5
- export {checkInitializationProvider} from './startup-provider.mjs';
6
4
  export {checkCompileSdk} from './compile-sdk.mjs';
7
- export {checkLifecycleExtensionsPin} from './lifecycle-extensions.mjs';
8
5
  export {mapDependencyChecks} from './dependency.mjs';
@@ -26,7 +26,7 @@ export function checkObfuscation(appInput, serverDefaults) {
26
26
  title: 'Code shrinking (R8/ProGuard)',
27
27
  status: 'fail',
28
28
  message:
29
- 'APK appears obfuscated/minified. Dependency alignment cannot be verified from the APK; use an unobfuscated debug APK if possible. See slackhq/keeper for shrinker rules when testing against release builds.',
29
+ 'APK appears obfuscated/minified. The Compose version cannot be verified from the APK; use an unobfuscated debug APK if possible. See slackhq/keeper for shrinker rules when testing against release builds.',
30
30
  docRef: 'docs/as-library.md',
31
31
  });
32
32
  results.push({