@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,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-DF1qKlny.js";
2
+ import { i as readPackageJson, r as allDeps } from "./scan-DLrsrFS9.js";
3
+ import { d as readBundledSkill } from "./skills-BvFOa4y6.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-DF1qKlny.js";
2
+ import { n as withSpinner } from "./spinner-CneRK5rk.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-Dqr01Dep.js";
5
+ import { n as orgForNewProject } from "./org-D0g_q3mv.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-DzRh7dI1.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import { _ as VERSION } from "./environment-DF1qKlny.js";
4
+ import "./storage-s2Dnz-yl.js";
5
+ import "./client-DP6Rc0t_.js";
6
+ import "./config-BO1Y87kV.js";
7
+ import { n as ui } from "./ui-D_qf3Gvw.js";
8
+ import "./resources-Dqr01Dep.js";
9
+ import { C as readLock, M as resolveFramework, N as assetBaseUrl, _ as collectProjectDeclarations, a as resolveProjectDir, i as requireProject, m as took, n as parseIds, s as selectSurfaces, u as kb, v as writeProjectTypes } from "./selection-Rdw-ZUoG.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 };
@@ -1,7 +1,7 @@
1
- //#region src/core/api/asc.ts
1
+ //#region src/core/app-store-connect/api/client.ts
2
2
  function ascBase(api) {
3
3
  const orgId = api.org.id;
4
- if (!orgId) throw new Error("No organization selected - run `superwall orgs use <id|name>` first.");
4
+ if (!orgId) throw new Error("App Store Connect needs the app's account - pass --app <id>.");
5
5
  return `/v2/organizations/${orgId}/app-store-connect`;
6
6
  }
7
7
  async function listAscConfigs(api) {
@@ -24,15 +24,17 @@ function replaceAscConfig(api, teamId, c) {
24
24
  ...c.accountName ? { account_name: c.accountName } : {}
25
25
  });
26
26
  }
27
- const appIntegrations = (app) => `/v2/projects/${app.projectId}/applications/${app.applicationId}/integrations`;
28
- function saveAppAscKey(api, app, c) {
27
+ function appIntegrations(app) {
28
+ return `/v2/projects/${app.projectId}/applications/${app.applicationId}/integrations`;
29
+ }
30
+ function replaceAppAscKey(api, app, c) {
29
31
  return api.put(`${appIntegrations(app)}/app-store-connect/configuration`, {
30
32
  key_id: c.keyId,
31
33
  issuer_id: c.issuerId,
32
34
  private_key: c.privateKey
33
35
  });
34
36
  }
35
- function saveAppPurchaseKey(api, app, c) {
37
+ function replaceAppPurchaseKey(api, app, c) {
36
38
  return api.put(`${appIntegrations(app)}/in-app-purchase/configuration`, {
37
39
  bundle_id: c.bundleId,
38
40
  key_id: c.keyId,
@@ -41,25 +43,24 @@ function saveAppPurchaseKey(api, app, c) {
41
43
  ...c.setApplicationBundleId ? { set_application_bundle_id: true } : {}
42
44
  });
43
45
  }
44
- async function getAppNotificationUrl(api, app) {
46
+ async function findAppNotificationUrl(api, app) {
45
47
  return (await api.get(`${appIntegrations(app)}/app-store-connect/notification-url`)).url;
46
48
  }
47
- function deleteAscConfig(api, teamId) {
49
+ function removeAscConfig(api, teamId) {
48
50
  return api.del(`${ascBase(api)}/${teamId}`);
49
51
  }
50
52
  function ascProxy(api, teamId, method, ascPath, body) {
51
53
  const path = `${ascBase(api)}/proxy/${teamId}${ascPath}`;
52
- switch (method.toUpperCase()) {
53
- case "GET": return api.get(path);
54
- case "POST": return api.post(path, body ?? {});
55
- case "PATCH": return api.patch(path, body ?? {});
56
- case "DELETE": return api.del(path);
57
- default: throw new Error(`Unsupported method: ${method}`);
54
+ switch (method) {
55
+ case "get": return api.get(path);
56
+ case "post": return api.post(path, body ?? {});
57
+ case "patch": return api.patch(path, body ?? {});
58
+ case "delete": return api.del(path);
58
59
  }
59
60
  }
60
61
  function ascProxyGet(api, teamId, ascPath) {
61
- return ascProxy(api, teamId, "GET", ascPath);
62
+ return ascProxy(api, teamId, "get", ascPath);
62
63
  }
63
64
 
64
65
  //#endregion
65
- export { getAppNotificationUrl as a, saveAppAscKey as c, deleteAscConfig as i, saveAppPurchaseKey as l, ascProxyGet as n, listAscConfigs as o, createAscConfig as r, replaceAscConfig as s, ascProxy as t };
66
+ export { listAscConfigs as a, replaceAppPurchaseKey as c, findAppNotificationUrl as i, replaceAscConfig as l, ascProxyGet as n, removeAscConfig as o, createAscConfig as r, replaceAppAscKey as s, ascProxy as t };