appium-xcuitest-driver 10.10.1 → 10.11.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 +6 -0
- package/build/lib/app-infos-cache.d.ts +29 -31
- package/build/lib/app-infos-cache.d.ts.map +1 -1
- package/build/lib/app-infos-cache.js +29 -33
- package/build/lib/app-infos-cache.js.map +1 -1
- package/build/lib/app-utils.d.ts +30 -59
- package/build/lib/app-utils.d.ts.map +1 -1
- package/build/lib/app-utils.js +158 -211
- package/build/lib/app-utils.js.map +1 -1
- package/build/lib/commands/battery.d.ts.map +1 -1
- package/build/lib/commands/battery.js +4 -8
- package/build/lib/commands/battery.js.map +1 -1
- package/build/lib/commands/biometric.d.ts.map +1 -1
- package/build/lib/commands/biometric.js +1 -5
- package/build/lib/commands/biometric.js.map +1 -1
- package/build/lib/commands/condition.js +4 -4
- package/build/lib/commands/condition.js.map +1 -1
- package/build/lib/commands/content-size.js +1 -1
- package/build/lib/commands/content-size.js.map +1 -1
- package/build/lib/commands/find.js +2 -2
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/increase-contrast.js +1 -1
- package/build/lib/commands/increase-contrast.js.map +1 -1
- package/build/lib/commands/keychains.d.ts.map +1 -1
- package/build/lib/commands/keychains.js +1 -5
- package/build/lib/commands/keychains.js.map +1 -1
- package/build/lib/commands/localization.d.ts.map +1 -1
- package/build/lib/commands/localization.js +1 -5
- package/build/lib/commands/localization.js.map +1 -1
- package/build/lib/commands/pasteboard.d.ts.map +1 -1
- package/build/lib/commands/pasteboard.js +10 -8
- package/build/lib/commands/pasteboard.js.map +1 -1
- package/build/lib/commands/permissions.js +1 -1
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/css-converter.d.ts +3 -9
- package/build/lib/css-converter.d.ts.map +1 -1
- package/build/lib/css-converter.js +41 -52
- package/build/lib/css-converter.js.map +1 -1
- package/build/lib/device/real-device-management.js +14 -14
- package/build/lib/device/real-device-management.js.map +1 -1
- package/build/lib/device/simulator-management.d.ts.map +1 -1
- package/build/lib/device/simulator-management.js +8 -4
- package/build/lib/device/simulator-management.js.map +1 -1
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +3 -3
- package/build/lib/driver.js.map +1 -1
- package/build/lib/logger.d.ts +1 -2
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +2 -2
- package/build/lib/logger.js.map +1 -1
- package/build/lib/utils.d.ts +76 -134
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +80 -141
- package/build/lib/utils.js.map +1 -1
- package/lib/{app-infos-cache.js → app-infos-cache.ts} +44 -46
- package/lib/{app-utils.js → app-utils.ts} +215 -245
- package/lib/commands/battery.js +3 -4
- package/lib/commands/biometric.js +1 -2
- package/lib/commands/condition.js +1 -1
- package/lib/commands/content-size.js +1 -1
- package/lib/commands/find.js +1 -1
- package/lib/commands/increase-contrast.js +1 -1
- package/lib/commands/keychains.js +1 -2
- package/lib/commands/localization.js +1 -2
- package/lib/commands/pasteboard.js +9 -8
- package/lib/commands/permissions.js +1 -1
- package/lib/{css-converter.js → css-converter.ts} +75 -88
- package/lib/device/real-device-management.ts +1 -1
- package/lib/device/simulator-management.ts +9 -4
- package/lib/driver.ts +6 -4
- package/lib/logger.ts +3 -0
- package/lib/{utils.js → utils.ts} +102 -139
- package/npm-shrinkwrap.json +26 -30
- package/package.json +2 -2
- package/lib/logger.js +0 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import path from 'path';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
import {plist, fs, tempDir, zip} from 'appium/support';
|
|
4
4
|
import {LRUCache} from 'lru-cache';
|
|
5
5
|
import B from 'bluebird';
|
|
6
|
+
import type {AppiumLogger, StringRecord} from '@appium/types';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
const MANIFEST_CACHE = new LRUCache({
|
|
8
|
+
const MANIFEST_CACHE = new LRUCache<string, StringRecord>({
|
|
9
9
|
max: 40,
|
|
10
10
|
updateAgeOnHas: true,
|
|
11
11
|
});
|
|
@@ -16,20 +16,19 @@ const IPA_ROOT_PLIST_PATH_PATTERN = new RegExp(
|
|
|
16
16
|
const MAX_MANIFEST_SIZE = 1024 * 1024; // 1 MiB
|
|
17
17
|
|
|
18
18
|
export class AppInfosCache {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
constructor (log) {
|
|
19
|
+
private readonly log: AppiumLogger;
|
|
20
|
+
|
|
21
|
+
constructor(log: AppiumLogger) {
|
|
23
22
|
this.log = log;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
*
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @returns
|
|
27
|
+
* @param bundlePath Full path to the .ipa or .app bundle
|
|
28
|
+
* @param propertyName
|
|
29
|
+
* @returns
|
|
31
30
|
*/
|
|
32
|
-
async extractManifestProperty
|
|
31
|
+
async extractManifestProperty(bundlePath: string, propertyName: string): Promise<any> {
|
|
33
32
|
const result = (await this.put(bundlePath))[propertyName];
|
|
34
33
|
this.log.debug(`${propertyName}: ${JSON.stringify(result)}`);
|
|
35
34
|
return result;
|
|
@@ -37,28 +36,28 @@ export class AppInfosCache {
|
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @returns
|
|
39
|
+
* @param bundlePath Full path to the .ipa or .app bundle
|
|
40
|
+
* @returns
|
|
42
41
|
*/
|
|
43
|
-
async extractBundleId
|
|
42
|
+
async extractBundleId(bundlePath: string): Promise<string> {
|
|
44
43
|
return await this.extractManifestProperty(bundlePath, 'CFBundleIdentifier');
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
/**
|
|
48
47
|
*
|
|
49
|
-
* @param
|
|
50
|
-
* @returns
|
|
48
|
+
* @param bundlePath Full path to the .ipa or .app bundle
|
|
49
|
+
* @returns
|
|
51
50
|
*/
|
|
52
|
-
async extractBundleVersion
|
|
51
|
+
async extractBundleVersion(bundlePath: string): Promise<string> {
|
|
53
52
|
return await this.extractManifestProperty(bundlePath, 'CFBundleVersion');
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
/**
|
|
57
56
|
*
|
|
58
|
-
* @param
|
|
59
|
-
* @returns
|
|
57
|
+
* @param bundlePath Full path to the .ipa or .app bundle
|
|
58
|
+
* @returns
|
|
60
59
|
*/
|
|
61
|
-
async extractAppPlatforms
|
|
60
|
+
async extractAppPlatforms(bundlePath: string): Promise<string[]> {
|
|
62
61
|
const result = await this.extractManifestProperty(bundlePath, 'CFBundleSupportedPlatforms');
|
|
63
62
|
if (!Array.isArray(result)) {
|
|
64
63
|
throw new Error(`${path.basename(bundlePath)}': CFBundleSupportedPlatforms is not a valid list`);
|
|
@@ -68,34 +67,32 @@ export class AppInfosCache {
|
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
69
|
*
|
|
71
|
-
* @param
|
|
72
|
-
* @returns
|
|
70
|
+
* @param bundlePath Full path to the .ipa or .app bundle
|
|
71
|
+
* @returns
|
|
73
72
|
*/
|
|
74
|
-
async extractExecutableName
|
|
73
|
+
async extractExecutableName(bundlePath: string): Promise<string> {
|
|
75
74
|
return await this.extractManifestProperty(bundlePath, 'CFBundleExecutable');
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
/**
|
|
79
78
|
*
|
|
80
|
-
* @param
|
|
81
|
-
* @returns
|
|
82
|
-
* @throws
|
|
79
|
+
* @param bundlePath Full path to the .ipa or .app bundle
|
|
80
|
+
* @returns The payload of the manifest plist
|
|
81
|
+
* @throws If the given app is not a valid bundle
|
|
83
82
|
*/
|
|
84
|
-
async put
|
|
83
|
+
async put(bundlePath: string): Promise<StringRecord> {
|
|
85
84
|
return (await fs.stat(bundlePath)).isFile()
|
|
86
85
|
? await this._putIpa(bundlePath)
|
|
87
86
|
: await this._putApp(bundlePath);
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
/**
|
|
91
|
-
* @param
|
|
92
|
-
* @returns
|
|
90
|
+
* @param ipaPath Fill path to the .ipa bundle
|
|
91
|
+
* @returns The payload of the manifest plist
|
|
93
92
|
*/
|
|
94
|
-
async _putIpa(ipaPath) {
|
|
95
|
-
|
|
96
|
-
let
|
|
97
|
-
/** @type {Error|undefined} */
|
|
98
|
-
let lastError;
|
|
93
|
+
private async _putIpa(ipaPath: string): Promise<StringRecord> {
|
|
94
|
+
let manifestPayload: StringRecord | undefined;
|
|
95
|
+
let lastError: Error | undefined;
|
|
99
96
|
try {
|
|
100
97
|
await zip.readEntries(ipaPath, async ({entry, extractEntryTo}) => {
|
|
101
98
|
// For a future reference:
|
|
@@ -126,7 +123,7 @@ export class AppInfosCache {
|
|
|
126
123
|
);
|
|
127
124
|
MANIFEST_CACHE.set(hash, manifestPayload);
|
|
128
125
|
}
|
|
129
|
-
} catch (e) {
|
|
126
|
+
} catch (e: any) {
|
|
130
127
|
this.log.debug(e.stack);
|
|
131
128
|
lastError = e;
|
|
132
129
|
} finally {
|
|
@@ -134,7 +131,7 @@ export class AppInfosCache {
|
|
|
134
131
|
}
|
|
135
132
|
return false;
|
|
136
133
|
});
|
|
137
|
-
} catch (e) {
|
|
134
|
+
} catch (e: any) {
|
|
138
135
|
this.log.debug(e.stack);
|
|
139
136
|
throw new Error(`Cannot find ${MANIFEST_FILE_NAME} in '${ipaPath}'. Is it a valid application bundle?`);
|
|
140
137
|
}
|
|
@@ -149,14 +146,15 @@ export class AppInfosCache {
|
|
|
149
146
|
}
|
|
150
147
|
|
|
151
148
|
/**
|
|
152
|
-
* @param
|
|
153
|
-
* @returns
|
|
149
|
+
* @param appPath Fill path to the .app bundle
|
|
150
|
+
* @returns The payload of the manifest plist
|
|
154
151
|
*/
|
|
155
|
-
async _putApp(appPath) {
|
|
152
|
+
private async _putApp(appPath: string): Promise<StringRecord> {
|
|
156
153
|
const manifestPath = path.join(appPath, MANIFEST_FILE_NAME);
|
|
157
154
|
const hash = await fs.hash(manifestPath);
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
const cached = MANIFEST_CACHE.get(hash);
|
|
156
|
+
if (cached) {
|
|
157
|
+
return cached;
|
|
160
158
|
}
|
|
161
159
|
const [payload, stat] = await B.all([
|
|
162
160
|
this._readPlist(manifestPath, appPath),
|
|
@@ -172,14 +170,14 @@ export class AppInfosCache {
|
|
|
172
170
|
}
|
|
173
171
|
|
|
174
172
|
/**
|
|
175
|
-
* @param
|
|
176
|
-
* @param
|
|
177
|
-
* @returns
|
|
173
|
+
* @param plistPath Full path to the plist
|
|
174
|
+
* @param bundlePath Full path to .ipa or .app bundle
|
|
175
|
+
* @returns The payload of the plist file
|
|
178
176
|
*/
|
|
179
|
-
async _readPlist(plistPath, bundlePath) {
|
|
177
|
+
private async _readPlist(plistPath: string, bundlePath: string): Promise<any> {
|
|
180
178
|
try {
|
|
181
179
|
return await plist.parsePlistFile(plistPath);
|
|
182
|
-
} catch (e) {
|
|
180
|
+
} catch (e: any) {
|
|
183
181
|
this.log.debug(e.stack);
|
|
184
182
|
throw new Error(`Cannot parse ${MANIFEST_FILE_NAME} of '${bundlePath}'. Is it a valid application bundle?`);
|
|
185
183
|
}
|