@superwall/cli 1.7.0 → 2.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 (229) hide show
  1. package/README.md +192 -52
  2. package/dist/{setup-Bxj22rYi.js → apple-CSzNTGHM.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-C3Q8DBU2.js} +98 -28
  6. package/dist/{bind-YrJvuRF9.js → bind-BumHTi9O.js} +38 -33
  7. package/dist/{build-DLoCW5Ri.js → build-Bpviiclc.js} +20 -26
  8. package/dist/client-BL0f_yGf.js +176 -0
  9. package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
  10. package/dist/config-BO1Y87kV.js +105 -0
  11. package/dist/create-BSfvpWoD.js +19 -0
  12. package/dist/{create-pkANt1Gs.js → create-BUcVG4Ab.js} +195 -169
  13. package/dist/{notification-url-DuKF2659.js → create-CfK3PeKA.js} +235 -539
  14. package/dist/doctor-BWqIYcMn.js +83 -0
  15. package/dist/{drivers-Qx9LxmRN.js → drivers-CPhdPkW5.js} +185 -172
  16. package/dist/entry.d.ts +0 -5
  17. package/dist/entry.js +28072 -1134
  18. package/dist/environment-eBXjELoN.js +58 -0
  19. package/dist/{existing-AVEfZu2A.js → existing-BltvQiX5.js} +12 -6
  20. package/dist/held-CPve03KJ.js +16 -0
  21. package/dist/held-DgnTFMl3.js +1112 -0
  22. package/dist/input-vi0bou04.js +42 -0
  23. package/dist/{integrate-brmhPG-S.js → integrate-BRsqoe01.js} +277 -254
  24. package/dist/log-NVhVe_oe.js +62 -0
  25. package/dist/login-BCEH5q0U.js +53 -0
  26. package/dist/login-BPOONe7n.js +16 -0
  27. package/dist/{login-Do4wFuLv.js → login-BbTIrCFT.js} +118 -55
  28. package/dist/lookup-rr1AkCJA.js +71 -0
  29. package/dist/migrate-C9X2Vz81.js +274 -0
  30. package/dist/notification-url-CV86qiKP.js +100 -0
  31. package/dist/{open-studio-DOw-6ydc.js → open-CcpXotHG.js} +34 -43
  32. package/dist/org-BQQDo7wm.js +35 -0
  33. package/dist/output-Ggzq5_-t.js +122 -0
  34. package/dist/paths-CRlU72cq.js +29 -0
  35. package/dist/playbook-DVMXN7fh.js +53 -0
  36. package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
  37. package/dist/promote-Da8xctzy.js +91 -0
  38. package/dist/push-BV-grvQg.js +22 -0
  39. package/dist/push-D6R9icWN.js +495 -0
  40. package/dist/registry-BYVD-_h6.js +10385 -0
  41. package/dist/{reports-CfJqoava.js → reports-D_qbl7_u.js} +7 -6
  42. package/dist/{resources-Bf9O1JNM.js → resources-DLON3-61.js} +162 -55
  43. package/dist/{run-DsVZ5snL.js → run-Co-BwhOg.js} +16 -22
  44. package/dist/scan-B88OlWOt.js +4 -0
  45. package/dist/{scan-zKsddO72.js → scan-CKuk-_6W.js} +48 -37
  46. package/dist/scope-DV22_Ufm.js +198 -0
  47. package/dist/screenshot-file-tVBfUEIi.js +16 -0
  48. package/dist/{selection-CxZoX4NT.js → selection-C2_KbLuo.js} +100 -51
  49. package/dist/server-C4f6ccUr.js +22 -0
  50. package/dist/{dev-DmB3XqaJ.js → server-D0d2oP-5.js} +86 -94
  51. package/dist/session-B-Uz0cQ7.js +40 -0
  52. package/dist/session-BuvArt1j.js +6 -0
  53. package/dist/session-C4rbE3VS.js +796 -0
  54. package/dist/skills/animate-onboarding/SKILL.md +467 -0
  55. package/dist/skills/animate-onboarding/references/engine.md +494 -0
  56. package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
  57. package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
  58. package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
  59. package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
  60. package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  61. package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
  62. package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
  63. package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  64. package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
  65. package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
  66. package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
  67. package/dist/skills/animate-onboarding/references/performance.md +41 -0
  68. package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
  69. package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  70. package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  71. package/dist/skills/index.json +37 -0
  72. package/dist/skills/mobile-design/SKILL.md +447 -0
  73. package/dist/skills/mobile-design/references/responsive.md +162 -0
  74. package/dist/skills/onboarding-questions/SKILL.md +231 -0
  75. package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
  76. package/dist/skills/onboarding-questions/references/craft.md +142 -0
  77. package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
  78. package/dist/skills/superwall/SKILL.md +82 -9
  79. package/dist/skills/superwall/references/api.md +153 -37
  80. package/dist/skills/superwall/references/apple-setup.md +316 -0
  81. package/dist/skills/superwall/references/asc.md +74 -38
  82. package/dist/skills/superwall/references/data-analytics.md +55 -21
  83. package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
  84. package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
  85. package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
  86. package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
  87. package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
  88. package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
  89. package/dist/skills/superwall/workflows/placements/android.md +2 -2
  90. package/dist/skills/superwall/workflows/placements/expo.md +2 -2
  91. package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
  92. package/dist/skills/superwall/workflows/placements/ios.md +2 -2
  93. package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
  94. package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
  95. package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
  96. package/dist/skills/superwall/workflows/review/playbook.md +1 -1
  97. package/dist/skills/superwall-editor/SKILL.md +61 -0
  98. package/dist/skills/superwall-editor/references/cli.md +135 -0
  99. package/dist/skills/superwall-editor/references/design.md +51 -0
  100. package/dist/skills/superwall-editor/references/native-elements.md +171 -0
  101. package/dist/skills/superwall-editor/references/workflow.md +65 -0
  102. package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
  103. package/dist/skills/superwall-framework/SKILL.md +85 -31
  104. package/dist/skills/superwall-framework/references/cli.md +58 -27
  105. package/dist/skills/superwall-framework/references/examples.md +4 -3
  106. package/dist/skills/superwall-framework/references/layout.md +64 -9
  107. package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
  108. package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
  109. package/dist/skills/wwdc/SKILL.md +22 -0
  110. package/dist/skills/wwdc/references/docs.md +52 -0
  111. package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
  112. package/dist/skills-CLGJuMnF.js +14 -0
  113. package/dist/{skills-DPzlnfCK.js → skills-CZcpnEnG.js} +100 -122
  114. package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
  115. package/dist/spinner-C2U6QBJ9.js +294 -0
  116. package/dist/storage-6h9vyiAz.js +31 -0
  117. package/dist/storage-CerJ5KLP.d.ts +16 -0
  118. package/dist/storekit-CK9JmM2D.js +16 -0
  119. package/dist/storekit-CinJra3V.js +47 -0
  120. package/dist/telemetry-DKyDhURo.js +56 -0
  121. package/dist/theme-DUsCh-Vd.js +25 -0
  122. package/dist/timing-BVxPrYq3.js +5 -0
  123. package/dist/{token-C0it-Xh7.js → token-DaxQgQkv.js} +6 -38
  124. package/dist/tools-skills/animate-onboarding/SKILL.md +467 -0
  125. package/dist/tools-skills/animate-onboarding/references/engine.md +494 -0
  126. package/dist/tools-skills/animate-onboarding/references/framework/Question.tsx +71 -0
  127. package/dist/tools-skills/animate-onboarding/references/framework/README.md +40 -0
  128. package/dist/tools-skills/animate-onboarding/references/framework/answers.ts +19 -0
  129. package/dist/tools-skills/animate-onboarding/references/framework/flow.ts +80 -0
  130. package/dist/tools-skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  131. package/dist/tools-skills/animate-onboarding/references/framework/layout.tsx +113 -0
  132. package/dist/tools-skills/animate-onboarding/references/framework/motion.css +559 -0
  133. package/dist/tools-skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  134. package/dist/tools-skills/animate-onboarding/references/handoffs.md +375 -0
  135. package/dist/tools-skills/animate-onboarding/references/imageReady.ts +92 -0
  136. package/dist/tools-skills/animate-onboarding/references/morphFrame.ts +356 -0
  137. package/dist/tools-skills/animate-onboarding/references/performance.md +41 -0
  138. package/dist/tools-skills/animate-onboarding/references/web-runtime/README.md +17 -0
  139. package/dist/tools-skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  140. package/dist/tools-skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  141. package/dist/tools-skills/mobile-design/SKILL.md +447 -0
  142. package/dist/tools-skills/mobile-design/references/responsive.md +162 -0
  143. package/dist/tools-skills/onboarding-questions/SKILL.md +231 -0
  144. package/dist/tools-skills/onboarding-questions/references/arpu-questions.md +139 -0
  145. package/dist/tools-skills/onboarding-questions/references/craft.md +142 -0
  146. package/dist/tools-skills/onboarding-questions/references/example-reflective.md +117 -0
  147. package/dist/tools-skills/superwall/SKILL.md +263 -0
  148. package/dist/tools-skills/superwall/references/api.md +303 -0
  149. package/dist/tools-skills/superwall/references/asa.md +166 -0
  150. package/dist/tools-skills/superwall/references/asc.md +95 -0
  151. package/dist/tools-skills/superwall/references/dashboard-links.md +57 -0
  152. package/dist/tools-skills/superwall/references/data-analytics.md +896 -0
  153. package/dist/tools-skills/superwall/references/docs.md +51 -0
  154. package/dist/tools-skills/superwall/references/sdk-integration.md +104 -0
  155. package/dist/tools-skills/superwall/references/sdk-source.md +18 -0
  156. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +76 -0
  157. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +100 -0
  158. package/dist/tools-skills/superwall/workflows/integrate/android.md +292 -0
  159. package/dist/tools-skills/superwall/workflows/integrate/expo.md +272 -0
  160. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +285 -0
  161. package/dist/tools-skills/superwall/workflows/integrate/ios.md +314 -0
  162. package/dist/tools-skills/superwall/workflows/integrate/playbook.md +83 -0
  163. package/dist/tools-skills/superwall/workflows/integrate/react-native.md +246 -0
  164. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +229 -0
  165. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +78 -0
  166. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +227 -0
  167. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +414 -0
  168. package/dist/tools-skills/superwall/workflows/placements/android.md +175 -0
  169. package/dist/tools-skills/superwall/workflows/placements/expo.md +161 -0
  170. package/dist/tools-skills/superwall/workflows/placements/flutter.md +139 -0
  171. package/dist/tools-skills/superwall/workflows/placements/ios.md +165 -0
  172. package/dist/tools-skills/superwall/workflows/placements/playbook.md +69 -0
  173. package/dist/tools-skills/superwall/workflows/placements/react-native.md +145 -0
  174. package/dist/tools-skills/superwall/workflows/placements/strategy.md +222 -0
  175. package/dist/tools-skills/superwall/workflows/review/android.md +120 -0
  176. package/dist/tools-skills/superwall/workflows/review/expo.md +100 -0
  177. package/dist/tools-skills/superwall/workflows/review/flutter.md +99 -0
  178. package/dist/tools-skills/superwall/workflows/review/ios.md +108 -0
  179. package/dist/tools-skills/superwall/workflows/review/playbook.md +70 -0
  180. package/dist/tools-skills/superwall/workflows/review/react-native.md +100 -0
  181. package/dist/tools-skills/superwall-editor/SKILL.md +113 -0
  182. package/dist/tools-skills/superwall-editor/references/cli.md +135 -0
  183. package/dist/tools-skills/superwall-editor/references/design.md +51 -0
  184. package/dist/tools-skills/superwall-editor/references/native-elements.md +171 -0
  185. package/dist/tools-skills/superwall-editor/references/workflow.md +65 -0
  186. package/dist/tools-skills/superwall-editor/scripts/sw-editor.sh +662 -0
  187. package/dist/tools-skills/wwdc/SKILL.md +22 -0
  188. package/dist/tools-skills/wwdc/references/docs.md +52 -0
  189. package/dist/tools-skills/wwdc/scripts/wwdc.sh +266 -0
  190. package/dist/tools.d.ts +96 -0
  191. package/dist/tools.js +11360 -0
  192. package/dist/ui-D_qf3Gvw.js +53 -0
  193. package/dist/upgrade-DPo0a4Es.js +117 -0
  194. package/dist/upgrade-ffseQDMx.js +7 -0
  195. package/package.json +10 -5
  196. package/dist/api-CZzirVMj.js +0 -151
  197. package/dist/api-output-aJNw7Syy.js +0 -20
  198. package/dist/app-DH6U8yuI.js +0 -190
  199. package/dist/asa-C-sQzPPn.js +0 -1194
  200. package/dist/asc-1ZBJ6DwS.js +0 -778
  201. package/dist/auth-YRhlV3DE.js +0 -140
  202. package/dist/billing-CCYHdApx.js +0 -80
  203. package/dist/bundle-id-CKxl_026.js +0 -121
  204. package/dist/command-CMIz81Da.js +0 -301
  205. package/dist/dev-DZy6pOnB.js +0 -22
  206. package/dist/doctor-H-hf-Yww.js +0 -88
  207. package/dist/feedback-CKf-rpBW.js +0 -152
  208. package/dist/hosted-CXe9TrWx.js +0 -32
  209. package/dist/migrate-C9ERDR6y.js +0 -284
  210. package/dist/org-sj7uyvp-.js +0 -40
  211. package/dist/output-C4o2gJ1K.js +0 -146
  212. package/dist/params-l3CrvRtR.js +0 -51
  213. package/dist/pipeline-BqzqZhX1.js +0 -977
  214. package/dist/print-skill-ZojRSybs.js +0 -74
  215. package/dist/promote-BG8X4Nv_.js +0 -88
  216. package/dist/publish-sxLh-G4G.js +0 -35
  217. package/dist/push-bQ6Vxtg8.js +0 -35
  218. package/dist/query-_FbybaH-.js +0 -53
  219. package/dist/resource-CGIwSd29.js +0 -323
  220. package/dist/revenue-provider-ebsRINY8.js +0 -100
  221. package/dist/scope-BvzD-kO4.js +0 -223
  222. package/dist/skills-D_R-lEsK.js +0 -64
  223. package/dist/spinner-TWa0hia6.js +0 -18
  224. package/dist/storekit-Cj9Cpjcz.js +0 -29
  225. package/dist/telemetry-DeA1mvnT.js +0 -169
  226. package/dist/ui-Dy0b-9L8.js +0 -27738
  227. package/dist/update-B2fWIc4q.js +0 -59
  228. package/dist/upgrade-BmzkTKrh.js +0 -72
  229. /package/dist/{devtools-8EgLo86w.js → devtools-pBl_vt03.js} +0 -0
