@superwall/cli 1.4.0 → 1.6.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 +21 -5
- package/dist/{actions-EfP8phmb.js → actions-Dt35nIi8.js} +3 -2
- package/dist/{api-CEwXCCoC.js → api-BOR-uXZe.js} +9 -9
- package/dist/{app-D8mEVlQo.js → app-BU27SLPX.js} +9 -9
- package/dist/{asa-BFWehnTA.js → asa-2ykGnjaV.js} +11 -11
- package/dist/{asc-DJqQmtmR.js → asc-r3xmFT0L.js} +14 -14
- package/dist/{auth-CT2DWX8r.js → auth-BWZfguI8.js} +9 -9
- package/dist/auth.js +2 -2
- package/dist/{billing-BzEnVPD2.js → billing-BsQgXXYh.js} +1 -1
- package/dist/{bind-BZxVyt9P.js → bind-BSTAinn6.js} +5 -4
- package/dist/{command-DP96_gmP.js → command-DMoMn7uc.js} +39 -16
- package/dist/{create-Q8TqqjZt.js → create-CSo6XjSm.js} +118 -91
- package/dist/dev-B0MF6z3L.js +21 -0
- package/dist/{dev-DlCcwFu5.js → dev-CuXa3J4Z.js} +29 -24
- package/dist/{doctor-CJsjHpCZ.js → doctor-DXJaDqsx.js} +10 -10
- package/dist/{drivers-UT36AnOw.js → drivers-Cr252DOJ.js} +3 -3
- package/dist/entry.js +84 -50
- package/dist/{existing-Cak1WxWB.js → existing-Ckx_g7Be.js} +6 -3
- package/dist/{feedback-DDRzoqPx.js → feedback-Dt5yebMS.js} +6 -6
- package/dist/{hosted-CEH78QVn.js → hosted-Cjekn8oJ.js} +2 -2
- package/dist/{integrate-D8jyhDzk.js → integrate-DVqhvPVq.js} +25 -66
- package/dist/{login-kneYhhk0.js → login-Bjj8QvIN.js} +6 -6
- package/dist/migrate-qmvOtp3l.js +283 -0
- package/dist/open-studio-CpHqjovS.js +1299 -0
- package/dist/{org-Cg25bcsj.js → org-CV8c849b.js} +3 -3
- package/dist/{output-csAtR6kJ.js → output-CiELrN8w.js} +15 -2
- package/dist/{pipeline-DAeI9tHs.js → pipeline-DSCHL9KA.js} +482 -9
- package/dist/{print-skill-BHVPP9cX.js → print-skill-CaHRJ8xW.js} +7 -7
- package/dist/{promote-Boek5K2d.js → promote-UMTh8Q33.js} +17 -18
- package/dist/publish-DWX8S9yZ.js +34 -0
- package/dist/push-Dox4_5Dq.js +34 -0
- package/dist/{query-B8G6T8Ba.js → query-CnSsDZ7Q.js} +10 -10
- package/dist/reports-C0xHCLnt.js +27 -0
- package/dist/{resource-DjsWVka-.js → resource-5bgyyL9B.js} +15 -15
- package/dist/{resources-s64mBHaC.js → resources-Bf9O1JNM.js} +28 -2
- package/dist/{run-BtcQJCP8.js → run-BVeZWbXx.js} +39 -22
- package/dist/{scan-DJixvuHn.js → scan-CAObNRgc.js} +44 -4
- package/dist/skills/superwall/SKILL.md +146 -0
- package/dist/skills/superwall/references/api.md +275 -0
- package/dist/skills/superwall/references/asa.md +160 -0
- package/dist/skills/superwall/references/asc.md +96 -0
- package/dist/skills/superwall/references/dashboard-links.md +57 -0
- package/dist/skills/superwall/references/data-analytics.md +893 -0
- package/dist/skills/superwall/references/docs.md +51 -0
- package/dist/skills/superwall/references/sdk-integration.md +105 -0
- package/dist/skills/superwall/references/sdk-source.md +18 -0
- package/{skills/superwall-dashboard/SKILL.md → dist/skills/superwall/workflows/dashboard/playbook.md} +3 -9
- package/{skills/superwall-dashboard/references → dist/skills/superwall/workflows/dashboard}/setup.md +1 -3
- package/dist/skills/superwall/workflows/integrate/android.md +292 -0
- package/{skills/superwall-integrate/SKILL.md → dist/skills/superwall/workflows/integrate/playbook.md} +16 -11
- package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/adapty.md +4 -4
- package/{skills/superwall-migrate/SKILL.md → dist/skills/superwall/workflows/migrate/playbook.md} +4 -10
- package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/qonversion.md +4 -4
- package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/revenuecat.md +4 -4
- package/dist/skills/superwall/workflows/placements/android.md +175 -0
- package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/expo.md +1 -1
- package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/flutter.md +1 -1
- package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/ios.md +1 -1
- package/{skills/superwall-placements/SKILL.md → dist/skills/superwall/workflows/placements/playbook.md} +6 -10
- package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/react-native.md +2 -2
- package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/strategy.md +4 -3
- package/dist/skills/superwall/workflows/review/android.md +120 -0
- package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/expo.md +1 -1
- package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/flutter.md +1 -1
- package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/ios.md +1 -1
- package/{skills/superwall-review/SKILL.md → dist/skills/superwall/workflows/review/playbook.md} +2 -7
- package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/react-native.md +1 -1
- package/dist/skills/superwall-framework/SKILL.md +253 -0
- package/dist/skills/superwall-framework/references/cli.md +340 -0
- package/dist/skills/superwall-framework/references/examples.md +123 -0
- package/dist/skills/superwall-framework/references/layout.md +295 -0
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +208 -0
- package/dist/skills/superwall-framework/references/migrate-from-native.md +193 -0
- package/dist/skills/superwall-framework/references/mobile-design.md +371 -0
- package/dist/skills/superwall-framework/references/native/android.md +83 -0
- package/dist/skills/superwall-framework/references/native/flutter.md +65 -0
- package/dist/skills/superwall-framework/references/native/ios.md +77 -0
- package/dist/skills/superwall-framework/references/native/react-native.md +67 -0
- package/dist/skills/superwall-framework/references/responsive.md +162 -0
- package/dist/{skills-CRG1xk0G.js → skills-Cu41i-Az.js} +12 -12
- package/dist/{skills-CODut1Hn.js → skills-grTDuHlc.js} +134 -36
- package/dist/{spinner-B9dT3DBY.js → spinner-DFctF_Jw.js} +1 -1
- package/dist/{telemetry-BtkMdT-5.js → telemetry-BuCbmoux.js} +3 -3
- package/dist/{token-hM7V1KMG.js → token-mju3Q-vc.js} +3 -3
- package/dist/{ui-Lqt_zFOr.js → ui-4gLyfrgl.js} +76 -46
- package/dist/{update-CeylIjx5.js → update-DnGfpCD7.js} +2 -2
- package/dist/{upgrade-DRqUfCBT.js → upgrade-PMoj3yqJ.js} +6 -6
- package/package.json +8 -7
- package/prompts/actions/paywall-migrate.xml +24 -0
- package/prompts/actions/screen-migrate.xml +26 -0
- package/dist/git-ZwA3Mx8m.js +0 -433
- package/dist/migrate-D_x1oyTk.js +0 -114
- package/dist/publish-C-zEUnO9.js +0 -35
- package/dist/push-DUDQG-EO.js +0 -35
- package/skills/README.md +0 -118
- /package/dist/{api-output-D9ggXQIr.js → api-output-CEhN-U_N.js} +0 -0
- /package/dist/{asc-products-C6MvSy8H.js → asc-products-1e1DoGeL.js} +0 -0
- /package/dist/{params-B1zeElGa.js → params-BxgTuCzr.js} +0 -0
- /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/expo.md +0 -0
- /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/flutter.md +0 -0
- /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/ios.md +0 -0
- /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/react-native.md +0 -0
- /package/dist/{storekit-DPonXSwe.js → storekit-Dlpbq5Wv.js} +0 -0
package/README.md
CHANGED
|
@@ -56,6 +56,9 @@ instead of running it — paste it into any agent.
|
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
superwall create # start a paywalls project — minimal, or any public example
|
|
59
|
+
superwall create --from {ID} # rebuild a dashboard paywall as code: its config.ts, a migration brief, Compare › Original in the studio
|
|
60
|
+
superwall migrate {ID} # …then rebuild its pages with your coding agent, or copy the prompt (--skill prints it)
|
|
61
|
+
superwall migrate --screen App/UpdateRequiredView.swift # rebuild a native screen (Swift, Kotlin, RN, Flutter) as a Superwall surface (no path: pick from candidates)
|
|
59
62
|
superwall dev # open the studio and preview everything live
|
|
60
63
|
superwall push # build and push immutable versions (production untouched)
|
|
61
64
|
superwall promote # point production at a pushed version
|
|
@@ -76,7 +79,9 @@ to begin from any example in the
|
|
|
76
79
|
then looks at the app around it: if the Superwall SDK is already configured,
|
|
77
80
|
it finds your app by its API key and binds pushes to it; otherwise it can log
|
|
78
81
|
you in, pick an app, or create one on the spot. `--yes` accepts the defaults;
|
|
79
|
-
`--no-install` and `--no-connect` skip those steps
|
|
82
|
+
`--no-install` and `--no-connect` skip those steps, and `--app <id>` connects a
|
|
83
|
+
specific Superwall app (the dashboard's **Copy Prompt** passes it) instead of
|
|
84
|
+
detecting or asking.
|
|
80
85
|
|
|
81
86
|
### A project is a directory
|
|
82
87
|
|
|
@@ -338,11 +343,22 @@ asking. The framework itself is built to be written by agents: a plain npm
|
|
|
338
343
|
project, file-based routes, ordinary React state — conventions an agent
|
|
339
344
|
already knows, so it gets a paywall right on the first try.
|
|
340
345
|
|
|
346
|
+
## Channels
|
|
347
|
+
|
|
348
|
+
Set `SUPERWALL_CHANNEL=next` to opt into experimental and beta features:
|
|
349
|
+
commands that are not in the stable set yet, and the matching agent skills
|
|
350
|
+
from the `next` branch of the skills repo. Everything else is unchanged.
|
|
351
|
+
Export it in your shell rc so every terminal and agent sees it. Unset it to
|
|
352
|
+
go back to the stable set.
|
|
353
|
+
|
|
341
354
|
## Telemetry
|
|
342
355
|
|
|
343
|
-
The CLI sends fully anonymous usage events
|
|
344
|
-
|
|
345
|
-
|
|
356
|
+
The CLI sends fully anonymous usage events for every command (which command
|
|
357
|
+
and subcommand ran, whether it succeeded, how long it took, and flags like
|
|
358
|
+
`--json` or `--dry-run` — never emails, IDs, file paths, SQL, prompts, API
|
|
359
|
+
paths, or error messages). Events carry a random per-machine id that is never
|
|
360
|
+
linked to your account. Opt out with `SUPERWALL_TELEMETRY_DISABLED=1` or
|
|
361
|
+
`DO_NOT_TRACK=1`.
|
|
346
362
|
|
|
347
363
|
## Package layout
|
|
348
364
|
|
|
@@ -360,7 +376,7 @@ packages/cli/
|
|
|
360
376
|
│ ├── core/ api client, auth, project detection, paywall
|
|
361
377
|
│ │ binding + lock, agent runners, telemetry, skills sync
|
|
362
378
|
│ └── ui/ the renderer: human output, --json envelopes, prompts
|
|
363
|
-
├── skills/
|
|
379
|
+
├── dist/skills/ the playbooks integrate/migrate/review run, bundled from superwall/skills at build
|
|
364
380
|
└── tests/ mirrors src/
|
|
365
381
|
```
|
|
366
382
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as loadBundledSkill } from "./skills-
|
|
1
|
+
import { m as Integration } from "./output-CiELrN8w.js";
|
|
2
|
+
import { i as loadBundledSkill } from "./skills-grTDuHlc.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/agent/actions.ts
|
|
5
5
|
/** Skill reference file per framework, so an agent only sees its own platform's docs. */
|
|
6
6
|
const FRAMEWORK_REF = {
|
|
7
7
|
[Integration.swift]: "ios",
|
|
8
|
+
[Integration.android]: "android",
|
|
8
9
|
[Integration.expo]: "expo",
|
|
9
10
|
[Integration.reactNative]: "react-native",
|
|
10
11
|
[Integration.flutter]: "flutter"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import "./output-
|
|
2
|
-
import "./telemetry-
|
|
3
|
-
import "./update-
|
|
4
|
-
import "./token-
|
|
5
|
-
import { t as defineCommand } from "./command-
|
|
6
|
-
import "./ui-
|
|
7
|
-
import {
|
|
8
|
-
import { t as parseParams } from "./params-
|
|
9
|
-
import { n as emitJson, t as apiCall } from "./api-output-
|
|
1
|
+
import "./output-CiELrN8w.js";
|
|
2
|
+
import "./telemetry-BuCbmoux.js";
|
|
3
|
+
import "./update-DnGfpCD7.js";
|
|
4
|
+
import "./token-mju3Q-vc.js";
|
|
5
|
+
import { t as defineCommand } from "./command-DMoMn7uc.js";
|
|
6
|
+
import "./ui-4gLyfrgl.js";
|
|
7
|
+
import { E as titleCase, T as rowName, b as platformLabel, g as listResource, h as listProjects, m as listOrganizations } from "./resources-Bf9O1JNM.js";
|
|
8
|
+
import { t as parseParams } from "./params-BxgTuCzr.js";
|
|
9
|
+
import { n as emitJson, t as apiCall } from "./api-output-CEhN-U_N.js";
|
|
10
10
|
import pc from "picocolors";
|
|
11
11
|
|
|
12
12
|
//#region src/commands/platform/api.ts
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { i as loadSession, r as clearSession } from "./token-
|
|
2
|
-
import {
|
|
3
|
-
import { n as ui } from "./ui-
|
|
4
|
-
import {
|
|
5
|
-
import { i as SUPPORTED_LABEL, t as scanProject } from "./scan-
|
|
6
|
-
import { r as getHostedStatus } from "./hosted-
|
|
7
|
-
import { t as withSpinner } from "./spinner-
|
|
8
|
-
import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-
|
|
9
|
-
import { t as ACTIONS } from "./actions-
|
|
1
|
+
import { i as loadSession, r as clearSession } from "./token-mju3Q-vc.js";
|
|
2
|
+
import { a as superwallApi } from "./command-DMoMn7uc.js";
|
|
3
|
+
import { n as ui } from "./ui-4gLyfrgl.js";
|
|
4
|
+
import { i as onboardingHooks, n as performLogin } from "./login-Bjj8QvIN.js";
|
|
5
|
+
import { i as SUPPORTED_LABEL, t as scanProject } from "./scan-CAObNRgc.js";
|
|
6
|
+
import { r as getHostedStatus } from "./hosted-Cjekn8oJ.js";
|
|
7
|
+
import { t as withSpinner } from "./spinner-DFctF_Jw.js";
|
|
8
|
+
import { n as resolveAppBinding, r as resolveScopeFromKey, t as platformForIntegration } from "./bind-BSTAinn6.js";
|
|
9
|
+
import { t as ACTIONS } from "./actions-Dt35nIi8.js";
|
|
10
10
|
|
|
11
11
|
//#region src/commands/workflow/integrate/app.ts
|
|
12
12
|
async function performLoginWithUi(app, onProvisioned) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import "./output-
|
|
2
|
-
import "./telemetry-
|
|
3
|
-
import "./update-
|
|
4
|
-
import "./token-
|
|
5
|
-
import {
|
|
6
|
-
import "./ui-
|
|
7
|
-
import "./spinner-
|
|
8
|
-
import {
|
|
9
|
-
import { t as requireOrg } from "./org-
|
|
10
|
-
import { t as parseParams } from "./params-
|
|
11
|
-
import { n as emitJson, t as apiCall } from "./api-output-
|
|
1
|
+
import "./output-CiELrN8w.js";
|
|
2
|
+
import "./telemetry-BuCbmoux.js";
|
|
3
|
+
import "./update-DnGfpCD7.js";
|
|
4
|
+
import "./token-mju3Q-vc.js";
|
|
5
|
+
import { r as ApiError, t as defineCommand } from "./command-DMoMn7uc.js";
|
|
6
|
+
import "./ui-4gLyfrgl.js";
|
|
7
|
+
import "./spinner-DFctF_Jw.js";
|
|
8
|
+
import { h as listProjects } from "./resources-Bf9O1JNM.js";
|
|
9
|
+
import { t as requireOrg } from "./org-CV8c849b.js";
|
|
10
|
+
import { t as parseParams } from "./params-BxgTuCzr.js";
|
|
11
|
+
import { n as emitJson, t as apiCall } from "./api-output-CEhN-U_N.js";
|
|
12
12
|
import { readFileSync } from "node:fs";
|
|
13
13
|
|
|
14
14
|
//#region src/core/api/asa.ts
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./telemetry-
|
|
3
|
-
import "./update-
|
|
4
|
-
import "./token-
|
|
5
|
-
import { t as defineCommand } from "./command-
|
|
6
|
-
import "./ui-
|
|
7
|
-
import "./spinner-
|
|
8
|
-
import {
|
|
9
|
-
import { t as requireOrg } from "./org-
|
|
10
|
-
import { t as parseParams } from "./params-
|
|
11
|
-
import { n as emitJson, t as apiCall } from "./api-output-
|
|
12
|
-
import { a as ascProxy, c as listAscConfigs, i as listAscApps, n as fetchUnimportedAscProducts, o as createAscConfig, r as findAscAppId, s as deleteAscConfig, t as ascTypeDisplay } from "./asc-products-
|
|
13
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
14
|
-
import { homedir } from "node:os";
|
|
1
|
+
import { g as SUPERWALL_HOME } from "./output-CiELrN8w.js";
|
|
2
|
+
import "./telemetry-BuCbmoux.js";
|
|
3
|
+
import "./update-DnGfpCD7.js";
|
|
4
|
+
import "./token-mju3Q-vc.js";
|
|
5
|
+
import { t as defineCommand } from "./command-DMoMn7uc.js";
|
|
6
|
+
import "./ui-4gLyfrgl.js";
|
|
7
|
+
import "./spinner-DFctF_Jw.js";
|
|
8
|
+
import { T as rowName } from "./resources-Bf9O1JNM.js";
|
|
9
|
+
import { t as requireOrg } from "./org-CV8c849b.js";
|
|
10
|
+
import { t as parseParams } from "./params-BxgTuCzr.js";
|
|
11
|
+
import { n as emitJson, t as apiCall } from "./api-output-CEhN-U_N.js";
|
|
12
|
+
import { a as ascProxy, c as listAscConfigs, i as listAscApps, n as fetchUnimportedAscProducts, o as createAscConfig, r as findAscAppId, s as deleteAscConfig, t as ascTypeDisplay } from "./asc-products-1e1DoGeL.js";
|
|
15
13
|
import { dirname, join } from "node:path";
|
|
14
|
+
import { homedir } from "node:os";
|
|
15
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { spawn } from "node:child_process";
|
|
17
17
|
import { inflateRawSync } from "node:zlib";
|
|
18
18
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as track } from "./telemetry-
|
|
3
|
-
import "./update-
|
|
4
|
-
import { i as loadSession, r as clearSession } from "./token-
|
|
5
|
-
import { t as defineCommand } from "./command-
|
|
6
|
-
import "./ui-
|
|
7
|
-
import { n as ensureSkillsCurrent } from "./skills-
|
|
1
|
+
import { o as API_HOST } from "./output-CiELrN8w.js";
|
|
2
|
+
import { i as track } from "./telemetry-BuCbmoux.js";
|
|
3
|
+
import "./update-DnGfpCD7.js";
|
|
4
|
+
import { i as loadSession, r as clearSession } from "./token-mju3Q-vc.js";
|
|
5
|
+
import { t as defineCommand } from "./command-DMoMn7uc.js";
|
|
6
|
+
import "./ui-4gLyfrgl.js";
|
|
7
|
+
import { n as ensureSkillsCurrent } from "./skills-grTDuHlc.js";
|
|
8
8
|
import "./spawn-DSoTXy_j.js";
|
|
9
|
-
import {
|
|
10
|
-
import { t as scanProject } from "./scan-
|
|
9
|
+
import { i as onboardingHooks, n as performLogin, t as loginWithApiKey } from "./login-Bjj8QvIN.js";
|
|
10
|
+
import { t as scanProject } from "./scan-CAObNRgc.js";
|
|
11
11
|
|
|
12
12
|
//#region src/commands/account/auth.ts
|
|
13
13
|
const runLogin = defineCommand({
|
package/dist/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./output-
|
|
2
|
-
import { n as resolveAuthToken, o as NotLoggedInError, t as getOAuthAccessToken } from "./token-
|
|
1
|
+
import "./output-CiELrN8w.js";
|
|
2
|
+
import { n as resolveAuthToken, o as NotLoggedInError, t as getOAuthAccessToken } from "./token-mju3Q-vc.js";
|
|
3
3
|
|
|
4
4
|
export { NotLoggedInError, getOAuthAccessToken, resolveAuthToken };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as ui } from "./ui-
|
|
3
|
-
import {
|
|
4
|
-
import { t as requireOrg } from "./org-
|
|
1
|
+
import { m as Integration } from "./output-CiELrN8w.js";
|
|
2
|
+
import { n as ui } from "./ui-4gLyfrgl.js";
|
|
3
|
+
import { b as platformLabel, h as listProjects, n as createApplication, s as createProject } from "./resources-Bf9O1JNM.js";
|
|
4
|
+
import { t as requireOrg } from "./org-CV8c849b.js";
|
|
5
5
|
|
|
6
6
|
//#region src/core/account/bind.ts
|
|
7
7
|
const NEW = "__new__";
|
|
@@ -11,6 +11,7 @@ const CANCEL = "esc cancel";
|
|
|
11
11
|
function platformForIntegration(integration) {
|
|
12
12
|
switch (integration) {
|
|
13
13
|
case Integration.swift: return "ios";
|
|
14
|
+
case Integration.android: return "android";
|
|
14
15
|
case Integration.flutter: return "flutter";
|
|
15
16
|
case Integration.expo:
|
|
16
17
|
case Integration.reactNative: return "react_native";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as track, n as maybeShowTelemetryNotice } from "./telemetry-
|
|
3
|
-
import { a as refreshUpdateCheck, i as maybeNotifyUpdate } from "./update-
|
|
4
|
-
import { a as saveSession, i as loadSession, n as resolveAuthToken, o as NotLoggedInError } from "./token-
|
|
5
|
-
import { r as useRenderer, t as selectRenderer } from "./ui-
|
|
1
|
+
import { i as writeJson, n as createCommandOutput, o as API_HOST, x as isNonInteractive } from "./output-CiELrN8w.js";
|
|
2
|
+
import { i as track, n as maybeShowTelemetryNotice } from "./telemetry-BuCbmoux.js";
|
|
3
|
+
import { a as refreshUpdateCheck, i as maybeNotifyUpdate } from "./update-DnGfpCD7.js";
|
|
4
|
+
import { a as saveSession, i as loadSession, n as resolveAuthToken, o as NotLoggedInError } from "./token-mju3Q-vc.js";
|
|
5
|
+
import { r as useRenderer, t as selectRenderer } from "./ui-4gLyfrgl.js";
|
|
6
6
|
import pc from "picocolors";
|
|
7
7
|
import { resolve } from "node:path";
|
|
8
8
|
|
|
@@ -186,15 +186,22 @@ async function executeCommand(definition, argv, runtime = {}) {
|
|
|
186
186
|
process.exitCode = 1;
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
|
-
const tracked = definition.telemetry === "workflow" && !argv.dryRun;
|
|
190
189
|
const startedAt = Date.now();
|
|
190
|
+
const base = commandTelemetry(definition, argv, {
|
|
191
|
+
json,
|
|
192
|
+
interactive
|
|
193
|
+
});
|
|
191
194
|
ui.start();
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
const offInterrupt = ui.onInterrupt?.(() => {
|
|
196
|
+
ui.stop();
|
|
197
|
+
process.stderr.write("\n✗ Cancelled.\n");
|
|
198
|
+
process.exit(130);
|
|
199
|
+
});
|
|
200
|
+
if (outputMode === "rich") maybeShowTelemetryNotice(ui);
|
|
201
|
+
track("command started", base);
|
|
196
202
|
try {
|
|
197
203
|
const api = resolveApi(definition.auth ?? "none", runtime.api ?? superwallApi);
|
|
204
|
+
if (definition.auth && definition.auth !== "none") base.logged_in = api !== void 0;
|
|
198
205
|
const context = {
|
|
199
206
|
argv,
|
|
200
207
|
ui,
|
|
@@ -207,27 +214,43 @@ async function executeCommand(definition, argv, runtime = {}) {
|
|
|
207
214
|
...api ? { api } : {}
|
|
208
215
|
};
|
|
209
216
|
await definition.run(context);
|
|
210
|
-
|
|
211
|
-
|
|
217
|
+
track("command finished", {
|
|
218
|
+
...base,
|
|
212
219
|
status: "success",
|
|
213
220
|
duration_ms: Date.now() - startedAt
|
|
214
221
|
});
|
|
215
222
|
} catch (error) {
|
|
216
223
|
reportError(ui, outputMode, stdout, error);
|
|
217
224
|
process.exitCode = 1;
|
|
218
|
-
|
|
219
|
-
|
|
225
|
+
const { code, status } = normalizeError(error);
|
|
226
|
+
track("command finished", {
|
|
227
|
+
...base,
|
|
220
228
|
status: "error",
|
|
221
|
-
error_code:
|
|
229
|
+
error_code: code,
|
|
230
|
+
...status === void 0 ? {} : { http_status: status },
|
|
222
231
|
duration_ms: Date.now() - startedAt
|
|
223
232
|
});
|
|
224
233
|
} finally {
|
|
234
|
+
offInterrupt?.();
|
|
225
235
|
if (outputMode !== "json") refreshUpdateCheck();
|
|
226
236
|
if (outputMode === "rich" && runtime.waitForPaint !== false) await new Promise((done) => setTimeout(done, 50));
|
|
227
237
|
ui.stop();
|
|
228
238
|
if (outputMode !== "json" && definition.name !== "upgrade") maybeNotifyUpdate(stdout);
|
|
229
239
|
}
|
|
230
240
|
}
|
|
241
|
+
const BARE_WORD = /^[a-z][a-z-]{0,31}$/;
|
|
242
|
+
function commandTelemetry(definition, argv, flags) {
|
|
243
|
+
const subcommand = [argv.target, argv.action].map((value) => typeof value === "string" ? value : void 0).filter((value) => value !== void 0 && BARE_WORD.test(value));
|
|
244
|
+
return {
|
|
245
|
+
command: definition.name,
|
|
246
|
+
...subcommand.length === 0 ? {} : { subcommand: subcommand.join(" ") },
|
|
247
|
+
auth: definition.auth ?? "none",
|
|
248
|
+
json: flags.json,
|
|
249
|
+
prompts: flags.interactive,
|
|
250
|
+
dry_run: Boolean(argv.dryRun),
|
|
251
|
+
skill: argv.skill === true
|
|
252
|
+
};
|
|
253
|
+
}
|
|
231
254
|
function resolveApi(policy, factory) {
|
|
232
255
|
if (policy === "required") return factory();
|
|
233
256
|
if (policy === "optional") try {
|
|
@@ -275,4 +298,4 @@ function normalizeError(error) {
|
|
|
275
298
|
}
|
|
276
299
|
|
|
277
300
|
//#endregion
|
|
278
|
-
export { superwallApi as i,
|
|
301
|
+
export { superwallApi as a, createSuperwallApi as i, executeCommand as n, ApiError as r, defineCommand as t };
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import "./output-
|
|
2
|
-
import "./telemetry-
|
|
3
|
-
import "./update-
|
|
4
|
-
import "./token-
|
|
5
|
-
import { t as defineCommand } from "./command-
|
|
6
|
-
import "./ui-
|
|
7
|
-
import "./skills-
|
|
1
|
+
import "./output-CiELrN8w.js";
|
|
2
|
+
import "./telemetry-BuCbmoux.js";
|
|
3
|
+
import "./update-DnGfpCD7.js";
|
|
4
|
+
import "./token-mju3Q-vc.js";
|
|
5
|
+
import { t as defineCommand } from "./command-DMoMn7uc.js";
|
|
6
|
+
import "./ui-4gLyfrgl.js";
|
|
7
|
+
import "./skills-grTDuHlc.js";
|
|
8
8
|
import "./spawn-DSoTXy_j.js";
|
|
9
|
-
import "./login-
|
|
10
|
-
import { n as allDeps, r as readPackageJson, t as scanProject } from "./scan-
|
|
11
|
-
import "./
|
|
12
|
-
import
|
|
13
|
-
import "./
|
|
14
|
-
import
|
|
15
|
-
import "./
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import "./
|
|
19
|
-
import "./
|
|
9
|
+
import "./login-Bjj8QvIN.js";
|
|
10
|
+
import { n as allDeps, r as readPackageJson, t as scanProject } from "./scan-CAObNRgc.js";
|
|
11
|
+
import "./drivers-Cr252DOJ.js";
|
|
12
|
+
import "./hosted-Cjekn8oJ.js";
|
|
13
|
+
import { t as detectExisting } from "./existing-Ckx_g7Be.js";
|
|
14
|
+
import "./spinner-DFctF_Jw.js";
|
|
15
|
+
import { b as platformLabel, h as listProjects, n as createApplication, p as listApplications } from "./resources-Bf9O1JNM.js";
|
|
16
|
+
import "./org-CV8c849b.js";
|
|
17
|
+
import { r as resolveScopeFromKey } from "./bind-BSTAinn6.js";
|
|
18
|
+
import { A as requireApi, L as writeApp, N as requirePlatform, f as gitAvailable, j as projectPackageName, k as LoginRequiredError } from "./pipeline-DSCHL9KA.js";
|
|
19
|
+
import "./actions-Dt35nIi8.js";
|
|
20
|
+
import "./app-BU27SLPX.js";
|
|
21
|
+
import "./run-BVeZWbXx.js";
|
|
22
|
+
import { b as writeTemplate, c as migrationFor, d as projectDirOf, f as scaffoldFromPaywall, i as startStudio, n as migrationNextSteps, s as isSuperwallProject, t as askStudio, u as offerMigration, v as starterConfig, x as slugOf, y as writeSurfaceFiles } from "./open-studio-CpHqjovS.js";
|
|
23
|
+
import "./dev-CuXa3J4Z.js";
|
|
20
24
|
import pc from "picocolors";
|
|
25
|
+
import * as path from "node:path";
|
|
26
|
+
import * as os$1 from "node:os";
|
|
21
27
|
import { promisify } from "node:util";
|
|
22
28
|
import * as fs from "node:fs";
|
|
23
|
-
import * as os$1 from "node:os";
|
|
24
|
-
import * as path from "node:path";
|
|
25
29
|
import { execFile } from "node:child_process";
|
|
26
30
|
|
|
27
31
|
//#region src/core/paywalls/project/examples.ts
|
|
@@ -67,65 +71,6 @@ function adoptExamplePackage(target, name) {
|
|
|
67
71
|
fs.writeFileSync(file, `${JSON.stringify(parsed, null, 2)}\n`);
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/core/paywalls/project/template.ts
|
|
72
|
-
const packageJson = (name) => `${JSON.stringify({
|
|
73
|
-
name,
|
|
74
|
-
private: true,
|
|
75
|
-
type: "module",
|
|
76
|
-
scripts: {
|
|
77
|
-
dev: "superwall dev",
|
|
78
|
-
push: "superwall push",
|
|
79
|
-
promote: "superwall promote",
|
|
80
|
-
ship: "superwall publish",
|
|
81
|
-
typecheck: "tsc -p tsconfig.json"
|
|
82
|
-
},
|
|
83
|
-
dependencies: {
|
|
84
|
-
react: "19.1.0",
|
|
85
|
-
"react-dom": "19.1.0",
|
|
86
|
-
superwall: "latest"
|
|
87
|
-
},
|
|
88
|
-
devDependencies: {
|
|
89
|
-
"@types/react": "^19.1.0",
|
|
90
|
-
"@types/react-dom": "^19.1.0",
|
|
91
|
-
typescript: "5.8.3"
|
|
92
|
-
}
|
|
93
|
-
}, null, 2)}\n`;
|
|
94
|
-
const README = `# Your paywalls
|
|
95
|
-
|
|
96
|
-
Each directory under \`paywalls/\` is one paywall — React pages in \`app/\`,
|
|
97
|
-
products and name in \`config.ts\`.
|
|
98
|
-
|
|
99
|
-
\`\`\`bash
|
|
100
|
-
bun dev # open the studio and preview live
|
|
101
|
-
bun run push # push versions to Superwall (production untouched)
|
|
102
|
-
bun run ship # push and promote to production
|
|
103
|
-
\`\`\`
|
|
104
|
-
`;
|
|
105
|
-
const TSCONFIG = "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"moduleResolution\": \"bundler\",\n \"jsx\": \"react-jsx\",\n \"strict\": true,\n \"isolatedModules\": true,\n \"resolveJsonModule\": true,\n \"skipLibCheck\": true,\n \"noUnusedLocals\": true,\n \"noUnusedParameters\": true,\n \"noFallthroughCasesInSwitch\": true,\n \"noEmit\": true,\n \"paths\": {\n \"@/*\": [\"./*\"]\n }\n },\n \"include\": [\".\"]\n}\n";
|
|
106
|
-
const SUPERWALL_DTS = "// Generated by the Superwall CLI. Commit it; don't edit it, and don't delete it.\n// It is what makes `import hero from \"./assets/hero.jpg\"` typecheck and what\n// makes router.push(\"...\") autocomplete and reject typos. `superwall dev`\n// rewrites it whenever your app/ directories change.\n\n/// <reference types=\"superwall/assets\" />\n\ndeclare module \"superwall/navigation\" {\n interface SuperwallRoutes {\n index: true;\n }\n}\n\nexport type SuperwallRouteName = keyof import(\"superwall/navigation\").SuperwallRoutes;\n";
|
|
107
|
-
const GITIGNORE = "node_modules/\n.superwall\n.env\n";
|
|
108
|
-
const CONFIG = "import { definePaywall } from \"superwall/config\";\n\nexport default definePaywall({\n /** What this paywall is called on Superwall. Defaults to the directory name. */\n name: \"Pro\",\n\n /**\n * The products this paywall sells, as `reference: \"store identifier\"`.\n *\n * The identifiers below are placeholders — replace them with products that\n * exist in your Superwall dashboard. Nothing about a product is stored here:\n * price, period and trial all come from the store at runtime, which is why\n * `useProducts()` returns nothing until these match. Run `superwall dev`\n * against a connected app and the real prices appear, locally and on device.\n *\n * A reference the dashboard has no product for blocks publishing, so a\n * paywall can never ship with prices it cannot render.\n */\n products: {\n monthly: \"pro_999_month\",\n },\n});\n";
|
|
109
|
-
const INDEX = "import { useActions, useHaptics, useProducts, usePurchase } from \"superwall/hooks\";\n\nexport default function Index() {\n const { close, restore } = useActions();\n const { getProduct } = useProducts();\n const { purchase } = usePurchase();\n const haptics = useHaptics();\n\n const monthly = getProduct(\"monthly\");\n\n return (\n <main className=\"page\">\n <button type=\"button\" className=\"close\" aria-label=\"Close\" onClick={close}>\n ✕\n </button>\n\n <div className=\"lede\">\n <h1>Go Pro</h1>\n <p>Everything unlocked, cancel whenever you like.</p>\n </div>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n className=\"button button--primary\"\n onClick={() => {\n haptics.light();\n purchase(\"monthly\");\n }}\n >\n {monthly?.variables.price ? `Subscribe · ${monthly.variables.price}` : \"Subscribe\"}\n </button>\n <button\n type=\"button\"\n className=\"link\"\n onClick={() => {\n haptics.light();\n restore();\n }}\n >\n Restore purchases\n </button>\n </div>\n </main>\n );\n}\n";
|
|
110
|
-
const LAYOUT = "import type { PropsWithChildren } from \"react\";\nimport { useActions, useHaptics } from \"superwall/hooks\";\nimport \"./theme.css\";\n\nexport default function Layout({ children }: PropsWithChildren) {\n const { openUrl } = useActions();\n const haptics = useHaptics();\n\n return (\n <div className=\"shell\">\n {children}\n <footer className=\"built\">\n Built with\n <button\n type=\"button\"\n className=\"wordmark\"\n aria-label=\"Superwall\"\n onClick={() => {\n haptics.light();\n openUrl(\"https://superwall.com\");\n }}\n >\n <span className=\"wordmark-accent\">$UPER</span>WALL\n </button>\n </footer>\n </div>\n );\n}\n";
|
|
111
|
-
const THEME = "@import url(\"https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&family=Roboto+Mono:wght@400..500&display=swap\");\n\n:root {\n --bg: #fdfef6;\n --surface: #f6f7ef;\n --elevated: #fff;\n --fg: #0c0b0a;\n --accent: #46d7d4;\n\n --fg-body: color-mix(in srgb, var(--fg) 70%, transparent);\n --fg-muted: color-mix(in srgb, var(--fg) 55%, transparent);\n --fg-caption: color-mix(in srgb, var(--fg) 50%, transparent);\n --border: color-mix(in srgb, var(--fg) 12%, transparent);\n --wash: color-mix(in srgb, var(--fg) 5%, transparent);\n\n --sans: Manrope, ui-sans-serif, system-ui, sans-serif;\n --mono: \"Roboto Mono\", ui-monospace, monospace;\n\n --sw-background: var(--bg);\n --sw-routes-height: auto;\n color-scheme: light;\n}\n\n:root.dark {\n --bg: #1c1b19;\n --surface: #232220;\n --elevated: #2a2926;\n --fg: #fdfef6;\n color-scheme: dark;\n}\n\n* {\n box-sizing: border-box;\n}\n\nbody {\n margin: 0;\n background: var(--bg);\n color: var(--fg);\n font-family: var(--sans);\n font-size: 0.9375rem;\n font-weight: 400;\n line-height: 1.5;\n letter-spacing: -0.01em;\n -webkit-font-smoothing: antialiased;\n}\n\nh1,\nh2,\nh3 {\n margin: 0;\n font-weight: 500;\n}\n\nh1 {\n font-size: clamp(2rem, 7vw, 2.5rem);\n line-height: 1.1;\n letter-spacing: -0.03em;\n}\n\nh2 {\n font-size: 1.5rem;\n line-height: 1.25;\n letter-spacing: -0.02em;\n}\n\nh3 {\n font-size: 1.25rem;\n line-height: 1.3;\n letter-spacing: -0.015em;\n}\n\np {\n margin: 0;\n color: var(--fg-body);\n}\n\ncode {\n font-family: var(--mono);\n font-size: 0.8125rem;\n}\n\n.shell {\n display: flex;\n min-height: 100vh;\n min-height: 100dvh;\n flex-direction: column;\n}\n\n.page {\n display: flex;\n min-height: 100%;\n flex-direction: column;\n gap: 24px;\n width: 100%;\n max-width: 44rem;\n margin: 0 auto;\n padding: 28px 20px 24px;\n}\n\n.lede {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.actions {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: auto;\n padding-top: 20px;\n}\n\n.button {\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n min-height: 44px;\n border: 1px solid var(--border);\n background: transparent;\n padding: 0 16px;\n color: var(--fg);\n font: inherit;\n font-size: 0.9375rem;\n font-weight: 500;\n cursor: pointer;\n transition:\n background-color 150ms ease,\n border-color 150ms ease;\n}\n\n.button:hover {\n background: var(--wash);\n}\n\n.button:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n}\n\n.button:disabled {\n cursor: default;\n opacity: 0.5;\n}\n\n.button--primary {\n border-color: var(--fg);\n background: var(--fg);\n color: var(--bg);\n}\n\n.button--primary:hover:not(:disabled) {\n background: color-mix(in srgb, var(--fg) 85%, transparent);\n}\n\n.link {\n align-self: center;\n border: 0;\n background: none;\n padding: 8px;\n color: var(--fg-muted);\n font: inherit;\n font-size: 0.8125rem;\n cursor: pointer;\n}\n\n.link:hover {\n color: var(--fg);\n}\n\n.link:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n}\n\n.close {\n align-self: flex-end;\n display: flex;\n width: 32px;\n height: 32px;\n align-items: center;\n justify-content: center;\n border: 0;\n background: none;\n padding: 0;\n color: var(--fg-muted);\n font: inherit;\n font-size: 1.25rem;\n line-height: 1;\n cursor: pointer;\n}\n\n.close:hover {\n color: var(--fg);\n}\n\n.close:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n}\n\n.built {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n gap: 6px;\n border-top: 1px solid var(--border);\n padding: 14px 20px;\n font-size: 0.75rem;\n color: var(--fg-caption);\n}\n\n.wordmark {\n border: 0;\n background: transparent;\n padding: 0;\n color: var(--fg);\n font: inherit;\n font-weight: 600;\n letter-spacing: 0.01em;\n cursor: pointer;\n}\n\n.wordmark:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: 2px;\n}\n\n.wordmark-accent {\n color: var(--accent);\n}\n\n@media (prefers-reduced-motion: reduce) {\n * {\n transition-duration: 1ms !important;\n }\n}\n";
|
|
112
|
-
function writeTemplate(target, name) {
|
|
113
|
-
const file = (relative$1, content) => {
|
|
114
|
-
const destination = path.join(target, relative$1);
|
|
115
|
-
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
116
|
-
fs.writeFileSync(destination, content);
|
|
117
|
-
};
|
|
118
|
-
file("package.json", packageJson(name ?? projectPackageName(target)));
|
|
119
|
-
file("tsconfig.json", TSCONFIG);
|
|
120
|
-
file("superwall.d.ts", SUPERWALL_DTS);
|
|
121
|
-
file(".gitignore", GITIGNORE);
|
|
122
|
-
file("README.md", README);
|
|
123
|
-
file("paywalls/pro/config.ts", CONFIG);
|
|
124
|
-
file("paywalls/pro/app/index.tsx", INDEX);
|
|
125
|
-
file("paywalls/pro/app/layout.tsx", LAYOUT);
|
|
126
|
-
file("paywalls/pro/app/theme.css", THEME);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
74
|
//#endregion
|
|
130
75
|
//#region src/commands/paywalls/create.ts
|
|
131
76
|
const run = promisify(execFile);
|
|
@@ -138,7 +83,8 @@ const APP_PLATFORMS = [
|
|
|
138
83
|
];
|
|
139
84
|
function alreadyAProject(root) {
|
|
140
85
|
const target = path.join(root, "superwall");
|
|
141
|
-
if (
|
|
86
|
+
if (isSuperwallProject(target)) return `\`${target}\` is already a superwall project — run \`superwall dev\` to open it.`;
|
|
87
|
+
if (fs.existsSync(path.join(target, "package.json"))) return `\`${target}\` already has a package.json that isn't a superwall project — move it aside first.`;
|
|
142
88
|
for (const marker of ["superwall.config.ts", "superwall.lock"]) if (fs.existsSync(path.join(root, marker))) return `\`${root}\` is already a superwall project — run \`superwall dev\` to open it.`;
|
|
143
89
|
const parsed = readPackageJson(root);
|
|
144
90
|
if (parsed && "superwall" in allDeps(parsed)) return `\`${root}\` is already a superwall project — run \`superwall dev\` to open it.`;
|
|
@@ -271,8 +217,15 @@ async function createAppFlow(ui, api, root) {
|
|
|
271
217
|
platform
|
|
272
218
|
};
|
|
273
219
|
}
|
|
274
|
-
async function connectApp(ui, interactive, root, target, detected) {
|
|
220
|
+
async function connectApp(ui, interactive, root, target, detected, appId) {
|
|
275
221
|
const api = await requireApi(interactive);
|
|
222
|
+
if (appId !== void 0) {
|
|
223
|
+
const app$1 = (await listApplications(api)).find((candidate) => String(candidate.id) === appId);
|
|
224
|
+
if (app$1 === void 0) throw new Error(`No app with id \`${appId}\` in this account — run \`superwall apps\` to list them.`);
|
|
225
|
+
writeApp(target, requirePlatform(app$1), String(app$1.id));
|
|
226
|
+
ui.success(`Pushes go to \`${app$1.name ?? app$1.id}\` — saved in superwall.lock, so commit that file.`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
276
229
|
if (detected?.existing.apiKey) {
|
|
277
230
|
const scope = await resolveScopeFromKey(api, detected.existing.apiKey).catch(() => null);
|
|
278
231
|
if (scope) {
|
|
@@ -314,6 +267,50 @@ async function connectApp(ui, interactive, root, target, detected) {
|
|
|
314
267
|
writeApp(target, requirePlatform(app), String(app.id));
|
|
315
268
|
ui.success(`Pushes go to \`${app.name ?? app.id}\` — saved in superwall.lock, so commit that file.`);
|
|
316
269
|
}
|
|
270
|
+
const uniqueSurfaceId = (superwallDir, slug) => {
|
|
271
|
+
let candidate = slug;
|
|
272
|
+
for (let n = 2; fs.existsSync(path.join(superwallDir, "paywalls", candidate)); n += 1) candidate = `${slug}-${n}`;
|
|
273
|
+
return candidate;
|
|
274
|
+
};
|
|
275
|
+
async function addSurface(context, superwallDir) {
|
|
276
|
+
const { argv, interactive, ui } = context;
|
|
277
|
+
const where = path.relative(process.cwd(), superwallDir) || ".";
|
|
278
|
+
if (typeof argv.example === "string") throw new Error(`\`${where}\` is already a superwall project — an example is a whole project, so start it in an empty directory.`);
|
|
279
|
+
if (argv.app !== void 0) throw new Error(`\`${where}\` is already connected — its apps live in superwall.lock; drop \`--app\`.`);
|
|
280
|
+
const from = typeof argv.from === "string" || typeof argv.from === "number" ? String(argv.from) : void 0;
|
|
281
|
+
if (from !== void 0) {
|
|
282
|
+
const migration = migrationFor(superwallDir, (await scaffoldFromPaywall(ui, await requireApi(interactive), {
|
|
283
|
+
root: process.cwd(),
|
|
284
|
+
target: superwallDir,
|
|
285
|
+
paywallId: from,
|
|
286
|
+
newProject: false
|
|
287
|
+
})).id);
|
|
288
|
+
const rebuilt = migration !== void 0 && interactive && argv.yes !== true ? await offerMigration(ui, interactive, migration) : "later";
|
|
289
|
+
const opening = rebuilt === "agent" && migration !== void 0 && await askStudio(ui, interactive, migration.surfaceId);
|
|
290
|
+
ui.step("Next steps");
|
|
291
|
+
ui.list({ items: migrationNextSteps(opening, where, from, rebuilt).map((label) => ({ label })) });
|
|
292
|
+
if (opening && migration !== void 0) await startStudio(superwallDir, migration.surfaceId);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const asked = interactive && argv.yes !== true ? await ui.text({
|
|
296
|
+
message: "What is the paywall called?",
|
|
297
|
+
initialValue: "Pro",
|
|
298
|
+
validate: (value) => value.trim() === "" ? "Give the paywall a name." : void 0
|
|
299
|
+
}) : "Pro";
|
|
300
|
+
if (asked === null) return;
|
|
301
|
+
const name = asked.trim();
|
|
302
|
+
const id = uniqueSurfaceId(superwallDir, slugOf(name));
|
|
303
|
+
writeSurfaceFiles(superwallDir, id, starterConfig(name));
|
|
304
|
+
ui.step(`Created ${where}/paywalls/${id} from the minimal template`);
|
|
305
|
+
ui.step("Next steps");
|
|
306
|
+
ui.list({ items: [{
|
|
307
|
+
label: `paywalls/${id}/config.ts`,
|
|
308
|
+
children: [{ label: "Point the product slot at a product that exists on your dashboard" }]
|
|
309
|
+
}, {
|
|
310
|
+
label: "superwall dev",
|
|
311
|
+
children: [{ label: "Open the studio and build the pages" }]
|
|
312
|
+
}] });
|
|
313
|
+
}
|
|
317
314
|
const runCreate = defineCommand({
|
|
318
315
|
name: "create",
|
|
319
316
|
output: "human",
|
|
@@ -321,12 +318,36 @@ const runCreate = defineCommand({
|
|
|
321
318
|
const { argv, interactive, ui } = context;
|
|
322
319
|
ui.intro(`Superwall ${pc.dim("create")}`);
|
|
323
320
|
const root = path.resolve(typeof argv.dir === "string" ? argv.dir : process.cwd());
|
|
321
|
+
const existing = projectDirOf(root);
|
|
322
|
+
if (existing !== void 0) {
|
|
323
|
+
await addSurface(context, existing);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
324
326
|
const problem = alreadyAProject(root);
|
|
325
327
|
if (problem !== void 0) throw new Error(problem);
|
|
326
328
|
const target = path.join(root, "superwall");
|
|
329
|
+
const appId = typeof argv.app === "string" || typeof argv.app === "number" ? String(argv.app) : void 0;
|
|
330
|
+
if (appId !== void 0 && argv.connect === false) throw new Error("`--app` connects the project to that app — drop `--no-connect`.");
|
|
327
331
|
const detection = detectHostApp(root);
|
|
332
|
+
const from = typeof argv.from === "string" || typeof argv.from === "number" ? String(argv.from) : void 0;
|
|
328
333
|
let example = typeof argv.example === "string" ? argv.example : void 0;
|
|
329
|
-
if (
|
|
334
|
+
if (from !== void 0 && example !== void 0) throw new Error("`--from` rebuilds a dashboard paywall as the starter — drop `--example`.");
|
|
335
|
+
if (from !== void 0 && argv.connect === false) throw new Error("`--from` connects the project to the paywall's app — drop `--no-connect`.");
|
|
336
|
+
let originAppId;
|
|
337
|
+
let originBound = false;
|
|
338
|
+
let migration;
|
|
339
|
+
if (from !== void 0) {
|
|
340
|
+
const origin = await scaffoldFromPaywall(ui, await requireApi(interactive), {
|
|
341
|
+
root,
|
|
342
|
+
target,
|
|
343
|
+
paywallId: from,
|
|
344
|
+
newProject: true
|
|
345
|
+
});
|
|
346
|
+
if (origin.applicationId !== void 0 && origin.platform !== void 0) originBound = true;
|
|
347
|
+
else originAppId = origin.applicationId;
|
|
348
|
+
migration = migrationFor(target, origin.id);
|
|
349
|
+
}
|
|
350
|
+
if (from === void 0 && example === void 0 && interactive && argv.yes !== true) {
|
|
330
351
|
const start = await ui.select({
|
|
331
352
|
message: "Start from",
|
|
332
353
|
options: [{
|
|
@@ -362,7 +383,7 @@ const runCreate = defineCommand({
|
|
|
362
383
|
}
|
|
363
384
|
}
|
|
364
385
|
}
|
|
365
|
-
if (example === void 0) {
|
|
386
|
+
if (from !== void 0) {} else if (example === void 0) {
|
|
366
387
|
writeTemplate(target, projectPackageName(root));
|
|
367
388
|
ui.step("Created superwall/ from the minimal template");
|
|
368
389
|
} else {
|
|
@@ -383,26 +404,32 @@ const runCreate = defineCommand({
|
|
|
383
404
|
}
|
|
384
405
|
const detected = await detection;
|
|
385
406
|
if (detected?.existing.fullyIntegrated) ui.info(`The Superwall SDK is already set up in \`${detected.app.name}\`.`);
|
|
386
|
-
if ((argv.connect === false ? false : interactive && argv.yes !== true ? await ui.confirm({
|
|
407
|
+
if ((argv.connect === false || originBound ? false : interactive && argv.yes !== true && appId === void 0 && from === void 0 ? await ui.confirm({
|
|
387
408
|
message: "Connect your Superwall account now? (Recommended)",
|
|
388
409
|
initial: true
|
|
389
410
|
}) : true) === true) try {
|
|
390
|
-
await connectApp(ui, interactive, root, target, detected);
|
|
411
|
+
await connectApp(ui, interactive, root, target, detected, appId ?? originAppId);
|
|
391
412
|
} catch (error) {
|
|
413
|
+
if (appId !== void 0) throw error;
|
|
392
414
|
if (error instanceof LoginRequiredError) ui.info("Not signed in — the first `superwall push` will connect you.");
|
|
393
415
|
else ui.warn(`${error instanceof Error ? error.message : String(error)}\nSkipping — the first \`superwall push\` connects you.`);
|
|
394
416
|
}
|
|
395
417
|
const manager = await detectPackageManager(root);
|
|
396
418
|
const installed = argv.install === false ? false : await installDependencies(ui, target, manager);
|
|
397
419
|
await initGit(ui, root);
|
|
398
|
-
|
|
399
|
-
ui
|
|
400
|
-
|
|
401
|
-
children: [{ label: "Open the studio" }]
|
|
402
|
-
}, ...detected?.existing.fullyIntegrated ? [] : [{
|
|
420
|
+
const rebuilt = migration !== void 0 && interactive && argv.yes !== true ? await offerMigration(ui, interactive, migration) : "later";
|
|
421
|
+
const opening = rebuilt === "agent" && migration !== void 0 && await askStudio(ui, interactive, migration.surfaceId);
|
|
422
|
+
const integrate = detected?.existing.fullyIntegrated ? [] : [{
|
|
403
423
|
label: "superwall integrate",
|
|
404
424
|
children: [{ label: "Set up the SDK in your app" }]
|
|
405
|
-
}]
|
|
425
|
+
}];
|
|
426
|
+
const dev = installed ? `cd superwall && ${devCommand(manager)}` : `cd superwall && ${manager} install && ${devCommand(manager)}`;
|
|
427
|
+
ui.step("Next steps");
|
|
428
|
+
ui.list({ items: from === void 0 ? [{
|
|
429
|
+
label: dev,
|
|
430
|
+
children: [{ label: "Open the studio" }]
|
|
431
|
+
}, ...integrate] : [...migrationNextSteps(opening, "superwall", from, rebuilt).map((label) => ({ label })), ...integrate] });
|
|
432
|
+
if (opening && migration !== void 0) await startStudio(target, migration.surfaceId);
|
|
406
433
|
}
|
|
407
434
|
});
|
|
408
435
|
|