@superwall/cli 1.7.0 → 2.1.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 (229) hide show
  1. package/README.md +192 -52
  2. package/dist/{setup-Bxj22rYi.js → apple-CSzNTGHM.js} +82 -76
  3. package/dist/auth.d.ts +4 -19
  4. package/dist/auth.js +4 -2
  5. package/dist/{actions-B7ym3oVS.js → billing-C3Q8DBU2.js} +98 -28
  6. package/dist/{bind-YrJvuRF9.js → bind-BumHTi9O.js} +38 -33
  7. package/dist/{build-DLoCW5Ri.js → build-Bpviiclc.js} +20 -26
  8. package/dist/client-BL0f_yGf.js +176 -0
  9. package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
  10. package/dist/config-BO1Y87kV.js +105 -0
  11. package/dist/create-BSfvpWoD.js +19 -0
  12. package/dist/{create-pkANt1Gs.js → create-BUcVG4Ab.js} +195 -169
  13. package/dist/{notification-url-DuKF2659.js → create-CfK3PeKA.js} +235 -539
  14. package/dist/doctor-BWqIYcMn.js +83 -0
  15. package/dist/{drivers-Qx9LxmRN.js → drivers-CPhdPkW5.js} +185 -172
  16. package/dist/entry.d.ts +0 -5
  17. package/dist/entry.js +28072 -1134
  18. package/dist/environment-eBXjELoN.js +58 -0
  19. package/dist/{existing-AVEfZu2A.js → existing-BltvQiX5.js} +12 -6
  20. package/dist/held-CPve03KJ.js +16 -0
  21. package/dist/held-DgnTFMl3.js +1112 -0
  22. package/dist/input-vi0bou04.js +42 -0
  23. package/dist/{integrate-brmhPG-S.js → integrate-BRsqoe01.js} +277 -254
  24. package/dist/log-NVhVe_oe.js +62 -0
  25. package/dist/login-BCEH5q0U.js +53 -0
  26. package/dist/login-BPOONe7n.js +16 -0
  27. package/dist/{login-Do4wFuLv.js → login-BbTIrCFT.js} +118 -55
  28. package/dist/lookup-rr1AkCJA.js +71 -0
  29. package/dist/migrate-C9X2Vz81.js +274 -0
  30. package/dist/notification-url-CV86qiKP.js +100 -0
  31. package/dist/{open-studio-DOw-6ydc.js → open-CcpXotHG.js} +34 -43
  32. package/dist/org-BQQDo7wm.js +35 -0
  33. package/dist/output-Ggzq5_-t.js +122 -0
  34. package/dist/paths-CRlU72cq.js +29 -0
  35. package/dist/playbook-DVMXN7fh.js +53 -0
  36. package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
  37. package/dist/promote-Da8xctzy.js +91 -0
  38. package/dist/push-BV-grvQg.js +22 -0
  39. package/dist/push-D6R9icWN.js +495 -0
  40. package/dist/registry-BYVD-_h6.js +10385 -0
  41. package/dist/{reports-CfJqoava.js → reports-D_qbl7_u.js} +7 -6
  42. package/dist/{resources-Bf9O1JNM.js → resources-DLON3-61.js} +162 -55
  43. package/dist/{run-DsVZ5snL.js → run-Co-BwhOg.js} +16 -22
  44. package/dist/scan-B88OlWOt.js +4 -0
  45. package/dist/{scan-zKsddO72.js → scan-CKuk-_6W.js} +48 -37
  46. package/dist/scope-DV22_Ufm.js +198 -0
  47. package/dist/screenshot-file-tVBfUEIi.js +16 -0
  48. package/dist/{selection-CxZoX4NT.js → selection-C2_KbLuo.js} +100 -51
  49. package/dist/server-C4f6ccUr.js +22 -0
  50. package/dist/{dev-DmB3XqaJ.js → server-D0d2oP-5.js} +86 -94
  51. package/dist/session-B-Uz0cQ7.js +40 -0
  52. package/dist/session-BuvArt1j.js +6 -0
  53. package/dist/session-C4rbE3VS.js +796 -0
  54. package/dist/skills/animate-onboarding/SKILL.md +467 -0
  55. package/dist/skills/animate-onboarding/references/engine.md +494 -0
  56. package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
  57. package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
  58. package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
  59. package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
  60. package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  61. package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
  62. package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
  63. package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  64. package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
  65. package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
  66. package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
  67. package/dist/skills/animate-onboarding/references/performance.md +41 -0
  68. package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
  69. package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  70. package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  71. package/dist/skills/index.json +37 -0
  72. package/dist/skills/mobile-design/SKILL.md +447 -0
  73. package/dist/skills/mobile-design/references/responsive.md +162 -0
  74. package/dist/skills/onboarding-questions/SKILL.md +231 -0
  75. package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
  76. package/dist/skills/onboarding-questions/references/craft.md +142 -0
  77. package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
  78. package/dist/skills/superwall/SKILL.md +82 -9
  79. package/dist/skills/superwall/references/api.md +153 -37
  80. package/dist/skills/superwall/references/apple-setup.md +316 -0
  81. package/dist/skills/superwall/references/asc.md +74 -38
  82. package/dist/skills/superwall/references/data-analytics.md +55 -21
  83. package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
  84. package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
  85. package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
  86. package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
  87. package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
  88. package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
  89. package/dist/skills/superwall/workflows/placements/android.md +2 -2
  90. package/dist/skills/superwall/workflows/placements/expo.md +2 -2
  91. package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
  92. package/dist/skills/superwall/workflows/placements/ios.md +2 -2
  93. package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
  94. package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
  95. package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
  96. package/dist/skills/superwall/workflows/review/playbook.md +1 -1
  97. package/dist/skills/superwall-editor/SKILL.md +61 -0
  98. package/dist/skills/superwall-editor/references/cli.md +135 -0
  99. package/dist/skills/superwall-editor/references/design.md +51 -0
  100. package/dist/skills/superwall-editor/references/native-elements.md +171 -0
  101. package/dist/skills/superwall-editor/references/workflow.md +65 -0
  102. package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
  103. package/dist/skills/superwall-framework/SKILL.md +85 -31
  104. package/dist/skills/superwall-framework/references/cli.md +58 -27
  105. package/dist/skills/superwall-framework/references/examples.md +4 -3
  106. package/dist/skills/superwall-framework/references/layout.md +64 -9
  107. package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
  108. package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
  109. package/dist/skills/wwdc/SKILL.md +22 -0
  110. package/dist/skills/wwdc/references/docs.md +52 -0
  111. package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
  112. package/dist/skills-CLGJuMnF.js +14 -0
  113. package/dist/{skills-DPzlnfCK.js → skills-CZcpnEnG.js} +100 -122
  114. package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
  115. package/dist/spinner-C2U6QBJ9.js +294 -0
  116. package/dist/storage-6h9vyiAz.js +31 -0
  117. package/dist/storage-CerJ5KLP.d.ts +16 -0
  118. package/dist/storekit-CK9JmM2D.js +16 -0
  119. package/dist/storekit-CinJra3V.js +47 -0
  120. package/dist/telemetry-DKyDhURo.js +56 -0
  121. package/dist/theme-DUsCh-Vd.js +25 -0
  122. package/dist/timing-BVxPrYq3.js +5 -0
  123. package/dist/{token-C0it-Xh7.js → token-DaxQgQkv.js} +6 -38
  124. package/dist/tools-skills/animate-onboarding/SKILL.md +467 -0
  125. package/dist/tools-skills/animate-onboarding/references/engine.md +494 -0
  126. package/dist/tools-skills/animate-onboarding/references/framework/Question.tsx +71 -0
  127. package/dist/tools-skills/animate-onboarding/references/framework/README.md +40 -0
  128. package/dist/tools-skills/animate-onboarding/references/framework/answers.ts +19 -0
  129. package/dist/tools-skills/animate-onboarding/references/framework/flow.ts +80 -0
  130. package/dist/tools-skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  131. package/dist/tools-skills/animate-onboarding/references/framework/layout.tsx +113 -0
  132. package/dist/tools-skills/animate-onboarding/references/framework/motion.css +559 -0
  133. package/dist/tools-skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  134. package/dist/tools-skills/animate-onboarding/references/handoffs.md +375 -0
  135. package/dist/tools-skills/animate-onboarding/references/imageReady.ts +92 -0
  136. package/dist/tools-skills/animate-onboarding/references/morphFrame.ts +356 -0
  137. package/dist/tools-skills/animate-onboarding/references/performance.md +41 -0
  138. package/dist/tools-skills/animate-onboarding/references/web-runtime/README.md +17 -0
  139. package/dist/tools-skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  140. package/dist/tools-skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  141. package/dist/tools-skills/mobile-design/SKILL.md +447 -0
  142. package/dist/tools-skills/mobile-design/references/responsive.md +162 -0
  143. package/dist/tools-skills/onboarding-questions/SKILL.md +231 -0
  144. package/dist/tools-skills/onboarding-questions/references/arpu-questions.md +139 -0
  145. package/dist/tools-skills/onboarding-questions/references/craft.md +142 -0
  146. package/dist/tools-skills/onboarding-questions/references/example-reflective.md +117 -0
  147. package/dist/tools-skills/superwall/SKILL.md +263 -0
  148. package/dist/tools-skills/superwall/references/api.md +303 -0
  149. package/dist/tools-skills/superwall/references/asa.md +166 -0
  150. package/dist/tools-skills/superwall/references/asc.md +95 -0
  151. package/dist/tools-skills/superwall/references/dashboard-links.md +57 -0
  152. package/dist/tools-skills/superwall/references/data-analytics.md +896 -0
  153. package/dist/tools-skills/superwall/references/docs.md +51 -0
  154. package/dist/tools-skills/superwall/references/sdk-integration.md +104 -0
  155. package/dist/tools-skills/superwall/references/sdk-source.md +18 -0
  156. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +76 -0
  157. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +100 -0
  158. package/dist/tools-skills/superwall/workflows/integrate/android.md +292 -0
  159. package/dist/tools-skills/superwall/workflows/integrate/expo.md +272 -0
  160. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +285 -0
  161. package/dist/tools-skills/superwall/workflows/integrate/ios.md +314 -0
  162. package/dist/tools-skills/superwall/workflows/integrate/playbook.md +83 -0
  163. package/dist/tools-skills/superwall/workflows/integrate/react-native.md +246 -0
  164. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +229 -0
  165. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +78 -0
  166. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +227 -0
  167. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +414 -0
  168. package/dist/tools-skills/superwall/workflows/placements/android.md +175 -0
  169. package/dist/tools-skills/superwall/workflows/placements/expo.md +161 -0
  170. package/dist/tools-skills/superwall/workflows/placements/flutter.md +139 -0
  171. package/dist/tools-skills/superwall/workflows/placements/ios.md +165 -0
  172. package/dist/tools-skills/superwall/workflows/placements/playbook.md +69 -0
  173. package/dist/tools-skills/superwall/workflows/placements/react-native.md +145 -0
  174. package/dist/tools-skills/superwall/workflows/placements/strategy.md +222 -0
  175. package/dist/tools-skills/superwall/workflows/review/android.md +120 -0
  176. package/dist/tools-skills/superwall/workflows/review/expo.md +100 -0
  177. package/dist/tools-skills/superwall/workflows/review/flutter.md +99 -0
  178. package/dist/tools-skills/superwall/workflows/review/ios.md +108 -0
  179. package/dist/tools-skills/superwall/workflows/review/playbook.md +70 -0
  180. package/dist/tools-skills/superwall/workflows/review/react-native.md +100 -0
  181. package/dist/tools-skills/superwall-editor/SKILL.md +113 -0
  182. package/dist/tools-skills/superwall-editor/references/cli.md +135 -0
  183. package/dist/tools-skills/superwall-editor/references/design.md +51 -0
  184. package/dist/tools-skills/superwall-editor/references/native-elements.md +171 -0
  185. package/dist/tools-skills/superwall-editor/references/workflow.md +65 -0
  186. package/dist/tools-skills/superwall-editor/scripts/sw-editor.sh +662 -0
  187. package/dist/tools-skills/wwdc/SKILL.md +22 -0
  188. package/dist/tools-skills/wwdc/references/docs.md +52 -0
  189. package/dist/tools-skills/wwdc/scripts/wwdc.sh +266 -0
  190. package/dist/tools.d.ts +96 -0
  191. package/dist/tools.js +11360 -0
  192. package/dist/ui-D_qf3Gvw.js +53 -0
  193. package/dist/upgrade-DPo0a4Es.js +117 -0
  194. package/dist/upgrade-ffseQDMx.js +7 -0
  195. package/package.json +10 -5
  196. package/dist/api-CZzirVMj.js +0 -151
  197. package/dist/api-output-aJNw7Syy.js +0 -20
  198. package/dist/app-DH6U8yuI.js +0 -190
  199. package/dist/asa-C-sQzPPn.js +0 -1194
  200. package/dist/asc-1ZBJ6DwS.js +0 -778
  201. package/dist/auth-YRhlV3DE.js +0 -140
  202. package/dist/billing-CCYHdApx.js +0 -80
  203. package/dist/bundle-id-CKxl_026.js +0 -121
  204. package/dist/command-CMIz81Da.js +0 -301
  205. package/dist/dev-DZy6pOnB.js +0 -22
  206. package/dist/doctor-H-hf-Yww.js +0 -88
  207. package/dist/feedback-CKf-rpBW.js +0 -152
  208. package/dist/hosted-CXe9TrWx.js +0 -32
  209. package/dist/migrate-C9ERDR6y.js +0 -284
  210. package/dist/org-sj7uyvp-.js +0 -40
  211. package/dist/output-C4o2gJ1K.js +0 -146
  212. package/dist/params-l3CrvRtR.js +0 -51
  213. package/dist/pipeline-BqzqZhX1.js +0 -977
  214. package/dist/print-skill-ZojRSybs.js +0 -74
  215. package/dist/promote-BG8X4Nv_.js +0 -88
  216. package/dist/publish-sxLh-G4G.js +0 -35
  217. package/dist/push-bQ6Vxtg8.js +0 -35
  218. package/dist/query-_FbybaH-.js +0 -53
  219. package/dist/resource-CGIwSd29.js +0 -323
  220. package/dist/revenue-provider-ebsRINY8.js +0 -100
  221. package/dist/scope-BvzD-kO4.js +0 -223
  222. package/dist/skills-D_R-lEsK.js +0 -64
  223. package/dist/spinner-TWa0hia6.js +0 -18
  224. package/dist/storekit-Cj9Cpjcz.js +0 -29
  225. package/dist/telemetry-DeA1mvnT.js +0 -169
  226. package/dist/ui-Dy0b-9L8.js +0 -27738
  227. package/dist/update-B2fWIc4q.js +0 -59
  228. package/dist/upgrade-BmzkTKrh.js +0 -72
  229. /package/dist/{devtools-8EgLo86w.js → devtools-pBl_vt03.js} +0 -0
