@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
package/README.md CHANGED
@@ -56,6 +56,9 @@ instead of running it — paste it into any agent.
56
56
 
57
57
  ```bash
58
58
  superwall create # start a paywalls project — minimal, or any public example
59
+ superwall create --from {ID} # rebuild a dashboard paywall as code: its config.ts, a migration brief, Compare › Original in the studio
60
+ superwall migrate {ID} # …then rebuild its pages with your coding agent, or copy the prompt (--skill prints it)
61
+ superwall migrate --screen App/UpdateRequiredView.swift # rebuild a native screen (Swift, Kotlin, RN, Flutter) as a Superwall surface (no path: pick from candidates)
59
62
  superwall dev # open the studio and preview everything live
60
63
  superwall push # build and push immutable versions (production untouched)
61
64
  superwall promote # point production at a pushed version
@@ -76,7 +79,9 @@ to begin from any example in the
76
79
  then looks at the app around it: if the Superwall SDK is already configured,
77
80
  it finds your app by its API key and binds pushes to it; otherwise it can log
78
81
  you in, pick an app, or create one on the spot. `--yes` accepts the defaults;
79
- `--no-install` and `--no-connect` skip those steps.
82
+ `--no-install` and `--no-connect` skip those steps, and `--app <id>` connects a
83
+ specific Superwall app (the dashboard's **Copy Prompt** passes it) instead of
84
+ detecting or asking.
80
85
 
81
86
  ### A project is a directory
82
87
 
@@ -338,11 +343,22 @@ asking. The framework itself is built to be written by agents: a plain npm
338
343
  project, file-based routes, ordinary React state — conventions an agent
339
344
  already knows, so it gets a paywall right on the first try.
340
345
 
346
+ ## Channels
347
+
348
+ Set `SUPERWALL_CHANNEL=next` to opt into experimental and beta features:
349
+ commands that are not in the stable set yet, and the matching agent skills
350
+ from the `next` branch of the skills repo. Everything else is unchanged.
351
+ Export it in your shell rc so every terminal and agent sees it. Unset it to
352
+ go back to the stable set.
353
+
341
354
  ## Telemetry
342
355
 
343
- The CLI sends fully anonymous usage events (which workflow ran and whether it
344
- succeeded — never emails, IDs, file paths, SQL, prompts, or error messages).
345
- Opt out with `SUPERWALL_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.
356
+ The CLI sends fully anonymous usage events for every command (which command
357
+ and subcommand ran, whether it succeeded, how long it took, and flags like
358
+ `--json` or `--dry-run` — never emails, IDs, file paths, SQL, prompts, API
359
+ paths, or error messages). Events carry a random per-machine id that is never
360
+ linked to your account. Opt out with `SUPERWALL_TELEMETRY_DISABLED=1` or
361
+ `DO_NOT_TRACK=1`.
346
362
 
347
363
  ## Package layout
348
364
 
@@ -360,7 +376,7 @@ packages/cli/
360
376
  │ ├── core/ api client, auth, project detection, paywall
361
377
  │ │ binding + lock, agent runners, telemetry, skills sync
362
378
  │ └── ui/ the renderer: human output, --json envelopes, prompts
363
- ├── skills/ the bundled playbooks integrate/migrate/review run
379
+ ├── dist/skills/ the playbooks integrate/migrate/review run, bundled from superwall/skills at build
364
380
  └── tests/ mirrors src/
