@superwall/cli 1.4.0 → 1.6.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 (103) hide show
  1. package/README.md +21 -5
  2. package/dist/{actions-EfP8phmb.js → actions-Dt35nIi8.js} +3 -2
  3. package/dist/{api-CEwXCCoC.js → api-BOR-uXZe.js} +9 -9
  4. package/dist/{app-D8mEVlQo.js → app-BU27SLPX.js} +9 -9
  5. package/dist/{asa-BFWehnTA.js → asa-2ykGnjaV.js} +11 -11
  6. package/dist/{asc-DJqQmtmR.js → asc-r3xmFT0L.js} +14 -14
  7. package/dist/{auth-CT2DWX8r.js → auth-BWZfguI8.js} +9 -9
  8. package/dist/auth.js +2 -2
  9. package/dist/{billing-BzEnVPD2.js → billing-BsQgXXYh.js} +1 -1
  10. package/dist/{bind-BZxVyt9P.js → bind-BSTAinn6.js} +5 -4
  11. package/dist/{command-DP96_gmP.js → command-DMoMn7uc.js} +39 -16
  12. package/dist/{create-Q8TqqjZt.js → create-CSo6XjSm.js} +118 -91
  13. package/dist/dev-B0MF6z3L.js +21 -0
  14. package/dist/{dev-DlCcwFu5.js → dev-CuXa3J4Z.js} +29 -24
  15. package/dist/{doctor-CJsjHpCZ.js → doctor-DXJaDqsx.js} +10 -10
  16. package/dist/{drivers-UT36AnOw.js → drivers-Cr252DOJ.js} +3 -3
  17. package/dist/entry.js +84 -50
  18. package/dist/{existing-Cak1WxWB.js → existing-Ckx_g7Be.js} +6 -3
  19. package/dist/{feedback-DDRzoqPx.js → feedback-Dt5yebMS.js} +6 -6
  20. package/dist/{hosted-CEH78QVn.js → hosted-Cjekn8oJ.js} +2 -2
  21. package/dist/{integrate-D8jyhDzk.js → integrate-DVqhvPVq.js} +25 -66
  22. package/dist/{login-kneYhhk0.js → login-Bjj8QvIN.js} +6 -6
  23. package/dist/migrate-qmvOtp3l.js +283 -0
  24. package/dist/open-studio-CpHqjovS.js +1299 -0
  25. package/dist/{org-Cg25bcsj.js → org-CV8c849b.js} +3 -3
  26. package/dist/{output-csAtR6kJ.js → output-CiELrN8w.js} +15 -2
  27. package/dist/{pipeline-DAeI9tHs.js → pipeline-DSCHL9KA.js} +482 -9
  28. package/dist/{print-skill-BHVPP9cX.js → print-skill-CaHRJ8xW.js} +7 -7
  29. package/dist/{promote-Boek5K2d.js → promote-UMTh8Q33.js} +17 -18
  30. package/dist/publish-DWX8S9yZ.js +34 -0
  31. package/dist/push-Dox4_5Dq.js +34 -0
  32. package/dist/{query-B8G6T8Ba.js → query-CnSsDZ7Q.js} +10 -10
  33. package/dist/reports-C0xHCLnt.js +27 -0
  34. package/dist/{resource-DjsWVka-.js → resource-5bgyyL9B.js} +15 -15
  35. package/dist/{resources-s64mBHaC.js → resources-Bf9O1JNM.js} +28 -2
  36. package/dist/{run-BtcQJCP8.js → run-BVeZWbXx.js} +39 -22
  37. package/dist/{scan-DJixvuHn.js → scan-CAObNRgc.js} +44 -4
  38. package/dist/skills/superwall/SKILL.md +146 -0
  39. package/dist/skills/superwall/references/api.md +275 -0
  40. package/dist/skills/superwall/references/asa.md +160 -0
  41. package/dist/skills/superwall/references/asc.md +96 -0
  42. package/dist/skills/superwall/references/dashboard-links.md +57 -0
  43. package/dist/skills/superwall/references/data-analytics.md +893 -0
  44. package/dist/skills/superwall/references/docs.md +51 -0
  45. package/dist/skills/superwall/references/sdk-integration.md +105 -0
  46. package/dist/skills/superwall/references/sdk-source.md +18 -0
  47. package/{skills/superwall-dashboard/SKILL.md → dist/skills/superwall/workflows/dashboard/playbook.md} +3 -9
  48. package/{skills/superwall-dashboard/references → dist/skills/superwall/workflows/dashboard}/setup.md +1 -3
  49. package/dist/skills/superwall/workflows/integrate/android.md +292 -0
  50. package/{skills/superwall-integrate/SKILL.md → dist/skills/superwall/workflows/integrate/playbook.md} +16 -11
  51. package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/adapty.md +4 -4
  52. package/{skills/superwall-migrate/SKILL.md → dist/skills/superwall/workflows/migrate/playbook.md} +4 -10
  53. package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/qonversion.md +4 -4
  54. package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/revenuecat.md +4 -4
  55. package/dist/skills/superwall/workflows/placements/android.md +175 -0
  56. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/expo.md +1 -1
  57. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/flutter.md +1 -1
  58. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/ios.md +1 -1
  59. package/{skills/superwall-placements/SKILL.md → dist/skills/superwall/workflows/placements/playbook.md} +6 -10
  60. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/react-native.md +2 -2
  61. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/strategy.md +4 -3
  62. package/dist/skills/superwall/workflows/review/android.md +120 -0
  63. package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/expo.md +1 -1
  64. package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/flutter.md +1 -1
  65. package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/ios.md +1 -1
  66. package/{skills/superwall-review/SKILL.md → dist/skills/superwall/workflows/review/playbook.md} +2 -7
  67. package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/react-native.md +1 -1
  68. package/dist/skills/superwall-framework/SKILL.md +253 -0
  69. package/dist/skills/superwall-framework/references/cli.md +340 -0
  70. package/dist/skills/superwall-framework/references/examples.md +123 -0
  71. package/dist/skills/superwall-framework/references/layout.md +295 -0
  72. package/dist/skills/superwall-framework/references/migrate-from-editor.md +208 -0
  73. package/dist/skills/superwall-framework/references/migrate-from-native.md +193 -0
  74. package/dist/skills/superwall-framework/references/mobile-design.md +371 -0
  75. package/dist/skills/superwall-framework/references/native/android.md +83 -0
  76. package/dist/skills/superwall-framework/references/native/flutter.md +65 -0
  77. package/dist/skills/superwall-framework/references/native/ios.md +77 -0
  78. package/dist/skills/superwall-framework/references/native/react-native.md +67 -0
  79. package/dist/skills/superwall-framework/references/responsive.md +162 -0
  80. package/dist/{skills-CRG1xk0G.js → skills-Cu41i-Az.js} +12 -12
  81. package/dist/{skills-CODut1Hn.js → skills-grTDuHlc.js} +134 -36
  82. package/dist/{spinner-B9dT3DBY.js → spinner-DFctF_Jw.js} +1 -1
  83. package/dist/{telemetry-BtkMdT-5.js → telemetry-BuCbmoux.js} +3 -3
  84. package/dist/{token-hM7V1KMG.js → token-mju3Q-vc.js} +3 -3
  85. package/dist/{ui-Lqt_zFOr.js → ui-4gLyfrgl.js} +76 -46
  86. package/dist/{update-CeylIjx5.js → update-DnGfpCD7.js} +2 -2
  87. package/dist/{upgrade-DRqUfCBT.js → upgrade-PMoj3yqJ.js} +6 -6
  88. package/package.json +8 -7
  89. package/prompts/actions/paywall-migrate.xml +24 -0
  90. package/prompts/actions/screen-migrate.xml +26 -0
  91. package/dist/git-ZwA3Mx8m.js +0 -433
  92. package/dist/migrate-D_x1oyTk.js +0 -114
  93. package/dist/publish-C-zEUnO9.js +0 -35
  94. package/dist/push-DUDQG-EO.js +0 -35
  95. package/skills/README.md +0 -118
  96. /package/dist/{api-output-D9ggXQIr.js → api-output-CEhN-U_N.js} +0 -0
  97. /package/dist/{asc-products-C6MvSy8H.js → asc-products-1e1DoGeL.js} +0 -0
  98. /package/dist/{params-B1zeElGa.js → params-BxgTuCzr.js} +0 -0
  99. /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/expo.md +0 -0
  100. /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/flutter.md +0 -0
  101. /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/ios.md +0 -0
  102. /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/react-native.md +0 -0
  103. /package/dist/{storekit-DPonXSwe.js → storekit-Dlpbq5Wv.js} +0 -0
