@swipt/cli 0.1.0-nightly.78 → 0.1.0-nightly.80

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 (68) hide show
  1. package/dist/availability.d.ts +5 -0
  2. package/dist/availability.js +349 -0
  3. package/dist/availability.js.map +1 -0
  4. package/dist/client.d.ts +25 -0
  5. package/dist/client.js +248 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/connection.d.ts +24 -0
  8. package/dist/connection.js +293 -0
  9. package/dist/connection.js.map +1 -0
  10. package/dist/coredevice.d.ts +22 -0
  11. package/dist/coredevice.js +329 -0
  12. package/dist/coredevice.js.map +1 -0
  13. package/dist/device.d.ts +130 -0
  14. package/dist/device.js +539 -0
  15. package/dist/device.js.map +1 -0
  16. package/dist/i18n.d.ts +2 -0
  17. package/dist/i18n.js +57 -0
  18. package/dist/i18n.js.map +1 -0
  19. package/dist/ignore.d.ts +8 -0
  20. package/dist/ignore.js +112 -0
  21. package/dist/ignore.js.map +1 -0
  22. package/dist/metro.d.ts +10 -0
  23. package/dist/metro.js +349 -0
  24. package/dist/metro.js.map +1 -0
  25. package/dist/output.d.ts +20 -0
  26. package/dist/output.js +116 -0
  27. package/dist/output.js.map +1 -0
  28. package/dist/project.d.ts +18 -0
  29. package/dist/project.js +696 -0
  30. package/dist/project.js.map +1 -0
  31. package/dist/proto/common_pb.js +14 -0
  32. package/dist/proto/common_pb.js.map +1 -0
  33. package/dist/proto/logs_pb.js +15 -0
  34. package/dist/proto/logs_pb.js.map +1 -0
  35. package/dist/proto/repl_pb.js +15 -0
  36. package/dist/proto/repl_pb.js.map +1 -0
  37. package/dist/proto/swiplets_pb.js +20 -0
  38. package/dist/proto/swiplets_pb.js.map +1 -0
  39. package/dist/proto/system_pb.js +15 -0
  40. package/dist/proto/system_pb.js.map +1 -0
  41. package/dist/sideload.d.ts +17 -0
  42. package/dist/sideload.js +1098 -0
  43. package/dist/sideload.js.map +1 -0
  44. package/dist/swipt.d.ts +1 -0
  45. package/dist/swipt.js +631 -0
  46. package/dist/swipt.js.map +1 -0
  47. package/dist/version.d.ts +2 -0
  48. package/dist/version.js +15 -0
  49. package/dist/version.js.map +1 -0
  50. package/package.json +21 -7
  51. package/availability.mjs +0 -642
  52. package/client.mjs +0 -375
  53. package/connection.mjs +0 -450
  54. package/coredevice.mjs +0 -464
  55. package/device.mjs +0 -837
  56. package/i18n.mjs +0 -71
  57. package/ignore.mjs +0 -149
  58. package/metro.mjs +0 -432
  59. package/output.mjs +0 -177
  60. package/project.mjs +0 -1013
  61. package/proto/common_pb.js +0 -98
  62. package/proto/logs_pb.js +0 -34
  63. package/proto/repl_pb.js +0 -55
  64. package/proto/swiplets_pb.js +0 -179
  65. package/proto/system_pb.js +0 -27
  66. package/sideload.mjs +0 -1696
  67. package/swipt.mjs +0 -726
  68. package/version.mjs +0 -16
