@superwall/cli 1.7.0 → 2.0.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 (165) hide show
  1. package/README.md +192 -52
  2. package/dist/{setup-Bxj22rYi.js → apple-CkKlHBZ9.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-XCZU_T46.js} +98 -28
  6. package/dist/{bind-YrJvuRF9.js → bind-drne__Ys.js} +38 -33
  7. package/dist/{build-DLoCW5Ri.js → build-Gpdq5QXP.js} +20 -26
  8. package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
  9. package/dist/client-DP6Rc0t_.js +176 -0
  10. package/dist/config-BO1Y87kV.js +105 -0
  11. package/dist/{notification-url-DuKF2659.js → create-BBrtgUgS.js} +235 -539
  12. package/dist/{create-pkANt1Gs.js → create-Cwc3SRWJ.js} +194 -168
  13. package/dist/create-Yvf2gStM.js +19 -0
  14. package/dist/doctor-C9ldpPFC.js +83 -0
  15. package/dist/{drivers-Qx9LxmRN.js → drivers-DNrx4LWA.js} +185 -172
  16. package/dist/entry.d.ts +0 -5
  17. package/dist/entry.js +28073 -1134
  18. package/dist/environment-DF1qKlny.js +58 -0
  19. package/dist/{existing-AVEfZu2A.js → existing-78LWSsqS.js} +12 -6
  20. package/dist/held-Cy8Wl4D1.js +1112 -0
  21. package/dist/held-Ddw1XSsr.js +16 -0
  22. package/dist/input-vi0bou04.js +42 -0
  23. package/dist/{integrate-brmhPG-S.js → integrate-DcJhpXy8.js} +277 -254
  24. package/dist/kinds-GFXB3sYu.js +11 -0
  25. package/dist/log-NVhVe_oe.js +62 -0
  26. package/dist/login-B2TsCE2H.js +53 -0
  27. package/dist/login-BoBe8Psl.js +16 -0
  28. package/dist/{login-Do4wFuLv.js → login-D0lh3_JI.js} +118 -55
  29. package/dist/lookup-D-nmmAbw.js +71 -0
  30. package/dist/migrate-Cfec564E.js +274 -0
  31. package/dist/notification-url-YDbq6FMA.js +100 -0
  32. package/dist/{open-studio-DOw-6ydc.js → open-Ba2vBl1_.js} +34 -43
  33. package/dist/org-D0g_q3mv.js +35 -0
  34. package/dist/output-Ggzq5_-t.js +122 -0
  35. package/dist/paths-DxSLdpOI.js +29 -0
  36. package/dist/playbook-DIeb7hne.js +53 -0
  37. package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
  38. package/dist/promote-COD4fYdz.js +91 -0
  39. package/dist/push-CncywhkQ.js +482 -0
  40. package/dist/push-CtD4FZQV.js +22 -0
  41. package/dist/registry-DSrosOYs.js +10228 -0
  42. package/dist/{reports-CfJqoava.js → reports-DdPq4blM.js} +7 -6
  43. package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
  44. package/dist/{run-DsVZ5snL.js → run-C9qg_QlC.js} +16 -22
  45. package/dist/scan-Cv5uOwVY.js +4 -0
  46. package/dist/{scan-zKsddO72.js → scan-DLrsrFS9.js} +48 -37
  47. package/dist/scope-V336uz8j.js +198 -0
  48. package/dist/screenshot-file-0UETadF8.js +16 -0
  49. package/dist/{selection-CxZoX4NT.js → selection-Rdw-ZUoG.js} +94 -51
  50. package/dist/send-BxD9yf6F.js +150 -0
  51. package/dist/{dev-DmB3XqaJ.js → server-D0tGG8C4.js} +82 -92
  52. package/dist/server-z1LH94R_.js +22 -0
  53. package/dist/session-1AV_Bs_d.js +6 -0
  54. package/dist/session-CFAmMhem.js +40 -0
  55. package/dist/session-D_nEWKXT.js +768 -0
  56. package/dist/skills/animate-onboarding/SKILL.md +467 -0
  57. package/dist/skills/animate-onboarding/references/engine.md +494 -0
  58. package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
  59. package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
  60. package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
  61. package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
  62. package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  63. package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
  64. package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
  65. package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  66. package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
  67. package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
  68. package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
  69. package/dist/skills/animate-onboarding/references/performance.md +41 -0
  70. package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
  71. package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  72. package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  73. package/dist/skills/index.json +37 -0
  74. package/dist/skills/mobile-design/SKILL.md +447 -0
  75. package/dist/skills/mobile-design/references/responsive.md +162 -0
  76. package/dist/skills/onboarding-questions/SKILL.md +231 -0
  77. package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
  78. package/dist/skills/onboarding-questions/references/craft.md +142 -0
  79. package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
  80. package/dist/skills/superwall/SKILL.md +82 -9
  81. package/dist/skills/superwall/references/api.md +153 -37
  82. package/dist/skills/superwall/references/apple-setup.md +316 -0
  83. package/dist/skills/superwall/references/asc.md +74 -38
  84. package/dist/skills/superwall/references/data-analytics.md +55 -21
  85. package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
  86. package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
  87. package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
  88. package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
  89. package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
  90. package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
  91. package/dist/skills/superwall/workflows/placements/android.md +2 -2
  92. package/dist/skills/superwall/workflows/placements/expo.md +2 -2
  93. package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
  94. package/dist/skills/superwall/workflows/placements/ios.md +2 -2
  95. package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
  96. package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
  97. package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
  98. package/dist/skills/superwall/workflows/review/playbook.md +1 -1
  99. package/dist/skills/superwall-editor/SKILL.md +61 -0
  100. package/dist/skills/superwall-editor/references/cli.md +135 -0
  101. package/dist/skills/superwall-editor/references/design.md +51 -0
  102. package/dist/skills/superwall-editor/references/native-elements.md +171 -0
  103. package/dist/skills/superwall-editor/references/workflow.md +65 -0
  104. package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
  105. package/dist/skills/superwall-framework/SKILL.md +78 -28
  106. package/dist/skills/superwall-framework/references/cli.md +58 -28
  107. package/dist/skills/superwall-framework/references/examples.md +4 -3
  108. package/dist/skills/superwall-framework/references/layout.md +30 -8
  109. package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
  110. package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
  111. package/dist/skills/wwdc/SKILL.md +22 -0
  112. package/dist/skills/wwdc/references/docs.md +52 -0
  113. package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
  114. package/dist/{skills-DPzlnfCK.js → skills-BvFOa4y6.js} +99 -122
  115. package/dist/skills-DMG4bpKk.js +14 -0
  116. package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
  117. package/dist/spinner-CneRK5rk.js +294 -0
  118. package/dist/storage-DYvmIOHa.d.ts +16 -0
  119. package/dist/storage-s2Dnz-yl.js +31 -0
  120. package/dist/storekit-DafAnGkM.js +16 -0
  121. package/dist/storekit-yY_kS2iR.js +47 -0
  122. package/dist/telemetry-DtG92m5O.js +56 -0
  123. package/dist/theme-DUsCh-Vd.js +25 -0
  124. package/dist/timing-BVxPrYq3.js +5 -0
  125. package/dist/{token-C0it-Xh7.js → token-DzRh7dI1.js} +6 -38
  126. package/dist/tools.d.ts +96 -0
  127. package/dist/tools.js +11178 -0
  128. package/dist/ui-D_qf3Gvw.js +53 -0
  129. package/dist/upgrade-Bt4Ouw1y.js +117 -0
  130. package/dist/upgrade-Cqy5orjb.js +7 -0
  131. package/package.json +10 -5
  132. package/dist/api-CZzirVMj.js +0 -151
  133. package/dist/api-output-aJNw7Syy.js +0 -20
  134. package/dist/app-DH6U8yuI.js +0 -190
  135. package/dist/asa-C-sQzPPn.js +0 -1194
  136. package/dist/asc-1ZBJ6DwS.js +0 -778
  137. package/dist/auth-YRhlV3DE.js +0 -140
  138. package/dist/billing-CCYHdApx.js +0 -80
  139. package/dist/bundle-id-CKxl_026.js +0 -121
  140. package/dist/command-CMIz81Da.js +0 -301
  141. package/dist/dev-DZy6pOnB.js +0 -22
  142. package/dist/doctor-H-hf-Yww.js +0 -88
  143. package/dist/feedback-CKf-rpBW.js +0 -152
  144. package/dist/hosted-CXe9TrWx.js +0 -32
  145. package/dist/migrate-C9ERDR6y.js +0 -284
  146. package/dist/org-sj7uyvp-.js +0 -40
  147. package/dist/output-C4o2gJ1K.js +0 -146
  148. package/dist/params-l3CrvRtR.js +0 -51
  149. package/dist/pipeline-BqzqZhX1.js +0 -977
  150. package/dist/print-skill-ZojRSybs.js +0 -74
  151. package/dist/promote-BG8X4Nv_.js +0 -88
  152. package/dist/publish-sxLh-G4G.js +0 -35
  153. package/dist/push-bQ6Vxtg8.js +0 -35
  154. package/dist/query-_FbybaH-.js +0 -53
  155. package/dist/resource-CGIwSd29.js +0 -323
  156. package/dist/revenue-provider-ebsRINY8.js +0 -100
  157. package/dist/scope-BvzD-kO4.js +0 -223
  158. package/dist/skills-D_R-lEsK.js +0 -64
  159. package/dist/spinner-TWa0hia6.js +0 -18
  160. package/dist/storekit-Cj9Cpjcz.js +0 -29
  161. package/dist/telemetry-DeA1mvnT.js +0 -169
  162. package/dist/ui-Dy0b-9L8.js +0 -27738
  163. package/dist/update-B2fWIc4q.js +0 -59
  164. package/dist/upgrade-BmzkTKrh.js +0 -72
  165. /package/dist/{devtools-8EgLo86w.js → devtools-ByZ6XYnn.js} +0 -0
