@superwall/cli 2.2.1 → 2.3.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 +24 -11
- package/dist/{apple-DaqaI4vD.js → apple-D79LBw5E.js} +13 -13
- package/dist/assets-Diivv88t.js +89 -0
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +3 -3
- package/dist/{billing-DyKr2kmd.js → billing-CCuMv6mh.js} +3 -3
- package/dist/{bind-BpxebZf4.js → bind-CVRlFlRo.js} +4 -4
- package/dist/{build-DzbdRThf.js → build-BCq0cGh-.js} +7 -6
- package/dist/{client-BF9rCULI.js → client-CYtQvWJR.js} +3 -3
- package/dist/{create-B55V99TD.js → create-BZyUW60x.js} +28 -226
- package/dist/{create-D7AZHYGH.js → create-BaP6hoQ1.js} +6 -6
- package/dist/create-DNfuZ9os.js +19 -0
- package/dist/{doctor-B2mPKiaJ.js → doctor-kx01VvQX.js} +6 -6
- package/dist/{drivers-DOMky8Ug.js → drivers-D0818zGc.js} +3 -3
- package/dist/entry.js +19 -19
- package/dist/{environment-DBwo79dy.js → environment-a7W-0wg0.js} +1 -1
- package/dist/{existing-B4VK4BCL.js → existing-B7qxYiUX.js} +2 -2
- package/dist/held-C4BiAQ_X.js +16 -0
- package/dist/{held-DjcZPCwn.js → held-CEyXc1SI.js} +6 -6
- package/dist/{integrate-B8oHbvwz.js → integrate-RK5U0GTQ.js} +22 -22
- package/dist/login-DV70XgZO.js +16 -0
- package/dist/{login-DfhqWY9C.js → login-DrMLxlF4.js} +6 -6
- package/dist/{login-B8hgMLhS.js → login-NxCl2WuU.js} +1 -1
- package/dist/{lookup-r8p6H2ZC.js → lookup-Dor6ch5A.js} +2 -2
- package/dist/{migrate-DQf2Fosc.js → migrate-CjSpcnNu.js} +25 -22
- package/dist/{open-CrEnSL4v.js → migration-MlzZHGP-.js} +11 -49
- package/dist/{notification-url-BxPTEmkv.js → notification-url-C_QXtljc.js} +2 -2
- package/dist/open-CBW0Cuog.js +41 -0
- package/dist/{org-Cc2WGvl1.js → org-BJCyaL1b.js} +2 -2
- package/dist/{paths-BcNbJfpw.js → paths-Cp_lgyWO.js} +1 -1
- package/dist/{playbook-D9J8frkE.js → playbook-VqV7546k.js} +10 -10
- package/dist/{promote-C8T7DCFF.js → promote-BSckFPwZ.js} +18 -16
- package/dist/pull-DEumBwvc.js +303 -0
- package/dist/{push-Bzs1l_5C.js → push-D-dewDd1.js} +8 -6
- package/dist/push-YEPqa6hs.js +24 -0
- package/dist/{registry-CpxZbmxp.js → registry-D6M1JxYC.js} +230 -115
- package/dist/{resources-Bo6i7wBi.js → resources-DKn4itf3.js} +21 -7
- package/dist/{run-BUp4r8Kk.js → run-Ccv5egCC.js} +2 -2
- package/dist/{scan-8cxu2fx0.js → scan-Be17rMcQ.js} +1 -1
- package/dist/scan-CocGVPe0.js +4 -0
- package/dist/{scope-CPG_wWXL.js → scope-92neiQ2q.js} +5 -4
- package/dist/{selection-CMA4aG4V.js → selection-C5ZY23dQ.js} +16 -96
- package/dist/server-1pOxW1GJ.js +24 -0
- package/dist/{server-Xb3wp-mx.js → server-DZ7L28w4.js} +9 -7
- package/dist/{session-eZeXR9xU.js → session-CdnUL4zt.js} +444 -243
- package/dist/session-Cm0U68t3.js +6 -0
- package/dist/{session-DOZV1TP6.js → session-gTuw2_8i.js} +1 -1
- package/dist/setup-esb3_a7N.js +216 -0
- package/dist/skills/animate-onboarding/SKILL.md +1 -1
- package/dist/skills/mobile-design/SKILL.md +1 -1
- package/dist/skills/onboarding-questions/SKILL.md +1 -1
- package/dist/skills/superwall/SKILL.md +6 -7
- package/dist/skills/superwall/references/api.md +8 -3
- package/dist/skills/superwall/workflows/dashboard/playbook.md +4 -3
- package/dist/skills/superwall/workflows/dashboard/setup.md +7 -4
- package/dist/skills/superwall/workflows/migrate/adapty.md +4 -3
- package/dist/skills/superwall/workflows/migrate/playbook.md +2 -2
- package/dist/skills/superwall/workflows/migrate/qonversion.md +4 -3
- package/dist/skills/superwall/workflows/migrate/revenuecat.md +4 -3
- package/dist/skills/superwall-editor/SKILL.md +2 -3
- package/dist/skills/superwall-framework/SKILL.md +83 -13
- package/dist/skills/superwall-framework/references/cli.md +92 -21
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +5 -1
- package/dist/{skills-BI19OGlS.js → skills-B_oH2dYK.js} +8 -8
- package/dist/{skills-DDf10ufO.js → skills-miJDcjQ2.js} +4 -4
- package/dist/source-push-NVrs53Uo.js +205 -0
- package/dist/{spinner-BClMQGGN.js → spinner-D6phP4Af.js} +3 -3
- package/dist/{storage-Po9E-CHL.js → storage-BcvKhvzZ.js} +1 -1
- package/dist/storekit-D1A5VHT1.js +16 -0
- package/dist/{storekit-Cbn9DBLA.js → storekit-Di3BkafX.js} +3 -3
- package/dist/{telemetry-s6dag6tb.js → telemetry-BpYXL-z3.js} +1 -1
- package/dist/{token-CPplNMVa.js → token-4dQOfOaK.js} +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +216 -90
- package/dist/{upgrade-1OYm5NQU.js → upgrade-BnOq32zn.js} +2 -2
- package/dist/{upgrade-ahapZeex.js → upgrade-Cb6f4S_c.js} +1 -1
- package/package.json +2 -2
- package/dist/create-BYAPuhhf.js +0 -19
- package/dist/held-C9FqvNbn.js +0 -16
- package/dist/login-D-a7oS_8.js +0 -16
- package/dist/push-snV3SrnH.js +0 -22
- package/dist/scan-nUeXs9a1.js +0 -4
- package/dist/server-Boqa8jh_.js +0 -22
- package/dist/session-DtBpdlF-.js +0 -6
- package/dist/storekit-BU6Eq_UO.js +0 -16
- /package/dist/{reports-D_qbl7_u.js → reports-CwwKLUh0.js} +0 -0
- /package/dist/{storage-BbJF7z3l.d.ts → storage-gRyQetN9.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# CLI — dev, push, promote, publish
|
|
1
|
+
# CLI — dev, push, promote, publish, pull
|
|
2
2
|
|
|
3
3
|
Git semantics on purpose: **push saves, promote ships.** Every push mints
|
|
4
4
|
a sealed version; nothing users see changes until promote points
|
|
@@ -11,6 +11,8 @@ superwall push # build + version. Production untouched.
|
|
|
11
11
|
superwall promote # point production at the latest push
|
|
12
12
|
superwall publish # push + promote in one step
|
|
13
13
|
superwall publish -m "Q3 test" # record why
|
|
14
|
+
superwall pull # merge teammates' work from the app's source repo
|
|
15
|
+
superwall pull --app <id> # get an app's paywalls into an empty folder
|
|
14
16
|
```
|
|
15
17
|
|
|
16
18
|
The scaffolded package scripts mirror these (`dev`, `push`, `promote`,
|
|
@@ -97,8 +99,8 @@ Three consequences for you, not the user:
|
|
|
97
99
|
paywall, shared by every thread and teammate, one turn at a time; its
|
|
98
100
|
preview is a `superwall build` snapshot taken when a turn ends, not a live
|
|
99
101
|
server. So edits may have arrived that a local checkout has never seen —
|
|
100
|
-
`main` carries the source commit of the last published version
|
|
101
|
-
|
|
102
|
+
`main` carries the source commit of the last published version; run
|
|
103
|
+
`superwall pull` to bring them into the local project.
|
|
102
104
|
|
|
103
105
|
The mechanism behind both (the envelope, the `ping` reply, hosting a paywall
|
|
104
106
|
yourself) is `curl -sL superwall.com/docs/framework/host-protocol.md`.
|
|
@@ -152,15 +154,19 @@ A push refuses if a `config.ts` names a product the dashboard doesn't have.
|
|
|
152
154
|
"the dashboard needs products" is work you can do, not a dependency:
|
|
153
155
|
|
|
154
156
|
```sh
|
|
155
|
-
superwall entitlements
|
|
157
|
+
superwall entitlements create --identifier pro --app <id> --json # skip if it exists
|
|
156
158
|
superwall products create --identifier <identifier> \
|
|
157
159
|
--app <id|dashboard link> \
|
|
158
160
|
--name "Annual" --price 39.99 --period year \
|
|
159
|
-
--trial-days 7 --entitlement
|
|
161
|
+
--trial-days 7 --entitlement pro --json
|
|
160
162
|
```
|
|
161
163
|
|
|
162
|
-
- `--entitlement` takes the
|
|
163
|
-
|
|
164
|
+
- `--entitlement` takes the entitlement's identifier (`pro`) or id. Pass
|
|
165
|
+
the same `--app` to both commands: a product only grants entitlements on
|
|
166
|
+
its own app, and a mismatch is refused with the fix in the message.
|
|
167
|
+
- CLI 2.2.1 and older take only the numeric id from
|
|
168
|
+
`superwall entitlements list --json`; run `superwall upgrade` once a
|
|
169
|
+
newer CLI is out.
|
|
164
170
|
- Pass `--app <id|dashboard link>` (or `--project <id>`) when the account
|
|
165
171
|
has several projects, or it stops with "You can open N projects" and
|
|
166
172
|
lists them.
|
|
@@ -199,8 +205,8 @@ The hosted studio's chat runs this at the end of every turn for its preview.
|
|
|
199
205
|
Builds every paywall, versions the changed ones, and leaves production
|
|
200
206
|
alone. Re-running with nothing changed is a no-op. Flags: `--id <id>`
|
|
201
207
|
(limit, repeatable), `--platform <p>` (repeatable or comma-separated; limits the platforms),
|
|
202
|
-
`--rename <old>=<new>`, `-m <note>`, `--overwrite-source` (
|
|
203
|
-
takes it too).
|
|
208
|
+
`--rename <old>=<new>`, `-m <note>`, `--overwrite-source` (replaces only the
|
|
209
|
+
pushed paywalls' source — below; `publish` takes it too).
|
|
204
210
|
|
|
205
211
|
A push refuses — before anything is written — when:
|
|
206
212
|
|
|
@@ -273,6 +279,22 @@ export default definePaywall({ platforms: ["web"], checkout: "sheet", products:
|
|
|
273
279
|
per-platform slot must name every platform in `platforms` (push error:
|
|
274
280
|
`` `annual` has no product id for web ``). The dashboard product check
|
|
275
281
|
runs per platform, so create the Play product too.
|
|
282
|
+
- An App Store product can offer Apple's monthly plan (a 12-month
|
|
283
|
+
commitment billed monthly) next to the year paid up front. A slot picks
|
|
284
|
+
which one it sells with `billingPlan: "monthly" | "upFront"`, on a slot
|
|
285
|
+
object or a per-platform slot:
|
|
286
|
+
`annual: { productId: "pro_annual", billingPlan: "upFront" }` or
|
|
287
|
+
`annual: { ios: "pro_annual", android: "pro_annual_play", billingPlan:
|
|
288
|
+
"upFront" }`. Omitted, it is `"monthly"` for a product that offers the
|
|
289
|
+
monthly plan and has no effect on one that does not. To offer both plans
|
|
290
|
+
side by side, use two slots on the same product:
|
|
291
|
+
`annual: { productId: "pro_annual", billingPlan: "upFront" },
|
|
292
|
+
annualMonthly: { productId: "pro_annual", billingPlan: "monthly" }`.
|
|
293
|
+
iOS / App Store only: Android and web have no such plan and ignore it,
|
|
294
|
+
and Play, Stripe and custom slots never carry it. `superwall push` sends
|
|
295
|
+
the plan with each version, and changing only `billingPlan` pushes a new
|
|
296
|
+
version. An unknown value fails the build (`` paywalls/<id>: `annual`
|
|
297
|
+
billingPlan must be one of "monthly", "upFront", got "upfront". ``).
|
|
276
298
|
|
|
277
299
|
### Renames
|
|
278
300
|
|
|
@@ -314,16 +336,28 @@ Every push also saves the `superwall/` source to the app's source repo on
|
|
|
314
336
|
Superwall, so the dashboard can show and diff the code each version was
|
|
315
337
|
built from — and `-m "why"` records the reason there.
|
|
316
338
|
|
|
317
|
-
- **
|
|
318
|
-
the app. A push
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
339
|
+
- **A push writes only its own paywall.** The repo is shared by everyone
|
|
340
|
+
who pushes to the app. A push of paywall `a` writes `paywalls/a/`, the
|
|
341
|
+
shared files outside every paywall and funnel directory (`package.json`,
|
|
342
|
+
components, config), and `a`'s own entries in `superwall.lock`. Every
|
|
343
|
+
other paywall and funnel stays as the repo has it — even from a checkout
|
|
344
|
+
with no sync point, and even if the local copy of another paywall is
|
|
345
|
+
stale or missing. `superwall.lock` merges entry by entry; `superwall.d.ts`
|
|
346
|
+
takes this project's copy.
|
|
347
|
+
- **Teammates' work is kept.** With a sync point (the commit
|
|
348
|
+
`superwall.lock` records under `sources` — commit the lock), a push
|
|
349
|
+
merges this project's changes on top of whatever others published since.
|
|
350
|
+
It stops and names only the conflicting files rather than overwrite:
|
|
351
|
+
`Someone else published changes to …` (a teammate changed the same file),
|
|
352
|
+
or, with no sync point, `The source repo differs from this project in …`
|
|
353
|
+
(the push would change an existing file in this paywall or a shared
|
|
354
|
+
file). Files the repo doesn't have yet never block. Both say to run
|
|
355
|
+
`superwall pull` (below), then publish again.
|
|
356
|
+
- **`--overwrite-source` replaces only the pushed paywall's source** (its
|
|
357
|
+
directory, the shared files and its lock entries); teammates' other
|
|
358
|
+
paywalls stay. It still discards a teammate's edits to that paywall, so
|
|
359
|
+
it is the user's decision, never a fix you reach for on your own —
|
|
360
|
+
reach for `superwall pull` first.
|
|
327
361
|
- **No version ships without its source.** A version whose source didn't
|
|
328
362
|
land is recorded in `superwall.lock` (`sourcePending`); the next push
|
|
329
363
|
finishes its source before anything else, `promote` refuses it (`version
|
|
@@ -360,6 +394,40 @@ Promote never rebuilds — it only moves the live pointer.
|
|
|
360
394
|
Push + promote in one step. Also warns about other paywalls that are
|
|
361
395
|
pushed-but-not-live, so nothing ships half-forgotten.
|
|
362
396
|
|
|
397
|
+
## `superwall pull`
|
|
398
|
+
|
|
399
|
+
Merges the app's source repo into this project: teammates' paywalls and
|
|
400
|
+
shared files, their `superwall.lock` bindings, and the sync point the next
|
|
401
|
+
push merges from. Run it inside a project; it pulls the repo of every app
|
|
402
|
+
`superwall.lock` binds (`--platform <p>` limits it to those platforms).
|
|
403
|
+
|
|
404
|
+
- **Local edits stay.** Uncommitted changes in the project are merged with
|
|
405
|
+
the repo's, and only the files that changed are written.
|
|
406
|
+
- **A conflict changes nothing.** If both sides changed a file (with no
|
|
407
|
+
sync point: any file both have with different content), it stops:
|
|
408
|
+
`Your project and the source repo both changed …, so nothing was
|
|
409
|
+
pulled`. `superwall pull --theirs` takes the repo's whole copy of those
|
|
410
|
+
files — the local edits to them are lost, so copy them aside first if
|
|
411
|
+
the user wants to keep them. Never add `--theirs` on your own.
|
|
412
|
+
- **Bindings:** the repo's lock entries are taken only for platforms this
|
|
413
|
+
project binds to the same app (or doesn't bind yet); a platform bound to
|
|
414
|
+
a different app keeps its local bindings.
|
|
415
|
+
- **No source-less version ships.** A local version whose source never
|
|
416
|
+
landed stays `sourcePending`, so `promote` still refuses it until a push
|
|
417
|
+
finishes its source.
|
|
418
|
+
- **Safety:** a gitignored local file is never overwritten (it is listed
|
|
419
|
+
as left alone), and a symlink or `..` in a path refuses the whole pull.
|
|
420
|
+
|
|
421
|
+
With no project, `superwall pull --app <id|name|dashboard link> [dir]`
|
|
422
|
+
clones the app's source into an empty `<dir>/superwall/` (default: the
|
|
423
|
+
current directory), with its `superwall.lock` bindings, `superwall.d.ts`
|
|
424
|
+
and sync point — the way to work on an app's paywalls without its codebase
|
|
425
|
+
or GitHub. It installs nothing; it prints the next step, `cd superwall &&
|
|
426
|
+
<manager> install && <dev>`. It refuses a directory that is already a
|
|
427
|
+
superwall project (run `superwall pull` there instead) or one that already
|
|
428
|
+
has files, and an app with no code paywall or an empty source repo (start
|
|
429
|
+
one with `superwall create --app <id>`).
|
|
430
|
+
|
|
363
431
|
## The studio's Push / Publish / Promote buttons
|
|
364
432
|
|
|
365
433
|
Same operations from the `dev` UI — good for iteration. Prefer the CLI
|
|
@@ -405,7 +473,10 @@ than listing none.
|
|
|
405
473
|
| `paywall x has never been pushed` (promote) | Push first |
|
|
406
474
|
| `superwall publish requires git` | Install git — the source snapshot is part of every publish |
|
|
407
475
|
| `… version N has no source yet` (promote) | Run `superwall push` to finish that version's source, then promote |
|
|
408
|
-
| `Someone else published changes to …` |
|
|
409
|
-
| `The source repo differs from this project in …` |
|
|
476
|
+
| `Someone else published changes to …` | Run `superwall pull`, then publish again; `--overwrite-source` (this paywall only) only on the user's say-so |
|
|
477
|
+
| `The source repo differs from this project in …` | Run `superwall pull`, then publish again; `--overwrite-source` (this paywall only) only on the user's say-so |
|
|
478
|
+
| `Your project and the source repo both changed …, so nothing was pulled` | Ask the user which copy wins; to take the repo's, copy their edits aside if wanted, then `superwall pull --theirs` |
|
|
479
|
+
| `… already has files — pull --app only fills an empty folder` | Pick an empty directory, or run `superwall pull` inside the existing project without `--app` |
|
|
480
|
+
| `App … has no code paywall on Superwall yet` / `source repo is empty` (pull) | Nothing to pull — start one with `superwall create --app <id>` |
|
|
410
481
|
| `The source in … is N MB, over the 250 MB limit` | Gitignore what doesn't belong in the source, push again |
|
|
411
482
|
| Not signed in | `superwall login`, or `SUPERWALL_API_KEY` in CI |
|
|
@@ -92,7 +92,11 @@ signatures before writing them.
|
|
|
92
92
|
2. **Fix the products.** A `"missing"` identifier in `config.ts` blocks
|
|
93
93
|
push. The dashboard paywall's product slots name the real products
|
|
94
94
|
on a published paywall; on a template they don't exist, and the user
|
|
95
|
-
has to choose (or you create them, see [cli.md](cli.md)).
|
|
95
|
+
has to choose (or you create them, see [cli.md](cli.md)). A slot the
|
|
96
|
+
dashboard set to an Apple billing plan comes over as
|
|
97
|
+
`{ productId: "pro_annual", billingPlan: "upFront" }` (or `"monthly"`);
|
|
98
|
+
keep it, since dropping it sells the monthly plan wherever the product
|
|
99
|
+
offers one. Slots without a plan stay plain strings.
|
|
96
100
|
3. **Rebuild page by page, in the store's order.** Each navigation child
|
|
97
101
|
is a route; shared chrome (close, back, step indicator) that the editor
|
|
98
102
|
drew outside the navigation goes in `layout.tsx`. Use the framework's
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import "./token-
|
|
1
|
+
import "./token-4dQOfOaK.js";
|
|
2
2
|
import "./output-Ggzq5_-t.js";
|
|
3
|
-
import "./environment-
|
|
4
|
-
import "./storage-
|
|
5
|
-
import "./client-
|
|
3
|
+
import "./environment-a7W-0wg0.js";
|
|
4
|
+
import "./storage-BcvKhvzZ.js";
|
|
5
|
+
import "./client-CYtQvWJR.js";
|
|
6
6
|
import "./config-BO1Y87kV.js";
|
|
7
|
-
import "./telemetry-
|
|
7
|
+
import "./telemetry-BpYXL-z3.js";
|
|
8
8
|
import "./spawn-DmmmHIP-.js";
|
|
9
|
-
import "./spinner-
|
|
9
|
+
import "./spinner-D6phP4Af.js";
|
|
10
10
|
import "./ui-D_qf3Gvw.js";
|
|
11
|
-
import "./paths-
|
|
12
|
-
import { a as bundledSkills, c as knownSkills, d as readBundledSkill, f as runSkills, i as SUPERWALL_SKILLS_SOURCE, l as normalizeSkillFrontmatter, m as skillsRefFor, n as SKILLS_INSTALL_SOURCE, o as checkSkillsSync, p as skillSummary, r as SKILLS_REF, s as ensureSkillsCurrent, t as PLAYBOOKS, u as normalizeSkillsDir } from "./skills-
|
|
11
|
+
import "./paths-Cp_lgyWO.js";
|
|
12
|
+
import { a as bundledSkills, c as knownSkills, d as readBundledSkill, f as runSkills, i as SUPERWALL_SKILLS_SOURCE, l as normalizeSkillFrontmatter, m as skillsRefFor, n as SKILLS_INSTALL_SOURCE, o as checkSkillsSync, p as skillSummary, r as SKILLS_REF, s as ensureSkillsCurrent, t as PLAYBOOKS, u as normalizeSkillsDir } from "./skills-miJDcjQ2.js";
|
|
13
13
|
|
|
14
14
|
export { PLAYBOOKS, SKILLS_INSTALL_SOURCE, SKILLS_REF, SUPERWALL_SKILLS_SOURCE, bundledSkills, checkSkillsSync, ensureSkillsCurrent, knownSkills, normalizeSkillFrontmatter, normalizeSkillsDir, readBundledSkill, runSkills, skillSummary, skillsRefFor };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as CHANNEL, o as CHANNELS, v as VERSION } from "./environment-
|
|
1
|
+
import { a as CHANNEL, o as CHANNELS, v as VERSION } from "./environment-a7W-0wg0.js";
|
|
2
2
|
import { m as writeSkillsSync, s as readSkillsSync } from "./config-BO1Y87kV.js";
|
|
3
|
-
import { r as track } from "./telemetry-
|
|
3
|
+
import { r as track } from "./telemetry-BpYXL-z3.js";
|
|
4
4
|
import { r as spawnStream } from "./spawn-DmmmHIP-.js";
|
|
5
|
-
import { n as withSpinner } from "./spinner-
|
|
5
|
+
import { n as withSpinner } from "./spinner-D6phP4Af.js";
|
|
6
6
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
7
|
-
import { i as packagedDir, t as AGENT_SKILLS_DIR } from "./paths-
|
|
7
|
+
import { i as packagedDir, t as AGENT_SKILLS_DIR } from "./paths-Cp_lgyWO.js";
|
|
8
8
|
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { tmpdir } from "node:os";
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { n as ApiUnreachableError, t as ApiError } from "./client-CYtQvWJR.js";
|
|
2
|
+
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
3
|
+
import { d as linkSourceCommit, f as listAppPaywalls, o as createHeadlessPaywall, v as mintSourceAccess } from "./resources-DKn4itf3.js";
|
|
4
|
+
import { n as findApplication } from "./lookup-Dor6ch5A.js";
|
|
5
|
+
import { M as writeBinding, k as readLock } from "./selection-C5ZY23dQ.js";
|
|
6
|
+
import { a as pushSourceTree, c as writeSourceBase, r as gitAvailable, s as readSourceBase } from "./session-CdnUL4zt.js";
|
|
7
|
+
import { setTimeout } from "node:timers/promises";
|
|
8
|
+
import { productVariables } from "@superwall/studio/products";
|
|
9
|
+
|
|
10
|
+
//#region src/core/paywalls/binding/binding.ts
|
|
11
|
+
var BindingError = class extends Error {};
|
|
12
|
+
const describe = (surface) => `${surface.kind} \`${surface.id}\``;
|
|
13
|
+
const humanize = (surfaceId) => surfaceId.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
14
|
+
async function resolveBinding(input) {
|
|
15
|
+
const { api, superwallDir, surface, app } = input;
|
|
16
|
+
const { platform, applicationId } = app;
|
|
17
|
+
const create = input.create ?? true;
|
|
18
|
+
const lock = readLock(superwallDir);
|
|
19
|
+
const section = surface.kind === "paywall" ? lock.paywalls : lock.funnels;
|
|
20
|
+
const locked = section[surface.id]?.[platform];
|
|
21
|
+
if (locked) return {
|
|
22
|
+
paywallId: locked.paywallId,
|
|
23
|
+
applicationId,
|
|
24
|
+
platform,
|
|
25
|
+
source: "lock"
|
|
26
|
+
};
|
|
27
|
+
const matches = (paywalls) => {
|
|
28
|
+
const headless = paywalls.filter((paywall) => paywall.metadata.headless === "true");
|
|
29
|
+
return headless.find((paywall) => paywall.metadata.headlessSurface === surface.id) ?? headless.find((paywall) => paywall.identifier === surface.id);
|
|
30
|
+
};
|
|
31
|
+
const match = matches(await listAppPaywalls(api, applicationId));
|
|
32
|
+
if (match) {
|
|
33
|
+
await requireAdoption(input.confirmAdopt, {
|
|
34
|
+
surface,
|
|
35
|
+
paywallId: match.id,
|
|
36
|
+
applicationId,
|
|
37
|
+
platform
|
|
38
|
+
});
|
|
39
|
+
writeBinding(superwallDir, surface.kind, surface.id, platform, { paywallId: match.id });
|
|
40
|
+
return {
|
|
41
|
+
paywallId: match.id,
|
|
42
|
+
applicationId,
|
|
43
|
+
platform,
|
|
44
|
+
source: "matched"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (!create) throw new BindingError(`${describe(surface)} has never been pushed to \`${platform}\` — run \`superwall push\` first.`);
|
|
48
|
+
if (!input.renamesResolved) {
|
|
49
|
+
const onDisk = new Set(input.surfaces.filter((candidate) => candidate.kind === surface.kind).map((c) => c.id));
|
|
50
|
+
const orphans = Object.keys(section).filter((id) => !onDisk.has(id));
|
|
51
|
+
if (orphans.length > 0) throw new BindingError(`\`${surface.id}\` is unbound while superwall.lock still binds ${orphans.join(", ")}, which no longer exist on disk. Resolve the renames first — \`superwall push\` asks, or declare them with \`--rename <old>=<new>\`.`);
|
|
52
|
+
}
|
|
53
|
+
const archived = matches(await listAppPaywalls(api, applicationId, { archived: true }));
|
|
54
|
+
if (archived) throw new BindingError(`${describe(surface)} matches archived paywall ${archived.id} on \`${platform}\`. Restore it in the dashboard to push to it, or rename the directory.`);
|
|
55
|
+
const created = await createHeadlessPaywall(api, {
|
|
56
|
+
applicationId,
|
|
57
|
+
name: input.name?.trim() || humanize(surface.id),
|
|
58
|
+
identifier: surface.id
|
|
59
|
+
});
|
|
60
|
+
writeBinding(superwallDir, surface.kind, surface.id, platform, { paywallId: created.id });
|
|
61
|
+
return {
|
|
62
|
+
paywallId: created.id,
|
|
63
|
+
applicationId,
|
|
64
|
+
platform,
|
|
65
|
+
source: "created"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function requireAdoption(confirm, candidate) {
|
|
69
|
+
if (confirm && await confirm(candidate)) return;
|
|
70
|
+
const { surface, paywallId, applicationId, platform } = candidate;
|
|
71
|
+
const lockLine = `"${surface.id}": { "${platform}": { "paywallId": "${paywallId}" } }`;
|
|
72
|
+
throw new BindingError([
|
|
73
|
+
`App ${applicationId} already has a paywall \`${surface.id}\` (${paywallId}) that superwall.lock doesn't bind, so nothing was pushed.`,
|
|
74
|
+
` - It's yours: run \`superwall push\` interactively and confirm, or add ${lockLine} under "${surface.kind === "paywall" ? "paywalls" : "funnels"}" in superwall.lock.`,
|
|
75
|
+
` - It isn't: rename the directory, and the next push creates a new paywall.`
|
|
76
|
+
].join("\n"));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/core/paywalls/products.ts
|
|
81
|
+
function storeOf(row) {
|
|
82
|
+
if (row.platform === "stripe") return "stripe";
|
|
83
|
+
if (row.store === "custom" || row.platform === "custom") return "custom";
|
|
84
|
+
if (row.store === "app_store") return "app-store";
|
|
85
|
+
if (row.store === "play_store") return "play-store";
|
|
86
|
+
}
|
|
87
|
+
async function listProjectCatalogue(api, projectId) {
|
|
88
|
+
const rows = await api.list(`/v2/products?project_id=${encodeURIComponent(projectId)}`);
|
|
89
|
+
const variables = /* @__PURE__ */ new Map();
|
|
90
|
+
const stores = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const row of rows) {
|
|
92
|
+
if (!row.identifier) continue;
|
|
93
|
+
variables.set(row.identifier, productVariables(row));
|
|
94
|
+
const store = storeOf(row);
|
|
95
|
+
if (store === void 0) continue;
|
|
96
|
+
const known = stores.get(row.identifier) ?? [];
|
|
97
|
+
if (!known.includes(store)) stores.set(row.identifier, [...known, store]);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
variables: Object.fromEntries(variables),
|
|
101
|
+
stores: Object.fromEntries(stores)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async function listProjectProducts(api, projectId) {
|
|
105
|
+
return (await listProjectCatalogue(api, projectId)).variables;
|
|
106
|
+
}
|
|
107
|
+
async function listApplicationCatalogue(api, applicationId) {
|
|
108
|
+
const projectId = await projectForApplication(api, applicationId);
|
|
109
|
+
if (projectId === void 0) return {
|
|
110
|
+
variables: {},
|
|
111
|
+
stores: {}
|
|
112
|
+
};
|
|
113
|
+
return listProjectCatalogue(api, projectId);
|
|
114
|
+
}
|
|
115
|
+
async function projectForApplication(api, applicationId) {
|
|
116
|
+
const found = await findApplication(api, applicationId).catch(() => void 0);
|
|
117
|
+
return found ? String(found.project.id) : void 0;
|
|
118
|
+
}
|
|
119
|
+
var MissingProductError = class extends Error {};
|
|
120
|
+
function requireProducts(catalogue, surfaces) {
|
|
121
|
+
const gaps = surfaces.flatMap((surface) => Object.entries(surface.products ?? {}).filter(([, identifier]) => !Object.hasOwn(catalogue, identifier)).map(([reference, identifier]) => ` ${surface.id}: ${reference} → ${identifier}`));
|
|
122
|
+
if (gaps.length === 0) return;
|
|
123
|
+
throw new MissingProductError([
|
|
124
|
+
gaps.length === 1 ? "This product does not exist on Superwall:" : `These ${gaps.length} products do not exist on Superwall:`,
|
|
125
|
+
...gaps,
|
|
126
|
+
"",
|
|
127
|
+
"Every variable on them would be undefined on device. Add them in the",
|
|
128
|
+
"dashboard, or point the config at products that exist."
|
|
129
|
+
].join("\n"));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/core/paywalls/source/portability.ts
|
|
134
|
+
const SHOWN = 5;
|
|
135
|
+
function portabilityWarning(external) {
|
|
136
|
+
const names = [...new Set(external)].filter((entry) => entry.trim() !== "").sort();
|
|
137
|
+
if (names.length === 0) return void 0;
|
|
138
|
+
const shown = names.slice(0, SHOWN).join(", ");
|
|
139
|
+
const rest = names.length - SHOWN;
|
|
140
|
+
return `${names.length} ${names.length === 1 ? "import resolves" : "imports resolve"} outside superwall/ (${shown}${rest > 0 ? `, and ${rest} more` : ""}) — this project can be edited locally only; remote editing and rebuilds won't be available. For full feature access, move them into superwall/components/ or install from a package registry.`;
|
|
141
|
+
}
|
|
142
|
+
function warnNotPortable(external) {
|
|
143
|
+
const message = portabilityWarning(external);
|
|
144
|
+
if (message) ui.warn(message);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/core/paywalls/source/source-push.ts
|
|
149
|
+
var GitRequiredError = class extends Error {
|
|
150
|
+
constructor() {
|
|
151
|
+
super("superwall publish requires git for the source step — install git");
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
async function assertGit(hasGit = gitAvailable) {
|
|
155
|
+
if (!await hasGit()) throw new GitRequiredError();
|
|
156
|
+
}
|
|
157
|
+
async function pushSource(input) {
|
|
158
|
+
for (let attempt = 0;; attempt++) {
|
|
159
|
+
const access = await mintSourceAccess(input.api, input.paywallId);
|
|
160
|
+
const pushed = await pushSourceTree({
|
|
161
|
+
access,
|
|
162
|
+
base: readSourceBase(input.superwallDir, access.repo),
|
|
163
|
+
overwrite: input.overwrite,
|
|
164
|
+
files: input.files,
|
|
165
|
+
message: {
|
|
166
|
+
kind: input.kind,
|
|
167
|
+
surface: input.surface,
|
|
168
|
+
version: input.version,
|
|
169
|
+
paywallId: input.paywallId,
|
|
170
|
+
applicationId: input.applicationId,
|
|
171
|
+
snapshotSha: input.snapshotId,
|
|
172
|
+
framework: input.framework,
|
|
173
|
+
cli: input.cli,
|
|
174
|
+
note: input.note,
|
|
175
|
+
external: input.external
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
if (pushed.syncedTo) writeSourceBase(input.superwallDir, access.repo, pushed.syncedTo);
|
|
179
|
+
try {
|
|
180
|
+
await linkCommit(input, access, pushed.commitSha);
|
|
181
|
+
return pushed;
|
|
182
|
+
} catch (error) {
|
|
183
|
+
if (attempt === 0 && error instanceof ApiError && error.status === 409) continue;
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const LINK_ATTEMPTS = 2;
|
|
189
|
+
const LINK_RETRY_DELAY_MS = 300;
|
|
190
|
+
async function linkCommit(input, access, commitSha) {
|
|
191
|
+
for (let attempt = 1;; attempt++) try {
|
|
192
|
+
await linkSourceCommit(input.api, input.paywallId, input.version, {
|
|
193
|
+
commitSha,
|
|
194
|
+
tokenId: access.tokenId
|
|
195
|
+
});
|
|
196
|
+
return;
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (attempt >= LINK_ATTEMPTS || !isTransient(error)) throw error;
|
|
199
|
+
await setTimeout(LINK_RETRY_DELAY_MS);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const isTransient = (error) => error instanceof ApiUnreachableError || error instanceof ApiError && error.status >= 500;
|
|
203
|
+
|
|
204
|
+
//#endregion
|
|
205
|
+
export { listProjectCatalogue as a, requireProducts as c, listApplicationCatalogue as i, resolveBinding as l, pushSource as n, listProjectProducts as o, warnNotPortable as r, projectForApplication as s, assertGit as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as NotLoggedInError } from "./token-
|
|
1
|
+
import { r as NotLoggedInError } from "./token-4dQOfOaK.js";
|
|
2
2
|
import { i as writeJson, n as createCommandOutput } from "./output-Ggzq5_-t.js";
|
|
3
|
-
import { a as CHANNEL } from "./environment-
|
|
4
|
-
import { t as ApiError } from "./client-
|
|
3
|
+
import { a as CHANNEL } from "./environment-a7W-0wg0.js";
|
|
4
|
+
import { t as ApiError } from "./client-CYtQvWJR.js";
|
|
5
5
|
import { n as ui, r as useRenderer } from "./ui-D_qf3Gvw.js";
|
|
6
6
|
import pc from "picocolors";
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { l as readJson, r as formatJson, u as state } from "./output-Ggzq5_-t.js";
|
|
2
|
-
import { n as API_HOST_OVERRIDE, t as API_HOST } from "./environment-
|
|
2
|
+
import { n as API_HOST_OVERRIDE, t as API_HOST } from "./environment-a7W-0wg0.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/account/storage.ts
|
|
5
5
|
const sessionOrgName = (session) => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./token-4dQOfOaK.js";
|
|
2
|
+
import "./output-Ggzq5_-t.js";
|
|
3
|
+
import "./environment-a7W-0wg0.js";
|
|
4
|
+
import "./storage-BcvKhvzZ.js";
|
|
5
|
+
import "./client-CYtQvWJR.js";
|
|
6
|
+
import "./config-BO1Y87kV.js";
|
|
7
|
+
import "./spinner-D6phP4Af.js";
|
|
8
|
+
import "./ui-D_qf3Gvw.js";
|
|
9
|
+
import "./resources-DKn4itf3.js";
|
|
10
|
+
import "./org-BJCyaL1b.js";
|
|
11
|
+
import "./lookup-Dor6ch5A.js";
|
|
12
|
+
import "./scope-92neiQ2q.js";
|
|
13
|
+
import "./input-vi0bou04.js";
|
|
14
|
+
import { n as writeStoreKit, t as generateStoreKit } from "./storekit-Di3BkafX.js";
|
|
15
|
+
|
|
16
|
+
export { generateStoreKit, writeStoreKit };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as formatJson } from "./output-Ggzq5_-t.js";
|
|
2
|
-
import { t as apiCall } from "./spinner-
|
|
3
|
-
import {
|
|
4
|
-
import { a as pickScope } from "./scope-
|
|
2
|
+
import { t as apiCall } from "./spinner-D6phP4Af.js";
|
|
3
|
+
import { h as listResource } from "./resources-DKn4itf3.js";
|
|
4
|
+
import { a as pickScope } from "./scope-92neiQ2q.js";
|
|
5
5
|
import { r as textOf } from "./input-vi0bou04.js";
|
|
6
6
|
import { writeFileSync } from "node:fs";
|
|
7
7
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as isNonInteractive, g as TELEMETRY_KEY, h as TELEMETRY_HOST, v as VERSION } from "./environment-
|
|
1
|
+
import { S as isNonInteractive, g as TELEMETRY_KEY, h as TELEMETRY_HOST, v as VERSION } from "./environment-a7W-0wg0.js";
|
|
2
2
|
import { h as writeTelemetryNoticeShown, l as telemetryNoticeShown, t as readAnonymousId } from "./config-BO1Y87kV.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/support/telemetry.ts
|
package/dist/tools.d.ts
CHANGED