package/dist/output.js ADDED
@@ -0,0 +1,116 @@
1
+ import { tr } from "./i18n.js";
2
+ import { LogLevelSchema } from "./proto/common_pb.js";
3
+ import "./proto/swiplets_pb.js";
4
+ import { timestampDate } from "@bufbuild/protobuf/wkt";
5
+ import { styleText } from "node:util";
6
+ import select from "@inquirer/select";
7
+ import stringWidth from "string-width";
8
+ // src/output.ts
9
+ var FalseResult = class extends Error {};
10
+ const selectTheme = { style: { keysHelpTip: () => [[`↑↓`, tr("navigate")], [`⏎`, tr("select")]].map(([key, action]) => `${styleText("bold", key)} ${styleText("dim", action)}`).join(styleText("dim", " • ")) } };
11
+ const interactive = (context) => context.options.device === void 0 && context.options.team === void 0 && process.stdin.isTTY && process.stderr.isTTY;
12
+ function choose(context, message, choices, failure) {
13
+ if (!interactive(context)) throw failure;
14
+ return select({
15
+ message,
16
+ choices,
17
+ theme: selectTheme
18
+ }, {
19
+ output: process.stderr,
20
+ signal: context.signal
21
+ });
22
+ }
23
+ const spinner = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏";
24
+ async function step(label, run, { transient = false } = {}) {
25
+ const stream = process.stderr;
26
+ if (!stream.isTTY) {
27
+ console.error(label);
28
+ return run(() => {});
29
+ }
30
+ const style = (format, text) => styleText(format, text, { stream });
31
+ const started = Date.now();
32
+ const elapsed = () => {
33
+ const seconds = Math.floor((Date.now() - started) / 1e3);
34
+ return seconds > 0 ? style("dim", ` ${seconds}s`) : "";
35
+ };
36
+ const draw = (line) => stream.write(`\r\x1b[?7l\x1b[2K${line}\x1b[?7h`);
37
+ let detail = "";
38
+ let frame = 0;
39
+ const render = () => {
40
+ frame = (frame + 1) % 10;
41
+ draw(`${style("cyan", spinner[frame])} ${label}${detail && style("dim", ` ${detail}`)}${elapsed()}`);
42
+ };
43
+ stream.write("\x1B[?25l");
44
+ render();
45
+ const timer = setInterval(render, 80);
46
+ try {
47
+ const result = await run((text) => {
48
+ detail = text;
49
+ });
50
+ clearInterval(timer);
51
+ draw(transient ? "" : `${style("green", "✔")} ${label}${elapsed()}\n`);
52
+ return result;
53
+ } catch (error) {
54
+ clearInterval(timer);
55
+ draw(`${style("red", "✖")} ${label}${elapsed()}\n`);
56
+ throw error;
57
+ } finally {
58
+ stream.write("\x1B[?25h");
59
+ }
60
+ }
61
+ const levelName = (level) => level === 0 ? "info" : LogLevelSchema.value[level].name.slice(10).toLowerCase();
62
+ const pad = (value, width) => String(value).padStart(width, "0");
63
+ function clockTime(timestamp) {
64
+ const at = timestampDate(timestamp);
65
+ return `${pad(at.getHours(), 2)}:${pad(at.getMinutes(), 2)}:${pad(at.getSeconds(), 2)}.${pad(at.getMilliseconds(), 3)}`;
66
+ }
67
+ function dateTime(timestamp) {
68
+ const at = timestampDate(timestamp);
69
+ return `${at.getFullYear()}-${pad(at.getMonth() + 1, 2)}-${pad(at.getDate(), 2)} ${pad(at.getHours(), 2)}:${pad(at.getMinutes(), 2)}:${pad(at.getSeconds(), 2)}`;
70
+ }
71
+ function columns(rows) {
72
+ const widths = [];
73
+ for (const row of rows) row.forEach((cell, index) => {
74
+ widths[index] = Math.max(widths[index] ?? 0, stringWidth(cell));
75
+ });
76
+ return rows.map((row) => row.map((cell, index) => index === row.length - 1 ? cell : cell + " ".repeat(widths[index] + 2 - stringWidth(cell))).join("").trimEnd()).join("\n");
77
+ }
78
+ const frameText = (frame) => {
79
+ const position = `${frame.file}:${frame.line}:${frame.column}`;
80
+ return frame.function === "" ? position : `${frame.function} (${position})`;
81
+ };
82
+ const failureText = (failure) => [`${failure.name}: ${failure.message}`, ...failure.stack.map((frame) => ` at ${frameText(frame)}`)].join("\n");
83
+ function printScriptError(failure) {
84
+ console.error(tr("error: {message}", { message: failureText(failure) }));
85
+ return new FalseResult();
86
+ }
87
+ function printLog(entry, toStdout) {
88
+ const message = entry.tag === "" ? entry.message : `${entry.tag}: ${entry.message}`;
89
+ (toStdout ? console.log : console.error)(clockTime(entry.time), levelName(entry.level).toUpperCase(), message);
90
+ }
91
+ const serviceStatuses = {
92
+ [0]: tr("stopped"),
93
+ [1]: tr("stopped"),
94
+ [2]: tr("starting"),
95
+ [3]: tr("running"),
96
+ [4]: tr("failed")
97
+ };
98
+ const serviceEnabledText = (enabled) => enabled ? tr("enabled") : tr("disabled");
99
+ const serviceStatusText = (status) => serviceStatuses[status];
100
+ function serviceText(_id, state) {
101
+ const enabled = serviceEnabledText(state?.enabled);
102
+ const status = serviceStatuses[state?.status ?? 0];
103
+ let text = state?.since ? tr("{enabled}, {status} since {time}", {
104
+ enabled,
105
+ status,
106
+ time: clockTime(state.since)
107
+ }) : tr("{enabled}, {status}", {
108
+ enabled,
109
+ status
110
+ });
111
+ if (state?.error) text += `: ${failureText(state.error)}`;
112
+ return text;
113
+ }
114
+ export { FalseResult, choose, clockTime, columns, dateTime, failureText, interactive, printLog, printScriptError, selectTheme, serviceEnabledText, serviceStatusText, serviceText, step };
115
+
116
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","names":[],"sources":["../src/output.ts"],"sourcesContent":["import { styleText } from \"node:util\";\n\nimport { timestampDate } from \"@bufbuild/protobuf/wkt\";\nimport select from \"@inquirer/select\";\nimport stringWidth from \"string-width\";\n\nimport { tr } from \"./i18n\";\nimport { LogLevel, LogLevelSchema } from \"./proto/common_pb\";\nimport { ServiceStatus } from \"./proto/swiplets_pb\";\n\nexport class FalseResult extends Error {}\n\nexport const selectTheme = {\n style: {\n keysHelpTip: () =>\n [\n [`↑↓`, tr(\"navigate\")],\n [`⏎`, tr(\"select\")],\n ]\n .map(\n ([key, action]) =>\n `${styleText(\"bold\", key)} ${styleText(\"dim\", action)}`,\n )\n .join(styleText(\"dim\", \" • \")),\n },\n};\n\nexport const interactive = (context) =>\n context.options.device === undefined &&\n context.options.team === undefined &&\n process.stdin.isTTY &&\n process.stderr.isTTY;\n\nexport function choose(context, message, choices, failure) {\n if (!interactive(context)) {\n throw failure;\n }\n return select(\n { message, choices, theme: selectTheme },\n { output: process.stderr, signal: context.signal },\n );\n}\n\nconst spinner = \"⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏\";\n\nexport async function step(label, run, { transient = false } = {}) {\n const stream = process.stderr;\n if (!stream.isTTY) {\n console.error(label);\n return run(() => {});\n }\n const style = (format, text) => styleText(format, text, { stream });\n const started = Date.now();\n const elapsed = () => {\n const seconds = Math.floor((Date.now() - started) / 1000);\n return seconds > 0 ? style(\"dim\", ` ${seconds}s`) : \"\";\n };\n const draw = (line) => stream.write(`\\r\\x1b[?7l\\x1b[2K${line}\\x1b[?7h`);\n let detail = \"\";\n let frame = 0;\n const render = () => {\n frame = (frame + 1) % spinner.length;\n draw(\n `${style(\"cyan\", spinner[frame])} ${label}${detail && style(\"dim\", ` ${detail}`)}${elapsed()}`,\n );\n };\n stream.write(\"\\x1b[?25l\");\n render();\n const timer = setInterval(render, 80);\n try {\n const result = await run((text) => {\n detail = text;\n });\n clearInterval(timer);\n draw(transient ? \"\" : `${style(\"green\", \"✔\")} ${label}${elapsed()}\\n`);\n return result;\n } catch (error) {\n clearInterval(timer);\n draw(`${style(\"red\", \"✖\")} ${label}${elapsed()}\\n`);\n throw error;\n } finally {\n stream.write(\"\\x1b[?25h\");\n }\n}\n\nconst levelName = (level) =>\n level === LogLevel.UNSPECIFIED\n ? \"info\"\n : LogLevelSchema.value[level].name.slice(\"LOG_LEVEL_\".length).toLowerCase();\n\nconst pad = (value, width) => String(value).padStart(width, \"0\");\n\nexport function clockTime(timestamp) {\n const at = timestampDate(timestamp);\n return `${pad(at.getHours(), 2)}:${pad(at.getMinutes(), 2)}:${pad(at.getSeconds(), 2)}.${pad(at.getMilliseconds(), 3)}`;\n}\n\nexport function dateTime(timestamp) {\n const at = timestampDate(timestamp);\n return `${at.getFullYear()}-${pad(at.getMonth() + 1, 2)}-${pad(at.getDate(), 2)} ${pad(at.getHours(), 2)}:${pad(at.getMinutes(), 2)}:${pad(at.getSeconds(), 2)}`;\n}\n\nexport function columns(rows) {\n const widths = [];\n for (const row of rows) {\n row.forEach((cell, index) => {\n widths[index] = Math.max(widths[index] ?? 0, stringWidth(cell));\n });\n }\n return rows\n .map((row) =>\n row\n .map((cell, index) =>\n index === row.length - 1\n ? cell\n : cell + \" \".repeat(widths[index] + 2 - stringWidth(cell)),\n )\n .join(\"\")\n .trimEnd(),\n )\n .join(\"\\n\");\n}\n\nconst frameText = (frame) => {\n const position = `${frame.file}:${frame.line}:${frame.column}`;\n return frame.function === \"\" ? position : `${frame.function} (${position})`;\n};\n\nexport const failureText = (failure) =>\n [\n `${failure.name}: ${failure.message}`,\n ...failure.stack.map((frame) => ` at ${frameText(frame)}`),\n ].join(\"\\n\");\n\nexport function printScriptError(failure) {\n console.error(tr(\"error: {message}\", { message: failureText(failure) }));\n return new FalseResult();\n}\n\nexport function printLog(entry, toStdout) {\n const message =\n entry.tag === \"\" ? entry.message : `${entry.tag}: ${entry.message}`;\n (toStdout ? console.log : console.error)(\n clockTime(entry.time),\n levelName(entry.level).toUpperCase(),\n message,\n );\n}\n\nconst serviceStatuses = {\n [ServiceStatus.UNSPECIFIED]: tr(\"stopped\"),\n [ServiceStatus.STOPPED]: tr(\"stopped\"),\n [ServiceStatus.STARTING]: tr(\"starting\"),\n [ServiceStatus.RUNNING]: tr(\"running\"),\n [ServiceStatus.FAILED]: tr(\"failed\"),\n};\n\nexport const serviceEnabledText = (enabled) =>\n enabled ? tr(\"enabled\") : tr(\"disabled\");\n\nexport const serviceStatusText = (status) => serviceStatuses[status];\n\nexport function serviceText(_id, state) {\n const enabled = serviceEnabledText(state?.enabled);\n const status = serviceStatuses[state?.status ?? ServiceStatus.UNSPECIFIED];\n let text = state?.since\n ? tr(\"{enabled}, {status} since {time}\", {\n enabled,\n status,\n time: clockTime(state.since),\n })\n : tr(\"{enabled}, {status}\", { enabled, status });\n if (state?.error) {\n text += `: ${failureText(state.error)}`;\n }\n return text;\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,cAAb,cAAiC,MAAM,CAAC;AAExC,MAAa,cAAc,EACzB,OAAO,EACL,mBACE,CACE,CAAC,MAAM,GAAG,UAAU,CAAC,GACrB,CAAC,KAAK,GAAG,QAAQ,CAAC,CACpB,CAAC,CACE,KACE,CAAC,KAAK,YACL,GAAG,UAAU,QAAQ,GAAG,EAAE,GAAG,UAAU,OAAO,MAAM,GACxD,CAAC,CACA,KAAK,UAAU,OAAO,KAAK,CAAC,EACnC,EACF;AAEA,MAAa,eAAe,YAC1B,QAAQ,QAAQ,WAAW,KAAA,KAC3B,QAAQ,QAAQ,SAAS,KAAA,KACzB,QAAQ,MAAM,SACd,QAAQ,OAAO;AAEjB,SAAgB,OAAO,SAAS,SAAS,SAAS,SAAS;CACzD,IAAI,CAAC,YAAY,OAAO,GACtB,MAAM;CAER,OAAO,OACL;EAAE;EAAS;EAAS,OAAO;CAAY,GACvC;EAAE,QAAQ,QAAQ;EAAQ,QAAQ,QAAQ;CAAO,CACnD;AACF;AAEA,MAAM,UAAU;AAEhB,eAAsB,KAAK,OAAO,KAAK,EAAE,YAAY,UAAU,CAAC,GAAG;CACjE,MAAM,SAAS,QAAQ;CACvB,IAAI,CAAC,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,SAAS;CACxC,QAAQ,MAAM,GAAG,oBAAoB,EAAE,SAAS,YAAY,OAAO,EAAE,CAAC,CAAC;CACvE,OAAO,IAAI,YAAY;AACzB;AAEA,SAAgB,SAAS,OAAO,UAAU;CACxC,MAAM,UACJ,MAAM,QAAQ,KAAK,MAAM,UAAU,GAAG,MAAM,IAAI,IAAI,MAAM;CAC5D,CAAC,WAAW,QAAQ,MAAM,QAAQ,MAAA,CAChC,UAAU,MAAM,IAAI,GACpB,UAAU,MAAM,KAAK,CAAC,CAAC,YAAY,GACnC,OACF;AACF;AAEA,MAAM,kBAAkB;EACO,IAAA,GAAG,SAAS;EAChB,IAAA,GAAG,SAAS;EACX,IAAA,GAAG,UAAU;EACd,IAAA,GAAG,SAAS;EACb,IAAA,GAAG,QAAQ;AACrC;AAEA,MAAa,sBAAsB,YACjC,UAAU,GAAG,SAAS,IAAI,GAAG,UAAU;AAEzC,MAAa,qBAAqB,WAAW,gBAAgB;AAE7D,SAAgB,YAAY,KAAK,OAAO;CACtC,MAAM,UAAU,mBAAmB,OAAO,OAAO;CACjD,MAAM,SAAS,gBAAgB,OAAO,UAAA;CACtC,IAAI,OAAO,OAAO,QACd,GAAG,oCAAoC;EACrC;EACA;EACA,MAAM,UAAU,MAAM,KAAK;CAC7B,CAAC,IACD,GAAG,uBAAuB;EAAE;EAAS;CAAO,CAAC;CACjD,IAAI,OAAO,OACT,QAAQ,KAAK,YAAY,MAAM,KAAK;CAEtC,OAAO;AACT"}
@@ -0,0 +1,18 @@
1
+ export declare function loadProject(root: any): {
2
+ root: any;
3
+ manifest: any;
4
+ config: any;
5
+ localizedNames: any;
6
+ apiLevel: any;
7
+ minimumIOSVersion: any;
8
+ apiDirectory: string;
9
+ app: string;
10
+ extension: string;
11
+ };
12
+ export declare function buildProject(root: any, checker?: any): Promise<{
13
+ id: any;
14
+ archive: string;
15
+ digest: string;
16
+ }>;
17
+ export declare function sourceCommand(root: any, given: any): void;
18
+ export declare function createCommand(directory: any): void;