@superwall/cli 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +201 -0
  3. package/dist/actions-MB-eBY64.js +140 -0
  4. package/dist/api-BF7-toqM.js +151 -0
  5. package/dist/api-output-B5hh0q4V.js +20 -0
  6. package/dist/app-K6j9Es7h.js +189 -0
  7. package/dist/asc-CArSwo5D.js +539 -0
  8. package/dist/asc-products-YQ6Oc6YO.js +93 -0
  9. package/dist/auth-CY2cO_NF.js +139 -0
  10. package/dist/auth.d.ts +30 -0
  11. package/dist/auth.js +4 -0
  12. package/dist/billing-DWyfEQ6l.js +80 -0
  13. package/dist/bind-hslFhcTR.js +213 -0
  14. package/dist/chunk-DQxbwPpZ.js +30 -0
  15. package/dist/command-Kwx4ekbo.js +283 -0
  16. package/dist/create-Bbi8BOO1.js +410 -0
  17. package/dist/dev-D0lQDCQI.js +397 -0
  18. package/dist/devtools-8EgLo86w.js +3638 -0
  19. package/dist/doctor-ByeRdMcl.js +88 -0
  20. package/dist/drivers-DVAZgone.js +413 -0
  21. package/dist/entry.d.ts +9 -0
  22. package/dist/entry.js +495 -0
  23. package/dist/existing-CcJrIIAU.js +88 -0
  24. package/dist/feedback-Z0Wk7VC5.js +73 -0
  25. package/dist/git-3OX9u3xE.js +433 -0
  26. package/dist/hosted-CHwaUqLd.js +32 -0
  27. package/dist/integrate-DqOAqK7J.js +863 -0
  28. package/dist/json-C3hPIMkI.js +7 -0
  29. package/dist/login-Dr8UN_Gx.js +290 -0
  30. package/dist/migrate-D92bJTg6.js +114 -0
  31. package/dist/org-B2gy9Pmu.js +40 -0
  32. package/dist/params-Bvq0iqQK.js +52 -0
  33. package/dist/pipeline-CHHIg6BU.js +1056 -0
  34. package/dist/print-skill-BnZAk7dV.js +74 -0
  35. package/dist/promote-CRe9170G.js +88 -0
  36. package/dist/publish-DsODvrOD.js +35 -0
  37. package/dist/push-BDkZUC0v.js +35 -0
  38. package/dist/query-DIllrSnk.js +53 -0
  39. package/dist/resource-CdP1MDla.js +483 -0
  40. package/dist/resources-CVrWwA1K.js +233 -0
  41. package/dist/run-cGGBUMs5.js +89 -0
  42. package/dist/scan-BQexuUPO.js +236 -0
  43. package/dist/skills-DhuUs28u.js +64 -0
  44. package/dist/skills-xrfXt9u0.js +205 -0
  45. package/dist/spawn-DSoTXy_j.js +69 -0
  46. package/dist/spinner-gOxIMz-V.js +18 -0
  47. package/dist/storekit-Ddvs4Ynw.js +29 -0
  48. package/dist/telemetry-CcfrtXdf.js +204 -0
  49. package/dist/token-DHRH8cxi.js +102 -0
  50. package/dist/ui-C4ncRJqd.js +27703 -0
  51. package/dist/update-BiVeR024.js +137 -0
  52. package/dist/upgrade-DYWspApv.js +72 -0
  53. package/package.json +87 -0
  54. package/prompts/actions/dashboard-setup.xml +10 -0
  55. package/prompts/actions/integrate.xml +5 -0
  56. package/prompts/actions/migrate.xml +11 -0
  57. package/prompts/actions/placements-implement.xml +20 -0
  58. package/prompts/actions/placements-review.xml +18 -0
  59. package/prompts/actions/review-fix.xml +18 -0
  60. package/prompts/actions/review.xml +18 -0
  61. package/prompts/commandments.xml +17 -0
  62. package/prompts/context.xml +9 -0
  63. package/skills/README.md +118 -0
  64. package/skills/superwall-dashboard/SKILL.md +81 -0
  65. package/skills/superwall-dashboard/references/setup.md +101 -0
  66. package/skills/superwall-integrate/SKILL.md +76 -0
  67. package/skills/superwall-integrate/references/expo.md +269 -0
  68. package/skills/superwall-integrate/references/flutter.md +285 -0
  69. package/skills/superwall-integrate/references/ios.md +314 -0
  70. package/skills/superwall-integrate/references/react-native.md +245 -0
  71. package/skills/superwall-migrate/SKILL.md +83 -0
  72. package/skills/superwall-migrate/references/adapty.md +229 -0
  73. package/skills/superwall-migrate/references/qonversion.md +227 -0
  74. package/skills/superwall-migrate/references/revenuecat.md +414 -0
  75. package/skills/superwall-placements/SKILL.md +73 -0
  76. package/skills/superwall-placements/references/expo.md +161 -0
  77. package/skills/superwall-placements/references/flutter.md +139 -0
  78. package/skills/superwall-placements/references/ios.md +165 -0
  79. package/skills/superwall-placements/references/react-native.md +145 -0
  80. package/skills/superwall-placements/references/strategy.md +221 -0
  81. package/skills/superwall-review/SKILL.md +75 -0
  82. package/skills/superwall-review/references/expo.md +100 -0
  83. package/skills/superwall-review/references/flutter.md +99 -0
  84. package/skills/superwall-review/references/ios.md +108 -0
  85. package/skills/superwall-review/references/react-native.md +100 -0
