@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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Superwall, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://superwall.com/">
|
|
3
|
+
<img src="https://user-images.githubusercontent.com/3296904/158817914-144c66d0-572d-43a4-9d47-d7d0b711c6d7.png" alt="Superwall" height="100" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Superwall CLI</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
Build paywalls and funnels as code, set up the SDK, manage products and
|
|
11
|
+
campaigns, query your analytics data, and call the API — from your terminal
|
|
12
|
+
or your coding agent.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --global superwall
|
|
19
|
+
superwall login
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or run it without installing: `npx superwall`. The CLI ships inside the
|
|
23
|
+
`superwall` package (the framework), which installs both the `superwall` and
|
|
24
|
+
the short `sw` command. Upgrade any time with
|
|
25
|
+
`superwall upgrade` - the CLI also tells you when a new version is out.
|
|
26
|
+
|
|
27
|
+
`superwall login` opens your browser once and every command shares that
|
|
28
|
+
session. In CI, log in without a browser: `superwall login --api-key <key>`.
|
|
29
|
+
If your account belongs to more than one organization, pick one with
|
|
30
|
+
`superwall orgs use` (you'll otherwise be asked the first time it matters).
|
|
31
|
+
|
|
32
|
+
## Set up your app
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
superwall integrate # set up Superwall in your app from scratch
|
|
36
|
+
superwall migrate # switch from RevenueCat, Adapty, or Qonversion
|
|
37
|
+
superwall review # audit an existing setup; add --fix to repair issues
|
|
38
|
+
superwall doctor # quick health check
|
|
39
|
+
superwall feedback # tell us what's working and what isn't
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`integrate` works out what kind of app it's looking at, connects it to your
|
|
43
|
+
Superwall account, and runs your own coding agent (Claude Code or Codex,
|
|
44
|
+
headless) to install and configure the SDK. Then it walks you through the
|
|
45
|
+
rest: products, campaigns, placements, paywalls, and verifying it all on a
|
|
46
|
+
real device.
|
|
47
|
+
|
|
48
|
+
Prefer to drive the agent yourself? Add `--skill` to `integrate`, `migrate`,
|
|
49
|
+
or `review` and the CLI prints the full playbook for your project's framework
|
|
50
|
+
instead of running it — paste it into any agent.
|
|
51
|
+
|
|
52
|
+
## Build paywalls & funnels
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
superwall create # start a paywalls project — minimal, or any public example
|
|
56
|
+
superwall dev # open the studio and preview everything live
|
|
57
|
+
superwall push # build and push immutable versions (production untouched)
|
|
58
|
+
superwall promote # point production at a pushed version
|
|
59
|
+
superwall publish # push and promote in one step
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`create` sets up a `superwall/` directory in your app — always that name,
|
|
63
|
+
always self-contained. `push -m "why"` records a note in the source commit,
|
|
64
|
+
and `promote --version <n>` points production at any pushed version, so a
|
|
65
|
+
rollback is one command. A project can push to several platforms: each
|
|
66
|
+
paywall's `config.ts` lists them (`platforms: ["ios", "android"]`; the lock
|
|
67
|
+
binds one app per platform), and `--platform <p>` narrows `push`, `promote`,
|
|
68
|
+
and `publish` to one of them. It asks for a starting point (`--example with-rive` to
|
|
69
|
+
begin from any example in the public repo), then looks at the app around it:
|
|
70
|
+
if the Superwall SDK is already configured, it finds your app by its API key
|
|
71
|
+
and binds pushes to it; otherwise it can log you in, pick an app, or create
|
|
72
|
+
one on the spot. `--yes` accepts the defaults; `--no-install` and
|
|
73
|
+
`--no-connect` skip those steps.
|
|
74
|
+
|
|
75
|
+
## Manage your account
|
|
76
|
+
|
|
77
|
+
Everything in the dashboard, from the terminal:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
superwall apps list
|
|
81
|
+
superwall products create pro_monthly --price 9.99 --period month
|
|
82
|
+
superwall products storekit # generate a local .storekit file
|
|
83
|
+
superwall entitlements create pro
|
|
84
|
+
superwall campaigns create "Onboarding upsell" onboarding_complete
|
|
85
|
+
superwall campaigns placement <campaign-id> onboarding_complete
|
|
86
|
+
superwall paywalls list
|
|
87
|
+
superwall whoami
|
|
88
|
+
superwall bootstrap # the whole account tree at a glance
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`list` is the default action, so `superwall products` means
|
|
92
|
+
`superwall products list`. Add `--json` for machine-readable output, and
|
|
93
|
+
`--project <id>` / `--app <id>` to scope when you have more than one. Run
|
|
94
|
+
`superwall <command> --help` for every action and flag.
|
|
95
|
+
|
|
96
|
+
## Query your data
|
|
97
|
+
|
|
98
|
+
Run SQL directly against your organization's ClickHouse analytics data:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
superwall query "SHOW TABLES FROM sw"
|
|
102
|
+
superwall query "SELECT count() FROM sw.<table>"
|
|
103
|
+
superwall query --file mrr.sql
|
|
104
|
+
cat query.sql | superwall query
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Use it for anything you'd build on raw data: ad hoc analysis, custom
|
|
108
|
+
dashboards, scheduled reports, agent workflows. `--json` returns ClickHouse's
|
|
109
|
+
native JSON envelope. Your session needs `data:read` access.
|
|
110
|
+
|
|
111
|
+
## Call the API
|
|
112
|
+
|
|
113
|
+
Any Superwall API endpoint, authenticated with your session:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
superwall get /v2/products
|
|
117
|
+
superwall post /v2/products -d name="Pro Monthly" -d price:=9.99
|
|
118
|
+
superwall delete /v2/products/prod_123
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`-d key=value` sends a string, `key:=value` sends typed JSON (numbers,
|
|
122
|
+
booleans, objects), and `key[sub]=value` nests. On `get` and `delete`, `-d`
|
|
123
|
+
params become query parameters.
|
|
124
|
+
|
|
125
|
+
## App Store Connect
|
|
126
|
+
|
|
127
|
+
The **entire** App Store Connect API, proxied and signed by Superwall — no
|
|
128
|
+
`.p8` file or JWT to manage locally. Connect your credentials once:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
superwall asc keys set --key-id <id> --issuer <id> --key-file AuthKey.p8
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Then it's the raw ASC API with the sharp edges filed off, because the CLI is
|
|
135
|
+
**schema-aware**: it keeps a copy of Apple's own OpenAPI spec (fetched on first
|
|
136
|
+
use, refreshed in the background) and knows every endpoint, field, and enum.
|
|
137
|
+
|
|
138
|
+
Look up the exact schema for anything — no guessing, no hunting through Apple's
|
|
139
|
+
docs:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
superwall asc docs # browse every resource
|
|
143
|
+
superwall asc docs "introductory offer" # search by keyword
|
|
144
|
+
superwall asc docs /v1/subscriptions post # required fields, enums, relationships
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Write with flat params. The CLI assembles the JSON:API body for you and
|
|
148
|
+
validates it locally, so a mistake comes back as a precise fix instead of one of
|
|
149
|
+
Apple's opaque `409`s:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
superwall asc post /v1/subscriptions \
|
|
153
|
+
-d name="Premium Monthly" -d productId=com.acme.pro \
|
|
154
|
+
-d subscriptionPeriod=MONTHLY -d group=<groupId>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
✗ Invalid POST /v1/subscriptions body:
|
|
159
|
+
• subscriptionPeriod "MONTHLY" not allowed — use ONE_WEEK|ONE_MONTH|…|ONE_YEAR
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Fix the value and it goes through. Shortcuts cover the common reads
|
|
163
|
+
(`asc apps`, `asc products <bundle-id>`, `asc subscriptions <bundle-id>`);
|
|
164
|
+
everything else is `asc get|post|patch|delete /v1/…`. Between the schema lookup
|
|
165
|
+
and the validation, an agent can build and manage your whole ASC catalog —
|
|
166
|
+
groups, subscriptions, prices, introductory offers — without ever memorizing the
|
|
167
|
+
API or eating a silent rejection.
|
|
168
|
+
|
|
169
|
+
## For agents and scripts
|
|
170
|
+
|
|
171
|
+
Pass `--json` to any command: stable output shape, structured errors, never
|
|
172
|
+
prompts. `--no-interactive` keeps the human-readable output but drops the
|
|
173
|
+
prompts.
|
|
174
|
+
|
|
175
|
+
Logging in also installs the [Superwall agent skills](https://github.com/superwall/skills)
|
|
176
|
+
into your coding agent and keeps them updated. `superwall skills` reinstalls
|
|
177
|
+
them (or a subset) manually; `superwall skills -y` installs everything without
|
|
178
|
+
asking.
|
|
179
|
+
|
|
180
|
+
## Telemetry
|
|
181
|
+
|
|
182
|
+
The CLI sends fully anonymous usage events (which workflow ran and whether it
|
|
183
|
+
succeeded — never emails, IDs, file paths, SQL, prompts, or error messages).
|
|
184
|
+
Opt out with `SUPERWALL_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.
|
|
185
|
+
|
|
186
|
+
## Develop
|
|
187
|
+
|
|
188
|
+
**Read [AGENTS.md](AGENTS.md) first** - command naming, UI rules, skill
|
|
189
|
+
authoring, and the sync checklist are decided conventions, not suggestions.
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
bun install
|
|
193
|
+
bun dev # run from source (bun bin.ts)
|
|
194
|
+
bun run build # build dist/ with tsdown
|
|
195
|
+
bun run typecheck
|
|
196
|
+
bun run test
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The global `superwall`/`sw` binaries are declared by the framework package:
|
|
200
|
+
`cd ../superwall && bun link` links them. They run this package's built
|
|
201
|
+
`dist/`, so rebuild after every change.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { T as Integration } from "./telemetry-CcfrtXdf.js";
|
|
2
|
+
import { i as loadBundledSkill } from "./skills-xrfXt9u0.js";
|
|
3
|
+
|
|
4
|
+
//#region src/core/agent/actions.ts
|
|
5
|
+
/** Skill reference file per framework, so an agent only sees its own platform's docs. */
|
|
6
|
+
const FRAMEWORK_REF = {
|
|
7
|
+
[Integration.swift]: "ios",
|
|
8
|
+
[Integration.expo]: "expo",
|
|
9
|
+
[Integration.reactNative]: "react-native",
|
|
10
|
+
[Integration.flutter]: "flutter"
|
|
11
|
+
};
|
|
12
|
+
const PROVIDER_REF = {
|
|
13
|
+
revenuecat: "revenuecat",
|
|
14
|
+
adapty: "adapty",
|
|
15
|
+
qonversion: "qonversion"
|
|
16
|
+
};
|
|
17
|
+
const WRITE_CAPABILITIES = {
|
|
18
|
+
filesystem: "write",
|
|
19
|
+
network: true,
|
|
20
|
+
shell: "unrestricted"
|
|
21
|
+
};
|
|
22
|
+
const READ_CAPABILITIES = {
|
|
23
|
+
filesystem: "read",
|
|
24
|
+
network: true,
|
|
25
|
+
shell: "read-only"
|
|
26
|
+
};
|
|
27
|
+
const ACTIONS = [
|
|
28
|
+
{
|
|
29
|
+
id: "integrate",
|
|
30
|
+
title: "Integrate the SDK",
|
|
31
|
+
hint: "Install + configure the Superwall SDK",
|
|
32
|
+
runningLabel: "Starting the integration",
|
|
33
|
+
successLabel: "Integration complete",
|
|
34
|
+
requiresIntegration: false,
|
|
35
|
+
requiresOrgKey: false,
|
|
36
|
+
outputMode: "silent",
|
|
37
|
+
capabilities: WRITE_CAPABILITIES,
|
|
38
|
+
vars: (ctx) => ({ skill: loadBundledSkill("superwall-integrate", FRAMEWORK_REF[ctx.app.framework.integration]) })
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "review",
|
|
42
|
+
title: "Review the setup",
|
|
43
|
+
hint: "Audit the SDK, purchasing, identity, deep links, placements & dashboard",
|
|
44
|
+
runningLabel: "Reviewing your Superwall setup",
|
|
45
|
+
successLabel: "Setup review complete",
|
|
46
|
+
requiresIntegration: true,
|
|
47
|
+
requiresOrgKey: false,
|
|
48
|
+
outputMode: "report",
|
|
49
|
+
capabilities: READ_CAPABILITIES,
|
|
50
|
+
vars: (ctx) => ({ skill: loadBundledSkill("superwall-review", FRAMEWORK_REF[ctx.app.framework.integration]) })
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "review-fix",
|
|
54
|
+
title: "Fix setup issues",
|
|
55
|
+
hint: "Apply verified, safe fixes from the setup review",
|
|
56
|
+
runningLabel: "Fixing your Superwall setup",
|
|
57
|
+
successLabel: "Setup fixes complete",
|
|
58
|
+
requiresIntegration: true,
|
|
59
|
+
requiresOrgKey: false,
|
|
60
|
+
outputMode: "silent",
|
|
61
|
+
capabilities: WRITE_CAPABILITIES,
|
|
62
|
+
vars: (ctx) => ({
|
|
63
|
+
prior_report: ctx.priorReport ?? "",
|
|
64
|
+
skill: loadBundledSkill("superwall-review", FRAMEWORK_REF[ctx.app.framework.integration])
|
|
65
|
+
})
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "placements-review",
|
|
69
|
+
title: "Review placements",
|
|
70
|
+
hint: "Audit every register() call + positioning",
|
|
71
|
+
runningLabel: "Reviewing placements",
|
|
72
|
+
successLabel: "Placement review complete",
|
|
73
|
+
requiresIntegration: true,
|
|
74
|
+
requiresOrgKey: false,
|
|
75
|
+
outputMode: "report",
|
|
76
|
+
capabilities: READ_CAPABILITIES,
|
|
77
|
+
vars: (ctx) => ({
|
|
78
|
+
campaigns: ctx.campaigns ?? "",
|
|
79
|
+
skill: loadBundledSkill("superwall-placements", ["strategy", FRAMEWORK_REF[ctx.app.framework.integration]])
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "placements-implement",
|
|
84
|
+
title: "Implement placements",
|
|
85
|
+
hint: "Add register() calls at the right feature gates",
|
|
86
|
+
runningLabel: "Implementing placements",
|
|
87
|
+
successLabel: "Placements implemented",
|
|
88
|
+
requiresIntegration: true,
|
|
89
|
+
requiresOrgKey: false,
|
|
90
|
+
outputMode: "silent",
|
|
91
|
+
capabilities: WRITE_CAPABILITIES,
|
|
92
|
+
vars: (ctx) => ({
|
|
93
|
+
prior_report: ctx.priorReport ?? "",
|
|
94
|
+
campaigns: ctx.campaigns ?? "",
|
|
95
|
+
skill: loadBundledSkill("superwall-placements", ["strategy", FRAMEWORK_REF[ctx.app.framework.integration]])
|
|
96
|
+
})
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: "dashboard-setup",
|
|
100
|
+
title: "Set up the dashboard",
|
|
101
|
+
hint: "Create a campaign + placement so paywalls present",
|
|
102
|
+
runningLabel: "Setting up the dashboard",
|
|
103
|
+
successLabel: "Dashboard configured",
|
|
104
|
+
requiresIntegration: false,
|
|
105
|
+
requiresOrgKey: true,
|
|
106
|
+
outputMode: "report",
|
|
107
|
+
capabilities: {
|
|
108
|
+
filesystem: "read",
|
|
109
|
+
network: true,
|
|
110
|
+
shell: "unrestricted"
|
|
111
|
+
},
|
|
112
|
+
vars: (ctx) => ({
|
|
113
|
+
skill: loadBundledSkill("superwall-dashboard"),
|
|
114
|
+
app_key: ctx.apiKey || "(the app you're working on)"
|
|
115
|
+
})
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "migrate",
|
|
119
|
+
title: "Migrate to Superwall",
|
|
120
|
+
hint: "Move products, entitlements & paywalls off your current provider",
|
|
121
|
+
runningLabel: "Migrating to Superwall",
|
|
122
|
+
successLabel: "Migration complete",
|
|
123
|
+
requiresIntegration: false,
|
|
124
|
+
requiresOrgKey: false,
|
|
125
|
+
outputMode: "report",
|
|
126
|
+
capabilities: WRITE_CAPABILITIES,
|
|
127
|
+
vars: (ctx) => {
|
|
128
|
+
const provider = ctx.billingProvider ?? "the current billing provider";
|
|
129
|
+
return {
|
|
130
|
+
provider,
|
|
131
|
+
goal: ctx.migrateIntent === "paywalls" ? `paywalls only, keep ${provider} for billing` : "full migration",
|
|
132
|
+
skill: loadBundledSkill("superwall-migrate", PROVIDER_REF[provider.toLowerCase()])
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
const actionById = Object.fromEntries(ACTIONS.map((a) => [a.id, a]));
|
|
138
|
+
|
|
139
|
+
//#endregion
|
|
140
|
+
export { FRAMEWORK_REF as n, actionById as r, ACTIONS as t };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import "./telemetry-CcfrtXdf.js";
|
|
2
|
+
import "./json-C3hPIMkI.js";
|
|
3
|
+
import "./update-BiVeR024.js";
|
|
4
|
+
import "./token-DHRH8cxi.js";
|
|
5
|
+
import { t as defineCommand } from "./command-Kwx4ekbo.js";
|
|
6
|
+
import "./ui-C4ncRJqd.js";
|
|
7
|
+
import { C as rowName, h as listResource, m as listProjects, p as listOrganizations, w as titleCase, y as platformLabel } from "./resources-CVrWwA1K.js";
|
|
8
|
+
import { t as parseParams } from "./params-Bvq0iqQK.js";
|
|
9
|
+
import { n as emitJson, t as apiCall } from "./api-output-B5hh0q4V.js";
|
|
10
|
+
import pc from "picocolors";
|
|
11
|
+
|
|
12
|
+
//#region src/commands/platform/api.ts
|
|
13
|
+
function runApi(verb) {
|
|
14
|
+
return defineCommand({
|
|
15
|
+
name: verb,
|
|
16
|
+
auth: "required",
|
|
17
|
+
interaction: "none",
|
|
18
|
+
output: "both",
|
|
19
|
+
async run(ctx) {
|
|
20
|
+
const path = String(ctx.argv.path ?? "");
|
|
21
|
+
if (!path.startsWith("/")) throw new Error(`Path must start with "/", e.g. /v2/products`);
|
|
22
|
+
const params = parseParams(ctx.argv.d);
|
|
23
|
+
return emitJson(ctx, await apiCall(ctx, `${verb.toUpperCase()} ${path}`, () => {
|
|
24
|
+
switch (verb) {
|
|
25
|
+
case "get": return ctx.api.get(withQuery(path, params));
|
|
26
|
+
case "delete": return ctx.api.del(withQuery(path, params));
|
|
27
|
+
case "post": return ctx.api.post(path, params);
|
|
28
|
+
case "patch": return ctx.api.patch(path, params);
|
|
29
|
+
}
|
|
30
|
+
}) ?? { ok: true });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function withQuery(path, params) {
|
|
35
|
+
const entries = Object.entries(params);
|
|
36
|
+
if (entries.length === 0) return path;
|
|
37
|
+
const qs = new URLSearchParams();
|
|
38
|
+
for (const [key, value] of entries) {
|
|
39
|
+
if (typeof value === "object" && value !== null) throw new Error(`Nested -d params aren't supported on GET/DELETE (got "${key}").`);
|
|
40
|
+
qs.set(key, String(value));
|
|
41
|
+
}
|
|
42
|
+
return `${path}${path.includes("?") ? "&" : "?"}${qs}`;
|
|
43
|
+
}
|
|
44
|
+
const runBootstrap = defineCommand({
|
|
45
|
+
name: "bootstrap",
|
|
46
|
+
auth: "required",
|
|
47
|
+
interaction: "none",
|
|
48
|
+
output: "both",
|
|
49
|
+
async run(ctx) {
|
|
50
|
+
const tree = await apiCall(ctx, "Loading your account", () => buildAccountTree(ctx.api));
|
|
51
|
+
if (ctx.json) return emitJson(ctx, tree);
|
|
52
|
+
const who = [ctx.api.userEmail, ctx.api.org.name].filter(Boolean).join(" · ");
|
|
53
|
+
if (who) ctx.ui.step(who);
|
|
54
|
+
const text = tree.organizations.flatMap((org) => renderTree([orgNode(org)])).join("\n");
|
|
55
|
+
ctx.output.text(text);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
async function buildAccountTree(api) {
|
|
59
|
+
const orgs = await listOrganizations(api);
|
|
60
|
+
const orgList = orgs.length > 0 ? orgs : [{
|
|
61
|
+
id: api.org.id,
|
|
62
|
+
name: api.org.name
|
|
63
|
+
}];
|
|
64
|
+
for (const org of orgList) if (!org.name && String(org.id ?? "") === api.org.id) org.name = api.org.name;
|
|
65
|
+
return { organizations: await Promise.all(orgList.map(async (org) => {
|
|
66
|
+
const projects = String(org.id ?? "") === api.org.id ? await listProjects(api) : await api.list(`/v2/projects?organization_id=${org.id}`);
|
|
67
|
+
const full = await Promise.all(projects.map(async (p) => {
|
|
68
|
+
const scope = { projectId: String(p.id) };
|
|
69
|
+
const [products, entitlements, apps] = await Promise.all([
|
|
70
|
+
listResource(api, "products", scope),
|
|
71
|
+
listResource(api, "entitlements", scope),
|
|
72
|
+
Promise.all((p.applications ?? []).map(async (a) => {
|
|
73
|
+
const appScope = {
|
|
74
|
+
...scope,
|
|
75
|
+
applicationId: String(a.id)
|
|
76
|
+
};
|
|
77
|
+
const [campaigns, paywalls] = await Promise.all([listResource(api, "campaigns", appScope), listResource(api, "paywalls", appScope)]);
|
|
78
|
+
return {
|
|
79
|
+
...a,
|
|
80
|
+
campaigns,
|
|
81
|
+
paywalls
|
|
82
|
+
};
|
|
83
|
+
}))
|
|
84
|
+
]);
|
|
85
|
+
return {
|
|
86
|
+
...p,
|
|
87
|
+
products,
|
|
88
|
+
entitlements,
|
|
89
|
+
applications_full: apps
|
|
90
|
+
};
|
|
91
|
+
}));
|
|
92
|
+
return {
|
|
93
|
+
...org,
|
|
94
|
+
projects: full
|
|
95
|
+
};
|
|
96
|
+
})) };
|
|
97
|
+
}
|
|
98
|
+
function renderTree(nodes, prefix = "") {
|
|
99
|
+
return nodes.flatMap((node, i) => {
|
|
100
|
+
const last = i === nodes.length - 1;
|
|
101
|
+
const line = `${prefix}${last ? "└── " : "├── "}${node.label}`;
|
|
102
|
+
const childPrefix = `${prefix}${last ? " " : "│ "}`;
|
|
103
|
+
return [line, ...renderTree(node.children ?? [], childPrefix)];
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const id = (row) => pc.dim(`#${row.id}`);
|
|
107
|
+
const group = (name, rows, child) => ({
|
|
108
|
+
label: rows.length ? `${name} ${pc.dim(`(${rows.length})`)}` : pc.dim(`${name} (0)`),
|
|
109
|
+
children: rows.map(child)
|
|
110
|
+
});
|
|
111
|
+
function orgNode(org) {
|
|
112
|
+
return {
|
|
113
|
+
label: `${pc.bold(rowName(org))} ${id(org)}${org.role ? pc.dim(` · ${titleCase(String(org.role))}`) : ""}`,
|
|
114
|
+
children: org.projects.map(projectNode)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function projectNode(p) {
|
|
118
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
119
|
+
const apps = p.applications_full.map((a) => {
|
|
120
|
+
const products = p.products.filter((r) => String(r.platform ?? "") === String(a.platform ?? ""));
|
|
121
|
+
for (const r of products) claimed.add(r.id);
|
|
122
|
+
return appNode(a, products, p.entitlements);
|
|
123
|
+
});
|
|
124
|
+
const leftover = p.products.filter((r) => !claimed.has(r.id));
|
|
125
|
+
return {
|
|
126
|
+
label: `${pc.bold(p.name ?? String(p.id))} ${id(p)}`,
|
|
127
|
+
children: [...apps, ...leftover.length ? [group("products (no app)", leftover, (r) => ({ label: `${rowName(r)} ${id(r)}` }))] : []]
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function appNode(a, products, entitlements) {
|
|
131
|
+
const key = a.public_api_key ? pc.dim(`pk_…${a.public_api_key.slice(-4)}`) : id(a);
|
|
132
|
+
return {
|
|
133
|
+
label: `${platformLabel(a.platform)} · ${a.bundle_id ?? a.name ?? a.id} ${key}`,
|
|
134
|
+
children: [
|
|
135
|
+
group("campaigns", a.campaigns, campaignNode),
|
|
136
|
+
group("paywalls", a.paywalls, (r) => ({ label: `${rowName(r)} ${id(r)}` })),
|
|
137
|
+
group("products", products, (r) => ({ label: `${rowName(r)} ${id(r)}` })),
|
|
138
|
+
group("entitlements", entitlements, (r) => ({ label: `${rowName(r)} ${id(r)}` }))
|
|
139
|
+
]
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function campaignNode(c) {
|
|
143
|
+
const placements = c.placements ?? [];
|
|
144
|
+
return {
|
|
145
|
+
label: `${String(c.description ?? rowName(c))} ${id(c)}`,
|
|
146
|
+
children: placements.map((p) => ({ label: `${String(p.event_name ?? p.id)}${p.enabled === false ? pc.dim(" · disabled") : ""}` }))
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
export { runApi, runBootstrap };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/util/api-output.ts
|
|
2
|
+
function emitJson(ctx, data) {
|
|
3
|
+
ctx.output.data(data);
|
|
4
|
+
}
|
|
5
|
+
async function apiCall(ctx, label, work) {
|
|
6
|
+
if (ctx.outputMode !== "rich") return work();
|
|
7
|
+
const spin = ctx.ui.spinner();
|
|
8
|
+
spin.start(label);
|
|
9
|
+
try {
|
|
10
|
+
const result = await work();
|
|
11
|
+
spin.stop(label);
|
|
12
|
+
return result;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
spin.stop("Failed");
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { emitJson as n, apiCall as t };
|