@swipt/cli 0.1.0-nightly.48 → 0.1.0-nightly.49
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/coredevice.mjs +9 -4
- package/package.json +4 -4
- package/sideload.mjs +34 -3
package/coredevice.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import os from "node:os";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import { promisify } from "node:util";
|
|
6
7
|
|
|
7
8
|
import { label, sameName } from "./connection.mjs";
|
|
8
|
-
import { choose, step } from "./output.mjs";
|
|
9
|
+
import { choose, interactive, step } from "./output.mjs";
|
|
9
10
|
|
|
10
11
|
const exec = promisify(execFile);
|
|
11
12
|
|
|
@@ -14,7 +15,7 @@ const xcodeMissing =
|
|
|
14
15
|
|
|
15
16
|
export async function devicectl(args, { parse = false } = {}) {
|
|
16
17
|
const output = parse
|
|
17
|
-
? path.join(os.tmpdir(), `devicectl-${
|
|
18
|
+
? path.join(os.tmpdir(), `devicectl-${randomUUID()}.json`)
|
|
18
19
|
: undefined;
|
|
19
20
|
try {
|
|
20
21
|
await exec(
|
|
@@ -54,7 +55,7 @@ const reachability =
|
|
|
54
55
|
const deviceLine = (device) =>
|
|
55
56
|
` ${device.name} ${device.udid}${device.offline ? " (offline)" : ""}`;
|
|
56
57
|
|
|
57
|
-
export async function coreDevice(context, { required = true } = {}) {
|
|
58
|
+
export async function coreDevice(context, { required = true, filter } = {}) {
|
|
58
59
|
const given = context.options.device;
|
|
59
60
|
const listed = await step(
|
|
60
61
|
"looking for devices",
|
|
@@ -104,10 +105,14 @@ export async function coreDevice(context, { required = true } = {}) {
|
|
|
104
105
|
if (matches.length === 0) {
|
|
105
106
|
throw failure;
|
|
106
107
|
}
|
|
108
|
+
const choices =
|
|
109
|
+
filter !== undefined && interactive(context)
|
|
110
|
+
? await filter(matches)
|
|
111
|
+
: matches;
|
|
107
112
|
return choose(
|
|
108
113
|
context,
|
|
109
114
|
"Choose a device",
|
|
110
|
-
|
|
115
|
+
choices.map((device) => ({
|
|
111
116
|
name: `${device.name} ${device.udid}`,
|
|
112
117
|
short: device.name,
|
|
113
118
|
value: device,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swipt/cli",
|
|
3
|
-
"version": "0.1.0-nightly.
|
|
3
|
+
"version": "0.1.0-nightly.49",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"react-native-worklets": "0.13.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@swipt/api": "0.1.0-nightly.
|
|
37
|
+
"@swipt/api": "0.1.0-nightly.49"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@swipt/server-darwin-arm64": "0.1.0-nightly.
|
|
41
|
-
"@swipt/server-darwin-x64": "0.1.0-nightly.
|
|
40
|
+
"@swipt/server-darwin-arm64": "0.1.0-nightly.49",
|
|
41
|
+
"@swipt/server-darwin-x64": "0.1.0-nightly.49"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@bufbuild/protoc-gen-es": "^2.16.0"
|
package/sideload.mjs
CHANGED
|
@@ -478,6 +478,32 @@ const teamChoice = ({ id, name }) => ({
|
|
|
478
478
|
value: id,
|
|
479
479
|
});
|
|
480
480
|
|
|
481
|
+
const installHint = '; install it with "swipt sideload install"';
|
|
482
|
+
|
|
483
|
+
async function sideloadedDevices(devices, hint = "") {
|
|
484
|
+
const sideloaded = await step(
|
|
485
|
+
"looking for Swipt on the devices",
|
|
486
|
+
() =>
|
|
487
|
+
Promise.all(
|
|
488
|
+
devices.map((device) =>
|
|
489
|
+
apps(device.udid).then(
|
|
490
|
+
(listed) =>
|
|
491
|
+
listed.some((app) =>
|
|
492
|
+
sideloadedPattern.test(app.bundleIdentifier),
|
|
493
|
+
),
|
|
494
|
+
() => true,
|
|
495
|
+
),
|
|
496
|
+
),
|
|
497
|
+
),
|
|
498
|
+
{ transient: true },
|
|
499
|
+
);
|
|
500
|
+
const found = devices.filter((_, index) => sideloaded[index]);
|
|
501
|
+
if (found.length === 0) {
|
|
502
|
+
throw new Error(`Swipt is not sideloaded on any online iOS device${hint}`);
|
|
503
|
+
}
|
|
504
|
+
return found;
|
|
505
|
+
}
|
|
506
|
+
|
|
481
507
|
async function locate(context, device, fresh = false) {
|
|
482
508
|
const { options } = context;
|
|
483
509
|
const listed = await step(
|
|
@@ -610,11 +636,16 @@ async function askPasscode(context) {
|
|
|
610
636
|
}
|
|
611
637
|
|
|
612
638
|
async function deploy(context, onlyNewer) {
|
|
613
|
-
const device = await coreDevice(
|
|
639
|
+
const device = await coreDevice(
|
|
640
|
+
context,
|
|
641
|
+
onlyNewer
|
|
642
|
+
? { filter: (devices) => sideloadedDevices(devices, installHint) }
|
|
643
|
+
: undefined,
|
|
644
|
+
);
|
|
614
645
|
const { team, current } = await locate(context, device, !onlyNewer);
|
|
615
646
|
if (current === undefined && onlyNewer) {
|
|
616
647
|
throw new Error(
|
|
617
|
-
`Swipt is not sideloaded on ${device.name}${team === undefined ? "" : ` by team ${team}`}
|
|
648
|
+
`Swipt is not sideloaded on ${device.name}${team === undefined ? "" : ` by team ${team}`}${installHint}`,
|
|
618
649
|
);
|
|
619
650
|
}
|
|
620
651
|
const passcode =
|
|
@@ -1058,7 +1089,7 @@ async function trustAndOpen(context, device, id, passcode) {
|
|
|
1058
1089
|
}
|
|
1059
1090
|
|
|
1060
1091
|
export async function uninstall(context) {
|
|
1061
|
-
const device = await coreDevice(context);
|
|
1092
|
+
const device = await coreDevice(context, { filter: sideloadedDevices });
|
|
1062
1093
|
const { team, current } = await locate(context, device);
|
|
1063
1094
|
if (current === undefined) {
|
|
1064
1095
|
throw new Error(
|