@swipt/cli 0.1.0-nightly.97 → 0.1.0-nightly.99
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/dist/availability.d.ts +3 -1
- package/dist/availability.js +173 -151
- package/dist/availability.js.map +1 -1
- package/dist/cli/cli.js +52 -66
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/command.d.ts +9 -0
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/commands/data/clear.js +2 -2
- package/dist/cli/commands/data/clear.js.map +1 -1
- package/dist/cli/commands/data/data.js +2 -2
- package/dist/cli/commands/data/data.js.map +1 -1
- package/dist/cli/commands/data/list.js +3 -3
- package/dist/cli/commands/data/list.js.map +1 -1
- package/dist/cli/commands/data/operand.js.map +1 -1
- package/dist/cli/commands/data/read.js +4 -7
- package/dist/cli/commands/data/read.js.map +1 -1
- package/dist/cli/commands/data/remove.js +3 -3
- package/dist/cli/commands/data/remove.js.map +1 -1
- package/dist/cli/commands/data/write.js +2 -2
- package/dist/cli/commands/data/write.js.map +1 -1
- package/dist/cli/commands/device/add.js +2 -2
- package/dist/cli/commands/device/add.js.map +1 -1
- package/dist/cli/commands/device/device.js +2 -2
- package/dist/cli/commands/device/device.js.map +1 -1
- package/dist/cli/commands/device/list.js +2 -2
- package/dist/cli/commands/device/list.js.map +1 -1
- package/dist/cli/commands/device/logs.js +44 -46
- package/dist/cli/commands/device/logs.js.map +1 -1
- package/dist/cli/commands/device/remove.js +2 -2
- package/dist/cli/commands/device/remove.js.map +1 -1
- package/dist/cli/commands/device/stop.js +3 -3
- package/dist/cli/commands/device/stop.js.map +1 -1
- package/dist/cli/commands/driver/driver.js +6 -6
- package/dist/cli/commands/driver/driver.js.map +1 -1
- package/dist/cli/commands/flags.js +9 -9
- package/dist/cli/commands/flags.js.map +1 -1
- package/dist/cli/commands/index.js +2 -2
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/project/build.js +2 -2
- package/dist/cli/commands/project/build.js.map +1 -1
- package/dist/cli/commands/project/create.js +3 -3
- package/dist/cli/commands/project/create.js.map +1 -1
- package/dist/cli/commands/project/deploy.js +2 -2
- package/dist/cli/commands/project/deploy.js.map +1 -1
- package/dist/cli/commands/project/develop.js +19 -19
- package/dist/cli/commands/project/develop.js.map +1 -1
- package/dist/cli/commands/project/project.js +2 -2
- package/dist/cli/commands/project/project.js.map +1 -1
- package/dist/cli/commands/project/source.js +62 -37
- package/dist/cli/commands/project/source.js.map +1 -1
- package/dist/cli/commands/repl/api.js +2 -2
- package/dist/cli/commands/repl/api.js.map +1 -1
- package/dist/cli/commands/repl/repl.js +4 -4
- package/dist/cli/commands/repl/repl.js.map +1 -1
- package/dist/cli/commands/repl/reset.js +2 -2
- package/dist/cli/commands/repl/reset.js.map +1 -1
- package/dist/cli/commands/repl/run.js +5 -5
- package/dist/cli/commands/repl/run.js.map +1 -1
- package/dist/cli/commands/sideload/install.js +4 -4
- package/dist/cli/commands/sideload/install.js.map +1 -1
- package/dist/cli/commands/sideload/setup.js +3 -3
- package/dist/cli/commands/sideload/setup.js.map +1 -1
- package/dist/cli/commands/sideload/sideload.js +2 -2
- package/dist/cli/commands/sideload/sideload.js.map +1 -1
- package/dist/cli/commands/sideload/uninstall.js +2 -2
- package/dist/cli/commands/sideload/uninstall.js.map +1 -1
- package/dist/cli/commands/sideload/update.js +3 -3
- package/dist/cli/commands/sideload/update.js.map +1 -1
- package/dist/cli/commands/swiplet/call.js +6 -6
- package/dist/cli/commands/swiplet/call.js.map +1 -1
- package/dist/cli/commands/swiplet/install.js +3 -3
- package/dist/cli/commands/swiplet/install.js.map +1 -1
- package/dist/cli/commands/swiplet/list.js +8 -8
- package/dist/cli/commands/swiplet/list.js.map +1 -1
- package/dist/cli/commands/swiplet/remove.js +3 -3
- package/dist/cli/commands/swiplet/remove.js.map +1 -1
- package/dist/cli/commands/swiplet/service/disable.js +3 -3
- package/dist/cli/commands/swiplet/service/disable.js.map +1 -1
- package/dist/cli/commands/swiplet/service/enable.js +3 -3
- package/dist/cli/commands/swiplet/service/enable.js.map +1 -1
- package/dist/cli/commands/swiplet/service/service.js +2 -2
- package/dist/cli/commands/swiplet/service/service.js.map +1 -1
- package/dist/cli/commands/swiplet/service/services.js +2 -2
- package/dist/cli/commands/swiplet/service/services.js.map +1 -1
- package/dist/cli/commands/swiplet/service/watch.js +2 -2
- package/dist/cli/commands/swiplet/service/watch.js.map +1 -1
- package/dist/cli/commands/swiplet/show.js +6 -6
- package/dist/cli/commands/swiplet/show.js.map +1 -1
- package/dist/cli/commands/swiplet/swiplet.js +4 -4
- package/dist/cli/commands/swiplet/swiplet.js.map +1 -1
- package/dist/cli/commands/version/version.js +2 -2
- package/dist/cli/commands/version/version.js.map +1 -1
- package/dist/cli/deploy.js +9 -7
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/session.js.map +1 -1
- package/dist/client.d.ts +145 -7
- package/dist/client.js +20 -22
- package/dist/client.js.map +1 -1
- package/dist/connection.d.ts +292 -25
- package/dist/connection.js +36 -35
- package/dist/connection.js.map +1 -1
- package/dist/driver.d.ts +62 -23
- package/dist/driver.js +29 -33
- package/dist/driver.js.map +1 -1
- package/dist/i18n.d.ts +2 -5
- package/dist/i18n.js +15 -13
- package/dist/i18n.js.map +1 -1
- package/dist/i18next.d.ts +7 -0
- package/dist/ignore.d.ts +14 -7
- package/dist/ignore.js +13 -14
- package/dist/ignore.js.map +1 -1
- package/dist/mdns.d.ts +2 -2
- package/dist/mdns.js +1 -1
- package/dist/mdns.js.map +1 -1
- package/dist/metro.d.ts +19 -5
- package/dist/metro.js +61 -63
- package/dist/metro.js.map +1 -1
- package/dist/output.d.ts +29 -14
- package/dist/output.js +17 -15
- package/dist/output.js.map +1 -1
- package/dist/passcode.d.ts +12 -8
- package/dist/passcode.js +18 -18
- package/dist/passcode.js.map +1 -1
- package/dist/project.d.ts +20 -10
- package/dist/project.js +72 -49
- package/dist/project.js.map +1 -1
- package/dist/proto/common_pb.d.ts +240 -0
- package/dist/proto/common_pb.js +7 -2
- package/dist/proto/common_pb.js.map +1 -1
- package/dist/proto/logs_pb.d.ts +38 -0
- package/dist/proto/repl_pb.d.ts +96 -0
- package/dist/proto/swiplets_pb.d.ts +361 -0
- package/dist/proto/swiplets_pb.js +7 -2
- package/dist/proto/swiplets_pb.js.map +1 -1
- package/dist/proto/system_pb.d.ts +33 -0
- package/dist/resources.d.ts +400 -0
- package/dist/serve.d.ts +9 -1
- package/dist/serve.js +17 -16
- package/dist/serve.js.map +1 -1
- package/dist/sideload.d.ts +27 -14
- package/dist/sideload.js +102 -89
- package/dist/sideload.js.map +1 -1
- package/dist/swipt-app.d.ts +19 -9
- package/dist/swipt-app.js +1 -1
- package/dist/swipt-app.js.map +1 -1
- package/locales/ar/translation.json +413 -0
- package/locales/bg/translation.json +397 -0
- package/locales/bn/translation.json +397 -0
- package/locales/ca/translation.json +401 -0
- package/locales/cs/translation.json +405 -0
- package/locales/da/translation.json +397 -0
- package/locales/de/translation.json +397 -0
- package/locales/el/translation.json +397 -0
- package/locales/en/translation.json +397 -0
- package/locales/es/translation.json +401 -0
- package/locales/es-419/translation.json +401 -0
- package/locales/fi/translation.json +397 -0
- package/locales/fr/translation.json +401 -0
- package/locales/fr-CA/translation.json +401 -0
- package/locales/gu/translation.json +397 -0
- package/locales/he/translation.json +401 -0
- package/locales/hi/translation.json +397 -0
- package/locales/hr/translation.json +401 -0
- package/locales/hu/translation.json +397 -0
- package/locales/id/translation.json +393 -0
- package/locales/it/translation.json +401 -0
- package/locales/ja/translation.json +393 -0
- package/locales/kk/translation.json +397 -0
- package/locales/kn/translation.json +397 -0
- package/locales/ko/translation.json +393 -0
- package/locales/lt/translation.json +405 -0
- package/locales/ml/translation.json +397 -0
- package/locales/mr/translation.json +397 -0
- package/locales/ms/translation.json +393 -0
- package/locales/nb/translation.json +397 -0
- package/locales/nl/translation.json +397 -0
- package/locales/or/translation.json +397 -0
- package/locales/pa/translation.json +397 -0
- package/locales/pl/translation.json +405 -0
- package/locales/pt-BR/translation.json +401 -0
- package/locales/pt-PT/translation.json +401 -0
- package/locales/ro/translation.json +401 -0
- package/locales/ru/translation.json +405 -0
- package/locales/sk/translation.json +405 -0
- package/locales/sl/translation.json +405 -0
- package/locales/sv/translation.json +397 -0
- package/locales/ta/translation.json +397 -0
- package/locales/te/translation.json +397 -0
- package/locales/th/translation.json +393 -0
- package/locales/tr/translation.json +397 -0
- package/locales/uk/translation.json +405 -0
- package/locales/ur/translation.json +397 -0
- package/locales/vi/translation.json +397 -0
- package/locales/zh-HK/translation.json +393 -0
- package/locales/zh-Hans/translation.json +393 -0
- package/locales/zh-Hant/translation.json +393 -0
- package/package.json +14 -9
- package/locales/ar.json +0 -311
- package/locales/bg.json +0 -295
- package/locales/bn.json +0 -295
- package/locales/ca.json +0 -299
- package/locales/cs.json +0 -303
- package/locales/da.json +0 -295
- package/locales/de.json +0 -295
- package/locales/el.json +0 -295
- package/locales/es-419.json +0 -299
- package/locales/es.json +0 -299
- package/locales/fi.json +0 -295
- package/locales/fr-CA.json +0 -299
- package/locales/fr.json +0 -299
- package/locales/gu.json +0 -295
- package/locales/he.json +0 -299
- package/locales/hi.json +0 -295
- package/locales/hr.json +0 -299
- package/locales/hu.json +0 -295
- package/locales/id.json +0 -283
- package/locales/it.json +0 -299
- package/locales/ja.json +0 -283
- package/locales/kk.json +0 -295
- package/locales/kn.json +0 -295
- package/locales/ko.json +0 -283
- package/locales/lt.json +0 -303
- package/locales/ml.json +0 -295
- package/locales/mr.json +0 -295
- package/locales/ms.json +0 -283
- package/locales/nb.json +0 -295
- package/locales/nl.json +0 -295
- package/locales/or.json +0 -295
- package/locales/pa.json +0 -295
- package/locales/pl.json +0 -303
- package/locales/pt-BR.json +0 -299
- package/locales/pt-PT.json +0 -299
- package/locales/ro.json +0 -299
- package/locales/ru.json +0 -303
- package/locales/sk.json +0 -303
- package/locales/sl.json +0 -303
- package/locales/sv.json +0 -295
- package/locales/ta.json +0 -295
- package/locales/te.json +0 -295
- package/locales/th.json +0 -283
- package/locales/tr.json +0 -295
- package/locales/uk.json +0 -303
- package/locales/ur.json +0 -295
- package/locales/vi.json +0 -295
- package/locales/zh-HK.json +0 -283
- package/locales/zh-Hans.json +0 -283
- package/locales/zh-Hant.json +0 -283
package/dist/sideload.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UsageError, open } from "./client.js";
|
|
2
2
|
import { findPublished, runningSwipt, tryUnlock, withToken } from "./connection.js";
|
|
3
3
|
import { cacheDirectory } from "./directories.js";
|
|
4
|
-
import { apps, configureVirtual, failures, installApp, launchApp, mountDiskImage, openSettings, provisioningProfiles, randomToken, serve, terminateApp, trustedDevice, uninstallApp } from "./driver.js";
|
|
5
|
-
import { language,
|
|
6
|
-
import { choose, columns, interactive, printScriptError, selectTheme, step } from "./output.js";
|
|
4
|
+
import { DriverError, apps, configureVirtual, failures, installApp, launchApp, mountDiskImage, openSettings, provisioningProfiles, randomToken, serve, terminateApp, trustedDevice, uninstallApp } from "./driver.js";
|
|
5
|
+
import { language, t } from "./i18n.js";
|
|
6
|
+
import { choose, columns, errorMessage, interactive, printScriptError, selectTheme, step } from "./output.js";
|
|
7
7
|
import { askPasscode, passcodeOf } from "./passcode.js";
|
|
8
8
|
import "./proto/common_pb.js";
|
|
9
9
|
import { bundleId, bundleTeam, hasPairing, publishArgument, savePairing, savePreferences, savedPasscode, setUpAutoUnlock, setupArgument, swiptApps, teamPattern } from "./swipt-app.js";
|
|
@@ -18,6 +18,13 @@ import { X509Certificate, createHash } from "node:crypto";
|
|
|
18
18
|
import { Readable } from "node:stream";
|
|
19
19
|
import { pipeline } from "node:stream/promises";
|
|
20
20
|
// src/sideload.ts
|
|
21
|
+
var GitHubError = class extends Error {
|
|
22
|
+
status;
|
|
23
|
+
constructor(message, status) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.status = status;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
21
28
|
const exec = promisify(execFile);
|
|
22
29
|
const repository = "swipt-automation/swipt";
|
|
23
30
|
const guestTeam = "SWIPTLOCAL";
|
|
@@ -45,9 +52,10 @@ const guestEntitlements = (id) => `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
45
52
|
const accountsHint = "Xcode › Settings › Accounts";
|
|
46
53
|
const xcodeProfiles = "Library/Developer/Xcode/UserData/Provisioning Profiles";
|
|
47
54
|
const downloads = path.join(cacheDirectory, "sideload");
|
|
48
|
-
const signingNeedsMac =
|
|
55
|
+
const signingNeedsMac = t("sideload.needsMacOS");
|
|
49
56
|
const expiresSoon = ({ creation, expiration }) => expiration - Date.now() < (expiration - creation) / 2;
|
|
50
|
-
const plistValueMissing = /No value at that key path
|
|
57
|
+
const plistValueMissing = (error) => error instanceof Error && "stderr" in error && typeof error.stderr === "string" && /No value at that key path/.test(error.stderr);
|
|
58
|
+
const failedWith = (error, code) => error instanceof DriverError && error.code === code;
|
|
51
59
|
function headers(accept) {
|
|
52
60
|
const token = process.env.GITHUB_TOKEN;
|
|
53
61
|
return {
|
|
@@ -63,7 +71,8 @@ async function github(url, accept, signal) {
|
|
|
63
71
|
signal,
|
|
64
72
|
redirect: "manual"
|
|
65
73
|
});
|
|
66
|
-
|
|
74
|
+
const location = response.headers.get("location");
|
|
75
|
+
if (response.status >= 300 && response.status < 400 && location !== null) response = await fetch(location, { signal });
|
|
67
76
|
if (!response.ok) {
|
|
68
77
|
let message = `GitHub answered ${response.status} for ${url}`;
|
|
69
78
|
if ([
|
|
@@ -71,16 +80,14 @@ async function github(url, accept, signal) {
|
|
|
71
80
|
403,
|
|
72
81
|
429
|
|
73
82
|
].includes(response.status)) message += `; ${process.env.GITHUB_TOKEN ? "GITHUB_TOKEN" : "set GITHUB_TOKEN to a token that"} must read the repository and stay under the rate limit`;
|
|
74
|
-
|
|
75
|
-
error.status = response.status;
|
|
76
|
-
throw error;
|
|
83
|
+
throw new GitHubError(message, response.status);
|
|
77
84
|
}
|
|
78
85
|
return response;
|
|
79
86
|
}
|
|
80
87
|
async function findRelease(nightly, signal) {
|
|
81
|
-
const read = async (name) => (await github(`https://api.github.com/repos/${repository}/releases/${name}`, "application/vnd.github+json", signal)).json();
|
|
88
|
+
const read = async (name) => await (await github(`https://api.github.com/repos/${repository}/releases/${name}`, "application/vnd.github+json", signal)).json();
|
|
82
89
|
const release = nightly ? await read("tags/nightly") : await read("latest").catch((error) => {
|
|
83
|
-
if (error.status !== 404) throw error;
|
|
90
|
+
if (!(error instanceof GitHubError) || error.status !== 404) throw error;
|
|
84
91
|
return read("tags/nightly");
|
|
85
92
|
});
|
|
86
93
|
const asset = (name) => {
|
|
@@ -92,12 +99,13 @@ async function findRelease(nightly, signal) {
|
|
|
92
99
|
return {
|
|
93
100
|
tag: release.tag_name,
|
|
94
101
|
version: metadata.version,
|
|
95
|
-
build:
|
|
102
|
+
build: metadata.build,
|
|
96
103
|
ipa: asset("Swipt.ipa")
|
|
97
104
|
};
|
|
98
105
|
}
|
|
99
106
|
async function download(url, file, signal, update) {
|
|
100
107
|
const response = await github(url, "application/octet-stream", signal);
|
|
108
|
+
if (response.body === null) throw new Error(`GitHub answered ${response.status} without a body for ${url}`);
|
|
101
109
|
const total = Number(response.headers.get("content-length"));
|
|
102
110
|
const megabytes = (bytes) => (bytes / 1e6).toFixed(1);
|
|
103
111
|
let received = 0;
|
|
@@ -179,16 +187,16 @@ const pbxproj = (id, team) => `// !$*UTF8*$!
|
|
|
179
187
|
`;
|
|
180
188
|
function explain(output, team) {
|
|
181
189
|
const errors = [...new Set(output.split("\n").filter((line) => /^(xcodebuild: )?error: /.test(line)).map((line) => line.replace(/^(xcodebuild: )?error: /, "")))].join("; ");
|
|
182
|
-
if (/No Accounts?\b/.test(output)) return
|
|
190
|
+
if (/No Accounts?\b/.test(output)) return t("sideload.noAccountForTeam", {
|
|
183
191
|
team,
|
|
184
192
|
accounts: accountsHint
|
|
185
193
|
});
|
|
186
|
-
if (/signing certificate|certificateType/i.test(output)) return
|
|
194
|
+
if (/signing certificate|certificateType/i.test(output)) return t("sideload.certificateFailed", {
|
|
187
195
|
team,
|
|
188
196
|
accounts: accountsHint,
|
|
189
197
|
errors
|
|
190
198
|
});
|
|
191
|
-
if (/requires Xcode|xcode-select/.test(output)) return
|
|
199
|
+
if (/requires Xcode|xcode-select/.test(output)) return t("sideload.xcodeMissing");
|
|
192
200
|
return errors || output.trim();
|
|
193
201
|
}
|
|
194
202
|
function profileField(file, key) {
|
|
@@ -267,16 +275,17 @@ async function provision(work, id, team, device, update) {
|
|
|
267
275
|
"-allowProvisioningUpdates",
|
|
268
276
|
"-allowProvisioningDeviceRegistration"
|
|
269
277
|
], { maxBuffer: Infinity });
|
|
270
|
-
running.child.stdout
|
|
278
|
+
running.child.stdout?.on("data", (chunk) => {
|
|
271
279
|
const line = String(chunk).split("\n").findLast((it) => /^[A-Z]\w* /.test(it));
|
|
272
280
|
if (line) update(line.split(" ")[0]);
|
|
273
281
|
});
|
|
274
282
|
try {
|
|
275
283
|
await running;
|
|
276
284
|
} catch (error) {
|
|
277
|
-
|
|
278
|
-
if (
|
|
279
|
-
|
|
285
|
+
const failure = error;
|
|
286
|
+
if (failure.code === "ENOENT") throw new Error(t("sideload.xcodebuildMissing"));
|
|
287
|
+
if (typeof failure.code !== "number") throw error;
|
|
288
|
+
throw new Error(explain(`${failure.stdout}${failure.stderr}`, team));
|
|
280
289
|
}
|
|
281
290
|
};
|
|
282
291
|
const certificates = path.join(work, "certificate");
|
|
@@ -332,9 +341,12 @@ async function resign(app, id, signing, update) {
|
|
|
332
341
|
"-o",
|
|
333
342
|
"-",
|
|
334
343
|
info
|
|
335
|
-
], {
|
|
344
|
+
], {
|
|
345
|
+
stdio: "pipe",
|
|
346
|
+
encoding: "utf8"
|
|
347
|
+
}));
|
|
336
348
|
} catch (error) {
|
|
337
|
-
if (!plistValueMissing
|
|
349
|
+
if (!plistValueMissing(error)) throw error;
|
|
338
350
|
}
|
|
339
351
|
if (permitted !== void 0) execFileSync("plutil", [
|
|
340
352
|
"-replace",
|
|
@@ -413,7 +425,7 @@ function xcodeSignedIn() {
|
|
|
413
425
|
}));
|
|
414
426
|
return Object.values(lists).some((accounts) => accounts.length > 0);
|
|
415
427
|
} catch (error) {
|
|
416
|
-
if (plistValueMissing
|
|
428
|
+
if (plistValueMissing(error)) return false;
|
|
417
429
|
throw error;
|
|
418
430
|
}
|
|
419
431
|
}
|
|
@@ -423,18 +435,18 @@ const teamChoice = ({ id, name }) => ({
|
|
|
423
435
|
short: name ?? id,
|
|
424
436
|
value: id
|
|
425
437
|
});
|
|
426
|
-
async function sideloadedDevices(devices, missing =
|
|
427
|
-
const sideloaded = await step(
|
|
438
|
+
async function sideloadedDevices(devices, missing = t("sideload.noneInstalled")) {
|
|
439
|
+
const sideloaded = await step(t("sideload.looking"), () => Promise.all(devices.map((device) => swiptApps(device).then((found) => found.length > 0, () => true))), { transient: true });
|
|
428
440
|
const found = devices.filter((_, index) => sideloaded[index]);
|
|
429
441
|
if (found.length === 0) throw new Error(missing);
|
|
430
442
|
return found;
|
|
431
443
|
}
|
|
432
444
|
async function locate(context, device, fresh = false) {
|
|
433
445
|
const { options } = context;
|
|
434
|
-
const found = await step(
|
|
446
|
+
const found = await step(t("sideload.checking", { device: device.name }), () => swiptApps(device), { transient: true });
|
|
435
447
|
if (device.virtual) return { current: found.find((app) => app.bundleIdentifier === bundleId) };
|
|
436
448
|
if (options.team !== void 0) {
|
|
437
|
-
if (!teamPattern.test(options.team)) throw new UsageError(
|
|
449
|
+
if (!teamPattern.test(options.team)) throw new UsageError(t("sideload.invalidTeam", {
|
|
438
450
|
value: JSON.stringify(options.team),
|
|
439
451
|
accounts: accountsHint
|
|
440
452
|
}));
|
|
@@ -449,7 +461,7 @@ async function locate(context, device, fresh = false) {
|
|
|
449
461
|
id: app.team,
|
|
450
462
|
name: known.find((team) => team.id === app.team)?.name
|
|
451
463
|
}));
|
|
452
|
-
const team = await choose(context,
|
|
464
|
+
const team = await choose(context, t("sideload.chooseTeam"), teams.map(teamChoice), /* @__PURE__ */ new Error(`${t("sideload.ambiguousTeam", { device: device.name })}\n${teamList(teams)}`));
|
|
453
465
|
return {
|
|
454
466
|
team,
|
|
455
467
|
current: found.find((app) => app.team === team)
|
|
@@ -458,9 +470,9 @@ async function locate(context, device, fresh = false) {
|
|
|
458
470
|
if (found.length === 0 && fresh) {
|
|
459
471
|
if (process.platform !== "darwin") throw new Error(signingNeedsMac);
|
|
460
472
|
const teams = xcodeTeams();
|
|
461
|
-
if (teams.length === 0) throw new Error(xcodeSignedIn() ?
|
|
473
|
+
if (teams.length === 0) throw new Error(xcodeSignedIn() ? t("sideload.noCertificate", { accounts: accountsHint }) : t("sideload.noAccount", { accounts: accountsHint }));
|
|
462
474
|
return {
|
|
463
|
-
team: teams.some((it) => it.id === "P8XK3KHB48") ? bundleTeam : teams.length === 1 ? teams[0].id : await choose(context,
|
|
475
|
+
team: teams.some((it) => it.id === "P8XK3KHB48") ? bundleTeam : teams.length === 1 ? teams[0].id : await choose(context, t("sideload.chooseTeam"), teams.map(teamChoice), /* @__PURE__ */ new Error(`${t("sideload.chooseTeamHint")}\n${teamList(teams)}`)),
|
|
464
476
|
current: void 0
|
|
465
477
|
};
|
|
466
478
|
}
|
|
@@ -472,7 +484,7 @@ async function locate(context, device, fresh = false) {
|
|
|
472
484
|
const buildText = (app) => `Swipt ${app.version} (${app.bundleVersion})`;
|
|
473
485
|
async function signingPeriod(device, id, team) {
|
|
474
486
|
const names = [id, "*"].map((it) => `iOS Team Provisioning Profile: ${it}`);
|
|
475
|
-
return (await step(
|
|
487
|
+
return (await step(t("sideload.checking", { device: device.name }), () => provisioningProfiles(device), { transient: true })).filter((profile) => profile.teamIdentifier === team && names.includes(profile.name)).map((profile) => ({
|
|
476
488
|
creation: Date.parse(profile.creationDate),
|
|
477
489
|
expiration: Date.parse(profile.expirationDate)
|
|
478
490
|
})).reduce((latest, it) => it.expiration > latest.expiration ? it : latest, {
|
|
@@ -490,9 +502,9 @@ async function installPasscode(context, device, current) {
|
|
|
490
502
|
return current === void 0 && !device.virtual && interactive(context) && context.options.passcode === void 0 && context.options["passcode-type"] === void 0 && !context.options["no-setup"] ? askPasscode(context) : passcodeOf(context.options);
|
|
491
503
|
}
|
|
492
504
|
async function findInstalled(context) {
|
|
493
|
-
const device = await trustedDevice(context, { filter: (devices) => sideloadedDevices(devices,
|
|
505
|
+
const device = await trustedDevice(context, { filter: (devices) => sideloadedDevices(devices, t("sideload.noneInstalledHint")) });
|
|
494
506
|
const { team, current } = await locate(context, device);
|
|
495
|
-
if (current === void 0) throw new Error(team === void 0 ?
|
|
507
|
+
if (current === void 0) throw new Error(team === void 0 ? t("sideload.notInstalledHint", { device: device.name }) : t("sideload.notInstalledByTeamHint", {
|
|
496
508
|
device: device.name,
|
|
497
509
|
team
|
|
498
510
|
}));
|
|
@@ -508,7 +520,7 @@ async function downloadIPA(context, release) {
|
|
|
508
520
|
if (fs.existsSync(ipa)) return ipa;
|
|
509
521
|
fs.mkdirSync(downloads, { recursive: true });
|
|
510
522
|
const partial = `${ipa}.download`;
|
|
511
|
-
await step(
|
|
523
|
+
await step(t("sideload.downloading", {
|
|
512
524
|
version: release.version,
|
|
513
525
|
build: release.build,
|
|
514
526
|
release: release.tag
|
|
@@ -520,22 +532,22 @@ async function downloadIPA(context, release) {
|
|
|
520
532
|
async function prepareDiskImage(context, device) {
|
|
521
533
|
if (device.virtual) return;
|
|
522
534
|
try {
|
|
523
|
-
await step(
|
|
535
|
+
await step(t("sideload.preparingDiskImage", { device: device.name }), () => mountDiskImage(device), { transient: true });
|
|
524
536
|
} catch (error) {
|
|
525
537
|
if (context.signal.aborted) throw error;
|
|
526
|
-
console.error(
|
|
538
|
+
console.error(t("sideload.diskImageFailed", {
|
|
527
539
|
device: device.name,
|
|
528
|
-
error: error
|
|
540
|
+
error: errorMessage(error)
|
|
529
541
|
}));
|
|
530
542
|
}
|
|
531
543
|
}
|
|
532
544
|
async function deploy(context, { device, team, current }, updateOnly) {
|
|
533
545
|
const passcode = await installPasscode(context, device, current);
|
|
534
|
-
const release = await step(
|
|
535
|
-
const id =
|
|
546
|
+
const release = await step(t("sideload.checkingRelease"), () => findRelease(context.options.nightly, context.signal), { transient: true });
|
|
547
|
+
const id = team === void 0 || team === "P8XK3KHB48" ? bundleId : `${bundleId}.${team}`;
|
|
536
548
|
if (current !== void 0) {
|
|
537
549
|
const installed = Number(current.bundleVersion);
|
|
538
|
-
const signing =
|
|
550
|
+
const signing = team === void 0 ? void 0 : await signingPeriod(device, id, team);
|
|
539
551
|
const parameters = {
|
|
540
552
|
build: buildText(current),
|
|
541
553
|
device: device.name,
|
|
@@ -543,20 +555,20 @@ async function deploy(context, { device, team, current }, updateOnly) {
|
|
|
543
555
|
releaseBuild: release.build
|
|
544
556
|
};
|
|
545
557
|
const asks = !updateOnly && !context.options.force && installed > release.build && interactive(context);
|
|
546
|
-
if (installed >= release.build && !asks) console.log(installed === release.build ?
|
|
558
|
+
if (installed >= release.build && !asks) console.log(installed === release.build ? t("sideload.upToDate", parameters) : t("sideload.laterThanRelease", parameters));
|
|
547
559
|
const versions = {
|
|
548
560
|
device: device.name,
|
|
549
561
|
version: `${current.version} (${current.bundleVersion})`,
|
|
550
562
|
releaseVersion: `${release.version} (${release.build})`
|
|
551
563
|
};
|
|
552
564
|
const replaces = asks ? await select({
|
|
553
|
-
message: release.tag === "nightly" ?
|
|
565
|
+
message: release.tag === "nightly" ? t("sideload.downgradePrompt", versions) : t("sideload.downgradeToStablePrompt", versions),
|
|
554
566
|
theme: selectTheme,
|
|
555
567
|
choices: [{
|
|
556
|
-
name:
|
|
568
|
+
name: t("sideload.downgrade"),
|
|
557
569
|
value: true
|
|
558
570
|
}, {
|
|
559
|
-
name:
|
|
571
|
+
name: t("noThanks"),
|
|
560
572
|
value: false
|
|
561
573
|
}]
|
|
562
574
|
}, {
|
|
@@ -564,12 +576,12 @@ async function deploy(context, { device, team, current }, updateOnly) {
|
|
|
564
576
|
signal: context.signal
|
|
565
577
|
}) : !updateOnly && context.options.force;
|
|
566
578
|
if (!replaces && installed >= release.build && (signing === void 0 || !expiresSoon(signing))) {
|
|
567
|
-
if (signing !== void 0) console.log(
|
|
579
|
+
if (signing !== void 0) console.log(t("sideload.expiration", { expiration: expirationText(signing.expiration) }));
|
|
568
580
|
const saves = !updateOnly && passcode !== void 0;
|
|
569
|
-
const pairs = !context.options["no-setup"] && !context.options["no-setup-pair"] && !await step(
|
|
581
|
+
const pairs = !context.options["no-setup"] && !context.options["no-setup-pair"] && !await step(t("sideload.checking", { device: device.name }), () => hasPairing(device, id), { transient: true });
|
|
570
582
|
if (!saves && !pairs) return;
|
|
571
583
|
await prepareDiskImage(context, device);
|
|
572
|
-
if (saves) await step(
|
|
584
|
+
if (saves) await step(t("sideload.settingUpAutoUnlock"), () => setUpAutoUnlock(device, id, passcode));
|
|
573
585
|
if (context.options["no-setup"]) {
|
|
574
586
|
await launch(device, id);
|
|
575
587
|
return;
|
|
@@ -578,14 +590,14 @@ async function deploy(context, { device, team, current }, updateOnly) {
|
|
|
578
590
|
if (saves || paired) await openConfigured(context, device, id, passcode);
|
|
579
591
|
return;
|
|
580
592
|
}
|
|
581
|
-
if (!replaces && installed > release.build) throw new Error(
|
|
593
|
+
if (!replaces && installed > release.build) throw new Error(t("sideload.renewalNeedsDowngrade", parameters));
|
|
582
594
|
}
|
|
583
|
-
if (
|
|
595
|
+
if (team !== void 0 && process.platform !== "darwin") throw new Error(signingNeedsMac);
|
|
584
596
|
const work = fs.mkdtempSync(path.join(os.tmpdir(), "swipt-sideload-"));
|
|
585
597
|
try {
|
|
586
|
-
const signing =
|
|
598
|
+
const signing = team === void 0 ? void 0 : await step(t("sideload.preparingSigning", { team: xcodeTeams().find((it) => it.id === team)?.name ?? team }), (update) => provision(work, id, team, device, update));
|
|
587
599
|
const ipa = await downloadIPA(context, release);
|
|
588
|
-
const app = signing === void 0 ? await unpack(ipa, work) : await step(
|
|
600
|
+
const app = signing === void 0 ? await unpack(ipa, work) : await step(t("sideload.resigning"), async (update) => {
|
|
589
601
|
const unpacked = await unpack(ipa, work);
|
|
590
602
|
await resign(unpacked, id, signing, update);
|
|
591
603
|
return unpacked;
|
|
@@ -610,7 +622,7 @@ async function installOnGuest(device, id, app) {
|
|
|
610
622
|
try {
|
|
611
623
|
const signed = path.join(work, "Payload", path.basename(app));
|
|
612
624
|
await exec("ditto", [app, signed]);
|
|
613
|
-
await step(
|
|
625
|
+
await step(t("sideload.resigning"), async (update) => {
|
|
614
626
|
const entitlements = path.join(work, "entitlements.plist");
|
|
615
627
|
fs.writeFileSync(entitlements, guestEntitlements(id));
|
|
616
628
|
execFileSync("plutil", [
|
|
@@ -625,7 +637,7 @@ async function installOnGuest(device, id, app) {
|
|
|
625
637
|
entitlements
|
|
626
638
|
}, update);
|
|
627
639
|
});
|
|
628
|
-
await step(
|
|
640
|
+
await step(t("sideload.installing", { device: device.name }), () => installApp(device, signed, id));
|
|
629
641
|
} finally {
|
|
630
642
|
fs.rmSync(work, {
|
|
631
643
|
recursive: true,
|
|
@@ -635,21 +647,21 @@ async function installOnGuest(device, id, app) {
|
|
|
635
647
|
}
|
|
636
648
|
async function installAndOpen(context, { device, id, current }, app, build, { passcode, saves = true }) {
|
|
637
649
|
if (current !== void 0) {
|
|
638
|
-
const running = await step(
|
|
639
|
-
if (running !== void 0) await step(
|
|
650
|
+
const running = await step(t("sideload.checking", { device: device.name }), () => runningSwipt(device.name, context.signal), { transient: true });
|
|
651
|
+
if (running !== void 0) await step(t("sideload.unlocking"), () => tryUnlock(running, context.signal), { transient: true });
|
|
640
652
|
}
|
|
641
653
|
await prepareDiskImage(context, device);
|
|
642
654
|
if (device.virtual) await installOnGuest(device, id, app);
|
|
643
|
-
else await step(
|
|
644
|
-
if (saves && passcode !== void 0) await step(
|
|
645
|
-
const result = (await step(
|
|
655
|
+
else await step(t("sideload.installing", { device: device.name }), () => installApp(device, app, id));
|
|
656
|
+
if (saves && passcode !== void 0) await step(t("sideload.settingUpAutoUnlock"), () => setUpAutoUnlock(device, id, passcode));
|
|
657
|
+
const result = (await step(t("sideload.checking", { device: device.name }), () => apps(device), { transient: true })).find((it) => it.bundleIdentifier === id);
|
|
646
658
|
if (result === void 0 || Number(result.bundleVersion) !== build) throw new Error(result === void 0 ? `${device.name} does not list ${id} after the install` : `${device.name} has ${buildText(result)} after the install`);
|
|
647
659
|
const parameters = {
|
|
648
660
|
build: buildText(result),
|
|
649
661
|
device: device.name
|
|
650
662
|
};
|
|
651
|
-
console.log(current !== void 0 && Number(current.bundleVersion) < build ?
|
|
652
|
-
if (!device.virtual) console.log(
|
|
663
|
+
console.log(current !== void 0 && Number(current.bundleVersion) < build ? t("sideload.updated", parameters) : t("sideload.installed", parameters));
|
|
664
|
+
if (!device.virtual) console.log(t("sideload.expiration", { expiration: expirationText(Date.parse(profileField(path.join(app, "embedded.mobileprovision"), "ExpirationDate"))) }));
|
|
653
665
|
if (context.options["no-setup"]) {
|
|
654
666
|
await launch(device, id);
|
|
655
667
|
return;
|
|
@@ -658,17 +670,17 @@ async function installAndOpen(context, { device, id, current }, app, build, { pa
|
|
|
658
670
|
await openConfigured(context, device, id, passcode, current !== void 0 && !paired);
|
|
659
671
|
}
|
|
660
672
|
async function printAPI(context, device) {
|
|
661
|
-
const found = await step(
|
|
673
|
+
const found = await step(t("sideload.checking", { device: device.name }), () => findPublished(device.name, context.signal), { transient: true });
|
|
662
674
|
if (found === void 0) {
|
|
663
|
-
console.error(
|
|
675
|
+
console.error(t("sideload.notOnNetwork", { device: device.name }));
|
|
664
676
|
return;
|
|
665
677
|
}
|
|
666
678
|
const url = found.authenticates ? withToken(found.url) : found.url;
|
|
667
679
|
console.log(columns([["CLI", url], ["MCP", `${url}/mcp`]]));
|
|
668
680
|
}
|
|
669
|
-
async function openConfigured(context, device, id, passcode, updated) {
|
|
681
|
+
async function openConfigured(context, device, id, passcode, updated = false) {
|
|
670
682
|
const publishes = !context.options["no-setup-api"];
|
|
671
|
-
if (device.virtual) await step(
|
|
683
|
+
if (device.virtual) await step(t("sideload.opening", { device: device.name }), async () => {
|
|
672
684
|
await savePreferences(device, id, {
|
|
673
685
|
autoUnlockSetUp: true,
|
|
674
686
|
developerLocalNetworkEnabled: publishes
|
|
@@ -679,15 +691,15 @@ async function openConfigured(context, device, id, passcode, updated) {
|
|
|
679
691
|
else await trustAndOpen(context, device, id, passcode, updated);
|
|
680
692
|
if (publishes) await printAPI(context, device);
|
|
681
693
|
}
|
|
682
|
-
async function launch(device, id
|
|
694
|
+
async function launch(device, id) {
|
|
683
695
|
try {
|
|
684
|
-
await step(
|
|
696
|
+
await step(t("sideload.opening", { device: device.name }), () => launchApp(device, id));
|
|
685
697
|
return true;
|
|
686
698
|
} catch (error) {
|
|
687
|
-
if (error
|
|
688
|
-
await step(
|
|
689
|
-
console.log(
|
|
690
|
-
} else if (error
|
|
699
|
+
if (failedWith(error, failures.untrusted)) {
|
|
700
|
+
await step(t("sideload.openingSettings", { device: device.name }), () => openSettings(device, "prefs:root=General&path=ManagedConfigurationList"));
|
|
701
|
+
console.log(t("sideload.untrusted", { device: device.name }));
|
|
702
|
+
} else if (failedWith(error, failures.locked)) console.log(t("sideload.opensAfterUnlock", { device: device.name }));
|
|
691
703
|
else throw error;
|
|
692
704
|
return false;
|
|
693
705
|
}
|
|
@@ -708,24 +720,24 @@ async function setup(context) {
|
|
|
708
720
|
const id = current.bundleIdentifier;
|
|
709
721
|
const passcode = given ?? (interactive(context) && !device.virtual ? await askPasscode(context) : void 0);
|
|
710
722
|
await prepareDiskImage(context, device);
|
|
711
|
-
if (passcode !== void 0) await step(
|
|
723
|
+
if (passcode !== void 0) await step(t("sideload.settingUpAutoUnlock"), () => setUpAutoUnlock(device, id, passcode));
|
|
712
724
|
if (!context.options["no-setup-pair"]) await pair(context, device, id, true);
|
|
713
725
|
await openConfigured(context, device, id, passcode);
|
|
714
726
|
}
|
|
715
727
|
const trustMessages = JSON.stringify({
|
|
716
|
-
unlockToContinue:
|
|
717
|
-
unlocking:
|
|
718
|
-
trusting:
|
|
719
|
-
running:
|
|
720
|
-
trusted:
|
|
728
|
+
unlockToContinue: t("sideload.unlockPrompt"),
|
|
729
|
+
unlocking: t("sideload.unlocking"),
|
|
730
|
+
trusting: t("sideload.trusting", { developer: "{developer}" }),
|
|
731
|
+
running: t("sideload.running", { app: "{app}" }),
|
|
732
|
+
trusted: t("sideload.trusted", { developer: "{developer}" })
|
|
721
733
|
});
|
|
722
734
|
async function pair(context, device, id, overwrite = false) {
|
|
723
|
-
if (!overwrite && await step(
|
|
735
|
+
if (!overwrite && await step(t("sideload.checking", { device: device.name }), () => hasPairing(device, id), { transient: true })) return false;
|
|
724
736
|
try {
|
|
725
|
-
await step(
|
|
737
|
+
await step(t("driver.pairing", { device: device.name }), () => savePairing(device, id));
|
|
726
738
|
} catch (error) {
|
|
727
739
|
if (context.signal.aborted) throw error;
|
|
728
|
-
console.error(
|
|
740
|
+
console.error(t("sideload.pairingFailed", { error: errorMessage(error) }));
|
|
729
741
|
return false;
|
|
730
742
|
}
|
|
731
743
|
return true;
|
|
@@ -735,7 +747,7 @@ async function launchUnlocking(device, id, args, signal) {
|
|
|
735
747
|
await launchApp(device, id, args);
|
|
736
748
|
return;
|
|
737
749
|
} catch (error) {
|
|
738
|
-
if (error
|
|
750
|
+
if (!failedWith(error, failures.locked)) throw error;
|
|
739
751
|
const passcode = await savedPasscode(device, id);
|
|
740
752
|
if (passcode === void 0) throw error;
|
|
741
753
|
const driven = serve(device.udid, {
|
|
@@ -757,19 +769,19 @@ async function trustAndOpen(context, device, id, given, updated) {
|
|
|
757
769
|
let failure;
|
|
758
770
|
let passcode = given;
|
|
759
771
|
try {
|
|
760
|
-
await step(
|
|
772
|
+
await step(t("sideload.opening", { device: device.name }), async (update) => {
|
|
761
773
|
if (updated) try {
|
|
762
774
|
await launchUnlocking(device, id, context.options["no-setup-api"] ? [] : [publishArgument], context.signal);
|
|
763
775
|
return;
|
|
764
776
|
} catch (error) {
|
|
765
|
-
if (error
|
|
777
|
+
if (!failedWith(error, failures.untrusted) && !failedWith(error, failures.locked)) throw error;
|
|
766
778
|
}
|
|
767
779
|
passcode ??= await savedPasscode(device, id);
|
|
768
780
|
await terminateApp(device, id);
|
|
769
781
|
const unlock = passcode !== void 0 ? "passcode" : process.stderr.isTTY ? "wait" : "";
|
|
770
782
|
let driven;
|
|
771
783
|
let local;
|
|
772
|
-
|
|
784
|
+
for (;;) {
|
|
773
785
|
driven = serve(device.udid, {
|
|
774
786
|
passcode,
|
|
775
787
|
token: randomToken(),
|
|
@@ -777,9 +789,10 @@ async function trustAndOpen(context, device, id, given, updated) {
|
|
|
777
789
|
});
|
|
778
790
|
try {
|
|
779
791
|
local = (await driven.serving).local;
|
|
792
|
+
break;
|
|
780
793
|
} catch (error) {
|
|
781
|
-
if (error
|
|
782
|
-
update(
|
|
794
|
+
if (!failedWith(error, failures.deviceNotListed) || unlock !== "wait") throw error;
|
|
795
|
+
update(t("sideload.waiting", { device: device.name }));
|
|
783
796
|
await setTimeout(1e3, void 0, { signal: context.signal });
|
|
784
797
|
}
|
|
785
798
|
}
|
|
@@ -811,7 +824,7 @@ async function trustAndOpen(context, device, id, given, updated) {
|
|
|
811
824
|
try {
|
|
812
825
|
await launchApp(device, id, args);
|
|
813
826
|
} catch (error) {
|
|
814
|
-
if (error
|
|
827
|
+
if (!failedWith(error, failures.untrusted)) throw error;
|
|
815
828
|
await run([
|
|
816
829
|
id,
|
|
817
830
|
"trust",
|
|
@@ -832,7 +845,7 @@ async function trustAndOpen(context, device, id, given, updated) {
|
|
|
832
845
|
for (const output of lines) (output.level === 1 || output.level === 2 ? console.error : console.log)(output.text);
|
|
833
846
|
}
|
|
834
847
|
if (failure) {
|
|
835
|
-
if (passcode === void 0 && failure.name === "UnavailableError" && /\bdevice is locked\b/.test(failure.message)) throw new Error(
|
|
848
|
+
if (passcode === void 0 && failure.name === "UnavailableError" && /\bdevice is locked\b/.test(failure.message)) throw new Error(t("sideload.locked", {
|
|
836
849
|
device: device.name,
|
|
837
850
|
message: failure.message
|
|
838
851
|
}));
|
|
@@ -842,12 +855,12 @@ async function trustAndOpen(context, device, id, given, updated) {
|
|
|
842
855
|
async function uninstall(context) {
|
|
843
856
|
const device = await trustedDevice(context, { filter: sideloadedDevices });
|
|
844
857
|
const { team, current } = await locate(context, device);
|
|
845
|
-
if (current === void 0) throw new Error(team === void 0 ?
|
|
858
|
+
if (current === void 0) throw new Error(team === void 0 ? t("sideload.notInstalled", { device: device.name }) : t("sideload.notInstalledByTeam", {
|
|
846
859
|
device: device.name,
|
|
847
860
|
team
|
|
848
861
|
}));
|
|
849
|
-
await step(
|
|
850
|
-
console.log(
|
|
862
|
+
await step(t("sideload.removing", { device: device.name }), () => uninstallApp(device, current.bundleIdentifier));
|
|
863
|
+
console.log(t("sideload.removed", {
|
|
851
864
|
build: buildText(current),
|
|
852
865
|
device: device.name
|
|
853
866
|
}));
|