@@ -1,13 +1,13 @@
1
- import { a as API_HOST, c as CLI_CLIENT_ID, d as Integration, f as OAUTH_SCOPE, s as AUTH_HOST } from "./output-csAtR6kJ.js";
2
- import { c as getOnboardedOrg, l as getOnboardingIdempotencyKey, m as setOnboardedOrg, p as setOnboardedApp } from "./telemetry-BtkMdT-5.js";
3
- import { a as saveSession } from "./token-hM7V1KMG.js";
4
- import { n as ui } from "./ui-Lqt_zFOr.js";
1
+ import { c as AUTH_HOST, d as CLI_CLIENT_ID, h as OAUTH_SCOPE, m as Integration, o as API_HOST } from "./output-CiELrN8w.js";
2
+ import { c as getOnboardedOrg, l as getOnboardingIdempotencyKey, m as setOnboardedOrg, p as setOnboardedApp } from "./telemetry-BuCbmoux.js";
3
+ import { a as saveSession } from "./token-mju3Q-vc.js";
4
+ import { n as ui } from "./ui-4gLyfrgl.js";
5
5
  import { spawn } from "node:child_process";
6
6
 
7
7
  //#region src/core/account/onboarding.ts
8
8
  function onboardingHooks(app) {
9
9
  const ref = { current: null };
10
- const platform = app?.integration === Integration.swift ? "ios" : app?.integration === Integration.web ? "web" : void 0;
10
+ const platform = app?.integration === Integration.swift ? "ios" : app?.integration === Integration.android ? "android" : app?.integration === Integration.web ? "web" : void 0;
11
11
  return {
12
12
  onOnboard: async () => {
13
13
  let onboardApp;
@@ -288,4 +288,4 @@ async function postJson(url, accessToken, body) {
288
288
  }
289
289
 
290
290
  //#endregion
291
- export { performLogin as n, onboardingHooks as r, loginWithApiKey as t };
291
+ export { onboardingHooks as i, performLogin as n, openBrowser as r, loginWithApiKey as t };
@@ -0,0 +1,283 @@
1
+ import { f as DASHBOARD_URL, t as blocks, y as VERSION } from "./output-CiELrN8w.js";
2
+ import "./telemetry-BuCbmoux.js";
3
+ import "./update-DnGfpCD7.js";
4
+ import { i as loadSession } from "./token-mju3Q-vc.js";
5
+ import { t as defineCommand } from "./command-DMoMn7uc.js";
6
+ import { i as stripReport, n as ui } from "./ui-4gLyfrgl.js";
7
+ import "./skills-grTDuHlc.js";
8
+ import "./spawn-DSoTXy_j.js";
9
+ import "./login-Bjj8QvIN.js";
10
+ import { t as scanProject } from "./scan-CAObNRgc.js";
11
+ import { t as detectDrivers } from "./drivers-Cr252DOJ.js";
12
+ import "./hosted-Cjekn8oJ.js";
13
+ import { t as detectExisting } from "./existing-Ckx_g7Be.js";
14
+ import "./spinner-DFctF_Jw.js";
15
+ import "./resources-Bf9O1JNM.js";
16
+ import "./org-CV8c849b.js";
17
+ import "./bind-BSTAinn6.js";
18
+ import { A as requireApi } from "./pipeline-DSCHL9KA.js";
19
+ import { r as actionById } from "./actions-Dt35nIi8.js";
20
+ import { r as performLoginWithUi } from "./app-BU27SLPX.js";
21
+ import { t as runAction } from "./run-BVeZWbXx.js";
22
+ 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-CpHqjovS.js";
23
+ import "./dev-CuXa3J4Z.js";
24
+ import { n as saveReport } from "./reports-C0xHCLnt.js";
25
+ import { t as detectBilling } from "./billing-BsQgXXYh.js";
26
+ import * as path from "node:path";
27
+ import * as os$1 from "node:os";
28
+ import * as fs from "node:fs";
29
+ import { execFile } from "node:child_process";
30
+
31
+ //#region src/core/paywalls/simulator.ts
32
+ const simctl = (args) => new Promise((resolve$1) => {
33
+ execFile("xcrun", ["simctl", ...args], { timeout: 15e3 }, (error, stdout) => {
34
+ resolve$1(error ? void 0 : String(stdout));
35
+ });
36
+ });
37
+ const simulator = {
38
+ booted: async () => {
39
+ if (os$1.platform() !== "darwin") return void 0;
40
+ const output = await simctl([
41
+ "list",
42
+ "devices",
43
+ "booted",
44
+ "-j"
45
+ ]);
46
+ if (output === void 0) return void 0;
47
+ try {
48
+ const parsed = JSON.parse(output);
49
+ for (const list of Object.values(parsed.devices ?? {})) {
50
+ const device = list.find((entry) => entry.state === "Booted" && typeof entry.udid === "string");
51
+ if (device?.udid) return {
52
+ udid: device.udid,
53
+ name: device.name ?? device.udid
54
+ };
55
+ }
56
+ } catch {
57
+ return;
58
+ }
59
+ },
60
+ screenshot: async (udid) => {
61
+ const file = path.join(os$1.tmpdir(), `superwall-original-${Date.now()}.png`);
62
+ return await simctl([
63
+ "io",
64
+ udid,
65
+ "screenshot",
66
+ file
67
+ ]) === void 0 ? void 0 : file;
68
+ }
69
+ };
70
+ async function askForScreenshot(ui$1, runtime = simulator) {
71
+ const booted = await runtime.booted();
72
+ if (booted === void 0) return void 0;
73
+ if (await ui$1.confirm({
74
+ message: `Capture \`${booted.name}\` as the original? Show the screen in the simulator first.`,
75
+ initial: true
76
+ }) !== true) return void 0;
77
+ const file = await runtime.screenshot(booted.udid);
78
+ if (file === void 0) {
79
+ ui$1.warn("The simulator screenshot failed — review against the running app instead.");
80
+ return;
81
+ }
82
+ ui$1.step(`Captured \`${booted.name}\``);
83
+ return file;
84
+ }
85
+
86
+ //#endregion
87
+ //#region src/commands/workflow/migrate.ts
88
+ const paywallIdOf = (value) => typeof value === "string" || typeof value === "number" ? String(value) : void 0;
89
+ async function runPaywallMigrate(ctx, paywallId) {
90
+ const { installDir, interactive, argv } = ctx;
91
+ const existingDir = projectDirOf(installDir);
92
+ let migration = existingDir === void 0 ? void 0 : migrationFor(existingDir, paywallId);
93
+ if (argv.skill) {
94
+ 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.`);
95
+ process.stdout.write(`${buildMigrationCopyPrompt(migration)}\n`);
96
+ return;
97
+ }
98
+ if (migration === void 0) {
99
+ const api = await requireApi(interactive);
100
+ const target = existingDir ?? path.join(installDir, "superwall");
101
+ 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.`);
102
+ migration = migrationFor(target, (await scaffoldFromPaywall(ui, api, {
103
+ root: installDir,
104
+ target,
105
+ paywallId,
106
+ newProject: existingDir === void 0
107
+ })).id);
108
+ if (migration === void 0) throw new Error(`Paywall ${paywallId} has no served document to rebuild from — nothing was recorded in superwall.lock.`);
109
+ } else ui.info(`\`paywalls/${migration.surfaceId}\` was scaffolded from paywall ${paywallId} — picking up the rebuild.`);
110
+ const choice = await offerMigration(ui, interactive, migration);
111
+ const opening = choice === "agent" && await askStudio(ui, interactive, migration.surfaceId);
112
+ ctx.output.render(blocks.nextSteps(migrationNextSteps(opening, path.relative(installDir, migration.superwallDir) || ".", paywallId, choice)), blocks.outro(`Done. ${DASHBOARD_URL}`));
113
+ if (opening) await startStudio(migration.superwallDir, migration.surfaceId);
114
+ }
115
+ async function pickScreen(ctx) {
116
+ const { installDir, interactive } = ctx;
117
+ const candidates = findScreenCandidates(installDir);
118
+ if (candidates.length === 0) throw new Error(`No screen-like files found under ${path.relative(process.cwd(), installDir) || "."} — pass one: \`superwall migrate --screen <path>\`.`);
119
+ if (!interactive) {
120
+ ui.list({ items: candidates.map((candidate) => ({
121
+ label: candidate.path,
122
+ meta: candidate.reason
123
+ })) });
124
+ ui.info("Pass one: `superwall migrate --screen <path>`.");
125
+ return;
126
+ }
127
+ return await ui.select({
128
+ message: "Which screen should ship through Superwall?",
129
+ options: candidates.map((candidate) => ({
130
+ value: candidate.path,
131
+ label: candidate.path,
132
+ hint: candidate.reason
133
+ }))
134
+ }) ?? void 0;
135
+ }
136
+ async function runScreenMigrate(ctx, screenArg) {
137
+ const { installDir, interactive, argv } = ctx;
138
+ const existingDir = projectDirOf(installDir);
139
+ let file = screenArg === "" ? void 0 : path.resolve(screenArg);
140
+ if (file === void 0) {
141
+ if (argv.skill) throw new Error("`--skill` needs the screen: `superwall migrate --screen <path> --skill`.");
142
+ const picked = await pickScreen(ctx);
143
+ if (picked === void 0) return;
144
+ file = path.resolve(installDir, picked);
145
+ }
146
+ const shown = path.relative(process.cwd(), file) || ".";
147
+ let migration = existingDir === void 0 ? void 0 : screenMigrationFor(existingDir, file);
148
+ if (argv.skill) {
149
+ 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.`);
150
+ process.stdout.write(`${buildMigrationCopyPrompt(migration)}\n`);
151
+ return;
152
+ }
153
+ if (migration === void 0) {
154
+ const target = existingDir ?? path.join(installDir, "superwall");
155
+ 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.`);
156
+ let screenshot = typeof argv.screenshot === "string" ? path.resolve(argv.screenshot) : void 0;
157
+ if (screenshot !== void 0 && !fs.existsSync(screenshot)) throw new Error(`No screenshot at \`${argv.screenshot}\`.`);
158
+ if (screenshot === void 0 && interactive) screenshot = await askForScreenshot(ui);
159
+ scaffoldFromScreen(ui, {
160
+ root: installDir,
161
+ target,
162
+ file,
163
+ newProject: existingDir === void 0,
164
+ screenshot
165
+ });
166
+ migration = screenMigrationFor(target, file);
167
+ if (migration === void 0) throw new Error(`\`${shown}\` was not recorded in superwall.lock — nothing to rebuild.`);
168
+ } else ui.info(`\`paywalls/${migration.surfaceId}\` was scaffolded from \`${shown}\` — picking up the rebuild.`);
169
+ const choice = await offerMigration(ui, interactive, migration);
170
+ const original = hasOriginal(migration);
171
+ const opening = choice === "agent" && await askStudio(ui, interactive, migration.surfaceId, original);
172
+ ctx.output.render(blocks.nextSteps(screenNextSteps({
173
+ studioOpening: opening,
174
+ superwallDir: path.relative(installDir, migration.superwallDir) || ".",
175
+ screenPath: migrationSource(migration),
176
+ placement: placementOfName(screenNameOf(file)),
177
+ screenshot: original,
178
+ choice
179
+ })), blocks.outro(`Done. ${DASHBOARD_URL}`));
180
+ if (opening) await startStudio(migration.superwallDir, migration.surfaceId, original);
181
+ }
182
+ const runMigrate = defineCommand({
183
+ name: "migrate",
184
+ auth: "optional",
185
+ async run(ctx) {
186
+ const { installDir, dryRun } = ctx;
187
+ if (typeof ctx.argv.screen === "string") {
188
+ if (!ctx.argv.skill) ui.intro(`Superwall migrate v${VERSION}`);
189
+ await runScreenMigrate(ctx, ctx.argv.screen);
190
+ return;
191
+ }
192
+ const paywallId = paywallIdOf(ctx.argv.paywall);
193
+ if (paywallId !== void 0) {
194
+ if (!ctx.argv.skill) ui.intro(`Superwall migrate v${VERSION}`);
195
+ await runPaywallMigrate(ctx, paywallId);
196
+ return;
197
+ }
198
+ ui.intro(`Superwall migrate v${VERSION}`);
199
+ const drivers = await detectDrivers();
200
+ if (drivers.length === 0) throw new Error("No coding agent found (Claude Code or Codex).");
201
+ const driver = drivers[0].driver;
202
+ const fallbackDrivers = drivers.slice(1).map((candidate) => candidate.driver);
203
+ const app = (await scanProject(installDir)).apps[0];
204
+ if (!app) throw new Error("No iOS / Android / Expo / React Native / Flutter app found here.");
205
+ ui.info(`Detected \`${app.framework.name}\`${app.details ? ` · \`${app.details}\`` : ""}`);
206
+ const billing = detectBilling(app);
207
+ const provider = billing.revenueCat ? "RevenueCat" : billing.adapty ? "Adapty" : billing.qonversion ? "Qonversion" : null;
208
+ if (!provider) {
209
+ ui.warn("No RevenueCat / Adapty / Qonversion detected - nothing to migrate.");
210
+ ui.info("Starting fresh? Run `superwall integrate` to set up directly.");
211
+ ui.outro("");
212
+ return;
213
+ }
214
+ ui.info(`Found \`${provider}\``);
215
+ let intent = "full";
216
+ if (ctx.interactive && !dryRun) {
217
+ const sel = await ui.select({
218
+ message: `Migrate from ${provider} - how far?`,
219
+ options: [{
220
+ value: "full",
221
+ label: "Full migration",
222
+ hint: `replace ${provider} with Superwall`
223
+ }, {
224
+ value: "paywalls",
225
+ label: "Paywalls only",
226
+ hint: `keep ${provider} for billing`
227
+ }],
228
+ initialValue: "full"
229
+ });
230
+ if (sel === null) return void ui.warn("Cancelled.");
231
+ intent = sel;
232
+ }
233
+ let session = loadSession();
234
+ if (session) ui.success(`Logged in as \`${session.userEmail ?? "you"}\`${session.orgName ? ` · \`${session.orgName}\`` : ""}`);
235
+ else if (ctx.interactive && !dryRun) session = await performLoginWithUi();
236
+ if (session?.apiKey) process.env.SUPERWALL_API_KEY = session.apiKey;
237
+ const existing = detectExisting(app);
238
+ const actionCtx = {
239
+ app,
240
+ apiKey: existing.apiKey ?? "",
241
+ existing,
242
+ billingProvider: provider,
243
+ migrateIntent: intent
244
+ };
245
+ if (dryRun) {
246
+ ui.note([
247
+ `Provider: ${provider}`,
248
+ `Mode: ${intent}`,
249
+ `App: ${app.name} (${app.framework.name})`,
250
+ `Path: ${app.path}`
251
+ ].join("\n"), "Migration plan");
252
+ ui.outro("Dry run - no changes made.");
253
+ return;
254
+ }
255
+ const spin = ui.spinner();
256
+ spin.start(`Migrating from ${provider}`);
257
+ const result = await runAction({
258
+ driver,
259
+ fallbackDrivers,
260
+ action: actionById["migrate"],
261
+ ctx: actionCtx,
262
+ onEvent: (e) => {
263
+ if (e.type === "status") spin.message(e.text);
264
+ }
265
+ });
266
+ if (result.ok) {
267
+ spin.stop("Migration complete");
268
+ if (result.finalText) {
269
+ const plain = stripReport(result.finalText);
270
+ saveReport(app.path, "migrate", plain);
271
+ ui.report(plain);
272
+ }
273
+ } else {
274
+ spin.stop("Migration stopped early");
275
+ if (result.finalText) ui.report(stripReport(result.finalText).slice(0, 1500));
276
+ throw new Error("Migration did not complete.");
277
+ }
278
+ 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}`));
279
+ }
280
+ });
281
+
282
+ //#endregion
283
+ export { runMigrate };