@@ -1,88 +0,0 @@
1
- import { S as apiKeyFromEnv } from "./output-C4o2gJ1K.js";
2
- import "./telemetry-DeA1mvnT.js";
3
- import "./update-B2fWIc4q.js";
4
- import { i as loadSession } from "./token-C0it-Xh7.js";
5
- import { t as defineCommand } from "./command-CMIz81Da.js";
6
- import { a as THEME, n as ui, o as fg } from "./ui-Dy0b-9L8.js";
7
- import "./spawn-DSoTXy_j.js";
8
- import { t as scanProject } from "./scan-zKsddO72.js";
9
- import { t as detectDrivers } from "./drivers-Qx9LxmRN.js";
10
- import "./hosted-CXe9TrWx.js";
11
- import { t as detectExisting } from "./existing-AVEfZu2A.js";
12
-
13
- //#region src/commands/account/doctor.ts
14
- const runDoctor = defineCommand({
15
- name: "doctor",
16
- auth: "optional",
17
- output: "both",
18
- async run(ctx) {
19
- ui.intro("Superwall doctor");
20
- const spin = ui.spinner();
21
- spin.start("Checking your setup");
22
- const drivers = await detectDrivers();
23
- const scan = await scanProject(ctx.installDir);
24
- spin.stop("Checks complete");
25
- const top = scan.apps[0];
26
- const existing = top ? detectExisting(top) : null;
27
- const session = loadSession();
28
- const rows = [
29
- [
30
- drivers.length > 0,
31
- "Coding agent",
32
- drivers.map((d) => d.info.displayName).join(", ") || "none found"
33
- ],
34
- top ? [
35
- true,
36
- "Project",
37
- `${top.framework.name}${top.details ? ` · ${top.details}` : ""}`
38
- ] : scan.unsupported[0] ? [
39
- false,
40
- "Project",
41
- `${scan.unsupported[0].framework.name} (not supported by this command)`
42
- ] : [
43
- false,
44
- "Project",
45
- "not detected"
46
- ],
47
- ...existing ? [
48
- [
49
- existing.sdkInstalled,
50
- "SDK",
51
- existing.sdkInstalled ? "installed" : "not installed"
52
- ],
53
- [
54
- existing.configureFound,
55
- "configure()",
56
- existing.configureFound ? "present" : "missing"
57
- ],
58
- [
59
- !!existing.apiKey,
60
- "API key",
61
- existing.apiKey ?? "none in project"
62
- ]
63
- ] : [],
64
- [
65
- !!session || !!apiKeyFromEnv(),
66
- "Logged in",
67
- session ? session.userEmail ?? session.orgName ?? "yes" : apiKeyFromEnv() ? "via SUPERWALL_API_KEY" : "no - run `superwall login`"
68
- ]
69
- ];
70
- if (ctx.json) {
71
- const checks = rows.map(([ok, label, value]) => ({
72
- ok,
73
- label,
74
- value
75
- }));
76
- return ctx.output.data({
77
- ok: checks.every((check) => check.ok),
78
- checks
79
- });
80
- }
81
- ui.report(rows.map(([ok, label, value]) => `${ok ? fg(THEME.primary, "✓") : fg(THEME.alert, "✗")} ${label.padEnd(13)} ${value}`).join("\n"));
82
- const failed = rows.filter(([ok]) => !ok).length;
83
- ui.outro(failed === 0 ? "All checks passed." : `${failed} of ${rows.length} checks need attention.`);
84
- }
85
- });
86
-
87
- //#endregion
88
- export { runDoctor };
@@ -1,152 +0,0 @@
1
- import { b as TELEMETRY_KEY, x as VERSION, y as TELEMETRY_HOST } from "./output-C4o2gJ1K.js";
2
- import { a as getAnonymousId, s as getOnboardedApp } from "./telemetry-DeA1mvnT.js";
3
- import "./update-B2fWIc4q.js";
4
- import { i as loadSession } from "./token-C0it-Xh7.js";
5
- import { t as defineCommand } from "./command-CMIz81Da.js";
6
- import "./ui-Dy0b-9L8.js";
7
- import { basename } from "node:path";
8
- import { arch, release } from "node:os";
9
- import { readFileSync } from "node:fs";
10
-
11
- //#region src/core/feedback.ts
12
- const FEEDBACK_KINDS = [
13
- "bug",
14
- "docs",
15
- "idea",
16
- "praise",
17
- "other"
18
- ];
19
- const MAX_FILES = 5;
20
- const MAX_FILE_CHARS = 2e4;
21
- function parseContext(pairs) {
22
- const out = {};
23
- for (const pair of pairs) {
24
- const at = pair.indexOf("=");
25
- if (at < 1) throw new Error(`--context expects key=value, got "${pair}"`);
26
- out[pair.slice(0, at).trim()] = pair.slice(at + 1).trim();
27
- }
28
- return out;
29
- }
30
- function linkedApp(cwd = process.cwd()) {
31
- const app = getOnboardedApp(cwd);
32
- return {
33
- projectId: app?.projectId,
34
- applicationId: app?.applicationId
35
- };
36
- }
37
- const AGENT_ENV = [
38
- ["CLAUDECODE", "claude-code"],
39
- ["CODEX_SANDBOX", "codex"],
40
- ["CURSOR_AGENT", "cursor"],
41
- ["GEMINI_CLI", "gemini-cli"]
42
- ];
43
- function detectAgent(env = process.env) {
44
- return AGENT_ENV.find(([key]) => env[key])?.[1];
45
- }
46
- /** Reads `--file` paths (`-` = stdin), keeping the base name and the tail of long logs. */
47
- function readAttachments(paths) {
48
- if (paths.length > MAX_FILES) throw new Error(`Attach at most ${MAX_FILES} files.`);
49
- return paths.map((path) => {
50
- const raw = readFileSync(path === "-" ? 0 : path, "utf8");
51
- const truncated = raw.length > MAX_FILE_CHARS;
52
- return {
53
- name: path === "-" ? "stdin" : basename(path),
54
- content: truncated ? raw.slice(-MAX_FILE_CHARS) : raw,
55
- truncated
56
- };
57
- });
58
- }
59
- function buildFeedbackEvent(feedback, via, distinctId, session) {
60
- return {
61
- api_key: TELEMETRY_KEY(),
62
- event: "feedback submitted",
63
- distinct_id: distinctId,
64
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
65
- properties: {
66
- $process_person_profile: false,
67
- title: feedback.title ?? null,
68
- message: feedback.message,
69
- kind: feedback.kind,
70
- command: feedback.command ?? null,
71
- project_id: feedback.projectId ?? null,
72
- application_id: feedback.applicationId ?? null,
73
- context: feedback.context,
74
- attachments: feedback.attachments,
75
- via,
76
- agent: feedback.agent ?? null,
77
- cli_version: VERSION,
78
- platform: process.platform,
79
- os_release: release(),
80
- arch: arch(),
81
- node_version: process.version,
82
- ci: process.env.CI === "true",
83
- email: session?.userEmail ?? null,
84
- org_id: session?.orgId ?? null,
85
- org_name: session?.orgName ?? null,
86
- auth_method: session?.authMethod ?? null
87
- }
88
- };
89
- }
90
- async function submitFeedback(feedback, via) {
91
- if (!TELEMETRY_KEY()) return false;
92
- const payload = buildFeedbackEvent(feedback, via, getAnonymousId(), loadSession());
93
- try {
94
- return (await fetch(`${TELEMETRY_HOST()}/capture/`, {
95
- method: "POST",
96
- headers: { "content-type": "application/json" },
97
- body: JSON.stringify(payload),
98
- signal: AbortSignal.timeout(8e3)
99
- })).ok;
100
- } catch {
101
- return false;
102
- }
103
- }
104
-
105
- //#endregion
106
- //#region src/commands/account/feedback.ts
107
- const runFeedback = defineCommand({
108
- name: "feedback",
109
- output: "both",
110
- async run(ctx) {
111
- const { ui, json, interactive, argv } = ctx;
112
- let message = argv.message?.trim();
113
- if (!message && interactive) {
114
- ui.intro("Superwall feedback");
115
- const answer = await ui.text({
116
- message: "What's your feedback on Superwall?",
117
- placeholder: "What worked, what didn't, what's missing...",
118
- validate: (v) => v?.trim() ? void 0 : "Required"
119
- });
120
- if (answer === null) return void ui.warn("Cancelled.");
121
- message = answer.trim();
122
- }
123
- if (!message) throw new Error("Usage: superwall feedback \"<message>\" [--title ...] [--kind bug] [--file log.txt]");
124
- const kind = argv.kind ?? "other";
125
- if (!FEEDBACK_KINDS.includes(kind)) throw new Error(`--kind must be one of: ${FEEDBACK_KINDS.join(", ")}`);
126
- const agent = argv.agent?.trim() || detectAgent();
127
- const attachments = readAttachments([].concat(argv.file ?? []).map(String).filter(Boolean));
128
- const context = parseContext([].concat(argv.context ?? []).map(String));
129
- const linked = linkedApp();
130
- const via = agent || !interactive ? "agent" : "human";
131
- const spin = interactive ? ui.spinner() : null;
132
- spin?.start("Sending your feedback");
133
- const ok = await submitFeedback({
134
- title: argv.title?.trim() || void 0,
135
- message,
136
- kind,
137
- command: argv.command?.trim() || void 0,
138
- agent,
139
- projectId: argv.project ?? linked.projectId,
140
- applicationId: argv.app ?? linked.applicationId,
141
- context,
142
- attachments
143
- }, via);
144
- spin?.stop(ok ? "Sent" : "Failed to send");
145
- if (json) return ctx.output.data({ submitted: ok });
146
- if (!ok) throw new Error("Couldn't send your feedback - check your connection and try again.");
147
- ui.success("Thank you! We've received your feedback and will read through it. Really appreciate you helping us make Superwall better.");
148
- }
149
- });
150
-
151
- //#endregion
152
- export { runFeedback };
@@ -1,32 +0,0 @@
1
- import { o as API_HOST } from "./output-C4o2gJ1K.js";
2
- import { i as loadSession, t as getOAuthAccessToken } from "./token-C0it-Xh7.js";
3
-
4
- //#region src/core/agent/hosted.ts
5
- const STATUS_PATH = "/v2/cli-agent/status";
6
- const ANTHROPIC_PROXY_PATH = "/v2/cli-agent/anthropic";
7
- function baseUrl() {
8
- return loadSession()?.host || API_HOST();
9
- }
10
- function getHostedAnthropicBaseUrl() {
11
- return `${baseUrl()}${ANTHROPIC_PROXY_PATH}`;
12
- }
13
- async function getHostedAuthToken() {
14
- return getOAuthAccessToken();
15
- }
16
- async function getHostedStatus() {
17
- const token = await getOAuthAccessToken();
18
- if (!token) return null;
19
- try {
20
- const res = await fetch(`${baseUrl()}${STATUS_PATH}`, { headers: {
21
- authorization: `Bearer ${token}`,
22
- accept: "application/json"
23
- } });
24
- if (!res.ok) return null;
25
- return await res.json();
26
- } catch {
27
- return null;
28
- }
29
- }
30
-
31
- //#endregion
32
- export { getHostedAuthToken as n, getHostedStatus as r, getHostedAnthropicBaseUrl as t };
@@ -1,284 +0,0 @@
1
- import { f as DASHBOARD_URL, t as blocks, x as VERSION } from "./output-C4o2gJ1K.js";
2
- import "./telemetry-DeA1mvnT.js";
3
- import "./update-B2fWIc4q.js";
4
- import { i as loadSession } from "./token-C0it-Xh7.js";
5
- import { t as defineCommand } from "./command-CMIz81Da.js";
6
- import { i as stripReport, n as ui } from "./ui-Dy0b-9L8.js";
7
- import "./skills-DPzlnfCK.js";
8
- import "./spawn-DSoTXy_j.js";
9
- import "./login-Do4wFuLv.js";
10
- import { t as scanProject } from "./scan-zKsddO72.js";
11
- import { t as detectDrivers } from "./drivers-Qx9LxmRN.js";
12
- import "./hosted-CXe9TrWx.js";
13
- import { t as detectExisting } from "./existing-AVEfZu2A.js";
14
- import "./spinner-TWa0hia6.js";
15
- import "./resources-Bf9O1JNM.js";
16
- import "./selection-CxZoX4NT.js";
17
- import "./org-sj7uyvp-.js";
18
- import "./bind-YrJvuRF9.js";
19
- import { _ as requireApi } from "./pipeline-BqzqZhX1.js";
20
- import { r as actionById } from "./actions-B7ym3oVS.js";
21
- import { r as performLoginWithUi } from "./app-DH6U8yuI.js";
22
- import { t as runAction } from "./run-DsVZ5snL.js";
23
- 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-studio-DOw-6ydc.js";
24
- import "./dev-DmB3XqaJ.js";
25
- import { n as saveReport } from "./reports-CfJqoava.js";
26
- import { t as detectBilling } from "./billing-CCYHdApx.js";
27
- import * as path from "node:path";
28
- import * as os$1 from "node:os";
29
- import * as fs from "node:fs";
30
- import { execFile } from "node:child_process";
31
-
32
- //#region src/core/paywalls/simulator.ts
33
- const simctl = (args) => new Promise((resolve$1) => {
34
- execFile("xcrun", ["simctl", ...args], { timeout: 15e3 }, (error, stdout) => {
35
- resolve$1(error ? void 0 : String(stdout));
36
- });
37
- });
38
- const simulator = {
39
- booted: async () => {
40
- if (os$1.platform() !== "darwin") return void 0;
41
- const output = await simctl([
42
- "list",
43
- "devices",
44
- "booted",
45
- "-j"
46
- ]);
47
- if (output === void 0) return void 0;
48
- try {
49
- const parsed = JSON.parse(output);
50
- for (const list of Object.values(parsed.devices ?? {})) {
51
- const device = list.find((entry) => entry.state === "Booted" && typeof entry.udid === "string");
52
- if (device?.udid) return {
53
- udid: device.udid,
54
- name: device.name ?? device.udid
55
- };
56
- }
57
- } catch {
58
- return;
59
- }
60
- },
61
- screenshot: async (udid) => {
62
- const file = path.join(os$1.tmpdir(), `superwall-original-${Date.now()}.png`);
63
- return await simctl([
64
- "io",
65
- udid,
66
- "screenshot",
67
- file
68
- ]) === void 0 ? void 0 : file;
69
- }
70
- };
71
- async function askForScreenshot(ui$1, runtime = simulator) {
72
- const booted = await runtime.booted();
73
- if (booted === void 0) return void 0;
74
- if (await ui$1.confirm({
75
- message: `Capture \`${booted.name}\` as the original? Show the screen in the simulator first.`,
76
- initial: true
77
- }) !== true) return void 0;
78
- const file = await runtime.screenshot(booted.udid);
79
- if (file === void 0) {
80
- ui$1.warn("The simulator screenshot failed — review against the running app instead.");
81
- return;
82
- }
83
- ui$1.step(`Captured \`${booted.name}\``);
84
- return file;
85
- }
86
-
87
- //#endregion
88
- //#region src/commands/workflow/migrate.ts
89
- const paywallIdOf = (value) => typeof value === "string" || typeof value === "number" ? String(value) : void 0;
90
- async function runPaywallMigrate(ctx, paywallId) {
91
- const { installDir, interactive, argv } = ctx;
92
- const existingDir = projectDirOf(installDir);
93
- let migration = existingDir === void 0 ? void 0 : migrationFor(existingDir, paywallId);
94
- if (argv.skill) {
95
- 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.`);
96
- process.stdout.write(`${buildMigrationCopyPrompt(migration)}\n`);
97
- return;
98
- }
99
- if (migration === void 0) {
100
- const api = await requireApi(interactive);
101
- const target = existingDir ?? path.join(installDir, "superwall");
102
- 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.`);
103
- migration = migrationFor(target, (await scaffoldFromPaywall(ui, api, {
104
- root: installDir,
105
- target,
106
- paywallId,
107
- newProject: existingDir === void 0
108
- })).id);
109
- if (migration === void 0) throw new Error(`Paywall ${paywallId} has no served document to rebuild from — nothing was recorded in superwall.lock.`);
110
- } else ui.info(`\`paywalls/${migration.surfaceId}\` was scaffolded from paywall ${paywallId} — picking up the rebuild.`);
111
- const choice = await offerMigration(ui, interactive, migration);
112
- const opening = choice === "agent" && await askStudio(ui, interactive, migration.surfaceId);
113
- ctx.output.render(blocks.nextSteps(migrationNextSteps(opening, path.relative(installDir, migration.superwallDir) || ".", paywallId, choice)), blocks.outro(`Done. ${DASHBOARD_URL}`));
114
- if (opening) await startStudio(migration.superwallDir, migration.surfaceId);
115
- }
116
- async function pickScreen(ctx) {
117
- const { installDir, interactive } = ctx;
118
- const candidates = findScreenCandidates(installDir);
119
- if (candidates.length === 0) throw new Error(`No screen-like files found under ${path.relative(process.cwd(), installDir) || "."} — pass one: \`superwall migrate --screen <path>\`.`);
120
- if (!interactive) {
121
- ui.list({ items: candidates.map((candidate) => ({
122
- label: candidate.path,
123
- meta: candidate.reason
124
- })) });
125
- ui.info("Pass one: `superwall migrate --screen <path>`.");
126
- return;
127
- }
128
- return await ui.select({
129
- message: "Which screen should ship through Superwall?",
130
- options: candidates.map((candidate) => ({
131
- value: candidate.path,
132
- label: candidate.path,
133
- hint: candidate.reason
134
- }))
135
- }) ?? void 0;
136
- }
137
- async function runScreenMigrate(ctx, screenArg) {
138
- const { installDir, interactive, argv } = ctx;
139
- const existingDir = projectDirOf(installDir);
140
- let file = screenArg === "" ? void 0 : path.resolve(screenArg);
141
- if (file === void 0) {
142
- if (argv.skill) throw new Error("`--skill` needs the screen: `superwall migrate --screen <path> --skill`.");
143
- const picked = await pickScreen(ctx);
144
- if (picked === void 0) return;
145
- file = path.resolve(installDir, picked);
146
- }
147
- const shown = path.relative(process.cwd(), file) || ".";
148
- let migration = existingDir === void 0 ? void 0 : screenMigrationFor(existingDir, file);
149
- if (argv.skill) {
150
- 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.`);
151
- process.stdout.write(`${buildMigrationCopyPrompt(migration)}\n`);
152
- return;
153
- }
154
- if (migration === void 0) {
155
- const target = existingDir ?? path.join(installDir, "superwall");
156
- 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.`);
157
- let screenshot = typeof argv.screenshot === "string" ? path.resolve(argv.screenshot) : void 0;
158
- if (screenshot !== void 0 && !fs.existsSync(screenshot)) throw new Error(`No screenshot at \`${argv.screenshot}\`.`);
159
- if (screenshot === void 0 && interactive) screenshot = await askForScreenshot(ui);
160
- scaffoldFromScreen(ui, {
161
- root: installDir,
162
- target,
163
- file,
164
- newProject: existingDir === void 0,
165
- screenshot
166
- });
167
- migration = screenMigrationFor(target, file);
168
- if (migration === void 0) throw new Error(`\`${shown}\` was not recorded in superwall.lock — nothing to rebuild.`);
169
- } else ui.info(`\`paywalls/${migration.surfaceId}\` was scaffolded from \`${shown}\` — picking up the rebuild.`);
170
- const choice = await offerMigration(ui, interactive, migration);
171
- const original = hasOriginal(migration);
172
- const opening = choice === "agent" && await askStudio(ui, interactive, migration.surfaceId, original);
173
- ctx.output.render(blocks.nextSteps(screenNextSteps({
174
- studioOpening: opening,
175
- superwallDir: path.relative(installDir, migration.superwallDir) || ".",
176
- screenPath: migrationSource(migration),
177
- placement: placementOfName(screenNameOf(file)),
178
- screenshot: original,
179
- choice
180
- })), blocks.outro(`Done. ${DASHBOARD_URL}`));
181
- if (opening) await startStudio(migration.superwallDir, migration.surfaceId, original);
182
- }
183
- const runMigrate = defineCommand({
184
- name: "migrate",
185
- auth: "optional",
186
- async run(ctx) {
187
- const { installDir, dryRun } = ctx;
188
- if (typeof ctx.argv.screen === "string") {
189
- if (!ctx.argv.skill) ui.intro(`Superwall migrate v${VERSION}`);
190
- await runScreenMigrate(ctx, ctx.argv.screen);
191
- return;
192
- }
193
- const paywallId = paywallIdOf(ctx.argv.paywall);
194
- if (paywallId !== void 0) {
195
- if (!ctx.argv.skill) ui.intro(`Superwall migrate v${VERSION}`);
196
- await runPaywallMigrate(ctx, paywallId);
197
- return;
198
- }
199
- ui.intro(`Superwall migrate v${VERSION}`);
200
- const drivers = await detectDrivers();
201
- if (drivers.length === 0) throw new Error("No coding agent found (Claude Code or Codex).");
202
- const driver = drivers[0].driver;
203
- const fallbackDrivers = drivers.slice(1).map((candidate) => candidate.driver);
204
- const app = (await scanProject(installDir)).apps[0];
205
- if (!app) throw new Error("No iOS / Android / Expo / React Native / Flutter app found here.");
206
- ui.info(`Detected \`${app.framework.name}\`${app.details ? ` · \`${app.details}\`` : ""}`);
207
- const billing = detectBilling(app);
208
- const provider = billing.revenueCat ? "RevenueCat" : billing.adapty ? "Adapty" : billing.qonversion ? "Qonversion" : null;
209
- if (!provider) {
210
- ui.warn("No RevenueCat / Adapty / Qonversion detected - nothing to migrate.");
211
- ui.info("Starting fresh? Run `superwall integrate` to set up directly.");
212
- ui.outro("");
213
- return;
214
- }
215
- ui.info(`Found \`${provider}\``);
216
- let intent = "full";
217
- if (ctx.interactive && !dryRun) {
218
- const sel = await ui.select({
219
- message: `Migrate from ${provider} - how far?`,
220
- options: [{
221
- value: "full",
222
- label: "Full migration",
223
- hint: `replace ${provider} with Superwall`
224
- }, {
225
- value: "paywalls",
226
- label: "Paywalls only",
227
- hint: `keep ${provider} for billing`
228
- }],
229
- initialValue: "full"
230
- });
231
- if (sel === null) return void ui.warn("Cancelled.");
232
- intent = sel;
233
- }
234
- let session = loadSession();
235
- if (session) ui.success(`Logged in as \`${session.userEmail ?? "you"}\`${session.orgName ? ` · \`${session.orgName}\`` : ""}`);
236
- else if (ctx.interactive && !dryRun) session = await performLoginWithUi();
237
- if (session?.apiKey) process.env.SUPERWALL_API_KEY = session.apiKey;
238
- const existing = detectExisting(app);
239
- const actionCtx = {
240
- app,
241
- apiKey: existing.apiKey ?? "",
242
- existing,
243
- billingProvider: provider,
244
- migrateIntent: intent
245
- };
246
- if (dryRun) {
247
- ui.note([
248
- `Provider: ${provider}`,
249
- `Mode: ${intent}`,
250
- `App: ${app.name} (${app.framework.name})`,
251
- `Path: ${app.path}`
252
- ].join("\n"), "Migration plan");
253
- ui.outro("Dry run - no changes made.");
254
- return;
255
- }
256
- const spin = ui.spinner();
257
- spin.start(`Migrating from ${provider}`);
258
- const result = await runAction({
259
- driver,
260
- fallbackDrivers,
261
- action: actionById["migrate"],
262
- ctx: actionCtx,
263
- onEvent: (e) => {
264
- if (e.type === "status") spin.message(e.text);
265
- }
266
- });
267
- if (result.ok) {
268
- spin.stop("Migration complete");
269
- if (result.finalText) {
270
- const plain = stripReport(result.finalText);
271
- saveReport(app.path, "migrate", plain);
272
- ui.report(plain);
273
- }
274
- } else {
275
- spin.stop("Migration stopped early");
276
- if (result.finalText) ui.report(stripReport(result.finalText).slice(0, 1500));
277
- throw new Error("Migration did not complete.");
278
- }
279
- 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}`));
280
- }
281
- });
282
-
283
- //#endregion
284
- export { runMigrate };
@@ -1,40 +0,0 @@
1
- import { n as ui } from "./ui-Dy0b-9L8.js";
2
- import { t as withSpinner } from "./spinner-TWa0hia6.js";
3
- import { E as titleCase, T as rowName, m as listOrganizations } from "./resources-Bf9O1JNM.js";
4
-
5
- //#region src/core/account/org.ts
6
- /**
7
- * Login is user-scoped and doesn't pick an org; org-scoped endpoints resolve
8
- * one here on first use and persist it to the session.
9
- */
10
- async function requireOrg(api, interactive) {
11
- if (api.org.id) return {
12
- id: api.org.id,
13
- name: api.org.name
14
- };
15
- const orgs = await withSpinner("Finding your organization", () => listOrganizations(api));
16
- if (orgs.length === 0) throw new Error("Your account has no organization yet - run `superwall login` to create one.");
17
- let picked = orgs.length === 1 ? orgs[0] : void 0;
18
- if (!picked) {
19
- if (!interactive) throw new Error("Your account has multiple organizations - run `superwall orgs use <id|name>` to pick one.");
20
- const sel = await ui.select({
21
- message: "Which organization?",
22
- options: orgs.map((o) => ({
23
- value: String(o.id),
24
- label: rowName(o),
25
- hint: titleCase(String(o.role ?? ""))
26
- }))
27
- });
28
- if (sel === null) throw new Error("An organization is required.");
29
- picked = orgs.find((o) => String(o.id) === sel);
30
- }
31
- const org = {
32
- id: String(picked.id),
33
- name: rowName(picked)
34
- };
35
- api.setOrg(org);
36
- return org;
37
- }
38
-
39
- //#endregion
40
- export { requireOrg as t };