365
381
  ```
366
382
 
@@ -1,10 +1,11 @@
1
- import { d as Integration } from "./output-csAtR6kJ.js";
2
- import { i as loadBundledSkill } from "./skills-CODut1Hn.js";
1
+ import { m as Integration } from "./output-CiELrN8w.js";
2
+ import { i as loadBundledSkill } from "./skills-grTDuHlc.js";
3
3
 
4
4
  //#region src/core/agent/actions.ts
5
5
  /** Skill reference file per framework, so an agent only sees its own platform's docs. */
6
6
  const FRAMEWORK_REF = {
7
7
  [Integration.swift]: "ios",
8
+ [Integration.android]: "android",
8
9
  [Integration.expo]: "expo",
9
10
  [Integration.reactNative]: "react-native",
10
11
  [Integration.flutter]: "flutter"
@@ -1,12 +1,12 @@
1
- import "./output-csAtR6kJ.js";
2
- import "./telemetry-BtkMdT-5.js";
3
- import "./update-CeylIjx5.js";
4
- import "./token-hM7V1KMG.js";
5
- import { t as defineCommand } from "./command-DP96_gmP.js";
6
- import "./ui-Lqt_zFOr.js";
7
- import { C as rowName, h as listResource, m as listProjects, p as listOrganizations, w as titleCase, y as platformLabel } from "./resources-s64mBHaC.js";
8
- import { t as parseParams } from "./params-B1zeElGa.js";
9
- import { n as emitJson, t as apiCall } from "./api-output-D9ggXQIr.js";
1
+ import "./output-CiELrN8w.js";
2
+ import "./telemetry-BuCbmoux.js";
3
+ import "./update-DnGfpCD7.js";
4
+ import "./token-mju3Q-vc.js";
5
+ import { t as defineCommand } from "./command-DMoMn7uc.js";
6
+ import "./ui-4gLyfrgl.js";
7
+ import { E as titleCase, T as rowName, b as platformLabel, g as listResource, h as listProjects, m as listOrganizations } from "./resources-Bf9O1JNM.js";
8
+ import { t as parseParams } from "./params-BxgTuCzr.js";
9
+ import { n as emitJson, t as apiCall } from "./api-output-CEhN-U_N.js";
10
10
  import pc from "picocolors";
11
11
 
12
12
  //#region src/commands/platform/api.ts
@@ -1,12 +1,12 @@
1
- import { i as loadSession, r as clearSession } from "./token-hM7V1KMG.js";
2
- import { i as superwallApi } from "./command-DP96_gmP.js";
3
- import { n as ui } from "./ui-Lqt_zFOr.js";
4
- import { n as performLogin, r as onboardingHooks } from "./login-kneYhhk0.js";
5
- import { i as SUPPORTED_LABEL, t as scanProject } from "./scan-DJixvuHn.js";
6
- import { r as getHostedStatus } from "./hosted-CEH78QVn.js";
7
- import { t as withSpinner } from "./spinner-B9dT3DBY.js";
8
- import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-BZxVyt9P.js";
9
- import { t as ACTIONS } from "./actions-EfP8phmb.js";
1
+ import { i as loadSession, r as clearSession } from "./token-mju3Q-vc.js";
2
+ import { a as superwallApi } from "./command-DMoMn7uc.js";
3
+ import { n as ui } from "./ui-4gLyfrgl.js";
4
+ import { i as onboardingHooks, n as performLogin } from "./login-Bjj8QvIN.js";
5
+ import { i as SUPPORTED_LABEL, t as scanProject } from "./scan-CAObNRgc.js";
6
+ import { r as getHostedStatus } from "./hosted-Cjekn8oJ.js";
7
+ import { t as withSpinner } from "./spinner-DFctF_Jw.js";
8
+ import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-BSTAinn6.js";
9
+ import { t as ACTIONS } from "./actions-Dt35nIi8.js";
10
10
 
11
11
  //#region src/commands/workflow/integrate/app.ts
12
12
  async function performLoginWithUi(app, onProvisioned) {
@@ -1,14 +1,14 @@
1
- import "./output-csAtR6kJ.js";
2
- import "./telemetry-BtkMdT-5.js";
3
- import "./update-CeylIjx5.js";
4
- import "./token-hM7V1KMG.js";
5
- import { n as ApiError, t as defineCommand } from "./command-DP96_gmP.js";
6
- import "./ui-Lqt_zFOr.js";
7
- import "./spinner-B9dT3DBY.js";
8
- import { m as listProjects } from "./resources-s64mBHaC.js";
9
- import { t as requireOrg } from "./org-Cg25bcsj.js";
10
- import { t as parseParams } from "./params-B1zeElGa.js";
11
- import { n as emitJson, t as apiCall } from "./api-output-D9ggXQIr.js";
1
+ import "./output-CiELrN8w.js";
2
+ import "./telemetry-BuCbmoux.js";
3
+ import "./update-DnGfpCD7.js";
4
+ import "./token-mju3Q-vc.js";
5
+ import { r as ApiError, t as defineCommand } from "./command-DMoMn7uc.js";
6
+ import "./ui-4gLyfrgl.js";
7
+ import "./spinner-DFctF_Jw.js";
8
+ import { h as listProjects } from "./resources-Bf9O1JNM.js";
9
+ import { t as requireOrg } from "./org-CV8c849b.js";
10
+ import { t as parseParams } from "./params-BxgTuCzr.js";
11
+ import { n as emitJson, t as apiCall } from "./api-output-CEhN-U_N.js";
12
12
  import { readFileSync } from "node:fs";
13
13
 
14
14
  //#region src/core/api/asa.ts
@@ -1,18 +1,18 @@
1
- import { p as SUPERWALL_HOME } from "./output-csAtR6kJ.js";
2
- import "./telemetry-BtkMdT-5.js";
3
- import "./update-CeylIjx5.js";
4
- import "./token-hM7V1KMG.js";
5
- import { t as defineCommand } from "./command-DP96_gmP.js";
6
- import "./ui-Lqt_zFOr.js";
7
- import "./spinner-B9dT3DBY.js";
8
- import { C as rowName } from "./resources-s64mBHaC.js";
9
- import { t as requireOrg } from "./org-Cg25bcsj.js";
10
- import { t as parseParams } from "./params-B1zeElGa.js";
11
- import { n as emitJson, t as apiCall } from "./api-output-D9ggXQIr.js";
12
- import { a as ascProxy, c as listAscConfigs, i as listAscApps, n as fetchUnimportedAscProducts, o as createAscConfig, r as findAscAppId, s as deleteAscConfig, t as ascTypeDisplay } from "./asc-products-C6MvSy8H.js";
13
- import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
14
- import { homedir } from "node:os";
1
+ import { g as SUPERWALL_HOME } from "./output-CiELrN8w.js";
2
+ import "./telemetry-BuCbmoux.js";
3
+ import "./update-DnGfpCD7.js";
4
+ import "./token-mju3Q-vc.js";
5
+ import { t as defineCommand } from "./command-DMoMn7uc.js";
6
+ import "./ui-4gLyfrgl.js";
7
+ import "./spinner-DFctF_Jw.js";
8
+ import { T as rowName } from "./resources-Bf9O1JNM.js";
9
+ import { t as requireOrg } from "./org-CV8c849b.js";
10
+ import { t as parseParams } from "./params-BxgTuCzr.js";
11
+ import { n as emitJson, t as apiCall } from "./api-output-CEhN-U_N.js";
12
+ import { a as ascProxy, c as listAscConfigs, i as listAscApps, n as fetchUnimportedAscProducts, o as createAscConfig, r as findAscAppId, s as deleteAscConfig, t as ascTypeDisplay } from "./asc-products-1e1DoGeL.js";
15
13
  import { dirname, join } from "node:path";
14
+ import { homedir } from "node:os";
15
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
16
16
  import { spawn } from "node:child_process";
17
17
  import { inflateRawSync } from "node:zlib";
18
18
 
@@ -1,13 +1,13 @@
1
- import { a as API_HOST } from "./output-csAtR6kJ.js";
2
- import { i as track } from "./telemetry-BtkMdT-5.js";
3
- import "./update-CeylIjx5.js";
4
- import { i as loadSession, r as clearSession } from "./token-hM7V1KMG.js";
5
- import { t as defineCommand } from "./command-DP96_gmP.js";
6
- import "./ui-Lqt_zFOr.js";
7
- import { n as ensureSkillsCurrent } from "./skills-CODut1Hn.js";
1
+ import { o as API_HOST } from "./output-CiELrN8w.js";
2
+ import { i as track } from "./telemetry-BuCbmoux.js";
3
+ import "./update-DnGfpCD7.js";
4
+ import { i as loadSession, r as clearSession } from "./token-mju3Q-vc.js";
5
+ import { t as defineCommand } from "./command-DMoMn7uc.js";
6
+ import "./ui-4gLyfrgl.js";
7
+ import { n as ensureSkillsCurrent } from "./skills-grTDuHlc.js";
8
8
  import "./spawn-DSoTXy_j.js";
9
- import { n as performLogin, r as onboardingHooks, t as loginWithApiKey } from "./login-kneYhhk0.js";
10
- import { t as scanProject } from "./scan-DJixvuHn.js";
9
+ import { i as onboardingHooks, n as performLogin, t as loginWithApiKey } from "./login-Bjj8QvIN.js";
10
+ import { t as scanProject } from "./scan-CAObNRgc.js";
11
11
 
12
12
  //#region src/commands/account/auth.ts
13
13
  const runLogin = defineCommand({
package/dist/auth.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./output-csAtR6kJ.js";
2
- import { n as resolveAuthToken, o as NotLoggedInError, t as getOAuthAccessToken } from "./token-hM7V1KMG.js";
1
+ import "./output-CiELrN8w.js";
2
+ import { n as resolveAuthToken, o as NotLoggedInError, t as getOAuthAccessToken } from "./token-mju3Q-vc.js";
3
3
 
4
4
  export { NotLoggedInError, getOAuthAccessToken, resolveAuthToken };
@@ -1,4 +1,4 @@
1
- import { n as allDeps, r as readPackageJson } from "./scan-DJixvuHn.js";
1
+ import { n as allDeps, r as readPackageJson } from "./scan-CAObNRgc.js";
2
2
  import { readFileSync } from "node:fs";
3
3
  import fg from "fast-glob";
4
4
 
@@ -1,7 +1,7 @@
1
- import { d as Integration } from "./output-csAtR6kJ.js";
2
- import { n as ui } from "./ui-Lqt_zFOr.js";
3
- import { m as listProjects, n as createApplication, s as createProject, y as platformLabel } from "./resources-s64mBHaC.js";
4
- import { t as requireOrg } from "./org-Cg25bcsj.js";
1
+ import { m as Integration } from "./output-CiELrN8w.js";
2
+ import { n as ui } from "./ui-4gLyfrgl.js";
3
+ import { b as platformLabel, h as listProjects, n as createApplication, s as createProject } from "./resources-Bf9O1JNM.js";
4
+ import { t as requireOrg } from "./org-CV8c849b.js";
5
5
 
6
6
  //#region src/core/account/bind.ts
7
7
  const NEW = "__new__";
@@ -11,6 +11,7 @@ const CANCEL = "esc cancel";
11
11
  function platformForIntegration(integration) {
12
12
  switch (integration) {
13
13
  case Integration.swift: return "ios";
14
+ case Integration.android: return "android";
14
15
  case Integration.flutter: return "flutter";
15
16
  case Integration.expo:
16
17
  case Integration.reactNative: return "react_native";
@@ -1,8 +1,8 @@
1
- import { a as API_HOST, i as writeJson, n as createCommandOutput, v as isNonInteractive } from "./output-csAtR6kJ.js";
2
- import { i as track, n as maybeShowTelemetryNotice } from "./telemetry-BtkMdT-5.js";
3
- import { a as refreshUpdateCheck, i as maybeNotifyUpdate } from "./update-CeylIjx5.js";
4
- import { a as saveSession, i as loadSession, n as resolveAuthToken, o as NotLoggedInError } from "./token-hM7V1KMG.js";
5
- import { r as useRenderer, t as selectRenderer } from "./ui-Lqt_zFOr.js";
1
+ import { i as writeJson, n as createCommandOutput, o as API_HOST, x as isNonInteractive } from "./output-CiELrN8w.js";
2
+ import { i as track, n as maybeShowTelemetryNotice } from "./telemetry-BuCbmoux.js";
3
+ import { a as refreshUpdateCheck, i as maybeNotifyUpdate } from "./update-DnGfpCD7.js";
4
+ import { a as saveSession, i as loadSession, n as resolveAuthToken, o as NotLoggedInError } from "./token-mju3Q-vc.js";
5
+ import { r as useRenderer, t as selectRenderer } from "./ui-4gLyfrgl.js";
6
6
  import pc from "picocolors";
7
7
  import { resolve } from "node:path";
8
8
 
@@ -186,15 +186,22 @@ async function executeCommand(definition, argv, runtime = {}) {
186
186
  process.exitCode = 1;
187
187
  return;
188
188
  }
189
- const tracked = definition.telemetry === "workflow" && !argv.dryRun;
190
189
  const startedAt = Date.now();
190
+ const base = commandTelemetry(definition, argv, {
191
+ json,
192
+ interactive
193
+ });
191
194
  ui.start();
192
- if (tracked) {
193
- if (outputMode === "rich") maybeShowTelemetryNotice(ui);
194
- track("workflow started", { workflow: definition.name });
195
- }
195
+ const offInterrupt = ui.onInterrupt?.(() => {
196
+ ui.stop();
197
+ process.stderr.write("\n✗ Cancelled.\n");
198
+ process.exit(130);
199
+ });
200
+ if (outputMode === "rich") maybeShowTelemetryNotice(ui);
201
+ track("command started", base);
196
202
  try {
197
203
  const api = resolveApi(definition.auth ?? "none", runtime.api ?? superwallApi);
204
+ if (definition.auth && definition.auth !== "none") base.logged_in = api !== void 0;
198
205
  const context = {
199
206
  argv,
200
207
  ui,
@@ -207,27 +214,43 @@ async function executeCommand(definition, argv, runtime = {}) {
207
214
  ...api ? { api } : {}
208
215
  };
209
216
  await definition.run(context);
210
- if (tracked) track("workflow finished", {
211
- workflow: definition.name,
217
+ track("command finished", {
218
+ ...base,
212
219
  status: "success",
213
220
  duration_ms: Date.now() - startedAt
214
221
  });
215
222
  } catch (error) {
216
223
  reportError(ui, outputMode, stdout, error);
217
224
  process.exitCode = 1;
218
- if (tracked) track("workflow finished", {
219
- workflow: definition.name,
225
+ const { code, status } = normalizeError(error);
226
+ track("command finished", {
227
+ ...base,
220
228
  status: "error",
221
- error_code: normalizeError(error).code,
229
+ error_code: code,
230
+ ...status === void 0 ? {} : { http_status: status },
222
231
  duration_ms: Date.now() - startedAt
223
232
  });
224
233
  } finally {
234
+ offInterrupt?.();
225
235
  if (outputMode !== "json") refreshUpdateCheck();
226
236
  if (outputMode === "rich" && runtime.waitForPaint !== false) await new Promise((done) => setTimeout(done, 50));
227
237
  ui.stop();
228
238
  if (outputMode !== "json" && definition.name !== "upgrade") maybeNotifyUpdate(stdout);
229
239
  }
230
240
  }
241
+ const BARE_WORD = /^[a-z][a-z-]{0,31}$/;
242
+ function commandTelemetry(definition, argv, flags) {
243
+ const subcommand = [argv.target, argv.action].map((value) => typeof value === "string" ? value : void 0).filter((value) => value !== void 0 && BARE_WORD.test(value));
244
+ return {
245
+ command: definition.name,
246
+ ...subcommand.length === 0 ? {} : { subcommand: subcommand.join(" ") },
247
+ auth: definition.auth ?? "none",
248
+ json: flags.json,
249
+ prompts: flags.interactive,
250
+ dry_run: Boolean(argv.dryRun),
251
+ skill: argv.skill === true
252
+ };
253
+ }
231
254
  function resolveApi(policy, factory) {
232
255
  if (policy === "required") return factory();
233
256
  if (policy === "optional") try {
@@ -275,4 +298,4 @@ function normalizeError(error) {
275
298
  }
276
299
 
277
300
  //#endregion
278
- export { superwallApi as i, ApiError as n, createSuperwallApi as r, defineCommand as t };
301
+ export { superwallApi as a, createSuperwallApi as i, executeCommand as n, ApiError as r, defineCommand as t };
@@ -1,27 +1,31 @@
1
- import "./output-csAtR6kJ.js";
2
- import "./telemetry-BtkMdT-5.js";
3
- import "./update-CeylIjx5.js";
4
- import "./token-hM7V1KMG.js";
5
- import { t as defineCommand } from "./command-DP96_gmP.js";
6
- import "./ui-Lqt_zFOr.js";
7
- import "./skills-CODut1Hn.js";
1
+ import "./output-CiELrN8w.js";
2
+ import "./telemetry-BuCbmoux.js";
3
+ import "./update-DnGfpCD7.js";
4
+ import "./token-mju3Q-vc.js";
5
+ import { t as defineCommand } from "./command-DMoMn7uc.js";
6
+ import "./ui-4gLyfrgl.js";
7
+ import "./skills-grTDuHlc.js";
8
8
  import "./spawn-DSoTXy_j.js";
9
- import "./login-kneYhhk0.js";
10
- import { n as allDeps, r as readPackageJson, t as scanProject } from "./scan-DJixvuHn.js";
11
- import "./hosted-CEH78QVn.js";
12
- import { t as detectExisting } from "./existing-Cak1WxWB.js";
13
- import "./spinner-B9dT3DBY.js";
14
- import { f as listApplications, m as listProjects, n as createApplication, y as platformLabel } from "./resources-s64mBHaC.js";
15
- import "./org-Cg25bcsj.js";
16
- import { r as resolveScopeFromKey } from "./bind-BZxVyt9P.js";
17
- import { a as projectPackageName, i as requireApi, l as requirePlatform, m as writeApp, r as LoginRequiredError, t as gitAvailable } from "./git-ZwA3Mx8m.js";
18
- import "./actions-EfP8phmb.js";
19
- import "./app-D8mEVlQo.js";
9
+ import "./login-Bjj8QvIN.js";
10
+ import { n as allDeps, r as readPackageJson, t as scanProject } from "./scan-CAObNRgc.js";
11
+ import "./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 { b as platformLabel, h as listProjects, n as createApplication, p as listApplications } from "./resources-Bf9O1JNM.js";
16
+ import "./org-CV8c849b.js";
17
+ import { r as resolveScopeFromKey } from "./bind-BSTAinn6.js";
18
+ import { A as requireApi, L as writeApp, N as requirePlatform, f as gitAvailable, j as projectPackageName, k as LoginRequiredError } from "./pipeline-DSCHL9KA.js";
19
+ import "./actions-Dt35nIi8.js";
20
+ import "./app-BU27SLPX.js";
21
+ import "./run-BVeZWbXx.js";
22
+ 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-CpHqjovS.js";
23
+ import "./dev-CuXa3J4Z.js";
20
24
  import pc from "picocolors";
25
+ import * as path from "node:path";
26
+ import * as os$1 from "node:os";
21
27
  import { promisify } from "node:util";
22
28
  import * as fs from "node:fs";
23
- import * as os$1 from "node:os";
24
- import * as path from "node:path";
25
29
  import { execFile } from "node:child_process";
26
30
 
27
31
  //#region src/core/paywalls/project/examples.ts
@@ -67,65 +71,6 @@ function adoptExamplePackage(target, name) {
67
71
  fs.writeFileSync(file, `${JSON.stringify(parsed, null, 2)}\n`);
68
72
  }
69
73
 
70
- //#endregion
71
- //#region src/core/paywalls/project/template.ts
72
- const packageJson = (name) => `${JSON.stringify({
73
- name,
74
- private: true,
75
- type: "module",
76
- scripts: {
77
- dev: "superwall dev",
78
- push: "superwall push",
79
- promote: "superwall promote",
80
- ship: "superwall publish",
81
- typecheck: "tsc -p tsconfig.json"
82
- },
83
- dependencies: {
84
- react: "19.1.0",
85
- "react-dom": "19.1.0",
86
- superwall: "latest"
87
- },
88
- devDependencies: {
89
- "@types/react": "^19.1.0",
90
- "@types/react-dom": "^19.1.0",
91
- typescript: "5.8.3"
92
- }
93
- }, null, 2)}\n`;
94
- const README = `# Your paywalls
95
-
96
- Each directory under \`paywalls/\` is one paywall — React pages in \`app/\`,
97
- products and name in \`config.ts\`.
98
-
99
- \`\`\`bash
100
- bun dev # open the studio and preview live
101
- bun run push # push versions to Superwall (production untouched)
102
- bun run ship # push and promote to production
103
- \`\`\`
104
- `;
105
- const TSCONFIG = "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"moduleResolution\": \"bundler\",\n \"jsx\": \"react-jsx\",\n \"strict\": true,\n \"isolatedModules\": true,\n \"resolveJsonModule\": true,\n \"skipLibCheck\": true,\n \"noUnusedLocals\": true,\n \"noUnusedParameters\": true,\n \"noFallthroughCasesInSwitch\": true,\n \"noEmit\": true,\n \"paths\": {\n \"@/*\": [\"./*\"]\n }\n },\n \"include\": [\".\"]\n}\n";
106
- const SUPERWALL_DTS = "// Generated by the Superwall CLI. Commit it; don't edit it, and don't delete it.\n// It is what makes `import hero from \"./assets/hero.jpg\"` typecheck and what\n// makes router.push(\"...\") autocomplete and reject typos. `superwall dev`\n// rewrites it whenever your app/ directories change.\n\n/// <reference types=\"superwall/assets\" />\n\ndeclare module \"superwall/navigation\" {\n interface SuperwallRoutes {\n index: true;\n }\n}\n\nexport type SuperwallRouteName = keyof import(\"superwall/navigation\").SuperwallRoutes;\n";
107
- const GITIGNORE = "node_modules/\n.superwall\n.env\n";
108
- const CONFIG = "import { definePaywall } from \"superwall/config\";\n\nexport default definePaywall({\n /** What this paywall is called on Superwall. Defaults to the directory name. */\n name: \"Pro\",\n\n /**\n * The products this paywall sells, as `reference: \"store identifier\"`.\n *\n * The identifiers below are placeholders — replace them with products that\n * exist in your Superwall dashboard. Nothing about a product is stored here:\n * price, period and trial all come from the store at runtime, which is why\n * `useProducts()` returns nothing until these match. Run `superwall dev`\n * against a connected app and the real prices appear, locally and on device.\n *\n * A reference the dashboard has no product for blocks publishing, so a\n * paywall can never ship with prices it cannot render.\n */\n products: {\n monthly: \"pro_999_month\",\n },\n});\n";
109
- const INDEX = "import { useActions, useHaptics, useProducts, usePurchase } from \"superwall/hooks\";\n\nexport default function Index() {\n const { close, restore } = useActions();\n const { getProduct } = useProducts();\n const { purchase } = usePurchase();\n const haptics = useHaptics();\n\n const monthly = getProduct(\"monthly\");\n\n return (\n <main className=\"page\">\n <button type=\"button\" className=\"close\" aria-label=\"Close\" onClick={close}>\n ✕\n </button>\n\n <div className=\"lede\">\n <h1>Go Pro</h1>\n <p>Everything unlocked, cancel whenever you like.</p>\n </div>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n className=\"button button--primary\"\n onClick={() => {\n haptics.light();\n purchase(\"monthly\");\n }}\n >\n {monthly?.variables.price ? `Subscribe · ${monthly.variables.price}` : \"Subscribe\"}\n </button>\n <button\n type=\"button\"\n className=\"link\"\n onClick={() => {\n haptics.light();\n restore();\n }}\n >\n Restore purchases\n </button>\n </div>\n </main>\n );\n}\n";
110
- const LAYOUT = "import type { PropsWithChildren } from \"react\";\nimport { useActions, useHaptics } from \"superwall/hooks\";\nimport \"./theme.css\";\n\nexport default function Layout({ children }: PropsWithChildren) {\n const { openUrl } = useActions();\n const haptics = useHaptics();\n\n return (\n <div className=\"shell\">\n {children}\n <footer className=\"built\">\n Built with\n <button\n type=\"button\"\n className=\"wordmark\"\n aria-label=\"Superwall\"\n onClick={() => {\n haptics.light();\n openUrl(\"https://superwall.com\");\n }}\n >\n <span className=\"wordmark-accent\">$UPER</span>WALL\n </button>\n </footer>\n </div>\n );\n}\n";
111
- const THEME = "@import url(\"https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&family=Roboto+Mono:wght@400..500&display=swap\");\n\n:root {\n --bg: #fdfef6;\n --surface: #f6f7ef;\n --elevated: #fff;\n --fg: #0c0b0a;\n --accent: #46d7d4;\n\n --fg-body: color-mix(in srgb, var(--fg) 70%, transparent);\n --fg-muted: color-mix(in srgb, var(--fg) 55%, transparent);\n --fg-caption: color-mix(in srgb, var(--fg) 50%, transparent);\n --border: color-mix(in srgb, var(--fg) 12%, transparent);\n --wash: color-mix(in srgb, var(--fg) 5%, transparent);\n\n --sans: Manrope, ui-sans-serif, system-ui, sans-serif;\n --mono: \"Roboto Mono\", ui-monospace, monospace;\n\n --sw-background: var(--bg);\n --sw-routes-height: auto;\n color-scheme: light;\n}\n\n:root.dark {\n --bg: #1c1b19;\n --surface: #232220;\n --elevated: #2a2926;\n --fg: #fdfef6;\n color-scheme: dark;\n}\n\n* {\n box-sizing: border-box;\n}\n\nbody {\n margin: 0;\n background: var(--bg);\n color: var(--fg);\n font-family: var(--sans);\n font-size: 0.9375rem;\n font-weight: 400;\n line-height: 1.5;\n letter-spacing: -0.01em;\n -webkit-font-smoothing: antialiased;\n}\n\nh1,\nh2,\nh3 {\n margin: 0;\n font-weight: 500;\n}\n\nh1 {\n font-size: clamp(2rem, 7vw, 2.5rem);\n line-height: 1.1;\n letter-spacing: -0.03em;\n}\n\nh2 {\n font-size: 1.5rem;\n line-height: 1.25;\n letter-spacing: -0.02em;\n}\n\nh3 {\n font-size: 1.25rem;\n line-height: 1.3;\n letter-spacing: -0.015em;\n}\n\np {\n margin: 0;\n color: var(--fg-body);\n}\n\ncode {\n font-family: var(--mono);\n font-size: 0.8125rem;\n}\n\n.shell {\n display: flex;\n min-height: 100vh;\n min-height: 100dvh;\n flex-direction: column;\n}\n\n.page {\n display: flex;\n min-height: 100%;\n flex-direction: column;\n gap: 24px;\n width: 100%;\n max-width: 44rem;\n margin: 0 auto;\n padding: 28px 20px 24px;\n}\n\n.lede {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.actions {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: auto;\n padding-top: 20px;\n}\n\n.button {\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n min-height: 44px;\n border: 1px solid var(--border);\n background: transparent;\n padding: 0 16px;\n color: var(--fg);\n font: inherit;\n font-size: 0.9375rem;\n font-weight: 500;\n cursor: pointer;\n transition:\n background-color 150ms ease,\n border-color 150ms ease;\n}\n\n.button:hover {\n background: var(--wash);\n}\n\n.button:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n}\n\n.button:disabled {\n cursor: default;\n opacity: 0.5;\n}\n\n.button--primary {\n border-color: var(--fg);\n background: var(--fg);\n color: var(--bg);\n}\n\n.button--primary:hover:not(:disabled) {\n background: color-mix(in srgb, var(--fg) 85%, transparent);\n}\n\n.link {\n align-self: center;\n border: 0;\n background: none;\n padding: 8px;\n color: var(--fg-muted);\n font: inherit;\n font-size: 0.8125rem;\n cursor: pointer;\n}\n\n.link:hover {\n color: var(--fg);\n}\n\n.link:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n}\n\n.close {\n align-self: flex-end;\n display: flex;\n width: 32px;\n height: 32px;\n align-items: center;\n justify-content: center;\n border: 0;\n background: none;\n padding: 0;\n color: var(--fg-muted);\n font: inherit;\n font-size: 1.25rem;\n line-height: 1;\n cursor: pointer;\n}\n\n.close:hover {\n color: var(--fg);\n}\n\n.close:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n}\n\n.built {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n gap: 6px;\n border-top: 1px solid var(--border);\n padding: 14px 20px;\n font-size: 0.75rem;\n color: var(--fg-caption);\n}\n\n.wordmark {\n border: 0;\n background: transparent;\n padding: 0;\n color: var(--fg);\n font: inherit;\n font-weight: 600;\n letter-spacing: 0.01em;\n cursor: pointer;\n}\n\n.wordmark:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: 2px;\n}\n\n.wordmark-accent {\n color: var(--accent);\n}\n\n@media (prefers-reduced-motion: reduce) {\n * {\n transition-duration: 1ms !important;\n }\n}\n";
112
- function writeTemplate(target, name) {
113
- const file = (relative$1, content) => {
114
- const destination = path.join(target, relative$1);
115
- fs.mkdirSync(path.dirname(destination), { recursive: true });
116
- fs.writeFileSync(destination, content);
117
- };
118
- file("package.json", packageJson(name ?? projectPackageName(target)));
119
- file("tsconfig.json", TSCONFIG);
120
- file("superwall.d.ts", SUPERWALL_DTS);
121
- file(".gitignore", GITIGNORE);
122
- file("README.md", README);
123
- file("paywalls/pro/config.ts", CONFIG);
124
- file("paywalls/pro/app/index.tsx", INDEX);
125
- file("paywalls/pro/app/layout.tsx", LAYOUT);
126
- file("paywalls/pro/app/theme.css", THEME);
127
- }
128
-
129
74
  //#endregion
