appium-ios-simulator 8.0.11 → 8.0.13

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 (68) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/defaults-utils.d.ts +1 -0
  3. package/build/lib/defaults-utils.d.ts.map +1 -1
  4. package/build/lib/defaults-utils.js +15 -7
  5. package/build/lib/defaults-utils.js.map +1 -1
  6. package/build/lib/extensions/applications.d.ts.map +1 -1
  7. package/build/lib/extensions/applications.js +2 -2
  8. package/build/lib/extensions/applications.js.map +1 -1
  9. package/build/lib/extensions/biometric.d.ts.map +1 -1
  10. package/build/lib/extensions/biometric.js +9 -13
  11. package/build/lib/extensions/biometric.js.map +1 -1
  12. package/build/lib/extensions/geolocation.d.ts.map +1 -1
  13. package/build/lib/extensions/geolocation.js.map +1 -1
  14. package/build/lib/extensions/keychain.d.ts.map +1 -1
  15. package/build/lib/extensions/keychain.js +14 -11
  16. package/build/lib/extensions/keychain.js.map +1 -1
  17. package/build/lib/extensions/misc.d.ts.map +1 -1
  18. package/build/lib/extensions/misc.js +2 -5
  19. package/build/lib/extensions/misc.js.map +1 -1
  20. package/build/lib/extensions/permissions.d.ts.map +1 -1
  21. package/build/lib/extensions/permissions.js +19 -11
  22. package/build/lib/extensions/permissions.js.map +1 -1
  23. package/build/lib/extensions/safari.d.ts.map +1 -1
  24. package/build/lib/extensions/safari.js +1 -1
  25. package/build/lib/extensions/safari.js.map +1 -1
  26. package/build/lib/extensions/settings.d.ts +2 -2
  27. package/build/lib/extensions/settings.d.ts.map +1 -1
  28. package/build/lib/extensions/settings.js +31 -30
  29. package/build/lib/extensions/settings.js.map +1 -1
  30. package/build/lib/index.d.ts +5 -0
  31. package/build/lib/index.d.ts.map +1 -0
  32. package/build/{index.js → lib/index.js} +2 -3
  33. package/build/lib/index.js.map +1 -0
  34. package/build/lib/logger.js.map +1 -1
  35. package/build/lib/simulator-xcode-14.d.ts.map +1 -1
  36. package/build/lib/simulator-xcode-14.js +7 -8
  37. package/build/lib/simulator-xcode-14.js.map +1 -1
  38. package/build/lib/simulator-xcode-15.d.ts.map +1 -1
  39. package/build/lib/simulator-xcode-15.js +4 -2
  40. package/build/lib/simulator-xcode-15.js.map +1 -1
  41. package/build/lib/simulator.d.ts.map +1 -1
  42. package/build/lib/simulator.js +3 -3
  43. package/build/lib/simulator.js.map +1 -1
  44. package/build/lib/types.d.ts.map +1 -1
  45. package/build/lib/utils.d.ts.map +1 -1
  46. package/build/lib/utils.js +3 -3
  47. package/build/lib/utils.js.map +1 -1
  48. package/lib/defaults-utils.ts +32 -15
  49. package/lib/extensions/applications.ts +30 -24
  50. package/lib/extensions/biometric.ts +27 -21
  51. package/lib/extensions/geolocation.ts +6 -3
  52. package/lib/extensions/keychain.ts +22 -18
  53. package/lib/extensions/misc.ts +9 -12
  54. package/lib/extensions/permissions.ts +93 -52
  55. package/lib/extensions/safari.ts +61 -32
  56. package/lib/extensions/settings.ts +153 -81
  57. package/lib/index.ts +6 -0
  58. package/lib/logger.ts +1 -1
  59. package/lib/simulator-xcode-14.ts +65 -45
  60. package/lib/simulator-xcode-15.ts +7 -6
  61. package/lib/simulator.ts +13 -17
  62. package/lib/types.ts +14 -14
  63. package/lib/utils.ts +25 -18
  64. package/package.json +6 -6
  65. package/build/index.d.ts +0 -5
  66. package/build/index.d.ts.map +0 -1
  67. package/build/index.js.map +0 -1
  68. package/index.ts +0 -8
@@ -1,8 +1,8 @@
1
1
  import _ from 'lodash';
2
- import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
3
- import { exec } from 'teen_process';
2
+ import {DOMParser, XMLSerializer, type Document, type Element} from '@xmldom/xmldom';
3
+ import {exec} from 'teen_process';
4
4
  import B from 'bluebird';
