@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.
Files changed (247) hide show
  1. package/dist/availability.d.ts +3 -1
  2. package/dist/availability.js +173 -151
  3. package/dist/availability.js.map +1 -1
  4. package/dist/cli/cli.js +52 -66
  5. package/dist/cli/cli.js.map +1 -1
  6. package/dist/cli/command.d.ts +9 -0
  7. package/dist/cli/command.js.map +1 -1
  8. package/dist/cli/commands/data/clear.js +2 -2
  9. package/dist/cli/commands/data/clear.js.map +1 -1
  10. package/dist/cli/commands/data/data.js +2 -2
  11. package/dist/cli/commands/data/data.js.map +1 -1
  12. package/dist/cli/commands/data/list.js +3 -3
  13. package/dist/cli/commands/data/list.js.map +1 -1
  14. package/dist/cli/commands/data/operand.js.map +1 -1
  15. package/dist/cli/commands/data/read.js +4 -7
  16. package/dist/cli/commands/data/read.js.map +1 -1
  17. package/dist/cli/commands/data/remove.js +3 -3
  18. package/dist/cli/commands/data/remove.js.map +1 -1
  19. package/dist/cli/commands/data/write.js +2 -2
  20. package/dist/cli/commands/data/write.js.map +1 -1
  21. package/dist/cli/commands/device/add.js +2 -2
  22. package/dist/cli/commands/device/add.js.map +1 -1
  23. package/dist/cli/commands/device/device.js +2 -2
  24. package/dist/cli/commands/device/device.js.map +1 -1
  25. package/dist/cli/commands/device/list.js +2 -2
  26. package/dist/cli/commands/device/list.js.map +1 -1
  27. package/dist/cli/commands/device/logs.js +44 -46
  28. package/dist/cli/commands/device/logs.js.map +1 -1
  29. package/dist/cli/commands/device/remove.js +2 -2
  30. package/dist/cli/commands/device/remove.js.map +1 -1
  31. package/dist/cli/commands/device/stop.js +3 -3
  32. package/dist/cli/commands/device/stop.js.map +1 -1
  33. package/dist/cli/commands/driver/driver.js +6 -6
  34. package/dist/cli/commands/driver/driver.js.map +1 -1
  35. package/dist/cli/commands/flags.js +9 -9
  36. package/dist/cli/commands/flags.js.map +1 -1
  37. package/dist/cli/commands/index.js +2 -2
  38. package/dist/cli/commands/index.js.map +1 -1
  39. package/dist/cli/commands/project/build.js +2 -2
  40. package/dist/cli/commands/project/build.js.map +1 -1
  41. package/dist/cli/commands/project/create.js +3 -3
  42. package/dist/cli/commands/project/create.js.map +1 -1
  43. package/dist/cli/commands/project/deploy.js +2 -2
  44. package/dist/cli/commands/project/deploy.js.map +1 -1
  45. package/dist/cli/commands/project/develop.js +19 -19
  46. package/dist/cli/commands/project/develop.js.map +1 -1
  47. package/dist/cli/commands/project/project.js +2 -2
  48. package/dist/cli/commands/project/project.js.map +1 -1
  49. package/dist/cli/commands/project/source.js +62 -37
  50. package/dist/cli/commands/project/source.js.map +1 -1
  51. package/dist/cli/commands/repl/api.js +2 -2
  52. package/dist/cli/commands/repl/api.js.map +1 -1
  53. package/dist/cli/commands/repl/repl.js +4 -4
  54. package/dist/cli/commands/repl/repl.js.map +1 -1
  55. package/dist/cli/commands/repl/reset.js +2 -2
  56. package/dist/cli/commands/repl/reset.js.map +1 -1
  57. package/dist/cli/commands/repl/run.js +5 -5
  58. package/dist/cli/commands/repl/run.js.map +1 -1
  59. package/dist/cli/commands/sideload/install.js +4 -4
  60. package/dist/cli/commands/sideload/install.js.map +1 -1
  61. package/dist/cli/commands/sideload/setup.js +3 -3
  62. package/dist/cli/commands/sideload/setup.js.map +1 -1
  63. package/dist/cli/commands/sideload/sideload.js +2 -2
  64. package/dist/cli/commands/sideload/sideload.js.map +1 -1
  65. package/dist/cli/commands/sideload/uninstall.js +2 -2
  66. package/dist/cli/commands/sideload/uninstall.js.map +1 -1
  67. package/dist/cli/commands/sideload/update.js +3 -3
  68. package/dist/cli/commands/sideload/update.js.map +1 -1
  69. package/dist/cli/commands/swiplet/call.js +6 -6
  70. package/dist/cli/commands/swiplet/call.js.map +1 -1
  71. package/dist/cli/commands/swiplet/install.js +3 -3
  72. package/dist/cli/commands/swiplet/install.js.map +1 -1
  73. package/dist/cli/commands/swiplet/list.js +8 -8
  74. package/dist/cli/commands/swiplet/list.js.map +1 -1
  75. package/dist/cli/commands/swiplet/remove.js +3 -3
  76. package/dist/cli/commands/swiplet/remove.js.map +1 -1
  77. package/dist/cli/commands/swiplet/service/disable.js +3 -3
  78. package/dist/cli/commands/swiplet/service/disable.js.map +1 -1
  79. package/dist/cli/commands/swiplet/service/enable.js +3 -3
  80. package/dist/cli/commands/swiplet/service/enable.js.map +1 -1
  81. package/dist/cli/commands/swiplet/service/service.js +2 -2
  82. package/dist/cli/commands/swiplet/service/service.js.map +1 -1
  83. package/dist/cli/commands/swiplet/service/services.js +2 -2
  84. package/dist/cli/commands/swiplet/service/services.js.map +1 -1
  85. package/dist/cli/commands/swiplet/service/watch.js +2 -2
  86. package/dist/cli/commands/swiplet/service/watch.js.map +1 -1
  87. package/dist/cli/commands/swiplet/show.js +6 -6
  88. package/dist/cli/commands/swiplet/show.js.map +1 -1
  89. package/dist/cli/commands/swiplet/swiplet.js +4 -4
  90. package/dist/cli/commands/swiplet/swiplet.js.map +1 -1
  91. package/dist/cli/commands/version/version.js +2 -2
  92. package/dist/cli/commands/version/version.js.map +1 -1
  93. package/dist/cli/deploy.js +9 -7
  94. package/dist/cli/deploy.js.map +1 -1
  95. package/dist/cli/session.js.map +1 -1
  96. package/dist/client.d.ts +145 -7
  97. package/dist/client.js +20 -22
  98. package/dist/client.js.map +1 -1
  99. package/dist/connection.d.ts +292 -25
  100. package/dist/connection.js +36 -35
  101. package/dist/connection.js.map +1 -1
  102. package/dist/driver.d.ts +62 -23
  103. package/dist/driver.js +29 -33
  104. package/dist/driver.js.map +1 -1
  105. package/dist/i18n.d.ts +2 -5
  106. package/dist/i18n.js +15 -13
  107. package/dist/i18n.js.map +1 -1
  108. package/dist/i18next.d.ts +7 -0
  109. package/dist/ignore.d.ts +14 -7
  110. package/dist/ignore.js +13 -14
  111. package/dist/ignore.js.map +1 -1
  112. package/dist/mdns.d.ts +2 -2
  113. package/dist/mdns.js +1 -1
  114. package/dist/mdns.js.map +1 -1
  115. package/dist/metro.d.ts +19 -5
  116. package/dist/metro.js +61 -63
  117. package/dist/metro.js.map +1 -1
  118. package/dist/output.d.ts +29 -14
  119. package/dist/output.js +17 -15
  120. package/dist/output.js.map +1 -1
  121. package/dist/passcode.d.ts +12 -8
  122. package/dist/passcode.js +18 -18
  123. package/dist/passcode.js.map +1 -1
  124. package/dist/project.d.ts +20 -10
  125. package/dist/project.js +72 -49
  126. package/dist/project.js.map +1 -1
  127. package/dist/proto/common_pb.d.ts +240 -0
  128. package/dist/proto/common_pb.js +7 -2
  129. package/dist/proto/common_pb.js.map +1 -1
  130. package/dist/proto/logs_pb.d.ts +38 -0
  131. package/dist/proto/repl_pb.d.ts +96 -0
  132. package/dist/proto/swiplets_pb.d.ts +361 -0
  133. package/dist/proto/swiplets_pb.js +7 -2
  134. package/dist/proto/swiplets_pb.js.map +1 -1
  135. package/dist/proto/system_pb.d.ts +33 -0
  136. package/dist/resources.d.ts +400 -0
  137. package/dist/serve.d.ts +9 -1
  138. package/dist/serve.js +17 -16
  139. package/dist/serve.js.map +1 -1
  140. package/dist/sideload.d.ts +27 -14
  141. package/dist/sideload.js +102 -89
  142. package/dist/sideload.js.map +1 -1
  143. package/dist/swipt-app.d.ts +19 -9
  144. package/dist/swipt-app.js +1 -1
  145. package/dist/swipt-app.js.map +1 -1
  146. package/locales/ar/translation.json +413 -0
  147. package/locales/bg/translation.json +397 -0
  148. package/locales/bn/translation.json +397 -0
  149. package/locales/ca/translation.json +401 -0
  150. package/locales/cs/translation.json +405 -0
  151. package/locales/da/translation.json +397 -0
  152. package/locales/de/translation.json +397 -0
  153. package/locales/el/translation.json +397 -0
  154. package/locales/en/translation.json +397 -0
  155. package/locales/es/translation.json +401 -0
  156. package/locales/es-419/translation.json +401 -0
  157. package/locales/fi/translation.json +397 -0
  158. package/locales/fr/translation.json +401 -0
  159. package/locales/fr-CA/translation.json +401 -0
  160. package/locales/gu/translation.json +397 -0
  161. package/locales/he/translation.json +401 -0
  162. package/locales/hi/translation.json +397 -0
  163. package/locales/hr/translation.json +401 -0
  164. package/locales/hu/translation.json +397 -0
  165. package/locales/id/translation.json +393 -0
  166. package/locales/it/translation.json +401 -0
  167. package/locales/ja/translation.json +393 -0
  168. package/locales/kk/translation.json +397 -0
  169. package/locales/kn/translation.json +397 -0
  170. package/locales/ko/translation.json +393 -0
  171. package/locales/lt/translation.json +405 -0
  172. package/locales/ml/translation.json +397 -0
  173. package/locales/mr/translation.json +397 -0
  174. package/locales/ms/translation.json +393 -0
  175. package/locales/nb/translation.json +397 -0
  176. package/locales/nl/translation.json +397 -0
  177. package/locales/or/translation.json +397 -0
  178. package/locales/pa/translation.json +397 -0
  179. package/locales/pl/translation.json +405 -0
  180. package/locales/pt-BR/translation.json +401 -0
  181. package/locales/pt-PT/translation.json +401 -0
  182. package/locales/ro/translation.json +401 -0
  183. package/locales/ru/translation.json +405 -0
  184. package/locales/sk/translation.json +405 -0
  185. package/locales/sl/translation.json +405 -0
  186. package/locales/sv/translation.json +397 -0
  187. package/locales/ta/translation.json +397 -0
  188. package/locales/te/translation.json +397 -0
  189. package/locales/th/translation.json +393 -0
  190. package/locales/tr/translation.json +397 -0
  191. package/locales/uk/translation.json +405 -0
  192. package/locales/ur/translation.json +397 -0
  193. package/locales/vi/translation.json +397 -0
  194. package/locales/zh-HK/translation.json +393 -0
  195. package/locales/zh-Hans/translation.json +393 -0
  196. package/locales/zh-Hant/translation.json +393 -0
  197. package/package.json +14 -9
  198. package/locales/ar.json +0 -311
  199. package/locales/bg.json +0 -295
  200. package/locales/bn.json +0 -295
  201. package/locales/ca.json +0 -299
  202. package/locales/cs.json +0 -303
  203. package/locales/da.json +0 -295
  204. package/locales/de.json +0 -295
  205. package/locales/el.json +0 -295
  206. package/locales/es-419.json +0 -299
  207. package/locales/es.json +0 -299
  208. package/locales/fi.json +0 -295
  209. package/locales/fr-CA.json +0 -299
  210. package/locales/fr.json +0 -299
  211. package/locales/gu.json +0 -295
  212. package/locales/he.json +0 -299
  213. package/locales/hi.json +0 -295
  214. package/locales/hr.json +0 -299
  215. package/locales/hu.json +0 -295
  216. package/locales/id.json +0 -283
  217. package/locales/it.json +0 -299
  218. package/locales/ja.json +0 -283
  219. package/locales/kk.json +0 -295
  220. package/locales/kn.json +0 -295
  221. package/locales/ko.json +0 -283
  222. package/locales/lt.json +0 -303
  223. package/locales/ml.json +0 -295
  224. package/locales/mr.json +0 -295
  225. package/locales/ms.json +0 -283
  226. package/locales/nb.json +0 -295
  227. package/locales/nl.json +0 -295
  228. package/locales/or.json +0 -295
  229. package/locales/pa.json +0 -295
  230. package/locales/pl.json +0 -303
  231. package/locales/pt-BR.json +0 -299
  232. package/locales/pt-PT.json +0 -299
  233. package/locales/ro.json +0 -299
  234. package/locales/ru.json +0 -303
  235. package/locales/sk.json +0 -303
  236. package/locales/sl.json +0 -303
  237. package/locales/sv.json +0 -295
  238. package/locales/ta.json +0 -295
  239. package/locales/te.json +0 -295
  240. package/locales/th.json +0 -283
  241. package/locales/tr.json +0 -295
  242. package/locales/uk.json +0 -303
  243. package/locales/ur.json +0 -295
  244. package/locales/vi.json +0 -295
  245. package/locales/zh-HK.json +0 -283
  246. package/locales/zh-Hans.json +0 -283
  247. 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, tr } from "./i18n.js";
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 = tr("Installing or updating Swipt needs macOS; install it from a Mac, then set it up here with \"swipt sideload setup\".");
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
- if (response.status >= 300 && response.status < 400) response = await fetch(response.headers.get("location"), { signal });
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
- const error = new Error(message);
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: Number(metadata.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 tr("Xcode has no account for team {team}; sign in to its Apple Account at {accounts}.", {
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 tr("Xcode couldn't make a development certificate for team {team}; add one at {accounts} › Manage Certificates ({errors}).", {
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 tr("xcodebuild needs Xcode; install it and select it with xcode-select");
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.on("data", (chunk) => {
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
- if (error.code === "ENOENT") throw new Error(tr("xcodebuild is missing; install Xcode."));
278
- if (typeof error.code !== "number") throw error;
279
- throw new Error(explain(`${error.stdout}${error.stderr}`, team));
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
- ], { stdio: "pipe" }));
344
+ ], {
345
+ stdio: "pipe",
346
+ encoding: "utf8"
347
+ }));
336
348
  } catch (error) {
337
- if (!plistValueMissing.test(error.stderr)) throw error;
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.test(error.stderr)) return false;
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 = tr("Swipt isn't sideloaded on any iPhone or iPad.")) {
427
- const sideloaded = await step(tr("looking for Swipt on the devices"), () => Promise.all(devices.map((device) => swiptApps(device).then((found) => found.length > 0, () => true))), { transient: true });
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(tr("checking Swipt on {device}", { device: device.name }), () => swiptApps(device), { transient: true });
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(tr("invalid argument {value} for --team: it's the 10-character team ID shown in {accounts}", {
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, tr("Choose a team"), teams.map(teamChoice), /* @__PURE__ */ new Error(`${tr("Swipt is sideloaded on {device} by more than one team; choose one with --team ID:", { device: device.name })}\n${teamList(teams)}`));
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() ? tr("Xcode has no development certificate; add one at {accounts} › Manage Certificates, or choose a team with --team ID", { accounts: accountsHint }) : tr("Xcode has no account; sign in at {accounts}, or choose a team with --team ID", { accounts: accountsHint }));
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, tr("Choose a team"), teams.map(teamChoice), /* @__PURE__ */ new Error(`${tr("Choose a team with --team ID:")}\n${teamList(teams)}`)),
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(tr("checking Swipt on {device}", { device: device.name }), () => provisioningProfiles(device), { transient: true })).filter((profile) => profile.teamIdentifier === team && names.includes(profile.name)).map((profile) => ({
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, tr("Swipt isn't sideloaded on any iPhone or iPad; install it with \"swipt sideload install\".")) });
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 ? tr("Swipt isn't sideloaded on {device}; install it with \"swipt sideload install\".", { device: device.name }) : tr("Swipt isn't sideloaded on {device} by team {team}; install it with \"swipt sideload install\".", {
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(tr("downloading Swipt {version} ({build}) from {release}", {
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(tr("preparing the Developer Disk Image on {device}", { device: device.name }), () => mountDiskImage(device), { transient: true });
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(tr("couldn't prepare the Developer Disk Image on {device}: {error}", {
538
+ console.error(t("sideload.diskImageFailed", {
527
539
  device: device.name,
528
- error: error.message
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(tr("checking the latest release"), () => findRelease(context.options.nightly, context.signal), { transient: true });
535
- const id = device.virtual || team === "P8XK3KHB48" ? bundleId : `${bundleId}.${team}`;
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 = device.virtual ? void 0 : await signingPeriod(device, id, team);
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 ? tr("{build} on {device} is already {release}.", parameters) : tr("{build} on {device} is later than {release} ({releaseBuild}).", parameters));
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" ? tr("Downgrade Swipt on {device} from {version} to {releaseVersion}? Swipt resets its data when the earlier version can't read it.", versions) : tr("Downgrade Swipt on {device} from nightly {version} to stable {releaseVersion}? Swipt resets its data when the earlier version can't read it.", versions),
565
+ message: release.tag === "nightly" ? t("sideload.downgradePrompt", versions) : t("sideload.downgradeToStablePrompt", versions),
554
566
  theme: selectTheme,
555
567
  choices: [{
556
- name: tr("Downgrade"),
568
+ name: t("sideload.downgrade"),
557
569
  value: true
558
570
  }, {
559
- name: tr("No Thanks"),
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(tr("Its signing expires {expiration}.", { expiration: expirationText(signing.expiration) }));
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(tr("checking Swipt on {device}", { device: device.name }), () => hasPairing(device, id), { transient: true });
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(tr("setting up auto-unlock"), () => setUpAutoUnlock(device, id, passcode));
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(tr("{build} on {device} needs new signing, but {release} ({releaseBuild}) is earlier; use --nightly, or downgrade with \"swipt sideload install --force\".", parameters));
593
+ if (!replaces && installed > release.build) throw new Error(t("sideload.renewalNeedsDowngrade", parameters));
582
594
  }
583
- if (!device.virtual && process.platform !== "darwin") throw new Error(signingNeedsMac);
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 = device.virtual ? void 0 : await step(tr("preparing signing for Swipt with team {team} through Xcode", { team: xcodeTeams().find((it) => it.id === team)?.name ?? team }), (update) => provision(work, id, team, device, update));
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(tr("re-signing Swipt"), async (update) => {
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(tr("re-signing Swipt"), async (update) => {
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(tr("installing on {device}", { device: device.name }), () => installApp(device, signed, id));
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(tr("checking Swipt on {device}", { device: device.name }), () => runningSwipt(device.name, context.signal), { transient: true });
639
- if (running !== void 0) await step(tr("unlocking the device"), () => tryUnlock(running, context.signal), { transient: true });
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(tr("installing on {device}", { device: device.name }), () => installApp(device, app, id));
644
- if (saves && passcode !== void 0) await step(tr("setting up auto-unlock"), () => setUpAutoUnlock(device, id, passcode));
645
- const result = (await step(tr("checking Swipt on {device}", { device: device.name }), () => apps(device), { transient: true })).find((it) => it.bundleIdentifier === id);
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 ? tr("{build} is updated on {device}.", parameters) : tr("{build} is installed on {device}.", parameters));
652
- if (!device.virtual) console.log(tr("Its signing expires {expiration}.", { expiration: expirationText(Date.parse(profileField(path.join(app, "embedded.mobileprovision"), "ExpirationDate"))) }));
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(tr("checking Swipt on {device}", { device: device.name }), () => findPublished(device.name, context.signal), { transient: true });
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(tr("{device} wasn't found on the local network; find its API URLs in Swipt › Developer › Local Network.", { device: device.name }));
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(tr("opening Swipt on {device}", { device: device.name }), async () => {
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, args) {
694
+ async function launch(device, id) {
683
695
  try {
684
- await step(tr("opening Swipt on {device}", { device: device.name }), () => launchApp(device, id, args));
696
+ await step(t("sideload.opening", { device: device.name }), () => launchApp(device, id));
685
697
  return true;
686
698
  } catch (error) {
687
- if (error.code === failures.untrusted) {
688
- await step(tr("opening Settings on {device}", { device: device.name }), () => openSettings(device, "prefs:root=General&path=ManagedConfigurationList"));
689
- console.log(tr("Its developer isn't trusted yet; trust it in the Settings page opened on {device}, then open Swipt.", { device: device.name }));
690
- } else if (error.code === failures.locked) console.log(tr("It opens after {device} is unlocked.", { device: device.name }));
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(tr("setting up auto-unlock"), () => setUpAutoUnlock(device, id, passcode));
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: tr("Unlock the device to continue."),
717
- unlocking: tr("unlocking the device"),
718
- trusting: tr("trusting {developer} in Settings", { developer: "{developer}" }),
719
- running: tr("{app} is running.", { app: "{app}" }),
720
- trusted: tr("{developer} is trusted.", { developer: "{developer}" })
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(tr("checking Swipt on {device}", { device: device.name }), () => hasPairing(device, id), { transient: true })) return false;
735
+ if (!overwrite && await step(t("sideload.checking", { device: device.name }), () => hasPairing(device, id), { transient: true })) return false;
724
736
  try {
725
- await step(tr("pairing with {device}", { device: device.name }), () => savePairing(device, id));
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(tr("Pairing failed, so Swipt pairs in Settings instead: {error}", { error: error.message }));
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.code !== failures.locked) throw 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(tr("opening Swipt on {device}", { device: device.name }), async (update) => {
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.code !== failures.untrusted && error.code !== failures.locked) throw 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
- while (local === void 0) {
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.code !== failures.deviceNotListed || unlock !== "wait") throw error;
782
- update(tr("waiting for {device}", { device: device.name }));
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.code !== failures.untrusted) throw 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(tr("{device}: {message}; unlock it or pass --passcode, then run this again.", {
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 ? tr("Swipt isn't sideloaded on {device}.", { device: device.name }) : tr("Swipt isn't sideloaded on {device} by team {team}.", {
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(tr("removing Swipt from {device}", { device: device.name }), () => uninstallApp(device, current.bundleIdentifier));
850
- console.log(tr("removed {build} from {device}", {
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
  }));