@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.
- package/README.md +192 -52
- package/dist/{setup-Bxj22rYi.js → apple-CSzNTGHM.js} +82 -76
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-B7ym3oVS.js → billing-C3Q8DBU2.js} +98 -28
- package/dist/{bind-YrJvuRF9.js → bind-BumHTi9O.js} +38 -33
- package/dist/{build-DLoCW5Ri.js → build-Bpviiclc.js} +20 -26
- package/dist/client-BL0f_yGf.js +176 -0
- package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/create-BSfvpWoD.js +19 -0
- package/dist/{create-pkANt1Gs.js → create-BUcVG4Ab.js} +195 -169
- package/dist/{notification-url-DuKF2659.js → create-CfK3PeKA.js} +235 -539
- package/dist/doctor-BWqIYcMn.js +83 -0
- package/dist/{drivers-Qx9LxmRN.js → drivers-CPhdPkW5.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28072 -1134
- package/dist/environment-eBXjELoN.js +58 -0
- package/dist/{existing-AVEfZu2A.js → existing-BltvQiX5.js} +12 -6
- package/dist/held-CPve03KJ.js +16 -0
- package/dist/held-DgnTFMl3.js +1112 -0
- package/dist/input-vi0bou04.js +42 -0
- package/dist/{integrate-brmhPG-S.js → integrate-BRsqoe01.js} +277 -254
- package/dist/log-NVhVe_oe.js +62 -0
- package/dist/login-BCEH5q0U.js +53 -0
- package/dist/login-BPOONe7n.js +16 -0
- package/dist/{login-Do4wFuLv.js → login-BbTIrCFT.js} +118 -55
- package/dist/lookup-rr1AkCJA.js +71 -0
- package/dist/migrate-C9X2Vz81.js +274 -0
- package/dist/notification-url-CV86qiKP.js +100 -0
- package/dist/{open-studio-DOw-6ydc.js → open-CcpXotHG.js} +34 -43
- package/dist/org-BQQDo7wm.js +35 -0
- package/dist/output-Ggzq5_-t.js +122 -0
- package/dist/paths-CRlU72cq.js +29 -0
- package/dist/playbook-DVMXN7fh.js +53 -0
- package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
- package/dist/promote-Da8xctzy.js +91 -0
- package/dist/push-BV-grvQg.js +22 -0
- package/dist/push-D6R9icWN.js +495 -0
- package/dist/registry-BYVD-_h6.js +10385 -0
- package/dist/{reports-CfJqoava.js → reports-D_qbl7_u.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-DLON3-61.js} +162 -55
- package/dist/{run-DsVZ5snL.js → run-Co-BwhOg.js} +16 -22
- package/dist/scan-B88OlWOt.js +4 -0
- package/dist/{scan-zKsddO72.js → scan-CKuk-_6W.js} +48 -37
- package/dist/scope-DV22_Ufm.js +198 -0
- package/dist/screenshot-file-tVBfUEIi.js +16 -0
- package/dist/{selection-CxZoX4NT.js → selection-C2_KbLuo.js} +100 -51
- package/dist/server-C4f6ccUr.js +22 -0
- package/dist/{dev-DmB3XqaJ.js → server-D0d2oP-5.js} +86 -94
- package/dist/session-B-Uz0cQ7.js +40 -0
- package/dist/session-BuvArt1j.js +6 -0
- package/dist/session-C4rbE3VS.js +796 -0
- package/dist/skills/animate-onboarding/SKILL.md +467 -0
- package/dist/skills/animate-onboarding/references/engine.md +494 -0
- package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/skills/animate-onboarding/references/performance.md +41 -0
- package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/skills/index.json +37 -0
- package/dist/skills/mobile-design/SKILL.md +447 -0
- package/dist/skills/mobile-design/references/responsive.md +162 -0
- package/dist/skills/onboarding-questions/SKILL.md +231 -0
- package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/skills/onboarding-questions/references/craft.md +142 -0
- package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/skills/superwall/SKILL.md +82 -9
- package/dist/skills/superwall/references/api.md +153 -37
- package/dist/skills/superwall/references/apple-setup.md +316 -0
- package/dist/skills/superwall/references/asc.md +74 -38
- package/dist/skills/superwall/references/data-analytics.md +55 -21
- package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
- package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
- package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
- package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
- package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
- package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
- package/dist/skills/superwall/workflows/placements/android.md +2 -2
- package/dist/skills/superwall/workflows/placements/expo.md +2 -2
- package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
- package/dist/skills/superwall/workflows/placements/ios.md +2 -2
- package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
- package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
- package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
- package/dist/skills/superwall/workflows/review/playbook.md +1 -1
- package/dist/skills/superwall-editor/SKILL.md +61 -0
- package/dist/skills/superwall-editor/references/cli.md +135 -0
- package/dist/skills/superwall-editor/references/design.md +51 -0
- package/dist/skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/skills/superwall-editor/references/workflow.md +65 -0
- package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/skills/superwall-framework/SKILL.md +85 -31
- package/dist/skills/superwall-framework/references/cli.md +58 -27
- package/dist/skills/superwall-framework/references/examples.md +4 -3
- package/dist/skills/superwall-framework/references/layout.md +64 -9
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
- package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
- package/dist/skills/wwdc/SKILL.md +22 -0
- package/dist/skills/wwdc/references/docs.md +52 -0
- package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/skills-CLGJuMnF.js +14 -0
- package/dist/{skills-DPzlnfCK.js → skills-CZcpnEnG.js} +100 -122
- package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
- package/dist/spinner-C2U6QBJ9.js +294 -0
- package/dist/storage-6h9vyiAz.js +31 -0
- package/dist/storage-CerJ5KLP.d.ts +16 -0
- package/dist/storekit-CK9JmM2D.js +16 -0
- package/dist/storekit-CinJra3V.js +47 -0
- package/dist/telemetry-DKyDhURo.js +56 -0
- package/dist/theme-DUsCh-Vd.js +25 -0
- package/dist/timing-BVxPrYq3.js +5 -0
- package/dist/{token-C0it-Xh7.js → token-DaxQgQkv.js} +6 -38
- package/dist/tools-skills/animate-onboarding/SKILL.md +467 -0
- package/dist/tools-skills/animate-onboarding/references/engine.md +494 -0
- package/dist/tools-skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/tools-skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/tools-skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/tools-skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/tools-skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/tools-skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/tools-skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/tools-skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/tools-skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/tools-skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/tools-skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/tools-skills/animate-onboarding/references/performance.md +41 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/tools-skills/mobile-design/SKILL.md +447 -0
- package/dist/tools-skills/mobile-design/references/responsive.md +162 -0
- package/dist/tools-skills/onboarding-questions/SKILL.md +231 -0
- package/dist/tools-skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/tools-skills/onboarding-questions/references/craft.md +142 -0
- package/dist/tools-skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/tools-skills/superwall/SKILL.md +263 -0
- package/dist/tools-skills/superwall/references/api.md +303 -0
- package/dist/tools-skills/superwall/references/asa.md +166 -0
- package/dist/tools-skills/superwall/references/asc.md +95 -0
- package/dist/tools-skills/superwall/references/dashboard-links.md +57 -0
- package/dist/tools-skills/superwall/references/data-analytics.md +896 -0
- package/dist/tools-skills/superwall/references/docs.md +51 -0
- package/dist/tools-skills/superwall/references/sdk-integration.md +104 -0
- package/dist/tools-skills/superwall/references/sdk-source.md +18 -0
- package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +76 -0
- package/dist/tools-skills/superwall/workflows/dashboard/setup.md +100 -0
- package/dist/tools-skills/superwall/workflows/integrate/android.md +292 -0
- package/dist/tools-skills/superwall/workflows/integrate/expo.md +272 -0
- package/dist/tools-skills/superwall/workflows/integrate/flutter.md +285 -0
- package/dist/tools-skills/superwall/workflows/integrate/ios.md +314 -0
- package/dist/tools-skills/superwall/workflows/integrate/playbook.md +83 -0
- package/dist/tools-skills/superwall/workflows/integrate/react-native.md +246 -0
- package/dist/tools-skills/superwall/workflows/migrate/adapty.md +229 -0
- package/dist/tools-skills/superwall/workflows/migrate/playbook.md +78 -0
- package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +227 -0
- package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +414 -0
- package/dist/tools-skills/superwall/workflows/placements/android.md +175 -0
- package/dist/tools-skills/superwall/workflows/placements/expo.md +161 -0
- package/dist/tools-skills/superwall/workflows/placements/flutter.md +139 -0
- package/dist/tools-skills/superwall/workflows/placements/ios.md +165 -0
- package/dist/tools-skills/superwall/workflows/placements/playbook.md +69 -0
- package/dist/tools-skills/superwall/workflows/placements/react-native.md +145 -0
- package/dist/tools-skills/superwall/workflows/placements/strategy.md +222 -0
- package/dist/tools-skills/superwall/workflows/review/android.md +120 -0
- package/dist/tools-skills/superwall/workflows/review/expo.md +100 -0
- package/dist/tools-skills/superwall/workflows/review/flutter.md +99 -0
- package/dist/tools-skills/superwall/workflows/review/ios.md +108 -0
- package/dist/tools-skills/superwall/workflows/review/playbook.md +70 -0
- package/dist/tools-skills/superwall/workflows/review/react-native.md +100 -0
- package/dist/tools-skills/superwall-editor/SKILL.md +113 -0
- package/dist/tools-skills/superwall-editor/references/cli.md +135 -0
- package/dist/tools-skills/superwall-editor/references/design.md +51 -0
- package/dist/tools-skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/tools-skills/superwall-editor/references/workflow.md +65 -0
- package/dist/tools-skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/tools-skills/wwdc/SKILL.md +22 -0
- package/dist/tools-skills/wwdc/references/docs.md +52 -0
- package/dist/tools-skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/tools.d.ts +96 -0
- package/dist/tools.js +11360 -0
- package/dist/ui-D_qf3Gvw.js +53 -0
- package/dist/upgrade-DPo0a4Es.js +117 -0
- package/dist/upgrade-ffseQDMx.js +7 -0
- package/package.json +10 -5
- package/dist/api-CZzirVMj.js +0 -151
- package/dist/api-output-aJNw7Syy.js +0 -20
- package/dist/app-DH6U8yuI.js +0 -190
- package/dist/asa-C-sQzPPn.js +0 -1194
- package/dist/asc-1ZBJ6DwS.js +0 -778
- package/dist/auth-YRhlV3DE.js +0 -140
- package/dist/billing-CCYHdApx.js +0 -80
- package/dist/bundle-id-CKxl_026.js +0 -121
- package/dist/command-CMIz81Da.js +0 -301
- package/dist/dev-DZy6pOnB.js +0 -22
- package/dist/doctor-H-hf-Yww.js +0 -88
- package/dist/feedback-CKf-rpBW.js +0 -152
- package/dist/hosted-CXe9TrWx.js +0 -32
- package/dist/migrate-C9ERDR6y.js +0 -284
- package/dist/org-sj7uyvp-.js +0 -40
- package/dist/output-C4o2gJ1K.js +0 -146
- package/dist/params-l3CrvRtR.js +0 -51
- package/dist/pipeline-BqzqZhX1.js +0 -977
- package/dist/print-skill-ZojRSybs.js +0 -74
- package/dist/promote-BG8X4Nv_.js +0 -88
- package/dist/publish-sxLh-G4G.js +0 -35
- package/dist/push-bQ6Vxtg8.js +0 -35
- package/dist/query-_FbybaH-.js +0 -53
- package/dist/resource-CGIwSd29.js +0 -323
- package/dist/revenue-provider-ebsRINY8.js +0 -100
- package/dist/scope-BvzD-kO4.js +0 -223
- package/dist/skills-D_R-lEsK.js +0 -64
- package/dist/spinner-TWa0hia6.js +0 -18
- package/dist/storekit-Cj9Cpjcz.js +0 -29
- package/dist/telemetry-DeA1mvnT.js +0 -169
- package/dist/ui-Dy0b-9L8.js +0 -27738
- package/dist/update-B2fWIc4q.js +0 -59
- package/dist/upgrade-BmzkTKrh.js +0 -72
- /package/dist/{devtools-8EgLo86w.js → devtools-pBl_vt03.js} +0 -0
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { r as
|
|
3
|
-
import "./
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import "./spawn-
|
|
9
|
-
import "./
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import "./
|
|
13
|
-
import { t as
|
|
14
|
-
import { t as
|
|
15
|
-
import {
|
|
16
|
-
import "./
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { a as
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import { t as
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
1
|
+
import "./token-DaxQgQkv.js";
|
|
2
|
+
import { r as formatJson, t as blocks } from "./output-Ggzq5_-t.js";
|
|
3
|
+
import { _ as VERSION, c as DASHBOARD_URL } from "./environment-eBXjELoN.js";
|
|
4
|
+
import { a as sessionOrgName, n as removeSession, t as readSession } from "./storage-6h9vyiAz.js";
|
|
5
|
+
import { i as superwallApi } from "./client-BL0f_yGf.js";
|
|
6
|
+
import { r as readOnboardedApp } from "./config-BO1Y87kV.js";
|
|
7
|
+
import { i as updateTelemetryTags } from "./telemetry-DKyDhURo.js";
|
|
8
|
+
import "./spawn-DmmmHIP-.js";
|
|
9
|
+
import { n as withSpinner } from "./spinner-C2U6QBJ9.js";
|
|
10
|
+
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
11
|
+
import "./theme-DUsCh-Vd.js";
|
|
12
|
+
import { t as stripReport } from "./log-NVhVe_oe.js";
|
|
13
|
+
import { n as SUPPORTED_LABEL, t as scanProject } from "./scan-CKuk-_6W.js";
|
|
14
|
+
import { t as detectExisting } from "./existing-BltvQiX5.js";
|
|
15
|
+
import { r as expandHome } from "./paths-CRlU72cq.js";
|
|
16
|
+
import { D as field, f as listApplications, k as listField, m as listResource, o as createProduct, v as platformLabel, w as rowName } from "./resources-DLON3-61.js";
|
|
17
|
+
import "./org-BQQDo7wm.js";
|
|
18
|
+
import "./lookup-rr1AkCJA.js";
|
|
19
|
+
import "./scope-DV22_Ufm.js";
|
|
20
|
+
import { a as listAscConfigs, r as createAscConfig } from "./client-BZ1UbpXz.js";
|
|
21
|
+
import { i as listUnimportedAscProducts, n as findAscAppId, r as listAscApps, t as ascTypeDisplay } from "./products-DH_fK9tY.js";
|
|
22
|
+
import "./input-vi0bou04.js";
|
|
23
|
+
import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-BumHTi9O.js";
|
|
24
|
+
import "./login-BbTIrCFT.js";
|
|
25
|
+
import { s as ensureSkillsCurrent } from "./skills-CZcpnEnG.js";
|
|
26
|
+
import { t as generateStoreKit } from "./storekit-CinJra3V.js";
|
|
27
|
+
import { n as performLoginWithUi, t as createLoginGate } from "./login-BCEH5q0U.js";
|
|
28
|
+
import { a as copyToClipboard, r as buildCopyPrompt, t as runAction } from "./run-Co-BwhOg.js";
|
|
29
|
+
import { n as selectHostedStatus, t as detectDrivers } from "./drivers-CPhdPkW5.js";
|
|
30
|
+
import { r as actionById, t as detectBilling } from "./billing-C3Q8DBU2.js";
|
|
31
|
+
import { n as writeReport, t as readReport } from "./reports-D_qbl7_u.js";
|
|
28
32
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
33
|
+
import { basename } from "node:path";
|
|
29
34
|
import fg from "fast-glob";
|
|
30
35
|
|
|
31
36
|
//#region src/core/account/index.ts
|
|
32
37
|
async function resolveAccount(opts) {
|
|
33
38
|
const projectKey = opts.existing.apiKey;
|
|
34
|
-
const flagKey = opts.
|
|
39
|
+
const flagKey = opts.apiKey;
|
|
35
40
|
if (projectKey) {
|
|
36
41
|
if (!opts.interactive || flagKey === projectKey) return { apiKey: projectKey };
|
|
37
42
|
const use = await opts.ui.confirm({ message: `This project already has a Superwall key (${projectKey}). Use this app?` });
|
|
@@ -39,50 +44,57 @@ async function resolveAccount(opts) {
|
|
|
39
44
|
if (use) return { apiKey: projectKey };
|
|
40
45
|
}
|
|
41
46
|
if (flagKey) return { apiKey: flagKey };
|
|
42
|
-
throw new Error(opts.interactive ? "Couldn't connect your app - re-run and complete the browser login." : "No public API key found. Pass --api-key
|
|
47
|
+
throw new Error(opts.interactive ? "Couldn't connect your app - re-run and complete the browser login." : "No public API key found. Pass --api-key.");
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
//#endregion
|
|
46
|
-
//#region src/core/
|
|
47
|
-
async function
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
apiKey: match.public_api_key,
|
|
54
|
-
app: match
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
if (apps.length === 1) {
|
|
58
|
-
const only = apps[0];
|
|
59
|
-
return {
|
|
60
|
-
apiKey: only.public_api_key,
|
|
61
|
-
app: only
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (opts.onMany) {
|
|
65
|
-
const picked = await opts.onMany(apps);
|
|
66
|
-
if (picked?.public_api_key) return {
|
|
67
|
-
apiKey: picked.public_api_key,
|
|
68
|
-
app: picked
|
|
69
|
-
};
|
|
51
|
+
//#region src/core/workflows/agent/fallback.ts
|
|
52
|
+
async function runFallback(installDir) {
|
|
53
|
+
const scan = await scanProject(installDir);
|
|
54
|
+
const top = scan.apps[0];
|
|
55
|
+
if (!top) {
|
|
56
|
+
if (scan.unsupported.length) throw new Error("Detected a web app. This command supports mobile apps.");
|
|
57
|
+
throw new Error(`No ${SUPPORTED_LABEL} app found here.`);
|
|
70
58
|
}
|
|
71
|
-
|
|
59
|
+
ui.info(`Detected ${top.framework.name}${top.details ? ` · ${top.details}` : ""}`);
|
|
60
|
+
ui.note([
|
|
61
|
+
`1. Install the SDK: ${top.framework.sdkPackage}`,
|
|
62
|
+
`2. Configure Superwall with your public API key at app launch.`,
|
|
63
|
+
`3. Register one placement: register("campaign_trigger").`,
|
|
64
|
+
``,
|
|
65
|
+
`Full guide: ${top.framework.docsUrl}`
|
|
66
|
+
].join("\n"), "Manual setup");
|
|
67
|
+
ui.note([
|
|
68
|
+
"For automated setup, install an agent and run `superwall integrate` again:",
|
|
69
|
+
"Claude Code: npm install --global @anthropic-ai/claude-code",
|
|
70
|
+
"Codex: npm install --global @openai/codex"
|
|
71
|
+
].join("\n"), "Automated setup");
|
|
72
|
+
ui.outro("Re-run `superwall integrate` after installing an agent.");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/core/api/discover.ts
|
|
77
|
+
async function discoverPublicApiKey(api) {
|
|
78
|
+
const [only, ...rest] = (await listApplications(api)).flatMap((app) => app.public_api_key ? [{
|
|
79
|
+
apiKey: app.public_api_key,
|
|
80
|
+
app
|
|
81
|
+
}] : []);
|
|
82
|
+
return only && rest.length === 0 ? only : null;
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
//#endregion
|
|
75
|
-
//#region src/core/dashboard
|
|
86
|
+
//#region src/core/workflows/dashboard-setup.ts
|
|
76
87
|
const SKIP = "__skip__";
|
|
77
|
-
function
|
|
88
|
+
function formatCount(n, noun) {
|
|
78
89
|
return `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
79
90
|
}
|
|
80
91
|
async function runProductsStage(ctx) {
|
|
81
92
|
const { api, scope } = ctx;
|
|
82
93
|
const [products, ascConfigs] = await withSpinner("Checking products", async () => [await listResource(api, "products", scope), await listAscConfigs(api).catch(() => [])]);
|
|
83
94
|
const teamId = ascConfigs[0] ? String(ascConfigs[0].team_id ?? ascConfigs[0].id ?? "") : void 0;
|
|
84
|
-
const storeKitFiles = await
|
|
85
|
-
|
|
95
|
+
const storeKitFiles = await listStoreKitFiles(ctx.projectDir);
|
|
96
|
+
const [firstStoreKit] = storeKitFiles;
|
|
97
|
+
if (products.length > 0) ui.success(`${formatCount(products.length, "product")} already in Superwall.`);
|
|
86
98
|
else ui.info("No products in Superwall yet.");
|
|
87
99
|
for (;;) {
|
|
88
100
|
const how = await ui.select({
|
|
@@ -96,7 +108,7 @@ async function runProductsStage(ctx) {
|
|
|
96
108
|
{
|
|
97
109
|
value: "storekit",
|
|
98
110
|
label: "Import from a StoreKit file",
|
|
99
|
-
hint:
|
|
111
|
+
hint: firstStoreKit ? basename(firstStoreKit) : "No StoreKit file found",
|
|
100
112
|
disabled: storeKitFiles.length === 0
|
|
101
113
|
},
|
|
102
114
|
...products.length > 0 ? [{
|
|
@@ -131,29 +143,27 @@ async function ascFlow(ctx, products, teamId) {
|
|
|
131
143
|
}
|
|
132
144
|
return importFromAsc(ctx, team, products);
|
|
133
145
|
}
|
|
134
|
-
async function
|
|
146
|
+
async function listStoreKitFiles(dir) {
|
|
135
147
|
if (!dir) return [];
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
} catch {
|
|
151
|
-
return [];
|
|
152
|
-
}
|
|
148
|
+
return fg("**/*.storekit", {
|
|
149
|
+
cwd: dir,
|
|
150
|
+
absolute: true,
|
|
151
|
+
deep: 6,
|
|
152
|
+
suppressErrors: true,
|
|
153
|
+
ignore: [
|
|
154
|
+
"**/node_modules/**",
|
|
155
|
+
"**/Pods/**",
|
|
156
|
+
"**/build/**",
|
|
157
|
+
"**/DerivedData/**",
|
|
158
|
+
"**/.git/**"
|
|
159
|
+
]
|
|
160
|
+
});
|
|
153
161
|
}
|
|
154
162
|
async function importFromStoreKit(ctx, existingProducts, files) {
|
|
155
163
|
const { api, scope } = ctx;
|
|
156
|
-
|
|
164
|
+
const [first] = files;
|
|
165
|
+
if (!first) return "done";
|
|
166
|
+
let path = first;
|
|
157
167
|
if (files.length > 1) {
|
|
158
168
|
const sel = await ui.select({
|
|
159
169
|
message: "Which StoreKit file?",
|
|
@@ -170,7 +180,7 @@ async function importFromStoreKit(ctx, existingProducts, files) {
|
|
|
170
180
|
}
|
|
171
181
|
let ids;
|
|
172
182
|
try {
|
|
173
|
-
ids =
|
|
183
|
+
ids = parseStoreKitProductIds(JSON.parse(readFileSync(path, "utf8")));
|
|
174
184
|
} catch {
|
|
175
185
|
ui.error(`Couldn't read \`${basename(path)}\` as a StoreKit file.`);
|
|
176
186
|
return "done";
|
|
@@ -186,7 +196,7 @@ async function importFromStoreKit(ctx, existingProducts, files) {
|
|
|
186
196
|
return "done";
|
|
187
197
|
}
|
|
188
198
|
const picked = await ui.multiselect({
|
|
189
|
-
message: `${
|
|
199
|
+
message: `${formatCount(toImport.length, "product")} in the StoreKit file`,
|
|
190
200
|
options: toImport.map((id) => ({
|
|
191
201
|
value: id,
|
|
192
202
|
label: id
|
|
@@ -199,27 +209,24 @@ async function importFromStoreKit(ctx, existingProducts, files) {
|
|
|
199
209
|
await withSpinner(`Importing ${id}`, () => createProduct(api, scope, id));
|
|
200
210
|
imported++;
|
|
201
211
|
}
|
|
202
|
-
ui.success(`Imported ${
|
|
212
|
+
ui.success(`Imported ${formatCount(imported, "product")} from the StoreKit file.`);
|
|
203
213
|
return "done";
|
|
204
214
|
}
|
|
205
|
-
function
|
|
215
|
+
function parseStoreKitProductIds(json) {
|
|
206
216
|
const ids = /* @__PURE__ */ new Set();
|
|
207
|
-
const add = (
|
|
208
|
-
|
|
209
|
-
|
|
217
|
+
const add = (items) => {
|
|
218
|
+
for (const item of items) {
|
|
219
|
+
const id = field(item, "productID");
|
|
220
|
+
if (id) ids.add(String(id));
|
|
210
221
|
}
|
|
211
222
|
};
|
|
212
|
-
|
|
213
|
-
add(
|
|
214
|
-
add(
|
|
215
|
-
for (const g of j.subscriptionGroups ?? []) add(g?.subscriptions);
|
|
223
|
+
add(listField(json, "products"));
|
|
224
|
+
add(listField(json, "nonRenewingSubscriptions"));
|
|
225
|
+
for (const group of listField(json, "subscriptionGroups")) add(listField(group, "subscriptions"));
|
|
216
226
|
return [...ids];
|
|
217
227
|
}
|
|
218
228
|
function existingIdSet(products) {
|
|
219
|
-
return new Set(products.map((p) =>
|
|
220
|
-
const r = p;
|
|
221
|
-
return String(r.identifier ?? r.product_identifier ?? rowName(p));
|
|
222
|
-
}));
|
|
229
|
+
return new Set(products.map((p) => String(p.identifier ?? p.product_identifier ?? rowName(p))));
|
|
223
230
|
}
|
|
224
231
|
async function connectAppStoreConnect(ctx) {
|
|
225
232
|
const { api } = ctx;
|
|
@@ -292,7 +299,8 @@ function keyIdFromFilename(path) {
|
|
|
292
299
|
}
|
|
293
300
|
async function importFromAsc(ctx, teamId, existingProducts) {
|
|
294
301
|
const { api, scope, bundleId } = ctx;
|
|
295
|
-
let ascAppId
|
|
302
|
+
let ascAppId;
|
|
303
|
+
if (bundleId) ascAppId = await withSpinner("Finding your app in App Store Connect", () => findAscAppId(api, teamId, bundleId));
|
|
296
304
|
if (!ascAppId) {
|
|
297
305
|
const apps = await withSpinner("Loading App Store Connect apps", () => listAscApps(api, teamId));
|
|
298
306
|
if (apps.length === 0) {
|
|
@@ -312,13 +320,13 @@ async function importFromAsc(ctx, teamId, existingProducts) {
|
|
|
312
320
|
if (sel === null) return "back";
|
|
313
321
|
ascAppId = sel;
|
|
314
322
|
}
|
|
315
|
-
const unimported = await withSpinner("Loading products from App Store Connect", () =>
|
|
323
|
+
const unimported = await withSpinner("Loading products from App Store Connect", () => listUnimportedAscProducts(api, teamId, ascAppId, existingIdSet(existingProducts)));
|
|
316
324
|
if (unimported.length === 0) {
|
|
317
325
|
ui.success("All App Store Connect products are already imported.");
|
|
318
326
|
return "done";
|
|
319
327
|
}
|
|
320
328
|
const picked = await ui.multiselect({
|
|
321
|
-
message: `${
|
|
329
|
+
message: `${formatCount(unimported.length, "product")} to import from App Store Connect`,
|
|
322
330
|
options: unimported.map((p) => ({
|
|
323
331
|
value: p.productId,
|
|
324
332
|
label: p.productId,
|
|
@@ -334,15 +342,12 @@ async function importFromAsc(ctx, teamId, existingProducts) {
|
|
|
334
342
|
await withSpinner(`Importing ${id}`, () => createProduct(api, scope, id, { name: p?.referenceName || void 0 }));
|
|
335
343
|
imported++;
|
|
336
344
|
}
|
|
337
|
-
ui.success(`Imported ${
|
|
345
|
+
ui.success(`Imported ${formatCount(imported, "product")} from App Store Connect.`);
|
|
338
346
|
return "done";
|
|
339
347
|
}
|
|
340
348
|
function required(v) {
|
|
341
349
|
return v?.trim() ? void 0 : "Required";
|
|
342
350
|
}
|
|
343
|
-
function expandHome(p) {
|
|
344
|
-
return p.startsWith("~") ? join(homedir(), p.slice(1)) : p;
|
|
345
|
-
}
|
|
346
351
|
function cleanPath(input) {
|
|
347
352
|
let s = input.trim();
|
|
348
353
|
if (s.length >= 2 && (s[0] === "'" && s.endsWith("'") || s[0] === "\"" && s.endsWith("\""))) s = s.slice(1, -1);
|
|
@@ -363,8 +368,8 @@ function runPaywallStage() {
|
|
|
363
368
|
async function runVerifyStage(ctx) {
|
|
364
369
|
const { api, scope } = ctx;
|
|
365
370
|
const [products, campaigns] = await withSpinner("Verifying setup", async () => [await listResource(api, "products", scope), await listResource(api, "campaigns", scope)]);
|
|
366
|
-
|
|
367
|
-
|
|
371
|
+
renderCheck(products.length > 0, `Products in Superwall: ${products.length}`);
|
|
372
|
+
renderCheck(campaigns.length > 0, `Campaigns: ${campaigns.length}`);
|
|
368
373
|
ui.note([
|
|
369
374
|
"To verify end to end:",
|
|
370
375
|
"1. Run the app on a device/simulator.",
|
|
@@ -372,43 +377,18 @@ async function runVerifyStage(ctx) {
|
|
|
372
377
|
"3. Confirm the paywall presents and a test purchase completes."
|
|
373
378
|
].join("\n"), "Next");
|
|
374
379
|
}
|
|
375
|
-
function
|
|
380
|
+
function renderCheck(ok, text) {
|
|
376
381
|
if (ok) ui.success(text);
|
|
377
382
|
else ui.warn(text);
|
|
378
383
|
}
|
|
379
384
|
function writeStoreKit(products) {
|
|
380
385
|
const out = "Superwall.storekit";
|
|
381
386
|
writeFileSync(out, `${formatJson(generateStoreKit(products))}\n`);
|
|
382
|
-
ui.success(`Wrote \`${out}\` with ${
|
|
387
|
+
ui.success(`Wrote \`${out}\` with ${formatCount(products.length, "product")}.`);
|
|
383
388
|
}
|
|
384
389
|
|
|
385
390
|
//#endregion
|
|
386
|
-
//#region src/core/agent
|
|
387
|
-
async function runFallback(installDir) {
|
|
388
|
-
const scan = await scanProject(installDir);
|
|
389
|
-
const top = scan.apps[0];
|
|
390
|
-
if (!top) {
|
|
391
|
-
if (scan.unsupported.length) throw new Error("Detected a web app. This command supports mobile apps.");
|
|
392
|
-
throw new Error(`No ${SUPPORTED_LABEL} app found here.`);
|
|
393
|
-
}
|
|
394
|
-
ui.info(`Detected ${top.framework.name}${top.details ? ` · ${top.details}` : ""}`);
|
|
395
|
-
ui.note([
|
|
396
|
-
`1. Install the SDK: ${top.framework.sdkPackage}`,
|
|
397
|
-
`2. Configure Superwall with your public API key at app launch.`,
|
|
398
|
-
`3. Register one placement: register("campaign_trigger").`,
|
|
399
|
-
``,
|
|
400
|
-
`Full guide: ${top.framework.docsUrl}`
|
|
401
|
-
].join("\n"), "Manual setup");
|
|
402
|
-
ui.note([
|
|
403
|
-
"For automated setup, install an agent and run `superwall integrate` again:",
|
|
404
|
-
"Claude Code: npm install --global @anthropic-ai/claude-code",
|
|
405
|
-
"Codex: npm install --global @openai/codex"
|
|
406
|
-
].join("\n"), "Automated setup");
|
|
407
|
-
ui.outro("Re-run `superwall integrate` after installing an agent.");
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region src/commands/workflow/integrate/agent.ts
|
|
391
|
+
//#region src/core/workflows/agent.ts
|
|
412
392
|
async function copyIntegrationPrompt(context) {
|
|
413
393
|
const prompt = buildCopyPrompt(actionById.integrate, context);
|
|
414
394
|
if (await copyToClipboard(prompt)) ui.note("Paste it into Claude Code, Codex, Cursor, or another coding agent.", "Integration prompt copied to clipboard");
|
|
@@ -434,7 +414,7 @@ async function runActionWithUI(driver, fallbackDrivers, action, context) {
|
|
|
434
414
|
spin.stop(action.successLabel);
|
|
435
415
|
if (action.outputMode === "report" && result.finalText) {
|
|
436
416
|
const report = stripReport(result.finalText);
|
|
437
|
-
|
|
417
|
+
writeReport(context.app.path, action.id, report);
|
|
438
418
|
ui.report(report);
|
|
439
419
|
}
|
|
440
420
|
}
|
|
@@ -449,18 +429,131 @@ function printPlan(agent, action, context) {
|
|
|
449
429
|
`Prior: ${context.priorReport ? "review report found" : "none"}`
|
|
450
430
|
].join("\n"), "Plan");
|
|
451
431
|
}
|
|
452
|
-
function finish(
|
|
432
|
+
function finish(output, action) {
|
|
453
433
|
const finalBlocks = [blocks.nextSteps({
|
|
454
434
|
integrate: ["Set up the dashboard (campaign + paywall) so the placement presents something.", "Verify on device for placement 'campaign_trigger'."],
|
|
455
435
|
"placements-implement": ["Set up the dashboard so the new placements present paywalls."],
|
|
456
436
|
"dashboard-setup": ["Design the paywall and attach products in the dashboard.", "Verify on device."]
|
|
457
437
|
}[action.id] ?? [])];
|
|
458
438
|
if (action.id !== "review" && action.id !== "review-fix") finalBlocks.push(blocks.outro(`Done. ${DASHBOARD_URL}`));
|
|
459
|
-
|
|
439
|
+
output.render(...finalBlocks);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/core/workflows/app.ts
|
|
444
|
+
async function recoverUnmatchedScope(app, apiKey) {
|
|
445
|
+
for (;;) {
|
|
446
|
+
const orgName = sessionOrgName(readSession());
|
|
447
|
+
const orgLabel = orgName ? `\`${orgName}\`` : "the apps this account can open";
|
|
448
|
+
ui.error(`This project's API key (\`${apiKey}\`) doesn't match any app in ${orgLabel}. You might be logged in to the wrong account.`);
|
|
449
|
+
const choice = await ui.select({
|
|
450
|
+
message: "How do you want to fix it?",
|
|
451
|
+
options: [
|
|
452
|
+
{
|
|
453
|
+
value: "relogin",
|
|
454
|
+
label: "Log in with a different account"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
value: "bind",
|
|
458
|
+
label: `Connect this app to ${orgLabel} instead`,
|
|
459
|
+
hint: "creates or picks an app and issues a new API key"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
value: "skip",
|
|
463
|
+
label: "Skip for now"
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
});
|
|
467
|
+
if (choice === null || choice === "skip") return null;
|
|
468
|
+
if (choice === "relogin") {
|
|
469
|
+
removeSession();
|
|
470
|
+
if (!await performLoginWithUi(app)) return null;
|
|
471
|
+
const resolved = await withSpinner("Finding this app in Superwall", () => resolveScopeFromKey(superwallApi(), apiKey).catch(() => null));
|
|
472
|
+
if (resolved) {
|
|
473
|
+
ui.success(`Found \`${resolved.appName ?? app.name}\``);
|
|
474
|
+
return {
|
|
475
|
+
scope: {
|
|
476
|
+
projectId: resolved.projectId,
|
|
477
|
+
applicationId: resolved.applicationId,
|
|
478
|
+
appName: resolved.appName ?? app.name
|
|
479
|
+
},
|
|
480
|
+
bundleId: resolved.bundleId
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
try {
|
|
486
|
+
const bound = await resolveAppBinding(superwallApi(), {
|
|
487
|
+
platform: platformForIntegration(app.integration),
|
|
488
|
+
appName: app.name
|
|
489
|
+
});
|
|
490
|
+
if (!bound) continue;
|
|
491
|
+
ui.note(`Your code still uses \`${apiKey}\`.\nReplace it with \`${bound.apiKey}\` so the app talks to ${orgLabel}.`, "Swap the API key");
|
|
492
|
+
return {
|
|
493
|
+
scope: {
|
|
494
|
+
projectId: bound.projectId,
|
|
495
|
+
applicationId: bound.applicationId,
|
|
496
|
+
appName: app.name
|
|
497
|
+
},
|
|
498
|
+
bundleId: bound.app.bundle_id
|
|
499
|
+
};
|
|
500
|
+
} catch (error) {
|
|
501
|
+
ui.warn(error instanceof Error ? error.message : String(error));
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
async function ensureAgentDriverReady(driver, ensureLogin, dryRun) {
|
|
506
|
+
if (driver.id !== "superwall" || dryRun) return true;
|
|
507
|
+
if (!await ensureLogin()) {
|
|
508
|
+
ui.warn("Superwall Agent needs sign-in. Run `superwall login`, or install Claude Code/Codex and re-run.");
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
const status = await withSpinner("Checking Superwall Agent credit", () => selectHostedStatus());
|
|
512
|
+
if (!status) {
|
|
513
|
+
ui.warn("Superwall Agent needs an OAuth login. Run `superwall login` (not `--api-key`), or install Claude Code/Codex.");
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
if (status.exhausted) {
|
|
517
|
+
ui.warn("Your hosted Superwall Agent credit is exhausted. Install Claude Code/Codex or copy the prompt into your own agent.");
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
async function pickApp(installDir, interactive) {
|
|
523
|
+
const scan = await withSpinner("Scanning your project", () => scanProject(installDir));
|
|
524
|
+
const [firstApp] = scan.apps;
|
|
525
|
+
if (!firstApp) {
|
|
526
|
+
const [webApp] = scan.unsupported;
|
|
527
|
+
if (webApp) throw new Error(`Detected a web app${webApp.details ? ` (\`${webApp.details}\`)` : ""}. This command supports mobile apps.`);
|
|
528
|
+
const skipped = scan.skipped.length ? ` Skipped: ${scan.skipped.join(", ")}.` : "";
|
|
529
|
+
throw new Error(`No ${SUPPORTED_LABEL} app found in this directory.${skipped}`);
|
|
530
|
+
}
|
|
531
|
+
if (scan.unsupported.length) ui.info(`Also found unsupported web apps: ${scan.unsupported.map((app) => app.name).join(", ")}`);
|
|
532
|
+
if (scan.apps.length === 1) {
|
|
533
|
+
ui.info(`Detected \`${firstApp.framework.name}\`` + (firstApp.details ? ` · \`${firstApp.details}\`` : "") + (firstApp.relPath !== "." ? ` (${firstApp.relPath})` : ""));
|
|
534
|
+
return firstApp;
|
|
535
|
+
}
|
|
536
|
+
if (!interactive) throw new Error("Multiple apps found. Pass --install-dir for the app you want to change.");
|
|
537
|
+
const choice = await ui.select({
|
|
538
|
+
message: scan.isMonorepo ? "Found multiple apps - which one?" : "Which app?",
|
|
539
|
+
options: scan.apps.map((app) => ({
|
|
540
|
+
value: app.path,
|
|
541
|
+
label: `${app.name} · ${app.framework.name}`,
|
|
542
|
+
hint: app.relPath === "." ? void 0 : app.relPath
|
|
543
|
+
})),
|
|
544
|
+
initialValue: firstApp.path
|
|
545
|
+
});
|
|
546
|
+
if (choice === null) return null;
|
|
547
|
+
return scan.apps.find((app) => app.path === choice) ?? firstApp;
|
|
548
|
+
}
|
|
549
|
+
async function stage(label, work) {
|
|
550
|
+
ui.step(label);
|
|
551
|
+
await new Promise((resolve$1) => setTimeout(resolve$1, 40));
|
|
552
|
+
await work();
|
|
460
553
|
}
|
|
461
554
|
|
|
462
555
|
//#endregion
|
|
463
|
-
//#region src/
|
|
556
|
+
//#region src/core/workflows/campaigns.ts
|
|
464
557
|
async function runCampaignsAndPlacements(driver, fallbackDrivers, actionContext, stageContext, ensureAgentReady) {
|
|
465
558
|
const { api, scope } = stageContext;
|
|
466
559
|
const campaigns = await withSpinner("Checking campaigns", () => listResource(api, "campaigns", scope));
|
|
@@ -487,15 +580,12 @@ async function runCampaignsAndPlacements(driver, fallbackDrivers, actionContext,
|
|
|
487
580
|
if (!await ensureAgentReady()) return;
|
|
488
581
|
await runActionWithUI(driver, fallbackDrivers, actionById["placements-implement"], {
|
|
489
582
|
...context,
|
|
490
|
-
priorReport:
|
|
583
|
+
priorReport: readReport(actionContext.app.path, "placements-review")
|
|
491
584
|
});
|
|
492
585
|
}
|
|
493
586
|
if (await ui.confirm({ message: "Create campaigns so these placements can present paywalls?" })) {
|
|
494
587
|
if (!await ensureAgentReady()) return;
|
|
495
|
-
await runActionWithUI(driver, fallbackDrivers, actionById["dashboard-setup"],
|
|
496
|
-
...context,
|
|
497
|
-
campaigns: campaignSummary(await listResource(api, "campaigns", scope).catch(() => campaigns))
|
|
498
|
-
});
|
|
588
|
+
await runActionWithUI(driver, fallbackDrivers, actionById["dashboard-setup"], context);
|
|
499
589
|
}
|
|
500
590
|
}
|
|
501
591
|
function placementsOf(campaign) {
|
|
@@ -510,36 +600,25 @@ function campaignSummary(campaigns) {
|
|
|
510
600
|
}
|
|
511
601
|
|
|
512
602
|
//#endregion
|
|
513
|
-
//#region src/
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
auth: "optional",
|
|
517
|
-
run: runPipeline
|
|
518
|
-
});
|
|
519
|
-
function runActionCommand(action) {
|
|
520
|
-
return defineCommand({
|
|
521
|
-
name: action,
|
|
522
|
-
auth: "optional",
|
|
523
|
-
run: (ctx) => runFlow(ctx, action)
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
async function runPipeline(ctx) {
|
|
527
|
-
const { installDir, dryRun, argv } = ctx;
|
|
603
|
+
//#region src/core/workflows/integrate.ts
|
|
604
|
+
async function runIntegrate(ctx) {
|
|
605
|
+
const { installDir, dryRun } = ctx;
|
|
528
606
|
ui.intro(`Superwall v${VERSION}`);
|
|
529
607
|
const drivers = await withSpinner("Checking your setup", () => detectDrivers());
|
|
530
|
-
|
|
608
|
+
const [first] = drivers;
|
|
609
|
+
if (!first) {
|
|
531
610
|
ui.warn("No coding agent found.");
|
|
532
611
|
await runFallback(installDir);
|
|
533
612
|
return;
|
|
534
613
|
}
|
|
535
|
-
const wanted =
|
|
536
|
-
const picked = wanted ? drivers.find((d) => d.driver.id === wanted) :
|
|
537
|
-
if (
|
|
614
|
+
const wanted = ctx.driver;
|
|
615
|
+
const picked = wanted ? drivers.find((d) => d.driver.id === wanted) : first;
|
|
616
|
+
if (!picked) throw new Error(`Driver "${wanted}" not available. Detected: ${drivers.map((d) => d.driver.id).join(", ")}.`);
|
|
538
617
|
const driver = picked.driver;
|
|
539
618
|
const fallbackDrivers = wanted ? [] : drivers.filter((candidate) => candidate !== picked).map((candidate) => candidate.driver);
|
|
540
619
|
const app = await pickApp(installDir, ctx.interactive);
|
|
541
620
|
if (!app) return;
|
|
542
|
-
|
|
621
|
+
updateTelemetryTags({
|
|
543
622
|
driver: driver.id,
|
|
544
623
|
framework: app.framework.integration
|
|
545
624
|
});
|
|
@@ -568,28 +647,21 @@ async function runPipeline(ctx) {
|
|
|
568
647
|
if (intent === null) return;
|
|
569
648
|
ui.info(`RevenueCat: \`${intent}\``);
|
|
570
649
|
}
|
|
571
|
-
|
|
572
|
-
if (session?.apiKey) process.env.SUPERWALL_API_KEY = session.apiKey;
|
|
650
|
+
const session = readSession();
|
|
573
651
|
let scopePromise = null;
|
|
574
652
|
if (session && existing.apiKey) scopePromise = resolveScopeFromKey(superwallApi(), existing.apiKey).catch(() => null);
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
});
|
|
582
|
-
if (!signedIn) return false;
|
|
583
|
-
session = signedIn;
|
|
584
|
-
if (session.apiKey) process.env.SUPERWALL_API_KEY = session.apiKey;
|
|
585
|
-
return true;
|
|
586
|
-
};
|
|
653
|
+
const login = createLoginGate(app, {
|
|
654
|
+
session,
|
|
655
|
+
interactive: ctx.interactive,
|
|
656
|
+
dryRun
|
|
657
|
+
});
|
|
658
|
+
const ensureLogin = login.ensure;
|
|
587
659
|
let apiKey = existing.apiKey ?? "";
|
|
588
|
-
const flagKey =
|
|
660
|
+
const flagKey = ctx.apiKey;
|
|
589
661
|
let scope = null;
|
|
590
662
|
let bundleId;
|
|
591
663
|
if (!apiKey && !flagKey) {
|
|
592
|
-
const remembered =
|
|
664
|
+
const remembered = readOnboardedApp(app.path);
|
|
593
665
|
if (remembered) {
|
|
594
666
|
apiKey = remembered.publicApiKey;
|
|
595
667
|
if (remembered.projectId && remembered.applicationId) scope = {
|
|
@@ -610,7 +682,7 @@ async function runPipeline(ctx) {
|
|
|
610
682
|
}
|
|
611
683
|
}
|
|
612
684
|
} else if (await ensureLogin()) {
|
|
613
|
-
const provisioned =
|
|
685
|
+
const provisioned = login.provisioned();
|
|
614
686
|
if (provisioned?.publicApiKey) {
|
|
615
687
|
apiKey = provisioned.publicApiKey;
|
|
616
688
|
if (provisioned.projectId && provisioned.applicationId) scope = {
|
|
@@ -634,20 +706,21 @@ async function runPipeline(ctx) {
|
|
|
634
706
|
bundleId = bound.app.bundle_id;
|
|
635
707
|
ui.success(`Using \`${bound.app.name ?? bound.app.id}\` (${platformLabel(bound.app.platform)})`);
|
|
636
708
|
} catch (e) {
|
|
637
|
-
ui.warn(e.message);
|
|
709
|
+
ui.warn(e instanceof Error ? e.message : String(e));
|
|
638
710
|
}
|
|
639
711
|
}
|
|
640
712
|
}
|
|
641
713
|
if (!apiKey) {
|
|
642
714
|
const account = await resolveAccount({
|
|
643
715
|
existing,
|
|
644
|
-
|
|
716
|
+
apiKey: ctx.apiKey,
|
|
645
717
|
interactive: ctx.interactive,
|
|
646
718
|
ui: ctx.ui
|
|
647
719
|
});
|
|
648
720
|
if (!account) return void ui.warn("Cancelled.");
|
|
649
721
|
apiKey = account.apiKey;
|
|
650
722
|
}
|
|
723
|
+
if (session?.apiKey) process.env.SUPERWALL_API_KEY = session.apiKey;
|
|
651
724
|
const ctxAction = {
|
|
652
725
|
app,
|
|
653
726
|
apiKey,
|
|
@@ -659,7 +732,8 @@ async function runPipeline(ctx) {
|
|
|
659
732
|
ui.info("SDK already integrated - skipped.");
|
|
660
733
|
if (!dryRun) await ensureSkillsCurrent();
|
|
661
734
|
} else if (!dryRun) {
|
|
662
|
-
|
|
735
|
+
let how = "now";
|
|
736
|
+
if (ctx.interactive) how = await ui.select({
|
|
663
737
|
message: `Integrate the Superwall SDK into \`${app.name}\`?`,
|
|
664
738
|
options: [{
|
|
665
739
|
value: "now",
|
|
@@ -687,13 +761,15 @@ async function runPipeline(ctx) {
|
|
|
687
761
|
await runActionWithUI(driver, fallbackDrivers, actionById["integrate"], ctxAction);
|
|
688
762
|
await ensureSkillsCurrent(true);
|
|
689
763
|
}
|
|
690
|
-
const canResolveHeadless = !ctx.interactive && !!apiKey && !!
|
|
691
|
-
if (!dryRun && !ctx.interactive && !
|
|
764
|
+
const canResolveHeadless = !ctx.interactive && !!apiKey && !!readSession();
|
|
765
|
+
if (!dryRun && !ctx.interactive && !readSession()) {
|
|
692
766
|
ui.warn("You aren't logged in — headless mode cannot run the placements/campaigns stages. Run `superwall login` first. The SDK code changes (if any) were applied, but the integration is INCOMPLETE.");
|
|
693
767
|
process.exitCode = 1;
|
|
694
768
|
}
|
|
695
769
|
if (!dryRun && !scope && (canResolveHeadless || ctx.interactive && await ensureLogin())) {
|
|
696
|
-
const resolved = await withSpinner("Finding this app in Superwall", () =>
|
|
770
|
+
const resolved = await withSpinner("Finding this app in Superwall", () => {
|
|
771
|
+
return scopePromise ?? resolveScopeFromKey(superwallApi(), apiKey).catch(() => null);
|
|
772
|
+
});
|
|
697
773
|
if (resolved) {
|
|
698
774
|
scope = resolved;
|
|
699
775
|
bundleId = resolved.bundleId;
|
|
@@ -724,85 +800,35 @@ async function runPipeline(ctx) {
|
|
|
724
800
|
}
|
|
725
801
|
ui.outro(`Done. ${DASHBOARD_URL}`);
|
|
726
802
|
}
|
|
727
|
-
async function
|
|
728
|
-
const { installDir, dryRun
|
|
803
|
+
async function runReview(ctx, fix) {
|
|
804
|
+
const { installDir, dryRun } = ctx;
|
|
729
805
|
ui.intro(`Superwall v${VERSION}`);
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
806
|
+
const [driver, ...fallbacks] = await withSpinner("Checking your setup", () => detectDrivers());
|
|
807
|
+
if (!driver) {
|
|
732
808
|
ui.warn("No coding agent found.");
|
|
733
809
|
await runFallback(installDir);
|
|
734
810
|
return;
|
|
735
811
|
}
|
|
736
|
-
const
|
|
737
|
-
const fallbackDrivers = drivers.slice(1).map((candidate) => candidate.driver);
|
|
738
|
-
let session = loadSession();
|
|
812
|
+
const fallbackDrivers = fallbacks.map((candidate) => candidate.driver);
|
|
739
813
|
const app = await pickApp(installDir, ctx.interactive);
|
|
740
814
|
if (!app) return void ui.warn("Cancelled.");
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
});
|
|
748
|
-
if (!signedIn) return false;
|
|
749
|
-
session = signedIn;
|
|
750
|
-
if (session.apiKey) process.env.SUPERWALL_API_KEY = session.apiKey;
|
|
751
|
-
return true;
|
|
752
|
-
};
|
|
753
|
-
setTelemetryTags({
|
|
815
|
+
const login = createLoginGate(app, {
|
|
816
|
+
session: readSession(),
|
|
817
|
+
interactive: ctx.interactive,
|
|
818
|
+
dryRun
|
|
819
|
+
});
|
|
820
|
+
updateTelemetryTags({
|
|
754
821
|
driver: driver.driver.id,
|
|
755
822
|
framework: app.framework.integration
|
|
756
823
|
});
|
|
757
824
|
const existing = detectExisting(app);
|
|
758
825
|
if (existing.fullyIntegrated) ui.success(`Superwall is already set up in \`${app.name}\`.`);
|
|
759
826
|
else if (existing.sdkInstalled) ui.info(`Partial Superwall setup found in \`${app.name}\`.`);
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
const action = actionById[choice];
|
|
763
|
-
if (action.requiresOrgKey && !process.env.SUPERWALL_API_KEY && !loadSession()) {
|
|
764
|
-
ui.warn("That needs an authenticated session - run `superwall login` first (or set SUPERWALL_API_KEY).");
|
|
765
|
-
ui.outro("");
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
let apiKey = existing.apiKey ?? "";
|
|
769
|
-
if (action.id === "integrate" || action.id === "dashboard-setup") {
|
|
770
|
-
const flagKey = argv.apiKey ?? apiKeyFromEnv();
|
|
771
|
-
if (!apiKey && !flagKey) {
|
|
772
|
-
const remembered = getOnboardedApp(app.path);
|
|
773
|
-
if (remembered) {
|
|
774
|
-
apiKey = remembered.publicApiKey;
|
|
775
|
-
ui.info(`Using \`${app.name}\` - created during onboarding.`);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
if (!apiKey && !flagKey && ctx.interactive && await ensureLogin()) if (provisionedRef.current?.publicApiKey) {
|
|
779
|
-
apiKey = provisionedRef.current.publicApiKey;
|
|
780
|
-
ui.success(`Created \`${app.name}\` in Superwall`);
|
|
781
|
-
} else try {
|
|
782
|
-
const bound = await resolveAppBinding(superwallApi(), {
|
|
783
|
-
platform: platformForIntegration(app.integration),
|
|
784
|
-
appName: app.name
|
|
785
|
-
});
|
|
786
|
-
if (!bound) return void ui.warn("Cancelled.");
|
|
787
|
-
apiKey = bound.apiKey;
|
|
788
|
-
} catch (e) {
|
|
789
|
-
ui.warn(e.message);
|
|
790
|
-
}
|
|
791
|
-
if (!apiKey) {
|
|
792
|
-
const account = await resolveAccount({
|
|
793
|
-
existing,
|
|
794
|
-
argv,
|
|
795
|
-
interactive: ctx.interactive,
|
|
796
|
-
ui: ctx.ui
|
|
797
|
-
});
|
|
798
|
-
if (!account) return void ui.warn("Cancelled.");
|
|
799
|
-
apiKey = account.apiKey;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
const priorReport = action.id === "review-fix" ? loadReport(app.path, "review") : action.id === "placements-implement" ? loadReport(app.path, "placements-review") : void 0;
|
|
827
|
+
const action = actionById[fix ? "review-fix" : "review"];
|
|
828
|
+
const priorReport = fix ? readReport(app.path, "review") : void 0;
|
|
803
829
|
const actionCtx = {
|
|
804
830
|
app,
|
|
805
|
-
apiKey,
|
|
831
|
+
apiKey: existing.apiKey ?? "",
|
|
806
832
|
existing,
|
|
807
833
|
priorReport
|
|
808
834
|
};
|
|
@@ -811,14 +837,11 @@ async function runFlow(ctx, forced) {
|
|
|
811
837
|
ui.outro("Dry run - no changes made.");
|
|
812
838
|
return;
|
|
813
839
|
}
|
|
814
|
-
if (
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
await ensureSkillsCurrent(action.id === "integrate" && !existing.fullyIntegrated);
|
|
820
|
-
finish(ctx, action);
|
|
840
|
+
if (!await ensureAgentDriverReady(driver.driver, login.ensure, dryRun)) return;
|
|
841
|
+
await runActionWithUI(driver.driver, fallbackDrivers, action, actionCtx);
|
|
842
|
+
await ensureSkillsCurrent();
|
|
843
|
+
finish(ctx.output, action);
|
|
821
844
|
}
|
|
822
845
|
|
|
823
846
|
//#endregion
|
|
824
|
-
export {
|
|
847
|
+
export { runIntegrate, runReview };
|