@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.
- package/README.md +192 -52
- package/dist/{setup-Bxj22rYi.js → apple-CkKlHBZ9.js} +82 -76
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-B7ym3oVS.js → billing-XCZU_T46.js} +98 -28
- package/dist/{bind-YrJvuRF9.js → bind-drne__Ys.js} +38 -33
- package/dist/{build-DLoCW5Ri.js → build-Gpdq5QXP.js} +20 -26
- package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
- package/dist/client-DP6Rc0t_.js +176 -0
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/{notification-url-DuKF2659.js → create-BBrtgUgS.js} +235 -539
- package/dist/{create-pkANt1Gs.js → create-Cwc3SRWJ.js} +194 -168
- package/dist/create-Yvf2gStM.js +19 -0
- package/dist/doctor-C9ldpPFC.js +83 -0
- package/dist/{drivers-Qx9LxmRN.js → drivers-DNrx4LWA.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28073 -1134
- package/dist/environment-DF1qKlny.js +58 -0
- package/dist/{existing-AVEfZu2A.js → existing-78LWSsqS.js} +12 -6
- package/dist/held-Cy8Wl4D1.js +1112 -0
- package/dist/held-Ddw1XSsr.js +16 -0
- package/dist/input-vi0bou04.js +42 -0
- package/dist/{integrate-brmhPG-S.js → integrate-DcJhpXy8.js} +277 -254
- package/dist/kinds-GFXB3sYu.js +11 -0
- package/dist/log-NVhVe_oe.js +62 -0
- package/dist/login-B2TsCE2H.js +53 -0
- package/dist/login-BoBe8Psl.js +16 -0
- package/dist/{login-Do4wFuLv.js → login-D0lh3_JI.js} +118 -55
- package/dist/lookup-D-nmmAbw.js +71 -0
- package/dist/migrate-Cfec564E.js +274 -0
- package/dist/notification-url-YDbq6FMA.js +100 -0
- package/dist/{open-studio-DOw-6ydc.js → open-Ba2vBl1_.js} +34 -43
- package/dist/org-D0g_q3mv.js +35 -0
- package/dist/output-Ggzq5_-t.js +122 -0
- package/dist/paths-DxSLdpOI.js +29 -0
- package/dist/playbook-DIeb7hne.js +53 -0
- package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
- package/dist/promote-COD4fYdz.js +91 -0
- package/dist/push-CncywhkQ.js +482 -0
- package/dist/push-CtD4FZQV.js +22 -0
- package/dist/registry-DSrosOYs.js +10228 -0
- package/dist/{reports-CfJqoava.js → reports-DdPq4blM.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
- package/dist/{run-DsVZ5snL.js → run-C9qg_QlC.js} +16 -22
- package/dist/scan-Cv5uOwVY.js +4 -0
- package/dist/{scan-zKsddO72.js → scan-DLrsrFS9.js} +48 -37
- package/dist/scope-V336uz8j.js +198 -0
- package/dist/screenshot-file-0UETadF8.js +16 -0
- package/dist/{selection-CxZoX4NT.js → selection-Rdw-ZUoG.js} +94 -51
- package/dist/send-BxD9yf6F.js +150 -0
- package/dist/{dev-DmB3XqaJ.js → server-D0tGG8C4.js} +82 -92
- package/dist/server-z1LH94R_.js +22 -0
- package/dist/session-1AV_Bs_d.js +6 -0
- package/dist/session-CFAmMhem.js +40 -0
- package/dist/session-D_nEWKXT.js +768 -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 +78 -28
- package/dist/skills/superwall-framework/references/cli.md +58 -28
- package/dist/skills/superwall-framework/references/examples.md +4 -3
- package/dist/skills/superwall-framework/references/layout.md +30 -8
- 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-DPzlnfCK.js → skills-BvFOa4y6.js} +99 -122
- package/dist/skills-DMG4bpKk.js +14 -0
- package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
- package/dist/spinner-CneRK5rk.js +294 -0
- package/dist/storage-DYvmIOHa.d.ts +16 -0
- package/dist/storage-s2Dnz-yl.js +31 -0
- package/dist/storekit-DafAnGkM.js +16 -0
- package/dist/storekit-yY_kS2iR.js +47 -0
- package/dist/telemetry-DtG92m5O.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-DzRh7dI1.js} +6 -38
- package/dist/tools.d.ts +96 -0
- package/dist/tools.js +11178 -0
- package/dist/ui-D_qf3Gvw.js +53 -0
- package/dist/upgrade-Bt4Ouw1y.js +117 -0
- package/dist/upgrade-Cqy5orjb.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-ByZ6XYnn.js} +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { n as readDefaultApp, u as writeDefaultApp } from "./config-BO1Y87kV.js";
|
|
2
|
+
import { t as apiCall, u as currentHost } from "./spinner-CneRK5rk.js";
|
|
3
|
+
import { A as listOrgGroups, M as orgIdOf, P as organizationOf, c as findPaywall, p as listProjects, v as platformLabel } from "./resources-Dqr01Dep.js";
|
|
4
|
+
import { t as chooseOrgOfApps } from "./org-D0g_q3mv.js";
|
|
5
|
+
import { n as findApplication, r as findProject, t as appNotFound } from "./lookup-D-nmmAbw.js";
|
|
6
|
+
|
|
7
|
+
//#region src/core/account/scope.ts
|
|
8
|
+
function moveFirst(items, match) {
|
|
9
|
+
const idx = items.findIndex(match);
|
|
10
|
+
const item = items[idx];
|
|
11
|
+
if (idx <= 0 || item === void 0) return items;
|
|
12
|
+
return [
|
|
13
|
+
item,
|
|
14
|
+
...items.slice(0, idx),
|
|
15
|
+
...items.slice(idx + 1)
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
function matchProject(projects, local) {
|
|
19
|
+
if (local.apiKey) {
|
|
20
|
+
const p = projects.find((project) => (project.applications ?? []).some((a) => a.public_api_key === local.apiKey));
|
|
21
|
+
if (p) return {
|
|
22
|
+
project: p,
|
|
23
|
+
exact: true
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (local.name) {
|
|
27
|
+
const p = projects.find((project) => project.name === local.name || (project.applications ?? []).some((a) => a.name === local.name));
|
|
28
|
+
if (p) return {
|
|
29
|
+
project: p,
|
|
30
|
+
exact: false
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { exact: false };
|
|
34
|
+
}
|
|
35
|
+
function matchApp(apps, local) {
|
|
36
|
+
if (local.apiKey) {
|
|
37
|
+
const a = apps.find((app) => app.public_api_key === local.apiKey);
|
|
38
|
+
if (a) return a;
|
|
39
|
+
}
|
|
40
|
+
if (local.name) return apps.find((app) => app.name === local.name);
|
|
41
|
+
}
|
|
42
|
+
async function lockBoundScope(context, api, projects) {
|
|
43
|
+
if (context.target.project || context.target.app) return void 0;
|
|
44
|
+
const appId = await resolveLockAppId(api, currentHost().readLockRef(context.installDir));
|
|
45
|
+
if (!appId) return void 0;
|
|
46
|
+
const found = await findApplication(api, appId, projects);
|
|
47
|
+
if (!found) return void 0;
|
|
48
|
+
context.ui.info(`Using \`${found.app.name ?? found.app.id}\` - bound in superwall.lock.`);
|
|
49
|
+
return found;
|
|
50
|
+
}
|
|
51
|
+
async function resolveLockAppId(api, lock) {
|
|
52
|
+
if (lock?.appId !== void 0) return lock.appId;
|
|
53
|
+
if (!lock?.paywallId) return void 0;
|
|
54
|
+
return (await findPaywall(api, lock.paywallId).catch(() => void 0))?.applicationId;
|
|
55
|
+
}
|
|
56
|
+
async function pickScope(context, api, appScoped) {
|
|
57
|
+
const projects = await apiCall(context, "Loading projects", () => listProjects(api));
|
|
58
|
+
const appFlag = context.target.app;
|
|
59
|
+
let bound;
|
|
60
|
+
if (appFlag) bound = await namedApp(context, api, projects, appFlag);
|
|
61
|
+
else bound = await lockBoundScope(context, api, projects);
|
|
62
|
+
if (bound) return {
|
|
63
|
+
projectId: String(bound.project.id),
|
|
64
|
+
applicationId: appScoped ? String(bound.app.id) : void 0,
|
|
65
|
+
projectName: bound.project.name,
|
|
66
|
+
appName: appScoped ? bound.app.name : void 0,
|
|
67
|
+
appPlatform: appScoped ? bound.app.platform : void 0,
|
|
68
|
+
projectCount: projects.length,
|
|
69
|
+
appCount: bound.project.applications?.length ?? 0
|
|
70
|
+
};
|
|
71
|
+
const project = await pickProject(context, api, projects);
|
|
72
|
+
const projectId = String(project.id);
|
|
73
|
+
const apps = project.applications ?? [];
|
|
74
|
+
let app;
|
|
75
|
+
if (appScoped) {
|
|
76
|
+
const remembered = apps.find((candidate) => String(candidate.id) === readDefaultApp(projectId));
|
|
77
|
+
const [first] = apps;
|
|
78
|
+
if (!first || apps.length === 1) app = first;
|
|
79
|
+
else if (!context.interactive) throw new Error(`${project.name ?? projectId} has ${apps.length} apps - pass --app <id>:\n` + candidates(apps.map((a) => [
|
|
80
|
+
a.id,
|
|
81
|
+
a.platform ? platformLabel(a.platform) : "",
|
|
82
|
+
a.name ?? ""
|
|
83
|
+
].filter(Boolean).join(" "))));
|
|
84
|
+
else {
|
|
85
|
+
app = await chooseApp(context, apps, remembered ?? first);
|
|
86
|
+
writeDefaultApp(projectId, String(app.id));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
projectId,
|
|
91
|
+
applicationId: app ? String(app.id) : void 0,
|
|
92
|
+
projectName: project.name,
|
|
93
|
+
appName: app?.name,
|
|
94
|
+
appPlatform: app?.platform,
|
|
95
|
+
projectCount: projects.length,
|
|
96
|
+
appCount: apps.length
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async function boundOrganization(context, api) {
|
|
100
|
+
const projects = await apiCall(context, "Loading projects", () => listProjects(api));
|
|
101
|
+
const appFlag = context.target.app;
|
|
102
|
+
let project;
|
|
103
|
+
if (appFlag) project = (await namedApp(context, api, projects, appFlag)).project;
|
|
104
|
+
else if (context.target.project) project = await pickProject(context, api, projects);
|
|
105
|
+
else project = (await lockBoundScope(context, api, projects))?.project;
|
|
106
|
+
return project && organizationOf(api, String(project.id), projects);
|
|
107
|
+
}
|
|
108
|
+
async function pickOrganization(context, api) {
|
|
109
|
+
const bound = await boundOrganization(context, api);
|
|
110
|
+
if (bound) return bound;
|
|
111
|
+
const projects = await listProjects(api);
|
|
112
|
+
const orgs = [...new Set(projects.map(orgIdOf).filter((id) => id !== void 0))];
|
|
113
|
+
const [first] = orgs;
|
|
114
|
+
if (first === void 0) throw new Error("No projects yet - run `superwall apps create --name <name> --platform ios`.");
|
|
115
|
+
if (orgs.length === 1) return first;
|
|
116
|
+
if (!context.interactive) {
|
|
117
|
+
const groups = await listOrgGroups(api);
|
|
118
|
+
throw new Error(`Your apps are in ${groups.length} organizations - pass --app <id|dashboard link> to say whose:\n` + candidates(groups.map((group) => {
|
|
119
|
+
const app = group.projects.flatMap((p) => p.applications ?? [])[0];
|
|
120
|
+
return `${group.name ?? `Organization ${group.id}`}${app ? ` e.g. --app ${app.id}` : ""}`;
|
|
121
|
+
})));
|
|
122
|
+
}
|
|
123
|
+
return chooseOrgOfApps(api, "Whose apps?");
|
|
124
|
+
}
|
|
125
|
+
async function namedApp(context, api, projects, appFlag) {
|
|
126
|
+
let found;
|
|
127
|
+
if (context.target.project) {
|
|
128
|
+
const project = await pickProject(context, api, projects);
|
|
129
|
+
const app = project.applications?.find((candidate) => String(candidate.id) === appFlag || candidate.name === appFlag);
|
|
130
|
+
if (!app) throw new Error(`No app ${appFlag} in ${project.name ?? project.id}.`);
|
|
131
|
+
found = {
|
|
132
|
+
project,
|
|
133
|
+
app
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
found = await findApplication(api, appFlag, projects);
|
|
137
|
+
if (!found) throw appNotFound(appFlag);
|
|
138
|
+
}
|
|
139
|
+
writeDefaultApp(String(found.project.id), String(found.app.id));
|
|
140
|
+
return found;
|
|
141
|
+
}
|
|
142
|
+
async function pickProject(context, api, projects) {
|
|
143
|
+
const projectFlag = context.target.project;
|
|
144
|
+
if (projectFlag) {
|
|
145
|
+
const p = await findProject(api, projectFlag, projects);
|
|
146
|
+
if (!p) throw new Error(`No project ${projectFlag} that this account can open.`);
|
|
147
|
+
return p;
|
|
148
|
+
}
|
|
149
|
+
const [first] = projects;
|
|
150
|
+
if (!first) throw new Error("No projects yet - run `superwall apps create --name <name> --platform ios`.");
|
|
151
|
+
if (projects.length === 1) return first;
|
|
152
|
+
const { project: preferred, exact } = matchProject(projects, await currentHost().detectApp(context.installDir));
|
|
153
|
+
if (exact && preferred) {
|
|
154
|
+
context.ui.info(`Using \`${preferred.name}\` - detected in this directory.`);
|
|
155
|
+
return preferred;
|
|
156
|
+
}
|
|
157
|
+
if (!context.interactive) throw new Error(`You can open ${projects.length} projects - pass --app <id|dashboard link> or --project <id>:\n` + candidates(projects.map((p) => `${p.id} ${p.name ?? ""}${(p.applications ?? []).length ? ` (apps ${(p.applications ?? []).map((a) => a.id).join(", ")})` : ""}`)));
|
|
158
|
+
return chooseProject(context, projects, preferred);
|
|
159
|
+
}
|
|
160
|
+
async function chooseProject(context, projects, preferred) {
|
|
161
|
+
const ordered = preferred ? moveFirst(projects, (p) => String(p.id) === String(preferred.id)) : projects;
|
|
162
|
+
const selection = await context.ui.select({
|
|
163
|
+
message: "Which project?",
|
|
164
|
+
options: ordered.map((project) => ({
|
|
165
|
+
value: String(project.id),
|
|
166
|
+
label: project.name ?? String(project.id)
|
|
167
|
+
})),
|
|
168
|
+
initialValue: preferred ? String(preferred.id) : void 0
|
|
169
|
+
});
|
|
170
|
+
if (selection === null) throw new Error("Cancelled.");
|
|
171
|
+
const chosen = projects.find((project) => String(project.id) === selection);
|
|
172
|
+
if (!chosen) throw new Error(`No project ${selection}.`);
|
|
173
|
+
return chosen;
|
|
174
|
+
}
|
|
175
|
+
async function chooseApp(context, apps, defaultApp) {
|
|
176
|
+
const top = matchApp(apps, await currentHost().detectApp(context.installDir)) ?? defaultApp;
|
|
177
|
+
const ordered = moveFirst(apps, (app) => String(app.id) === String(top.id));
|
|
178
|
+
const selection = await context.ui.select({
|
|
179
|
+
message: "Which app?",
|
|
180
|
+
options: ordered.map((app) => ({
|
|
181
|
+
value: String(app.id),
|
|
182
|
+
label: app.name ?? String(app.id),
|
|
183
|
+
hint: platformLabel(app.platform)
|
|
184
|
+
})),
|
|
185
|
+
initialValue: String(top.id)
|
|
186
|
+
});
|
|
187
|
+
if (selection === null) throw new Error("Cancelled.");
|
|
188
|
+
return apps.find((app) => String(app.id) === selection) ?? top;
|
|
189
|
+
}
|
|
190
|
+
const CANDIDATES_SHOWN = 10;
|
|
191
|
+
function candidates(lines) {
|
|
192
|
+
const shown = lines.slice(0, CANDIDATES_SHOWN).map((line) => ` ${line.trimEnd()}`);
|
|
193
|
+
if (lines.length > CANDIDATES_SHOWN) shown.push(` …and ${lines.length - CANDIDATES_SHOWN} more: \`superwall apps list\` lists them all.`);
|
|
194
|
+
return shown.join("\n");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
//#endregion
|
|
198
|
+
export { pickScope as a, pickProject as i, chooseApp as n, pickOrganization as r, boundOrganization as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
//#region src/core/app-store-connect/resources/screenshot-file.ts
|
|
6
|
+
function readScreenshotFile(path) {
|
|
7
|
+
const bytes = new Uint8Array(readFileSync(path));
|
|
8
|
+
return {
|
|
9
|
+
name: basename(path),
|
|
10
|
+
bytes,
|
|
11
|
+
checksum: createHash("md5").update(bytes).digest("hex")
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { readScreenshotFile };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { r as ASSET_HOST } from "./environment-DF1qKlny.js";
|
|
2
|
+
import { t as ApiError } from "./client-DP6Rc0t_.js";
|
|
3
|
+
import { b as pushPaywallAssets } from "./resources-Dqr01Dep.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
|
-
import pc from "picocolors";
|
|
6
|
-
import * as path from "node:path";
|
|
7
|
-
import { join, resolve } from "node:path";
|
|
8
5
|
import * as fs from "node:fs";
|
|
9
6
|
import { globSync, readFileSync, statSync } from "node:fs";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import { join, resolve } from "node:path";
|
|
9
|
+
import pc from "picocolors";
|
|
10
10
|
import { pathToFileURL } from "node:url";
|
|
11
11
|
|
|
12
12
|
//#region src/core/paywalls/assets.ts
|
|
@@ -102,7 +102,6 @@ async function importSubpath(packageDir, subpath) {
|
|
|
102
102
|
return import(pathToFileURL(createRequire(join(packageDir, "package.json")).resolve(subpath)).href);
|
|
103
103
|
}
|
|
104
104
|
function fn(mod, name, subpath) {
|
|
105
|
-
if (typeof mod !== "object" || mod === null) throw new Error(`superwall ${subpath} did not load as a module`);
|
|
106
105
|
const candidate = mod[name];
|
|
107
106
|
if (typeof candidate !== "function") throw new Error(`This project's superwall version does not export ${name} from ${subpath} — update the project's superwall dependency.`);
|
|
108
107
|
return candidate;
|
|
@@ -117,24 +116,21 @@ function resolveFrameworkDir(cwd) {
|
|
|
117
116
|
}
|
|
118
117
|
function frameworkVersion(cwd) {
|
|
119
118
|
try {
|
|
120
|
-
const
|
|
121
|
-
if (typeof
|
|
122
|
-
const version = parsed.version;
|
|
123
|
-
if (typeof version === "string" && version !== "") return version;
|
|
124
|
-
}
|
|
119
|
+
const { version } = JSON.parse(readFileSync(join(resolveFrameworkDir(cwd), "package.json"), "utf8"));
|
|
120
|
+
if (typeof version === "string" && version !== "") return version;
|
|
125
121
|
} catch {
|
|
126
122
|
return "unknown";
|
|
127
123
|
}
|
|
128
124
|
return "unknown";
|
|
129
125
|
}
|
|
130
|
-
async function
|
|
126
|
+
async function resolveFramework(cwd) {
|
|
131
127
|
const dir = resolveFrameworkDir(cwd);
|
|
132
128
|
const [discover, build, preview] = await Promise.all([
|
|
133
129
|
importSubpath(dir, "superwall/discover"),
|
|
134
130
|
importSubpath(dir, "superwall/build"),
|
|
135
131
|
importSubpath(dir, "superwall/preview")
|
|
136
132
|
]);
|
|
137
|
-
const studioProject = typeof preview
|
|
133
|
+
const studioProject = typeof preview.buildStudioProject === "function" ? preview.buildStudioProject : void 0;
|
|
138
134
|
return {
|
|
139
135
|
discoverProject: fn(discover, "discoverProject", "superwall/discover"),
|
|
140
136
|
buildSnapshot: fn(build, "buildSnapshot", "superwall/build"),
|
|
@@ -172,7 +168,7 @@ const readOrigin = (candidate) => {
|
|
|
172
168
|
};
|
|
173
169
|
}
|
|
174
170
|
};
|
|
175
|
-
const EXPLAINER = "Commit this file: it binds each paywall to its dashboard entry, per app, so every machine and CI push to the same place. Managed by the Superwall CLI.";
|
|
171
|
+
const EXPLAINER = "Commit this file: it binds each paywall to its dashboard entry, per app, so every machine and CI push to the same place, and the source commit each app was last synced to. Managed by the Superwall CLI.";
|
|
176
172
|
const emptyLock = () => ({
|
|
177
173
|
version: 1,
|
|
178
174
|
apps: {},
|
|
@@ -194,10 +190,20 @@ const lockPath = (superwallDir) => path.join(superwallDir, "superwall.lock");
|
|
|
194
190
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
195
191
|
const readBinding = (value) => {
|
|
196
192
|
if (!isRecord(value) || typeof value.paywallId !== "string") return void 0;
|
|
197
|
-
|
|
193
|
+
if (typeof value.snapshot !== "string") return { paywallId: value.paywallId };
|
|
194
|
+
return Number.isInteger(value.sourcePending) ? {
|
|
195
|
+
paywallId: value.paywallId,
|
|
196
|
+
snapshot: value.snapshot,
|
|
197
|
+
sourcePending: Number(value.sourcePending)
|
|
198
|
+
} : {
|
|
198
199
|
paywallId: value.paywallId,
|
|
199
200
|
snapshot: value.snapshot
|
|
200
|
-
}
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
const COMMIT_SHA = /^[0-9a-f]{40}$/;
|
|
204
|
+
const parseSources = (value) => {
|
|
205
|
+
if (!isRecord(value)) return {};
|
|
206
|
+
return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string" && COMMIT_SHA.test(entry[1])));
|
|
201
207
|
};
|
|
202
208
|
const readSection = (value) => {
|
|
203
209
|
const section = {};
|
|
@@ -213,34 +219,59 @@ const readSection = (value) => {
|
|
|
213
219
|
}
|
|
214
220
|
return section;
|
|
215
221
|
};
|
|
222
|
+
const CONFLICT_MARKER = /^(<{7}|={7}|>{7})( |$)/m;
|
|
223
|
+
function parseLockFile(file) {
|
|
224
|
+
const text = fs.readFileSync(file, "utf8");
|
|
225
|
+
if (CONFLICT_MARKER.test(text)) throw new Error(`${file} has unresolved merge conflicts — resolve them, then run again.`);
|
|
226
|
+
let parsed;
|
|
227
|
+
try {
|
|
228
|
+
parsed = JSON.parse(text);
|
|
229
|
+
} catch (error) {
|
|
230
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
231
|
+
throw new Error(`${file} isn't valid JSON (${reason}) — fix it or restore it from git.`);
|
|
232
|
+
}
|
|
233
|
+
if (!isRecord(parsed) || typeof parsed.version !== "number") throw new Error(`${file} isn't a Superwall lock file — fix it or restore it from git.`);
|
|
234
|
+
if (parsed.version > 1) throw new Error(`${file} was written by a newer Superwall CLI (lock version ${parsed.version}) — run \`superwall upgrade\`.`);
|
|
235
|
+
if (parsed.version !== 1) throw new Error(`${file} has an unknown lock version (${parsed.version}) — fix it or restore it from git.`);
|
|
236
|
+
return parsed;
|
|
237
|
+
}
|
|
216
238
|
function readLock(superwallDir) {
|
|
217
239
|
const file = lockPath(superwallDir);
|
|
218
240
|
if (!fs.existsSync(file)) return emptyLock();
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const lock =
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
} catch {}
|
|
232
|
-
return emptyLock();
|
|
241
|
+
const parsed = parseLockFile(file);
|
|
242
|
+
const lock = emptyLock();
|
|
243
|
+
if (isRecord(parsed.apps)) {
|
|
244
|
+
for (const [platform, id] of Object.entries(parsed.apps)) if (typeof id === "string") lock.apps[platform] = id;
|
|
245
|
+
}
|
|
246
|
+
lock.paywalls = readSection(parsed.paywalls);
|
|
247
|
+
lock.funnels = readSection(parsed.funnels);
|
|
248
|
+
const origins = readOrigins(parsed.origins);
|
|
249
|
+
if (origins) lock.origins = origins;
|
|
250
|
+
const sources = parseSources(parsed.sources);
|
|
251
|
+
if (Object.keys(sources).length > 0) lock.sources = sources;
|
|
252
|
+
return lock;
|
|
233
253
|
}
|
|
234
|
-
function
|
|
254
|
+
function formatLock(lock) {
|
|
235
255
|
const annotated = {
|
|
236
256
|
"//": EXPLAINER,
|
|
237
257
|
version: lock.version,
|
|
238
258
|
apps: lock.apps,
|
|
239
259
|
paywalls: lock.paywalls,
|
|
240
260
|
funnels: lock.funnels,
|
|
241
|
-
...lock.origins && Object.keys(lock.origins).length > 0 ? { origins: lock.origins } : {}
|
|
261
|
+
...lock.origins && Object.keys(lock.origins).length > 0 ? { origins: lock.origins } : {},
|
|
262
|
+
...lock.sources && Object.keys(lock.sources).length > 0 ? { sources: lock.sources } : {}
|
|
242
263
|
};
|
|
243
|
-
|
|
264
|
+
return `${JSON.stringify(annotated, null, 2)}\n`;
|
|
265
|
+
}
|
|
266
|
+
function formatSharedLock(superwallDir) {
|
|
267
|
+
const { sources: _,...lock } = readLock(superwallDir);
|
|
268
|
+
return formatLock(lock);
|
|
269
|
+
}
|
|
270
|
+
function writeLock(superwallDir, lock) {
|
|
271
|
+
const file = lockPath(superwallDir);
|
|
272
|
+
const temporary = `${file}.${process.pid}.tmp`;
|
|
273
|
+
fs.writeFileSync(temporary, formatLock(lock));
|
|
274
|
+
fs.renameSync(temporary, file);
|
|
244
275
|
}
|
|
245
276
|
function writeOrigin(superwallDir, kind, surfaceId, origin) {
|
|
246
277
|
const lock = readLock(superwallDir);
|
|
@@ -270,20 +301,33 @@ function writeBindings(superwallDir, kind, surfaceId, bindings) {
|
|
|
270
301
|
sectionOf(lock, kind)[surfaceId] = { ...bindings };
|
|
271
302
|
writeLock(superwallDir, lock);
|
|
272
303
|
}
|
|
273
|
-
function writeSnapshot(superwallDir, kind, surfaceId, platform,
|
|
304
|
+
function writeSnapshot(superwallDir, kind, surfaceId, platform, pushed) {
|
|
274
305
|
const lock = readLock(superwallDir);
|
|
275
306
|
const section = sectionOf(lock, kind);
|
|
276
307
|
const binding = section[surfaceId]?.[platform];
|
|
277
|
-
if (!binding
|
|
308
|
+
if (!binding) return;
|
|
309
|
+
if (binding.snapshot === pushed.snapshot && binding.sourcePending === pushed.sourcePending) return;
|
|
278
310
|
section[surfaceId] = {
|
|
279
311
|
...section[surfaceId],
|
|
280
|
-
[platform]: {
|
|
281
|
-
|
|
282
|
-
snapshot
|
|
312
|
+
[platform]: pushed.sourcePending === void 0 ? {
|
|
313
|
+
paywallId: binding.paywallId,
|
|
314
|
+
snapshot: pushed.snapshot
|
|
315
|
+
} : {
|
|
316
|
+
paywallId: binding.paywallId,
|
|
317
|
+
snapshot: pushed.snapshot,
|
|
318
|
+
sourcePending: pushed.sourcePending
|
|
283
319
|
}
|
|
284
320
|
};
|
|
285
321
|
writeLock(superwallDir, lock);
|
|
286
322
|
}
|
|
323
|
+
function writeSources(superwallDir, sources) {
|
|
324
|
+
const lock = readLock(superwallDir);
|
|
325
|
+
lock.sources = {
|
|
326
|
+
...lock.sources,
|
|
327
|
+
...sources
|
|
328
|
+
};
|
|
329
|
+
writeLock(superwallDir, lock);
|
|
330
|
+
}
|
|
287
331
|
function removeBinding(superwallDir, kind, surfaceId) {
|
|
288
332
|
const lock = readLock(superwallDir);
|
|
289
333
|
const section = sectionOf(lock, kind);
|
|
@@ -354,7 +398,7 @@ function projectTypes(project, products = {}) {
|
|
|
354
398
|
for (const surface of project.surfaces) for (const route of surface.routes) names.add(route.name);
|
|
355
399
|
const sorted = [...names].sort();
|
|
356
400
|
const sortedProducts = Object.keys(products).sort();
|
|
357
|
-
const sortedStripe =
|
|
401
|
+
const sortedStripe = Object.entries(products).filter(([, identifiers]) => identifiers.some(isStripeIdentifier)).map(([name]) => name).sort();
|
|
358
402
|
const blocks = [sorted.length > 0 ? routeBlock(sorted) : "", sortedProducts.length > 0 ? productBlock(sortedProducts, sortedStripe) : ""].filter(Boolean);
|
|
359
403
|
return blocks.length === 0 ? `${HEADER}\nexport {};\n` : `${HEADER}\n${blocks.join("\n\n")}\n`;
|
|
360
404
|
}
|
|
@@ -377,7 +421,7 @@ function writeProjectTypes(project, products = {}) {
|
|
|
377
421
|
}
|
|
378
422
|
|
|
379
423
|
//#endregion
|
|
380
|
-
//#region src/
|
|
424
|
+
//#region src/core/paywalls/pipeline/output.ts
|
|
381
425
|
const kb = (bytes) => `${(bytes / 1024).toFixed(1)} kB`;
|
|
382
426
|
const weight = (bytes) => bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : kb(bytes);
|
|
383
427
|
const SHORT_SHA = 7;
|
|
@@ -422,7 +466,7 @@ function pendingPromoteWarning(pending, multi = false) {
|
|
|
422
466
|
].join("\n");
|
|
423
467
|
}
|
|
424
468
|
function resolveNote(message) {
|
|
425
|
-
if (
|
|
469
|
+
if (message === void 0) return void 0;
|
|
426
470
|
if (message.length > NOTE_LIMIT) throw new Error(`Publish note is ${message.length} characters (limit ${NOTE_LIMIT}).`);
|
|
427
471
|
return message;
|
|
428
472
|
}
|
|
@@ -432,14 +476,13 @@ const took = (since) => {
|
|
|
432
476
|
};
|
|
433
477
|
|
|
434
478
|
//#endregion
|
|
435
|
-
//#region src/
|
|
436
|
-
function
|
|
437
|
-
const [first] =
|
|
479
|
+
//#region src/core/paywalls/pipeline/selection.ts
|
|
480
|
+
function resolveProjectDir(dir) {
|
|
481
|
+
const [first] = resolveProjectDirs(dir === void 0 ? [] : [dir]);
|
|
438
482
|
return first ?? process.cwd();
|
|
439
483
|
}
|
|
440
|
-
function
|
|
441
|
-
const
|
|
442
|
-
const list = (Array.isArray(raw) ? raw : raw === void 0 ? [] : [raw]).filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
484
|
+
function resolveProjectDirs(dirs) {
|
|
485
|
+
const list = dirs.filter((entry) => entry.length > 0);
|
|
443
486
|
if (list.length === 0) return [process.cwd()];
|
|
444
487
|
const expanded = list.flatMap((entry) => entry.includes("*") ? expandGlob(entry) : [entry]);
|
|
445
488
|
return [...new Set(expanded.map((entry) => resolve(entry)))];
|
|
@@ -456,8 +499,8 @@ function requireProject(project, dir) {
|
|
|
456
499
|
if (project.packageName === "superwall") throw new Error(`${project.superwallDir}/package.json is named "superwall".\nNode resolves every bare \`import "superwall"\` inside a package to that package itself, so the framework can never load. Rename it to your project's name.`);
|
|
457
500
|
return project;
|
|
458
501
|
}
|
|
459
|
-
function parseIds(
|
|
460
|
-
return
|
|
502
|
+
function parseIds(values) {
|
|
503
|
+
return values.flatMap((entry) => entry.split(",")).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
461
504
|
}
|
|
462
505
|
function selectSurfaces(project, ids) {
|
|
463
506
|
const wanted = parseIds(ids);
|
|
@@ -493,4 +536,4 @@ function needsWork(built, pushed, live) {
|
|
|
493
536
|
}
|
|
494
537
|
|
|
495
538
|
//#endregion
|
|
496
|
-
export {
|
|
539
|
+
export { writeSources as A, readLock as C, writeBindings as D, writeBinding as E, syncAssets as F, resolveFramework as M, assetBaseUrl as N, writeOrigin as O, requireAssets as P, parseSources as S, writeApp as T, collectProjectDeclarations as _, resolveProjectDir as a, formatSharedLock as b, BIND_VERB as c, pendingPromoteWarning as d, pushedLine as f, weight as g, transition as h, requireProject as i, frameworkVersion as j, writeSnapshot as k, LAYOUT_HINT as l, took as m, parseIds as n, resolveProjectDirs as o, resolveNote as p, requireClean as r, selectSurfaces as s, needsWork as t, kb as u, writeProjectTypes as v, removeBinding as w, isScreenOrigin as x, describeBindings as y };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import "./token-DzRh7dI1.js";
|
|
2
|
+
import "./output-Ggzq5_-t.js";
|
|
3
|
+
import { _ as VERSION, g as TELEMETRY_KEY, h as TELEMETRY_HOST } from "./environment-DF1qKlny.js";
|
|
4
|
+
import { t as readSession } from "./storage-s2Dnz-yl.js";
|
|
5
|
+
import "./client-DP6Rc0t_.js";
|
|
6
|
+
import { r as readOnboardedApp, t as readAnonymousId } from "./config-BO1Y87kV.js";
|
|
7
|
+
import { M as orgIdOf } from "./resources-Dqr01Dep.js";
|
|
8
|
+
import { n as findApplication } from "./lookup-D-nmmAbw.js";
|
|
9
|
+
import { t as FEEDBACK_KINDS } from "./kinds-GFXB3sYu.js";
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { basename } from "node:path";
|
|
12
|
+
import { arch, release } from "node:os";
|
|
13
|
+
|
|
14
|
+
//#region src/core/support/feedback/send.ts
|
|
15
|
+
const MAX_FILES = 5;
|
|
16
|
+
const MAX_FILE_CHARS = 2e4;
|
|
17
|
+
function parseContext(pairs) {
|
|
18
|
+
const out = {};
|
|
19
|
+
for (const pair of pairs) {
|
|
20
|
+
const at = pair.indexOf("=");
|
|
21
|
+
if (at < 1) throw new Error(`--context expects key=value, got "${pair}"`);
|
|
22
|
+
out[pair.slice(0, at).trim()] = pair.slice(at + 1).trim();
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
function linkedApp(cwd = process.cwd()) {
|
|
27
|
+
const app = readOnboardedApp(cwd);
|
|
28
|
+
return {
|
|
29
|
+
projectId: app?.projectId,
|
|
30
|
+
applicationId: app?.applicationId
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const AGENT_ENV = [
|
|
34
|
+
["CLAUDECODE", "claude-code"],
|
|
35
|
+
["CODEX_SANDBOX", "codex"],
|
|
36
|
+
["CURSOR_AGENT", "cursor"],
|
|
37
|
+
["GEMINI_CLI", "gemini-cli"]
|
|
38
|
+
];
|
|
39
|
+
function detectAgent(env = process.env) {
|
|
40
|
+
return AGENT_ENV.find(([key]) => env[key])?.[1];
|
|
41
|
+
}
|
|
42
|
+
function readAttachments(paths) {
|
|
43
|
+
if (paths.length > MAX_FILES) throw new Error(`Attach at most ${MAX_FILES} files.`);
|
|
44
|
+
return paths.map((path) => {
|
|
45
|
+
const raw = readFileSync(path === "-" ? 0 : path, "utf8");
|
|
46
|
+
const truncated = raw.length > MAX_FILE_CHARS;
|
|
47
|
+
return {
|
|
48
|
+
name: path === "-" ? "stdin" : basename(path),
|
|
49
|
+
content: truncated ? raw.slice(-MAX_FILE_CHARS) : raw,
|
|
50
|
+
truncated
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function buildFeedbackEvent(feedback, via, distinctId, session) {
|
|
55
|
+
return {
|
|
56
|
+
api_key: TELEMETRY_KEY(),
|
|
57
|
+
event: "feedback submitted",
|
|
58
|
+
distinct_id: distinctId,
|
|
59
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
60
|
+
properties: {
|
|
61
|
+
$process_person_profile: false,
|
|
62
|
+
title: feedback.title ?? null,
|
|
63
|
+
message: feedback.message,
|
|
64
|
+
kind: feedback.kind,
|
|
65
|
+
command: feedback.command ?? null,
|
|
66
|
+
project_id: feedback.projectId ?? null,
|
|
67
|
+
application_id: feedback.applicationId ?? null,
|
|
68
|
+
organization_id: feedback.organizationId ?? null,
|
|
69
|
+
context: feedback.context,
|
|
70
|
+
attachments: feedback.attachments,
|
|
71
|
+
via,
|
|
72
|
+
agent: feedback.agent ?? null,
|
|
73
|
+
cli_version: VERSION,
|
|
74
|
+
platform: process.platform,
|
|
75
|
+
os_release: release(),
|
|
76
|
+
arch: arch(),
|
|
77
|
+
node_version: process.version,
|
|
78
|
+
ci: process.env.CI === "true",
|
|
79
|
+
email: session?.userEmail ?? null,
|
|
80
|
+
org_name: session?.orgName ?? null,
|
|
81
|
+
auth_method: session?.authMethod ?? null
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async function submitFeedback(feedback, via) {
|
|
86
|
+
const payload = buildFeedbackEvent(feedback, via, readAnonymousId(), readSession());
|
|
87
|
+
try {
|
|
88
|
+
return (await fetch(`${TELEMETRY_HOST()}/capture/`, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: { "content-type": "application/json" },
|
|
91
|
+
body: JSON.stringify(payload),
|
|
92
|
+
signal: AbortSignal.timeout(8e3)
|
|
93
|
+
})).ok;
|
|
94
|
+
} catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const ORG_LOOKUP_MS = 3e3;
|
|
99
|
+
async function organizationOfApp(api, applicationId) {
|
|
100
|
+
if (!api || !applicationId) return void 0;
|
|
101
|
+
const lookup = findApplication(api, applicationId).then((found) => found ? orgIdOf(found.project) : void 0).catch(() => void 0);
|
|
102
|
+
const timeout = new Promise((resolve$1) => {
|
|
103
|
+
setTimeout(() => resolve$1(void 0), ORG_LOOKUP_MS).unref();
|
|
104
|
+
});
|
|
105
|
+
return Promise.race([lookup, timeout]);
|
|
106
|
+
}
|
|
107
|
+
async function runFeedback(ctx, { args, flags }) {
|
|
108
|
+
const { ui, json, interactive } = ctx;
|
|
109
|
+
let message = args.message;
|
|
110
|
+
if (!message && interactive) {
|
|
111
|
+
ui.intro("Superwall feedback");
|
|
112
|
+
const answer = await ui.text({
|
|
113
|
+
message: "What's your feedback on Superwall?",
|
|
114
|
+
placeholder: "What worked, what didn't, what's missing...",
|
|
115
|
+
validate: (v) => v?.trim() ? void 0 : "Required"
|
|
116
|
+
});
|
|
117
|
+
if (answer === null) return void ui.warn("Cancelled.");
|
|
118
|
+
message = answer.trim();
|
|
119
|
+
}
|
|
120
|
+
if (!message) throw new Error("Usage: superwall feedback \"<message>\" [--title ...] [--kind bug] [--file log.txt]");
|
|
121
|
+
const kind = FEEDBACK_KINDS.find((candidate) => candidate === flags.kind);
|
|
122
|
+
if (!kind) throw new Error(`--kind must be one of: ${FEEDBACK_KINDS.join(", ")}`);
|
|
123
|
+
const agent = flags.agent ?? detectAgent();
|
|
124
|
+
const attachments = readAttachments(flags.file.filter(Boolean));
|
|
125
|
+
const context = parseContext(flags.context);
|
|
126
|
+
const linked = linkedApp();
|
|
127
|
+
const applicationId = flags.app ?? linked.applicationId;
|
|
128
|
+
const via = agent || !interactive ? "agent" : "human";
|
|
129
|
+
const spin = interactive ? ui.spinner() : null;
|
|
130
|
+
spin?.start("Sending your feedback");
|
|
131
|
+
const ok = await submitFeedback({
|
|
132
|
+
title: flags.title,
|
|
133
|
+
message,
|
|
134
|
+
kind,
|
|
135
|
+
command: flags.command,
|
|
136
|
+
agent,
|
|
137
|
+
projectId: flags.project ?? linked.projectId,
|
|
138
|
+
applicationId,
|
|
139
|
+
organizationId: await organizationOfApp(ctx.api, applicationId),
|
|
140
|
+
context,
|
|
141
|
+
attachments
|
|
142
|
+
}, via);
|
|
143
|
+
spin?.stop(ok ? "Sent" : "Failed to send");
|
|
144
|
+
if (json) return ctx.output.data({ submitted: ok });
|
|
145
|
+
if (!ok) throw new Error("Couldn't send your feedback - check your connection and try again.");
|
|
146
|
+
ui.success("Thank you! We've received your feedback and will read through it. Really appreciate you helping us make Superwall better.");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
export { MAX_FILES, MAX_FILE_CHARS, buildFeedbackEvent, detectAgent, organizationOfApp, parseContext, readAttachments, runFeedback };
|