@superwall/cli 1.6.2 → 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 +281 -34
- package/dist/apple-CkKlHBZ9.js +195 -0
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-H7f6knyY.js → billing-XCZU_T46.js} +98 -28
- package/dist/{bind-BIzaGq8K.js → bind-drne__Ys.js} +38 -33
- package/dist/{build-B7BS1rF2.js → build-Gpdq5QXP.js} +20 -26
- package/dist/client-BZ1UbpXz.js +66 -0
- package/dist/client-DP6Rc0t_.js +176 -0
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/create-BBrtgUgS.js +969 -0
- package/dist/{create-CwnnNqv4.js → create-Cwc3SRWJ.js} +194 -168
- package/dist/create-Yvf2gStM.js +19 -0
- package/dist/doctor-C9ldpPFC.js +83 -0
- package/dist/{drivers-6RMOPIdn.js → drivers-DNrx4LWA.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28083 -801
- package/dist/environment-DF1qKlny.js +58 -0
- package/dist/{existing-DHpPn1y6.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-BR2LR-EK.js → integrate-DcJhpXy8.js} +277 -253
- 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-Bhxgqwtm.js → login-D0lh3_JI.js} +144 -66
- 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-BnVD6tJ9.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-Dvcyef3_.js → products-DH_fK9tY.js} +6 -39
- 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-DqMs9xNR.js → reports-DdPq4blM.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
- package/dist/{run-D-NbZLpj.js → run-C9qg_QlC.js} +16 -22
- package/dist/scan-Cv5uOwVY.js +4 -0
- package/dist/{scan-BmAW413l.js → scan-DLrsrFS9.js} +48 -37
- package/dist/scope-V336uz8j.js +198 -0
- package/dist/screenshot-file-0UETadF8.js +16 -0
- package/dist/{selection-BGi6GyxC.js → selection-Rdw-ZUoG.js} +94 -51
- package/dist/send-BxD9yf6F.js +150 -0
- package/dist/{dev-CgGAb5Al.js → server-D0tGG8C4.js} +82 -87
- 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-AxAf7bDB.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-BGAVPSQc.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-Dv3LyZ5m.js +0 -151
- package/dist/api-output-aJNw7Syy.js +0 -20
- package/dist/app-mJC5NDtW.js +0 -189
- package/dist/asa-D6H7Pjae.js +0 -1194
- package/dist/asc-xCin0akG.js +0 -539
- package/dist/auth-ZlLL-Gko.js +0 -139
- package/dist/billing-C8kBge_S.js +0 -80
- package/dist/command-3fGYyC8r.js +0 -301
- package/dist/dev-Dx99K183.js +0 -22
- package/dist/doctor-CyUvut31.js +0 -88
- package/dist/feedback-RKyGuQ8_.js +0 -152
- package/dist/hosted-BeGVAntr.js +0 -32
- package/dist/migrate-C-4ISELN.js +0 -284
- package/dist/org-CQduIOic.js +0 -40
- package/dist/output-C-4UKMot.js +0 -136
- package/dist/params-l3CrvRtR.js +0 -51
- package/dist/pipeline-CHX0Syre.js +0 -977
- package/dist/print-skill-BiZLdCKv.js +0 -74
- package/dist/promote-Pgpz-3xl.js +0 -88
- package/dist/publish-BPeuc3lq.js +0 -35
- package/dist/push-DcSQ4odB.js +0 -35
- package/dist/query-CWLaZkdm.js +0 -53
- package/dist/resource-jwASPCrw.js +0 -483
- package/dist/skills-FK5aDuNV.js +0 -64
- package/dist/spinner-DFctF_Jw.js +0 -18
- package/dist/storekit-CC4gnTI6.js +0 -29
- package/dist/telemetry-Ch9cCTI-.js +0 -169
- package/dist/ui-4gLyfrgl.js +0 -27737
- package/dist/update-DIXbL-H9.js +0 -59
- package/dist/upgrade-De7JMI1g.js +0 -72
- /package/dist/{devtools-8EgLo86w.js → devtools-ByZ6XYnn.js} +0 -0
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
import { r as formatJson, t as blocks } from "./output-C-4UKMot.js";
|
|
2
|
-
import { f as setDefaultApp, o as getDefaultApp } from "./telemetry-Ch9cCTI-.js";
|
|
3
|
-
import "./update-DIXbL-H9.js";
|
|
4
|
-
import "./token-BGAVPSQc.js";
|
|
5
|
-
import { r as ApiError, t as defineCommand } from "./command-3fGYyC8r.js";
|
|
6
|
-
import "./ui-4gLyfrgl.js";
|
|
7
|
-
import { t as scanProject } from "./scan-BmAW413l.js";
|
|
8
|
-
import { t as detectExisting } from "./existing-DHpPn1y6.js";
|
|
9
|
-
import "./spinner-DFctF_Jw.js";
|
|
10
|
-
import { E as titleCase, T as rowName, b as platformLabel, g as listResource, h as listProjects, i as createEntitlement, l as getPaywallApplicationId, m as listOrganizations, n as createApplication, o as createProduct, r as createCampaign, s as createProject, t as addPlacement, u as isAppScoped } from "./resources-Bf9O1JNM.js";
|
|
11
|
-
import { t as requireOrg } from "./org-CQduIOic.js";
|
|
12
|
-
import { t as platformForIntegration } from "./bind-BIzaGq8K.js";
|
|
13
|
-
import { t as apiCall } from "./api-output-aJNw7Syy.js";
|
|
14
|
-
import { t as generateStoreKit } from "./storekit-CC4gnTI6.js";
|
|
15
|
-
import * as path from "node:path";
|
|
16
|
-
import * as fs from "node:fs";
|
|
17
|
-
import { writeFileSync } from "node:fs";
|
|
18
|
-
|
|
19
|
-
//#region src/commands/resource/scope.ts
|
|
20
|
-
async function detectLocal(installDir) {
|
|
21
|
-
const detected = (await scanProject(installDir).catch(() => null))?.apps[0];
|
|
22
|
-
if (!detected) return {};
|
|
23
|
-
return {
|
|
24
|
-
apiKey: detectExisting(detected).apiKey,
|
|
25
|
-
name: detected.name
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function moveFirst(items, match) {
|
|
29
|
-
const idx = items.findIndex(match);
|
|
30
|
-
if (idx <= 0) return items;
|
|
31
|
-
return [
|
|
32
|
-
items[idx],
|
|
33
|
-
...items.slice(0, idx),
|
|
34
|
-
...items.slice(idx + 1)
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
function matchProject(projects, local) {
|
|
38
|
-
if (local.apiKey) {
|
|
39
|
-
const p = projects.find((project) => (project.applications ?? []).some((a) => a.public_api_key === local.apiKey));
|
|
40
|
-
if (p) return {
|
|
41
|
-
project: p,
|
|
42
|
-
exact: true
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (local.name) {
|
|
46
|
-
const p = projects.find((project) => project.name === local.name || (project.applications ?? []).some((a) => a.name === local.name));
|
|
47
|
-
if (p) return {
|
|
48
|
-
project: p,
|
|
49
|
-
exact: false
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return { exact: false };
|
|
53
|
-
}
|
|
54
|
-
function matchApp(apps, local) {
|
|
55
|
-
if (local.apiKey) {
|
|
56
|
-
const a = apps.find((app) => app.public_api_key === local.apiKey);
|
|
57
|
-
if (a) return a;
|
|
58
|
-
}
|
|
59
|
-
if (local.name) return apps.find((app) => app.name === local.name);
|
|
60
|
-
}
|
|
61
|
-
function lockBoundPaywallId(installDir) {
|
|
62
|
-
for (const file of [path.join(installDir, "superwall.lock"), path.join(installDir, "superwall", "superwall.lock")]) try {
|
|
63
|
-
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
64
|
-
for (const entry of Object.values({
|
|
65
|
-
...parsed.paywalls,
|
|
66
|
-
...parsed.funnels
|
|
67
|
-
})) {
|
|
68
|
-
if (typeof entry?.paywallId === "string") return entry.paywallId;
|
|
69
|
-
for (const binding of Object.values(entry ?? {})) {
|
|
70
|
-
const paywallId = binding?.paywallId;
|
|
71
|
-
if (typeof paywallId === "string") return paywallId;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
} catch {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async function lockBoundScope(context, api, projects) {
|
|
79
|
-
if (context.argv.project || context.argv.app) return void 0;
|
|
80
|
-
const paywallId = lockBoundPaywallId(context.installDir);
|
|
81
|
-
if (!paywallId) return void 0;
|
|
82
|
-
const applicationId = await getPaywallApplicationId(api, paywallId).catch(() => void 0);
|
|
83
|
-
if (!applicationId) return void 0;
|
|
84
|
-
const project = projects.find((candidate) => (candidate.applications ?? []).some((app$1) => String(app$1.id) === applicationId));
|
|
85
|
-
const app = project?.applications?.find((candidate) => String(candidate.id) === applicationId);
|
|
86
|
-
if (!project || !app) return void 0;
|
|
87
|
-
context.ui.info(`Using \`${app.name ?? applicationId}\` - bound in superwall.lock.`);
|
|
88
|
-
return {
|
|
89
|
-
project,
|
|
90
|
-
app
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
async function pickScope(context, api, appScoped) {
|
|
94
|
-
const projects = await apiCall(context, "Loading projects", () => listProjects(api));
|
|
95
|
-
const bound = await lockBoundScope(context, api, projects);
|
|
96
|
-
if (bound) return {
|
|
97
|
-
projectId: String(bound.project.id),
|
|
98
|
-
applicationId: appScoped ? String(bound.app.id) : void 0,
|
|
99
|
-
projectName: bound.project.name,
|
|
100
|
-
appName: appScoped ? bound.app.name : void 0,
|
|
101
|
-
appPlatform: appScoped ? bound.app.platform : void 0,
|
|
102
|
-
projectCount: projects.length,
|
|
103
|
-
appCount: bound.project.applications?.length ?? 0
|
|
104
|
-
};
|
|
105
|
-
const project = await pickProject(context, projects);
|
|
106
|
-
const projectId = String(project.id);
|
|
107
|
-
const apps = project.applications ?? [];
|
|
108
|
-
let app;
|
|
109
|
-
if (appScoped) {
|
|
110
|
-
const appFlag = context.argv.app;
|
|
111
|
-
const remembered = apps.find((candidate) => String(candidate.id) === getDefaultApp(projectId));
|
|
112
|
-
if (appFlag) {
|
|
113
|
-
app = apps.find((candidate) => String(candidate.id) === appFlag || candidate.name === appFlag);
|
|
114
|
-
if (!app) throw new Error(`No app ${appFlag} in ${project.name ?? projectId}.`);
|
|
115
|
-
setDefaultApp(projectId, String(app.id));
|
|
116
|
-
} else if (apps.length <= 1) app = apps[0];
|
|
117
|
-
else if (!context.interactive) throw new Error(`Multiple apps found in ${project.name ?? projectId}. Pass --app <id>.`);
|
|
118
|
-
else {
|
|
119
|
-
app = await chooseApp(context, apps, remembered ?? apps[0]);
|
|
120
|
-
setDefaultApp(projectId, String(app.id));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
projectId,
|
|
125
|
-
applicationId: app ? String(app.id) : void 0,
|
|
126
|
-
projectName: project.name,
|
|
127
|
-
appName: app?.name,
|
|
128
|
-
appPlatform: app?.platform,
|
|
129
|
-
projectCount: projects.length,
|
|
130
|
-
appCount: apps.length
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
async function pickProject(context, projects) {
|
|
134
|
-
const projectFlag = context.argv.project;
|
|
135
|
-
if (projectFlag) {
|
|
136
|
-
const p = projects.find((c) => String(c.id) === projectFlag);
|
|
137
|
-
if (!p) throw new Error(`No project ${projectFlag} in this organization.`);
|
|
138
|
-
return p;
|
|
139
|
-
}
|
|
140
|
-
if (projects.length === 0) throw new Error("No project found in this organization.");
|
|
141
|
-
if (projects.length === 1) return projects[0];
|
|
142
|
-
const { project: preferred, exact } = matchProject(projects, await detectLocal(context.installDir));
|
|
143
|
-
if (exact && preferred) {
|
|
144
|
-
context.ui.info(`Using \`${preferred.name}\` - detected in this directory.`);
|
|
145
|
-
return preferred;
|
|
146
|
-
}
|
|
147
|
-
if (!context.interactive) throw new Error("Multiple projects found. Pass --project <id>.");
|
|
148
|
-
return chooseProject(context, projects, preferred);
|
|
149
|
-
}
|
|
150
|
-
async function chooseProject(context, projects, preferred) {
|
|
151
|
-
const ordered = preferred ? moveFirst(projects, (p) => String(p.id) === String(preferred.id)) : projects;
|
|
152
|
-
const selection = await context.ui.select({
|
|
153
|
-
message: "Which project?",
|
|
154
|
-
options: ordered.map((project) => ({
|
|
155
|
-
value: String(project.id),
|
|
156
|
-
label: project.name ?? String(project.id)
|
|
157
|
-
})),
|
|
158
|
-
initialValue: preferred ? String(preferred.id) : void 0
|
|
159
|
-
});
|
|
160
|
-
if (selection === null) throw new Error("Cancelled.");
|
|
161
|
-
return projects.find((project) => String(project.id) === selection);
|
|
162
|
-
}
|
|
163
|
-
async function chooseApp(context, apps, defaultApp) {
|
|
164
|
-
const top = matchApp(apps, await detectLocal(context.installDir)) ?? defaultApp;
|
|
165
|
-
const ordered = moveFirst(apps, (app) => String(app.id) === String(top.id));
|
|
166
|
-
const selection = await context.ui.select({
|
|
167
|
-
message: "Which app?",
|
|
168
|
-
options: ordered.map((app) => ({
|
|
169
|
-
value: String(app.id),
|
|
170
|
-
label: app.name ?? String(app.id),
|
|
171
|
-
hint: platformLabel(app.platform)
|
|
172
|
-
})),
|
|
173
|
-
initialValue: String(top.id)
|
|
174
|
-
});
|
|
175
|
-
if (selection === null) throw new Error("Cancelled.");
|
|
176
|
-
return apps.find((app) => String(app.id) === selection) ?? top;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/commands/resource/actions.ts
|
|
181
|
-
async function addCampaignPlacement(context, api) {
|
|
182
|
-
const { ui, json, dryRun, argv } = context;
|
|
183
|
-
const campaignId = argv.value;
|
|
184
|
-
const placement = argv.value2;
|
|
185
|
-
if (!campaignId || !placement) throw new Error("Usage: superwall campaigns placement <campaignId> <placement>");
|
|
186
|
-
if (dryRun) {
|
|
187
|
-
const plan = {
|
|
188
|
-
dryRun: true,
|
|
189
|
-
action: "placement",
|
|
190
|
-
campaignId,
|
|
191
|
-
placement
|
|
192
|
-
};
|
|
193
|
-
if (json) return context.output.data(plan);
|
|
194
|
-
ui.info(`[dry-run] would add placement "${placement}" to campaign ${campaignId}`);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const result = await apiCall(context, `Adding placement "${placement}"`, () => addPlacement(api, campaignId, placement));
|
|
198
|
-
if (json) return context.output.data(result);
|
|
199
|
-
ui.success(`Added placement \`${placement}\` to campaign ${campaignId}`);
|
|
200
|
-
}
|
|
201
|
-
async function writeStoreKit(context, api) {
|
|
202
|
-
const scope = await pickScope(context, api, false);
|
|
203
|
-
const products = await apiCall(context, "Loading products", () => listResource(api, "products", scope));
|
|
204
|
-
const outFile = context.argv.out ?? "Superwall.storekit";
|
|
205
|
-
writeFileSync(outFile, `${formatJson(generateStoreKit(products))}\n`);
|
|
206
|
-
if (context.json) return context.output.data({
|
|
207
|
-
path: outFile,
|
|
208
|
-
products: products.length
|
|
209
|
-
});
|
|
210
|
-
context.ui.success(`Wrote \`${outFile}\` with ${products.length} product${products.length === 1 ? "" : "s"}`);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/commands/resource/create.ts
|
|
215
|
-
async function create(context, api, resource) {
|
|
216
|
-
const { ui, json, dryRun, argv } = context;
|
|
217
|
-
const value = argv.value;
|
|
218
|
-
if (resource === "apps") return createApp(context, api, value);
|
|
219
|
-
if (!value) throw new Error(resource === "campaigns" ? "Usage: superwall campaigns create \"<description>\" <placement>" : `Usage: superwall ${resource} create <${createArgLabel(resource)}>`);
|
|
220
|
-
if (resource === "campaigns" && !argv.value2) throw new Error("Usage: superwall campaigns create \"<description>\" <placement> (campaigns need at least one placement)");
|
|
221
|
-
const scope = await pickScope(context, api, isAppScoped(resource));
|
|
222
|
-
if (dryRun) {
|
|
223
|
-
const plan = {
|
|
224
|
-
dryRun: true,
|
|
225
|
-
action: "create",
|
|
226
|
-
resource,
|
|
227
|
-
value,
|
|
228
|
-
scope
|
|
229
|
-
};
|
|
230
|
-
if (json) return context.output.data(plan);
|
|
231
|
-
ui.info(`[dry-run] would create ${resource.replace(/s$/, "")} "${value}" in ${scope.projectName ?? scope.projectId}`);
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const created = await apiCall(context, `Creating ${resource.replace(/s$/, "")}`, () => createOne(api, resource, scope, value, argv));
|
|
235
|
-
if (json) return context.output.data(created);
|
|
236
|
-
ui.success(`Created ${resource.replace(/s$/, "")} \`${rowName(created)}\` ${created.id ?? ""}`);
|
|
237
|
-
}
|
|
238
|
-
const APP_PLATFORMS = [
|
|
239
|
-
"ios",
|
|
240
|
-
"android",
|
|
241
|
-
"flutter",
|
|
242
|
-
"react_native",
|
|
243
|
-
"web"
|
|
244
|
-
];
|
|
245
|
-
async function createApp(context, api, nameArg) {
|
|
246
|
-
const { argv, dryRun, json, ui, interactive } = context;
|
|
247
|
-
let name = nameArg;
|
|
248
|
-
let platform = argv.platform;
|
|
249
|
-
if (interactive && (!name || !platform)) {
|
|
250
|
-
const detected = (await scanProject(context.installDir).catch(() => null))?.apps[0];
|
|
251
|
-
if (detected && !name && !platform) {
|
|
252
|
-
ui.info(`Detected \`${detected.framework.name}\`` + (detected.details ? ` · \`${detected.details}\`` : ""));
|
|
253
|
-
const ok = await ui.confirm({ message: `Create \`${detected.name}\` in Superwall?` });
|
|
254
|
-
if (ok === null) return void ui.warn("Cancelled.");
|
|
255
|
-
if (ok) {
|
|
256
|
-
name = detected.name;
|
|
257
|
-
platform = platformForIntegration(detected.integration);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (!name) {
|
|
261
|
-
const answer = await ui.text({
|
|
262
|
-
message: "What's your app called?",
|
|
263
|
-
placeholder: "My App",
|
|
264
|
-
initialValue: detected?.name,
|
|
265
|
-
validate: (v) => v?.trim() ? void 0 : "Required"
|
|
266
|
-
});
|
|
267
|
-
if (answer === null) return void ui.warn("Cancelled.");
|
|
268
|
-
name = answer.trim();
|
|
269
|
-
}
|
|
270
|
-
if (!platform) {
|
|
271
|
-
const answer = await ui.select({
|
|
272
|
-
message: "Which platform?",
|
|
273
|
-
options: APP_PLATFORMS.map((p) => ({
|
|
274
|
-
value: p,
|
|
275
|
-
label: platformLabel(p)
|
|
276
|
-
})),
|
|
277
|
-
initialValue: detected ? platformForIntegration(detected.integration) : "ios"
|
|
278
|
-
});
|
|
279
|
-
if (answer === null) return void ui.warn("Cancelled.");
|
|
280
|
-
platform = answer;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
if (!name || !platform) throw new Error("Usage: superwall apps create <name> --platform <ios|android|flutter|react_native|web> [--bundle <id>] [--project <projectId>]");
|
|
284
|
-
const bundle = argv.bundle;
|
|
285
|
-
const target = argv.project;
|
|
286
|
-
if (dryRun) {
|
|
287
|
-
const plan = {
|
|
288
|
-
dryRun: true,
|
|
289
|
-
action: "create",
|
|
290
|
-
resource: "apps",
|
|
291
|
-
name,
|
|
292
|
-
platform,
|
|
293
|
-
project: target ?? null
|
|
294
|
-
};
|
|
295
|
-
if (json) return context.output.data(plan);
|
|
296
|
-
ui.info(`[dry-run] would add ${platformLabel(platform)} app "${name}" to ${target ? `project ${target}` : "a new project"}`);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
let projectId = target;
|
|
300
|
-
if (!projectId) {
|
|
301
|
-
await requireOrg(api, context.interactive);
|
|
302
|
-
projectId = String((await apiCall(context, `Creating project "${name}"`, () => createProject(api, name))).id);
|
|
303
|
-
}
|
|
304
|
-
let project;
|
|
305
|
-
try {
|
|
306
|
-
project = await apiCall(context, `Adding ${platformLabel(platform)} app`, () => createApplication(api, { projectId }, {
|
|
307
|
-
name,
|
|
308
|
-
platform,
|
|
309
|
-
bundleId: bundle
|
|
310
|
-
}));
|
|
311
|
-
} catch (error) {
|
|
312
|
-
if (error instanceof ApiError && /already[_ ]?exists|Duplicate entry|projectId_platform/i.test(error.body ?? "")) throw new Error(`Project ${projectId} already has a ${platformLabel(platform)} app - each project allows one app per platform.`);
|
|
313
|
-
throw error;
|
|
314
|
-
}
|
|
315
|
-
if (json) return context.output.data(project);
|
|
316
|
-
const created = project.applications?.find((app) => app.name === name && app.platform === platform) ?? project.applications?.find((app) => app.platform === platform) ?? project.applications?.at(-1);
|
|
317
|
-
const key = created?.public_api_key ? ` · \`pk_…${created.public_api_key.slice(-4)}\`` : "";
|
|
318
|
-
const projectLabel = project.name ? ` in \`${project.name}\`` : "";
|
|
319
|
-
ui.success(`Added \`${platformLabel(platform)}\` app \`${name}\`${projectLabel}${key}`);
|
|
320
|
-
}
|
|
321
|
-
function createOne(api, resource, scope, value, argv) {
|
|
322
|
-
switch (resource) {
|
|
323
|
-
case "entitlements": return createEntitlement(api, scope, value);
|
|
324
|
-
case "products": return createProduct(api, scope, value, productOptsFromArgv(argv));
|
|
325
|
-
case "campaigns": return createCampaign(api, scope, value, String(argv.value2));
|
|
326
|
-
default: throw new Error(`create is not supported for ${resource} yet.`);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function productOptsFromArgv(argv) {
|
|
330
|
-
const options = {};
|
|
331
|
-
if (argv.name) options.name = String(argv.name);
|
|
332
|
-
if (argv.price !== void 0) options.price = {
|
|
333
|
-
amount: Math.round(Number(argv.price) * 100),
|
|
334
|
-
currency: String(argv.currency ?? "USD").toUpperCase()
|
|
335
|
-
};
|
|
336
|
-
if (argv.period) options.subscription = {
|
|
337
|
-
period: String(argv.period),
|
|
338
|
-
period_count: argv.periodCount !== void 0 ? Number(argv.periodCount) : 1,
|
|
339
|
-
...argv.trialDays !== void 0 ? { trial_period_days: Number(argv.trialDays) } : {}
|
|
340
|
-
};
|
|
341
|
-
const entitlement = argv.entitlement;
|
|
342
|
-
const entitlements = Array.isArray(entitlement) ? entitlement.map(String) : entitlement ? [String(entitlement)] : [];
|
|
343
|
-
if (entitlements.length) options.entitlements = entitlements;
|
|
344
|
-
return options;
|
|
345
|
-
}
|
|
346
|
-
function createArgLabel(resource) {
|
|
347
|
-
return resource === "campaigns" ? "description" : "identifier";
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
//#endregion
|
|
351
|
-
//#region src/commands/resource/list.ts
|
|
352
|
-
async function list(context, api, resource) {
|
|
353
|
-
const { json } = context;
|
|
354
|
-
if (resource === "orgs") {
|
|
355
|
-
const organizations = await apiCall(context, "Loading organizations", () => listOrganizations(api));
|
|
356
|
-
if (json) return context.output.data(organizations);
|
|
357
|
-
context.output.render(blocks.step(count(organizations.length, "organization")), blocks.list({
|
|
358
|
-
items: organizations.map((organization) => {
|
|
359
|
-
const label = rowName(organization);
|
|
360
|
-
return {
|
|
361
|
-
label,
|
|
362
|
-
badge: titleCase(String(organization.role ?? "")),
|
|
363
|
-
meta: secondaryId(label, organization.id)
|
|
364
|
-
};
|
|
365
|
-
}),
|
|
366
|
-
empty: "No organizations."
|
|
367
|
-
}));
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (resource === "projects" || resource === "apps") {
|
|
371
|
-
const projects = await apiCall(context, "Loading projects", () => listProjects(api));
|
|
372
|
-
if (json) return context.output.data(projects);
|
|
373
|
-
context.output.render(blocks.step(`${count(projects.length, "project")}${orgLabel(api)}`), blocks.list({
|
|
374
|
-
items: projects.map((project) => ({
|
|
375
|
-
label: project.name ?? String(project.id),
|
|
376
|
-
meta: String(project.id),
|
|
377
|
-
children: (project.applications ?? []).map((app) => ({
|
|
378
|
-
badge: platformLabel(app.platform),
|
|
379
|
-
label: app.bundle_id ?? app.name ?? "",
|
|
380
|
-
meta: app.public_api_key ? `pk_…${app.public_api_key.slice(-4)}` : "(no key)"
|
|
381
|
-
}))
|
|
382
|
-
})),
|
|
383
|
-
empty: "No projects yet - run `superwall apps create <name> --platform ios`."
|
|
384
|
-
}));
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
const scope = await pickScope(context, api, isAppScoped(resource));
|
|
388
|
-
const rows = await apiCall(context, `Loading ${resource}`, () => listResource(api, resource, scope));
|
|
389
|
-
if (json) return context.output.data(rows);
|
|
390
|
-
context.output.render(blocks.step(`${count(rows.length, resource.replace(/s$/, ""))}${scopeLabel(resource, scope)}`), blocks.list({
|
|
391
|
-
items: rows.map((row) => {
|
|
392
|
-
const label = rowName(row);
|
|
393
|
-
return {
|
|
394
|
-
label,
|
|
395
|
-
meta: secondaryId(label, row.id)
|
|
396
|
-
};
|
|
397
|
-
}),
|
|
398
|
-
empty: `No ${resource} yet.`
|
|
399
|
-
}));
|
|
400
|
-
}
|
|
401
|
-
async function useApp(context, api) {
|
|
402
|
-
const project = await pickProject(context, await apiCall(context, "Loading projects", () => listProjects(api)));
|
|
403
|
-
const apps = project.applications ?? [];
|
|
404
|
-
if (apps.length === 0) throw new Error(`${project.name ?? project.id} has no apps yet.`);
|
|
405
|
-
const target = context.argv.value;
|
|
406
|
-
let app;
|
|
407
|
-
if (target) {
|
|
408
|
-
app = apps.find((candidate) => String(candidate.id) === target || candidate.name === target);
|
|
409
|
-
if (!app) throw new Error(`No app ${target} in ${project.name ?? project.id}.`);
|
|
410
|
-
} else if (!context.interactive) throw new Error("Specify an app: superwall apps use <id|name>");
|
|
411
|
-
else app = await chooseApp(context, apps, apps.find((candidate) => String(candidate.id) === getDefaultApp(String(project.id))) ?? apps[0]);
|
|
412
|
-
setDefaultApp(String(project.id), String(app.id));
|
|
413
|
-
if (context.json) return context.output.data(app);
|
|
414
|
-
context.ui.success(`Default app set to \`${app.name ?? app.id}\` (${platformLabel(app.platform)})`);
|
|
415
|
-
}
|
|
416
|
-
async function useOrg(context, api) {
|
|
417
|
-
const organizations = await apiCall(context, "Loading organizations", () => listOrganizations(api));
|
|
418
|
-
if (organizations.length === 0) throw new Error("Your account has no organizations.");
|
|
419
|
-
const target = context.argv.value;
|
|
420
|
-
let org;
|
|
421
|
-
if (target) {
|
|
422
|
-
org = organizations.find((candidate) => String(candidate.id) === target || rowName(candidate) === target);
|
|
423
|
-
if (!org) throw new Error(`No organization ${target}.`);
|
|
424
|
-
} else if (!context.interactive) throw new Error("Specify an organization: superwall orgs use <id|name>");
|
|
425
|
-
else {
|
|
426
|
-
const sel = await context.ui.select({
|
|
427
|
-
message: "Which organization?",
|
|
428
|
-
options: organizations.map((candidate) => ({
|
|
429
|
-
value: String(candidate.id),
|
|
430
|
-
label: rowName(candidate),
|
|
431
|
-
hint: titleCase(String(candidate.role ?? ""))
|
|
432
|
-
})),
|
|
433
|
-
initialValue: api.org.id
|
|
434
|
-
});
|
|
435
|
-
if (sel === null) return;
|
|
436
|
-
org = organizations.find((candidate) => String(candidate.id) === sel);
|
|
437
|
-
}
|
|
438
|
-
api.setOrg({
|
|
439
|
-
id: String(org.id),
|
|
440
|
-
name: rowName(org)
|
|
441
|
-
});
|
|
442
|
-
if (context.json) return context.output.data(org);
|
|
443
|
-
context.ui.success(`Organization set to \`${rowName(org)}\`.`);
|
|
444
|
-
}
|
|
445
|
-
function secondaryId(label, id) {
|
|
446
|
-
const value = String(id ?? "");
|
|
447
|
-
return value && value !== label ? value : void 0;
|
|
448
|
-
}
|
|
449
|
-
function count(value, noun) {
|
|
450
|
-
return `${value} ${noun}${value === 1 ? "" : "s"}`;
|
|
451
|
-
}
|
|
452
|
-
function orgLabel(api) {
|
|
453
|
-
return api.org.count > 1 && api.org.name ? ` in \`${api.org.name}\`` : "";
|
|
454
|
-
}
|
|
455
|
-
function scopeLabel(resource, scope) {
|
|
456
|
-
const parts = [];
|
|
457
|
-
if (scope.projectCount > 1 && scope.projectName) parts.push(scope.projectName);
|
|
458
|
-
if (isAppScoped(resource) && scope.appCount > 1 && scope.appName) parts.push(`${scope.appName} (${platformLabel(scope.appPlatform)})`);
|
|
459
|
-
return parts.length ? ` in \`${parts.join(" · ")}\`` : "";
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region src/commands/resource/resource.ts
|
|
464
|
-
function runResource(resource) {
|
|
465
|
-
return defineCommand({
|
|
466
|
-
name: resource,
|
|
467
|
-
auth: "required",
|
|
468
|
-
output: "both",
|
|
469
|
-
async run(context) {
|
|
470
|
-
const action = context.argv.action ?? "list";
|
|
471
|
-
if (action === "list") return list(context, context.api, resource);
|
|
472
|
-
if (action === "create") return create(context, context.api, resource);
|
|
473
|
-
if (action === "use" && resource === "apps") return useApp(context, context.api);
|
|
474
|
-
if (action === "use" && resource === "orgs") return useOrg(context, context.api);
|
|
475
|
-
if (action === "placement" && resource === "campaigns") return addCampaignPlacement(context, context.api);
|
|
476
|
-
if (action === "storekit" && resource === "products") return writeStoreKit(context, context.api);
|
|
477
|
-
throw new Error(`Unknown action "${action}" for ${resource}.`);
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
//#endregion
|
|
483
|
-
export { runResource };
|
package/dist/skills-FK5aDuNV.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import "./output-C-4UKMot.js";
|
|
2
|
-
import "./telemetry-Ch9cCTI-.js";
|
|
3
|
-
import "./update-DIXbL-H9.js";
|
|
4
|
-
import "./token-BGAVPSQc.js";
|
|
5
|
-
import { t as defineCommand } from "./command-3fGYyC8r.js";
|
|
6
|
-
import { n as ui } from "./ui-4gLyfrgl.js";
|
|
7
|
-
import { a as skillsOutOfDate, o as syncSkills, r as fetchPublicSkills, t as SKILLS_INSTALL_SOURCE } from "./skills-AxAf7bDB.js";
|
|
8
|
-
import "./spawn-DSoTXy_j.js";
|
|
9
|
-
import { t as withSpinner } from "./spinner-DFctF_Jw.js";
|
|
10
|
-
|
|
11
|
-
//#region src/commands/account/skills.ts
|
|
12
|
-
const runSkills = defineCommand({
|
|
13
|
-
name: "skills",
|
|
14
|
-
async run(ctx) {
|
|
15
|
-
ui.intro("Superwall agent skills");
|
|
16
|
-
let skills = normalizeList(ctx.argv.skill);
|
|
17
|
-
const { dryRun } = ctx;
|
|
18
|
-
const force = Boolean(ctx.argv.force);
|
|
19
|
-
const yes = Boolean(ctx.argv.yes);
|
|
20
|
-
const interactive = ctx.interactive && !yes;
|
|
21
|
-
if (!skills && !dryRun && !force) {
|
|
22
|
-
if (!await withSpinner("Checking your skills", skillsOutOfDate)) {
|
|
23
|
-
ui.success("Your Superwall skills are already up to date.");
|
|
24
|
-
ui.outro("Run `superwall skills --force` to reinstall.");
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (!skills && !dryRun && interactive) {
|
|
29
|
-
const available = await withSpinner(`Fetching skills from ${SKILLS_INSTALL_SOURCE()}`, fetchPublicSkills);
|
|
30
|
-
const picked = await ui.multiselect({
|
|
31
|
-
message: `Which skills from ${SKILLS_INSTALL_SOURCE()}? (installs globally)`,
|
|
32
|
-
options: available.map((s) => ({
|
|
33
|
-
value: s.name,
|
|
34
|
-
label: s.name,
|
|
35
|
-
hint: s.summary
|
|
36
|
-
})),
|
|
37
|
-
initialValues: available.map((s) => s.name)
|
|
38
|
-
});
|
|
39
|
-
if (picked === null || picked.length === 0) {
|
|
40
|
-
ui.warn("Nothing selected.");
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
skills = picked.length === available.length ? void 0 : picked;
|
|
44
|
-
} else if (skills?.length) ui.info(`Installing \`${skills.join("`, `")}\` from ${SKILLS_INSTALL_SOURCE()}`);
|
|
45
|
-
else ui.info(`Installing every skill from ${SKILLS_INSTALL_SOURCE()}`);
|
|
46
|
-
const spin = ui.spinner();
|
|
47
|
-
spin.start(dryRun ? "Resolving" : "Installing skills globally");
|
|
48
|
-
const { ok, commands } = await syncSkills({
|
|
49
|
-
skills,
|
|
50
|
-
dryRun
|
|
51
|
-
});
|
|
52
|
-
spin.stop(dryRun ? "Dry run" : ok ? "Skills installed for every detected agent" : "Install failed");
|
|
53
|
-
if (dryRun) for (const command of commands) ui.info(command);
|
|
54
|
-
ui.outro(ok ? `**Done.** Try: ask your agent to "review my Superwall setup".` : "Something went wrong - try again, or check that `npx` is available.");
|
|
55
|
-
if (!ok) throw new Error("Skill installation failed. Check that `npx` is available and try again.");
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
function normalizeList(v) {
|
|
59
|
-
if (Array.isArray(v)) return v.map(String);
|
|
60
|
-
if (typeof v === "string") return [v];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
export { runSkills };
|
package/dist/spinner-DFctF_Jw.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { n as ui } from "./ui-4gLyfrgl.js";
|
|
2
|
-
|
|
3
|
-
//#region src/ui/spinner.ts
|
|
4
|
-
async function withSpinner(label, work) {
|
|
5
|
-
const spin = ui.spinner();
|
|
6
|
-
spin.start(label);
|
|
7
|
-
try {
|
|
8
|
-
const result = await work();
|
|
9
|
-
spin.stop(label);
|
|
10
|
-
return result;
|
|
11
|
-
} catch (e) {
|
|
12
|
-
spin.stop("Failed");
|
|
13
|
-
throw e;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { withSpinner as t };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region src/core/dashboard/storekit.ts
|
|
2
|
-
function generateStoreKit(products) {
|
|
3
|
-
return {
|
|
4
|
-
identifier: "SUPERWALL",
|
|
5
|
-
nonRenewingSubscriptions: [],
|
|
6
|
-
products: products.map((p) => String(p.identifier ?? p.product_identifier ?? p.name ?? "")).filter(Boolean).map((id, i) => ({
|
|
7
|
-
displayPrice: "9.99",
|
|
8
|
-
familyShareable: false,
|
|
9
|
-
internalID: String(1e3 + i),
|
|
10
|
-
localizations: [{
|
|
11
|
-
description: id,
|
|
12
|
-
displayName: id,
|
|
13
|
-
locale: "en_US"
|
|
14
|
-
}],
|
|
15
|
-
productID: id,
|
|
16
|
-
referenceName: id,
|
|
17
|
-
type: "NonConsumable"
|
|
18
|
-
})),
|
|
19
|
-
settings: { _applicationInternalID: "SUPERWALL" },
|
|
20
|
-
subscriptionGroups: [],
|
|
21
|
-
version: {
|
|
22
|
-
major: 3,
|
|
23
|
-
minor: 0
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
export { generateStoreKit as t };
|