@@ -0,0 +1,495 @@
1
+ import { _ as VERSION } from "./environment-eBXjELoN.js";
2
+ import { n as ui } from "./ui-D_qf3Gvw.js";
3
+ import { C as pushedProducts, E as versionProducts, S as pushPaywallVersion, b as promotePaywallVersion, h as livePaywall, v as platformLabel, y as platformStore } from "./resources-DLON3-61.js";
4
+ import { A as writeSnapshot, F as requireAssets, I as syncAssets, M as frameworkVersion, N as resolveFramework, O as writeBindings, P as assetBaseUrl, T as removeBinding, _ as weight, a as resolveProjectDir, b as describeBindings, c as storesDiffer, d as kb, f as pendingPromoteWarning, g as transition, h as took, i as requireProject, l as BIND_VERB, m as resolveNote, p as pushedLine, r as requireClean, s as selectSurfaces, t as needsWork, v as collectProjectDeclarations, w as readLock, y as writeProjectTypes } from "./selection-C2_KbLuo.js";
5
+ import { _ as targetLabel, d as listProjectCatalogue, g as planTargets, h as parsePlatformFlags, i as pushSource, l as writeProjectScaffold, m as requireProducts, n as requireApi, o as collectSourceFiles, p as projectForApplication, r as assertGit, s as warnNotPortable, v as wantedPlatforms, x as resolveApps, y as resolveBinding } from "./session-C4rbE3VS.js";
6
+ import pc from "picocolors";
7
+ import { cpus } from "node:os";
8
+
9
+ //#region src/core/paywalls/binding/renames.ts
10
+ var RenameError = class extends Error {};
11
+ function parseRenameFlags(value) {
12
+ return (value === void 0 ? [] : Array.isArray(value) ? value : [value]).map((entry) => {
13
+ const text = typeof entry === "string" ? entry.trim() : "";
14
+ const at = text.indexOf("=");
15
+ const from = at === -1 ? "" : text.slice(0, at).trim();
16
+ const to = at === -1 ? "" : text.slice(at + 1).trim();
17
+ if (!from || !to) throw new RenameError(`--rename takes <old>=<new>, e.g. --rename plus-upgrade=pro-upgrade` + (text ? ` (got "${text}")` : ""));
18
+ return {
19
+ from,
20
+ to
21
+ };
22
+ });
23
+ }
24
+ function unresolvedError(orphans, newcomers) {
25
+ return new RenameError([
26
+ "Cannot tell whether these are new or renamed, and this run cannot ask.",
27
+ "",
28
+ "Bound in superwall.lock, but no directory on disk:",
29
+ ...orphans.map((orphan) => ` ${orphan.id} → ${describeBindings(orphan.bindings)}`),
30
+ "On disk, but not in superwall.lock:",
31
+ ...newcomers.map((newcomer) => ` ${newcomer.id}`),
32
+ "",
33
+ "Declare each rename, then run again:",
34
+ ...newcomers.flatMap((newcomer) => orphans.map((orphan) => ` --rename ${orphan.id}=${newcomer.id}`)),
35
+ "",
36
+ "If one of these paywalls is genuinely gone, remove its entry from",
37
+ "superwall.lock by hand and run again.",
38
+ "",
39
+ "Refusing to create — the bound paywalls are what production serves."
40
+ ].join("\n"));
41
+ }
42
+ async function resolveRenames(input) {
43
+ const lock = readLock(input.superwallDir);
44
+ const orphans = [];
45
+ const newcomers = [];
46
+ for (const kind of ["paywall", "funnel"]) {
47
+ const section = kind === "paywall" ? lock.paywalls : lock.funnels;
48
+ const onDisk = input.surfaces.filter((surface) => surface.kind === kind);
49
+ const ids = new Set(onDisk.map((surface) => surface.id));
50
+ for (const [id, bindings] of Object.entries(section).sort(([a], [b]) => a.localeCompare(b))) if (!ids.has(id)) orphans.push({
51
+ kind,
52
+ id,
53
+ bindings
54
+ });
55
+ for (const surface of onDisk) if (!(surface.id in section)) newcomers.push(surface);
56
+ }
57
+ const renamed = [];
58
+ const rebind = (orphan, newcomer) => {
59
+ writeBindings(input.superwallDir, newcomer.kind, newcomer.id, orphan.bindings);
60
+ removeBinding(input.superwallDir, orphan.kind, orphan.id);
61
+ renamed.push({
62
+ kind: newcomer.kind,
63
+ from: orphan.id,
64
+ to: newcomer.id,
65
+ bindings: orphan.bindings
66
+ });
67
+ orphans.splice(orphans.indexOf(orphan), 1);
68
+ newcomers.splice(newcomers.indexOf(newcomer), 1);
69
+ };
70
+ for (const declaration of input.declared ?? []) {
71
+ const newcomer = newcomers.find((candidate) => candidate.id === declaration.to);
72
+ if (!newcomer) throw new RenameError(`--rename ${declaration.from}=${declaration.to}: no unbound directory named "${declaration.to}".`);
73
+ const orphan = orphans.find((candidate) => candidate.id === declaration.from && candidate.kind === newcomer.kind);
74
+ if (!orphan) throw new RenameError(`--rename ${declaration.from}=${declaration.to}: superwall.lock has no ${newcomer.kind} "${declaration.from}" waiting to be renamed.`);
75
+ rebind(orphan, newcomer);
76
+ }
77
+ for (const newcomer of [...newcomers]) {
78
+ const candidates = orphans.filter((orphan) => orphan.kind === newcomer.kind);
79
+ if (candidates.length === 0) continue;
80
+ if (!input.choose) throw unresolvedError(candidates, [newcomer]);
81
+ const decision = await input.choose({
82
+ newcomer,
83
+ orphans: candidates
84
+ });
85
+ if (decision.kind === "rename") {
86
+ const orphan = candidates.find((candidate) => candidate.id === decision.orphanId);
87
+ if (!orphan) throw new RenameError(`No pending rename candidate named "${decision.orphanId}".`);
88
+ rebind(orphan, newcomer);
89
+ }
90
+ }
91
+ const dropped = [];
92
+ const kept = [];
93
+ for (const orphan of orphans) {
94
+ if (!input.chooseStale) {
95
+ input.notice?.(`\`${orphan.id}\` is still bound to ${describeBindings(orphan.bindings)} but no longer exists on disk — remove it from superwall.lock if that paywall is gone.`);
96
+ kept.push(orphan);
97
+ continue;
98
+ }
99
+ if (await input.chooseStale(orphan) === "remove") {
100
+ removeBinding(input.superwallDir, orphan.kind, orphan.id);
101
+ dropped.push(orphan);
102
+ } else kept.push(orphan);
103
+ }
104
+ return {
105
+ renamed,
106
+ stale: kept,
107
+ dropped
108
+ };
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/core/paywalls/pickers/adopt.ts
113
+ const ADOPT = "__adopt__";
114
+ const STOP = "__stop__";
115
+ async function pickAdoptOption(candidate) {
116
+ const { surface, paywallId, applicationId } = candidate;
117
+ return await ui.select({
118
+ message: `App ${applicationId} already has a paywall \`${surface.id}\` (${paywallId}), and superwall.lock doesn't bind it. It may belong to someone else in this app.`,
119
+ options: [{
120
+ value: STOP,
121
+ label: "Stop",
122
+ hint: "rename the directory to push as a new paywall"
123
+ }, {
124
+ value: ADOPT,
125
+ label: `Push to paywall ${paywallId}`,
126
+ hint: "it's mine — bind it in superwall.lock"
127
+ }],
128
+ initialValue: STOP
129
+ }) === ADOPT;
130
+ }
131
+
132
+ //#endregion
133
+ //#region src/core/paywalls/pickers/application.ts
134
+ async function pickApplicationOption(apps, platform) {
135
+ const picked = await ui.select({
136
+ message: platform ? `Which ${platformLabel(platform)} app do these paywalls push to? The choice is saved under apps in superwall.lock.` : "Which app do these paywalls belong to?",
137
+ options: apps.map((app) => ({
138
+ value: String(app.id),
139
+ label: app.name ?? app.bundle_id ?? String(app.id),
140
+ hint: platformLabel(app.platform)
141
+ }))
142
+ });
143
+ if (!picked) return null;
144
+ return apps.find((app) => String(app.id) === picked) ?? null;
145
+ }
146
+
147
+ //#endregion
148
+ //#region src/core/paywalls/pickers/rename.ts
149
+ const CREATE = "__create__";
150
+ async function pickRenameOption(input) {
151
+ const picked = await ui.select({
152
+ message: `\`${input.newcomer.id}\` is not in superwall.lock. Is it a new ${input.newcomer.kind}, or renamed?`,
153
+ options: [...input.orphans.map((orphan) => ({
154
+ value: orphan.id,
155
+ label: `Renamed from ${orphan.id}`,
156
+ hint: describeBindings(orphan.bindings)
157
+ })), {
158
+ value: CREATE,
159
+ label: `Create a new ${input.newcomer.kind}`
160
+ }]
161
+ });
162
+ if (picked === null) throw new RenameError("Cancelled — superwall.lock is unchanged and nothing was pushed.");
163
+ return picked === CREATE ? { kind: "create" } : {
164
+ kind: "rename",
165
+ orphanId: picked
166
+ };
167
+ }
168
+
169
+ //#endregion
170
+ //#region src/core/paywalls/pickers/stale.ts
171
+ const REMOVE = "__remove__";
172
+ const KEEP = "__keep__";
173
+ async function pickStaleOption(orphan) {
174
+ const picked = await ui.select({
175
+ message: `\`${orphan.id}\` is bound to ${describeBindings(orphan.bindings)} but no longer exists on disk. Removing only forgets it locally — the paywall stays on Superwall, keeps its campaigns, and keeps serving devices.`,
176
+ options: [{
177
+ value: REMOVE,
178
+ label: "Remove the binding",
179
+ hint: "restoring the directory re-binds it on the next push"
180
+ }, {
181
+ value: KEEP,
182
+ label: "Keep it",
183
+ hint: "superwall.lock is left as it is"
184
+ }],
185
+ initialValue: REMOVE
186
+ });
187
+ if (picked === null) throw new RenameError("Cancelled — superwall.lock is unchanged and nothing was pushed.");
188
+ return picked === REMOVE ? "remove" : "keep";
189
+ }
190
+
191
+ //#endregion
192
+ //#region src/core/paywalls/pipeline/push.ts
193
+ async function pooled(items, limit, work) {
194
+ const results = new Array(items.length);
195
+ let cursor = 0;
196
+ const runners = Array.from({ length: Math.min(limit, items.length) }, async () => {
197
+ while (cursor < items.length) {
198
+ const index = cursor++;
199
+ const item = items[index];
200
+ if (item === void 0) continue;
201
+ results[index] = await work(item, index);
202
+ }
203
+ });
204
+ await Promise.all(runners);
205
+ return results;
206
+ }
207
+ async function timed(work) {
208
+ const at = Date.now();
209
+ return {
210
+ value: await work(),
211
+ took: took(at)
212
+ };
213
+ }
214
+ async function group(outputMode, id, work) {
215
+ const spin = outputMode === "rich" ? ui.spinner() : void 0;
216
+ spin?.start(id);
217
+ try {
218
+ const lines = await work((message) => spin?.message(`${id} ${pc.dim(message)}`));
219
+ const block = [pc.bold(id), ...lines].join("\n");
220
+ if (spin) spin.stop(block);
221
+ else ui.info(block);
222
+ } catch (error) {
223
+ if (spin) spin.stop(pc.red(`${id} failed`));
224
+ else ui.info(pc.red(`${id} failed`));
225
+ throw error;
226
+ }
227
+ }
228
+ function summary(outcomes, skipped, promoted) {
229
+ const count = outcomes.length;
230
+ const noun = (n) => n === 1 ? "paywall" : "paywalls";
231
+ const unchanged = skipped > 0 ? ` · ${pc.dim(`${skipped} unchanged`)}` : "";
232
+ if (count === 0) {
233
+ ui.outro(skipped > 0 ? `Nothing to do · ${skipped} unchanged.` : "Nothing to do.");
234
+ return;
235
+ }
236
+ if (promoted) {
237
+ ui.outro(`${pc.green(`${count} ${noun(count)} live`)}${unchanged}.`);
238
+ return;
239
+ }
240
+ ui.outro(`${count} ${noun(count)} pushed${unchanged} · run \`superwall promote\` to publish ${count === 1 ? "it" : "them"}.`);
241
+ }
242
+ const BUILD_CONCURRENCY = Math.max(2, Math.min(8, cpus().length - 1));
243
+ async function prepare(context, input) {
244
+ const { framework, project, surfaces, declared } = input;
245
+ const apps = await resolveApps({
246
+ api: context.api,
247
+ superwallDir: project.superwallDir,
248
+ wanted: wantedPlatforms(surfaces, declared),
249
+ pickApplication: context.interactive ? pickApplicationOption : void 0
250
+ });
251
+ const multi = Object.keys(apps).length > 1;
252
+ const targets = planTargets({
253
+ surfaces,
254
+ declared,
255
+ apps,
256
+ only: parsePlatformFlags(input.platforms)
257
+ });
258
+ const spin = context.outputMode === "rich" ? ui.spinner() : void 0;
259
+ const label = targets.length === 1 && targets[0] !== void 0 ? targetLabel(targets[0], multi) : `${targets.length} paywalls`;
260
+ spin?.start(`Building ${label}`);
261
+ const at = Date.now();
262
+ try {
263
+ const projectIds = /* @__PURE__ */ new Map();
264
+ for (const target of targets) {
265
+ if (projectIds.has(target.applicationId)) continue;
266
+ projectIds.set(target.applicationId, await projectForApplication(context.api, target.applicationId));
267
+ }
268
+ const catalogues = /* @__PURE__ */ new Map();
269
+ for (const projectId of new Set(projectIds.values())) {
270
+ if (projectId === void 0) continue;
271
+ catalogues.set(projectId, await listProjectCatalogue(context.api, projectId));
272
+ }
273
+ const catalogueOf = (target) => {
274
+ const projectId = projectIds.get(target.applicationId);
275
+ return projectId === void 0 ? void 0 : catalogues.get(projectId);
276
+ };
277
+ const builds = await pooled(targets, BUILD_CONCURRENCY, (target) => framework.buildSnapshot(project, target.surface, {
278
+ assetBaseUrl: assetBaseUrl(target.applicationId),
279
+ platform: target.platform,
280
+ catalogue: catalogueOf(target)?.variables
281
+ }));
282
+ for (const [projectId, catalogue] of catalogues) requireProducts(catalogue.variables, targets.flatMap((target, index) => projectIds.get(target.applicationId) === projectId ? [{
283
+ id: target.surface.id,
284
+ products: builds[index]?.products
285
+ }] : []));
286
+ const bindings = [];
287
+ for (const [index, target] of targets.entries()) bindings.push(await resolveBinding({
288
+ api: context.api,
289
+ superwallDir: project.superwallDir,
290
+ surface: target.surface,
291
+ app: {
292
+ platform: target.platform,
293
+ applicationId: target.applicationId
294
+ },
295
+ name: builds[index]?.name,
296
+ surfaces: project.surfaces,
297
+ renamesResolved: true,
298
+ confirmAdopt: context.interactive ? pickAdoptOption : void 0
299
+ }));
300
+ const prepared = await pooled(targets, BUILD_CONCURRENCY, async (target, index) => {
301
+ const bind = bindings[index];
302
+ const build = builds[index];
303
+ if (!bind || !build) throw new Error(`Missing binding for ${target.surface.id}`);
304
+ requireAssets(build);
305
+ const live = await livePaywall(context.api, bind.paywallId);
306
+ const lock = readLock(project.superwallDir);
307
+ const recorded = (target.surface.kind === "paywall" ? lock.paywalls : lock.funnels)[target.surface.id]?.[target.platform];
308
+ const stores = catalogueOf(target)?.stores ?? {};
309
+ const unsourced = recorded?.snapshot === build.snapshotId ? recorded.sourcePending : void 0;
310
+ const stale = needsWork(build.snapshotId, recorded?.snapshot, live.snapshotId);
311
+ const storesChanged = !stale && storesDiffer(versionProducts(build.products, target.platform, stores), await pushedProducts(context.api, bind.paywallId, build.snapshotId));
312
+ const changed = unsourced !== void 0 || stale || storesChanged;
313
+ return {
314
+ target,
315
+ bind,
316
+ build,
317
+ live: live.version,
318
+ changed,
319
+ pending: !changed && live.snapshotId !== build.snapshotId,
320
+ unsourced: storesChanged ? void 0 : unsourced,
321
+ stores
322
+ };
323
+ });
324
+ const modified = prepared.filter((entry) => entry.changed).length;
325
+ spin?.stop(`${pc.bold(`Built ${label}`)} ${pc.dim(`${modified} modified · ${prepared.length - modified} unchanged`)} ${took(at)}`);
326
+ return {
327
+ prepared,
328
+ multi
329
+ };
330
+ } catch (error) {
331
+ spin?.stop(pc.red(`Building ${label} failed`));
332
+ throw error;
333
+ }
334
+ }
335
+ async function pushVersion(context, input, lines, note) {
336
+ const { target, bind, build } = input;
337
+ const assets = requireAssets(build);
338
+ lines.push(assets.length > 0 ? `Built ${pc.dim(`${kb(build.bytes)} html + ${weight(build.assetBytes ?? 0)} assets`)}` : `Built ${pc.dim(`${kb(build.bytes)} · ${build.snapshotId.slice(0, 8)}`)}`);
339
+ note("Syncing assets");
340
+ const synced = await timed(() => syncAssets({
341
+ api: context.api,
342
+ paywallId: bind.paywallId,
343
+ assets
344
+ }));
345
+ if (assets.length > 0) {
346
+ const noun = assets.length === 1 ? "asset" : "assets";
347
+ lines.push(synced.value.uploaded > 0 ? `${assets.length} ${noun} ${pc.dim(`(${weight(synced.value.totalBytes)})`)}, ${synced.value.uploaded} uploaded ${synced.took}` : `Assets up to date ${pc.dim(`(${assets.length} ${noun})`)} ${synced.took}`);
348
+ }
349
+ const products = versionProducts(build.products, target.platform, input.stores);
350
+ const elsewhere = products.filter((product) => product.store !== platformStore(target.platform));
351
+ if (elsewhere.length > 0) lines.push(`Products ${pc.dim(elsewhere.map((product) => `${product.reference_name} → ${product.store}`).join(", "))}`);
352
+ note("Pushing");
353
+ const push = await timed(() => pushPaywallVersion(context.api, bind.paywallId, {
354
+ html: build.html,
355
+ surface: target.surface.id,
356
+ assets: synced.value.assets,
357
+ products,
358
+ settings: build.settings,
359
+ locales: build.locales
360
+ }));
361
+ lines.push(`${pushedLine({
362
+ version: push.value.version,
363
+ snapshotId: push.value.snapshot_id ?? build.snapshotId,
364
+ live: input.wasLive,
365
+ promoting: input.promoting
366
+ })} ${push.took}`);
367
+ return push.value.version;
368
+ }
369
+ async function runPushPipeline(context, options) {
370
+ const dir = resolveProjectDir(options.dir);
371
+ const framework = await (options.load ?? resolveFramework)(dir);
372
+ const project = requireProject(framework.discoverProject(dir), dir);
373
+ const installed = frameworkVersion(dir);
374
+ const declarations = await collectProjectDeclarations(framework, project.root);
375
+ writeProjectTypes(project, declarations.products);
376
+ writeProjectScaffold({
377
+ root: project.root,
378
+ superwallDir: project.superwallDir,
379
+ frameworkVersion: installed
380
+ });
381
+ const surfaces = selectSurfaces(project, options.ids ?? []);
382
+ requireClean(surfaces);
383
+ const publishNote = resolveNote(options.message);
384
+ ui.intro(`Superwall ${pc.dim(`v${VERSION}`)}`);
385
+ const renames = await resolveRenames({
386
+ superwallDir: project.superwallDir,
387
+ surfaces: project.surfaces,
388
+ declared: parseRenameFlags(options.renames ?? []),
389
+ choose: context.interactive ? pickRenameOption : void 0,
390
+ chooseStale: context.interactive ? pickStaleOption : void 0,
391
+ notice: (message) => ui.warn(message)
392
+ });
393
+ for (const pair of renames.renamed) ui.step(`${pair.kind}/${pair.to} keeps ${describeBindings(pair.bindings)} (renamed from ${pair.from})`);
394
+ for (const orphan of renames.dropped) ui.step(`${orphan.kind}/${orphan.id} removed from superwall.lock · ${describeBindings(orphan.bindings)} untouched on Superwall`);
395
+ const source = await collectSourceFiles(project.superwallDir);
396
+ const outcomes = [];
397
+ const external = /* @__PURE__ */ new Set();
398
+ const { prepared, multi } = await prepare(context, {
399
+ framework,
400
+ project,
401
+ surfaces,
402
+ declared: declarations.platforms,
403
+ platforms: options.platforms ?? []
404
+ });
405
+ for (const entry of prepared) for (const source$1 of entry.build.externalSources ?? []) external.add(source$1);
406
+ const changed = prepared.filter((entry) => entry.changed);
407
+ const skipped = prepared.length - changed.length;
408
+ const pendingHint = pendingPromoteWarning((options.promote ? prepared.filter((entry) => entry.pending) : []).map((entry) => ({
409
+ id: entry.target.surface.id,
410
+ platform: entry.target.platform
411
+ })), multi);
412
+ if (pendingHint) ui.warn(pendingHint);
413
+ if (changed.length > 0) {
414
+ if (!source.ok) throw new Error(source.reason);
415
+ await assertGit();
416
+ }
417
+ const files = source.ok ? source.files : [];
418
+ for (const { target, bind, build, live: wasLive, unsourced, stores } of changed) {
419
+ const { surface } = target;
420
+ let version = 0;
421
+ let live = false;
422
+ await group(context.outputMode, targetLabel(target, multi), async (note) => {
423
+ const lines = [`${BIND_VERB[bind.source]} paywall ${bind.paywallId}`];
424
+ if (unsourced === void 0) {
425
+ version = await pushVersion(context, {
426
+ target,
427
+ bind,
428
+ build,
429
+ stores,
430
+ wasLive,
431
+ promoting: options.promote
432
+ }, lines, note);
433
+ writeSnapshot(project.superwallDir, surface.kind, surface.id, target.platform, {
434
+ snapshot: build.snapshotId,
435
+ sourcePending: version
436
+ });
437
+ } else {
438
+ version = unsourced;
439
+ lines.push(`Finishing version ${version} ${pc.dim("(its source never landed)")}`);
440
+ }
441
+ note("Pushing source");
442
+ const pushed = await timed(() => pushSource({
443
+ api: context.api,
444
+ superwallDir: project.superwallDir,
445
+ paywallId: bind.paywallId,
446
+ applicationId: bind.applicationId,
447
+ version,
448
+ files,
449
+ framework: installed,
450
+ surface: surface.id,
451
+ kind: surface.kind,
452
+ snapshotId: build.snapshotId,
453
+ cli: VERSION,
454
+ note: publishNote,
455
+ external: [...build.externalSources ?? []].sort(),
456
+ overwrite: options.overwriteSource
457
+ }));
458
+ writeSnapshot(project.superwallDir, surface.kind, surface.id, target.platform, { snapshot: build.snapshotId });
459
+ const sha = pc.dim(pushed.value.commitSha.slice(0, 7));
460
+ lines.push(`Source ${pushed.value.status === "unchanged" ? "unchanged" : "pushed"} ${sha} ${pushed.took}`);
461
+ if (options.promote) {
462
+ note("Promoting");
463
+ const promo = await timed(() => promotePaywallVersion(context.api, bind.paywallId, { version }));
464
+ lines.push(`${transition(wasLive, promo.value.version)} ${promo.took}`);
465
+ live = true;
466
+ }
467
+ return lines;
468
+ });
469
+ outcomes.push({
470
+ id: targetLabel(target, multi),
471
+ version,
472
+ live
473
+ });
474
+ }
475
+ warnNotPortable(external);
476
+ summary(outcomes, skipped, options.promote);
477
+ }
478
+ async function runPush(ctx, { args, flags }, promote) {
479
+ await runPushPipeline({
480
+ api: await requireApi(ctx.interactive),
481
+ interactive: ctx.interactive,
482
+ outputMode: ctx.outputMode
483
+ }, {
484
+ promote,
485
+ dir: args.dir,
486
+ ids: flags.id,
487
+ platforms: flags.platform,
488
+ renames: flags.rename,
489
+ message: flags.message,
490
+ overwriteSource: flags.overwriteSource
491
+ });
492
+ }
493
+
494
+ //#endregion
495
+ export { pickApplicationOption as a, timed as i, runPush as n, pickAdoptOption as o, runPushPipeline as r, group as t };