@@ -1,8 +1,10 @@
1
- import { g as Integration } from "./output-C4o2gJ1K.js";
2
- import { i as loadBundledSkill } from "./skills-DPzlnfCK.js";
1
+ import { f as Integration } from "./environment-eBXjELoN.js";
2
+ import { i as readPackageJson, r as allDeps } from "./scan-CKuk-_6W.js";
3
+ import { d as readBundledSkill } from "./skills-CZcpnEnG.js";
4
+ import { readFileSync } from "node:fs";
5
+ import fg from "fast-glob";
3
6
 
4
- //#region src/core/agent/actions.ts
5
- /** Skill reference file per framework, so an agent only sees its own platform's docs. */
7
+ //#region src/core/workflows/agent/actions.ts
6
8
  const FRAMEWORK_REF = {
7
9
  [Integration.swift]: "ios",
8
10
  [Integration.android]: "android",
@@ -25,84 +27,78 @@ const READ_CAPABILITIES = {
25
27
  network: true,
26
28
  shell: "read-only"
27
29
  };
28
- const ACTIONS = [
29
- {
30
+ const actionById = {
31
+ integrate: {
30
32
  id: "integrate",
31
33
  title: "Integrate the SDK",
32
34
  hint: "Install + configure the Superwall SDK",
33
35
  runningLabel: "Starting the integration",
34
36
  successLabel: "Integration complete",
35
- requiresIntegration: false,
36
37
  requiresOrgKey: false,
37
38
  outputMode: "silent",
38
39
  capabilities: WRITE_CAPABILITIES,
39
- vars: (ctx) => ({ skill: loadBundledSkill("superwall-integrate", FRAMEWORK_REF[ctx.app.framework.integration]) })
40
+ vars: (ctx) => ({ skill: readBundledSkill("superwall-integrate", FRAMEWORK_REF[ctx.app.framework.integration]) })
40
41
  },
41
- {
42
+ review: {
42
43
  id: "review",
43
44
  title: "Review the setup",
44
45
  hint: "Audit the SDK, purchasing, identity, deep links, placements & dashboard",
45
46
  runningLabel: "Reviewing your Superwall setup",
46
47
  successLabel: "Setup review complete",
47
- requiresIntegration: true,
48
48
  requiresOrgKey: false,
49
49
  outputMode: "report",
50
50
  capabilities: READ_CAPABILITIES,
51
- vars: (ctx) => ({ skill: loadBundledSkill("superwall-review", FRAMEWORK_REF[ctx.app.framework.integration]) })
51
+ vars: (ctx) => ({ skill: readBundledSkill("superwall-review", FRAMEWORK_REF[ctx.app.framework.integration]) })
52
52
  },
53
- {
53
+ "review-fix": {
54
54
  id: "review-fix",
55
55
  title: "Fix setup issues",
56
56
  hint: "Apply verified, safe fixes from the setup review",
57
57
  runningLabel: "Fixing your Superwall setup",
58
58
  successLabel: "Setup fixes complete",
59
- requiresIntegration: true,
60
59
  requiresOrgKey: false,
61
60
  outputMode: "silent",
62
61
  capabilities: WRITE_CAPABILITIES,
63
62
  vars: (ctx) => ({
64
63
  prior_report: ctx.priorReport ?? "",
65
- skill: loadBundledSkill("superwall-review", FRAMEWORK_REF[ctx.app.framework.integration])
64
+ skill: readBundledSkill("superwall-review", FRAMEWORK_REF[ctx.app.framework.integration])
66
65
  })
67
66
  },
68
- {
67
+ "placements-review": {
69
68
  id: "placements-review",
70
69
  title: "Review placements",
71
70
  hint: "Audit every register() call + positioning",
72
71
  runningLabel: "Reviewing placements",
73
72
  successLabel: "Placement review complete",
74
- requiresIntegration: true,
75
73
  requiresOrgKey: false,
76
74
  outputMode: "report",
77
75
  capabilities: READ_CAPABILITIES,
78
76
  vars: (ctx) => ({
79
77
  campaigns: ctx.campaigns ?? "",
80
- skill: loadBundledSkill("superwall-placements", ["strategy", FRAMEWORK_REF[ctx.app.framework.integration]])
78
+ skill: readBundledSkill("superwall-placements", ["strategy", FRAMEWORK_REF[ctx.app.framework.integration]])
81
79
  })
82
80
  },
83
- {
81
+ "placements-implement": {
84
82
  id: "placements-implement",
85
83
  title: "Implement placements",
86
84
  hint: "Add register() calls at the right feature gates",
87
85
  runningLabel: "Implementing placements",
88
86
  successLabel: "Placements implemented",
89
- requiresIntegration: true,
90
87
  requiresOrgKey: false,
91
88
  outputMode: "silent",
92
89
  capabilities: WRITE_CAPABILITIES,
93
90
  vars: (ctx) => ({
94
91
  prior_report: ctx.priorReport ?? "",
95
92
  campaigns: ctx.campaigns ?? "",
96
- skill: loadBundledSkill("superwall-placements", ["strategy", FRAMEWORK_REF[ctx.app.framework.integration]])
93
+ skill: readBundledSkill("superwall-placements", ["strategy", FRAMEWORK_REF[ctx.app.framework.integration]])
97
94
  })
98
95
  },
99
- {
96
+ "dashboard-setup": {
100
97
  id: "dashboard-setup",
101
98
  title: "Set up the dashboard",
102
99
  hint: "Create a campaign + placement so paywalls present",
103
100
  runningLabel: "Setting up the dashboard",
104
101
  successLabel: "Dashboard configured",
105
- requiresIntegration: false,
106
102
  requiresOrgKey: true,
107
103
  outputMode: "report",
108
104
  capabilities: {
@@ -111,17 +107,16 @@ const ACTIONS = [
111
107
  shell: "unrestricted"
112
108
  },
113
109
  vars: (ctx) => ({
114
- skill: loadBundledSkill("superwall-dashboard"),
110
+ skill: readBundledSkill("superwall-dashboard"),
115
111
  app_key: ctx.apiKey || "(the app you're working on)"
116
112
  })
117
113
  },
118
- {
114
+ migrate: {
119
115
  id: "migrate",
120
116
  title: "Migrate to Superwall",
121
117
  hint: "Move products, entitlements & paywalls off your current provider",
122
118
  runningLabel: "Migrating to Superwall",
123
119
  successLabel: "Migration complete",
124
- requiresIntegration: false,
125
120
  requiresOrgKey: false,
126
121
  outputMode: "report",
127
122
  capabilities: WRITE_CAPABILITIES,
@@ -130,12 +125,87 @@ const ACTIONS = [
130
125
  return {
131
126
  provider,
132
127
  goal: ctx.migrateIntent === "paywalls" ? `paywalls only, keep ${provider} for billing` : "full migration",
133
- skill: loadBundledSkill("superwall-migrate", PROVIDER_REF[provider.toLowerCase()])
128
+ skill: readBundledSkill("superwall-migrate", PROVIDER_REF[provider.toLowerCase()])
134
129
  };
135
130
  }
136
131
  }
132
+ };
133
+ const ACTIONS = Object.values(actionById);
134
+
135
+ //#endregion
136
+ //#region src/core/codebase/billing.ts
137
+ const IGNORE = [
138
+ "**/node_modules/**",
139
+ "**/.git/**",
140
+ "**/Pods/**",
141
+ "**/build/**",
142
+ "**/.build/**",
143
+ "**/dist/**"
137
144
  ];
138
- const actionById = Object.fromEntries(ACTIONS.map((a) => [a.id, a]));
145
+ function detectBilling(app) {
146
+ const deps = allDeps(readPackageJson(app.path));
147
+ const inDeps = (names) => names.some((n) => n in deps);
148
+ let revenueCat = inDeps([
149
+ "react-native-purchases",
150
+ "@revenuecat/purchases-js",
151
+ "purchases-capacitor",
152
+ "purchases_flutter"
153
+ ]);
154
+ let adapty = inDeps(["react-native-adapty", "adapty_flutter"]);
155
+ let qonversion = inDeps(["react-native-qonversion", "qonversion_flutter"]);
156
+ const manifests = fg.sync([
157
+ "**/Package.resolved",
158
+ "**/Package.swift",
159
+ "**/Project.swift",
160
+ "**/Podfile",
161
+ "**/Podfile.lock",
162
+ "**/project.pbxproj",
163
+ "**/*.gradle",
164
+ "**/*.gradle.kts",
165
+ "**/pubspec.yaml",
166
+ "**/pubspec.lock"
167
+ ], {
168
+ cwd: app.path,
169
+ ignore: IGNORE,
170
+ absolute: true,
171
+ deep: 5
172
+ });
173
+ for (const f of manifests) {
174
+ let c;
175
+ try {
176
+ c = readFileSync(f, "utf8");
177
+ } catch {
178
+ continue;
179
+ }
180
+ if (/RevenueCat|\bPurchases\b|purchases_flutter/i.test(c)) revenueCat = true;
181
+ if (/Adapty/i.test(c)) adapty = true;
182
+ if (/Qonversion/i.test(c)) qonversion = true;
183
+ }
184
+ if (!revenueCat || !adapty || !qonversion) {
185
+ const sources = fg.sync(["**/*.swift", "**/*.kt"], {
186
+ cwd: app.path,
187
+ ignore: IGNORE,
188
+ absolute: true,
189
+ deep: 6
190
+ }).slice(0, 600);
191
+ for (const f of sources) {
192
+ let c;
193
+ try {
194
+ c = readFileSync(f, "utf8");
195
+ } catch {
196
+ continue;
197
+ }
198
+ if (/import RevenueCat|com\.revenuecat/.test(c)) revenueCat = true;
199
+ if (/import Adapty|com\.adapty/.test(c)) adapty = true;
200
+ if (/import Qonversion|com\.qonversion/.test(c)) qonversion = true;
201
+ }
202
+ }
203
+ return {
204
+ revenueCat,
205
+ adapty,
206
+ qonversion
207
+ };
208
+ }
139
209
 
140
210
  //#endregion
141
- export { FRAMEWORK_REF as n, actionById as r, ACTIONS as t };
211
+ export { FRAMEWORK_REF as n, actionById as r, detectBilling as t };
@@ -1,7 +1,8 @@
1
- import { g as Integration } from "./output-C4o2gJ1K.js";
2
- import { n as ui } from "./ui-Dy0b-9L8.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-sj7uyvp-.js";
1
+ import { f as Integration } from "./environment-eBXjELoN.js";
2
+ import { n as withSpinner } from "./spinner-C2U6QBJ9.js";
3
+ import { n as ui } from "./ui-D_qf3Gvw.js";
4
+ import { n as createApplication, p as listProjects, s as createProject, v as platformLabel } from "./resources-DLON3-61.js";
5
+ import { n as orgForNewProject } from "./org-BQQDo7wm.js";
5
6
 
6
7
  //#region src/core/account/bind.ts
7
8
  const NEW = "__new__";
@@ -16,18 +17,18 @@ function platformForIntegration(integration) {
16
17
  case Integration.expo:
17
18
  case Integration.reactNative: return "react_native";
18
19
  case Integration.web: return "web";
19
- default: return "ios";
20
20
  }
21
21
  }
22
22
  async function resolveAppBinding(api, opts) {
23
- const projects = await loading("Loading your projects", () => listProjects(api));
23
+ const projects = await withSpinner("Loading your projects", () => listProjects(api));
24
24
  let lastProjectId;
25
25
  for (;;) {
26
26
  const project = await pickProject(api, projects, opts.appName, lastProjectId);
27
27
  if (project === "cancel") return null;
28
28
  lastProjectId = String(project.id);
29
- const app = await pickApp(api, project, opts);
30
- if (app === "back") continue;
29
+ const picked = await pickApp(api, project, opts);
30
+ if (picked === "back") continue;
31
+ const { app } = picked;
31
32
  if (!app.public_api_key) {
32
33
  ui.warn(`\`${app.name ?? app.id}\` has no SDK key yet - pick another or add a new app.`);
33
34
  return null;
@@ -35,7 +36,7 @@ async function resolveAppBinding(api, opts) {
35
36
  return {
36
37
  apiKey: app.public_api_key,
37
38
  app,
38
- projectId: String(project.id),
39
+ projectId: String(picked.project.id),
39
40
  applicationId: String(app.id)
40
41
  };
41
42
  }
@@ -56,7 +57,8 @@ async function resolveScopeFromKey(api, publicApiKey) {
56
57
  }
57
58
  async function pickProject(api, projects, defaultName, preselect) {
58
59
  for (;;) {
59
- if (projects.length === 0) {
60
+ const first = projects[0];
61
+ if (!first) {
60
62
  const created = await createProjectFlow(api, defaultName);
61
63
  return created === "back" ? "cancel" : created;
62
64
  }
@@ -70,7 +72,7 @@ async function pickProject(api, projects, defaultName, preselect) {
70
72
  value: NEW,
71
73
  label: "+ Create a new project"
72
74
  }],
73
- initialValue: preselect ?? String(projects[0].id),
75
+ initialValue: preselect ?? String(first.id),
74
76
  footer: CANCEL,
75
77
  transient: true
76
78
  });
@@ -80,14 +82,16 @@ async function pickProject(api, projects, defaultName, preselect) {
80
82
  if (created === "back") continue;
81
83
  return created;
82
84
  }
83
- return projects.find((p) => String(p.id) === sel);
85
+ const picked = projects.find((p) => String(p.id) === sel);
86
+ if (picked) return picked;
84
87
  }
85
88
  }
86
89
  async function pickApp(api, project, opts) {
87
90
  for (;;) {
88
91
  const apps = project.applications ?? [];
89
92
  const label = platformLabel(opts.platform);
90
- if (apps.length === 0) {
93
+ const first = apps[0];
94
+ if (!first) {
91
95
  if (await ui.select({
92
96
  message: `No apps in \`${project.name ?? "this project"}\` yet.`,
93
97
  options: [{
@@ -101,10 +105,13 @@ async function pickApp(api, project, opts) {
101
105
  }) === null) return "back";
102
106
  const created = await createAppFlow(api, project, opts);
103
107
  if (created === "back") continue;
104
- return created;
108
+ return {
109
+ project,
110
+ app: created
111
+ };
105
112
  }
106
113
  const platformTaken = apps.some((a) => a.platform === opts.platform);
107
- const match = apps.find((a) => a.platform === opts.platform) ?? apps[0];
114
+ const match = apps.find((a) => a.platform === opts.platform) ?? first;
108
115
  const options = apps.map((a) => ({
109
116
  value: String(a.id),
110
117
  label: a.name ?? String(a.id),
@@ -129,20 +136,30 @@ async function pickApp(api, project, opts) {
129
136
  if (sel === NEW) {
130
137
  const created = await createAppFlow(api, project, opts);
131
138
  if (created === "back") continue;
132
- return created;
139
+ return {
140
+ project,
141
+ app: created
142
+ };
133
143
  }
134
144
  if (sel === NEW_PROJECT) {
135
145
  const fresh = await createProjectFlow(api, opts.appName);
136
146
  if (fresh === "back") continue;
137
147
  const created = await createAppFlow(api, fresh, opts);
138
148
  if (created === "back") continue;
139
- return created;
149
+ return {
150
+ project: fresh,
151
+ app: created
152
+ };
140
153
  }
141
- return apps.find((a) => String(a.id) === sel);
154
+ const picked = apps.find((a) => String(a.id) === sel);
155
+ if (picked) return {
156
+ project,
157
+ app: picked
158
+ };
142
159
  }
143
160
  }
144
161
  async function createProjectFlow(api, defaultName) {
145
- await requireOrg(api, true);
162
+ const organizationId = await orgForNewProject(api, true);
146
163
  const name = await ui.text({
147
164
  message: "Name your new project",
148
165
  placeholder: defaultName,
@@ -151,7 +168,7 @@ async function createProjectFlow(api, defaultName) {
151
168
  transient: true
152
169
  });
153
170
  if (name === null) return "back";
154
- const created = await loading("Creating project", () => createProject(api, name.trim()));
171
+ const created = await withSpinner("Creating project", () => createProject(api, name.trim(), organizationId));
155
172
  ui.success(`Created project \`${created.name ?? name.trim()}\``);
156
173
  return {
157
174
  id: created.id,
@@ -179,7 +196,7 @@ async function createAppFlow(api, project, opts) {
179
196
  });
180
197
  if (bundle === null) continue;
181
198
  const bundleId = bundle.trim() || opts.bundleId;
182
- const parent = await loading(`Adding the ${label} app`, () => createApplication(api, { projectId: String(project.id) }, {
199
+ const parent = await withSpinner(`Adding the ${label} app`, () => createApplication(api, { projectId: String(project.id) }, {
183
200
  name: name.trim(),
184
201
  platform: opts.platform,
185
202
  bundleId
@@ -197,18 +214,6 @@ function appCountHint(p) {
197
214
  const n = (p.applications ?? []).length;
198
215
  return `${n} app${n === 1 ? "" : "s"}`;
199
216
  }
200
- async function loading(label, work) {
201
- const spin = ui.spinner();
202
- spin.start(label);
203
- try {
204
- const result = await work();
205
- spin.stop(label);
206
- return result;
207
- } catch (e) {
208
- spin.stop("Failed");
209
- throw e;
210
- }
211
- }
212
217
 
213
218
  //#endregion
214
219
  export { resolveAppBinding as n, resolveScopeFromKey as r, platformForIntegration as t };
@@ -1,23 +1,24 @@
1
- import { x as VERSION } from "./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 { n as ui } from "./ui-Dy0b-9L8.js";
7
- import "./resources-Bf9O1JNM.js";
8
- import { A as assetBaseUrl, _ as collectProjectDeclarations, k as loadFramework, m as took, n as parseIds, o as requireProject, r as projectDir, s as selectSurfaces, u as kb, v as writeProjectTypes, x as readLock } from "./selection-CxZoX4NT.js";
9
- import pc from "picocolors";
10
- import * as path from "node:path";
1
+ import "./token-DaxQgQkv.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import { _ as VERSION } from "./environment-eBXjELoN.js";
4
+ import "./storage-6h9vyiAz.js";
5
+ import "./client-BL0f_yGf.js";
6
+ import "./config-BO1Y87kV.js";
7
+ import { n as ui } from "./ui-D_qf3Gvw.js";
8
+ import "./resources-DLON3-61.js";
9
+ import { N as resolveFramework, P as assetBaseUrl, a as resolveProjectDir, d as kb, h as took, i as requireProject, n as parseIds, s as selectSurfaces, v as collectProjectDeclarations, w as readLock, y as writeProjectTypes } from "./selection-C2_KbLuo.js";
11
10
  import * as fs from "node:fs";
11
+ import * as path from "node:path";
12
+ import pc from "picocolors";
12
13
 
13
- //#region src/commands/paywalls/build.ts
14
+ //#region src/core/paywalls/pipeline/build.ts
14
15
  const PLATFORMS = new Set([
15
16
  "ios",
16
17
  "android",
17
18
  "web"
18
19
  ]);
19
- function parseBuildPlatforms(value) {
20
- const platforms = parseIds(value);
20
+ function parseBuildPlatforms(values) {
21
+ const platforms = parseIds(values);
21
22
  for (const platform of platforms) if (!PLATFORMS.has(platform)) throw new Error(`Unknown platform "${platform}" — use ios, android or web.`);
22
23
  return platforms.length === 0 ? [void 0] : platforms;
23
24
  }
@@ -33,13 +34,13 @@ function boundAssetBaseUrl(project, surface, platform) {
33
34
  return assetBaseUrl(applicationId);
34
35
  }
35
36
  async function runBuildPipeline(context, options = {}) {
36
- const dir = projectDir(context);
37
- const framework = await (options.load ?? loadFramework)(dir);
37
+ const dir = resolveProjectDir(options.dir);
38
+ const framework = await (options.load ?? resolveFramework)(dir);
38
39
  const project = requireProject(framework.discoverProject(dir), dir);
39
40
  writeProjectTypes(project, (await collectProjectDeclarations(framework, project.root)).products);
40
- const surfaces = selectSurfaces(project, context.argv.id);
41
- const platforms = parseBuildPlatforms(context.argv.platform);
42
- const out = path.resolve(typeof context.argv.out === "string" && context.argv.out !== "" ? context.argv.out : path.join(project.superwallDir, ".superwall", "build"));
41
+ const surfaces = selectSurfaces(project, options.ids ?? []);
42
+ const platforms = parseBuildPlatforms(options.platforms ?? []);
43
+ const out = path.resolve(options.out ?? path.join(project.superwallDir, ".superwall", "build"));
43
44
  context.output.render({
44
45
  kind: "intro",
45
46
  text: `Superwall ${pc.dim(`v${VERSION}`)}`
@@ -75,13 +76,6 @@ async function runBuildPipeline(context, options = {}) {
75
76
  if (context.json) context.output.data({ builds: outcomes });
76
77
  return outcomes;
77
78
  }
78
- const runBuild = defineCommand({
79
- name: "build",
80
- output: "both",
81
- async run(context) {
82
- await runBuildPipeline(context);
83
- }
84
- });
85
79
 
86
80
  //#endregion
87
- export { outputFile, parseBuildPlatforms, runBuild, runBuildPipeline };
81
+ export { outputFile, parseBuildPlatforms, runBuildPipeline };
@@ -0,0 +1,176 @@
1
+ import { n as resolveAuthToken, r as NotLoggedInError } from "./token-DaxQgQkv.js";
2
+ import { r as resolveApiHost, t as readSession } from "./storage-6h9vyiAz.js";
3
+
4
+ //#region src/core/api/client.ts
5
+ const BODY_SNIPPET = 200;
6
+ function parseErrorEnvelope(body) {
7
+ let parsed;
8
+ try {
9
+ parsed = JSON.parse(body);
10
+ } catch {
11
+ return;
12
+ }
13
+ if (typeof parsed !== "object" || parsed === null) return void 0;
14
+ const text = (key) => {
15
+ const value = Reflect.get(parsed, key);
16
+ return typeof value === "string" && value !== "" ? value : void 0;
17
+ };
18
+ const message = text("message");
19
+ if (message === void 0) return void 0;
20
+ return {
21
+ message,
22
+ detail: {
23
+ type: text("type"),
24
+ code: text("code"),
25
+ param: text("param"),
26
+ docUrl: text("doc_url"),
27
+ resourceType: text("resource_type"),
28
+ resourceId: text("resource_id")
29
+ }
30
+ };
31
+ }
32
+ var ApiError = class extends Error {
33
+ detail;
34
+ request;
35
+ envelope;
36
+ hint;
37
+ constructor(request, status, body) {
38
+ const envelope = body === void 0 ? void 0 : parseErrorEnvelope(body);
39
+ const snippet = body?.trim().slice(0, BODY_SNIPPET);
40
+ super(envelope?.message ?? (snippet ? `HTTP ${status} — ${snippet}` : `HTTP ${status}`));
41
+ this.status = status;
42
+ this.body = body;
43
+ this.detail = envelope?.detail ?? {};
44
+ this.request = request;
45
+ this.envelope = envelope !== void 0;
46
+ }
47
+ };
48
+ var ApiUnreachableError = class extends Error {
49
+ constructor(host, cause) {
50
+ const local = /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])/.test(host);
51
+ super(`Couldn't reach the Superwall API at ${host}.\n` + (local ? " That's a local address — start the API, or unset SUPERWALL_API_HOST to use production." : " Check your network or proxy, then try again."));
52
+ this.name = "ApiUnreachableError";
53
+ this.cause = cause;
54
+ }
55
+ };
56
+ const PAGE_LIMIT = 50;
57
+ const GET_RETRIES = 3;
58
+ const RETRYABLE = new Set([
59
+ 429,
60
+ 502,
61
+ 503,
62
+ 504
63
+ ]);
64
+ async function parseApiError(request, res) {
65
+ const text = await res.text().catch(() => "");
66
+ return new ApiError(request, res.status, text);
67
+ }
68
+ function retryDelay(res, retry) {
69
+ const after = Number(res.headers.get("retry-after"));
70
+ if (Number.isFinite(after) && after >= 0 && res.headers.has("retry-after")) return after * 1e3;
71
+ return 400 * 2 ** retry;
72
+ }
73
+ const createSuperwallApi = (initial) => {
74
+ let session = initial;
75
+ const host = () => resolveApiHost(session);
76
+ const send = async (url, init) => {
77
+ try {
78
+ return await fetch(url, init);
79
+ } catch (error) {
80
+ throw new ApiUnreachableError(host(), error);
81
+ }
82
+ };
83
+ const authorized = async () => {
84
+ const resolved = await resolveAuthToken(session);
85
+ session = resolved.session;
86
+ return resolved.token;
87
+ };
88
+ const request = async (method, path, body, options = {}) => {
89
+ const token = await authorized();
90
+ const attempt = () => {
91
+ return send(`${host()}${path}`, {
92
+ method,
93
+ headers: {
94
+ ...options.headers,
95
+ authorization: `Bearer ${token}`,
96
+ accept: "application/json",
97
+ ...body !== void 0 ? { "content-type": "application/json" } : {}
98
+ },
99
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
100
+ });
101
+ };
102
+ let res = await attempt();
103
+ for (let retry = 0; method === "GET" && RETRYABLE.has(res.status) && retry < GET_RETRIES; retry++) {
104
+ await new Promise((done) => setTimeout(done, retryDelay(res, retry)));
105
+ res = await attempt();
106
+ }
107
+ if (!res.ok) throw await parseApiError(`${method} ${path}`, res);
108
+ if (res.status === 204) return void 0;
109
+ return await res.json();
110
+ };
111
+ const api = {
112
+ org: {},
113
+ get userEmail() {
114
+ return session.userEmail;
115
+ },
116
+ get host() {
117
+ return host();
118
+ },
119
+ forOrg: (id) => ({
120
+ ...api,
121
+ org: { id },
122
+ forOrg: api.forOrg
123
+ }),
124
+ get: (path, options) => request("GET", path, void 0, options),
125
+ post: (path, body, options) => request("POST", path, body, options),
126
+ put: (path, body, options) => request("PUT", path, body, options),
127
+ patch: (path, body, options) => request("PATCH", path, body, options),
128
+ del: (path, options) => request("DELETE", path, void 0, options),
129
+ async postText(path, body) {
130
+ const token = await authorized();
131
+ const res = await send(`${host()}${path}`, {
132
+ method: "POST",
133
+ headers: {
134
+ authorization: `Bearer ${token}`,
135
+ accept: "text/plain",
136
+ "content-type": "text/plain; charset=utf-8"
137
+ },
138
+ body
139
+ });
140
+ if (!res.ok) throw await parseApiError(`POST ${path}`, res);
141
+ return res.text();
142
+ },
143
+ async list(path) {
144
+ const out = [];
145
+ let after;
146
+ for (let page = 0; page < PAGE_LIMIT; page++) {
147
+ const url = `${path}${path.includes("?") ? "&" : "?"}limit=100${after ? `&starting_after=${after}` : ""}`;
148
+ const batch = await api.get(url);
149
+ out.push(...batch.data);
150
+ if (!batch.has_more || batch.data.length === 0) break;
151
+ const last = batch.data.at(-1);
152
+ if (typeof last !== "object" || last === null || !("id" in last) || last.id == null) break;
153
+ after = String(last.id);
154
+ }
155
+ return out;
156
+ }
157
+ };
158
+ return api;
159
+ };
160
+ const superwallApi = () => {
161
+ const session = readSession();
162
+ if (!session) throw new NotLoggedInError();
163
+ return createSuperwallApi(session);
164
+ };
165
+ function withQuery(path, qs) {
166
+ const params = qs instanceof URLSearchParams ? qs : new URLSearchParams();
167
+ if (!(qs instanceof URLSearchParams)) for (const [key, value] of Object.entries(qs)) {
168
+ if (typeof value === "object" && value !== null) throw new Error(`Nested -d params aren't supported on GET/DELETE (got "${key}").`);
169
+ params.set(key, String(value));
170
+ }
171
+ const s = params.toString();
172
+ return s ? `${path}${path.includes("?") ? "&" : "?"}${s}` : path;
173
+ }
174
+
175
+ //#endregion
176
+ export { withQuery as a, superwallApi as i, ApiUnreachableError as n, createSuperwallApi as r, ApiError as t };