@superwall/cli 1.6.2 → 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.
- package/README.md +281 -34
- package/dist/apple-CkKlHBZ9.js +195 -0
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-H7f6knyY.js → billing-XCZU_T46.js} +98 -28
- package/dist/{bind-BIzaGq8K.js → bind-drne__Ys.js} +38 -33
- package/dist/{build-B7BS1rF2.js → build-Gpdq5QXP.js} +20 -26
- package/dist/client-BZ1UbpXz.js +66 -0
- package/dist/client-DP6Rc0t_.js +176 -0
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/create-BBrtgUgS.js +969 -0
- package/dist/{create-CwnnNqv4.js → create-Cwc3SRWJ.js} +194 -168
- package/dist/create-Yvf2gStM.js +19 -0
- package/dist/doctor-C9ldpPFC.js +83 -0
- package/dist/{drivers-6RMOPIdn.js → drivers-DNrx4LWA.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28083 -801
- package/dist/environment-DF1qKlny.js +58 -0
- package/dist/{existing-DHpPn1y6.js → existing-78LWSsqS.js} +12 -6
- package/dist/held-Cy8Wl4D1.js +1112 -0
- package/dist/held-Ddw1XSsr.js +16 -0
- package/dist/input-vi0bou04.js +42 -0
- package/dist/{integrate-BR2LR-EK.js → integrate-DcJhpXy8.js} +277 -253
- package/dist/kinds-GFXB3sYu.js +11 -0
- package/dist/log-NVhVe_oe.js +62 -0
- package/dist/login-B2TsCE2H.js +53 -0
- package/dist/login-BoBe8Psl.js +16 -0
- package/dist/{login-Bhxgqwtm.js → login-D0lh3_JI.js} +144 -66
- package/dist/lookup-D-nmmAbw.js +71 -0
- package/dist/migrate-Cfec564E.js +274 -0
- package/dist/notification-url-YDbq6FMA.js +100 -0
- package/dist/{open-studio-BnVD6tJ9.js → open-Ba2vBl1_.js} +34 -43
- package/dist/org-D0g_q3mv.js +35 -0
- package/dist/output-Ggzq5_-t.js +122 -0
- package/dist/paths-DxSLdpOI.js +29 -0
- package/dist/playbook-DIeb7hne.js +53 -0
- package/dist/{asc-products-Dvcyef3_.js → products-DH_fK9tY.js} +6 -39
- package/dist/promote-COD4fYdz.js +91 -0
- package/dist/push-CncywhkQ.js +482 -0
- package/dist/push-CtD4FZQV.js +22 -0
- package/dist/registry-DSrosOYs.js +10228 -0
- package/dist/{reports-DqMs9xNR.js → reports-DdPq4blM.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
- package/dist/{run-D-NbZLpj.js → run-C9qg_QlC.js} +16 -22
- package/dist/scan-Cv5uOwVY.js +4 -0
- package/dist/{scan-BmAW413l.js → scan-DLrsrFS9.js} +48 -37
- package/dist/scope-V336uz8j.js +198 -0
- package/dist/screenshot-file-0UETadF8.js +16 -0
- package/dist/{selection-BGi6GyxC.js → selection-Rdw-ZUoG.js} +94 -51
- package/dist/send-BxD9yf6F.js +150 -0
- package/dist/{dev-CgGAb5Al.js → server-D0tGG8C4.js} +82 -87
- package/dist/server-z1LH94R_.js +22 -0
- package/dist/session-1AV_Bs_d.js +6 -0
- package/dist/session-CFAmMhem.js +40 -0
- package/dist/session-D_nEWKXT.js +768 -0
- package/dist/skills/animate-onboarding/SKILL.md +467 -0
- package/dist/skills/animate-onboarding/references/engine.md +494 -0
- package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/skills/animate-onboarding/references/performance.md +41 -0
- package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/skills/index.json +37 -0
- package/dist/skills/mobile-design/SKILL.md +447 -0
- package/dist/skills/mobile-design/references/responsive.md +162 -0
- package/dist/skills/onboarding-questions/SKILL.md +231 -0
- package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/skills/onboarding-questions/references/craft.md +142 -0
- package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/skills/superwall/SKILL.md +82 -9
- package/dist/skills/superwall/references/api.md +153 -37
- package/dist/skills/superwall/references/apple-setup.md +316 -0
- package/dist/skills/superwall/references/asc.md +74 -38
- package/dist/skills/superwall/references/data-analytics.md +55 -21
- package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
- package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
- package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
- package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
- package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
- package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
- package/dist/skills/superwall/workflows/placements/android.md +2 -2
- package/dist/skills/superwall/workflows/placements/expo.md +2 -2
- package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
- package/dist/skills/superwall/workflows/placements/ios.md +2 -2
- package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
- package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
- package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
- package/dist/skills/superwall/workflows/review/playbook.md +1 -1
- package/dist/skills/superwall-editor/SKILL.md +61 -0
- package/dist/skills/superwall-editor/references/cli.md +135 -0
- package/dist/skills/superwall-editor/references/design.md +51 -0
- package/dist/skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/skills/superwall-editor/references/workflow.md +65 -0
- package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/skills/superwall-framework/SKILL.md +78 -28
- package/dist/skills/superwall-framework/references/cli.md +58 -28
- package/dist/skills/superwall-framework/references/examples.md +4 -3
- package/dist/skills/superwall-framework/references/layout.md +30 -8
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
- package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
- package/dist/skills/wwdc/SKILL.md +22 -0
- package/dist/skills/wwdc/references/docs.md +52 -0
- package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/{skills-AxAf7bDB.js → skills-BvFOa4y6.js} +99 -122
- package/dist/skills-DMG4bpKk.js +14 -0
- package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
- package/dist/spinner-CneRK5rk.js +294 -0
- package/dist/storage-DYvmIOHa.d.ts +16 -0
- package/dist/storage-s2Dnz-yl.js +31 -0
- package/dist/storekit-DafAnGkM.js +16 -0
- package/dist/storekit-yY_kS2iR.js +47 -0
- package/dist/telemetry-DtG92m5O.js +56 -0
- package/dist/theme-DUsCh-Vd.js +25 -0
- package/dist/timing-BVxPrYq3.js +5 -0
- package/dist/{token-BGAVPSQc.js → token-DzRh7dI1.js} +6 -38
- package/dist/tools.d.ts +96 -0
- package/dist/tools.js +11178 -0
- package/dist/ui-D_qf3Gvw.js +53 -0
- package/dist/upgrade-Bt4Ouw1y.js +117 -0
- package/dist/upgrade-Cqy5orjb.js +7 -0
- package/package.json +10 -5
- package/dist/api-Dv3LyZ5m.js +0 -151
- package/dist/api-output-aJNw7Syy.js +0 -20
- package/dist/app-mJC5NDtW.js +0 -189
- package/dist/asa-D6H7Pjae.js +0 -1194
- package/dist/asc-xCin0akG.js +0 -539
- package/dist/auth-ZlLL-Gko.js +0 -139
- package/dist/billing-C8kBge_S.js +0 -80
- package/dist/command-3fGYyC8r.js +0 -301
- package/dist/dev-Dx99K183.js +0 -22
- package/dist/doctor-CyUvut31.js +0 -88
- package/dist/feedback-RKyGuQ8_.js +0 -152
- package/dist/hosted-BeGVAntr.js +0 -32
- package/dist/migrate-C-4ISELN.js +0 -284
- package/dist/org-CQduIOic.js +0 -40
- package/dist/output-C-4UKMot.js +0 -136
- package/dist/params-l3CrvRtR.js +0 -51
- package/dist/pipeline-CHX0Syre.js +0 -977
- package/dist/print-skill-BiZLdCKv.js +0 -74
- package/dist/promote-Pgpz-3xl.js +0 -88
- package/dist/publish-BPeuc3lq.js +0 -35
- package/dist/push-DcSQ4odB.js +0 -35
- package/dist/query-CWLaZkdm.js +0 -53
- package/dist/resource-jwASPCrw.js +0 -483
- package/dist/skills-FK5aDuNV.js +0 -64
- package/dist/spinner-DFctF_Jw.js +0 -18
- package/dist/storekit-CC4gnTI6.js +0 -29
- package/dist/telemetry-Ch9cCTI-.js +0 -169
- package/dist/ui-4gLyfrgl.js +0 -27737
- package/dist/update-DIXbL-H9.js +0 -59
- package/dist/upgrade-De7JMI1g.js +0 -72
- /package/dist/{devtools-8EgLo86w.js → devtools-ByZ6XYnn.js} +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import "./token-DzRh7dI1.js";
|
|
2
|
+
import { t as blocks } from "./output-Ggzq5_-t.js";
|
|
3
|
+
import { _ as VERSION, c as DASHBOARD_URL } from "./environment-DF1qKlny.js";
|
|
4
|
+
import { a as sessionOrgName, t as readSession } from "./storage-s2Dnz-yl.js";
|
|
5
|
+
import "./client-DP6Rc0t_.js";
|
|
6
|
+
import "./config-BO1Y87kV.js";
|
|
7
|
+
import "./telemetry-DtG92m5O.js";
|
|
8
|
+
import "./spawn-DmmmHIP-.js";
|
|
9
|
+
import "./spinner-CneRK5rk.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-DLrsrFS9.js";
|
|
14
|
+
import { t as detectExisting } from "./existing-78LWSsqS.js";
|
|
15
|
+
import "./paths-DxSLdpOI.js";
|
|
16
|
+
import "./resources-Dqr01Dep.js";
|
|
17
|
+
import "./lookup-D-nmmAbw.js";
|
|
18
|
+
import "./login-D0lh3_JI.js";
|
|
19
|
+
import "./skills-BvFOa4y6.js";
|
|
20
|
+
import "./selection-Rdw-ZUoG.js";
|
|
21
|
+
import { n as requireApi } from "./session-D_nEWKXT.js";
|
|
22
|
+
import { n as performLoginWithUi } from "./login-B2TsCE2H.js";
|
|
23
|
+
import { t as runAction } from "./run-C9qg_QlC.js";
|
|
24
|
+
import { t as detectDrivers } from "./drivers-DNrx4LWA.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-Ba2vBl1_.js";
|
|
26
|
+
import "./server-D0tGG8C4.js";
|
|
27
|
+
import { r as actionById, t as detectBilling } from "./billing-XCZU_T46.js";
|
|
28
|
+
import { n as writeReport } from "./reports-DdPq4blM.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-Cy8Wl4D1.js";
|
|
2
|
+
import { t as apiCall } from "./spinner-CneRK5rk.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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { i as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { t as
|
|
12
|
-
import * as path from "node:path";
|
|
1
|
+
import { b as isNonInteractive, c as DASHBOARD_URL } from "./environment-DF1qKlny.js";
|
|
2
|
+
import { t as ApiError } from "./client-DP6Rc0t_.js";
|
|
3
|
+
import { t as stripReport } from "./log-NVhVe_oe.js";
|
|
4
|
+
import { i as readPackageJson, r as allDeps } from "./scan-DLrsrFS9.js";
|
|
5
|
+
import { c as findPaywall, f as listApplications } from "./resources-Dqr01Dep.js";
|
|
6
|
+
import { d as readBundledSkill } from "./skills-BvFOa4y6.js";
|
|
7
|
+
import { C as readLock, O as writeOrigin, T as writeApp, x as isScreenOrigin } from "./selection-Rdw-ZUoG.js";
|
|
8
|
+
import { c as projectPackageName } from "./session-D_nEWKXT.js";
|
|
9
|
+
import { a as copyToClipboard, i as readPrompt, n as runWithDriverFallback } from "./run-C9qg_QlC.js";
|
|
10
|
+
import { t as detectDrivers } from "./drivers-DNrx4LWA.js";
|
|
11
|
+
import { t as runStudio } from "./server-D0tGG8C4.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)].
|
|
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)].
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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))
|
|
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
|
-
`${
|
|
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
|
|
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
|
|
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) =>
|
|
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:
|
|
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) =>
|
|
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:
|
|
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/
|
|
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
|
|
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-CneRK5rk.js";
|
|
2
|
+
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
3
|
+
import { A as listOrgGroups, C as titleCase, S as rowName, j as listOrganizations } from "./resources-Dqr01Dep.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 };
|