5
- import { log } from './logger';
5
+ import {log} from './logger';
6
6
 
7
7
  /**
8
8
  * Serializes the given value to plist-compatible
@@ -21,19 +21,21 @@ export function toXmlArg(value: any, serialize: boolean = true): string | Elemen
21
21
 
22
22
  if (_.isPlainObject(value)) {
23
23
  xmlDoc = new DOMParser().parseFromString('<dict></dict>', 'text/xml');
24
+ const documentElement = requireDocumentElement(xmlDoc);
24
25
  for (const [subKey, subValue] of _.toPairs(value)) {
25
26
  const keyEl = xmlDoc.createElement('key');
26
27
  const keyTextEl = xmlDoc.createTextNode(subKey);
27
28
  keyEl.appendChild(keyTextEl);
28
- xmlDoc.documentElement.appendChild(keyEl);
29
+ documentElement.appendChild(keyEl);
29
30
  const subValueEl = xmlDoc.importNode(toXmlArg(subValue, false) as Element, true);
30
- xmlDoc.documentElement.appendChild(subValueEl);
31
+ documentElement.appendChild(subValueEl);
31
32
  }
32
33
  } else if (_.isArray(value)) {
33
34
  xmlDoc = new DOMParser().parseFromString('<array></array>', 'text/xml');
35
+ const documentElement = requireDocumentElement(xmlDoc);
34
36
  for (const subValue of value) {
35
37
  const subValueEl = xmlDoc.importNode(toXmlArg(subValue, false) as Element, true);
36
- xmlDoc.documentElement.appendChild(subValueEl);
38
+ documentElement.appendChild(subValueEl);
37
39
  }
38
40
  } else if (_.isBoolean(value)) {
39
41
  xmlDoc = new DOMParser().parseFromString(value ? '<true/>' : '<false/>', 'text/xml');
@@ -44,17 +46,18 @@ export function toXmlArg(value: any, serialize: boolean = true): string | Elemen
44
46
  } else if (_.isString(value)) {
45
47
  xmlDoc = new DOMParser().parseFromString(`<string></string>`, 'text/xml');
46
48
  const valueTextEl = xmlDoc.createTextNode(value);
47
- xmlDoc.documentElement.appendChild(valueTextEl);
49
+ requireDocumentElement(xmlDoc).appendChild(valueTextEl);
48
50
  }
49
51
 
50
52
  if (!xmlDoc) {
51
- throw new TypeError(`The defaults value ${JSON.stringify(value)} cannot be written, ` +
52
- `because it is not known how to handle its type`);
53
+ throw new TypeError(
54
+ `The defaults value ${JSON.stringify(value)} cannot be written, ` +
55
+ `because it is not known how to handle its type`,
56
+ );
53
57
  }
54
58
 
55
- return serialize
56
- ? new XMLSerializer().serializeToString(xmlDoc.documentElement)
57
- : xmlDoc.documentElement;
59
+ const documentElement = requireDocumentElement(xmlDoc);
60
+ return serialize ? new XMLSerializer().serializeToString(documentElement) : documentElement;
58
61
  }
59
62
 
60
63
  /**
@@ -70,7 +73,10 @@ export function toXmlArg(value: any, serialize: boolean = true): string | Elemen
70
73
  * @returns Each item in the array
71
74
  * is the `defaults write <plist>` command suffix
72
75
  */