@@ -0,0 +1,189 @@
1
+ import { i as loadSession, r as clearSession } from "./token-DHRH8cxi.js";
2
+ import { r as SuperwallApi } from "./command-Kwx4ekbo.js";
3
+ import { n as ui } from "./ui-C4ncRJqd.js";
4
+ import { n as performLogin, r as onboardingHooks } from "./login-Dr8UN_Gx.js";
5
+ import { i as SUPPORTED_LABEL, t as scanProject } from "./scan-BQexuUPO.js";
6
+ import { r as getHostedStatus } from "./hosted-CHwaUqLd.js";
7
+ import { t as withSpinner } from "./spinner-gOxIMz-V.js";
8
+ import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-hslFhcTR.js";
9
+ import { t as ACTIONS } from "./actions-MB-eBY64.js";
10
+
11
+ //#region src/commands/workflow/integrate/app.ts
12
+ async function performLoginWithUi(app, onProvisioned) {
13
+ const spin = ui.spinner();
14
+ const hooks = onboardingHooks(app);
15
+ try {
16
+ const session = await performLogin({
17
+ onVerify: ({ url, userCode }) => {
18
+ ui.info(`Approve this login in your browser · code \`${userCode}\`\n${url}`);
19
+ spin.start("Waiting for you to approve in the browser");
20
+ },
21
+ onStatus: (message) => spin.message(message),
22
+ onOnboard: async () => {
23
+ const setup = await hooks.onOnboard();
24
+ if (setup) spin.start("Creating your account");
25
+ return setup;
26
+ },
27
+ onProvisioned: (result) => {
28
+ hooks.onProvisioned(result);
29
+ onProvisioned?.(result);
30
+ }
31
+ });
32
+ spin.stop(`Logged in as \`${session.userEmail ?? "you"}\``);
33
+ return session;
34
+ } catch (error) {
35
+ spin.stop("Login failed");
36
+ ui.warn(error.message);
37
+ return null;
38
+ }
39
+ }
40
+ /**
41
+ * The project has an API key that matches nothing in the logged-in org - most
42
+ * likely the wrong account. Offer to re-login, rebind, or skip; returns the
43
+ * resolved scope when a fix works.
44
+ */
45
+ async function recoverUnmatchedScope(app, apiKey) {
46
+ for (;;) {
47
+ const orgName = loadSession()?.orgName;
48
+ const orgLabel = orgName ? `\`${orgName}\`` : "your organization";
49
+ ui.error(`This project's API key (\`${apiKey}\`) doesn't match any app in ${orgLabel}. You might be logged in to the wrong account.`);
50
+ const choice = await ui.select({
51
+ message: "How do you want to fix it?",
52
+ options: [
53
+ {
54
+ value: "relogin",
55
+ label: "Log in with a different account"
56
+ },
57
+ {
58
+ value: "bind",
59
+ label: `Connect this app to ${orgLabel} instead`,
60
+ hint: "creates or picks an app and issues a new API key"
61
+ },
62
+ {
63
+ value: "skip",
64
+ label: "Skip for now"
65
+ }
66
+ ]
67
+ });
68
+ if (choice === null || choice === "skip") return null;
69
+ if (choice === "relogin") {
70
+ clearSession();
71
+ if (!await performLoginWithUi(app)) return null;
72
+ const resolved = await withSpinner("Finding this app in Superwall", () => resolveScopeFromKey(SuperwallApi.fromSession(), apiKey).catch(() => null));
73
+ if (resolved) {
74
+ ui.success(`Found \`${resolved.appName ?? app.name}\``);
75
+ return {
76
+ scope: {
77
+ projectId: resolved.projectId,
78
+ applicationId: resolved.applicationId,
79
+ appName: resolved.appName ?? app.name
80
+ },
81
+ bundleId: resolved.bundleId
82
+ };
83
+ }
84
+ continue;
85
+ }
86
+ try {
87
+ const bound = await resolveAppBinding(SuperwallApi.fromSession(), {
88
+ platform: platformForIntegration(app.integration),
89
+ appName: app.name
90
+ });
91
+ if (!bound) continue;
92
+ ui.note(`Your code still uses \`${apiKey}\`.\nReplace it with \`${bound.apiKey}\` so the app talks to ${orgLabel}.`, "Swap the API key");
93
+ return {
94
+ scope: {
95
+ projectId: bound.projectId,
96
+ applicationId: bound.applicationId,
97
+ appName: app.name
98
+ },
99
+ bundleId: bound.app.bundle_id
100
+ };
101
+ } catch (error) {
102
+ ui.warn(error.message);
103
+ }
104
+ }
105
+ }
106
+ async function ensureAgentDriverReady(driver, ensureLogin, dryRun) {
107
+ if (driver.id !== "superwall" || dryRun) return true;
108
+ if (!await ensureLogin()) {
109
+ ui.warn("Superwall Agent needs sign-in. Run `superwall login`, or install Claude Code/Codex and re-run.");
110
+ return false;
111
+ }
112
+ const status = await withSpinner("Checking Superwall Agent credit", () => getHostedStatus());
113
+ if (!status) {
114
+ ui.warn("Superwall Agent needs an OAuth login. Run `superwall login` (not `--api-key`), or install Claude Code/Codex.");
115
+ return false;
116
+ }
117
+ if (status.exhausted) {
118
+ ui.warn("Your hosted Superwall Agent credit is exhausted. Install Claude Code/Codex or copy the prompt into your own agent.");
119
+ return false;
120
+ }
121
+ return true;
122
+ }
123
+ async function pickApp(installDir, interactive) {
124
+ const scan = await withSpinner("Scanning your project", () => scanProject(installDir));
125
+ if (scan.apps.length === 0) {
126
+ if (scan.unsupported.length) {
127
+ const webApp = scan.unsupported[0];
128
+ throw new Error(`Detected a web app${webApp.details ? ` (\`${webApp.details}\`)` : ""}. This command supports mobile apps.`);
129
+ }
130
+ const skipped = scan.skipped.length ? ` Skipped: ${scan.skipped.join(", ")}.` : "";
131
+ throw new Error(`No ${SUPPORTED_LABEL} app found in this directory.${skipped}`);
132
+ }
133
+ if (scan.unsupported.length) ui.info(`Also found unsupported web apps: ${scan.unsupported.map((app) => app.name).join(", ")}`);
134
+ if (scan.apps.length === 1) {
135
+ const app = scan.apps[0];
136
+ ui.info(`Detected \`${app.framework.name}\`` + (app.details ? ` · \`${app.details}\`` : "") + (app.relPath !== "." ? ` (${app.relPath})` : ""));
137
+ return app;
138
+ }
139
+ if (!interactive) throw new Error("Multiple apps found. Pass --install-dir for the app you want to change.");
140
+ const choice = await ui.select({
141
+ message: scan.isMonorepo ? "Found multiple apps - which one?" : "Which app?",
142
+ options: scan.apps.map((app) => ({
143
+ value: app.path,
144
+ label: `${app.name} · ${app.framework.name}`,
145
+ hint: app.relPath === "." ? void 0 : app.relPath
146
+ })),
147
+ initialValue: scan.apps[0].path
148
+ });
149
+ if (choice === null) return null;
150
+ return scan.apps.find((app) => app.path === choice) ?? scan.apps[0];
151
+ }
152
+ async function chooseAction(forced, existing, app, interactive) {
153
+ if (forced) return forced;
154
+ if (!interactive) return "integrate";
155
+ if (!existing.sdkInstalled) {
156
+ const confirmed = await ui.confirm({ message: `Integrate Superwall into \`${app.name}\`?` });
157
+ if (confirmed === null) {
158
+ ui.warn("Cancelled.");
159
+ return null;
160
+ }
161
+ if (!confirmed) {
162
+ ui.outro("No problem - run `superwall integrate` again anytime.");
163
+ return null;
164
+ }
165
+ return "integrate";
166
+ }
167
+ const available = ACTIONS.filter((action) => {
168
+ if (action.id === "integrate") return false;
169
+ if (action.requiresOrgKey && !process.env.SUPERWALL_API_KEY) return false;
170
+ return true;
171
+ });
172
+ return await ui.select({
173
+ message: "What do you want to do?",
174
+ options: available.map((action) => ({
175
+ value: action.id,
176
+ label: action.title,
177
+ hint: action.hint
178
+ })),
179
+ initialValue: "review"
180
+ });
181
+ }
182
+ async function stage(label, work) {
183
+ ui.step(label);
184
+ await new Promise((resolve) => setTimeout(resolve, 40));
185
+ await work();
186
+ }
187
+
188
+ //#endregion
189
+ export { recoverUnmatchedScope as a, pickApp as i, ensureAgentDriverReady as n, stage as o, performLoginWithUi as r, chooseAction as t };