appium-ios-simulator 8.0.13 → 8.1.1

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 (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/defaults-utils.d.ts +24 -24
  3. package/build/lib/defaults-utils.d.ts.map +1 -1
  4. package/build/lib/defaults-utils.js +61 -65
  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 +6 -7
  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 +3 -6
  11. package/build/lib/extensions/biometric.js.map +1 -1
  12. package/build/lib/extensions/keychain.d.ts.map +1 -1
  13. package/build/lib/extensions/keychain.js +7 -6
  14. package/build/lib/extensions/keychain.js.map +1 -1
  15. package/build/lib/extensions/permissions.d.ts.map +1 -1
  16. package/build/lib/extensions/permissions.js +17 -19
  17. package/build/lib/extensions/permissions.js.map +1 -1
  18. package/build/lib/extensions/safari.d.ts.map +1 -1
  19. package/build/lib/extensions/safari.js +2 -4
  20. package/build/lib/extensions/safari.js.map +1 -1
  21. package/build/lib/extensions/settings.d.ts.map +1 -1
  22. package/build/lib/extensions/settings.js +52 -50
  23. package/build/lib/extensions/settings.js.map +1 -1
  24. package/build/lib/simulator-xcode-14.d.ts +37 -37
  25. package/build/lib/simulator-xcode-14.d.ts.map +1 -1
  26. package/build/lib/simulator-xcode-14.js +57 -59
  27. package/build/lib/simulator-xcode-14.js.map +1 -1
  28. package/build/lib/simulator-xcode-15.d.ts.map +1 -1
  29. package/build/lib/simulator-xcode-15.js +3 -5
  30. package/build/lib/simulator-xcode-15.js.map +1 -1
  31. package/build/lib/types.d.ts +8 -8
  32. package/build/lib/types.d.ts.map +1 -1
  33. package/build/lib/utils.d.ts +11 -3
  34. package/build/lib/utils.d.ts.map +1 -1
  35. package/build/lib/utils.js +50 -35
  36. package/build/lib/utils.js.map +1 -1
  37. package/lib/defaults-utils.ts +69 -68
  38. package/lib/extensions/applications.ts +6 -7
  39. package/lib/extensions/biometric.ts +3 -3
  40. package/lib/extensions/keychain.ts +11 -6
  41. package/lib/extensions/permissions.ts +18 -20
  42. package/lib/extensions/safari.ts +2 -4
  43. package/lib/extensions/settings.ts +71 -62
  44. package/lib/simulator-xcode-14.ts +70 -71
  45. package/lib/simulator-xcode-15.ts +3 -5
  46. package/lib/types.ts +9 -9
  47. package/lib/utils.ts +52 -37
  48. package/package.json +1 -5
package/lib/utils.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import {log} from './logger';
2
- import _ from 'lodash';
3
2
  import {exec} from 'teen_process';
4
3
  import {waitForCondition} from 'asyncbox';
5
4
  import {getVersion} from 'appium-xcode';
@@ -16,29 +15,8 @@ export const MOBILE_SAFARI_BUNDLE_ID = 'com.apple.mobilesafari';
16
15
  export const SIMULATOR_APP_NAME = 'Simulator.app';
17
16
  export const MIN_SUPPORTED_XCODE_VERSION = 14;
18
17
 
19
- /**
20
- * @param appName - The application name to kill.
21
- * @param forceKill - Whether to force kill the process.
22
- * @returns Promise that resolves to 0 on success.
23
- */
24
- async function pkill(appName: string, forceKill: boolean = false): Promise<number> {
25
- const args = forceKill ? ['-9'] : [];
26
- args.push('-x', appName);
27
- try {
28
- await exec('pkill', args);
29
- return 0;
30
- } catch (err: any) {
31
- // pgrep/pkill exit codes:
32
- // 0 One or more processes were matched.
33
- // 1 No processes were matched.
34
- // 2 Invalid options were specified on the command line.
35
- // 3 An internal error occurred.
36
- if (!_.isUndefined(err.code)) {
37
- throw new Error(`Cannot forcefully terminate ${appName}. pkill error code: ${err.code}`);
38
- }
39
- log.error(`Received unexpected error while trying to kill ${appName}: ${err.message}`);
40
- throw err;
41
- }
18
+ export interface SimulatorInfoOptions {
19
+ devicesSetPath?: string | null;
42
20
  }
43
21
 
44
22
  /**
@@ -50,7 +28,7 @@ export async function killAllSimulators(
50
28
  ): Promise<void> {
51
29
  log.debug('Killing all iOS Simulators');
52
30
  const xcodeVersion = await getVersion(true);
53
- if (_.isString(xcodeVersion)) {
31
+ if (typeof xcodeVersion === 'string') {
54
32
  return;
55
33
  }
56
34
  const appName = path.parse(SIMULATOR_APP_NAME).name;
@@ -74,13 +52,13 @@ export async function killAllSimulators(
74
52
  log.debug(`${appName} is not running. Continuing...`);
75
53
  return;
76
54
  }
77
- if (_.isEmpty(pids)) {
55
+ if (pids.length === 0) {
78
56
  log.warn(
79
57
  `pgrep error ${e.code} while detecting whether ${appName} is running. Trying to kill anyway.`,
80
58
  );
81
59
  }
82
60
  }
83
- if (!_.isEmpty(pids)) {
61
+ if (pids.length > 0) {
84
62
  log.debug(`Killing processes: ${pids.join(', ')}`);
85
63
  try {
86
64
  await exec('kill', ['-9', ...pids.map((pid) => `${pid}`)]);
@@ -98,8 +76,8 @@ export async function killAllSimulators(
98
76
  async function allSimsAreDown(): Promise<boolean> {
99
77
  remainingDevices = [];
100
78
  const devicesRecord = await utilsModule.getDevices();
101
- const devices = _.flatten(_.values(devicesRecord));
102
- return _.every(devices, (sim: any) => {
79
+ const devices = Object.values(devicesRecord).flat();
80
+ return devices.every((sim: any) => {
103
81
  const state = sim.state.toLowerCase();
104
82
  const done = ['shutdown', 'unavailable', 'disconnected'].includes(state);
105
83
  if (!done) {
@@ -126,10 +104,6 @@ export async function killAllSimulators(
126
104
  }
127
105
  }
128
106
 
129
- export interface SimulatorInfoOptions {
130
- devicesSetPath?: string | null;
131
- }
132
-
133
107
  /**
134
108
  * @param udid - The simulator UDID.
135
109
  * @param opts - Options including devicesSetPath.
@@ -141,10 +115,8 @@ export async function getSimulatorInfo(
141
115
  ): Promise<any> {
142
116
  const {devicesSetPath} = opts;
143
117
  // see the README for github.com/appium/node-simctl for example output of getDevices()
144
- const devices = _.toPairs(await utilsModule.getDevices({devicesSetPath}))
145
- .map((pair) => pair[1])
146
- .reduce((a, b) => a.concat(b), []);
147
- return _.find(devices, (sim: any) => sim.udid === udid);
118
+ const devices = Object.values(await utilsModule.getDevices({devicesSetPath})).flat();
119
+ return devices.find((sim: any) => sim.udid === udid);
148
120
  }
149
121
 
150
122
  /**
@@ -188,3 +160,46 @@ export function assertXcodeVersion<V extends XcodeVersion>(xcodeVersion: V): V {
188
160
  export async function getDevices(simctlOpts?: StringRecord): Promise<Record<string, any[]>> {
189
161
  return await new Simctl(simctlOpts).getDevices();
190
162
  }
163
+
164
+ /**
165
+ * Checks whether the given value is a plain object.
166
+ */
167
+ export function isPlainObject(value: unknown): value is Record<string, any> {
168
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) {
169
+ return false;
170
+ }
171
+ const proto = Object.getPrototypeOf(value);
172
+ return proto === null || proto === Object.prototype;
173
+ }
174
+
175
+ /**
176
+ * Escapes regexp control characters in a string.
177
+ */
178
+ export function escapeRegExp(value: string): string {
179
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
180
+ }
181
+
182
+ /**
183
+ * @param appName - The application name to kill.
184
+ * @param forceKill - Whether to force kill the process.
185
+ * @returns Promise that resolves to 0 on success.
186
+ */
187
+ async function pkill(appName: string, forceKill: boolean = false): Promise<number> {
188
+ const args = forceKill ? ['-9'] : [];
189
+ args.push('-x', appName);
190
+ try {
191
+ await exec('pkill', args);
192
+ return 0;
193
+ } catch (err: any) {
194
+ // pgrep/pkill exit codes:
195
+ // 0 One or more processes were matched.
196
+ // 1 No processes were matched.
197
+ // 2 Invalid options were specified on the command line.
198
+ // 3 An internal error occurred.
199
+ if (err.code !== undefined) {
200
+ throw new Error(`Cannot forcefully terminate ${appName}. pkill error code: ${err.code}`);
201
+ }
202
+ log.error(`Received unexpected error while trying to kill ${appName}: ${err.message}`);
203
+ throw err;
204
+ }
205
+ }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "ios",
8
8
  "simctl"
9
9
  ],
10
- "version": "8.0.13",
10
+ "version": "8.1.1",
11
11
  "author": "Appium Contributors",
12
12
  "license": "Apache-2.0",
13
13
  "repository": {
@@ -37,8 +37,6 @@
37
37
  "appium-xcode": "^6.0.0",
38
38
  "async-lock": "^1.0.0",
39
39
  "asyncbox": "^6.0.1",
40
- "bluebird": "^3.5.1",
41
- "lodash": "^4.2.1",
42
40
  "node-simctl": "^8.1.1",
43
41
  "semver": "^7.0.0",
44
42
  "teen_process": "^4.0.4"
@@ -68,8 +66,6 @@
68
66
  "@colors/colors": "^1.5.0",
69
67
  "@semantic-release/changelog": "^6.0.1",
70
68
  "@semantic-release/git": "^10.0.1",
71
- "@types/bluebird": "^3.5.38",
72
- "@types/lodash": "^4.14.196",
73
69
  "@types/mocha": "^10.0.1",
74
70
  "@types/node": "^25.0.0",
75
71
  "chai": "^6.0.0",