@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,33 +1,38 @@
1
- import "./output-C4o2gJ1K.js";
2
- import "./telemetry-DeA1mvnT.js";
3
- import "./update-B2fWIc4q.js";
4
- import "./token-C0it-Xh7.js";
5
- import { t as defineCommand } from "./command-CMIz81Da.js";
6
- import "./ui-Dy0b-9L8.js";
7
- import "./skills-DPzlnfCK.js";
8
- import "./spawn-DSoTXy_j.js";
9
- import "./login-Do4wFuLv.js";
10
- import { n as allDeps, r as readPackageJson, t as scanProject } from "./scan-zKsddO72.js";
11
- import "./drivers-Qx9LxmRN.js";
12
- import "./hosted-CXe9TrWx.js";
13
- import { t as detectExisting } from "./existing-AVEfZu2A.js";
14
- import "./spinner-TWa0hia6.js";
15
- import { b as platformLabel, h as listProjects, n as createApplication, p as listApplications } from "./resources-Bf9O1JNM.js";
16
- import { C as writeApp } from "./selection-CxZoX4NT.js";
17
- import "./org-sj7uyvp-.js";
18
- import { r as resolveScopeFromKey } from "./bind-YrJvuRF9.js";
19
- import { _ as requireApi, b as requirePlatform, g as LoginRequiredError, o as gitAvailable, v as projectPackageName } from "./pipeline-BqzqZhX1.js";
20
- import "./actions-B7ym3oVS.js";
21
- import "./app-DH6U8yuI.js";
22
- import "./run-DsVZ5snL.js";
23
- import { b as writeTemplate, c as migrationFor, d as projectDirOf, f as scaffoldFromPaywall, i as startStudio, n as migrationNextSteps, s as isSuperwallProject, t as askStudio, u as offerMigration, v as starterConfig, x as slugOf, y as writeSurfaceFiles } from "./open-studio-DOw-6ydc.js";
24
- import "./dev-DmB3XqaJ.js";
25
- import pc from "picocolors";
1
+ import "./token-DzRh7dI1.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-DF1qKlny.js";
4
+ import "./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 "./ui-D_qf3Gvw.js";
11
+ import "./theme-DUsCh-Vd.js";
12
+ import "./log-NVhVe_oe.js";
13
+ import { i as readPackageJson, r as allDeps, t as scanProject } from "./scan-DLrsrFS9.js";
14
+ import { t as detectExisting } from "./existing-78LWSsqS.js";
15
+ import "./paths-DxSLdpOI.js";
16
+ import { T as field, f as listApplications, n as createApplication, p as listProjects, v as platformLabel } from "./resources-Dqr01Dep.js";
17
+ import "./org-D0g_q3mv.js";
18
+ import "./lookup-D-nmmAbw.js";
19
+ import { r as resolveScopeFromKey } from "./bind-drne__Ys.js";
20
+ import "./login-D0lh3_JI.js";
21
+ import "./skills-BvFOa4y6.js";
22
+ import { T as writeApp } from "./selection-Rdw-ZUoG.js";
23
+ import { a as gitAvailable, c as projectPackageName, n as requireApi, t as LoginRequiredError, v as requirePlatform } from "./session-D_nEWKXT.js";
24
+ import "./login-B2TsCE2H.js";
25
+ import "./run-C9qg_QlC.js";
26
+ import "./drivers-DNrx4LWA.js";
27
+ import { b as writeTemplate, c as migrationFor, d as projectDirOf, f as scaffoldFromPaywall, i as startStudio, n as migrationNextSteps, s as isSuperwallProject, t as askStudio, u as offerMigration, v as starterConfig, x as slugOf, y as writeSurfaceFiles } from "./open-Ba2vBl1_.js";
28
+ import "./server-D0tGG8C4.js";
29
+ import { execFile } from "node:child_process";
30
+ import * as fs from "node:fs";
26
31
  import * as path from "node:path";
27
- import * as os$1 from "node:os";
32
+ import pc from "picocolors";
28
33
  import { promisify } from "node:util";
29
- import * as fs from "node:fs";
30
- import { execFile } from "node:child_process";
34
+ import * as os$1 from "node:os";
35
+ import { gunzipSync } from "node:zlib";
31
36
 
