@superwall/cli 1.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/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/actions-MB-eBY64.js +140 -0
- package/dist/api-BF7-toqM.js +151 -0
- package/dist/api-output-B5hh0q4V.js +20 -0
- package/dist/app-K6j9Es7h.js +189 -0
- package/dist/asc-CArSwo5D.js +539 -0
- package/dist/asc-products-YQ6Oc6YO.js +93 -0
- package/dist/auth-CY2cO_NF.js +139 -0
- package/dist/auth.d.ts +30 -0
- package/dist/auth.js +4 -0
- package/dist/billing-DWyfEQ6l.js +80 -0
- package/dist/bind-hslFhcTR.js +213 -0
- package/dist/chunk-DQxbwPpZ.js +30 -0
- package/dist/command-Kwx4ekbo.js +283 -0
- package/dist/create-Bbi8BOO1.js +410 -0
- package/dist/dev-D0lQDCQI.js +397 -0
- package/dist/devtools-8EgLo86w.js +3638 -0
- package/dist/doctor-ByeRdMcl.js +88 -0
- package/dist/drivers-DVAZgone.js +413 -0
- package/dist/entry.d.ts +9 -0
- package/dist/entry.js +495 -0
- package/dist/existing-CcJrIIAU.js +88 -0
- package/dist/feedback-Z0Wk7VC5.js +73 -0
- package/dist/git-3OX9u3xE.js +433 -0
- package/dist/hosted-CHwaUqLd.js +32 -0
- package/dist/integrate-DqOAqK7J.js +863 -0
- package/dist/json-C3hPIMkI.js +7 -0
- package/dist/login-Dr8UN_Gx.js +290 -0
- package/dist/migrate-D92bJTg6.js +114 -0
- package/dist/org-B2gy9Pmu.js +40 -0
- package/dist/params-Bvq0iqQK.js +52 -0
- package/dist/pipeline-CHHIg6BU.js +1056 -0
- package/dist/print-skill-BnZAk7dV.js +74 -0
- package/dist/promote-CRe9170G.js +88 -0
- package/dist/publish-DsODvrOD.js +35 -0
- package/dist/push-BDkZUC0v.js +35 -0
- package/dist/query-DIllrSnk.js +53 -0
- package/dist/resource-CdP1MDla.js +483 -0
- package/dist/resources-CVrWwA1K.js +233 -0
- package/dist/run-cGGBUMs5.js +89 -0
- package/dist/scan-BQexuUPO.js +236 -0
- package/dist/skills-DhuUs28u.js +64 -0
- package/dist/skills-xrfXt9u0.js +205 -0
- package/dist/spawn-DSoTXy_j.js +69 -0
- package/dist/spinner-gOxIMz-V.js +18 -0
- package/dist/storekit-Ddvs4Ynw.js +29 -0
- package/dist/telemetry-CcfrtXdf.js +204 -0
- package/dist/token-DHRH8cxi.js +102 -0
- package/dist/ui-C4ncRJqd.js +27703 -0
- package/dist/update-BiVeR024.js +137 -0
- package/dist/upgrade-DYWspApv.js +72 -0
- package/package.json +87 -0
- package/prompts/actions/dashboard-setup.xml +10 -0
- package/prompts/actions/integrate.xml +5 -0
- package/prompts/actions/migrate.xml +11 -0
- package/prompts/actions/placements-implement.xml +20 -0
- package/prompts/actions/placements-review.xml +18 -0
- package/prompts/actions/review-fix.xml +18 -0
- package/prompts/actions/review.xml +18 -0
- package/prompts/commandments.xml +17 -0
- package/prompts/context.xml +9 -0
- package/skills/README.md +118 -0
- package/skills/superwall-dashboard/SKILL.md +81 -0
- package/skills/superwall-dashboard/references/setup.md +101 -0
- package/skills/superwall-integrate/SKILL.md +76 -0
- package/skills/superwall-integrate/references/expo.md +269 -0
- package/skills/superwall-integrate/references/flutter.md +285 -0
- package/skills/superwall-integrate/references/ios.md +314 -0
- package/skills/superwall-integrate/references/react-native.md +245 -0
- package/skills/superwall-migrate/SKILL.md +83 -0
- package/skills/superwall-migrate/references/adapty.md +229 -0
- package/skills/superwall-migrate/references/qonversion.md +227 -0
- package/skills/superwall-migrate/references/revenuecat.md +414 -0
- package/skills/superwall-placements/SKILL.md +73 -0
- package/skills/superwall-placements/references/expo.md +161 -0
- package/skills/superwall-placements/references/flutter.md +139 -0
- package/skills/superwall-placements/references/ios.md +165 -0
- package/skills/superwall-placements/references/react-native.md +145 -0
- package/skills/superwall-placements/references/strategy.md +221 -0
- package/skills/superwall-review/SKILL.md +75 -0
- package/skills/superwall-review/references/expo.md +100 -0
- package/skills/superwall-review/references/flutter.md +99 -0
- package/skills/superwall-review/references/ios.md +108 -0
- package/skills/superwall-review/references/react-native.md +100 -0
package/dist/entry.js
ADDED
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import { k as VERSION, t as flushTelemetry, w as ENV_API_KEY } from "./telemetry-CcfrtXdf.js";
|
|
2
|
+
import "./json-C3hPIMkI.js";
|
|
3
|
+
import { c as writeJson, n as flushUpdateCheck } from "./update-BiVeR024.js";
|
|
4
|
+
import yargs from "yargs";
|
|
5
|
+
import { hideBin } from "yargs/helpers";
|
|
6
|
+
import pc from "picocolors";
|
|
7
|
+
|
|
8
|
+
//#region src/cli.ts
|
|
9
|
+
const installDirOption = { "install-dir": {
|
|
10
|
+
describe: "Directory to set up Superwall in (default: cwd)",
|
|
11
|
+
type: "string"
|
|
12
|
+
} };
|
|
13
|
+
const apiKeyOption = { "api-key": {
|
|
14
|
+
describe: `Superwall public API key (or set ${ENV_API_KEY})`,
|
|
15
|
+
type: "string"
|
|
16
|
+
} };
|
|
17
|
+
const dryRunOption = { "dry-run": {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
describe: "Plan without changing anything",
|
|
20
|
+
hidden: true
|
|
21
|
+
} };
|
|
22
|
+
const skillOption = { skill: {
|
|
23
|
+
type: "boolean",
|
|
24
|
+
describe: "Print the agent playbook (skill + this project's reference) instead of running"
|
|
25
|
+
} };
|
|
26
|
+
const RESOURCES = [
|
|
27
|
+
"orgs",
|
|
28
|
+
"apps",
|
|
29
|
+
"products",
|
|
30
|
+
"campaigns",
|
|
31
|
+
"paywalls",
|
|
32
|
+
"entitlements"
|
|
33
|
+
];
|
|
34
|
+
const API_VERBS = [
|
|
35
|
+
"get",
|
|
36
|
+
"post",
|
|
37
|
+
"patch",
|
|
38
|
+
"delete"
|
|
39
|
+
];
|
|
40
|
+
function printHelp() {
|
|
41
|
+
const pad = (cmd) => ` ${cmd.padEnd(30)}`;
|
|
42
|
+
const row = (cmd, desc) => `${pad(cmd)}${desc}`;
|
|
43
|
+
const head = (title) => pc.bold(`${title}:`);
|
|
44
|
+
process.stdout.write([
|
|
45
|
+
`${pc.bold("Superwall CLI")} ${pc.dim(`v${VERSION}`)}`,
|
|
46
|
+
"",
|
|
47
|
+
pc.bold("Usage:"),
|
|
48
|
+
" superwall [command]",
|
|
49
|
+
"",
|
|
50
|
+
head("Workflow commands"),
|
|
51
|
+
row("integrate", "Set up Superwall in your app (agent-driven)"),
|
|
52
|
+
row("migrate", "Migrate from RevenueCat / Adapty / Qonversion"),
|
|
53
|
+
row("review [--fix]", "Audit an existing Superwall setup; --fix repairs issues"),
|
|
54
|
+
pc.dim(" Each takes --skill to print the playbook instead of running."),
|
|
55
|
+
"",
|
|
56
|
+
head("Paywalls & funnels"),
|
|
57
|
+
row("create [dir]", "Set up paywalls in your app - creates superwall/ inside it"),
|
|
58
|
+
row("dev [dir..]", "Host the studio: browse and preview your paywalls and funnels"),
|
|
59
|
+
row("push [dir]", "Build and push your paywalls and funnels as immutable versions"),
|
|
60
|
+
row("promote [dir]", "Point production at a pushed version"),
|
|
61
|
+
row("publish [dir]", "Push and promote in one step"),
|
|
62
|
+
pc.dim(" push and publish take -m <note> to record why, in the source commit."),
|
|
63
|
+
pc.dim(" All three take --platform <p> when the project pushes to several platforms."),
|
|
64
|
+
"",
|
|
65
|
+
head("Resource commands"),
|
|
66
|
+
row("bootstrap", "Complete account tree: projects, apps, campaigns, and products"),
|
|
67
|
+
row("apps", "Projects and platform apps (list, create, use)"),
|
|
68
|
+
row("products", "Products (list, create, storekit)"),
|
|
69
|
+
row("entitlements", "Entitlements (list, create)"),
|
|
70
|
+
row("campaigns", "Campaigns (list, create, placement)"),
|
|
71
|
+
row("paywalls", "Paywalls (list)"),
|
|
72
|
+
row("query [sql]", "Run SQL against your ClickHouse analytics data"),
|
|
73
|
+
row("orgs", "Organizations (list, use) - only needed with multiple orgs"),
|
|
74
|
+
"",
|
|
75
|
+
head("API commands"),
|
|
76
|
+
row("get, post, patch, delete", "Raw requests to the Superwall API (/v2/...)"),
|
|
77
|
+
"",
|
|
78
|
+
head("App Store Connect commands"),
|
|
79
|
+
row("asc", "The ASC API via Superwall's signed proxy (no .p8 / JWT)"),
|
|
80
|
+
row("asc docs", "Exact ASC request schema, from Apple's spec (path or search)"),
|
|
81
|
+
row("asc keys", "Manage App Store Connect API keys (list, set, rm)"),
|
|
82
|
+
"",
|
|
83
|
+
head("Other commands"),
|
|
84
|
+
row("login, logout, whoami", "Authenticate the CLI"),
|
|
85
|
+
row("skills", "Install or update the Superwall agent skills"),
|
|
86
|
+
row("doctor", "Check the health of your integration"),
|
|
87
|
+
row("upgrade", "Update the CLI to the latest version"),
|
|
88
|
+
row("feedback", "Send feedback about the CLI to the Superwall team"),
|
|
89
|
+
"",
|
|
90
|
+
pc.bold("Flags:"),
|
|
91
|
+
row("--json", "Machine-readable output"),
|
|
92
|
+
row("--no-interactive", "Disable prompts for automation"),
|
|
93
|
+
row("-v, --version", "Print the CLI version"),
|
|
94
|
+
row("-h, --help", "Help for superwall"),
|
|
95
|
+
"",
|
|
96
|
+
`Use ${pc.bold("\"superwall [command] --help\"")} for more information about a command.`,
|
|
97
|
+
""
|
|
98
|
+
].join("\n"));
|
|
99
|
+
}
|
|
100
|
+
async function run() {
|
|
101
|
+
const args = hideBin(process.argv);
|
|
102
|
+
if (args.length === 0 || args[0] === "help" || (args[0] === "-h" || args[0] === "--help") && args.length === 1) {
|
|
103
|
+
printHelp();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
let cli = yargs(args).scriptName("superwall").usage("Superwall CLI\n\n$0 [command]").option("interactive", {
|
|
107
|
+
type: "boolean",
|
|
108
|
+
default: true,
|
|
109
|
+
hidden: true,
|
|
110
|
+
describe: "Allow prompts (use --no-interactive for automation)"
|
|
111
|
+
}).option("json", {
|
|
112
|
+
type: "boolean",
|
|
113
|
+
default: false,
|
|
114
|
+
describe: "Machine-readable output"
|
|
115
|
+
}).command("integrate", "Set up the SDK, placements, and dashboard in your app", (y) => y.options({
|
|
116
|
+
...installDirOption,
|
|
117
|
+
...apiKeyOption,
|
|
118
|
+
...dryRunOption,
|
|
119
|
+
...skillOption,
|
|
120
|
+
driver: {
|
|
121
|
+
type: "string",
|
|
122
|
+
choices: [
|
|
123
|
+
"claude",
|
|
124
|
+
"codex",
|
|
125
|
+
"superwall"
|
|
126
|
+
],
|
|
127
|
+
describe: "Force a coding-agent backend (default: first detected)",
|
|
128
|
+
hidden: true
|
|
129
|
+
}
|
|
130
|
+
}), (argv) => {
|
|
131
|
+
if (argv.skill) return import("./print-skill-BnZAk7dV.js").then((m) => m.runPrintSkill("integrate")(argv));
|
|
132
|
+
return import("./integrate-DqOAqK7J.js").then((m) => m.runIntegrate(argv));
|
|
133
|
+
}).command("review", "Review an existing Superwall setup end to end", (y) => y.options({
|
|
134
|
+
...installDirOption,
|
|
135
|
+
...dryRunOption,
|
|
136
|
+
...skillOption,
|
|
137
|
+
fix: {
|
|
138
|
+
type: "boolean",
|
|
139
|
+
describe: "Apply verified, safe fixes from the latest review"
|
|
140
|
+
}
|
|
141
|
+
}), (argv) => {
|
|
142
|
+
const id = argv.fix ? "review-fix" : "review";
|
|
143
|
+
if (argv.skill) return import("./print-skill-BnZAk7dV.js").then((m) => m.runPrintSkill(id)(argv));
|
|
144
|
+
return import("./integrate-DqOAqK7J.js").then((m) => m.runActionCommand(id)(argv));
|
|
145
|
+
}).command("migrate", "Migrate from RevenueCat / Adapty / Qonversion to Superwall", (y) => y.options({
|
|
146
|
+
...installDirOption,
|
|
147
|
+
"dry-run": {
|
|
148
|
+
type: "boolean",
|
|
149
|
+
describe: "Plan without changes"
|
|
150
|
+
},
|
|
151
|
+
...skillOption
|
|
152
|
+
}), (argv) => {
|
|
153
|
+
if (argv.skill) return import("./print-skill-BnZAk7dV.js").then((m) => m.runPrintSkill("migrate")(argv));
|
|
154
|
+
return import("./migrate-D92bJTg6.js").then((m) => m.runMigrate(argv));
|
|
155
|
+
}).command("login", "Log in to Superwall (opens your browser)", (y) => y.options({
|
|
156
|
+
"api-key": {
|
|
157
|
+
type: "string",
|
|
158
|
+
describe: "Log in headlessly with an API key (for CI) instead of the browser"
|
|
159
|
+
},
|
|
160
|
+
host: {
|
|
161
|
+
type: "string",
|
|
162
|
+
describe: "OAuth issuer override",
|
|
163
|
+
hidden: true
|
|
164
|
+
},
|
|
165
|
+
"client-id": {
|
|
166
|
+
type: "string",
|
|
167
|
+
describe: "OAuth client id override",
|
|
168
|
+
hidden: true
|
|
169
|
+
}
|
|
170
|
+
}), (argv) => {
|
|
171
|
+
return import("./auth-CY2cO_NF.js").then((m) => m.runLogin(argv));
|
|
172
|
+
}).command("logout", "Log out of Superwall", (y) => y, (argv) => {
|
|
173
|
+
return import("./auth-CY2cO_NF.js").then((m) => m.runLogout(argv));
|
|
174
|
+
}).command("whoami", "Show the logged-in Superwall account", (y) => y, (argv) => {
|
|
175
|
+
return import("./auth-CY2cO_NF.js").then((m) => m.runWhoami(argv));
|
|
176
|
+
}).command("skills", "Install or update the Superwall agent skills for your coding agent", (y) => y.options({
|
|
177
|
+
skill: {
|
|
178
|
+
type: "array",
|
|
179
|
+
describe: "Install specific skills by name (default: all)"
|
|
180
|
+
},
|
|
181
|
+
force: {
|
|
182
|
+
type: "boolean",
|
|
183
|
+
describe: "Reinstall even if skills are already up to date"
|
|
184
|
+
},
|
|
185
|
+
yes: {
|
|
186
|
+
type: "boolean",
|
|
187
|
+
alias: "y",
|
|
188
|
+
describe: "Install all skills without asking"
|
|
189
|
+
},
|
|
190
|
+
"dry-run": {
|
|
191
|
+
type: "boolean",
|
|
192
|
+
describe: "Print the install command without running it",
|
|
193
|
+
hidden: true
|
|
194
|
+
}
|
|
195
|
+
}), (argv) => {
|
|
196
|
+
return import("./skills-DhuUs28u.js").then((m) => m.runSkills(argv));
|
|
197
|
+
}).command("doctor", "Check the health of your Superwall integration", (y) => y.options({ ...installDirOption }), (argv) => {
|
|
198
|
+
return import("./doctor-ByeRdMcl.js").then((m) => m.runDoctor(argv));
|
|
199
|
+
}).command("upgrade", "Update the CLI to the latest version", (y) => y, (argv) => {
|
|
200
|
+
return import("./upgrade-DYWspApv.js").then((m) => m.runUpgrade(argv));
|
|
201
|
+
}).command("feedback [message]", "Send feedback about the CLI to the Superwall team", (y) => y.positional("message", {
|
|
202
|
+
type: "string",
|
|
203
|
+
describe: "Your feedback (omit to be prompted)"
|
|
204
|
+
}).example("$0 feedback \"migrate crashed on Expo\"", "Send feedback").example("$0 feedback \"...\" --json", "For agents / automation"), (argv) => {
|
|
205
|
+
return import("./feedback-Z0Wk7VC5.js").then((m) => m.runFeedback(argv));
|
|
206
|
+
}).command("query [sql]", "Run SQL against your ClickHouse analytics data", (y) => y.positional("sql", {
|
|
207
|
+
type: "string",
|
|
208
|
+
describe: "SQL query (or pass it with --file / stdin)"
|
|
209
|
+
}).options({ file: {
|
|
210
|
+
type: "string",
|
|
211
|
+
describe: "Read SQL from a .sql file"
|
|
212
|
+
} }).example("$0 query \"SHOW TABLES FROM sw\"", "Run an inline query").example("$0 query --file report.sql --json", "Run a saved query"), (argv) => {
|
|
213
|
+
return import("./query-DIllrSnk.js").then((m) => m.runQuery(argv));
|
|
214
|
+
}).command("asc <target> [value] [value2]", "Call the App Store Connect API through Superwall's signed proxy (no .p8 / JWT needed)", (y) => y.positional("target", {
|
|
215
|
+
type: "string",
|
|
216
|
+
describe: "get|post|patch|delete, a raw path (/v1/...), or: apps | products | subscriptions | iaps | docs | keys"
|
|
217
|
+
}).positional("value", {
|
|
218
|
+
type: "string",
|
|
219
|
+
describe: "Path (for a verb), app bundle id / ASC app id (shortcuts), docs path or search, or list|set|rm (keys)"
|
|
220
|
+
}).positional("value2", {
|
|
221
|
+
type: "string",
|
|
222
|
+
describe: "Team id (keys rm)"
|
|
223
|
+
}).options({
|
|
224
|
+
d: {
|
|
225
|
+
type: "array",
|
|
226
|
+
describe: "Request param, Stripe-style: -d key=value (string) or key:=value (number/bool/json); nesting via key[sub]"
|
|
227
|
+
},
|
|
228
|
+
team: {
|
|
229
|
+
type: "string",
|
|
230
|
+
describe: "ASC team id (if the org has more than one connected)"
|
|
231
|
+
},
|
|
232
|
+
force: {
|
|
233
|
+
type: "boolean",
|
|
234
|
+
describe: "Skip request-body schema validation and send as-is (post/patch)"
|
|
235
|
+
},
|
|
236
|
+
quiet: {
|
|
237
|
+
type: "boolean",
|
|
238
|
+
hidden: true
|
|
239
|
+
},
|
|
240
|
+
"key-id": {
|
|
241
|
+
type: "string",
|
|
242
|
+
describe: "ASC key id (keys set)"
|
|
243
|
+
},
|
|
244
|
+
issuer: {
|
|
245
|
+
type: "string",
|
|
246
|
+
describe: "ASC issuer id (keys set)"
|
|
247
|
+
},
|
|
248
|
+
"key-file": {
|
|
249
|
+
type: "string",
|
|
250
|
+
describe: "Path to the .p8 key file (keys set)"
|
|
251
|
+
},
|
|
252
|
+
name: {
|
|
253
|
+
type: "string",
|
|
254
|
+
describe: "Account name (keys set)"
|
|
255
|
+
},
|
|
256
|
+
"dry-run": {
|
|
257
|
+
type: "boolean",
|
|
258
|
+
hidden: true
|
|
259
|
+
}
|
|
260
|
+
}), (argv) => {
|
|
261
|
+
return import("./asc-CArSwo5D.js").then((m) => m.runAsc(argv));
|
|
262
|
+
});
|
|
263
|
+
const RESOURCE_HELP = {
|
|
264
|
+
orgs: "Your Superwall organizations (list, use <id|name>)",
|
|
265
|
+
apps: "Your apps, grouped by project (list, create <name> --platform ios, use <id>)"
|
|
266
|
+
};
|
|
267
|
+
for (const resource of RESOURCES) cli = cli.command(`${resource} [action] [value] [value2]`, RESOURCE_HELP[resource] ?? `Manage Superwall ${resource} (list, create)`, (y) => y.positional("action", {
|
|
268
|
+
type: "string",
|
|
269
|
+
default: "list",
|
|
270
|
+
describe: "list | create | placement | use | storekit"
|
|
271
|
+
}).positional("value", {
|
|
272
|
+
type: "string",
|
|
273
|
+
describe: "identifier / description / campaign id"
|
|
274
|
+
}).positional("value2", {
|
|
275
|
+
type: "string",
|
|
276
|
+
describe: "placement name (campaigns create / placement)"
|
|
277
|
+
}).options({
|
|
278
|
+
project: {
|
|
279
|
+
type: "string",
|
|
280
|
+
describe: "Scope to a project id"
|
|
281
|
+
},
|
|
282
|
+
app: {
|
|
283
|
+
type: "string",
|
|
284
|
+
describe: "Scope to an application id"
|
|
285
|
+
},
|
|
286
|
+
name: {
|
|
287
|
+
type: "string",
|
|
288
|
+
describe: "Display name (products create)"
|
|
289
|
+
},
|
|
290
|
+
platform: {
|
|
291
|
+
type: "string",
|
|
292
|
+
describe: "ios | android | flutter | react_native | web (apps create)"
|
|
293
|
+
},
|
|
294
|
+
bundle: {
|
|
295
|
+
type: "string",
|
|
296
|
+
describe: "Bundle id / package name (apps create)"
|
|
297
|
+
},
|
|
298
|
+
out: {
|
|
299
|
+
type: "string",
|
|
300
|
+
describe: "Output file (products storekit)"
|
|
301
|
+
},
|
|
302
|
+
price: {
|
|
303
|
+
type: "number",
|
|
304
|
+
describe: "Price in major units, e.g. 9.99 (products create)"
|
|
305
|
+
},
|
|
306
|
+
currency: {
|
|
307
|
+
type: "string",
|
|
308
|
+
describe: "ISO currency, default USD (products create)"
|
|
309
|
+
},
|
|
310
|
+
period: {
|
|
311
|
+
choices: [
|
|
312
|
+
"day",
|
|
313
|
+
"week",
|
|
314
|
+
"month",
|
|
315
|
+
"year"
|
|
316
|
+
],
|
|
317
|
+
describe: "Subscription billing period (products create)"
|
|
318
|
+
},
|
|
319
|
+
"period-count": {
|
|
320
|
+
type: "number",
|
|
321
|
+
describe: "Periods per cycle, default 1 (products create)"
|
|
322
|
+
},
|
|
323
|
+
"trial-days": {
|
|
324
|
+
type: "number",
|
|
325
|
+
describe: "Free-trial length in days (products create)"
|
|
326
|
+
},
|
|
327
|
+
entitlement: {
|
|
328
|
+
type: "array",
|
|
329
|
+
describe: "Entitlement id(s) to grant (products create)"
|
|
330
|
+
},
|
|
331
|
+
"dry-run": {
|
|
332
|
+
type: "boolean",
|
|
333
|
+
describe: "Plan without writing"
|
|
334
|
+
}
|
|
335
|
+
}), (argv) => {
|
|
336
|
+
return import("./resource-CdP1MDla.js").then((m) => m.runResource(resource)(argv));
|
|
337
|
+
});
|
|
338
|
+
cli = cli.command("bootstrap", "Complete account tree: orgs, projects, apps, campaigns, placements, and products", (y) => y, (argv) => {
|
|
339
|
+
return import("./api-BF7-toqM.js").then((m) => m.runBootstrap(argv));
|
|
340
|
+
});
|
|
341
|
+
for (const verb of API_VERBS) cli = cli.command(`${verb} <path>`, `Make ${verb.toUpperCase()} requests to the Superwall API`, (y) => y.positional("path", {
|
|
342
|
+
type: "string",
|
|
343
|
+
describe: "API path, e.g. /v2/products"
|
|
344
|
+
}).options({ d: {
|
|
345
|
+
type: "array",
|
|
346
|
+
describe: "Param, Stripe-style: -d key=value (string) or key:=value (number/bool/json); nesting via key[sub]"
|
|
347
|
+
} }), (argv) => {
|
|
348
|
+
return import("./api-BF7-toqM.js").then((m) => m.runApi(verb)(argv));
|
|
349
|
+
});
|
|
350
|
+
cli = cli.command("create [dir]", "Set up paywalls in your app - creates a superwall/ directory inside it", (y) => y.positional("dir", {
|
|
351
|
+
type: "string",
|
|
352
|
+
describe: "Your app's root (default: cwd) - paywalls land in superwall/ inside it"
|
|
353
|
+
}).options({
|
|
354
|
+
example: {
|
|
355
|
+
type: "string",
|
|
356
|
+
describe: "Start from a public example by name, e.g. --example with-rive"
|
|
357
|
+
},
|
|
358
|
+
yes: {
|
|
359
|
+
type: "boolean",
|
|
360
|
+
alias: "y",
|
|
361
|
+
describe: "Accept defaults and skip the optional prompts"
|
|
362
|
+
},
|
|
363
|
+
install: {
|
|
364
|
+
type: "boolean",
|
|
365
|
+
default: true,
|
|
366
|
+
describe: "Install dependencies after scaffolding (--no-install to skip)"
|
|
367
|
+
},
|
|
368
|
+
connect: {
|
|
369
|
+
type: "boolean",
|
|
370
|
+
default: true,
|
|
371
|
+
describe: "Connect a Superwall app when possible (--no-connect to skip)"
|
|
372
|
+
}
|
|
373
|
+
}).example("$0 create", "Set up superwall/ in the current app").example("$0 create --example with-rive", "Start from an example"), (argv) => {
|
|
374
|
+
return import("./create-Bbi8BOO1.js").then((m) => m.runCreate(argv));
|
|
375
|
+
}).command("dev [dir..]", "Host the studio: browse and preview your paywalls and funnels", (y) => y.positional("dir", {
|
|
376
|
+
type: "string",
|
|
377
|
+
array: true,
|
|
378
|
+
describe: "Project directories to serve (default: cwd)"
|
|
379
|
+
}).options({
|
|
380
|
+
port: {
|
|
381
|
+
type: "number",
|
|
382
|
+
default: 6100,
|
|
383
|
+
alias: "p",
|
|
384
|
+
describe: "Preferred port (falls back to the next free one)"
|
|
385
|
+
},
|
|
386
|
+
host: {
|
|
387
|
+
type: "string",
|
|
388
|
+
default: "0.0.0.0",
|
|
389
|
+
describe: "Host to bind"
|
|
390
|
+
}
|
|
391
|
+
}), (argv) => {
|
|
392
|
+
return import("./dev-D0lQDCQI.js").then((m) => m.runDev(argv));
|
|
393
|
+
}).command("push [dir]", "Build and push your paywalls as immutable versions (production untouched)", (y) => y.positional("dir", {
|
|
394
|
+
type: "string",
|
|
395
|
+
describe: "Project directory (default: cwd)"
|
|
396
|
+
}).options({
|
|
397
|
+
id: {
|
|
398
|
+
type: "array",
|
|
399
|
+
string: true,
|
|
400
|
+
describe: "Limit to these paywalls or funnels by id (repeatable, or comma-separated)"
|
|
401
|
+
},
|
|
402
|
+
platform: {
|
|
403
|
+
type: "array",
|
|
404
|
+
string: true,
|
|
405
|
+
describe: "Limit to these platforms (repeatable, or comma-separated) - ios, android, web, flutter, react_native"
|
|
406
|
+
},
|
|
407
|
+
rename: {
|
|
408
|
+
type: "array",
|
|
409
|
+
string: true,
|
|
410
|
+
describe: "Declare a renamed directory as <old>=<new> (repeatable) - required in CI, where the resolver cannot prompt"
|
|
411
|
+
},
|
|
412
|
+
message: {
|
|
413
|
+
type: "string",
|
|
414
|
+
alias: "m",
|
|
415
|
+
describe: "Publish note recorded in the source commit (only lands when this publish creates a new source commit — unchanged source reuses the existing commit)"
|
|
416
|
+
}
|
|
417
|
+
}), (argv) => {
|
|
418
|
+
return import("./push-BDkZUC0v.js").then((m) => m.runPush(argv));
|
|
419
|
+
}).command("promote [dir]", "Point production at a pushed version (the latest by default)", (y) => y.version(false).positional("dir", {
|
|
420
|
+
type: "string",
|
|
421
|
+
describe: "Project directory (default: cwd)"
|
|
422
|
+
}).options({
|
|
423
|
+
id: {
|
|
424
|
+
type: "array",
|
|
425
|
+
string: true,
|
|
426
|
+
describe: "Limit to these paywalls or funnels by id (repeatable, or comma-separated)"
|
|
427
|
+
},
|
|
428
|
+
platform: {
|
|
429
|
+
type: "array",
|
|
430
|
+
string: true,
|
|
431
|
+
describe: "Limit to these platforms (repeatable, or comma-separated) - ios, android, web, flutter, react_native"
|
|
432
|
+
},
|
|
433
|
+
version: {
|
|
434
|
+
type: "number",
|
|
435
|
+
alias: "v",
|
|
436
|
+
describe: "Pushed version number to promote (requires a single --id)"
|
|
437
|
+
}
|
|
438
|
+
}), (argv) => {
|
|
439
|
+
return import("./promote-CRe9170G.js").then((m) => m.runPromote(argv));
|
|
440
|
+
}).command("publish [dir]", "Push and promote in one step - build, version, and ship to production", (y) => y.positional("dir", {
|
|
441
|
+
type: "string",
|
|
442
|
+
describe: "Project directory (default: cwd)"
|
|
443
|
+
}).options({
|
|
444
|
+
id: {
|
|
445
|
+
type: "array",
|
|
446
|
+
string: true,
|
|
447
|
+
describe: "Limit to these paywalls or funnels by id (repeatable, or comma-separated)"
|
|
448
|
+
},
|
|
449
|
+
platform: {
|
|
450
|
+
type: "array",
|
|
451
|
+
string: true,
|
|
452
|
+
describe: "Limit to these platforms (repeatable, or comma-separated) - ios, android, web, flutter, react_native"
|
|
453
|
+
},
|
|
454
|
+
rename: {
|
|
455
|
+
type: "array",
|
|
456
|
+
string: true,
|
|
457
|
+
describe: "Declare a renamed directory as <old>=<new> (repeatable) - required in CI, where the resolver cannot prompt"
|
|
458
|
+
},
|
|
459
|
+
message: {
|
|
460
|
+
type: "string",
|
|
461
|
+
alias: "m",
|
|
462
|
+
describe: "Publish note recorded in the source commit (only lands when this publish creates a new source commit — unchanged source reuses the existing commit)"
|
|
463
|
+
}
|
|
464
|
+
}), (argv) => {
|
|
465
|
+
return import("./publish-DsODvrOD.js").then((m) => m.runPublish(argv));
|
|
466
|
+
});
|
|
467
|
+
await cli.command("$0", false, (y) => y, () => printHelp()).version(VERSION).alias("v", "version").help().alias("h", "help").recommendCommands().showHelpOnFail(false).fail((msg, err) => {
|
|
468
|
+
if (err) throw err;
|
|
469
|
+
const friendly = msg.replace(/^Unknown arguments?:/, "Unknown command:").replace(/^Not enough non-option arguments.*$/, "Missing a required argument.");
|
|
470
|
+
if (args.includes("--json")) writeJson(process.stdout, { error: {
|
|
471
|
+
code: "invalid_arguments",
|
|
472
|
+
message: friendly
|
|
473
|
+
} });
|
|
474
|
+
else process.stderr.write(`${pc.red("✗")} ${friendly}\n\nRun ${pc.bold("superwall --help")} for usage.\n`);
|
|
475
|
+
process.exit(1);
|
|
476
|
+
}).strict().parseAsync();
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/entry.ts
|
|
481
|
+
/**
|
|
482
|
+
* The CLI's programmatic entrypoint: the `superwall` package's bin calls
|
|
483
|
+
* this after registering tsx (which is what lets the paywall commands load
|
|
484
|
+
* the project's framework TypeScript at runtime).
|
|
485
|
+
*/
|
|
486
|
+
async function main() {
|
|
487
|
+
try {
|
|
488
|
+
await run();
|
|
489
|
+
} finally {
|
|
490
|
+
await Promise.all([flushTelemetry(), flushUpdateCheck()]);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
//#endregion
|
|
495
|
+
export { main };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { T as Integration } from "./telemetry-CcfrtXdf.js";
|
|
2
|
+
import { n as allDeps, r as readPackageJson } from "./scan-BQexuUPO.js";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import fg from "fast-glob";
|
|
5
|
+
|
|
6
|
+
//#region src/core/project/existing.ts
|
|
7
|
+
const JS_SDK_PACKAGES = {
|
|
8
|
+
[Integration.expo]: ["expo-superwall"],
|
|
9
|
+
[Integration.reactNative]: ["@superwall/react-native-superwall", "react-native-superwall"],
|
|
10
|
+
[Integration.web]: ["@superwall/web", "superwall-js"]
|
|
11
|
+
};
|
|
12
|
+
const PK_RE = /pk_[A-Za-z0-9._-]{6,}/;
|
|
13
|
+
const CONFIGURE_RE = /Superwall\.(shared\.)?configure|configureSuperwall|SuperwallProvider|\.configure\(\s*apiKey/;
|
|
14
|
+
const SDK_REF_RE = /Superwall-iOS|SuperwallKit|superwallkit_flutter|expo-superwall|superwall/i;
|
|
15
|
+
const SOURCE_GLOBS = [
|
|
16
|
+
"**/*.{swift,ts,tsx,js,jsx,kt,dart}",
|
|
17
|
+
"**/.env*",
|
|
18
|
+
"**/*.xcconfig"
|
|
19
|
+
];
|
|
20
|
+
const IGNORE = [
|
|
21
|
+
"**/node_modules/**",
|
|
22
|
+
"**/.git/**",
|
|
23
|
+
"**/Pods/**",
|
|
24
|
+
"**/build/**",
|
|
25
|
+
"**/.build/**",
|
|
26
|
+
"**/DerivedData/**",
|
|
27
|
+
"**/dist/**",
|
|
28
|
+
"**/.next/**"
|
|
29
|
+
];
|
|
30
|
+
const MAX_FILES = 600;
|
|
31
|
+
function sdkInstalledFor(app) {
|
|
32
|
+
const jsPkgs = JS_SDK_PACKAGES[app.integration];
|
|
33
|
+
if (jsPkgs) {
|
|
34
|
+
const deps = allDeps(readPackageJson(app.path));
|
|
35
|
+
if (jsPkgs.some((p) => p in deps)) return true;
|
|
36
|
+
}
|
|
37
|
+
const manifests = fg.sync([
|
|
38
|
+
"**/Package.resolved",
|
|
39
|
+
"**/project.pbxproj",
|
|
40
|
+
"**/Podfile",
|
|
41
|
+
"**/pubspec.yaml",
|
|
42
|
+
"**/pubspec.lock"
|
|
43
|
+
], {
|
|
44
|
+
cwd: app.path,
|
|
45
|
+
ignore: IGNORE,
|
|
46
|
+
absolute: true,
|
|
47
|
+
deep: 5
|
|
48
|
+
});
|
|
49
|
+
for (const f of manifests) try {
|
|
50
|
+
if (SDK_REF_RE.test(readFileSync(f, "utf8"))) return true;
|
|
51
|
+
} catch {}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
function detectExisting(app) {
|
|
55
|
+
const sdkInstalled = sdkInstalledFor(app);
|
|
56
|
+
let configureFound = false;
|
|
57
|
+
let apiKey;
|
|
58
|
+
const files = fg.sync(SOURCE_GLOBS, {
|
|
59
|
+
cwd: app.path,
|
|
60
|
+
ignore: IGNORE,
|
|
61
|
+
absolute: true,
|
|
62
|
+
deep: 6,
|
|
63
|
+
dot: true
|
|
64
|
+
});
|
|
65
|
+
for (const f of files.slice(0, MAX_FILES)) {
|
|
66
|
+
let content;
|
|
67
|
+
try {
|
|
68
|
+
content = readFileSync(f, "utf8");
|
|
69
|
+
} catch {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (!configureFound && CONFIGURE_RE.test(content)) configureFound = true;
|
|
73
|
+
if (!apiKey) {
|
|
74
|
+
const m = content.match(PK_RE);
|
|
75
|
+
if (m) apiKey = m[0];
|
|
76
|
+
}
|
|
77
|
+
if (configureFound && apiKey) break;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
sdkInstalled,
|
|
81
|
+
configureFound,
|
|
82
|
+
apiKey,
|
|
83
|
+
fullyIntegrated: sdkInstalled && configureFound
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
export { detectExisting as t };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { D as TELEMETRY_HOST, O as TELEMETRY_KEY, k as VERSION, s as getAnonymousId } from "./telemetry-CcfrtXdf.js";
|
|
2
|
+
import "./json-C3hPIMkI.js";
|
|
3
|
+
import "./update-BiVeR024.js";
|
|
4
|
+
import { i as loadSession } from "./token-DHRH8cxi.js";
|
|
5
|
+
import { t as defineCommand } from "./command-Kwx4ekbo.js";
|
|
6
|
+
import "./ui-C4ncRJqd.js";
|
|
7
|
+
|
|
8
|
+
//#region src/core/feedback.ts
|
|
9
|
+
function buildFeedbackEvent(message, via, distinctId, session) {
|
|
10
|
+
return {
|
|
11
|
+
api_key: TELEMETRY_KEY,
|
|
12
|
+
event: "feedback submitted",
|
|
13
|
+
distinct_id: distinctId,
|
|
14
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15
|
+
properties: {
|
|
16
|
+
$process_person_profile: false,
|
|
17
|
+
message,
|
|
18
|
+
via,
|
|
19
|
+
cli_version: VERSION,
|
|
20
|
+
platform: process.platform,
|
|
21
|
+
email: session?.userEmail ?? null,
|
|
22
|
+
org_id: session?.orgId ?? null,
|
|
23
|
+
org_name: session?.orgName ?? null
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async function submitFeedback(message, via) {
|
|
28
|
+
if (!TELEMETRY_KEY) return false;
|
|
29
|
+
const payload = buildFeedbackEvent(message, via, getAnonymousId(), loadSession());
|
|
30
|
+
try {
|
|
31
|
+
return (await fetch(`${TELEMETRY_HOST}/capture/`, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: { "content-type": "application/json" },
|
|
34
|
+
body: JSON.stringify(payload),
|
|
35
|
+
signal: AbortSignal.timeout(8e3)
|
|
36
|
+
})).ok;
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/commands/account/feedback.ts
|
|
44
|
+
const runFeedback = defineCommand({
|
|
45
|
+
name: "feedback",
|
|
46
|
+
output: "both",
|
|
47
|
+
async run(ctx) {
|
|
48
|
+
const { ui, json, interactive, argv } = ctx;
|
|
49
|
+
let message = argv.message?.trim();
|
|
50
|
+
if (!message && interactive) {
|
|
51
|
+
ui.intro("Superwall feedback");
|
|
52
|
+
const answer = await ui.text({
|
|
53
|
+
message: "What's your feedback on the Superwall CLI?",
|
|
54
|
+
placeholder: "What worked, what didn't, what's missing...",
|
|
55
|
+
validate: (v) => v?.trim() ? void 0 : "Required"
|
|
56
|
+
});
|
|
57
|
+
if (answer === null) return void ui.warn("Cancelled.");
|
|
58
|
+
message = answer.trim();
|
|
59
|
+
}
|
|
60
|
+
if (!message) throw new Error("Usage: superwall feedback \"<message>\"");
|
|
61
|
+
const via = interactive ? "human" : "agent";
|
|
62
|
+
const spin = interactive ? ui.spinner() : null;
|
|
63
|
+
spin?.start("Sending your feedback");
|
|
64
|
+
const ok = await submitFeedback(message, via);
|
|
65
|
+
spin?.stop(ok ? "Sent" : "Failed to send");
|
|
66
|
+
if (json) return ctx.output.data({ submitted: ok });
|
|
67
|
+
if (!ok) throw new Error("Couldn't send your feedback - check your connection and try again.");
|
|
68
|
+
ui.success("Thank you! We've received your feedback and will read through it. Really appreciate you helping us make the CLI better.");
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { runFeedback };
|