@scalebun-release/cli 2.5.0

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 (210) hide show
  1. package/bin/scalebun.js +2 -0
  2. package/lib/api/client.d.ts +52 -0
  3. package/lib/api/client.d.ts.map +1 -0
  4. package/lib/api/client.js +335 -0
  5. package/lib/api/client.js.map +1 -0
  6. package/lib/commands/ci-init.d.ts +3 -0
  7. package/lib/commands/ci-init.d.ts.map +1 -0
  8. package/lib/commands/ci-init.js +348 -0
  9. package/lib/commands/ci-init.js.map +1 -0
  10. package/lib/commands/doctor.d.ts +31 -0
  11. package/lib/commands/doctor.d.ts.map +1 -0
  12. package/lib/commands/doctor.js +559 -0
  13. package/lib/commands/doctor.js.map +1 -0
  14. package/lib/commands/launch.d.ts +3 -0
  15. package/lib/commands/launch.d.ts.map +1 -0
  16. package/lib/commands/launch.js +23 -0
  17. package/lib/commands/launch.js.map +1 -0
  18. package/lib/commands/link.d.ts +16 -0
  19. package/lib/commands/link.d.ts.map +1 -0
  20. package/lib/commands/link.js +164 -0
  21. package/lib/commands/link.js.map +1 -0
  22. package/lib/commands/login.d.ts +12 -0
  23. package/lib/commands/login.d.ts.map +1 -0
  24. package/lib/commands/login.js +124 -0
  25. package/lib/commands/login.js.map +1 -0
  26. package/lib/commands/migrate-codepush.d.ts +13 -0
  27. package/lib/commands/migrate-codepush.d.ts.map +1 -0
  28. package/lib/commands/migrate-codepush.js +98 -0
  29. package/lib/commands/migrate-codepush.js.map +1 -0
  30. package/lib/commands/ota-bundle.d.ts +22 -0
  31. package/lib/commands/ota-bundle.d.ts.map +1 -0
  32. package/lib/commands/ota-bundle.js +253 -0
  33. package/lib/commands/ota-bundle.js.map +1 -0
  34. package/lib/commands/ota-channels.d.ts +3 -0
  35. package/lib/commands/ota-channels.d.ts.map +1 -0
  36. package/lib/commands/ota-channels.js +231 -0
  37. package/lib/commands/ota-channels.js.map +1 -0
  38. package/lib/commands/ota-delete-bundle.d.ts +16 -0
  39. package/lib/commands/ota-delete-bundle.d.ts.map +1 -0
  40. package/lib/commands/ota-delete-bundle.js +96 -0
  41. package/lib/commands/ota-delete-bundle.js.map +1 -0
  42. package/lib/commands/ota-inspect.d.ts +3 -0
  43. package/lib/commands/ota-inspect.d.ts.map +1 -0
  44. package/lib/commands/ota-inspect.js +258 -0
  45. package/lib/commands/ota-inspect.js.map +1 -0
  46. package/lib/commands/ota-keys.d.ts +91 -0
  47. package/lib/commands/ota-keys.d.ts.map +1 -0
  48. package/lib/commands/ota-keys.js +765 -0
  49. package/lib/commands/ota-keys.js.map +1 -0
  50. package/lib/commands/ota-promote.d.ts +3 -0
  51. package/lib/commands/ota-promote.d.ts.map +1 -0
  52. package/lib/commands/ota-promote.js +194 -0
  53. package/lib/commands/ota-promote.js.map +1 -0
  54. package/lib/commands/ota-publish.d.ts +26 -0
  55. package/lib/commands/ota-publish.d.ts.map +1 -0
  56. package/lib/commands/ota-publish.js +892 -0
  57. package/lib/commands/ota-publish.js.map +1 -0
  58. package/lib/commands/ota-rollout.d.ts +3 -0
  59. package/lib/commands/ota-rollout.d.ts.map +1 -0
  60. package/lib/commands/ota-rollout.js +265 -0
  61. package/lib/commands/ota-rollout.js.map +1 -0
  62. package/lib/commands/ota-sign.d.ts +19 -0
  63. package/lib/commands/ota-sign.d.ts.map +1 -0
  64. package/lib/commands/ota-sign.js +245 -0
  65. package/lib/commands/ota-sign.js.map +1 -0
  66. package/lib/commands/push-apns.d.ts +3 -0
  67. package/lib/commands/push-apns.d.ts.map +1 -0
  68. package/lib/commands/push-apns.js +166 -0
  69. package/lib/commands/push-apns.js.map +1 -0
  70. package/lib/commands/quickstart.d.ts +4 -0
  71. package/lib/commands/quickstart.d.ts.map +1 -0
  72. package/lib/commands/quickstart.js +672 -0
  73. package/lib/commands/quickstart.js.map +1 -0
  74. package/lib/commands/shell.d.ts +28 -0
  75. package/lib/commands/shell.d.ts.map +1 -0
  76. package/lib/commands/shell.js +512 -0
  77. package/lib/commands/shell.js.map +1 -0
  78. package/lib/commands/tls-pins.d.ts +27 -0
  79. package/lib/commands/tls-pins.d.ts.map +1 -0
  80. package/lib/commands/tls-pins.js +209 -0
  81. package/lib/commands/tls-pins.js.map +1 -0
  82. package/lib/index.d.ts +2 -0
  83. package/lib/index.d.ts.map +1 -0
  84. package/lib/index.js +233 -0
  85. package/lib/index.js.map +1 -0
  86. package/lib/ui/banner.d.ts +23 -0
  87. package/lib/ui/banner.d.ts.map +1 -0
  88. package/lib/ui/banner.js +162 -0
  89. package/lib/ui/banner.js.map +1 -0
  90. package/lib/ui/graphics.d.ts +18 -0
  91. package/lib/ui/graphics.d.ts.map +1 -0
  92. package/lib/ui/graphics.js +134 -0
  93. package/lib/ui/graphics.js.map +1 -0
  94. package/lib/ui/mark.d.ts +4 -0
  95. package/lib/ui/mark.d.ts.map +1 -0
  96. package/lib/ui/mark.js +21 -0
  97. package/lib/ui/mark.js.map +1 -0
  98. package/lib/ui/menu.d.ts +109 -0
  99. package/lib/ui/menu.d.ts.map +1 -0
  100. package/lib/ui/menu.js +314 -0
  101. package/lib/ui/menu.js.map +1 -0
  102. package/lib/ui/sixel.d.ts +6 -0
  103. package/lib/ui/sixel.d.ts.map +1 -0
  104. package/lib/ui/sixel.js +9 -0
  105. package/lib/ui/sixel.js.map +1 -0
  106. package/lib/utils/apps.d.ts +29 -0
  107. package/lib/utils/apps.d.ts.map +1 -0
  108. package/lib/utils/apps.js +19 -0
  109. package/lib/utils/apps.js.map +1 -0
  110. package/lib/utils/browser.d.ts +9 -0
  111. package/lib/utils/browser.d.ts.map +1 -0
  112. package/lib/utils/browser.js +39 -0
  113. package/lib/utils/browser.js.map +1 -0
  114. package/lib/utils/bundle.d.ts +153 -0
  115. package/lib/utils/bundle.d.ts.map +1 -0
  116. package/lib/utils/bundle.js +459 -0
  117. package/lib/utils/bundle.js.map +1 -0
  118. package/lib/utils/bundleStore.d.ts +128 -0
  119. package/lib/utils/bundleStore.d.ts.map +1 -0
  120. package/lib/utils/bundleStore.js +250 -0
  121. package/lib/utils/bundleStore.js.map +1 -0
  122. package/lib/utils/context.d.ts +88 -0
  123. package/lib/utils/context.d.ts.map +1 -0
  124. package/lib/utils/context.js +247 -0
  125. package/lib/utils/context.js.map +1 -0
  126. package/lib/utils/credentials.d.ts +59 -0
  127. package/lib/utils/credentials.d.ts.map +1 -0
  128. package/lib/utils/credentials.js +147 -0
  129. package/lib/utils/credentials.js.map +1 -0
  130. package/lib/utils/guide.d.ts +63 -0
  131. package/lib/utils/guide.d.ts.map +1 -0
  132. package/lib/utils/guide.js +191 -0
  133. package/lib/utils/guide.js.map +1 -0
  134. package/lib/utils/hash.d.ts +3 -0
  135. package/lib/utils/hash.d.ts.map +1 -0
  136. package/lib/utils/hash.js +44 -0
  137. package/lib/utils/hash.js.map +1 -0
  138. package/lib/utils/native-id.d.ts +17 -0
  139. package/lib/utils/native-id.d.ts.map +1 -0
  140. package/lib/utils/native-id.js +105 -0
  141. package/lib/utils/native-id.js.map +1 -0
  142. package/lib/utils/output.d.ts +96 -0
  143. package/lib/utils/output.d.ts.map +1 -0
  144. package/lib/utils/output.js +135 -0
  145. package/lib/utils/output.js.map +1 -0
  146. package/lib/utils/prompt.d.ts +106 -0
  147. package/lib/utils/prompt.d.ts.map +1 -0
  148. package/lib/utils/prompt.js +457 -0
  149. package/lib/utils/prompt.js.map +1 -0
  150. package/lib/utils/provenance.d.ts +30 -0
  151. package/lib/utils/provenance.d.ts.map +1 -0
  152. package/lib/utils/provenance.js +157 -0
  153. package/lib/utils/provenance.js.map +1 -0
  154. package/lib/utils/resolve.d.ts +81 -0
  155. package/lib/utils/resolve.d.ts.map +1 -0
  156. package/lib/utils/resolve.js +139 -0
  157. package/lib/utils/resolve.js.map +1 -0
  158. package/lib/utils/sdkBin.d.ts +18 -0
  159. package/lib/utils/sdkBin.d.ts.map +1 -0
  160. package/lib/utils/sdkBin.js +76 -0
  161. package/lib/utils/sdkBin.js.map +1 -0
  162. package/lib/utils/signer.d.ts +94 -0
  163. package/lib/utils/signer.d.ts.map +1 -0
  164. package/lib/utils/signer.js +230 -0
  165. package/lib/utils/signer.js.map +1 -0
  166. package/lib/utils/signing.d.ts +102 -0
  167. package/lib/utils/signing.d.ts.map +1 -0
  168. package/lib/utils/signing.js +229 -0
  169. package/lib/utils/signing.js.map +1 -0
  170. package/lib/utils/transportSecurity.d.ts +36 -0
  171. package/lib/utils/transportSecurity.d.ts.map +1 -0
  172. package/lib/utils/transportSecurity.js +74 -0
  173. package/lib/utils/transportSecurity.js.map +1 -0
  174. package/lib/utils/trustAnchor.d.ts +109 -0
  175. package/lib/utils/trustAnchor.d.ts.map +1 -0
  176. package/lib/utils/trustAnchor.js +169 -0
  177. package/lib/utils/trustAnchor.js.map +1 -0
  178. package/lib/utils/ui.d.ts +12 -0
  179. package/lib/utils/ui.d.ts.map +1 -0
  180. package/lib/utils/ui.js +60 -0
  181. package/lib/utils/ui.js.map +1 -0
  182. package/lib/utils/validate.d.ts +62 -0
  183. package/lib/utils/validate.d.ts.map +1 -0
  184. package/lib/utils/validate.js +189 -0
  185. package/lib/utils/validate.js.map +1 -0
  186. package/lib/vendor/ota-protocol/base64.d.ts +11 -0
  187. package/lib/vendor/ota-protocol/base64.d.ts.map +1 -0
  188. package/lib/vendor/ota-protocol/base64.js +39 -0
  189. package/lib/vendor/ota-protocol/base64.js.map +1 -0
  190. package/lib/vendor/ota-protocol/codec.d.ts +26 -0
  191. package/lib/vendor/ota-protocol/codec.d.ts.map +1 -0
  192. package/lib/vendor/ota-protocol/codec.js +349 -0
  193. package/lib/vendor/ota-protocol/codec.js.map +1 -0
  194. package/lib/vendor/ota-protocol/hex.d.ts +8 -0
  195. package/lib/vendor/ota-protocol/hex.d.ts.map +1 -0
  196. package/lib/vendor/ota-protocol/hex.js +31 -0
  197. package/lib/vendor/ota-protocol/hex.js.map +1 -0
  198. package/lib/vendor/ota-protocol/index.d.ts +17 -0
  199. package/lib/vendor/ota-protocol/index.d.ts.map +1 -0
  200. package/lib/vendor/ota-protocol/index.js +41 -0
  201. package/lib/vendor/ota-protocol/index.js.map +1 -0
  202. package/lib/vendor/ota-protocol/limits.d.ts +39 -0
  203. package/lib/vendor/ota-protocol/limits.d.ts.map +1 -0
  204. package/lib/vendor/ota-protocol/limits.js +42 -0
  205. package/lib/vendor/ota-protocol/limits.js.map +1 -0
  206. package/lib/vendor/ota-protocol/types.d.ts +73 -0
  207. package/lib/vendor/ota-protocol/types.d.ts.map +1 -0
  208. package/lib/vendor/ota-protocol/types.js +24 -0
  209. package/lib/vendor/ota-protocol/types.js.map +1 -0
  210. package/package.json +37 -0