73
- export function generateDefaultsCommandArgs(valuesMap: Record<string, any>, replace: boolean = false): string[][] {
76
+ export function generateDefaultsCommandArgs(
77
+ valuesMap: Record<string, any>,
78
+ replace: boolean = false,
79
+ ): string[][] {
74
80
  const resultArgs: string[][] = [];
75
81
  for (const [key, value] of _.toPairs(valuesMap)) {
76
82
  try {
@@ -119,7 +125,9 @@ export class NSUserDefaults {
119
125
  const {stdout} = await exec('plutil', ['-convert', 'json', '-o', '-', this.plist]);
120
126
  return JSON.parse(stdout);
121
127
  } catch (e: any) {
122
- throw new Error(`'${this.plist}' cannot be converted to JSON. Original error: ${e.stderr || e.message}`);
128
+ throw new Error(
129
+ `'${this.plist}' cannot be converted to JSON. Original error: ${e.stderr || e.message}`,
130
+ );
123
131
  }
124
132
  }
125
133
 
@@ -146,8 +154,17 @@ export class NSUserDefaults {
146
154
  try {
147
155
  await B.all(commandArgs.map((args) => exec('defaults', ['write', this.plist, ...args])));
148
156
  } catch (e: any) {
149
- throw new Error(`Could not write defaults into '${this.plist}'. Original error: ${e.stderr || e.message}`);
157
+ throw new Error(
158
+ `Could not write defaults into '${this.plist}'. Original error: ${e.stderr || e.message}`,
159
+ );
150
160
  }
151
161
  }
152
162
  }
153
163
 
164
+ function requireDocumentElement(xmlDoc: Document): Element {
165
+ const {documentElement} = xmlDoc;
166
+ if (!documentElement) {
167
+ throw new Error('Cannot parse XML document element');
168
+ }
169
+ return documentElement;
170
+ }
@@ -1,9 +1,9 @@
1
1
  import _ from 'lodash';
2
2
  import path from 'node:path';
3
- import { fs, plist, util } from '@appium/support';
3
+ import {fs, plist, util} from '@appium/support';
4
4
  import B from 'bluebird';
5
- import { waitForCondition } from 'asyncbox';
6
- import type { CoreSimulator, InteractsWithApps, LaunchAppOptions } from '../types';
5
+ import {waitForCondition} from 'asyncbox';
6
+ import type {CoreSimulator, InteractsWithApps, LaunchAppOptions} from '../types';
7
7
 
8
8
  type CoreSimulatorWithApps = CoreSimulator & InteractsWithApps;
9
9
 
@@ -24,7 +24,7 @@ export async function installApp(this: CoreSimulatorWithApps, app: string): Prom
24
24
  */
25
25
  export async function getUserInstalledBundleIdsByBundleName(
26
26
  this: CoreSimulatorWithApps,
27
- bundleName: string
27
+ bundleName: string,
28
28
  ): Promise<string[]> {
29
29
  const appsRoot = path.resolve(this.getDir(), 'Containers', 'Bundle', 'Application');
30
30
  // glob all Info.plist from simdir/data/Containers/Bundle/Application
@@ -38,25 +38,27 @@ export async function getUserInstalledBundleIdsByBundleName(
38
38
 
39
39
  const bundleInfoPromises: Promise<any>[] = [];
40
40
  for (const infoPlist of infoPlists) {
41
- bundleInfoPromises.push((async () => {
42
- try {
43
- return await plist.parsePlistFile(infoPlist);
44
- } catch {
45
- return null;
46
- }
47
- })());
41
+ bundleInfoPromises.push(
42
+ (async () => {
43
+ try {
44
+ return await plist.parsePlistFile(infoPlist);
45
+ } catch {
46
+ return null;
47
+ }
48
+ })(),
49
+ );
48
50
  }
49
51
  const bundleInfos = (await B.all(bundleInfoPromises)).filter(_.isPlainObject);
50
52
  const bundleIds = bundleInfos
51
- .filter(({ CFBundleName }) => CFBundleName === bundleName)
52
- .map(({ CFBundleIdentifier }) => CFBundleIdentifier);
53
+ .filter(({CFBundleName}) => CFBundleName === bundleName)
54
+ .map(({CFBundleIdentifier}) => CFBundleIdentifier);
53
55
  if (_.isEmpty(bundleIds)) {
54
56
  return [];
55
57
  }
56
58
 
57
59
  this.log.debug(
58
60
  `The simulator has ${util.pluralize('bundle', bundleIds.length, true)} which ` +
59
- `have '${bundleName}' as their 'CFBundleName': ${JSON.stringify(bundleIds)}`
61
+ `have '${bundleName}' as their 'CFBundleName': ${JSON.stringify(bundleIds)}`,
60
62
  );
61
63
  return bundleIds;
62
64
  }
@@ -67,7 +69,10 @@ export async function getUserInstalledBundleIdsByBundleName(
67
69
  * @param bundleId The bundle id of the application to be checked.
68
70
  * @return True if the given application is installed.
69
71
  */
70
- export async function isAppInstalled(this: CoreSimulatorWithApps, bundleId: string): Promise<boolean> {
72
+ export async function isAppInstalled(
73
+ this: CoreSimulatorWithApps,
74
+ bundleId: string,
75
+ ): Promise<boolean> {
71
76
  try {
72
77
  const appContainer = await this.simctl.getAppContainer(bundleId);
73
78
  if (!appContainer.endsWith('.app')) {
@@ -105,13 +110,10 @@ export async function removeApp(this: CoreSimulatorWithApps, bundleId: string):
105
110
  export async function launchApp(
106
111
  this: CoreSimulatorWithApps,
107
112
  bundleId: string,
108
- opts: LaunchAppOptions = {}
113
+ opts: LaunchAppOptions = {},
109
114
  ): Promise<void> {
110
115
  await this.simctl.launchApp(bundleId);
111
- const {
112
- wait = false,
113
- timeoutMs = 10000,
114
- } = opts;
116
+ const {wait = false, timeoutMs = 10000} = opts;
115
117
  if (!wait) {
116
118
  return;
117
119
  }
@@ -119,7 +121,7 @@ export async function launchApp(
119
121
  try {
120
122
  await waitForCondition(async () => await this.isAppRunning(bundleId), {
121
123
  waitMs: timeoutMs,
122
- intervalMs: 300
124
+ intervalMs: 300,
123
125
  });
124
126
  } catch {
125
127
  throw new Error(`App '${bundleId}' is not runnning after ${timeoutMs}ms timeout.`);
@@ -140,7 +142,10 @@ export async function terminateApp(this: CoreSimulatorWithApps, bundleId: string
140
142
  *
141
143
  * @param bundleId The bundle ID of the application to be checked.
142
144
  */
143
- export async function isAppRunning(this: CoreSimulatorWithApps, bundleId: string): Promise<boolean> {
145
+ export async function isAppRunning(
146
+ this: CoreSimulatorWithApps,
147
+ bundleId: string,
148
+ ): Promise<boolean> {
144
149
  return (await this.ps()).some(({name}) => name === bundleId);
145
150
  }
146
151
 
@@ -158,7 +163,9 @@ export async function scrubApp(this: CoreSimulatorWithApps, bundleId: string): P
158
163
  nodir: true,
159
164
  absolute: true,
160
165
  });
161
- this.log.info(`Found ${appFiles.length} ${bundleId} app ${util.pluralize('file', appFiles.length, false)} to scrub`);
166
+ this.log.info(
167
+ `Found ${appFiles.length} ${bundleId} app ${util.pluralize('file', appFiles.length, false)} to scrub`,
168
+ );
162
169
  if (_.isEmpty(appFiles)) {
163
170
  return;
164
171
  }
@@ -168,4 +175,3 @@ export async function scrubApp(this: CoreSimulatorWithApps, bundleId: string): P
168
175
  } catch {}
169
176
  await B.all(appFiles.map((p) => fs.rimraf(p)));
170
177
  }
171
-
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import type { CoreSimulator, SupportsBiometric } from '../types';
2
+ import type {CoreSimulator, SupportsBiometric} from '../types';
3
3
 
4
4
  type CoreSimulatorWithBiometric = CoreSimulator & SupportsBiometric;
5
5
 
@@ -15,10 +15,12 @@ const BIOMETRICS: Record<string, string> = {
15
15
  export async function isBiometricEnrolled(this: CoreSimulatorWithBiometric): Promise<boolean> {
16
16
  const {stdout} = await this.simctl.spawnProcess([
17
17
  'notifyutil',
18
- '-g', ENROLLMENT_NOTIFICATION_RECEIVER
18
+ '-g',
19
+ ENROLLMENT_NOTIFICATION_RECEIVER,
19
20
  ]);
20
- const match = (new RegExp(`${_.escapeRegExp(ENROLLMENT_NOTIFICATION_RECEIVER)}\\s+([01])`))
21
- .exec(stdout);
21
+ const match = new RegExp(`${_.escapeRegExp(ENROLLMENT_NOTIFICATION_RECEIVER)}\\s+([01])`).exec(
22
+ stdout,
23
+ );
22
24
  if (!match) {
23
25
  throw new Error(`Cannot parse biometric enrollment state from '${stdout}'`);
24
26
  }
@@ -29,18 +31,24 @@ export async function isBiometricEnrolled(this: CoreSimulatorWithBiometric): Pro
29
31
  /**
30
32
  * @param isEnabled Whether to enable biometric enrollment
31
33
  */
32
- export async function enrollBiometric(this: CoreSimulatorWithBiometric, isEnabled: boolean = true): Promise<void> {
33
- this.log.debug(`Setting biometric enrolled state for ${this.udid} Simulator to '${isEnabled ? 'enabled' : 'disabled'}'`);
34
- await this.simctl.spawnProcess([
35
- 'notifyutil',
36
- '-s', ENROLLMENT_NOTIFICATION_RECEIVER, isEnabled ? '1' : '0'
37
- ]);
34
+ export async function enrollBiometric(
35
+ this: CoreSimulatorWithBiometric,
36
+ isEnabled: boolean = true,
37
+ ): Promise<void> {
38
+ this.log.debug(
39
+ `Setting biometric enrolled state for ${this.udid} Simulator to '${isEnabled ? 'enabled' : 'disabled'}'`,
40
+ );
38
41
  await this.simctl.spawnProcess([
39
42
  'notifyutil',
40
- '-p', ENROLLMENT_NOTIFICATION_RECEIVER
43
+ '-s',
44
+ ENROLLMENT_NOTIFICATION_RECEIVER,
45
+ isEnabled ? '1' : '0',
41
46
  ]);
42
- if (await this.isBiometricEnrolled() !== isEnabled) {
43
- throw new Error(`Cannot set biometric enrolled state for ${this.udid} Simulator to '${isEnabled ? 'enabled' : 'disabled'}'`);
47
+ await this.simctl.spawnProcess(['notifyutil', '-p', ENROLLMENT_NOTIFICATION_RECEIVER]);
48
+ if ((await this.isBiometricEnrolled()) !== isEnabled) {
49
+ throw new Error(
50
+ `Cannot set biometric enrolled state for ${this.udid} Simulator to '${isEnabled ? 'enabled' : 'disabled'}'`,
51
+ );
44
52
  }
45
53
  }
46
54
 
@@ -54,17 +62,14 @@ export async function enrollBiometric(this: CoreSimulatorWithBiometric, isEnable
54
62
  export async function sendBiometricMatch(
55
63
  this: CoreSimulatorWithBiometric,
56
64
  shouldMatch: boolean = true,
57
- biometricName: string = 'touchId'
65
+ biometricName: string = 'touchId',
58
66
  ): Promise<void> {
59
67
  const domainComponent = toBiometricDomainComponent(biometricName);
60
68
  const domain = `com.apple.BiometricKit_Sim.${domainComponent}.${shouldMatch ? '' : 'no'}match`;
61
- await this.simctl.spawnProcess([
62
- 'notifyutil',
63
- '-p', domain
64
- ]);
69
+ await this.simctl.spawnProcess(['notifyutil', '-p', domain]);
65
70
  this.log.info(
66
71
  `Sent notification ${domain} to ${shouldMatch ? 'match' : 'not match'} ${biometricName} biometric ` +
67
- `for ${this.udid} Simulator`
72
+ `for ${this.udid} Simulator`,
68
73
  );
69
74
  }
70
75
 
@@ -74,8 +79,9 @@ export async function sendBiometricMatch(
74
79
  */
75
80
  export function toBiometricDomainComponent(name: string): string {
76
81
  if (!BIOMETRICS[name]) {
77
- throw new Error(`'${name}' is not a valid biometric. Use one of: ${JSON.stringify(_.keys(BIOMETRICS))}`);
82
+ throw new Error(
83
+ `'${name}' is not a valid biometric. Use one of: ${JSON.stringify(_.keys(BIOMETRICS))}`,
84
+ );
78
85
  }
79
86
  return BIOMETRICS[name];
80
87
  }
81
-
@@ -1,4 +1,4 @@
1
- import type { CoreSimulator, SupportsGeolocation } from '../types';
1
+ import type {CoreSimulator, SupportsGeolocation} from '../types';
2
2
 
3
3
  type CoreSimulatorWithGeolocation = CoreSimulator & SupportsGeolocation;
4
4
 
@@ -9,8 +9,11 @@ type CoreSimulatorWithGeolocation = CoreSimulator & SupportsGeolocation;
9
9
  * @param longitude The longitude coordinate.
10
10
  * @returns True if the geolocation was set successfully.
11
11
  */
12
- export async function setGeolocation(this: CoreSimulatorWithGeolocation, latitude: string | number, longitude: string | number): Promise<boolean> {
12
+ export async function setGeolocation(
13
+ this: CoreSimulatorWithGeolocation,
14
+ latitude: string | number,
15
+ longitude: string | number,
16
+ ): Promise<boolean> {
13
17
  await this.simctl.setLocation(latitude, longitude);
14
18
  return true;
15
19
  }
16
-
@@ -1,8 +1,8 @@
1
1
  import _ from 'lodash';
2
2
  import path from 'node:path';
3
- import { fs, mkdirp, tempDir, util } from '@appium/support';
4
- import { exec } from 'teen_process';
5
- import type { CoreSimulator, InteractsWithKeychain } from '../types';
3
+ import {fs, mkdirp, tempDir, util} from '@appium/support';
4
+ import {exec} from 'teen_process';
5
+ import type {CoreSimulator, InteractsWithKeychain} from '../types';
6
6
 
7
7
  type CoreSimulatorWithKeychain = CoreSimulator & InteractsWithKeychain;
8
8
 
@@ -16,20 +16,22 @@ type CoreSimulatorWithKeychain = CoreSimulator & InteractsWithKeychain;
16
16
  */
17
17
  export async function backupKeychains(this: CoreSimulatorWithKeychain): Promise<boolean> {
18
18
  const resetBackupPath = async (newPath: string | null | undefined) => {
19
- if (_.isString(this._keychainsBackupPath) && await fs.exists(this._keychainsBackupPath)) {
19
+ if (_.isString(this._keychainsBackupPath) && (await fs.exists(this._keychainsBackupPath))) {
20
20
  await fs.unlink(this._keychainsBackupPath);
21
21
  }
22
22
  this._keychainsBackupPath = newPath;
23
23
  };
24
24
 
25
- if (!await fs.exists(this.keychainPath) || _.isEmpty(await fs.readdir(this.keychainPath))) {
25
+ if (!(await fs.exists(this.keychainPath)) || _.isEmpty(await fs.readdir(this.keychainPath))) {
26
26
  this.log.info(`There is nothing to backup from '${this.keychainPath}'`);
27
27
  await resetBackupPath(null);
28
28
  return false;
29
29
  }
30
30
 
31
31
  const dstPath = await tempDir.path({
32
- prefix: `keychains_backup_${Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)}`,
32
+ prefix: `keychains_backup_${Math.floor((1 + Math.random()) * 0x10000)
33
+ .toString(16)
34
+ .substring(1)}`,
33
35
  suffix: '.zip',
34
36
  });
35
37
  const zipArgs = ['-r', dstPath, `${path.basename(this.keychainPath)}${path.sep}`];
@@ -39,7 +41,7 @@ export async function backupKeychains(this: CoreSimulatorWithKeychain): Promise<
39
41
  } catch (err: any) {
40
42
  throw new Error(
41
43
  `Cannot create keychains backup from '${this.keychainPath}'. ` +
42
- `Original error: ${err.stderr || err.stdout || err.message}`
44
+ `Original error: ${err.stderr || err.stdout || err.message}`,
43
45
  );
44
46
  }
45
47
  await resetBackupPath(dstPath);
@@ -60,11 +62,12 @@ export async function backupKeychains(this: CoreSimulatorWithKeychain): Promise<
60
62
  */
61
63
  export async function restoreKeychains(
62
64
  this: CoreSimulatorWithKeychain,
63
- excludePatterns: string[] | string = []
65
+ excludePatterns: string[] | string = [],
64
66
  ): Promise<boolean> {
65
- if (!_.isString(this._keychainsBackupPath) || !await fs.exists(this._keychainsBackupPath)) {
66
- throw new Error(`The keychains backup archive does not exist. ` +
67
- `Are you sure it was created before?`);
67
+ if (!_.isString(this._keychainsBackupPath) || !(await fs.exists(this._keychainsBackupPath))) {
68
+ throw new Error(
69
+ `The keychains backup archive does not exist. ` + `Are you sure it was created before?`,
70
+ );
68
71
  }
69
72
 
70
73
  let patterns: string[] = [];
@@ -77,7 +80,7 @@ export async function restoreKeychains(
77
80
  let plistPath: string | undefined;
78
81
  if (isServerRunning) {
79
82
  plistPath = path.resolve(await this.getLaunchDaemonsRoot(), 'com.apple.securityd.plist');
80
- if (!await fs.exists(plistPath)) {
83
+ if (!(await fs.exists(plistPath))) {
81
84
  throw new Error(`Cannot clear keychains because '${plistPath}' does not exist`);
82
85
  }
83
86
  await this.simctl.spawnProcess(['launchctl', 'unload', plistPath]);
@@ -90,9 +93,11 @@ export async function restoreKeychains(
90
93
  throw new Error('Backup path is not set');
91
94
  }
92
95
  const unzipArgs = [
93
- '-o', backupPath,
94
- ...(_.flatMap(patterns.map((x) => ['-x', x]))),
95
- '-d', path.dirname(this.keychainPath),
96
+ '-o',
97
+ backupPath,
98
+ ..._.flatMap(patterns.map((x) => ['-x', x])),
99
+ '-d',
100
+ path.dirname(this.keychainPath),
96
101
  ];
97
102
  this.log.debug(`Restoring keychains with '${util.quote(['unzip', ...unzipArgs])}' command`);
98
103
  try {
@@ -100,7 +105,7 @@ export async function restoreKeychains(
100
105
  } catch (err: any) {
101
106
  throw new Error(
102
107
  `Cannot restore keychains from '${backupPath}'. ` +
103
- `Original error: ${err.stderr || err.stdout || err.message}`
108
+ `Original error: ${err.stderr || err.stdout || err.message}`,
104
109
  );
105
110
  }
106
111
  await fs.unlink(backupPath);
@@ -121,7 +126,7 @@ export async function restoreKeychains(
121
126
  */
122
127
  export async function clearKeychains(this: CoreSimulatorWithKeychain): Promise<void> {
123
128
  const plistPath = path.resolve(await this.getLaunchDaemonsRoot(), 'com.apple.securityd.plist');
124
- if (!await fs.exists(plistPath)) {
129
+ if (!(await fs.exists(plistPath))) {
125
130
  throw new Error(`Cannot clear keychains because '${plistPath}' does not exist`);
126
131
  }
127
132
  await this.simctl.spawnProcess(['launchctl', 'unload', plistPath]);
@@ -134,4 +139,3 @@ export async function clearKeychains(this: CoreSimulatorWithKeychain): Promise<v
134
139
  await this.simctl.spawnProcess(['launchctl', 'load', plistPath]);
135
140
  }
136
141
  }
137
-
@@ -1,5 +1,5 @@
1
- import type { CoreSimulator, HasMiscFeatures, CertificateOptions } from '../types';
2
- import type { StringRecord } from '@appium/types';
1
+ import type {CoreSimulator, HasMiscFeatures, CertificateOptions} from '../types';
2
+ import type {StringRecord} from '@appium/types';
3
3
 
4
4
  type CoreSimulatorWithMiscFeatures = CoreSimulator & HasMiscFeatures;
5
5
 
@@ -8,10 +8,7 @@ type CoreSimulatorWithMiscFeatures = CoreSimulator & HasMiscFeatures;
8
8
  */
9
9
  export async function shake(this: CoreSimulatorWithMiscFeatures): Promise<void> {
10
10
  this.log.info(`Performing shake gesture on ${this.udid} Simulator`);
11
- await this.simctl.spawnProcess([
12
- 'notifyutil',
13
- '-p', 'com.apple.UIKit.SimulatorShake'
14
- ]);
11
+ await this.simctl.spawnProcess(['notifyutil', '-p', 'com.apple.UIKit.SimulatorShake']);
15
12
  }
16
13
 
17
14
  /**
@@ -25,11 +22,11 @@ export async function shake(this: CoreSimulatorWithMiscFeatures): Promise<void>
25
22
  * @returns True if the certificate was added successfully.
26
23
  */
27
24
  export async function addCertificate(
28
- this: CoreSimulatorWithMiscFeatures, payload: string, opts: CertificateOptions = {}
25
+ this: CoreSimulatorWithMiscFeatures,
26
+ payload: string,
27
+ opts: CertificateOptions = {},
29
28
  ): Promise<boolean> {
30
- const {
31
- isRoot = true,
32
- } = opts;
29
+ const {isRoot = true} = opts;
33
30
  const methodName = isRoot ? 'addRootCertificate' : 'addCertificate';
34
31
  await this.simctl[methodName](payload, {raw: true});
35
32
  return true;
@@ -53,8 +50,8 @@ export async function addCertificate(
53
50
  * }
54
51
  */
55
52
  export async function pushNotification(
56
- this: CoreSimulatorWithMiscFeatures, payload: StringRecord
53
+ this: CoreSimulatorWithMiscFeatures,
54
+ payload: StringRecord,
57
55
  ): Promise<void> {
58
56
  await this.simctl.pushNotification(payload);
59
57
  }
60
-