130
75
  //#region src/commands/paywalls/create.ts
131
76
  const run = promisify(execFile);
@@ -138,7 +83,8 @@ const APP_PLATFORMS = [
138
83
  ];
139
84
  function alreadyAProject(root) {
140
85
  const target = path.join(root, "superwall");
141
- if (fs.existsSync(target) && fs.readdirSync(target).length > 0) return `\`${target}\` already exists — run \`superwall dev\` to open it.`;
86
+ if (isSuperwallProject(target)) return `\`${target}\` is already a superwall project — run \`superwall dev\` to open it.`;
87
+ if (fs.existsSync(path.join(target, "package.json"))) return `\`${target}\` already has a package.json that isn't a superwall project — move it aside first.`;
142
88
  for (const marker of ["superwall.config.ts", "superwall.lock"]) if (fs.existsSync(path.join(root, marker))) return `\`${root}\` is already a superwall project — run \`superwall dev\` to open it.`;
143
89
  const parsed = readPackageJson(root);
144
90
  if (parsed && "superwall" in allDeps(parsed)) return `\`${root}\` is already a superwall project — run \`superwall dev\` to open it.`;
@@ -271,8 +217,15 @@ async function createAppFlow(ui, api, root) {
271
217
  platform
272
218
  };
273
219
  }
