@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,274 @@
1
+ import "./token-DaxQgQkv.js";
2
+ import { t as blocks } from "./output-Ggzq5_-t.js";
3
+ import { _ as VERSION, c as DASHBOARD_URL } from "./environment-eBXjELoN.js";
4
+ import { a as sessionOrgName, t as readSession } from "./storage-6h9vyiAz.js";
5
+ import "./client-BL0f_yGf.js";
6
+ import "./config-BO1Y87kV.js";
7
+ import "./telemetry-DKyDhURo.js";
8
+ import "./spawn-DmmmHIP-.js";
9
+ import "./spinner-C2U6QBJ9.js";
10
+ import { n as ui } from "./ui-D_qf3Gvw.js";
11
+ import "./theme-DUsCh-Vd.js";
12
+ import { t as stripReport } from "./log-NVhVe_oe.js";
13
+ import { t as scanProject } from "./scan-CKuk-_6W.js";
14
+ import { t as detectExisting } from "./existing-BltvQiX5.js";
15
+ import "./paths-CRlU72cq.js";
16
+ import "./resources-DLON3-61.js";
17
+ import "./lookup-rr1AkCJA.js";
18
+ import "./login-BbTIrCFT.js";
19
+ import "./skills-CZcpnEnG.js";
20
+ import "./selection-C2_KbLuo.js";
21
+ import { n as requireApi } from "./session-C4rbE3VS.js";
22
+ import { n as performLoginWithUi } from "./login-BCEH5q0U.js";
23
+ import { t as runAction } from "./run-Co-BwhOg.js";
24
+ import { t as detectDrivers } from "./drivers-CPhdPkW5.js";
25
+ import { _ as screenNameOf, a as buildMigrationCopyPrompt, c as migrationFor, d as projectDirOf, f as scaffoldFromPaywall, g as placementOfName, h as findScreenCandidates, i as startStudio, l as migrationSource, m as screenMigrationFor, n as migrationNextSteps, o as hasOriginal, p as scaffoldFromScreen, r as screenNextSteps, t as askStudio, u as offerMigration } from "./open-CcpXotHG.js";
26
+ import "./server-D0d2oP-5.js";
27
+ import { r as actionById, t as detectBilling } from "./billing-C3Q8DBU2.js";
28
+ import { n as writeReport } from "./reports-D_qbl7_u.js";
29
+ import { execFile } from "node:child_process";
30
+ import * as fs from "node:fs";
31
+ import * as path from "node:path";
32
+ import * as os$1 from "node:os";
33
+
34
+ //#region src/core/paywalls/simulator.ts
35
+ function createSimulator(run = execFile, platform = os$1.platform()) {
36
+ const simctl = (args) => new Promise((resolve$1) => {
37
+ run("xcrun", ["simctl", ...args], { timeout: 15e3 }, (error, stdout) => {
38
+ resolve$1(error ? void 0 : String(stdout));
39
+ });
40
+ });
41
+ return {
42
+ booted: async () => {
43
+ if (platform !== "darwin") return void 0;
44
+ const output = await simctl([
45
+ "list",
46
+ "devices",
47
+ "booted",
48
+ "-j"
49
+ ]);
50
+ if (output === void 0) return void 0;
51
+ try {
52
+ const parsed = JSON.parse(output);
53
+ for (const list of Object.values(parsed.devices ?? {})) {
54
+ const device = list.find((entry) => entry.state === "Booted" && typeof entry.udid === "string");
55
+ if (device?.udid) return {
56
+ udid: device.udid,
57
+ name: device.name ?? device.udid
58
+ };
59
+ }
60
+ } catch {
61
+ return;
62
+ }
63
+ },
64
+ screenshot: async (udid) => {
65
+ const file = path.join(os$1.tmpdir(), `superwall-original-${Date.now()}.png`);
66
+ return await simctl([
67
+ "io",
68
+ udid,
69
+ "screenshot",
70
+ file
71
+ ]) === void 0 ? void 0 : file;
72
+ }
73
+ };
74
+ }
75
+ async function askForScreenshot(ui$1, runtime = createSimulator()) {
76
+ const booted = await runtime.booted();
77
+ if (booted === void 0) return void 0;
78
+ if (await ui$1.confirm({
79
+ message: `Capture \`${booted.name}\` as the original? Show the screen in the simulator first.`,
80
+ initial: true
81
+ }) !== true) return void 0;
82
+ const file = await runtime.screenshot(booted.udid);
83
+ if (file === void 0) {
84
+ ui$1.warn("The simulator screenshot failed — review against the running app instead.");
85
+ return;
86
+ }
87
+ ui$1.step(`Captured \`${booted.name}\``);
88
+ return file;
89
+ }
90
+
91
+ //#endregion
92
+ //#region src/core/workflows/migrate.ts
93
+ async function runPaywallMigration(ctx, paywallId, skill) {
94
+ const { installDir, interactive } = ctx;
95
+ if (!skill) ui.intro(`Superwall migrate v${VERSION}`);
96
+ const existingDir = projectDirOf(installDir);
97
+ let migration = existingDir === void 0 ? void 0 : migrationFor(existingDir, paywallId);
98
+ if (skill) {
99
+ if (migration === void 0) throw new Error(`Paywall ${paywallId} isn't in this project yet — run \`superwall migrate ${paywallId}\` once without --skill to scaffold it, then print the prompt.`);
100
+ process.stdout.write(`${buildMigrationCopyPrompt(migration)}\n`);
101
+ return;
102
+ }
103
+ if (migration === void 0) {
104
+ const api = await requireApi(interactive);
105
+ const target = existingDir ?? path.join(installDir, "superwall");
106
+ if (existingDir === void 0 && fs.existsSync(path.join(target, "package.json"))) throw new Error(`\`${target}\` already has a package.json that isn't a superwall project — move it aside first.`);
107
+ migration = migrationFor(target, (await scaffoldFromPaywall(ui, api, {
108
+ root: installDir,
109
+ target,
110
+ paywallId,
111
+ newProject: existingDir === void 0
112
+ })).id);
113
+ if (migration === void 0) throw new Error(`Paywall ${paywallId} has no served document to rebuild from — nothing was recorded in superwall.lock.`);
114
+ } else ui.info(`\`paywalls/${migration.surfaceId}\` was scaffolded from paywall ${paywallId} — picking up the rebuild.`);
115
+ const choice = await offerMigration(ui, interactive, migration);
116
+ const opening = choice === "agent" && await askStudio(ui, interactive, migration.surfaceId);
117
+ ctx.output.render(blocks.nextSteps(migrationNextSteps(opening, path.relative(installDir, migration.superwallDir) || ".", paywallId, choice)), blocks.outro(`Done. ${DASHBOARD_URL}`));
118
+ if (opening) await startStudio(migration.superwallDir, migration.surfaceId);
119
+ }
120
+ async function pickScreen(ctx) {
121
+ const { installDir, interactive } = ctx;
122
+ const candidates = findScreenCandidates(installDir);
123
+ if (candidates.length === 0) throw new Error(`No screen-like files found under ${path.relative(process.cwd(), installDir) || "."} — pass one: \`superwall migrate --screen <path>\`.`);
124
+ if (!interactive) {
125
+ ui.list({ items: candidates.map((candidate) => ({
126
+ label: candidate.path,
127
+ meta: candidate.reason
128
+ })) });
129
+ ui.info("Pass one: `superwall migrate --screen <path>`.");
130
+ return;
131
+ }
132
+ return await ui.select({
133
+ message: "Which screen should ship through Superwall?",
134
+ options: candidates.map((candidate) => ({
135
+ value: candidate.path,
136
+ label: candidate.path,
137
+ hint: candidate.reason
138
+ }))
139
+ }) ?? void 0;
140
+ }
141
+ async function runScreenMigration(ctx, screen, skill) {
142
+ const { installDir, interactive } = ctx;
143
+ if (!skill) ui.intro(`Superwall migrate v${VERSION}`);
144
+ const existingDir = projectDirOf(installDir);
145
+ let file = screen.path === "" ? void 0 : path.resolve(screen.path);
146
+ if (file === void 0) {
147
+ if (skill) throw new Error("`--skill` needs the screen: `superwall migrate --screen <path> --skill`.");
148
+ const picked = await pickScreen(ctx);
149
+ if (picked === void 0) return;
150
+ file = path.resolve(installDir, picked);
151
+ }
152
+ const shown = path.relative(process.cwd(), file) || ".";
153
+ let migration = existingDir === void 0 ? void 0 : screenMigrationFor(existingDir, file);
154
+ if (skill) {
155
+ if (migration === void 0) throw new Error(`\`${shown}\` isn't in this project yet — run \`superwall migrate --screen ${shown}\` once without --skill to scaffold it, then print the prompt.`);
156
+ process.stdout.write(`${buildMigrationCopyPrompt(migration)}\n`);
157
+ return;
158
+ }
159
+ if (migration === void 0) {
160
+ const target = existingDir ?? path.join(installDir, "superwall");
161
+ if (existingDir === void 0 && fs.existsSync(path.join(target, "package.json"))) throw new Error(`\`${target}\` already has a package.json that isn't a superwall project — move it aside first.`);
162
+ let screenshot = screen.screenshot === void 0 ? void 0 : path.resolve(screen.screenshot);
163
+ if (screenshot !== void 0 && !fs.existsSync(screenshot)) throw new Error(`No screenshot at \`${screen.screenshot}\`.`);
164
+ if (screenshot === void 0 && interactive) screenshot = await askForScreenshot(ui);
165
+ scaffoldFromScreen(ui, {
166
+ root: installDir,
167
+ target,
168
+ file,
169
+ newProject: existingDir === void 0,
170
+ screenshot
171
+ });
172
+ migration = screenMigrationFor(target, file);
173
+ if (migration === void 0) throw new Error(`\`${shown}\` was not recorded in superwall.lock — nothing to rebuild.`);
174
+ } else ui.info(`\`paywalls/${migration.surfaceId}\` was scaffolded from \`${shown}\` — picking up the rebuild.`);
175
+ const choice = await offerMigration(ui, interactive, migration);
176
+ const original = hasOriginal(migration);
177
+ const opening = choice === "agent" && await askStudio(ui, interactive, migration.surfaceId, original);
178
+ ctx.output.render(blocks.nextSteps(screenNextSteps({
179
+ studioOpening: opening,
180
+ superwallDir: path.relative(installDir, migration.superwallDir) || ".",
181
+ screenPath: migrationSource(migration),
182
+ placement: placementOfName(screenNameOf(file)),
183
+ screenshot: original,
184
+ choice
185
+ })), blocks.outro(`Done. ${DASHBOARD_URL}`));
186
+ if (opening) await startStudio(migration.superwallDir, migration.surfaceId, original);
187
+ }
188
+ async function runProviderMigration(ctx) {
189
+ const { installDir, dryRun } = ctx;
190
+ ui.intro(`Superwall migrate v${VERSION}`);
191
+ const [detected, ...fallbacks] = await detectDrivers();
192
+ if (!detected) throw new Error("No coding agent found (Claude Code or Codex).");
193
+ const driver = detected.driver;
194
+ const fallbackDrivers = fallbacks.map((candidate) => candidate.driver);
195
+ const app = (await scanProject(installDir)).apps[0];
196
+ if (!app) throw new Error("No iOS / Android / Expo / React Native / Flutter app found here.");
197
+ ui.info(`Detected \`${app.framework.name}\`${app.details ? ` · \`${app.details}\`` : ""}`);
198
+ const billing = detectBilling(app);
199
+ const provider = billing.revenueCat ? "RevenueCat" : billing.adapty ? "Adapty" : billing.qonversion ? "Qonversion" : null;
200
+ if (!provider) {
201
+ ui.warn("No RevenueCat / Adapty / Qonversion detected - nothing to migrate.");
202
+ ui.info("Starting fresh? Run `superwall integrate` to set up directly.");
203
+ ui.outro("");
204
+ return;
205
+ }
206
+ ui.info(`Found \`${provider}\``);
207
+ let intent = "full";
208
+ if (ctx.interactive && !dryRun) {
209
+ const sel = await ui.select({
210
+ message: `Migrate from ${provider} - how far?`,
211
+ options: [{
212
+ value: "full",
213
+ label: "Full migration",
214
+ hint: `replace ${provider} with Superwall`
215
+ }, {
216
+ value: "paywalls",
217
+ label: "Paywalls only",
218
+ hint: `keep ${provider} for billing`
219
+ }],
220
+ initialValue: "full"
221
+ });
222
+ if (sel === null) return void ui.warn("Cancelled.");
223
+ intent = sel;
224
+ }
225
+ let session = readSession();
226
+ if (session) ui.success(`Logged in as \`${session.userEmail ?? "you"}\`${sessionOrgName(session) ? ` · \`${sessionOrgName(session)}\`` : ""}`);
227
+ else if (ctx.interactive && !dryRun) session = await performLoginWithUi();
228
+ if (session?.apiKey) process.env.SUPERWALL_API_KEY = session.apiKey;
229
+ const existing = detectExisting(app);
230
+ const actionCtx = {
231
+ app,
232
+ apiKey: existing.apiKey ?? "",
233
+ existing,
234
+ billingProvider: provider,
235
+ migrateIntent: intent
236
+ };
237
+ if (dryRun) {
238
+ ui.note([
239
+ `Provider: ${provider}`,
240
+ `Mode: ${intent}`,
241
+ `App: ${app.name} (${app.framework.name})`,
242
+ `Path: ${app.path}`
243
+ ].join("\n"), "Migration plan");
244
+ ui.outro("Dry run - no changes made.");
245
+ return;
246
+ }
247
+ const spin = ui.spinner();
248
+ spin.start(`Migrating from ${provider}`);
249
+ const result = await runAction({
250
+ driver,
251
+ fallbackDrivers,
252
+ action: actionById["migrate"],
253
+ ctx: actionCtx,
254
+ onEvent: (e) => {
255
+ if (e.type === "status") spin.message(e.text);
256
+ }
257
+ });
258
+ if (result.ok) {
259
+ spin.stop("Migration complete");
260
+ if (result.finalText) {
261
+ const plain = stripReport(result.finalText);
262
+ writeReport(app.path, "migrate", plain);
263
+ ui.report(plain);
264
+ }
265
+ } else {
266
+ spin.stop("Migration stopped early");
267
+ if (result.finalText) ui.report(stripReport(result.finalText).slice(0, 1500));
268
+ throw new Error("Migration did not complete.");
269
+ }
270
+ ctx.output.render(blocks.nextSteps(["Rebuild your paywalls - as code (`superwall create`) or in the dashboard editor - and attach products.", "Verify a purchase on device."]), blocks.outro(`Done. ${DASHBOARD_URL}`));
271
+ }
272
+
273
+ //#endregion
274
+ export { runPaywallMigration, runProviderMigration, runScreenMigration };
@@ -0,0 +1,100 @@
1
+ import { D as updateServerNotifications, r as chooseKeyApp } from "./held-DgnTFMl3.js";
2
+ import { t as apiCall } from "./spinner-C2U6QBJ9.js";
3
+ import { i as findAppNotificationUrl } from "./client-BZ1UbpXz.js";
4
+ import { t as timing } from "./timing-BVxPrYq3.js";
5
+
6
+ //#region src/core/app-store-connect/notification-url.ts
7
+ const RETRY_DELAYS = [
8
+ 1e3,
9
+ 2e3,
10
+ 3e3
11
+ ];
12
+ async function settled(sleep, work) {
13
+ for (let attempt = 0;; attempt++) {
14
+ const outcome = await work();
15
+ const delay = RETRY_DELAYS[attempt];
16
+ if (outcome.status !== "failed" || !outcome.retryable || delay === void 0) return outcome;
17
+ await sleep(delay);
18
+ }
19
+ }
20
+ function ensureNotificationUrl(ctx, sleep, api, app, options) {
21
+ return apiCall(ctx, "Setting the server notification URL", () => {
22
+ return settled(sleep, () => updateServerNotifications(api, app, options));
23
+ });
24
+ }
25
+ function holder(environment) {
26
+ switch (environment.owner) {
27
+ case "this_app": return "this app's Superwall URL";
28
+ case "none": return "none";
29
+ case "superwall_app": return environment.application ? `another Superwall app, ${environment.application.name} (app ${environment.application.id})` : "another Superwall app";
30
+ case "other": return "another server";
31
+ }
32
+ }
33
+ function environmentLines(outcome) {
34
+ return ["production", "sandbox"].flatMap((name) => {
35
+ const environment = outcome[name];
36
+ if (!environment) return [];
37
+ const label = name === "production" ? "Production" : "Sandbox";
38
+ const shown = environment.owner === "this_app" || environment.owner === "none" || !environment.url ? "" : ` ${environment.url}`;
39
+ return [`${label}: ${holder(environment)}${shown}`];
40
+ });
41
+ }
42
+ function describeNotificationUrl(outcome) {
43
+ switch (outcome.status) {
44
+ case "set": return "Apple now sends this app's server notifications to Superwall.";
45
+ case "already_set": return "Apple already sends this app's server notifications to Superwall.";
46
+ case "not_set": return "Apple has no server notification URL for this app in production, sandbox, or both. No other server holds either.";
47
+ case "conflict": {
48
+ const holders = ["production", "sandbox"].map((name) => outcome[name]).filter((environment) => environment?.owner === "superwall_app" || environment?.owner === "other");
49
+ return holders.length > 0 && holders.every((environment) => environment.owner === "superwall_app") ? "Apple sends this app's server notifications to another Superwall app. Superwall won't replace it." : "Apple sends this app's server notifications to another server. Superwall won't replace it.";
50
+ }
51
+ case "skipped": return outcome.message ?? "Apple can't be asked about this app's server notification URL.";
52
+ case "failed": return outcome.message ?? "Apple couldn't be asked about this app's server notification URL.";
53
+ }
54
+ }
55
+ function printServerNotifications(ctx, applicationId, outcome, ok, extra = {}) {
56
+ if (ctx.json) ctx.output.data({
57
+ application_id: applicationId,
58
+ url: outcome.url,
59
+ apple: {
60
+ status: outcome.status,
61
+ message: outcome.message,
62
+ production: outcome.production,
63
+ sandbox: outcome.sandbox
64
+ },
65
+ ...extra
66
+ });
67
+ else {
68
+ const message = [describeNotificationUrl(outcome), ...environmentLines(outcome).map((line) => ` ${line}`)].join("\n");
69
+ if (!ok) ctx.ui.error(message);
70
+ else if (outcome.status === "set" || outcome.status === "already_set") ctx.ui.success(message);
71
+ else ctx.ui.info(message);
72
+ }
73
+ if (!ok) ctx.fail();
74
+ }
75
+ async function runAscNotificationUrlSet(ctx, { flags }) {
76
+ const { api } = ctx;
77
+ const { app } = await chooseKeyApp(ctx, {
78
+ app: flags.app,
79
+ project: flags.project
80
+ });
81
+ const setRevenueProvider = flags.setRevenueProvider;
82
+ if (ctx.dryRun) {
83
+ const url = await apiCall(ctx, "Loading the URL", () => findAppNotificationUrl(api, app));
84
+ if (ctx.json) return ctx.output.data({
85
+ dryRun: true,
86
+ action: "set",
87
+ application_id: app.applicationId,
88
+ url,
89
+ set_revenue_provider: setRevenueProvider
90
+ });
91
+ ctx.ui.info(`[dry-run] would set ${url} where Apple has no server notification URL.`);
92
+ return;
93
+ }
94
+ const outcome = await ensureNotificationUrl(ctx, timing.sleep, api, app, { setRevenueProvider });
95
+ const ok = outcome.status === "set" || outcome.status === "already_set";
96
+ printServerNotifications(ctx, app.applicationId, outcome, ok, { set_revenue_provider: setRevenueProvider });
97
+ }
98
+
99
+ //#endregion
100
+ export { runAscNotificationUrlSet as a, printServerNotifications as i, ensureNotificationUrl as n, environmentLines as r, describeNotificationUrl as t };
@@ -1,16 +1,16 @@
1
- import { f as DASHBOARD_URL } from "./output-C4o2gJ1K.js";
2
- import { n as executeCommand, r as ApiError } from "./command-CMIz81Da.js";
3
- import { i as stripReport } from "./ui-Dy0b-9L8.js";
4
- import { i as loadBundledSkill } from "./skills-DPzlnfCK.js";
5
- import { n as allDeps, r as readPackageJson } from "./scan-zKsddO72.js";
6
- import { t as detectDrivers } from "./drivers-Qx9LxmRN.js";
7
- import { c as getPaywall, p as listApplications, x as projectOrganizationId } from "./resources-Bf9O1JNM.js";
8
- import { C as writeApp, E as writeOrigin, b as isScreenOrigin, x as readLock } from "./selection-CxZoX4NT.js";
9
- import { v as projectPackageName } from "./pipeline-BqzqZhX1.js";
10
- import { a as copyToClipboard, i as loadPrompt, n as runWithDriverFallback } from "./run-DsVZ5snL.js";
11
- import { t as runDev } from "./dev-DmB3XqaJ.js";
12
- import * as path from "node:path";
1
+ import { b as isNonInteractive, c as DASHBOARD_URL } from "./environment-eBXjELoN.js";
2
+ import { t as ApiError } from "./client-BL0f_yGf.js";
3
+ import { t as stripReport } from "./log-NVhVe_oe.js";
4
+ import { i as readPackageJson, r as allDeps } from "./scan-CKuk-_6W.js";
5
+ import { c as findPaywall, f as listApplications } from "./resources-DLON3-61.js";
6
+ import { d as readBundledSkill } from "./skills-CZcpnEnG.js";
7
+ import { E as writeApp, S as isScreenOrigin, k as writeOrigin, w as readLock } from "./selection-C2_KbLuo.js";
8
+ import { c as projectPackageName } from "./session-C4rbE3VS.js";
9
+ import { a as copyToClipboard, i as readPrompt, n as runWithDriverFallback } from "./run-Co-BwhOg.js";
10
+ import { t as detectDrivers } from "./drivers-CPhdPkW5.js";
11
+ import { t as runStudio } from "./server-D0d2oP-5.js";
13
12
  import * as fs from "node:fs";
13
+ import * as path from "node:path";
14
14
  import fg from "fast-glob";
15
15
 
16
16
  //#region src/core/paywalls/project/origin.ts
@@ -497,7 +497,7 @@ const SNAKE_ID = /^[a-z0-9]+(_[a-z0-9.]+)+$/;
497
497
  const IDENTIFIER_LIKE = /^[A-Za-z_$][\w$.\-/]*$/;
498
498
  const interpolationsIn = (value, framework) => {
499
499
  const pattern = framework === "swiftui" || framework === "uikit" ? /\\\(([^)]*)\)/g : framework === "flutter" || framework === "compose" || framework === "android-views" ? /\$\{([^}]*)\}|\$([A-Za-z_]\w*)/g : /\$\{([^}]*)\}/g;
500
- return [...value.matchAll(pattern)].map((match) => (match[1] ?? match[2] ?? "").trim());
500
+ return [...value.matchAll(pattern)].flatMap((match) => match.slice(1).filter((group) => group !== void 0).map((group) => group.trim()));
501
501
  };
502
502
  const MODULE_CONTEXT = /\b(import|from|package)\s*$/;
503
503
  const looksLikeCopy = (value) => /[A-Za-z]/.test(value) && !/^https?:|^itms-apps:|^mailto:|^tel:/.test(value) && !IDENTIFIER_LIKE.test(value) && !(/^\S+$/.test(value) && /[/:@]/.test(value)) && !/<\/?[A-Za-z]|\/>/.test(value) && !/^[%\\]/.test(value) && !/^#[0-9a-fA-F]{3,8}$/.test(value) && !/^[\d.\s+\-*/()%]+$/.test(value);
@@ -634,7 +634,7 @@ function scanInterfaceBuilder(xml, classes) {
634
634
  const text = (xml.includes("<scene") ? [...xml.matchAll(/<scene[\s\S]*?<\/scene>/g)].map((match) => match[0]).filter((scene) => classes.some((name) => scene.includes(`customClass="${name}"`))) : [xml]).join("\n");
635
635
  const copy = [...text.matchAll(/\b(?:text|title|placeholder|normalTitle|value)="([^"]*)"/g)].map((match) => decodeXml(match[1]).trim()).filter((value) => /[A-Za-z]/.test(value));
636
636
  const assets = [...text.matchAll(/\bimage="([^"]*)"/g)].map((match) => match[1]);
637
- const symbols = [...text.matchAll(/\bcatalog="system"[^>]*\bimage="([^"]*)"|\bimage="([^"]*)"[^>]*\bcatalog="system"/g)].map((match) => match[1] ?? match[2] ?? "");
637
+ const symbols = [...text.matchAll(/\bcatalog="system"[^>]*\bimage="([^"]*)"|\bimage="([^"]*)"[^>]*\bcatalog="system"/g)].flatMap((match) => match.slice(1).filter((group) => group !== void 0));
638
638
  const taps = (text.match(/<button\b/g) ?? []).length;
639
639
  return {
640
640
  copy: unique(copy),
@@ -683,7 +683,7 @@ const EMPTY_INVENTORY = {
683
683
  productIds: [],
684
684
  actions: []
685
685
  };
686
- const ANDROID_RESOURCE_TYPES = /\b(ViewModel|Presenter|State|Model)\b/;
686
+ const ANDROID_RESOURCE_TYPES = /(Model|Presenter)$/;
687
687
  function androidCompanionsOf(searchRoot, primary, source) {
688
688
  const options = {
689
689
  cwd: searchRoot,
@@ -707,12 +707,7 @@ function androidStringsOf(companions) {
707
707
  const strings = /* @__PURE__ */ new Map();
708
708
  for (const file of companions) {
709
709
  if (!file.endsWith("strings.xml")) continue;
710
- let xml;
711
- try {
712
- xml = fs.readFileSync(file, "utf8");
713
- } catch {
714
- continue;
715
- }
710
+ const xml = fs.readFileSync(file, "utf8");
716
711
  for (const match of xml.matchAll(/<string\s+name="([^"]+)"[^>]*>([\s\S]*?)<\/string>/g)) strings.set(match[1], decodeXml(match[2].trim()).replace(/^"|"$/g, "").replace(/\\'/g, "'"));
717
712
  }
718
713
  return strings;
@@ -967,7 +962,7 @@ const ACTION_MAPPING = {
967
962
  tap: ["a tappable control", "a `<button>` calling one of the hooks above"]
968
963
  };
969
964
  const table = (rows) => rows.map((row) => `| ${row.join(" | ")} |`).join("\n");
970
- const bulletsOr = (values, empty, format = (value) => `\`${value}\``) => values.length === 0 ? `_${empty}_` : values.map((value) => `- ${format(value)}`).join("\n");
965
+ const bulletsOr = (values, empty) => values.length === 0 ? `_${empty}_` : values.map((value) => `- \`${value}\``).join("\n");
971
966
  function screenBrief(screen, screenshot) {
972
967
  const { inventory } = screen;
973
968
  const copy = inventory.copy.length === 0 ? "_No user-visible strings were found in the file; read it for text drawn elsewhere (localized string tables, view models)._" : table([
@@ -1045,7 +1040,7 @@ ${actions}
1045
1040
  //#endregion
1046
1041
  //#region src/core/paywalls/migration.ts
1047
1042
  const screenFileOf = (migration, origin) => path.resolve(migration.superwallDir, origin.path);
1048
- const migrationSource = (migration, from = process.cwd()) => isScreenOrigin(migration.origin) ? path.relative(from, screenFileOf(migration, migration.origin)) || "." : migration.origin.paywallId;
1043
+ const migrationSource = (migration, from = process.cwd()) => isScreenOrigin(migration.origin) ? path.relative(from, screenFileOf(migration, migration.origin)) : migration.origin.paywallId;
1049
1044
  const migrationCommand = (migration, from = process.cwd()) => isScreenOrigin(migration.origin) ? `superwall migrate --screen ${migrationSource(migration, from)}` : `superwall migrate ${migration.origin.paywallId}`;
1050
1045
  const hasOriginal = (migration) => !isScreenOrigin(migration.origin) || migration.origin.screenshot !== void 0;
1051
1046
  function isSuperwallProject(dir) {
@@ -1102,11 +1097,12 @@ function scaffoldFromScreen(ui, options) {
1102
1097
  ...screenshot === void 0 ? {} : { screenshot }
1103
1098
  };
1104
1099
  writeOrigin(target, "paywall", screen.slug, origin);
1100
+ const actions = inventory.actions.reduce((sum, action) => sum + action.count, 0);
1105
1101
  const found = [
1106
1102
  `${inventory.copy.length} string${inventory.copy.length === 1 ? "" : "s"}`,
1107
1103
  `${inventory.assets.length} asset${inventory.assets.length === 1 ? "" : "s"}`,
1108
1104
  `${inventory.productIds.length} product${inventory.productIds.length === 1 ? "" : "s"}`,
1109
- `${inventory.actions.reduce((sum, action) => sum + action.count, 0)} action${inventory.actions.length === 1 ? "" : "s"}`
1105
+ `${actions} action${actions === 1 ? "" : "s"}`
1110
1106
  ].join(", ");
1111
1107
  ui.step(`Read \`${screen.path}\` (${screenFrameworkLabel(screen.framework)}): ${found}`);
1112
1108
  ui.step(`Created ${path.relative(root, target) || "."}/paywalls/${screen.slug} for \`${screen.name}\``);
@@ -1118,13 +1114,13 @@ async function scaffoldFromPaywall(ui, api, options) {
1118
1114
  const { root, target, paywallId } = options;
1119
1115
  const spin = ui.spinner();
1120
1116
  spin.start(`Reading paywall ${paywallId}`);
1121
- const detail = await getPaywall(api, paywallId).catch((error) => {
1117
+ const detail = await findPaywall(api, paywallId).catch((error) => {
1122
1118
  spin.stop(`Could not read paywall ${paywallId}`);
1123
1119
  if (error instanceof ApiError && [
1124
1120
  401,
1125
1121
  403,
1126
1122
  404
1127
- ].includes(error.status)) throw new Error(`Paywall ${paywallId} isn't visible to this account. Check the id in the dashboard URL, and if it belongs to another organization, switch with \`superwall orgs use <id>\` first.`);
1123
+ ].includes(error.status)) throw new Error(`Paywall ${paywallId} isn't visible to this account. Check the id in the dashboard URL.`);
1128
1124
  throw error;
1129
1125
  });
1130
1126
  if (detail.headless) {
@@ -1151,11 +1147,7 @@ async function scaffoldFromPaywall(ui, api, options) {
1151
1147
  writeApp(target, origin.platform, origin.applicationId);
1152
1148
  const app = (await listApplications(api).catch(() => [])).find((candidate) => String(candidate.id) === origin.applicationId);
1153
1149
  if (app) ui.success(`Pushes go to \`${app.name ?? app.id}\`, the paywall's app — saved in superwall.lock, so commit that file.`);
1154
- else {
1155
- const organization = origin.projectId === void 0 ? void 0 : await projectOrganizationId(api, origin.projectId).catch(() => void 0);
1156
- ui.success(`Pushes go to app ${origin.applicationId}, the paywall's app — saved in superwall.lock.`);
1157
- ui.warn(organization === void 0 ? "That app is in another organization: run `superwall orgs use <id>` before pushing." : `That app is in another organization: run \`superwall orgs use ${organization}\` before pushing.`);
1158
- }
1150
+ else ui.success(`Pushes go to app ${origin.applicationId}, the paywall's app — saved in superwall.lock.`);
1159
1151
  }
1160
1152
  }
1161
1153
  return origin;
@@ -1168,23 +1160,23 @@ const SCREEN_REFERENCE = {
1168
1160
  "react-native": "react-native",
1169
1161
  flutter: "flutter"
1170
1162
  };
1171
- const screenPrompt = (migration, origin) => loadPrompt("actions/screen-migrate.xml", {
1163
+ const screenPrompt = (migration, origin) => readPrompt("actions/screen-migrate.xml", {
1172
1164
  project_dir: migration.superwallDir,
1173
1165
  surface_dir: `paywalls/${migration.surfaceId}`,
1174
1166
  source_path: origin.path,
1175
1167
  framework: screenFrameworkLabel(origin.framework),
1176
1168
  screenshot: origin.screenshot === void 0 ? "none" : `paywalls/${migration.surfaceId}/${origin.screenshot}`,
1177
1169
  dashboard_url: DASHBOARD_URL,
1178
- skill: loadBundledSkill("superwall-screen-migrate", SCREEN_REFERENCE[origin.framework]),
1170
+ skill: readBundledSkill("superwall-screen-migrate", SCREEN_REFERENCE[origin.framework]),
1179
1171
  brief: migration.brief || "(MIGRATION.md is missing — inventory the source file first.)"
1180
1172
  });
1181
- const paywallPrompt = (migration, origin) => loadPrompt("actions/paywall-migrate.xml", {
1173
+ const paywallPrompt = (migration, origin) => readPrompt("actions/paywall-migrate.xml", {
1182
1174
  project_dir: migration.superwallDir,
1183
1175
  surface_dir: `paywalls/${migration.surfaceId}`,
1184
1176
  paywall_id: origin.paywallId,
1185
1177
  source_url: origin.url,
1186
1178
  dashboard_url: DASHBOARD_URL,
1187
- skill: loadBundledSkill("superwall-paywall-migrate"),
1179
+ skill: readBundledSkill("superwall-paywall-migrate"),
1188
1180
  brief: migration.brief || "(MIGRATION.md is missing — inventory the source from its URL first.)"
1189
1181
  });
1190
1182
  function buildMigrationPrompt(migration) {
@@ -1261,7 +1253,7 @@ async function offerMigration(ui, interactive, migration, forced, deps = runtime
1261
1253
  }
1262
1254
 
1263
1255
  //#endregion
1264
- //#region src/commands/paywalls/open-studio.ts
1256
+ //#region src/core/paywalls/studio/open.ts
1265
1257
  async function askStudio(ui, interactive, surfaceId, original = true) {
1266
1258
  if (!interactive) return false;
1267
1259
  return await ui.confirm({
@@ -1269,15 +1261,14 @@ async function askStudio(ui, interactive, surfaceId, original = true) {
1269
1261
  initial: true
1270
1262
  }) === true;
1271
1263
  }
1272
- async function startStudio(superwallDir, surfaceId, original = true) {
1273
- await executeCommand(runDev.definition, {
1274
- _: [],
1275
- $0: "superwall",
1276
- dir: [superwallDir],
1264
+ async function startStudio(superwallDir, surfaceId, original = true, deps = {}) {
1265
+ await runStudio({
1266
+ dirs: [superwallDir],
1277
1267
  port: 6100,
1278
1268
  host: "0.0.0.0",
1279
- open: original ? `paywall/${surfaceId}?compare=origin` : `paywall/${surfaceId}`
1280
- }, {});
1269
+ open: original ? `paywall/${surfaceId}?compare=origin` : `paywall/${surfaceId}`,
1270
+ interactive: !isNonInteractive()
1271
+ }, deps);
1281
1272
  }
1282
1273
  function migrationNextSteps(studioOpening, superwallDir, paywallId, choice) {
1283
1274
  const compare = studioOpening ? "The studio opens on the rebuilt paywall with the original beside it. Walk every page in both schemes (the toolbar's Compare menu switches the right pane)." : `Run \`superwall dev\` in ${superwallDir}, open the paywall, and pick Compare › Original in the toolbar. Walk every page in both schemes.`;
@@ -0,0 +1,35 @@
1
+ import { n as withSpinner } from "./spinner-C2U6QBJ9.js";
2
+ import { n as ui } from "./ui-D_qf3Gvw.js";
3
+ import { M as listOrgGroups, N as listOrganizations, T as titleCase, w as rowName } from "./resources-DLON3-61.js";
4
+
5
+ //#region src/core/account/org.ts
6
+ async function orgForNewProject(api, interactive) {
7
+ const orgs = await withSpinner("Loading your account", () => listOrganizations(api));
8
+ const [first] = orgs;
9
+ if (!first) throw new Error("Your account has no organization yet - run `superwall login` to create one.");
10
+ if (orgs.length === 1) return String(first.id);
11
+ if (!interactive) throw new Error(`You belong to ${orgs.length} organizations, so a new project needs a home: run this interactively to choose, or pass --project <id> to add the app to an existing project.`);
12
+ return chooseOrg(orgs, "Which organization should own the new project?");
13
+ }
14
+ async function chooseOrg(orgs, message) {
15
+ const sel = await ui.select({
16
+ message,
17
+ options: orgs.map((o) => ({
18
+ value: String(o.id),
19
+ label: rowName(o),
20
+ hint: titleCase(String(o.role ?? ""))
21
+ }))
22
+ });
23
+ if (sel === null) throw new Error("Cancelled.");
24
+ return sel;
25
+ }
26
+ async function chooseOrgOfApps(api, message) {
27
+ return chooseOrg((await listOrgGroups(api)).map((group) => ({
28
+ id: group.id,
29
+ name: group.name ?? `Organization ${group.id}`,
30
+ role: group.member ? "" : "not a member"
31
+ })), message);
32
+ }
33
+
34
+ //#endregion
35
+ export { orgForNewProject as n, chooseOrgOfApps as t };