32
37
  //#region src/core/paywalls/project/examples.ts
33
38
  const run$1 = promisify(execFile);
@@ -37,19 +42,26 @@ var ExampleError = class extends Error {};
37
42
  async function listExamples(fetchImpl = fetch) {
38
43
  const response = await fetchImpl(`https://api.github.com/repos/${EXAMPLES_REPO}/contents/examples?ref=${EXAMPLES_REF}`);
39
44
  if (!response.ok) throw new ExampleError(`Could not list examples from github.com/${EXAMPLES_REPO} (HTTP ${response.status}).`);
40
- return (await response.json()).filter((entry) => entry.type === "dir" && typeof entry.name === "string").map((entry) => entry.name).sort();
45
+ const entries = await response.json();
46
+ return (Array.isArray(entries) ? entries : []).filter((entry) => field(entry, "type") === "dir").map((entry) => field(entry, "name")).filter((name) => typeof name === "string").sort();
41
47
  }
42
48
  async function downloadExample(name, target, fetchImpl = fetch) {
43
49
  if (!/^[a-z0-9][a-z0-9-]*$/.test(name)) throw new ExampleError(`\`${name}\` is not an example name.`);
44
50
  const response = await fetchImpl(`https://codeload.github.com/${EXAMPLES_REPO}/tar.gz/refs/heads/${EXAMPLES_REF}`);
45
51
  if (!response.ok) throw new ExampleError(`Could not download github.com/${EXAMPLES_REPO} (HTTP ${response.status}). Check your network, then try again.`);
46
- const tarball = path.join(os$1.tmpdir(), `superwall-example-${process.pid}.tar.gz`);
47
- fs.writeFileSync(tarball, Buffer.from(await response.arrayBuffer()));
52
+ let archive;
53
+ try {
54
+ archive = gunzipSync(Buffer.from(await response.arrayBuffer()));
55
+ } catch {
56
+ throw new ExampleError(`The download of github.com/${EXAMPLES_REPO} was damaged. Try again.`);
57
+ }
58
+ const tarball = path.join(os$1.tmpdir(), `superwall-example-${process.pid}.tar`);
59
+ fs.writeFileSync(tarball, archive);
48
60
  const prefix = `${EXAMPLES_REPO.split("/")[1]}-${EXAMPLES_REF.replace(/\//g, "-")}`;
49
61
  fs.mkdirSync(target, { recursive: true });
50
62
  try {
51
63
  await run$1("tar", [
52
- "-xzf",
64
+ "-xf",
53
65
  tarball,
54
66
  "-C",
55
67
  target,
@@ -73,7 +85,7 @@ function adoptExamplePackage(target, name) {
73
85
  }
74
86
 
75
87
  //#endregion
76
- //#region src/commands/paywalls/create.ts
88
+ //#region src/core/paywalls/project/setup.ts
77
89
  const run = promisify(execFile);
78
90
  const APP_PLATFORMS = [
79
91
  "ios",
@@ -141,10 +153,7 @@ async function installDependencies(ui, target, manager) {
141
153
  }
142
154
  async function initGit(ui, root) {
143
155
  if (!await gitAvailable()) return;
144
- try {
145
- await run("git", ["rev-parse", "--is-inside-work-tree"], { cwd: root });
146
- return;
147
- } catch {}
156
+ if (await run("git", ["rev-parse", "--is-inside-work-tree"], { cwd: root }).then(() => true, () => false)) return;
148
157
  try {
149
158
  await run("git", ["init", "--quiet"], { cwd: root });
150
159
  await run("git", ["add", "-A"], { cwd: root });
@@ -155,7 +164,9 @@ async function initGit(ui, root) {
155
164
  "New superwall project"
156
165
  ], { cwd: root });
157
166
  ui.step("Initialized a git repository");
158
- } catch {}
167
+ } catch {
168
+ return;
169
+ }
159
170
  }
160
171
  function humanName(root) {
161
172
  return projectPackageName(root).split(/[-_.]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
@@ -174,11 +185,12 @@ async function detectHostApp(root) {
174
185
  }
175
186
  async function createAppFlow(ui, api, root) {
176
187
  const projects = await listProjects(api);
177
- if (projects.length === 0) {
188
+ const [first] = projects;
189
+ if (first === void 0) {
178
190
  ui.warn("Your account has no projects yet — create one in the dashboard first.");
179
191
  return null;
180
192
  }
181
- let project = projects[0];
193
+ let project = first;
182
194
  if (projects.length > 1) {
183
195
  const picked = await ui.select({
184
196
  message: "Which project does the app belong to?",
@@ -268,36 +280,53 @@ async function connectApp(ui, interactive, root, target, detected, appId) {
268
280
  writeApp(target, requirePlatform(app), String(app.id));
269
281
  ui.success(`Pushes go to \`${app.name ?? app.id}\` — saved in superwall.lock, so commit that file.`);
270
282
  }
271
- const uniqueSurfaceId = (superwallDir, slug) => {
283
+ function uniqueSurfaceId(superwallDir, slug) {
272
284
  let candidate = slug;
273
285
  for (let n = 2; fs.existsSync(path.join(superwallDir, "paywalls", candidate)); n += 1) candidate = `${slug}-${n}`;
274
286
  return candidate;
287
+ }
288
+
289
+ //#endregion
290
+ //#region src/core/paywalls/project/create.ts
291
+ const runtime = {
292
+ offerMigration,
293
+ askStudio,
294
+ startStudio
275
295
  };
276
- async function addSurface(context, superwallDir) {
277
- const { argv, interactive, ui } = context;
296
+ async function offerRebuild(ctx, options, migration, deps) {
297
+ const { interactive, ui } = ctx;
298
+ if (migration === void 0 || !interactive || options.yes) return { choice: "later" };
299
+ const choice = await deps.offerMigration(ui, interactive, migration);
300
+ if (choice !== "agent") return { choice };
301
+ return await deps.askStudio(ui, interactive, migration.surfaceId) ? {
302
+ choice,
303
+ studio: migration
304
+ } : { choice };
305
+ }
306
+ async function addSurface(ctx, options, superwallDir, deps) {
307
+ const { interactive, ui } = ctx;
278
308
  const where = path.relative(process.cwd(), superwallDir) || ".";
279
- if (typeof argv.example === "string") throw new Error(`\`${where}\` is already a superwall project — an example is a whole project, so start it in an empty directory.`);
280
- if (argv.app !== void 0) throw new Error(`\`${where}\` is already connected — its apps live in superwall.lock; drop \`--app\`.`);
281
- const from = typeof argv.from === "string" || typeof argv.from === "number" ? String(argv.from) : void 0;
309
+ if (options.example !== void 0) throw new Error(`\`${where}\` is already a superwall project — an example is a whole project, so start it in an empty directory.`);
310
+ if (options.app !== void 0) throw new Error(`\`${where}\` is already connected — its apps live in superwall.lock; drop \`--app\`.`);
311
+ const from = options.from;
282
312
  if (from !== void 0) {
283
- const migration = migrationFor(superwallDir, (await scaffoldFromPaywall(ui, await requireApi(interactive), {
313
+ const rebuild = await offerRebuild(ctx, options, migrationFor(superwallDir, (await scaffoldFromPaywall(ui, await requireApi(interactive), {
284
314
  root: process.cwd(),
285
315
  target: superwallDir,
286
316
  paywallId: from,
287
317
  newProject: false
288
- })).id);
289
- const rebuilt = migration !== void 0 && interactive && argv.yes !== true ? await offerMigration(ui, interactive, migration) : "later";
290
- const opening = rebuilt === "agent" && migration !== void 0 && await askStudio(ui, interactive, migration.surfaceId);
318
+ })).id), deps);
291
319
  ui.step("Next steps");
292
- ui.list({ items: migrationNextSteps(opening, where, from, rebuilt).map((label) => ({ label })) });
293
- if (opening && migration !== void 0) await startStudio(superwallDir, migration.surfaceId);
320
+ ui.list({ items: migrationNextSteps(rebuild.studio !== void 0, where, from, rebuild.choice).map((label) => ({ label })) });
321
+ if (rebuild.studio !== void 0) await deps.startStudio(superwallDir, rebuild.studio.surfaceId);
294
322
  return;
295
323
  }
296
- const asked = interactive && argv.yes !== true ? await ui.text({
324
+ let asked = "Pro";
325
+ if (interactive && !options.yes) asked = await ui.text({
297
326
  message: "What is the paywall called?",
298
327
  initialValue: "Pro",
299
328
  validate: (value) => value.trim() === "" ? "Give the paywall a name." : void 0
300
- }) : "Pro";
329
+ });
301
330
  if (asked === null) return;
302
331
  const name = asked.trim();
303
332
  const id = uniqueSurfaceId(superwallDir, slugOf(name));
@@ -312,127 +341,124 @@ async function addSurface(context, superwallDir) {
312
341
  children: [{ label: "Open the studio and build the pages" }]
313
342
  }] });
314
343
  }
315
- const runCreate = defineCommand({
316
- name: "create",
317
- output: "human",
318
- async run(context) {
319
- const { argv, interactive, ui } = context;
320
- ui.intro(`Superwall ${pc.dim("create")}`);
321
- const root = path.resolve(typeof argv.dir === "string" ? argv.dir : process.cwd());
322
- const existing = projectDirOf(root);
323
- if (existing !== void 0) {
324
- await addSurface(context, existing);
325
- return;
326
- }
327
- const problem = alreadyAProject(root);
328
- if (problem !== void 0) throw new Error(problem);
329
- const target = path.join(root, "superwall");
330
- const appId = typeof argv.app === "string" || typeof argv.app === "number" ? String(argv.app) : void 0;
331
- if (appId !== void 0 && argv.connect === false) throw new Error("`--app` connects the project to that app — drop `--no-connect`.");
332
- const detection = detectHostApp(root);
333
- const from = typeof argv.from === "string" || typeof argv.from === "number" ? String(argv.from) : void 0;
334
- let example = typeof argv.example === "string" ? argv.example : void 0;
335
- if (from !== void 0 && example !== void 0) throw new Error("`--from` rebuilds a dashboard paywall as the starter — drop `--example`.");
336
- if (from !== void 0 && argv.connect === false) throw new Error("`--from` connects the project to the paywall's app — drop `--no-connect`.");
337
- let originAppId;
338
- let originBound = false;
339
- let migration;
340
- if (from !== void 0) {
341
- const origin = await scaffoldFromPaywall(ui, await requireApi(interactive), {
342
- root,
343
- target,
344
- paywallId: from,
345
- newProject: true
346
- });
347
- if (origin.applicationId !== void 0 && origin.platform !== void 0) originBound = true;
348
- else originAppId = origin.applicationId;
349
- migration = migrationFor(target, origin.id);
350
- }
351
- if (from === void 0 && example === void 0 && interactive && argv.yes !== true) {
352
- const start = await ui.select({
353
- message: "Start from",
354
- options: [{
355
- value: "minimal",
356
- label: "Minimal",
357
- hint: "one paywall, one product"
358
- }, {
359
- value: "example",
360
- label: "An example",
361
- hint: `github.com/${EXAMPLES_REPO}`
362
- }],
363
- initialValue: "minimal"
364
- });
365
- if (start === null) return;
366
- if (start === "example") {
367
- const spin = ui.spinner();
368
- spin.start("Fetching the example list");
369
- try {
370
- const examples = await listExamples();
371
- spin.stop(`${examples.length} examples`);
372
- const picked = await ui.select({
373
- message: "Which example?",
374
- options: examples.map((name) => ({
375
- value: name,
376
- label: name
377
- }))
378
- });
379
- if (picked === null) return;
380
- example = picked;
381
- } catch (error) {
382
- spin.stop("Could not fetch the example list");
383
- ui.warn(`${error instanceof ExampleError ? error.message : String(error)}\nStarting from minimal instead.`);
384
- }
385
- }
386
- }
387
- if (from !== void 0) {} else if (example === void 0) {
388
- writeTemplate(target, projectPackageName(root));
389
- ui.step("Created superwall/ from the minimal template");
390
- } else {
344
+ async function runCreate(ctx, options, deps = runtime) {
345
+ const { interactive, ui } = ctx;
346
+ ui.intro(`Superwall ${pc.dim("create")}`);
347
+ const root = path.resolve(options.dir ?? process.cwd());
348
+ const existing = projectDirOf(root);
349
+ if (existing !== void 0) {
350
+ await addSurface(ctx, options, existing, deps);
351
+ return;
352
+ }
353
+ const problem = alreadyAProject(root);
354
+ if (problem !== void 0) throw new Error(problem);
355
+ const target = path.join(root, "superwall");
356
+ const appId = options.app;
357
+ if (appId !== void 0 && !options.connect) throw new Error("`--app` connects the project to that app — drop `--no-connect`.");
358
+ const detection = detectHostApp(root);
359
+ const from = options.from;
360
+ let example = options.example;
361
+ if (from !== void 0 && example !== void 0) throw new Error("`--from` rebuilds a dashboard paywall as the starter — drop `--example`.");
362
+ if (from !== void 0 && !options.connect) throw new Error("`--from` connects the project to the paywall's app — drop `--no-connect`.");
363
+ let originAppId;
364
+ let originBound = false;
365
+ let migration;
366
+ if (from !== void 0) {
367
+ const origin = await scaffoldFromPaywall(ui, await requireApi(interactive), {
368
+ root,
369
+ target,
370
+ paywallId: from,
371
+ newProject: true
372
+ });
373
+ if (origin.applicationId !== void 0 && origin.platform !== void 0) originBound = true;
374
+ else originAppId = origin.applicationId;
375
+ migration = migrationFor(target, origin.id);
376
+ }
377
+ if (from === void 0 && example === void 0 && interactive && !options.yes) {
378
+ const start = await ui.select({
379
+ message: "Start from",
380
+ options: [{
381
+ value: "minimal",
382
+ label: "Minimal",
383
+ hint: "one paywall, one product"
384
+ }, {
385
+ value: "example",
386
+ label: "An example",
387
+ hint: `github.com/${EXAMPLES_REPO}`
388
+ }],
389
+ initialValue: "minimal"
390
+ });
391
+ if (start === null) return;
392
+ if (start === "example") {
391
393
  const spin = ui.spinner();
392
- spin.start(`Downloading \`${example}\``);
394
+ spin.start("Fetching the example list");
393
395
  try {
394
- await downloadExample(example, target);
395
- } catch (error) {
396
- spin.stop("Download failed");
397
- fs.rmSync(target, {
398
- recursive: true,
399
- force: true
396
+ const examples = await listExamples();
397
+ spin.stop(`${examples.length} examples`);
398
+ const picked = await ui.select({
399
+ message: "Which example?",
400
+ options: examples.map((name) => ({
401
+ value: name,
402
+ label: name
403
+ }))
400
404
  });
401
- throw error;
405
+ if (picked === null) return;
406
+ example = picked;
407
+ } catch (error) {
408
+ spin.stop("Could not fetch the example list");
409
+ ui.warn(`${error instanceof ExampleError ? error.message : String(error)}\nStarting from minimal instead.`);
402
410
  }
403
- adoptExamplePackage(target, projectPackageName(root));
404
- spin.stop(`Created superwall/ from the \`${example}\` example`);
405
411
  }
406
- const detected = await detection;
407
- if (detected?.existing.fullyIntegrated) ui.info(`The Superwall SDK is already set up in \`${detected.app.name}\`.`);
408
- if ((argv.connect === false || originBound ? false : interactive && argv.yes !== true && appId === void 0 && from === void 0 ? await ui.confirm({
409
- message: "Connect your Superwall account now? (Recommended)",
410
- initial: true
411
- }) : true) === true) try {
412
- await connectApp(ui, interactive, root, target, detected, appId ?? originAppId);
412
+ }
413
+ if (from === void 0 && example === void 0) {
414
+ writeTemplate(target, projectPackageName(root));
415
+ ui.step("Created superwall/ from the minimal template");
416
+ } else if (from === void 0 && example !== void 0) {
417
+ const spin = ui.spinner();
418
+ spin.start(`Downloading \`${example}\``);
419
+ try {
420
+ await downloadExample(example, target);
413
421
  } catch (error) {
414
- if (appId !== void 0) throw error;
415
- if (error instanceof LoginRequiredError) ui.info("Not signed in — the first `superwall push` will connect you.");
416
- else ui.warn(`${error instanceof Error ? error.message : String(error)}\nSkipping — the first \`superwall push\` connects you.`);
422
+ spin.stop("Download failed");
423
+ fs.rmSync(target, {
424
+ recursive: true,
425
+ force: true
426
+ });
427
+ throw error;
417
428
  }
418
- const manager = await detectPackageManager(root);
419
- const installed = argv.install === false ? false : await installDependencies(ui, target, manager);
420
- await initGit(ui, root);
421
- const rebuilt = migration !== void 0 && interactive && argv.yes !== true ? await offerMigration(ui, interactive, migration) : "later";
422
- const opening = rebuilt === "agent" && migration !== void 0 && await askStudio(ui, interactive, migration.surfaceId);
423
- const integrate = detected?.existing.fullyIntegrated ? [] : [{
424
- label: "superwall integrate",
425
- children: [{ label: "Set up the SDK in your app" }]
426
- }];
427
- const dev = installed ? `cd superwall && ${devCommand(manager)}` : `cd superwall && ${manager} install && ${devCommand(manager)}`;
428
- ui.step("Next steps");
429
- ui.list({ items: from === void 0 ? [{
430
- label: dev,
431
- children: [{ label: "Open the studio" }]
432
- }, ...integrate] : [...migrationNextSteps(opening, "superwall", from, rebuilt).map((label) => ({ label })), ...integrate] });
433
- if (opening && migration !== void 0) await startStudio(target, migration.surfaceId);
429
+ adoptExamplePackage(target, projectPackageName(root));
430
+ spin.stop(`Created superwall/ from the \`${example}\` example`);
431
+ }
432
+ const detected = await detection;
433
+ if (detected?.existing.fullyIntegrated) ui.info(`The Superwall SDK is already set up in \`${detected.app.name}\`.`);
434
+ let connect = options.connect && !originBound;
435
+ if (connect && interactive && !options.yes && appId === void 0 && from === void 0) connect = await ui.confirm({
436
+ message: "Connect your Superwall account now? (Recommended)",
437
+ initial: true
438
+ }) === true;
439
+ if (connect) try {
440
+ await connectApp(ui, interactive, root, target, detected, appId ?? originAppId);
441
+ } catch (error) {
442
+ if (appId !== void 0) throw error;
443
+ if (error instanceof LoginRequiredError) ui.info("Not signed in — the first `superwall push` will connect you.");
444
+ else ui.warn(`${error instanceof Error ? error.message : String(error)}\nSkipping — the first \`superwall push\` connects you.`);
434
445
  }
435
- });
446
+ const manager = await detectPackageManager(root);
447
+ const installed = options.install && await installDependencies(ui, target, manager);
448
+ await initGit(ui, root);
449
+ const rebuild = await offerRebuild(ctx, options, migration, deps);
450
+ const integrate = detected?.existing.fullyIntegrated ? [] : [{
451
+ label: "superwall integrate",
452
+ children: [{ label: "Set up the SDK in your app" }]
453
+ }];
454
+ const dev = installed ? `cd superwall && ${devCommand(manager)}` : `cd superwall && ${manager} install && ${devCommand(manager)}`;
455
+ ui.step("Next steps");
456
+ ui.list({ items: from === void 0 ? [{
457
+ label: dev,
458
+ children: [{ label: "Open the studio" }]
459
+ }, ...integrate] : [...migrationNextSteps(rebuild.studio !== void 0, "superwall", from, rebuild.choice).map((label) => ({ label })), ...integrate] });
460
+ if (rebuild.studio !== void 0) await deps.startStudio(target, rebuild.studio.surfaceId);
461
+ }
436
462
 
437
463
  //#endregion
438
- export { alreadyAProject, runCreate };
464
+ export { runCreate };
@@ -0,0 +1,19 @@
1
+ import "./token-DzRh7dI1.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-DF1qKlny.js";
4
+ import "./storage-s2Dnz-yl.js";
5
+ import "./client-DP6Rc0t_.js";
6
+ import "./held-Cy8Wl4D1.js";
7
+ import "./config-BO1Y87kV.js";
8
+ import "./spinner-CneRK5rk.js";
9
+ import "./ui-D_qf3Gvw.js";
10
+ import "./paths-DxSLdpOI.js";
11
+ import "./resources-Dqr01Dep.js";
12
+ import "./org-D0g_q3mv.js";
13
+ import "./lookup-D-nmmAbw.js";
14
+ import "./scope-V336uz8j.js";
15
+ import "./client-BZ1UbpXz.js";
16
+ import "./timing-BVxPrYq3.js";
17
+ import { i as runAscKeysCreate, n as keyAccess, r as keyRole, t as createAndSaveKey } from "./create-BBrtgUgS.js";
18
+
19
+ export { createAndSaveKey, keyAccess, keyRole, runAscKeysCreate };
@@ -0,0 +1,83 @@
1
+ import "./token-DzRh7dI1.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import { v as apiKeyFromEnv } from "./environment-DF1qKlny.js";
4
+ import { t as readSession } from "./storage-s2Dnz-yl.js";
5
+ import "./spawn-DmmmHIP-.js";
6
+ import { n as ui } from "./ui-D_qf3Gvw.js";
7
+ import { n as fg, t as THEME } from "./theme-DUsCh-Vd.js";
8
+ import { t as scanProject } from "./scan-DLrsrFS9.js";
9
+ import { t as detectExisting } from "./existing-78LWSsqS.js";
10
+ import { t as detectDrivers } from "./drivers-DNrx4LWA.js";
11
+
12
+ //#region src/core/support/doctor.ts
13
+ async function runDoctor(ctx, deps = {}) {
14
+ ui.intro("Superwall doctor");
15
+ const spin = ui.spinner();
16
+ spin.start("Checking your setup");
17
+ const drivers = await (deps.detectDrivers ?? detectDrivers)();
18
+ const scan = await scanProject(ctx.installDir);
19
+ spin.stop("Checks complete");
20
+ const top = scan.apps[0];
21
+ const existing = top ? detectExisting(top) : null;
22
+ const session = readSession();
23
+ const sdkChecks = existing ? [
24
+ [
25
+ existing.sdkInstalled,
26
+ "SDK",
27
+ existing.sdkInstalled ? "installed" : "not installed"
28
+ ],
29
+ [
30
+ existing.configureFound,
31
+ "configure()",
32
+ existing.configureFound ? "present" : "missing"
33
+ ],
34
+ [
35
+ !!existing.apiKey,
36
+ "API key",
37
+ existing.apiKey ?? "none in project"
38
+ ]
39
+ ] : [];
40
+ const rows = [
41
+ [
42
+ drivers.length > 0,
43
+ "Coding agent",
44
+ drivers.map((d) => d.info.displayName).join(", ") || "none found"
45
+ ],
46
+ top ? [
47
+ true,
48
+ "Project",
49
+ `${top.framework.name}${top.details ? ` · ${top.details}` : ""}`
50
+ ] : scan.unsupported[0] ? [
51
+ false,
52
+ "Project",
53
+ `${scan.unsupported[0].framework.name} (not supported by this command)`
54
+ ] : [
55
+ false,
56
+ "Project",
57
+ "not detected"
58
+ ],
59
+ ...sdkChecks,
60
+ [
61
+ !!session || !!apiKeyFromEnv(),
62
+ "Logged in",
63
+ session ? session.userEmail ?? session.orgName ?? "yes" : apiKeyFromEnv() ? "via SUPERWALL_API_KEY" : "no - run `superwall login`"
64
+ ]
65
+ ];
66
+ if (ctx.json) {
67
+ const checks = rows.map(([ok, label, value]) => ({
68
+ ok,
69
+ label,
70
+ value
71
+ }));
72
+ return ctx.output.data({
73
+ ok: checks.every((check) => check.ok),
74
+ checks
75
+ });
76
+ }
77
+ ui.report(rows.map(([ok, label, value]) => `${ok ? fg(THEME.primary, "✓") : fg(THEME.alert, "✗")} ${label.padEnd(13)} ${value}`).join("\n"));
78
+ const failed = rows.filter(([ok]) => !ok).length;
79
+ ui.outro(failed === 0 ? "All checks passed." : `${failed} of ${rows.length} checks need attention.`);
80
+ }
81
+
82
+ //#endregion
83
+ export { runDoctor };