@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance.js","sourceRoot":"","sources":["../../src/utils/provenance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,8CAmDC;AAuBD,oDAkCC;AArJD,4DAA8C;AAC9C,uCAAyB;AACzB,2CAA6B;AAC7B,iCAAoC;AAkBpC,SAAS,GAAG,CAAC,IAAc,EAAE,GAAW;IACtC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY;aACrB,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;aAC1F,IAAI,EAAE,CAAC;QACV,OAAO,GAAG,IAAI,SAAS,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,SAAS,OAAO,CAAC,CAAa;IAC5B,MAAM,GAAG,GAAe,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAA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,CAAC,IAAI,CAAC,CAAC;gBAC7B,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;oBACrB,IAAI,CAAC,IAAI,CAAC,CAAC;gBACb,CAAC;qBAAM,CAAC;oBACN,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACrE,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,GAAG;wBACT,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC;wBAChC,SAAS,EAAE,EAAE,CAAC,IAAI;wBAClB,MAAM,EAAE,IAAA,iBAAU,EAAC,IAAI,CAAC;qBACzB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QACF,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,CAAC,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,qEAAqE;QACvE,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Resolving what a command should act on, without making the operator type it.
3
+ *
4
+ * ── The chain, in order ─────────────────────────────────────────────────────
5
+ *
6
+ * 1. an explicit flag — always wins
7
+ * 2. SCALEBUN_APP_ID / scalebun.json — the common case, and silent
8
+ * 3. the account has exactly one app — auto-select and say so
9
+ * 4. a TTY — interactive picker
10
+ * 5. no TTY — hard error naming the flag
11
+ *
12
+ * Layer 5 is the one that must never be skipped. A prompt that blocks in CI is
13
+ * a deploy that hangs until the job times out, and it looks like a network
14
+ * fault rather than a missing flag. The publish wizard already got this right
15
+ * (`ota-publish.ts`, TTY-gated); this generalises that rule so every command
16
+ * inherits it instead of re-deciding.
17
+ *
18
+ * ── Why resolving beats prompting ───────────────────────────────────────────
19
+ *
20
+ * Prompting on nine commands turns a nine-flag problem into a nine-prompt
21
+ * problem. Layer 2 is where the win is: `scalebun link` once, and the flag
22
+ * disappears from every later invocation. There is a cost argument too —
23
+ * `fetchAllApps` walks orgs → projects → project-detail, so resolving from the
24
+ * network on every command pays N+1 HTTP calls every time.
25
+ */
26
+ export interface ResolveOpts {
27
+ /** The explicit flag value, if the user passed one. */
28
+ appId?: string;
29
+ /** Skip layers 3 and 4 — set by --json / --non-interactive / --yes. */
30
+ nonInteractive?: boolean;
31
+ /** Flag name to quote in the non-TTY error. */
32
+ flag?: string;
33
+ }
34
+ /**
35
+ * True when this process must not prompt: no TTY, or the caller forbade it.
36
+ *
37
+ * `isJson()` is the authority on machine mode rather than a per-command
38
+ * `opts.json`. Commander does not hand root options down to subcommand
39
+ * handlers — and because the root declares `--json` too, it consumes the flag
40
+ * before a subcommand ever sees it. So the flag is read once from raw argv at
41
+ * startup (`applyGlobalFlags`) and every consumer asks `output.ts`. The
42
+ * per-command `--json` declarations remain, purely so `--help` documents them.
43
+ */
44
+ export declare function isNonInteractive(opts?: {
45
+ nonInteractive?: boolean;
46
+ }): boolean;
47
+ /**
48
+ * Resolve the app id for a command.
49
+ *
50
+ * Never returns an empty string — it either returns an id or exits with a
51
+ * message naming the exact flag to pass.
52
+ */
53
+ export declare function resolveAppId(opts?: ResolveOpts): Promise<string>;
54
+ /**
55
+ * Resolve a release for the control commands.
56
+ *
57
+ * `pause` and `rollback` already accepted an optional --release-id and fell
58
+ * back to "the single ACTIVE release"; `resume` required it and never resolved,
59
+ * which made the undo of the panic button the hardest command to type. This
60
+ * generalises the resolver and lets each caller say which statuses count —
61
+ * so `resume` can look for PAUSED rather than ACTIVE.
62
+ */
63
+ export interface ReleaseRow {
64
+ id: string;
65
+ status: string;
66
+ rolloutPercent?: number;
67
+ bundle?: {
68
+ version?: number;
69
+ platform?: string;
70
+ };
71
+ }
72
+ export declare function describeRelease(r: ReleaseRow): string;
73
+ export declare function resolveRelease(releases: ReleaseRow[], opts: {
74
+ releaseId?: string;
75
+ /** Statuses that qualify when no id was given. */
76
+ statuses: string[];
77
+ /** Verb used in messages: "resume", "pause", … */
78
+ verb: string;
79
+ nonInteractive?: boolean;
80
+ }): Promise<ReleaseRow>;
81
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/utils/resolve.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CASjF;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsE1E;AAmBD;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAIrD;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,UAAU,EAAE,EACtB,IAAI,EAAE;IACJ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GACA,OAAO,CAAC,UAAU,CAAC,CAmCrB"}
@@ -0,0 +1,139 @@
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.isNonInteractive = isNonInteractive;
7
+ exports.resolveAppId = resolveAppId;
8
+ exports.describeRelease = describeRelease;
9
+ exports.resolveRelease = resolveRelease;
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ const client_1 = require("../api/client");
12
+ const credentials_1 = require("./credentials");
13
+ const apps_1 = require("./apps");
14
+ const context_1 = require("./context");
15
+ const prompt_1 = require("./prompt");
16
+ const output_1 = require("./output");
17
+ const validate_1 = require("./validate");
18
+ /**
19
+ * True when this process must not prompt: no TTY, or the caller forbade it.
20
+ *
21
+ * `isJson()` is the authority on machine mode rather than a per-command
22
+ * `opts.json`. Commander does not hand root options down to subcommand
23
+ * handlers — and because the root declares `--json` too, it consumes the flag
24
+ * before a subcommand ever sees it. So the flag is read once from raw argv at
25
+ * startup (`applyGlobalFlags`) and every consumer asks `output.ts`. The
26
+ * per-command `--json` declarations remain, purely so `--help` documents them.
27
+ */
28
+ function isNonInteractive(opts = {}) {
29
+ return (!!opts.nonInteractive ||
30
+ (0, output_1.isJson)() ||
31
+ !process.stdin.isTTY ||
32
+ !process.stdout.isTTY ||
33
+ process.argv.includes('--non-interactive') ||
34
+ process.env.CI === 'true');
35
+ }
36
+ /**
37
+ * Resolve the app id for a command.
38
+ *
39
+ * Never returns an empty string — it either returns an id or exits with a
40
+ * message naming the exact flag to pass.
41
+ */
42
+ async function resolveAppId(opts = {}) {
43
+ const flag = opts.flag ?? '--app-id';
44
+ // An explicit flag is checked before it is used. The two ways an id arrives
45
+ // broken both end in a confusing 404 rather than a usage error: an unset
46
+ // shell variable (`--app-id $APP`) leaves the flag to swallow whatever comes
47
+ // next, and a mis-quoted paste brings whitespace with it. Only the explicit
48
+ // value is checked — a stored scalebun.json or SCALEBUN_APP_ID is the user's
49
+ // own earlier input and failing here would strand a linked project.
50
+ if (opts.appId !== undefined)
51
+ (0, validate_1.checkedId)(flag, opts.appId);
52
+ // Layers 1 + 2 — explicit, then ambient. getContext does both, in order.
53
+ const ctx = (0, context_1.getContext)({ appId: opts.appId });
54
+ if (ctx.appId)
55
+ return ctx.appId;
56
+ const creds = (0, credentials_1.readCredentials)();
57
+ if (!creds) {
58
+ (0, output_1.fail)('Not signed in.', ['Run `scalebun login`, or set SCALEBUN_TOKEN in CI.'], output_1.ExitCode.Usage);
59
+ }
60
+ // Layers 3 + 4 need the network, so they are also the layers CI must not reach.
61
+ if (isNonInteractive(opts)) {
62
+ (0, output_1.fail)(`${flag} is required.`, [
63
+ `Pass ${flag}, set SCALEBUN_APP_ID, or run \`scalebun link\` in this project.`,
64
+ 'This shell is not interactive, so the app cannot be chosen here.',
65
+ ], output_1.ExitCode.Usage);
66
+ }
67
+ let entries;
68
+ try {
69
+ entries = await (0, apps_1.fetchAllApps)(new client_1.ApiClient(creds));
70
+ }
71
+ catch (err) {
72
+ (0, output_1.fail)(`Could not list apps: ${err?.message ?? err}`, [], output_1.ExitCode.Network);
73
+ }
74
+ if (!entries.length) {
75
+ (0, output_1.fail)('This account has no apps yet.', ['Create one in the dashboard (Organization → Project → App), then re-run.'], output_1.ExitCode.Usage);
76
+ }
77
+ // Layer 3 — one app is not a choice, so do not present it as one.
78
+ if (entries.length === 1) {
79
+ const only = entries[0];
80
+ console.log(chalk_1.default.dim(`Using your only app: ${only.app.name} (${only.app.id})`));
81
+ rememberIfLinked(only);
82
+ return only.app.id;
83
+ }
84
+ // Layer 4 — a real choice, so ask.
85
+ const chosen = await (0, prompt_1.select)('Which app?', entries.map((e) => ({
86
+ label: `${e.app.name} ${chalk_1.default.dim(`${e.orgName} / ${e.projectName}`)}`,
87
+ value: e,
88
+ })));
89
+ (0, prompt_1.closePrompts)();
90
+ rememberIfLinked(chosen);
91
+ return chosen.app.id;
92
+ }
93
+ /**
94
+ * Cache the choice into an EXISTING scalebun.json.
95
+ *
96
+ * Deliberately does not create one: `scalebun link` is the command that decides
97
+ * a directory is a ScaleBun project, and a picker answering one command should
98
+ * not silently write a config file into a directory the user never linked.
99
+ */
100
+ function rememberIfLinked(entry) {
101
+ const root = (0, context_1.findProjectRoot)();
102
+ if (!root)
103
+ return;
104
+ try {
105
+ (0, context_1.writeProjectConfig)(root, { appId: entry.app.id, appName: entry.app.name });
106
+ }
107
+ catch {
108
+ /* cache only */
109
+ }
110
+ }
111
+ function describeRelease(r) {
112
+ const v = r.bundle?.version != null ? `v${r.bundle.version}` : r.id;
113
+ const p = r.bundle?.platform ? ` (${r.bundle.platform})` : '';
114
+ return `${v}${p} — ${r.status} @ ${r.rolloutPercent ?? 0}%`;
115
+ }
116
+ async function resolveRelease(releases, opts) {
117
+ if (opts.releaseId) {
118
+ const hit = releases.find((r) => r.id === opts.releaseId);
119
+ if (!hit)
120
+ (0, output_1.fail)(`No release ${opts.releaseId} on this app.`, [], output_1.ExitCode.Usage);
121
+ return hit;
122
+ }
123
+ const candidates = releases.filter((r) => opts.statuses.includes(r.status));
124
+ if (candidates.length === 0) {
125
+ (0, output_1.fail)(`Nothing to ${opts.verb} — no release is ${opts.statuses.join(' or ')}.`, ['Run `scalebun ota releases` to see the current state.'], output_1.ExitCode.Usage);
126
+ }
127
+ if (candidates.length === 1)
128
+ return candidates[0];
129
+ // More than one qualifies. Refusing to guess is right — but the old code
130
+ // then exited and made the operator copy an id out of a list during an
131
+ // incident. On a TTY, offer the list as a choice instead.
132
+ if (isNonInteractive(opts)) {
133
+ (0, output_1.fail)(`${candidates.length} releases are ${opts.statuses.join(' or ')} — pass --release-id.`, candidates.map((r) => ` ${r.id} ${describeRelease(r)}`), output_1.ExitCode.Usage);
134
+ }
135
+ const chosen = await (0, prompt_1.select)(`Which release do you want to ${opts.verb}?`, candidates.map((r) => ({ label: describeRelease(r), value: r })));
136
+ (0, prompt_1.closePrompts)();
137
+ return chosen;
138
+ }
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AC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,eAAM,EACzB,gCAAgC,IAAI,CAAC,IAAI,GAAG,EAC5C,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CACjE,CAAC;IACF,IAAA,qBAAY,GAAE,CAAC;IACf,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Locating and running @scalebun/react-native's bin from this CLI.
3
+ *
4
+ * `init android` / `init ios` live in the SDK package (they need its native
5
+ * codemods), but both this CLI and the SDK declare the same `scalebun` bin
6
+ * name — so whichever binary the user ends up with must be able to reach the
7
+ * other's commands. The SDK bin already forwards `ota …` here; these helpers
8
+ * are the return path, shared by the unknown-command forwarder (index.ts) and
9
+ * quickstart's native-wiring step.
10
+ */
11
+ /** Resolve @scalebun/react-native's bin script, or null when absent. */
12
+ export declare function resolveSdkBin(): string | null;
13
+ /**
14
+ * Run the SDK bin with the given argv, inheriting stdio.
15
+ * Returns the child's exit code (1 when the child died on a signal).
16
+ */
17
+ export declare function runSdkBin(sdkBin: string, args: string[]): number;
18
+ //# sourceMappingURL=sdkBin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkBin.d.ts","sourceRoot":"","sources":["../../src/utils/sdkBin.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,wEAAwE;AACxE,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAc7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAGhE"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.resolveSdkBin = resolveSdkBin;
37
+ exports.runSdkBin = runSdkBin;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const child_process_1 = require("child_process");
41
+ /**
42
+ * Locating and running @scalebun/react-native's bin from this CLI.
43
+ *
44
+ * `init android` / `init ios` live in the SDK package (they need its native
45
+ * codemods), but both this CLI and the SDK declare the same `scalebun` bin
46
+ * name — so whichever binary the user ends up with must be able to reach the
47
+ * other's commands. The SDK bin already forwards `ota …` here; these helpers
48
+ * are the return path, shared by the unknown-command forwarder (index.ts) and
49
+ * quickstart's native-wiring step.
50
+ */
51
+ /** Resolve @scalebun/react-native's bin script, or null when absent. */
52
+ function resolveSdkBin() {
53
+ try {
54
+ // The SDK's `exports` map has no "./bin/*" entry, so resolving the bin
55
+ // subpath directly throws ERR_PACKAGE_PATH_NOT_EXPORTED. "./package.json"
56
+ // IS exported — resolve that and join. cwd first: the SDK is installed in
57
+ // the app being worked on, not necessarily next to this CLI.
58
+ const pkg = require.resolve('@scalebun/react-native/package.json', {
59
+ paths: [process.cwd(), __dirname],
60
+ });
61
+ const bin = path.join(path.dirname(pkg), 'bin', 'scalebun.js');
62
+ return fs.existsSync(bin) ? bin : null;
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ }
68
+ /**
69
+ * Run the SDK bin with the given argv, inheriting stdio.
70
+ * Returns the child's exit code (1 when the child died on a signal).
71
+ */
72
+ function runSdkBin(sdkBin, args) {
73
+ const res = (0, child_process_1.spawnSync)(process.execPath, [sdkBin, ...args], { stdio: 'inherit' });
74
+ return res.status ?? 1;
75
+ }
76
+ //# sourceMappingURL=sdkBin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkBin.js","sourceRoot":"","sources":["../../src/utils/sdkBin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,sCAcC;AAMD,8BAGC;AAvCD,uCAAyB;AACzB,2CAA6B;AAC7B,iDAA0C;AAE1C;;;;;;;;;GASG;AAEH,wEAAwE;AACxE,SAAgB,aAAa;IAC3B,IAAI,CAAC;QACH,uEAAuE;QACvE,0EAA0E;QAC1E,0EAA0E;QAC1E,6DAA6D;QAC7D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,qCAAqC,EAAE;YACjE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC;SAClC,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,MAAc,EAAE,IAAc;IACtD,MAAM,GAAG,GAAG,IAAA,yBAAS,EAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACjF,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Where a release signature comes from.
3
+ *
4
+ * ── Why this exists ──────────────────────────────────────────────────────────
5
+ *
6
+ * Control T-1 of a customer's security assessment reads: "Signing key held in an
7
+ * HSM or approved key vault; signing only within controlled CI/CD." That is an
8
+ * obligation on THEM — we never hold the key — but until now our CLI could only
9
+ * sign with a PEM on disk, so a customer whose security policy requires an HSM
10
+ * had no way to use the product at all.
11
+ *
12
+ * ── Why an external COMMAND rather than an SDK per vault ─────────────────────
13
+ *
14
+ * A command covers AWS KMS, Google Cloud KMS, Azure Key Vault, PKCS#11, YubiHSM
15
+ * and whatever the customer has already standardised on, without this package
16
+ * taking a dependency on any of them. Every dependency a signing tool carries is
17
+ * a dependency someone has to audit forever, and the customers who need this are
18
+ * precisely the ones who will audit it.
19
+ *
20
+ * ── What does NOT change ─────────────────────────────────────────────────────
21
+ *
22
+ * The bytes that get signed, and the self-verify that happens afterwards. The
23
+ * canonical payload is serialized exactly as before, and the resulting signature
24
+ * is verified before it is returned, so a vault that produces an unusable
25
+ * signature fails on the build machine instead of on a million handsets.
26
+ *
27
+ * That check is the reason an external signer must ALSO supply the public key:
28
+ * with a local PEM the public half is derived from the private one, and we do
29
+ * not have the private one here. Skipping the verification instead would remove
30
+ * the guarantee exactly where it matters most — a remote signer is the case with
31
+ * the most ways to go quietly wrong.
32
+ */
33
+ import * as crypto from 'crypto';
34
+ export interface Signer {
35
+ /** Sign the canonical payload bytes. */
36
+ sign(bytes: Uint8Array): Promise<Buffer>;
37
+ /** The public half, for the self-verify. */
38
+ publicKey(): Promise<crypto.KeyObject>;
39
+ /** One line for --dry-run output and the audit trail. */
40
+ describe(): string;
41
+ }
42
+ /** Today's behaviour, unchanged: a PKCS#8 PEM on this machine. */
43
+ export declare class LocalPemSigner implements Signer {
44
+ private readonly key;
45
+ constructor(privateKeyPem: string | Buffer, passphrase?: string);
46
+ sign(bytes: Uint8Array): Promise<Buffer>;
47
+ publicKey(): Promise<crypto.KeyObject>;
48
+ describe(): string;
49
+ }
50
+ export interface ExternalSignerConfig {
51
+ /** Command line, e.g. "aws kms sign --key-id alias/ota ...". */
52
+ command: string;
53
+ /** SPKI PEM of the public half, or a path to one. */
54
+ publicKeyPem: string;
55
+ timeoutMs?: number;
56
+ }
57
+ /**
58
+ * Sign by handing the payload to a command on stdin and reading the signature
59
+ * from stdout.
60
+ *
61
+ * The contract is deliberately the smallest one that can work:
62
+ *
63
+ * stdin the raw canonical payload bytes
64
+ * stdout the raw signature bytes, or the same base64-encoded
65
+ * exit 0 success; anything else is a failure and the build stops
66
+ *
67
+ * Base64 is accepted because most cloud KMS CLIs emit it by default, and
68
+ * requiring every customer to pipe through a decoder would be a footgun that
69
+ * buys nothing.
70
+ */
71
+ export declare class ExternalCommandSigner implements Signer {
72
+ private pub?;
73
+ private readonly cfg;
74
+ constructor(cfg: ExternalSignerConfig);
75
+ sign(bytes: Uint8Array): Promise<Buffer>;
76
+ publicKey(): Promise<crypto.KeyObject>;
77
+ describe(): string;
78
+ private run;
79
+ }
80
+ /**
81
+ * Build a signer from configuration.
82
+ *
83
+ * An external signer is used ONLY when explicitly configured. With nothing set,
84
+ * this returns the local PEM signer and every existing flow behaves exactly as
85
+ * it did — which is the whole point: this is additive, and a customer who has
86
+ * not asked for an HSM must not notice it exists.
87
+ */
88
+ export declare function resolveSigner(opts: {
89
+ privateKeyPem?: string | Buffer | null;
90
+ passphrase?: string;
91
+ signerCommand?: string;
92
+ signerPublicKey?: string;
93
+ }): Signer;
94
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/utils/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAUjC,MAAM,WAAW,MAAM;IACrB,wCAAwC;IACxC,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,4CAA4C;IAC5C,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvC,yDAAyD;IACzD,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED,kEAAkE;AAClE,qBAAa,cAAe,YAAW,MAAM;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAmB;gBAE3B,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IASzD,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;IAI5C,QAAQ,IAAI,MAAM;CAGnB;AAED,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,qBAAsB,YAAW,MAAM;IAClD,OAAO,CAAC,GAAG,CAAC,CAAmB;IAE/B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAuB;gBAI/B,GAAG,EAAE,oBAAoB;IAY/B,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,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