274
- async function connectApp(ui, interactive, root, target, detected) {
220
+ async function connectApp(ui, interactive, root, target, detected, appId) {
275
221
  const api = await requireApi(interactive);
222
+ if (appId !== void 0) {
223
+ const app$1 = (await listApplications(api)).find((candidate) => String(candidate.id) === appId);
224
+ if (app$1 === void 0) throw new Error(`No app with id \`${appId}\` in this account — run \`superwall apps\` to list them.`);
225
+ writeApp(target, requirePlatform(app$1), String(app$1.id));
226
+ ui.success(`Pushes go to \`${app$1.name ?? app$1.id}\` — saved in superwall.lock, so commit that file.`);
227
+ return;
228
+ }
276
229
  if (detected?.existing.apiKey) {
277
230
  const scope = await resolveScopeFromKey(api, detected.existing.apiKey).catch(() => null);
278
231
  if (scope) {
@@ -314,6 +267,50 @@ async function connectApp(ui, interactive, root, target, detected) {
314
267
  writeApp(target, requirePlatform(app), String(app.id));
315
268
  ui.success(`Pushes go to \`${app.name ?? app.id}\` — saved in superwall.lock, so commit that file.`);
316
269
  }
270
+ const uniqueSurfaceId = (superwallDir, slug) => {
271
+ let candidate = slug;
272
+ for (let n = 2; fs.existsSync(path.join(superwallDir, "paywalls", candidate)); n += 1) candidate = `${slug}-${n}`;
273
+ return candidate;
274
+ };
275
+ async function addSurface(context, superwallDir) {
276
+ const { argv, interactive, ui } = context;
277
+ const where = path.relative(process.cwd(), superwallDir) || ".";
278
+ 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.`);
279
+ if (argv.app !== void 0) throw new Error(`\`${where}\` is already connected — its apps live in superwall.lock; drop \`--app\`.`);
280
+ const from = typeof argv.from === "string" || typeof argv.from === "number" ? String(argv.from) : void 0;
281
+ if (from !== void 0) {
282
+ const migration = migrationFor(superwallDir, (await scaffoldFromPaywall(ui, await requireApi(interactive), {
283
+ root: process.cwd(),
284
+ target: superwallDir,
285
+ paywallId: from,
286
+ newProject: false
287
+ })).id);
288
+ const rebuilt = migration !== void 0 && interactive && argv.yes !== true ? await offerMigration(ui, interactive, migration) : "later";
289
+ const opening = rebuilt === "agent" && migration !== void 0 && await askStudio(ui, interactive, migration.surfaceId);
290
+ ui.step("Next steps");
291
+ ui.list({ items: migrationNextSteps(opening, where, from, rebuilt).map((label) => ({ label })) });
292
+ if (opening && migration !== void 0) await startStudio(superwallDir, migration.surfaceId);
293
+ return;
294
+ }
295
+ const asked = interactive && argv.yes !== true ? await ui.text({
296
+ message: "What is the paywall called?",
297
+ initialValue: "Pro",
298
+ validate: (value) => value.trim() === "" ? "Give the paywall a name." : void 0
299
+ }) : "Pro";
300
+ if (asked === null) return;
301
+ const name = asked.trim();
302
+ const id = uniqueSurfaceId(superwallDir, slugOf(name));
303
+ writeSurfaceFiles(superwallDir, id, starterConfig(name));
304
+ ui.step(`Created ${where}/paywalls/${id} from the minimal template`);
305
+ ui.step("Next steps");
306
+ ui.list({ items: [{
307
+ label: `paywalls/${id}/config.ts`,
308
+ children: [{ label: "Point the product slot at a product that exists on your dashboard" }]
309
+ }, {
310
+ label: "superwall dev",
311
+ children: [{ label: "Open the studio and build the pages" }]
312
+ }] });
313
+ }
317
314
  const runCreate = defineCommand({
318
315
  name: "create",
319
316
  output: "human",
@@ -321,12 +318,36 @@ const runCreate = defineCommand({
321
318
  const { argv, interactive, ui } = context;
322
319
  ui.intro(`Superwall ${pc.dim("create")}`);
323
320
  const root = path.resolve(typeof argv.dir === "string" ? argv.dir : process.cwd());
321
+ const existing = projectDirOf(root);
322
+ if (existing !== void 0) {
323
+ await addSurface(context, existing);
324
+ return;
325
+ }
324
326
  const problem = alreadyAProject(root);
325
327
  if (problem !== void 0) throw new Error(problem);
326
328
  const target = path.join(root, "superwall");
329
+ const appId = typeof argv.app === "string" || typeof argv.app === "number" ? String(argv.app) : void 0;
330
+ if (appId !== void 0 && argv.connect === false) throw new Error("`--app` connects the project to that app — drop `--no-connect`.");
327
331
  const detection = detectHostApp(root);
332
+ const from = typeof argv.from === "string" || typeof argv.from === "number" ? String(argv.from) : void 0;
328
333
  let example = typeof argv.example === "string" ? argv.example : void 0;
329
- if (example === void 0 && interactive && argv.yes !== true) {
334
+ if (from !== void 0 && example !== void 0) throw new Error("`--from` rebuilds a dashboard paywall as the starter — drop `--example`.");
335
+ if (from !== void 0 && argv.connect === false) throw new Error("`--from` connects the project to the paywall's app — drop `--no-connect`.");
336
+ let originAppId;
337
+ let originBound = false;
338
+ let migration;
339
+ if (from !== void 0) {
340
+ const origin = await scaffoldFromPaywall(ui, await requireApi(interactive), {
341
+ root,
342
+ target,
343
+ paywallId: from,
344
+ newProject: true
345
+ });
346
+ if (origin.applicationId !== void 0 && origin.platform !== void 0) originBound = true;
347
+ else originAppId = origin.applicationId;
348
+ migration = migrationFor(target, origin.id);
349
+ }
350
+ if (from === void 0 && example === void 0 && interactive && argv.yes !== true) {
330
351
  const start = await ui.select({
331
352
  message: "Start from",
332
353
  options: [{
@@ -362,7 +383,7 @@ const runCreate = defineCommand({
362
383
  }
363
384
  }
364
385
  }
365
- if (example === void 0) {
386
+ if (from !== void 0) {} else if (example === void 0) {
366
387
  writeTemplate(target, projectPackageName(root));
367
388
  ui.step("Created superwall/ from the minimal template");
368
389
  } else {
@@ -383,26 +404,32 @@ const runCreate = defineCommand({
383
404
  }
384
405
  const detected = await detection;
385
406
  if (detected?.existing.fullyIntegrated) ui.info(`The Superwall SDK is already set up in \`${detected.app.name}\`.`);
386
- if ((argv.connect === false ? false : interactive && argv.yes !== true ? await ui.confirm({
407
+ if ((argv.connect === false || originBound ? false : interactive && argv.yes !== true && appId === void 0 && from === void 0 ? await ui.confirm({
387
408
  message: "Connect your Superwall account now? (Recommended)",
388
409
  initial: true
389
410
  }) : true) === true) try {
390
- await connectApp(ui, interactive, root, target, detected);
411
+ await connectApp(ui, interactive, root, target, detected, appId ?? originAppId);
391
412
  } catch (error) {
413
+ if (appId !== void 0) throw error;
392
414
  if (error instanceof LoginRequiredError) ui.info("Not signed in — the first `superwall push` will connect you.");
393
415
  else ui.warn(`${error instanceof Error ? error.message : String(error)}\nSkipping — the first \`superwall push\` connects you.`);
394
416
  }
395
417
  const manager = await detectPackageManager(root);
396
418
  const installed = argv.install === false ? false : await installDependencies(ui, target, manager);
397
419
  await initGit(ui, root);
398
- ui.step("Next steps");
399
- ui.list({ items: [{
400
- label: installed ? `cd superwall && ${devCommand(manager)}` : `cd superwall && ${manager} install && ${devCommand(manager)}`,
401
- children: [{ label: "Open the studio" }]
402
- }, ...detected?.existing.fullyIntegrated ? [] : [{
420
+ const rebuilt = migration !== void 0 && interactive && argv.yes !== true ? await offerMigration(ui, interactive, migration) : "later";
421
+ const opening = rebuilt === "agent" && migration !== void 0 && await askStudio(ui, interactive, migration.surfaceId);
422
+ const integrate = detected?.existing.fullyIntegrated ? [] : [{
403
423
  label: "superwall integrate",
404
424
  children: [{ label: "Set up the SDK in your app" }]
405
- }]] });
425
+ }];
426
+ const dev = installed ? `cd superwall && ${devCommand(manager)}` : `cd superwall && ${manager} install && ${devCommand(manager)}`;
427
+ ui.step("Next steps");
428
+ ui.list({ items: from === void 0 ? [{
429
+ label: dev,
430
+ children: [{ label: "Open the studio" }]
431
+ }, ...integrate] : [...migrationNextSteps(opening, "superwall", from, rebuilt).map((label) => ({ label })), ...integrate] });
432
+ if (opening && migration !== void 0) await startStudio(target, migration.surfaceId);
406
433
  }
407
434
  });
408
435