package/lib/ui/menu.js ADDED
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.splitKeys = splitKeys;
7
+ exports.composeFrame = composeFrame;
8
+ exports.menu = menu;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const ui_1 = require("../utils/ui");
11
+ const context_1 = require("../utils/context");
12
+ const guide_1 = require("../utils/guide");
13
+ const KEY = {
14
+ up: ['\x1b[A', '\x1bOA'],
15
+ down: ['\x1b[B', '\x1bOB'],
16
+ right: ['\x1b[C', '\x1bOC'],
17
+ left: ['\x1b[D', '\x1bOD'],
18
+ enter: ['\r', '\n'],
19
+ esc: '\x1b',
20
+ ctrlC: '\x03',
21
+ backspace: ['\x7f', '\b'],
22
+ };
23
+ /**
24
+ * Split one stdin chunk into individual keypresses.
25
+ *
26
+ * stdin delivers BYTES, not keys. Press two arrows faster than the event loop
27
+ * drains stdin — which is just "press them quickly" — and both arrive in a
28
+ * single chunk as `\x1b[B\x1b[B`. Comparing the whole chunk against a table of
29
+ * key sequences matches nothing, so the keys are silently dropped and the menu
30
+ * looks frozen. The same happens to a held-down arrow and to any paste.
31
+ *
32
+ * Escape sequences are ESC, an introducer (`[` for CSI, `O` for SS3), then
33
+ * parameter bytes up to a final byte in the 0x40-0x7E range. A lone ESC with
34
+ * nothing after it is the Escape key.
35
+ */
36
+ function splitKeys(chunk) {
37
+ const keys = [];
38
+ let i = 0;
39
+ while (i < chunk.length) {
40
+ if (chunk[i] === '\x1b' && (chunk[i + 1] === '[' || chunk[i + 1] === 'O')) {
41
+ let j = i + 2;
42
+ // Parameter and intermediate bytes come before the final byte.
43
+ while (j < chunk.length && chunk[j] >= '0' && chunk[j] <= '?')
44
+ j++;
45
+ keys.push(chunk.slice(i, j + 1));
46
+ i = j + 1;
47
+ continue;
48
+ }
49
+ keys.push(chunk[i]);
50
+ i += 1;
51
+ }
52
+ return keys;
53
+ }
54
+ /** Widest label in a list, so descriptions line up in one column. */
55
+ function column(labels) {
56
+ return labels.reduce((w, l) => Math.max(w, l.length), 0);
57
+ }
58
+ function lines(s) {
59
+ return s.replace(/\n+$/, '').split('\n');
60
+ }
61
+ /**
62
+ * Show at most `max` items, keeping the cursor in view.
63
+ *
64
+ * Two rows are given up to the more-markers only when there is something to
65
+ * mark, and the window is clamped to the ends of the list so the last item is
66
+ * reachable rather than always leaving the cursor mid-screen.
67
+ */
68
+ function windowItems(items, active, max) {
69
+ if (max <= 0)
70
+ return [];
71
+ if (items.length <= max)
72
+ return items;
73
+ // Below three rows there is no room for an item AND its markers, and
74
+ // returning them anyway would overflow the very budget this exists to
75
+ // respect. Show the cursor row alone — the caller's plan ladder makes this
76
+ // unreachable today, but a future layout must not be able to break the fit
77
+ // by asking for a smaller list.
78
+ if (max < 3)
79
+ return [items[active]].slice(0, max);
80
+ const inner = Math.max(1, max - 2);
81
+ const start = Math.max(0, Math.min(active - Math.floor(inner / 2), items.length - inner));
82
+ const end = start + inner;
83
+ const above = start;
84
+ const below = items.length - end;
85
+ return [
86
+ chalk_1.default.dim(above > 0 ? ` ↑ ${above} more` : ''),
87
+ ...items.slice(start, end),
88
+ chalk_1.default.dim(below > 0 ? ` ↓ ${below} more` : ''),
89
+ ];
90
+ }
91
+ /**
92
+ * Compose one frame that fits.
93
+ *
94
+ * Pure, and exported, because the fit is the invariant that matters and it is
95
+ * invisible until it breaks: an overflowing frame scrolls the terminal, so the
96
+ * next redraw's cursor-home lands somewhere other than the top of the frame and
97
+ * the screen degrades into a collage of half-frames. That reads as a hung
98
+ * session, not as a layout bug, which is what makes it worth a test rather than
99
+ * an eyeball.
100
+ */
101
+ function composeFrame(input) {
102
+ // One row is left unused on purpose: writing the very last line of a
103
+ // terminal scrolls it by one, which is the same overflow this budget exists
104
+ // to prevent.
105
+ const rows = Math.max(8, input.rows - 1);
106
+ const build = (show) => {
107
+ const head = [];
108
+ if (show.status)
109
+ head.push(...input.status);
110
+ if (show.extras)
111
+ head.push(...input.extras);
112
+ head.push('');
113
+ const top = show.art ? input.art : [];
114
+ // rows - top - head - title - (blank + footer)
115
+ return {
116
+ top,
117
+ head,
118
+ budget: rows - top.length - head.length - input.title.length - 2 - (input.notice ? 1 : 0),
119
+ };
120
+ };
121
+ // Progressive degradation, in the order things are worth losing.
122
+ //
123
+ // The status box goes FIRST. It says you are authenticated, which `doctor`
124
+ // will tell you and which you will find out the moment you run anything.
125
+ // `extras` is the project line — which app and channel you are pointed at —
126
+ // and on a tool that can roll back production for every device, knowing the
127
+ // target beats knowing the login state.
128
+ //
129
+ // The logo goes LAST, because it is the reason for coming back to this
130
+ // screen rather than staying in the scrollback of the last command.
131
+ //
132
+ // Three visible rows is the floor for a list still being navigable.
133
+ const PLANS = [
134
+ { art: true, status: true, extras: true },
135
+ { art: true, status: false, extras: true },
136
+ { art: true, status: false, extras: false },
137
+ { art: false, status: true, extras: true },
138
+ { art: false, status: false, extras: true },
139
+ { art: false, status: false, extras: false },
140
+ ];
141
+ let layout = build(PLANS[PLANS.length - 1]);
142
+ for (const plan of PLANS) {
143
+ const candidate = build(plan);
144
+ if (candidate.budget >= 3) {
145
+ layout = candidate;
146
+ break;
147
+ }
148
+ }
149
+ return [
150
+ ...layout.top,
151
+ ...layout.head,
152
+ ...input.title,
153
+ ...windowItems(input.items, input.active, layout.budget),
154
+ ...(input.notice ? [chalk_1.default.yellow(` ⚠ ${input.notice}`)] : []),
155
+ '',
156
+ input.footer,
157
+ ];
158
+ }
159
+ function menu(deps) {
160
+ return new Promise((resolve) => {
161
+ const stdin = process.stdin;
162
+ const stdout = process.stdout;
163
+ /** null = looking at the group list; a number = inside that group. */
164
+ let openGroup = null;
165
+ let groupIdx = 0;
166
+ let cmdIdx = 0;
167
+ /** Title block, selectable rows, and the key hint — before any windowing. */
168
+ const parts = () => {
169
+ if (openGroup === null) {
170
+ const width = column(guide_1.GROUPS.map((g) => g.title));
171
+ return {
172
+ title: [` ${chalk_1.default.bold.white('WHAT DO YOU WANT TO DO?')}`, ''],
173
+ items: guide_1.GROUPS.map((g, i) => {
174
+ const on = i === groupIdx;
175
+ const pointer = on ? chalk_1.default.cyan('❯') : ' ';
176
+ const t = g.title.padEnd(width);
177
+ return ` ${pointer} ${on ? chalk_1.default.bold.cyan(t) : chalk_1.default.white(t)} ${chalk_1.default.dim(g.summary)}`;
178
+ }),
179
+ footer: chalk_1.default.dim(' ↑↓ move · ↵ open · type to run a command · esc quit'),
180
+ active: groupIdx,
181
+ };
182
+ }
183
+ const g = guide_1.GROUPS[openGroup];
184
+ const labels = g.commands.map((c) => c.argv.join(' '));
185
+ const width = column(labels);
186
+ return {
187
+ title: [
188
+ ` ${chalk_1.default.bold.white(g.title)} ${chalk_1.default.dim(g.summary)}`,
189
+ '',
190
+ ],
191
+ items: g.commands.map((c, i) => {
192
+ const on = i === cmdIdx;
193
+ const pointer = on ? chalk_1.default.cyan('❯') : ' ';
194
+ const label = labels[i].padEnd(width);
195
+ return ` ${pointer} ${on ? chalk_1.default.bold.cyan(label) : chalk_1.default.cyan(label)} ${chalk_1.default.dim(c.desc)}`;
196
+ }),
197
+ footer: chalk_1.default.dim(' ↑↓ move · ↵ run · ← back · esc back · type to run a command'),
198
+ active: cmdIdx,
199
+ };
200
+ };
201
+ const draw = () => {
202
+ const ctx = (0, context_1.getContext)();
203
+ const { title, items, footer, active } = parts();
204
+ const extras = [];
205
+ const ctxLine = (0, guide_1.contextLineText)(ctx);
206
+ if (ctxLine)
207
+ extras.push(ctxLine);
208
+ const hint = (0, guide_1.nextStepHint)(ctx);
209
+ if (hint)
210
+ extras.push(hint);
211
+ const frame = composeFrame({
212
+ rows: stdout.rows ?? 24,
213
+ notice: deps.notice?.(),
214
+ art: deps.art ? lines(deps.art) : [],
215
+ status: lines((0, ui_1.statusText)()),
216
+ extras,
217
+ title,
218
+ items,
219
+ active,
220
+ footer,
221
+ });
222
+ // \x1b[H home · \x1b[2J clear the screen · \x1b[3J drop the scrollback a
223
+ // finished command left behind, so nothing can scroll back into view.
224
+ // No trailing newline: that alone would push the frame up by one row.
225
+ stdout.write('\x1b[H\x1b[2J\x1b[3J' + frame.join('\n'));
226
+ };
227
+ let done = false;
228
+ const cleanup = () => {
229
+ if (stdin.isTTY)
230
+ stdin.setRawMode(false);
231
+ stdin.pause();
232
+ stdin.removeListener('data', onData);
233
+ stdout.removeListener('resize', draw);
234
+ stdout.write('\x1b[?25h'); // show cursor
235
+ };
236
+ const finish = (choice) => {
237
+ done = true;
238
+ cleanup();
239
+ resolve(choice);
240
+ };
241
+ const onData = (chunk) => {
242
+ // One chunk can carry several keypresses. Handle each in turn, and stop
243
+ // the moment one of them ends the menu — the rest belong to whatever
244
+ // comes next, not to a menu that is already gone.
245
+ for (const key of splitKeys(chunk)) {
246
+ if (done)
247
+ return;
248
+ handleKey(key, chunk);
249
+ }
250
+ };
251
+ const handleKey = (key, whole) => {
252
+ const list = openGroup === null ? guide_1.GROUPS : guide_1.GROUPS[openGroup].commands;
253
+ const idx = openGroup === null ? groupIdx : cmdIdx;
254
+ const setIdx = (n) => {
255
+ if (openGroup === null)
256
+ groupIdx = n;
257
+ else
258
+ cmdIdx = n;
259
+ };
260
+ const back = () => {
261
+ openGroup = null;
262
+ draw();
263
+ };
264
+ if (KEY.up.includes(key)) {
265
+ setIdx((idx - 1 + list.length) % list.length);
266
+ return draw();
267
+ }
268
+ if (KEY.down.includes(key)) {
269
+ setIdx((idx + 1) % list.length);
270
+ return draw();
271
+ }
272
+ if (KEY.enter.includes(key) || KEY.right.includes(key)) {
273
+ if (openGroup === null) {
274
+ openGroup = groupIdx;
275
+ cmdIdx = 0;
276
+ return draw();
277
+ }
278
+ return finish({ kind: 'run', argv: guide_1.GROUPS[openGroup].commands[cmdIdx].argv });
279
+ }
280
+ if (KEY.left.includes(key) || KEY.backspace.includes(key)) {
281
+ if (openGroup !== null)
282
+ return back();
283
+ return;
284
+ }
285
+ if (key === KEY.esc) {
286
+ if (openGroup !== null)
287
+ return back();
288
+ return finish({ kind: 'quit' });
289
+ }
290
+ if (key === KEY.ctrlC)
291
+ return finish({ kind: 'quit' });
292
+ // Anything printable is the user deciding they would rather type. The
293
+ // seed is the whole printable run from this key, not just the one
294
+ // character: a fast typist or a paste puts several in at once, and
295
+ // seeding only the first would drop the rest on the floor — the same
296
+ // class of bug as dropping a doubled arrow key.
297
+ if (key.length === 1 && key >= ' ' && key !== '\x7f') {
298
+ const printable = whole.length > 1 && /^[ -~]+$/.test(whole) ? whole : key;
299
+ return finish({ kind: 'type', seed: printable === '/' ? '' : printable });
300
+ }
301
+ };
302
+ stdin.resume();
303
+ stdin.setEncoding('utf8');
304
+ if (stdin.isTTY)
305
+ stdin.setRawMode(true);
306
+ stdout.write('\x1b[?25l'); // hide cursor
307
+ stdin.on('data', onData);
308
+ // Dragging the window smaller changes the budget; without this the frame
309
+ // keeps its old height and starts overflowing again.
310
+ stdout.on('resize', draw);
311
+ draw();
312
+ });
313
+ }
314
+ //# sourceMappingURL=menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/ui/menu.ts"],"names":[],"mappings":";;;;;AA6FA,8BAgBC;AAmED,oCA0DC;AAED,oBA8JC;AA1YD,kDAA0B;AAC1B,oCAAyC;AACzC,8CAA8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ACT,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const SIXEL: Record<string, {
2
+ w: number;
3
+ h: number;
4
+ d: string;
5
+ }>;
6
+ //# sourceMappingURL=sixel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sixel.d.ts","sourceRoot":"","sources":["../../src/ui/sixel.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAC6xL,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SIXEL = void 0;
4
+ /* eslint-disable */
5
+ // prettier-ignore
6
+ // GENERATED by tools/gen-sixel.mjs from assets/scalebun-mark.svg — do not edit by hand.
7
+ // 9 rows tall, keyed by terminal cell height in px.
8
+ exports.SIXEL = { "16": { "w": 102, "h": 144, "d": "\u001bP0;1;0q\"1;1;102;144#0;2;31;27;90#0!77?__ooww{{}}!5~}{!8-#0!15?!5_!46?__oow{{}}!19~}!7-#0!8?_w{}}!9~}}{wo_!33?O{}!10~^!20~!7-#0!6?w}!8~NNN^!8~}{o!31?BB!4FBB@@ow}!8~NFB!9~_!6-#0!4?o!9~F!6?@BF^!7~{_!34?_w}!8~NF@!4?@^!6~^B!6-#0!4?!10~!11?B^!7~{_!28?_w{!8~^F@!24-#0!4?!10~!13?N!8~w!23?_o{!8~^FB!28-#0!4?B!9~o!13?N!8~{!18?_o{}!7~^NB!32-#0!6?N!8~{_!12?^!8~}!14?ow}!8~NB@!35-#0!7?@F!8~}w_!10?^!8~}!9?_w}!9~f`!4_!35-#0!10?BN^!7~}wo!8?!9~w!7?^!22~}}{{{wwo__!21-#0!13?@F^!8~}{o!5?N!7~^!9?!4@!10B!4FNNN^^!10~}{wwo_!13-#0!11?ow{}!9~^NF!7?@BBB@@!35?@@BFFN^!8~}{w_!8-#0!7?o{}!8~^FFB@!60?@BN^!8~{w_!4-#0!4?o{!8~NB@!50?!5_!15?@BN!8~{o-#0??w!8~NB!51?{}!7~}{!15?@F!8~{-#0_!9~B!53?BFN!4^NNFB!13?oww{|!8~}-#0!10~!77?F^!13~-#0N!9~_!80?p!8~^-#0?F!9~{o!74?_ow}!7~^B-#0???BN!9~{wo_!41?{}!4~}}{wo__!6?___oow{}!8~^NB@!4-#0!6?@FN^!9~}{{woo___!32?BN^!24~^^NFB@!9-#0!11?@BFFN^^!13~!4}!18{!5}{{{o???@@BBB!10FBBB@@!17-#0!20?@@BBFFF!4N!5^!15~!5^NNNFF@!40-\u001b\\" }, "20": { "w": 127, "h": 180, "d": "\u001bP0;1;0q\"1;1;127;180#0;2;31;27;90#0!99?__ooww{{}}}!5~}{!10-#0!87?__ooww{{}}!21~!9-#0!13?_ooww!6{wwwoo_!48?_oww{{}}!32~o!8-#0!9?_w{!19~}{wo!42?!12~^^NNn!25~!8-#0!7?w}!10~^NFFN^!11~}w_!39?@!6B@@??_o{}!10~^FB@N!11~!8-#0!5?o!12~B!7?@BF^!9~}w!45?o{}!10~^FB!6?^!9~^!8-#0!5?!12~!14?F!10~{!39?ow}!10~^FB!12?@!5B@!10-#0!5?!12~!16?^!10~w!33?_w}!10~^NB@!32-#0!5?!12~!17?N!10~}!28?_w{!11~NB@!36-#0!5?@!11~}!17?^!11~_!22?_o{!11~NF@!40-#0!7?F!11~w!16?^!11~_!17?_o{}!10~^FB!44-#0!8?@F!11~w_!14?^!11~!14?ow}!10~^FB!48-#0!11?BN!10~}w_!12?!12~!10?w}!14~}}!6{wwwooo___!34-#0!14?BN!11~{wo!9?!11~{!9?FN^!32~}}{{woo__!23-#0!17?BF^!11~}w_!6?N!9~^!18?!10@!5BFFFNN^^!14~}{{wo_!16-#0!14?_ow{}!12~^NB!8?@!6B@!43?@@BBFN^!12~}{wo!11-#0!10?ow{!11~^^NFB@!72?@BN^!11~}wo!7-#0!7?o{!10~^NFB!84?@FN!11~{o!4-#0!4?o{!10~NB@!62?__ooowwoo__!19?BN!10~}o-#0??w!11~F!64?w}!12~w!19?@N!10~}-#0_}!10~N!67?FN^!6~^^NF!17?_ooww|!11~-#0!12~!97?!18~-#0!12~!98?@BFN^!11~N-#0F!11~}_!99?o}!10~F-#0?@^!11~{o!93?_w{!10~^F-#0???@F^!11~{wo_!53?{}!5~}}{wo_!14?__oww{}!11~NF@!5-#0!6?@BN^!12~}{woo_!46?BN!13~!10}!14~^NFB@!9-#0!11?@BFN^!14~}}{{{www!4o!6_!12?!8_ooo!4_??@BFFN^^^!16~^^^NNFFBB@!16-#0!17?@BBFNN^^!51~}!12?!8@!30-#0!27?@@@BB!4F!4N!7^!15~!6^!4NFFBB!51-\u001b\\" }, "26": { "w": 165, "h": 234, "d": "\u001bP0;1;0q\"1;1;165;234#0;2;31;27;90#0!132?__ooww{{}}}!5~}}{o!13-#0!120?__ooww{{}}!22~}!12-#0!109?__oow{{}}!35~o!11-#0!17?_ow{{!4}~~~!5}{{woo_!61?_ow{{}!47~!11-#0!12?_o{}!25~}{w_!54?K!18~^^NN!32~!11-#0!10?o}!15~^^!17~}w_!51?@BFF!5NFFFBBB@@?_w}!15~NFB^!15~!10-#0!8?w!15~NB!5?@BFN^!14~{_!62?_w{!15~NF@!5?!15~!10-#0!7?}!15~B!13?BF^!12~}w!56?_o{}!14~NF@!9?@N!11~^B!10-#0!6?}!15~!18?BN!13~w!51?o{}!14~^FB!16?@@@BBB@@!14-#0!6?!16~!20?B!14~o!45?ow}!14~^FB!42-#0!6?!16~!21?@!14~}!40?_w}!14~^NB!46-#0!6?B!15~_!22?!15~_!34?_w{!15~NB@!49-#0!7?B!15~o!22?!15~o!29?_o{!15~NF@!53-#0!9?N!14~{_!21?!15~o!24?_o{}!14~^FB!57-#0!10?@N!14~{o!19?@!15~o!20?ow}!14~^FB!61-#0!12?@F^!13~}w_!17?@!15~_!15?_w}!15~nb`!64-#0!15?BN!14~}{o!15?B!15~!13?{!28~!4}!4{wwooo__!43-#0!18?BF^!14~}wo_!11?B!14~}!12?F^!44~}}{{wwo__!32-#0!21?@FN!15~}{o_!8?B!14~!16?!4@!12B!7F!4N^^^!22~}}{woo_!24-#0!23?_o!18~{!9?FN^^!4~^^^NB!49?@@BBFFNN^!18~}{wo_!18-#0!17?_ow{}!17~^NF@!83?@BBFN^!16~}{w_!13-#0!13?_w{}!15~^NFBB@!95?@BFN^!15~}w_!9-#0!10?o{!15~^FB@!107?@BF^!15~{_!6-#0!7?o{!14~NF@!116?@BN!14~}w!4-#0!4?_{!14~NB!82?_ow{{!7}{{wo_!25?F^!14~o-#0??_{!14~F!84?}!17~w!26?B^!13~{-#0?w!14~N!86?@F^!12~^NF!24?_ooow!14~{-#0{!14~^!91?@@!5B@@@!24?o{}!21~-#0!15~!126?@N^!21~-#0!15~{!129?@BFF!15~@-#0B!15~w!130?o{!13~^@-#0?@^!15~w_!124?o{!14~^B-#0???BN!15~}w_!74?_o!6woo_!30?_ow{}!14~^F@!5-#0!6?BN!16~}wo_!68?!13~}{{wo__!12?__ooow{{}!16~^FB!9-#0!9?@FN!17~}}{woo_!60?@F^!48~^NFB@!13-#0!13?@BFN^!20~}}{{wwooo___!50?@BFN^!32~^^NNFFB@@!19-#0!19?@BBFN^^!28~!6}!20{!7}!6~!4}{wo!7?@@@BBB!15F!4B@@@!30-#0!27?@@BBFFNN^^!62~N!65-#0!40?@@@BBB!4F!5N!8^!15~!8^!4N!4FBB@@!67-\u001b\\" }, "34": { "w": 216, "h": 306, "d": "\u001bP0;1;0q\"1;1;216;306#0;2;31;27;90#0!176?__ooww{{{}}}!6~}}{w_!17-#0!164?__ooww{{}}!25~{!16-#0!153?_ooww{{}}!38~o!15-#0!141?__ooww{{}}!50~!15-#0!23?_ow{{}}}!10~}}}{{wwoo_!82?_oww{}}!61~w!14-#0!18?_w{}!30~}{wo_!73?w}!70~!14-#0!15?o{!41~{wo!69?@N!17~^^NNFFBB`p{!42~!14-#0!12?_w!20~^!4N^!22~{w_!68?@@!9B@@@!7?ow}!20~NF@??B!19~!14-#0!10?_{!20~F@!7?@BFN^!19~}w_!82?ow}!20~NF@!7?!20~!13-#0!9?o!20~N!16?@BN^!17~}o!76?_w{!20~^FB!12?^!17~!14-#0!8?o!20~F!21?@F!18~w!70?_w{!20~^FB!17?@BFNN!5^NNNFB@!15-#0!8?!21~!25?F!18~w!64?_o{}!19~^NB!52-#0!8?!20~@!26?@^!18~o!59?ow}!19~^NB@!55-#0!8?!20~w!28?N!18~{!54?ow}!20~NB@!59-#0!8?N!20~!29?F!19~_!48?_w{!20~NF@!63-#0!9?^!19~w!29?F!19~o!43?_o{!20~^FB!67-#0!10?N!19~{!29?F!19~w!38?_o{}!19~^NB!71-#0!11?B^!19~o!28?N!19~w!34?o{}!19~^NB@!74-#0!13?B^!18~}o!27?^!19~w!29?ow}!20~NF@!78-#0!15?B^!19~w_!25?^!19~w!24?_w}!20~^F@!82-#0!17?@N!19~}w_!23?!20~_!19?_w{!22~b!6_!80-#0!20?BN!19~}wo!21?!20~!17?w}!38~!4}{{{wwwooo__!59-#0!23?BN!20~{wo!17?@!19~}!16?^!57~}}{{wwo__!47-#0!26?BF^!20~}wo_!13?@!19~!17?@BFFNN!8^!54~}{{woo_!38-#0!29?@FN!21~}wo!12?N!17~!43?!7@!5BFFFNNN^^!31~}{wwo_!30-#0!31?_o!24~!12?@N^!11~^NB!66?@@BBFFNN^^!25~}{wo_!24-#0!25?_ow{}!23~^NFB!106?@@BFFN^!23~}{w_!19-#0!20?_o{}!23~^NFB@!119?@BFN^!22~}wo!15-#0!16?_w{!22~^NFB@!131?@BFN!21~}w_!11-#0!13?o{}!19~^NFB@!142?@BN^!19~}w_!8-#0!10?o{!19~^FB!152?@F^!19~}w!6-#0!7?_{!19~NB!110?__!4owwwooo__!35?@F^!19~w!4-#0!5?o}!18~NB!109?w{}!17~{w_!33?BN!19~o-#0???o}!18~N@!110?!24~!35?@N!18~w-#0??}!19~@!112?@N!20~^F!33?!4_r!18~o-#0?!20~!117?@BFF!8NFFFBB@!30?ow{}!26~-#0}!19~!165?}!30~-#0!20~!166?FN^!27~-#0!20~_!169?@BFFN!20~-#0B!20~_!172?o!18~^@-#0?F!20~w!168?_w!19~F-#0??@N!20~{o!161?_o{}!18~^B!5-#0!4?@N!21~{o_!97?__oo!6woo_!42?_ow{!20~^F@!7-#0!7?BN!21~}{w_!91?o}!15~}{wo_!27?_oow{{}!21~^NB@!10-#0!10?BF^!22~}{woo_!84?@^!21~}}{{!14w!4{}}!25~^NFB!15-#0!14?BFN!25~}{{woo__!77?@FN^!59~^^NFB@!20-#0!18?@BFN^!29~}}{{wwooo___!67?@BFFN^!44~^^NFFBB@!27-#0!24?@BBFN^!38~!4}!6{!27w!8{!10}{{{wwo_!9?@@BBFFF!5N!13^!6NFFFBBB@@!38-#0!32?@BBFNN^^!90~}!85-#0!42?@@BBFFNNN^^!74~^NF@!85-#0!56?!4@!4B!4F!6N!8^!20~!9^!5N!4FBBB@@!91-\u001b\\" } };
9
+ //# sourceMappingURL=sixel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sixel.js","sourceRoot":"","sources":["../../src/ui/sixel.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,kBAAkB;AAClB,wFAAwF;AACxF,oDAAoD;AACvC,QAAA,KAAK,GAChB,EAAC,IAAI,EAAC,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,26BAA26B,EAAC,EAAC,IAAI,EAAC,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,ksCAAksC,EAAC,EAAC,IAAI,EAAC,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,4kDAA4kD,EAAC,EAAC,IAAI,EAAC,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,ujEAAujE,EAAC,EAAC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { ApiClient } from '../api/client';
2
+ /**
3
+ * Fetching the account's apps — shared by `scalebun apps`, `quickstart`, and the
4
+ * interactive `ota publish` wizard, so the org → project → app walk lives in one
5
+ * place instead of being copy-pasted per command.
6
+ */
7
+ export interface AppRow {
8
+ id: string;
9
+ name: string;
10
+ platform: string | null;
11
+ }
12
+ export interface AppEntry {
13
+ orgId: string;
14
+ orgName: string;
15
+ /**
16
+ * The project's id, not just its name. It is already fetched to walk into the
17
+ * project, and it is what the device's trust anchor must carry: the native
18
+ * verifier compares the signed release's projectId against the embedded one
19
+ * and refuses on PROJECT_MISMATCH. Keeping only `projectName` meant every
20
+ * caller that needed the id had to guess — and appId is the easy wrong guess,
21
+ * since both are `cm…` cuids.
22
+ */
23
+ projectId: string;
24
+ projectName: string;
25
+ app: AppRow;
26
+ }
27
+ /** Every app the account can see, flattened for listing/selection. */
28
+ export declare function fetchAllApps(client: ApiClient): Promise<AppEntry[]>;
29
+ //# sourceMappingURL=apps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../src/utils/apps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;GAIG;AAEH,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAaD,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,sEAAsE;AACtE,wBAAsB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAiBzE"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchAllApps = fetchAllApps;
4
+ /** Every app the account can see, flattened for listing/selection. */
5
+ async function fetchAllApps(client) {
6
+ const orgs = await client.get('/organizations');
7
+ const entries = [];
8
+ for (const org of orgs ?? []) {
9
+ const projects = await client.get(`/organizations/${org.id}/projects`);
10
+ for (const p of projects ?? []) {
11
+ const detail = await client.get(`/organizations/${org.id}/projects/${p.id}`);
12
+ for (const app of detail?.apps ?? []) {
13
+ entries.push({ orgId: org.id, orgName: org.name, projectId: p.id, projectName: p.name, app });
14
+ }
15
+ }
16
+ }
17
+ return entries;
18
+ }
19
+ //# sourceMappingURL=apps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apps.js","sourceRoot":"","sources":["../../src/utils/apps.ts"],"names":[],"mappings":";;AA0CA,oCAiBC;AAlBD,sEAAsE;AAC/D,KAAK,UAAU,YAAY,CAAC,MAAiB;IAClD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAW,gBAAgB,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAe,EAAE,CAAC;IAC/B,KAAK,MAAM,GAAG,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAC/B,kBAAkB,GAAG,CAAC,EAAE,WAAW,CACpC,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAC7B,kBAAkB,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,EAAE,CAC5C,CAAC;YACF,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;YAChG,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Best-effort "open this URL in the default browser". Non-fatal: callers always
3
+ * print the URL too, so a headless box or a missing opener never blocks the flow.
4
+ *
5
+ * Uses the platform opener (`start` on Windows, `open` on macOS, `xdg-open` on
6
+ * Linux) detached, so the CLI doesn't wait on the browser process.
7
+ */
8
+ export declare function openUrl(url: string): void;
9
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/utils/browser.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAuBzC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openUrl = openUrl;
4
+ const child_process_1 = require("child_process");
5
+ /**
6
+ * Best-effort "open this URL in the default browser". Non-fatal: callers always
7
+ * print the URL too, so a headless box or a missing opener never blocks the flow.
8
+ *
9
+ * Uses the platform opener (`start` on Windows, `open` on macOS, `xdg-open` on
10
+ * Linux) detached, so the CLI doesn't wait on the browser process.
11
+ */
12
+ function openUrl(url) {
13
+ try {
14
+ let command;
15
+ let args;
16
+ if (process.platform === 'win32') {
17
+ // `start` is a cmd builtin; the empty "" is the window title arg it expects.
18
+ command = 'cmd';
19
+ args = ['/c', 'start', '', url];
20
+ }
21
+ else if (process.platform === 'darwin') {
22
+ command = 'open';
23
+ args = [url];
24
+ }
25
+ else {
26
+ command = 'xdg-open';
27
+ args = [url];
28
+ }
29
+ const child = (0, child_process_1.spawn)(command, args, { stdio: 'ignore', detached: true });
30
+ child.on('error', () => {
31
+ /* opener missing — the caller already printed the URL */
32
+ });
33
+ child.unref();
34
+ }
35
+ catch {
36
+ /* never throw from a convenience opener */
37
+ }
38
+ }
39
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/utils/browser.ts"],"names":[],"mappings":";;AASA,0BAuBC;AAhCD,iDAAsC;AAEtC;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,GAAW;IACjC,IAAI,CAAC;QACH,IAAI,OAAe,CAAC;QACpB,IAAI,IAAc,CAAC;QACnB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACjC,6EAA6E;YAC7E,OAAO,GAAG,KAAK,CAAC;YAChB,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;aAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACzC,OAAO,GAAG,MAAM,CAAC;YACjB,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,UAAU,CAAC;YACrB,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;QACD,MAAM,KAAK,GAAG,IAAA,qBAAK,EAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACxE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACrB,yDAAyD;QAC3D,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,2CAA2C;IAC7C,CAAC;AACH,CAAC"}
@@ -0,0 +1,153 @@
1
+ export interface BundleOptions {
2
+ platform: 'android' | 'ios';
3
+ entryFile: string;
4
+ dev: boolean;
5
+ /**
6
+ * If true, run hermesc to compile the JS bundle to Hermes bytecode (.hbc).
7
+ * Default: false (Sprint 2). Sprint 7 patch engine requires .hbc for
8
+ * correct diffing — enable this flag when binary patching ships.
9
+ *
10
+ * NOTE: `react-native bundle` in RN 0.74+ with Hermes enabled in the
11
+ * project config (build.gradle / Podfile) outputs plain JS that gets
12
+ * compiled to Hermes bytecode during the native build step, NOT during
13
+ * `react-native bundle`. For OTA bundles that skip the native build,
14
+ * we must explicitly run hermesc to produce the .hbc artifact.
15
+ *
16
+ * CAVEAT (Sprint 2): Without hermesc, OTA bundles are plain JS interpreted
17
+ * by Hermes (works correctly, but ~20-30% slower cold startup compared to
18
+ * pre-compiled bytecode). This is acceptable for Sprint 2; the hermesc
19
+ * step will be mandatory when the patch engine ships.
20
+ */
21
+ hermes?: boolean;
22
+ /**
23
+ * Permit shipping a plain-JS bundle when `--hermes` was asked for but
24
+ * hermesc could not run. Default false: a failed compile is an ERROR.
25
+ *
26
+ * It used to warn and ship the uncompiled bundle, which is a silent
27
+ * downgrade of the artifact — the publish "succeeds" and nothing downstream
28
+ * can tell that what shipped is not what was requested. Two concrete costs:
29
+ * cold start is 20-30% slower for every user on that release, and the delta
30
+ * engine diffs the new bundle against the previous one, so a channel that
31
+ * flips between bytecode and plain JS produces patches with nothing in
32
+ * common and every device falls back to a full download.
33
+ *
34
+ * A broken toolchain should stop the publish, not quietly change what it
35
+ * publishes. The escape hatch stays available for anyone who genuinely
36
+ * wants the uncompiled artifact — it just has to be asked for.
37
+ */
38
+ allowPlainJs?: boolean;
39
+ /** If true, generate a sourcemap alongside the bundle. */
40
+ sourcemap?: boolean;
41
+ /**
42
+ * Identity marker to compile into the bundle. Injected into the JS source
43
+ * BEFORE hermesc runs — Hermes bytecode is a binary format, so text cannot be
44
+ * prepended after compilation without corrupting the file.
45
+ *
46
+ * At runtime the SDK reads `globalThis.__SCALEBUN_OTA_ID__` and compares it
47
+ * against the slot it believes is active. That comparison is the only way to
48
+ * prove from JS that the bundle we installed is the bundle actually running —
49
+ * which catches a host app that never wired `getJSBundleFile()`, and the
50
+ * bridgeless runtimes below RN 0.76.1 that ignore it entirely.
51
+ */
52
+ identityToken?: string;
53
+ }
54
+ export interface BundleResult {
55
+ bundlePath: string;
56
+ assetsPath: string;
57
+ /**
58
+ * Asset files Metro emitted for this bundle, relative to `assetsPath`.
59
+ * OTA ships the JS artifact only — these resolve from the installed binary,
60
+ * so the list exists to WARN about assets added since the last store build.
61
+ */
62
+ assets: string[];
63
+ /** True when the artifact really is Hermes bytecode (verified from the header). */
64
+ hermesCompiled: boolean;
65
+ /** HBC format version read from the compiled header, or null for plain JS. */
66
+ hermesBytecodeVersion: number | null;
67
+ }
68
+ /**
69
+ * Read the HBC format version straight out of the compiled file header.
70
+ *
71
+ * Parsed from the artifact rather than from `hermesc --version` output, because
72
+ * the header is what the device's VM actually compares against — and its format
73
+ * is stable, whereas the CLI's version banner is not.
74
+ *
75
+ * Returns null when the file is not Hermes bytecode.
76
+ */
77
+ export declare function readHermesBytecodeVersion(filePath: string): number | null;
78
+ /**
79
+ * Locate the `hermesc` binary that ships inside React Native.
80
+ *
81
+ * `hermesc` is NOT an npm package — `npx hermesc` fails with
82
+ * "No versions available for hermesc" on every project, which meant `--hermes`
83
+ * silently degraded to a plain JS bundle every single time it was used. React
84
+ * Native ships a prebuilt binary per host platform under `sdks/hermesc/`.
85
+ *
86
+ * Using the copy inside the project's own `react-native` is also the correct
87
+ * choice for a second reason: it is the compiler matched to the Hermes runtime
88
+ * in that app's binary. Compiling with any other hermesc is what produces
89
+ * "Wrong bytecode version. Expected 96 but got 98" on device.
90
+ *
91
+ * Where it lives moved. Up to ~0.86 it was the prebuilt under `sdks/hermesc/`;
92
+ * from 0.87 that is no longer populated and the binary comes from the
93
+ * hermes-engine pod instead. This looked in exactly one place, so on 0.87 a
94
+ * default `--hermes` publish failed with nothing to point at. The candidate
95
+ * list below mirrors React Native's own resolution order, override included.
96
+ */
97
+ export declare function hermescCandidates(cwd?: string): string[];
98
+ export declare function resolveHermesc(cwd?: string): string | null;
99
+ /** React Native version of the project being published, from its node_modules. */
100
+ export declare function detectProjectRnVersion(cwd?: string): string | null;
101
+ /**
102
+ * Shell out to `npx react-native bundle` to produce a JS bundle.
103
+ *
104
+ * When opts.hermes is true, also runs hermesc to compile to bytecode.
105
+ * The native runtime detects the format from magic bytes (\x1f\x\xbc —
106
+ * Hermes bytecode header), so the same .jsbundle extension works for both.
107
+ */
108
+ /**
109
+ * True when this project is an Expo app.
110
+ *
111
+ * Expo projects do not ship `@react-native-community/cli`, so `npx react-native
112
+ * bundle` fails outright with a "react-native depends on
113
+ * @react-native-community/cli" error. Expo's equivalent is `expo export:embed`,
114
+ * which takes the same flags and produces the same artifact. Detecting this is
115
+ * not a nicety — without it `ota publish` cannot build a bundle in an Expo app
116
+ * at all, which is a large share of the React Native ecosystem.
117
+ */
118
+ export declare function isExpoProject(cwd?: string): boolean;
119
+ /**
120
+ * How to invoke this project's bundler.
121
+ *
122
+ * `npx react-native bundle` was the only path, and it fails on a project that is
123
+ * entirely healthy: React Native 0.77+ no longer links a `react-native` bin into
124
+ * node_modules/.bin (the executable moved to @react-native-community/cli, which
125
+ * links `rnc-cli` instead). npx then finds nothing on PATH and the publish dies
126
+ * with "'react-native' is not recognized as an internal or external command" —
127
+ * a message that reads like a broken install rather than a moved binary, and one
128
+ * a user cannot act on.
129
+ *
130
+ * So prefer the entrypoint the project already has on disk. react-native's own
131
+ * package.json still declares `bin: { "react-native": "cli.js" }`, so cli.js is
132
+ * present even when nothing linked it; running it through `node` needs no bin
133
+ * link, no PATH lookup and no shell — which also sidesteps the .cmd/EINVAL
134
+ * spawn problem that forces shell:true everywhere else on Windows.
135
+ */
136
+ export declare function resolveBundler(cwd: string, expo: boolean): {
137
+ cmd: string;
138
+ pre: string[];
139
+ shell: boolean;
140
+ label: string;
141
+ };
142
+ export declare function buildBundle(opts: BundleOptions): BundleResult;
143
+ /**
144
+ * Every asset file Metro emitted for this bundle, relative to the assets root.
145
+ *
146
+ * OTA ships ONE artifact: the JS/bytecode bundle. Assets are resolved from what
147
+ * the installed binary already contains, so an image or font added since the
148
+ * last store build is referenced by the new JS and is simply not there — the
149
+ * update installs cleanly and renders a missing image. `ota publish` uses this
150
+ * list to say so out loud rather than discarding the directory in silence.
151
+ */
152
+ export declare function listAssets(root: string): string[];
153
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/utils/bundle.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,SAAS,GAAG,KAAK,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;IACb;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,mFAAmF;IACnF,cAAc,EAAE,OAAO,CAAC;IACxB,8EAA8E;IAC9E,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAQD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBzE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,EAAE,CAqCvE;AAED,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAsB,GAAG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