node-simctl 8.1.4 → 8.1.6
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 +12 -0
- package/build/lib/helpers.d.ts.map +1 -1
- package/build/lib/helpers.js.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/simctl.d.ts.map +1 -1
- package/build/lib/simctl.js +5 -2
- package/build/lib/simctl.js.map +1 -1
- package/build/lib/subcommands/addmedia.d.ts.map +1 -1
- package/build/lib/subcommands/addmedia.js.map +1 -1
- package/build/lib/subcommands/appinfo.d.ts.map +1 -1
- package/build/lib/subcommands/appinfo.js.map +1 -1
- package/build/lib/subcommands/boot.d.ts.map +1 -1
- package/build/lib/subcommands/boot.js +1 -1
- package/build/lib/subcommands/boot.js.map +1 -1
- package/build/lib/subcommands/bootstatus.d.ts.map +1 -1
- package/build/lib/subcommands/bootstatus.js.map +1 -1
- package/build/lib/subcommands/create.d.ts.map +1 -1
- package/build/lib/subcommands/create.js +2 -2
- package/build/lib/subcommands/create.js.map +1 -1
- package/build/lib/subcommands/delete.d.ts.map +1 -1
- package/build/lib/subcommands/delete.js +1 -1
- package/build/lib/subcommands/erase.d.ts.map +1 -1
- package/build/lib/subcommands/erase.js +1 -1
- package/build/lib/subcommands/erase.js.map +1 -1
- package/build/lib/subcommands/get_app_container.d.ts.map +1 -1
- package/build/lib/subcommands/getenv.d.ts.map +1 -1
- package/build/lib/subcommands/getenv.js.map +1 -1
- package/build/lib/subcommands/install.d.ts.map +1 -1
- package/build/lib/subcommands/install.js.map +1 -1
- package/build/lib/subcommands/io.d.ts.map +1 -1
- package/build/lib/subcommands/io.js +4 -4
- package/build/lib/subcommands/io.js.map +1 -1
- package/build/lib/subcommands/keychain.d.ts.map +1 -1
- package/build/lib/subcommands/keychain.js +6 -6
- package/build/lib/subcommands/keychain.js.map +1 -1
- package/build/lib/subcommands/launch.d.ts.map +1 -1
- package/build/lib/subcommands/launch.js.map +1 -1
- package/build/lib/subcommands/list.d.ts.map +1 -1
- package/build/lib/subcommands/list.js +4 -3
- package/build/lib/subcommands/list.js.map +1 -1
- package/build/lib/subcommands/location.d.ts.map +1 -1
- package/build/lib/subcommands/location.js.map +1 -1
- package/build/lib/subcommands/openurl.d.ts.map +1 -1
- package/build/lib/subcommands/openurl.js.map +1 -1
- package/build/lib/subcommands/pbcopy.d.ts.map +1 -1
- package/build/lib/subcommands/pbcopy.js +2 -2
- package/build/lib/subcommands/pbcopy.js.map +1 -1
- package/build/lib/subcommands/pbpaste.d.ts.map +1 -1
- package/build/lib/subcommands/pbpaste.js.map +1 -1
- package/build/lib/subcommands/privacy.d.ts.map +1 -1
- package/build/lib/subcommands/privacy.js.map +1 -1
- package/build/lib/subcommands/push.d.ts.map +1 -1
- package/build/lib/subcommands/push.js +4 -4
- package/build/lib/subcommands/push.js.map +1 -1
- package/build/lib/subcommands/shutdown.d.ts.map +1 -1
- package/build/lib/subcommands/shutdown.js.map +1 -1
- package/build/lib/subcommands/spawn.d.ts.map +1 -1
- package/build/lib/subcommands/spawn.js +2 -2
- package/build/lib/subcommands/spawn.js.map +1 -1
- package/build/lib/subcommands/terminate.d.ts.map +1 -1
- package/build/lib/subcommands/terminate.js.map +1 -1
- package/build/lib/subcommands/ui.d.ts.map +1 -1
- package/build/lib/subcommands/ui.js.map +1 -1
- package/build/lib/subcommands/uninstall.d.ts.map +1 -1
- package/build/lib/subcommands/uninstall.js.map +1 -1
- package/build/lib/types.d.ts.map +1 -1
- package/lib/helpers.ts +9 -8
- package/lib/logger.ts +2 -2
- package/lib/simctl.ts +34 -32
- package/lib/subcommands/addmedia.ts +6 -3
- package/lib/subcommands/appinfo.ts +5 -5
- package/lib/subcommands/boot.ts +4 -4
- package/lib/subcommands/bootstatus.ts +82 -80
- package/lib/subcommands/create.ts +22 -20
- package/lib/subcommands/delete.ts +3 -4
- package/lib/subcommands/erase.ts +10 -8
- package/lib/subcommands/get_app_container.ts +3 -4
- package/lib/subcommands/getenv.ts +2 -3
- package/lib/subcommands/install.ts +2 -3
- package/lib/subcommands/io.ts +7 -8
- package/lib/subcommands/keychain.ts +24 -27
- package/lib/subcommands/launch.ts +7 -4
- package/lib/subcommands/list.ts +48 -38
- package/lib/subcommands/location.ts +5 -6
- package/lib/subcommands/openurl.ts +3 -3
- package/lib/subcommands/pbcopy.ts +6 -7
- package/lib/subcommands/pbpaste.ts +5 -3
- package/lib/subcommands/privacy.ts +8 -5
- package/lib/subcommands/push.ts +7 -8
- package/lib/subcommands/shutdown.ts +3 -4
- package/lib/subcommands/spawn.ts +8 -9
- package/lib/subcommands/terminate.ts +2 -3
- package/lib/subcommands/ui.ts +7 -8
- package/lib/subcommands/uninstall.ts +2 -3
- package/lib/types.ts +1 -2
- package/package.json +4 -2
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.pushNotification = pushNotification;
|
|
7
7
|
const rimraf_1 = require("rimraf");
|
|
8
8
|
const helpers_1 = require("../helpers");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
11
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
12
12
|
/**
|
|
13
13
|
* Send a simulated push notification
|
|
14
14
|
*
|
|
@@ -30,7 +30,7 @@ const promises_1 = __importDefault(require("fs/promises"));
|
|
|
30
30
|
* @throws {Error} If the `udid` instance property is unset
|
|
31
31
|
*/
|
|
32
32
|
async function pushNotification(payload) {
|
|
33
|
-
const dstPath =
|
|
33
|
+
const dstPath = node_path_1.default.resolve(node_os_1.default.tmpdir(), `${await (0, helpers_1.uuidV4)()}.json`);
|
|
34
34
|
try {
|
|
35
35
|
await promises_1.default.writeFile(dstPath, JSON.stringify(payload), 'utf8');
|
|
36
36
|
await this.exec('push', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../lib/subcommands/push.ts"],"names":[],"mappings":";;;;;AA2BA,4CAUC;AArCD,
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../lib/subcommands/push.ts"],"names":[],"mappings":";;;;;AA2BA,4CAUC;AArCD,mCAA8B;AAC9B,wCAAkC;AAClC,0DAA6B;AAC7B,sDAAyB;AACzB,gEAAkC;AAGlC;;;;;;;;;;;;;;;;;;;GAmBG;AACI,KAAK,UAAU,gBAAgB,CAAe,OAA4B;IAC/E,MAAM,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,iBAAE,CAAC,MAAM,EAAE,EAAE,GAAG,MAAM,IAAA,gBAAM,GAAE,OAAO,CAAC,CAAC;IACpE,IAAI,CAAC;QACH,MAAM,kBAAE,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;QAC7D,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACtB,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;SAC1C,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC;IACxB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/shutdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/shutdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEtC;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../../lib/subcommands/shutdown.ts"],"names":[],"mappings":";;;;;AAWA,wCAWC;AAtBD,oDAAuB;AACvB,
|
|
1
|
+
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../../lib/subcommands/shutdown.ts"],"names":[],"mappings":";;;;;AAWA,wCAWC;AAtBD,oDAAuB;AACvB,sCAA0C;AAG1C;;;;;;GAMG;AACI,KAAK,UAAU,cAAc;IAClC,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;SACrC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,gBAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,yBAAyB,CAAC,EAAE,CAAC;YACtD,MAAM,CAAC,CAAC;QACV,CAAC;QACD,YAAG,CAAC,KAAK,CAAC,mBAAU,EAAE,mDAAmD,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/spawn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/spawn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAC,qBAAqB,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAEpE;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAC5B,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CASxC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAC5B,OAAO,CAAC,UAAU,CAAC,CAUrB"}
|
|
@@ -39,10 +39,10 @@ async function spawnSubProcess(args, env = {}) {
|
|
|
39
39
|
if (lodash_1.default.isEmpty(args)) {
|
|
40
40
|
throw new Error('Spawn arguments are required');
|
|
41
41
|
}
|
|
42
|
-
return await this.exec('spawn', {
|
|
42
|
+
return (await this.exec('spawn', {
|
|
43
43
|
args: [this.requireUdid('spawn'), ...(lodash_1.default.isArray(args) ? args : [args])],
|
|
44
44
|
env,
|
|
45
45
|
asynchronous: true,
|
|
46
|
-
});
|
|
46
|
+
}));
|
|
47
47
|
}
|
|
48
48
|
//# sourceMappingURL=spawn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../../lib/subcommands/spawn.ts"],"names":[],"mappings":";;;;;AAeA,oCAaC;AAWD,0CAcC;AArDD,oDAAuB;AAIvB;;;;;;;;;;GAUG;AACI,KAAK,UAAU,YAAY,CAEhC,IAAuB,EACvB,MAA2B,EAAE;IAE7B,IAAI,gBAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QAC9B,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,gBAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACvE,GAAG;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G,CAAC,gBAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACvE,GAAG;QACH,YAAY,EAAE,IAAI;KACnB,CAAC,CAAe,CAAC;AACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminate.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/terminate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"terminate.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/terminate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEtC;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIhF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminate.js","sourceRoot":"","sources":["../../../lib/subcommands/terminate.ts"],"names":[],"mappings":";;AAYA,oCAIC;AAdD;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,
|
|
1
|
+
{"version":3,"file":"terminate.js","sourceRoot":"","sources":["../../../lib/subcommands/terminate.ts"],"names":[],"mappings":";;AAYA,oCAIC;AAdD;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,CAAe,QAAgB;IAC/D,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QAC3B,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC;KAChD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/ui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/ui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEtC;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKjE;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAInF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKvE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI/F;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKlE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../lib/subcommands/ui.ts"],"names":[],"mappings":";;;;;AAYA,sCAKC;AAWD,sCAIC;AAkBD,kDAKC;AAeD,kDAIC;AAuBD,wCAKC;AAwBD,wCAIC;AAlID,oDAAuB;AAGvB;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa;IACjC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QACrC,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC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ACpB,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC;KACtE,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,cAAc;IAClC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QACrC,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC;KAC/C,CAAC,CAAC;IACH,OAAO,gBAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,cAAc,CAAe,iBAAyB;IAC1E,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QACpB,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,iBAAiB,CAAC;KAClE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../../lib/subcommands/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../lib/subcommands/uninstall.ts"],"names":[],"mappings":";;AAaA,8BAIC;AAfD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,SAAS,
|
|
1
|
+
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../lib/subcommands/uninstall.ts"],"names":[],"mappings":";;AAaA,8BAIC;AAfD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,SAAS,CAAe,QAAgB;IAC5D,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QAC3B,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC;KAChD,CAAC,CAAC;AACL,CAAC"}
|
package/build/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,cAAc,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;A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;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
package/lib/helpers.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as semver from 'semver';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {spawn} from 'node:child_process';
|
|
3
|
+
import {Readable} from 'node:stream';
|
|
4
4
|
|
|
5
5
|
export const DEFAULT_EXEC_TIMEOUT = 10 * 60 * 1000; // ms
|
|
6
6
|
export const SIM_RUNTIME_NAME = 'com.apple.CoreSimulator.SimRuntime.';
|
|
@@ -13,7 +13,7 @@ export const SIM_RUNTIME_NAME = 'com.apple.CoreSimulator.SimRuntime.';
|
|
|
13
13
|
* @return The version in 'major.minor' form
|
|
14
14
|
* @throws {Error} If the version not parseable by the `semver` package
|
|
15
15
|
*/
|
|
16
|
-
export function normalizeVersion
|
|
16
|
+
export function normalizeVersion(version: string): string {
|
|
17
17
|
const semverVersion = semver.coerce(version);
|
|
18
18
|
if (!semverVersion) {
|
|
19
19
|
throw new Error(`Unable to parse version '${version}'`);
|
|
@@ -24,7 +24,7 @@ export function normalizeVersion (version: string): string {
|
|
|
24
24
|
/**
|
|
25
25
|
* @returns The xcrun binary name
|
|
26
26
|
*/
|
|
27
|
-
export function getXcrunBinary
|
|
27
|
+
export function getXcrunBinary(): string {
|
|
28
28
|
return process.env.XCRUN_BINARY || 'xcrun';
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ export function getXcrunBinary (): string {
|
|
|
33
33
|
*
|
|
34
34
|
* @returns Promise resolving to UUID string
|
|
35
35
|
*/
|
|
36
|
-
export async function uuidV4
|
|
36
|
+
export async function uuidV4(): Promise<string> {
|
|
37
37
|
const uuidLib = await import('uuid');
|
|
38
38
|
return uuidLib.v4();
|
|
39
39
|
}
|
|
@@ -45,7 +45,7 @@ export async function uuidV4 (): Promise<string> {
|
|
|
45
45
|
* @return Promise resolving to parsed JSON object
|
|
46
46
|
* @throws {Error} If plutil fails to convert the input
|
|
47
47
|
*/
|
|
48
|
-
export async function convertPlistToJson
|
|
48
|
+
export async function convertPlistToJson(plistInput: string): Promise<any> {
|
|
49
49
|
const plutilProcess = spawn('plutil', ['-convert', 'json', '-o', '-', '-']);
|
|
50
50
|
let jsonOutput = '';
|
|
51
51
|
plutilProcess.stdout.on('data', (chunk) => {
|
|
@@ -71,11 +71,12 @@ export async function convertPlistToJson (plistInput: string): Promise<any> {
|
|
|
71
71
|
});
|
|
72
72
|
} catch (err) {
|
|
73
73
|
plutilProcess.kill(9);
|
|
74
|
-
throw new Error(
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Failed to convert plist to JSON: ${err instanceof Error ? err.message : String(err)}`,
|
|
76
|
+
);
|
|
75
77
|
} finally {
|
|
76
78
|
plutilProcess.removeAllListeners();
|
|
77
79
|
inputStream.removeAllListeners();
|
|
78
80
|
}
|
|
79
81
|
return JSON.parse(jsonOutput);
|
|
80
82
|
}
|
|
81
|
-
|
package/lib/logger.ts
CHANGED
|
@@ -2,10 +2,10 @@ import appiumLogger from '@appium/logger';
|
|
|
2
2
|
|
|
3
3
|
export const LOG_PREFIX = 'simctl';
|
|
4
4
|
|
|
5
|
-
function getLogger
|
|
5
|
+
function getLogger() {
|
|
6
6
|
const logger = global._global_npmlog || appiumLogger;
|
|
7
7
|
if (!logger.debug) {
|
|
8
|
-
logger.addLevel('debug', 1000, {
|
|
8
|
+
logger.addLevel('debug', 1000, {fg: 'blue', bg: 'black'}, 'dbug');
|
|
9
9
|
}
|
|
10
10
|
return logger;
|
|
11
11
|
}
|
package/lib/simctl.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import which from 'which';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
} from './helpers';
|
|
7
|
-
import { exec as tpExec, SubProcess } from 'teen_process';
|
|
3
|
+
import {log, LOG_PREFIX} from './logger';
|
|
4
|
+
import {DEFAULT_EXEC_TIMEOUT, getXcrunBinary} from './helpers';
|
|
5
|
+
import {exec as tpExec, SubProcess} from 'teen_process';
|
|
8
6
|
import * as addmediaCommands from './subcommands/addmedia';
|
|
9
7
|
import * as appinfoCommands from './subcommands/appinfo';
|
|
10
8
|
import * as bootCommands from './subcommands/boot';
|
|
@@ -30,9 +28,7 @@ import * as terminateCommands from './subcommands/terminate';
|
|
|
30
28
|
import * as uiCommands from './subcommands/ui';
|
|
31
29
|
import * as uninstallCommands from './subcommands/uninstall';
|
|
32
30
|
import * as locationCommands from './subcommands/location';
|
|
33
|
-
import type {
|
|
34
|
-
XCRun, ExecOpts, SimctlOpts, ExecResult,
|
|
35
|
-
} from './types';
|
|
31
|
+
import type {XCRun, ExecOpts, SimctlOpts, ExecResult} from './types';
|
|
36
32
|
|
|
37
33
|
const SIMCTL_ENV_PREFIX = 'SIMCTL_CHILD_';
|
|
38
34
|
|
|
@@ -43,27 +39,27 @@ export class Simctl {
|
|
|
43
39
|
private _udid: string | null;
|
|
44
40
|
private _devicesSetPath: string | null;
|
|
45
41
|
|
|
46
|
-
constructor
|
|
47
|
-
this.xcrun = _.cloneDeep(opts.xcrun ?? {
|
|
42
|
+
constructor(opts: SimctlOpts = {}) {
|
|
43
|
+
this.xcrun = _.cloneDeep(opts.xcrun ?? {path: null});
|
|
48
44
|
this.execTimeout = opts.execTimeout ?? DEFAULT_EXEC_TIMEOUT;
|
|
49
45
|
this.logErrors = opts.logErrors ?? true;
|
|
50
46
|
this._udid = opts.udid ?? null;
|
|
51
47
|
this._devicesSetPath = opts.devicesSetPath ?? null;
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
set udid
|
|
50
|
+
set udid(value: string | null) {
|
|
55
51
|
this._udid = value;
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
get udid
|
|
54
|
+
get udid(): string | null {
|
|
59
55
|
return this._udid;
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
set devicesSetPath
|
|
58
|
+
set devicesSetPath(value: string | null) {
|
|
63
59
|
this._devicesSetPath = value;
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
get devicesSetPath
|
|
62
|
+
get devicesSetPath(): string | null {
|
|
67
63
|
return this._devicesSetPath;
|
|
68
64
|
}
|
|
69
65
|
|
|
@@ -72,10 +68,12 @@ export class Simctl {
|
|
|
72
68
|
* @returns The UDID string
|
|
73
69
|
* @throws {Error} If UDID is not set
|
|
74
70
|
*/
|
|
75
|
-
requireUdid
|
|
71
|
+
requireUdid(commandName: string | null = null): string {
|
|
76
72
|
if (!this.udid) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
|
|
73
|
+
throw new Error(
|
|
74
|
+
`udid is required to be set for ` +
|
|
75
|
+
(commandName ? `the '${commandName}' command` : 'this simctl command'),
|
|
76
|
+
);
|
|
79
77
|
}
|
|
80
78
|
return this.udid;
|
|
81
79
|
}
|
|
@@ -83,15 +81,17 @@ export class Simctl {
|
|
|
83
81
|
/**
|
|
84
82
|
* @returns Promise resolving to the xcrun binary path
|
|
85
83
|
*/
|
|
86
|
-
async requireXcrun
|
|
84
|
+
async requireXcrun(): Promise<string> {
|
|
87
85
|
const xcrunBinary = getXcrunBinary();
|
|
88
86
|
|
|
89
87
|
if (!this.xcrun.path) {
|
|
90
88
|
try {
|
|
91
89
|
this.xcrun.path = await which(xcrunBinary);
|
|
92
90
|
} catch {
|
|
93
|
-
throw new Error(
|
|
94
|
-
|
|
91
|
+
throw new Error(
|
|
92
|
+
`${xcrunBinary} tool has not been found in PATH. ` +
|
|
93
|
+
`Are Xcode developers tools installed?`,
|
|
94
|
+
);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
if (!this.xcrun.path) {
|
|
@@ -110,10 +110,7 @@ export class Simctl {
|
|
|
110
110
|
* `SubProcess` instance depending of `opts.asynchronous` value.
|
|
111
111
|
* @throws {Error} If the simctl subcommand command returns non-zero return code.
|
|
112
112
|
*/
|
|
113
|
-
async exec<T extends ExecOpts>
|
|
114
|
-
subcommand: string,
|
|
115
|
-
opts?: T
|
|
116
|
-
): Promise<ExecResult<T>> {
|
|
113
|
+
async exec<T extends ExecOpts>(subcommand: string, opts?: T): Promise<ExecResult<T>> {
|
|
117
114
|
const {
|
|
118
115
|
args: initialArgs = [],
|
|
119
116
|
env: initialEnv = {},
|
|
@@ -122,20 +119,21 @@ export class Simctl {
|
|
|
122
119
|
logErrors = true,
|
|
123
120
|
architectures,
|
|
124
121
|
timeout,
|
|
125
|
-
} = opts ?? {} as T;
|
|
122
|
+
} = opts ?? ({} as T);
|
|
126
123
|
// run a particular simctl command
|
|
127
124
|
const args = [
|
|
128
125
|
'simctl',
|
|
129
126
|
...(this.devicesSetPath ? ['--set', this.devicesSetPath] : []),
|
|
130
127
|
subcommand,
|
|
131
|
-
...initialArgs
|
|
128
|
+
...initialArgs,
|
|
132
129
|
];
|
|
133
130
|
// Prefix all passed in environment variables with 'SIMCTL_CHILD_', simctl
|
|
134
131
|
// will then pass these to the child (spawned) process.
|
|
135
132
|
const env = _.defaults(
|
|
136
|
-
_.mapKeys(initialEnv,
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
_.mapKeys(initialEnv, (value, key) =>
|
|
134
|
+
_.startsWith(key, SIMCTL_ENV_PREFIX) ? key : `${SIMCTL_ENV_PREFIX}${key}`,
|
|
135
|
+
),
|
|
136
|
+
process.env,
|
|
139
137
|
);
|
|
140
138
|
|
|
141
139
|
const execOpts: any = {
|
|
@@ -150,14 +148,19 @@ export class Simctl {
|
|
|
150
148
|
let execArgs: [string, string[], any];
|
|
151
149
|
if (architectures?.length) {
|
|
152
150
|
const archArgs = _.flatMap(
|
|
153
|
-
(_.isArray(architectures) ? architectures : [architectures]).map((arch) => [
|
|
151
|
+
(_.isArray(architectures) ? architectures : [architectures]).map((arch) => [
|
|
152
|
+
'-arch',
|
|
153
|
+
arch,
|
|
154
|
+
]),
|
|
154
155
|
);
|
|
155
156
|
execArgs = ['arch', [...archArgs, xcrun, ...args], execOpts];
|
|
156
157
|
} else {
|
|
157
158
|
execArgs = [xcrun, args, execOpts];
|
|
158
159
|
}
|
|
159
160
|
// We know what we are doing here - the type system can't handle the dynamic nature
|
|
160
|
-
return (
|
|
161
|
+
return (
|
|
162
|
+
asynchronous ? new SubProcess(...execArgs) : await tpExec(...execArgs)
|
|
163
|
+
) as ExecResult<T>;
|
|
161
164
|
} catch (e: any) {
|
|
162
165
|
if (!this.logErrors || !logErrors) {
|
|
163
166
|
// if we don't want to see the errors, just throw and allow the calling
|
|
@@ -218,4 +221,3 @@ export class Simctl {
|
|
|
218
221
|
}
|
|
219
222
|
|
|
220
223
|
export default Simctl;
|
|
221
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type {Simctl} from '../simctl';
|
|
2
|
+
import type {TeenProcessExecResult} from 'teen_process';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Add the particular media file to Simulator's library.
|
|
@@ -12,7 +12,10 @@ import type { TeenProcessExecResult } from 'teen_process';
|
|
|
12
12
|
* returns non-zero return code.
|
|
13
13
|
* @throws {Error} If the `udid` instance property is unset
|
|
14
14
|
*/
|
|
15
|
-
export async function addMedia
|
|
15
|
+
export async function addMedia(
|
|
16
|
+
this: Simctl,
|
|
17
|
+
filePath: string,
|
|
18
|
+
): Promise<TeenProcessExecResult<string>> {
|
|
16
19
|
return await this.exec('addmedia', {
|
|
17
20
|
args: [this.requireUdid('addmedia'), filePath],
|
|
18
21
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
import type {Simctl} from '../simctl';
|
|
2
|
+
import type {AppInfo} from '../types';
|
|
3
|
+
import {convertPlistToJson} from '../helpers';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -13,7 +13,7 @@ import _ from 'lodash';
|
|
|
13
13
|
* returns non-zero return code.
|
|
14
14
|
* @throws {Error} If the `udid` instance property is unset
|
|
15
15
|
*/
|
|
16
|
-
export async function appInfo
|
|
16
|
+
export async function appInfo(this: Simctl, bundleId: string): Promise<AppInfo> {
|
|
17
17
|
const {stdout} = await this.exec('appinfo', {
|
|
18
18
|
args: [this.requireUdid('appinfo'), bundleId],
|
|
19
19
|
});
|
|
@@ -26,7 +26,7 @@ export async function appInfo (this: Simctl, bundleId: string): Promise<AppInfo>
|
|
|
26
26
|
result = await convertPlistToJson(stdout);
|
|
27
27
|
} catch (err) {
|
|
28
28
|
throw new Error(
|
|
29
|
-
`Cannot retrieve app info for ${bundleId}: ${err instanceof Error ? err.message : String(err)}
|
|
29
|
+
`Cannot retrieve app info for ${bundleId}: ${err instanceof Error ? err.message : String(err)}`,
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
}
|
package/lib/subcommands/boot.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
2
|
+
import {log, LOG_PREFIX} from '../logger';
|
|
3
|
+
import type {Simctl} from '../simctl';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Boot the particular Simulator if it is not running.
|
|
@@ -9,10 +9,10 @@ import type { Simctl } from '../simctl';
|
|
|
9
9
|
* returns non-zero return code.
|
|
10
10
|
* @throws {Error} If the `udid` instance property is unset
|
|
11
11
|
*/
|
|
12
|
-
export async function bootDevice
|
|
12
|
+
export async function bootDevice(this: Simctl): Promise<void> {
|
|
13
13
|
try {
|
|
14
14
|
await this.exec('boot', {
|
|
15
|
-
args: [this.requireUdid('boot')]
|
|
15
|
+
args: [this.requireUdid('boot')],
|
|
16
16
|
});
|
|
17
17
|
} catch (e: any) {
|
|
18
18
|
if (_.includes(e.message, 'Unable to boot device in current state: Booted')) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {log} from '../logger';
|
|
2
|
+
import {waitForCondition} from 'asyncbox';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
4
|
+
import type {Simctl} from '../simctl';
|
|
5
|
+
import type {BootMonitorOptions} from '../types';
|
|
6
|
+
import type {SubProcess} from 'teen_process';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Start monitoring for boot status of the particular Simulator.
|
|
@@ -17,92 +17,94 @@ import type { SubProcess } from 'teen_process';
|
|
|
17
17
|
* property is not set.
|
|
18
18
|
* @throws {Error} If the `udid` instance property is unset
|
|
19
19
|
*/
|
|
20
|
-
export async function startBootMonitor
|
|
20
|
+
export async function startBootMonitor(
|
|
21
21
|
this: Simctl,
|
|
22
|
-
opts: BootMonitorOptions = {}
|
|
22
|
+
opts: BootMonitorOptions = {},
|
|
23
23
|
): Promise<SubProcess> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
const {
|
|
25
|
+
timeout = 240000,
|
|
26
|
+
onWaitingDataMigration,
|
|
27
|
+
onWaitingSystemApp,
|
|
28
|
+
onFinished,
|
|
29
|
+
onError,
|
|
30
|
+
shouldPreboot,
|
|
31
|
+
} = opts;
|
|
32
|
+
const udid = this.requireUdid('bootstatus');
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const status: string[] = [];
|
|
35
|
+
let isBootingFinished = false;
|
|
36
|
+
let error: Error | null = null;
|
|
37
|
+
let timeoutHandler: NodeJS.Timeout | null = null;
|
|
38
|
+
const args = [udid];
|
|
39
|
+
if (shouldPreboot) {
|
|
40
|
+
args.push('-b');
|
|
41
|
+
}
|
|
42
|
+
const bootMonitor = await this.exec('bootstatus', {
|
|
43
|
+
args,
|
|
44
|
+
asynchronous: true,
|
|
45
|
+
});
|
|
46
|
+
const onStreamLine = (line: string) => {
|
|
47
|
+
status.push(line);
|
|
48
|
+
if (onWaitingDataMigration && line.includes('Waiting on Data Migration')) {
|
|
49
|
+
onWaitingDataMigration();
|
|
50
|
+
} else if (onWaitingSystemApp && line.includes('Waiting on System App')) {
|
|
51
|
+
onWaitingSystemApp();
|
|
41
52
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onWaitingDataMigration();
|
|
50
|
-
} else if (onWaitingSystemApp && line.includes('Waiting on System App')) {
|
|
51
|
-
onWaitingSystemApp();
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
for (const streamName of ['stdout', 'stderr']) {
|
|
55
|
-
bootMonitor.on(`line-${streamName}`, onStreamLine);
|
|
53
|
+
};
|
|
54
|
+
for (const streamName of ['stdout', 'stderr']) {
|
|
55
|
+
bootMonitor.on(`line-${streamName}`, onStreamLine);
|
|
56
|
+
}
|
|
57
|
+
bootMonitor.once('exit', (code, signal) => {
|
|
58
|
+
if (timeoutHandler) {
|
|
59
|
+
clearTimeout(timeoutHandler);
|
|
56
60
|
}
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
if (code === 0) {
|
|
62
|
-
if (onFinished) {
|
|
63
|
-
onFinished();
|
|
64
|
-
}
|
|
65
|
-
isBootingFinished = true;
|
|
66
|
-
} else {
|
|
67
|
-
const errMessage = _.isEmpty(status)
|
|
68
|
-
? `The simulator booting process has exited with code ${code} by signal ${signal}`
|
|
69
|
-
: status.join('\n');
|
|
70
|
-
error = new Error(errMessage);
|
|
71
|
-
if (onError) {
|
|
72
|
-
onError(error);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
await bootMonitor.start(0);
|
|
77
|
-
const stopMonitor = async () => {
|
|
78
|
-
if (bootMonitor.isRunning) {
|
|
79
|
-
try {
|
|
80
|
-
await bootMonitor.stop();
|
|
81
|
-
} catch (e: any) {
|
|
82
|
-
log.warn(e.message);
|
|
83
|
-
}
|
|
61
|
+
if (code === 0) {
|
|
62
|
+
if (onFinished) {
|
|
63
|
+
onFinished();
|
|
84
64
|
}
|
|
85
|
-
|
|
86
|
-
const start = process.hrtime();
|
|
87
|
-
if (onFinished) {
|
|
88
|
-
timeoutHandler = setTimeout(stopMonitor, timeout);
|
|
65
|
+
isBootingFinished = true;
|
|
89
66
|
} else {
|
|
67
|
+
const errMessage = _.isEmpty(status)
|
|
68
|
+
? `The simulator booting process has exited with code ${code} by signal ${signal}`
|
|
69
|
+
: status.join('\n');
|
|
70
|
+
error = new Error(errMessage);
|
|
71
|
+
if (onError) {
|
|
72
|
+
onError(error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
await bootMonitor.start(0);
|
|
77
|
+
const stopMonitor = async () => {
|
|
78
|
+
if (bootMonitor.isRunning) {
|
|
90
79
|
try {
|
|
91
|
-
await
|
|
80
|
+
await bootMonitor.stop();
|
|
81
|
+
} catch (e: any) {
|
|
82
|
+
log.warn(e.message);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const start = process.hrtime();
|
|
87
|
+
if (onFinished) {
|
|
88
|
+
timeoutHandler = setTimeout(stopMonitor, timeout);
|
|
89
|
+
} else {
|
|
90
|
+
try {
|
|
91
|
+
await waitForCondition(
|
|
92
|
+
() => {
|
|
92
93
|
if (error) {
|
|
93
94
|
throw error;
|
|
94
95
|
}
|
|
95
96
|
return isBootingFinished;
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
},
|
|
98
|
+
{waitMs: timeout, intervalMs: 500},
|
|
99
|
+
);
|
|
100
|
+
} catch {
|
|
101
|
+
await stopMonitor();
|
|
102
|
+
const [seconds] = process.hrtime(start);
|
|
103
|
+
throw new Error(
|
|
104
|
+
`The simulator ${udid} has failed to finish booting after ${seconds}s. ` +
|
|
105
|
+
`Original status: ${status.join('\n')}`,
|
|
106
|
+
);
|
|
105
107
|
}
|
|
106
|
-
|
|
108
|
+
}
|
|
109
|
+
return bootMonitor;
|
|
107
110
|
}
|
|
108
|
-
|