@superwall/cli 1.7.0 → 2.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/README.md +192 -52
- package/dist/{setup-Bxj22rYi.js → apple-CSzNTGHM.js} +82 -76
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-B7ym3oVS.js → billing-C3Q8DBU2.js} +98 -28
- package/dist/{bind-YrJvuRF9.js → bind-BumHTi9O.js} +38 -33
- package/dist/{build-DLoCW5Ri.js → build-Bpviiclc.js} +20 -26
- package/dist/client-BL0f_yGf.js +176 -0
- package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/create-BSfvpWoD.js +19 -0
- package/dist/{create-pkANt1Gs.js → create-BUcVG4Ab.js} +195 -169
- package/dist/{notification-url-DuKF2659.js → create-CfK3PeKA.js} +235 -539
- package/dist/doctor-BWqIYcMn.js +83 -0
- package/dist/{drivers-Qx9LxmRN.js → drivers-CPhdPkW5.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28072 -1134
- package/dist/environment-eBXjELoN.js +58 -0
- package/dist/{existing-AVEfZu2A.js → existing-BltvQiX5.js} +12 -6
- package/dist/held-CPve03KJ.js +16 -0
- package/dist/held-DgnTFMl3.js +1112 -0
- package/dist/input-vi0bou04.js +42 -0
- package/dist/{integrate-brmhPG-S.js → integrate-BRsqoe01.js} +277 -254
- package/dist/log-NVhVe_oe.js +62 -0
- package/dist/login-BCEH5q0U.js +53 -0
- package/dist/login-BPOONe7n.js +16 -0
- package/dist/{login-Do4wFuLv.js → login-BbTIrCFT.js} +118 -55
- package/dist/lookup-rr1AkCJA.js +71 -0
- package/dist/migrate-C9X2Vz81.js +274 -0
- package/dist/notification-url-CV86qiKP.js +100 -0
- package/dist/{open-studio-DOw-6ydc.js → open-CcpXotHG.js} +34 -43
- package/dist/org-BQQDo7wm.js +35 -0
- package/dist/output-Ggzq5_-t.js +122 -0
- package/dist/paths-CRlU72cq.js +29 -0
- package/dist/playbook-DVMXN7fh.js +53 -0
- package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
- package/dist/promote-Da8xctzy.js +91 -0
- package/dist/push-BV-grvQg.js +22 -0
- package/dist/push-D6R9icWN.js +495 -0
- package/dist/registry-BYVD-_h6.js +10385 -0
- package/dist/{reports-CfJqoava.js → reports-D_qbl7_u.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-DLON3-61.js} +162 -55
- package/dist/{run-DsVZ5snL.js → run-Co-BwhOg.js} +16 -22
- package/dist/scan-B88OlWOt.js +4 -0
- package/dist/{scan-zKsddO72.js → scan-CKuk-_6W.js} +48 -37
- package/dist/scope-DV22_Ufm.js +198 -0
- package/dist/screenshot-file-tVBfUEIi.js +16 -0
- package/dist/{selection-CxZoX4NT.js → selection-C2_KbLuo.js} +100 -51
- package/dist/server-C4f6ccUr.js +22 -0
- package/dist/{dev-DmB3XqaJ.js → server-D0d2oP-5.js} +86 -94
- package/dist/session-B-Uz0cQ7.js +40 -0
- package/dist/session-BuvArt1j.js +6 -0
- package/dist/session-C4rbE3VS.js +796 -0
- package/dist/skills/animate-onboarding/SKILL.md +467 -0
- package/dist/skills/animate-onboarding/references/engine.md +494 -0
- package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/skills/animate-onboarding/references/performance.md +41 -0
- package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/skills/index.json +37 -0
- package/dist/skills/mobile-design/SKILL.md +447 -0
- package/dist/skills/mobile-design/references/responsive.md +162 -0
- package/dist/skills/onboarding-questions/SKILL.md +231 -0
- package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/skills/onboarding-questions/references/craft.md +142 -0
- package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/skills/superwall/SKILL.md +82 -9
- package/dist/skills/superwall/references/api.md +153 -37
- package/dist/skills/superwall/references/apple-setup.md +316 -0
- package/dist/skills/superwall/references/asc.md +74 -38
- package/dist/skills/superwall/references/data-analytics.md +55 -21
- package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
- package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
- package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
- package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
- package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
- package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
- package/dist/skills/superwall/workflows/placements/android.md +2 -2
- package/dist/skills/superwall/workflows/placements/expo.md +2 -2
- package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
- package/dist/skills/superwall/workflows/placements/ios.md +2 -2
- package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
- package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
- package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
- package/dist/skills/superwall/workflows/review/playbook.md +1 -1
- package/dist/skills/superwall-editor/SKILL.md +61 -0
- package/dist/skills/superwall-editor/references/cli.md +135 -0
- package/dist/skills/superwall-editor/references/design.md +51 -0
- package/dist/skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/skills/superwall-editor/references/workflow.md +65 -0
- package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/skills/superwall-framework/SKILL.md +85 -31
- package/dist/skills/superwall-framework/references/cli.md +58 -27
- package/dist/skills/superwall-framework/references/examples.md +4 -3
- package/dist/skills/superwall-framework/references/layout.md +64 -9
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
- package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
- package/dist/skills/wwdc/SKILL.md +22 -0
- package/dist/skills/wwdc/references/docs.md +52 -0
- package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/skills-CLGJuMnF.js +14 -0
- package/dist/{skills-DPzlnfCK.js → skills-CZcpnEnG.js} +100 -122
- package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
- package/dist/spinner-C2U6QBJ9.js +294 -0
- package/dist/storage-6h9vyiAz.js +31 -0
- package/dist/storage-CerJ5KLP.d.ts +16 -0
- package/dist/storekit-CK9JmM2D.js +16 -0
- package/dist/storekit-CinJra3V.js +47 -0
- package/dist/telemetry-DKyDhURo.js +56 -0
- package/dist/theme-DUsCh-Vd.js +25 -0
- package/dist/timing-BVxPrYq3.js +5 -0
- package/dist/{token-C0it-Xh7.js → token-DaxQgQkv.js} +6 -38
- package/dist/tools-skills/animate-onboarding/SKILL.md +467 -0
- package/dist/tools-skills/animate-onboarding/references/engine.md +494 -0
- package/dist/tools-skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/tools-skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/tools-skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/tools-skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/tools-skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/tools-skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/tools-skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/tools-skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/tools-skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/tools-skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/tools-skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/tools-skills/animate-onboarding/references/performance.md +41 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/tools-skills/mobile-design/SKILL.md +447 -0
- package/dist/tools-skills/mobile-design/references/responsive.md +162 -0
- package/dist/tools-skills/onboarding-questions/SKILL.md +231 -0
- package/dist/tools-skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/tools-skills/onboarding-questions/references/craft.md +142 -0
- package/dist/tools-skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/tools-skills/superwall/SKILL.md +263 -0
- package/dist/tools-skills/superwall/references/api.md +303 -0
- package/dist/tools-skills/superwall/references/asa.md +166 -0
- package/dist/tools-skills/superwall/references/asc.md +95 -0
- package/dist/tools-skills/superwall/references/dashboard-links.md +57 -0
- package/dist/tools-skills/superwall/references/data-analytics.md +896 -0
- package/dist/tools-skills/superwall/references/docs.md +51 -0
- package/dist/tools-skills/superwall/references/sdk-integration.md +104 -0
- package/dist/tools-skills/superwall/references/sdk-source.md +18 -0
- package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +76 -0
- package/dist/tools-skills/superwall/workflows/dashboard/setup.md +100 -0
- package/dist/tools-skills/superwall/workflows/integrate/android.md +292 -0
- package/dist/tools-skills/superwall/workflows/integrate/expo.md +272 -0
- package/dist/tools-skills/superwall/workflows/integrate/flutter.md +285 -0
- package/dist/tools-skills/superwall/workflows/integrate/ios.md +314 -0
- package/dist/tools-skills/superwall/workflows/integrate/playbook.md +83 -0
- package/dist/tools-skills/superwall/workflows/integrate/react-native.md +246 -0
- package/dist/tools-skills/superwall/workflows/migrate/adapty.md +229 -0
- package/dist/tools-skills/superwall/workflows/migrate/playbook.md +78 -0
- package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +227 -0
- package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +414 -0
- package/dist/tools-skills/superwall/workflows/placements/android.md +175 -0
- package/dist/tools-skills/superwall/workflows/placements/expo.md +161 -0
- package/dist/tools-skills/superwall/workflows/placements/flutter.md +139 -0
- package/dist/tools-skills/superwall/workflows/placements/ios.md +165 -0
- package/dist/tools-skills/superwall/workflows/placements/playbook.md +69 -0
- package/dist/tools-skills/superwall/workflows/placements/react-native.md +145 -0
- package/dist/tools-skills/superwall/workflows/placements/strategy.md +222 -0
- package/dist/tools-skills/superwall/workflows/review/android.md +120 -0
- package/dist/tools-skills/superwall/workflows/review/expo.md +100 -0
- package/dist/tools-skills/superwall/workflows/review/flutter.md +99 -0
- package/dist/tools-skills/superwall/workflows/review/ios.md +108 -0
- package/dist/tools-skills/superwall/workflows/review/playbook.md +70 -0
- package/dist/tools-skills/superwall/workflows/review/react-native.md +100 -0
- package/dist/tools-skills/superwall-editor/SKILL.md +113 -0
- package/dist/tools-skills/superwall-editor/references/cli.md +135 -0
- package/dist/tools-skills/superwall-editor/references/design.md +51 -0
- package/dist/tools-skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/tools-skills/superwall-editor/references/workflow.md +65 -0
- package/dist/tools-skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/tools-skills/wwdc/SKILL.md +22 -0
- package/dist/tools-skills/wwdc/references/docs.md +52 -0
- package/dist/tools-skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/tools.d.ts +96 -0
- package/dist/tools.js +11360 -0
- package/dist/ui-D_qf3Gvw.js +53 -0
- package/dist/upgrade-DPo0a4Es.js +117 -0
- package/dist/upgrade-ffseQDMx.js +7 -0
- package/package.json +10 -5
- package/dist/api-CZzirVMj.js +0 -151
- package/dist/api-output-aJNw7Syy.js +0 -20
- package/dist/app-DH6U8yuI.js +0 -190
- package/dist/asa-C-sQzPPn.js +0 -1194
- package/dist/asc-1ZBJ6DwS.js +0 -778
- package/dist/auth-YRhlV3DE.js +0 -140
- package/dist/billing-CCYHdApx.js +0 -80
- package/dist/bundle-id-CKxl_026.js +0 -121
- package/dist/command-CMIz81Da.js +0 -301
- package/dist/dev-DZy6pOnB.js +0 -22
- package/dist/doctor-H-hf-Yww.js +0 -88
- package/dist/feedback-CKf-rpBW.js +0 -152
- package/dist/hosted-CXe9TrWx.js +0 -32
- package/dist/migrate-C9ERDR6y.js +0 -284
- package/dist/org-sj7uyvp-.js +0 -40
- package/dist/output-C4o2gJ1K.js +0 -146
- package/dist/params-l3CrvRtR.js +0 -51
- package/dist/pipeline-BqzqZhX1.js +0 -977
- package/dist/print-skill-ZojRSybs.js +0 -74
- package/dist/promote-BG8X4Nv_.js +0 -88
- package/dist/publish-sxLh-G4G.js +0 -35
- package/dist/push-bQ6Vxtg8.js +0 -35
- package/dist/query-_FbybaH-.js +0 -53
- package/dist/resource-CGIwSd29.js +0 -323
- package/dist/revenue-provider-ebsRINY8.js +0 -100
- package/dist/scope-BvzD-kO4.js +0 -223
- package/dist/skills-D_R-lEsK.js +0 -64
- package/dist/spinner-TWa0hia6.js +0 -18
- package/dist/storekit-Cj9Cpjcz.js +0 -29
- package/dist/telemetry-DeA1mvnT.js +0 -169
- package/dist/ui-Dy0b-9L8.js +0 -27738
- package/dist/update-B2fWIc4q.js +0 -59
- package/dist/upgrade-BmzkTKrh.js +0 -72
- /package/dist/{devtools-8EgLo86w.js → devtools-pBl_vt03.js} +0 -0
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
5
|
-
import
|
|
6
|
-
import "./
|
|
7
|
-
import "./
|
|
8
|
-
import "./spawn-
|
|
9
|
-
import "./
|
|
10
|
-
import
|
|
11
|
-
import "./
|
|
12
|
-
import "./
|
|
13
|
-
import { t as
|
|
14
|
-
import "./
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import "./org-
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import "./
|
|
21
|
-
import "./
|
|
22
|
-
import "./
|
|
23
|
-
import {
|
|
24
|
-
import "./
|
|
25
|
-
import
|
|
1
|
+
import "./token-DaxQgQkv.js";
|
|
2
|
+
import "./output-Ggzq5_-t.js";
|
|
3
|
+
import "./environment-eBXjELoN.js";
|
|
4
|
+
import "./storage-6h9vyiAz.js";
|
|
5
|
+
import "./client-BL0f_yGf.js";
|
|
6
|
+
import "./config-BO1Y87kV.js";
|
|
7
|
+
import "./telemetry-DKyDhURo.js";
|
|
8
|
+
import "./spawn-DmmmHIP-.js";
|
|
9
|
+
import "./spinner-C2U6QBJ9.js";
|
|
10
|
+
import "./ui-D_qf3Gvw.js";
|
|
11
|
+
import "./theme-DUsCh-Vd.js";
|
|
12
|
+
import "./log-NVhVe_oe.js";
|
|
13
|
+
import { i as readPackageJson, r as allDeps, t as scanProject } from "./scan-CKuk-_6W.js";
|
|
14
|
+
import { t as detectExisting } from "./existing-BltvQiX5.js";
|
|
15
|
+
import "./paths-CRlU72cq.js";
|
|
16
|
+
import { D as field, f as listApplications, n as createApplication, p as listProjects, v as platformLabel } from "./resources-DLON3-61.js";
|
|
17
|
+
import "./org-BQQDo7wm.js";
|
|
18
|
+
import { n as findApplication } from "./lookup-rr1AkCJA.js";
|
|
19
|
+
import { r as resolveScopeFromKey } from "./bind-BumHTi9O.js";
|
|
20
|
+
import "./login-BbTIrCFT.js";
|
|
21
|
+
import "./skills-CZcpnEnG.js";
|
|
22
|
+
import { E as writeApp } from "./selection-C2_KbLuo.js";
|
|
23
|
+
import { a as gitAvailable, b as requirePlatform, c as projectPackageName, n as requireApi, t as LoginRequiredError } from "./session-C4rbE3VS.js";
|
|
24
|
+
import "./login-BCEH5q0U.js";
|
|
25
|
+
import "./run-Co-BwhOg.js";
|
|
26
|
+
import "./drivers-CPhdPkW5.js";
|
|
27
|
+
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-CcpXotHG.js";
|
|
28
|
+
import "./server-D0d2oP-5.js";
|
|
29
|
+
import { execFile } from "node:child_process";
|
|
30
|
+
import * as fs from "node:fs";
|
|
26
31
|
import * as path from "node:path";
|
|
27
|
-
import
|
|
32
|
+
import pc from "picocolors";
|
|
28
33
|
import { promisify } from "node:util";
|
|
29
|
-
import * as
|
|
30
|
-
import {
|
|
34
|
+
import * as os$1 from "node:os";
|
|
35
|
+
import { gunzipSync } from "node:zlib";
|
|
31
36
|
|
|
32
37
|
//#region src/core/paywalls/project/examples.ts
|
|
33
38
|
const run$1 = promisify(execFile);
|
|
@@ -37,19 +42,26 @@ var ExampleError = class extends Error {};
|
|
|
37
42
|
async function listExamples(fetchImpl = fetch) {
|
|
38
43
|
const response = await fetchImpl(`https://api.github.com/repos/${EXAMPLES_REPO}/contents/examples?ref=${EXAMPLES_REF}`);
|
|
39
44
|
if (!response.ok) throw new ExampleError(`Could not list examples from github.com/${EXAMPLES_REPO} (HTTP ${response.status}).`);
|
|
40
|
-
|
|
45
|
+
const entries = await response.json();
|
|
46
|
+
return (Array.isArray(entries) ? entries : []).filter((entry) => field(entry, "type") === "dir").map((entry) => field(entry, "name")).filter((name) => typeof name === "string").sort();
|
|
41
47
|
}
|
|
42
48
|
async function downloadExample(name, target, fetchImpl = fetch) {
|
|
43
49
|
if (!/^[a-z0-9][a-z0-9-]*$/.test(name)) throw new ExampleError(`\`${name}\` is not an example name.`);
|
|
44
50
|
const response = await fetchImpl(`https://codeload.github.com/${EXAMPLES_REPO}/tar.gz/refs/heads/${EXAMPLES_REF}`);
|
|
45
51
|
if (!response.ok) throw new ExampleError(`Could not download github.com/${EXAMPLES_REPO} (HTTP ${response.status}). Check your network, then try again.`);
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
let archive;
|
|
53
|
+
try {
|
|
54
|
+
archive = gunzipSync(Buffer.from(await response.arrayBuffer()));
|
|
55
|
+
} catch {
|
|
56
|
+
throw new ExampleError(`The download of github.com/${EXAMPLES_REPO} was damaged. Try again.`);
|
|
57
|
+
}
|
|
58
|
+
const tarball = path.join(os$1.tmpdir(), `superwall-example-${process.pid}.tar`);
|
|
59
|
+
fs.writeFileSync(tarball, archive);
|
|
48
60
|
const prefix = `${EXAMPLES_REPO.split("/")[1]}-${EXAMPLES_REF.replace(/\//g, "-")}`;
|
|
49
61
|
fs.mkdirSync(target, { recursive: true });
|
|
50
62
|
try {
|
|
51
63
|
await run$1("tar", [
|
|
52
|
-
"-
|
|
64
|
+
"-xf",
|
|
53
65
|
tarball,
|
|
54
66
|
"-C",
|
|
55
67
|
target,
|
|
@@ -73,7 +85,7 @@ function adoptExamplePackage(target, name) {
|
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
//#endregion
|
|
76
|
-
//#region src/
|
|
88
|
+
//#region src/core/paywalls/project/setup.ts
|
|
77
89
|
const run = promisify(execFile);
|
|
78
90
|
const APP_PLATFORMS = [
|
|
79
91
|
"ios",
|
|
@@ -141,10 +153,7 @@ async function installDependencies(ui, target, manager) {
|
|
|
141
153
|
}
|
|
142
154
|
async function initGit(ui, root) {
|
|
143
155
|
if (!await gitAvailable()) return;
|
|
144
|
-
|
|
145
|
-
await run("git", ["rev-parse", "--is-inside-work-tree"], { cwd: root });
|
|
146
|
-
return;
|
|
147
|
-
} catch {}
|
|
156
|
+
if (await run("git", ["rev-parse", "--is-inside-work-tree"], { cwd: root }).then(() => true, () => false)) return;
|
|
148
157
|
try {
|
|
149
158
|
await run("git", ["init", "--quiet"], { cwd: root });
|
|
150
159
|
await run("git", ["add", "-A"], { cwd: root });
|
|
@@ -155,7 +164,9 @@ async function initGit(ui, root) {
|
|
|
155
164
|
"New superwall project"
|
|
156
165
|
], { cwd: root });
|
|
157
166
|
ui.step("Initialized a git repository");
|
|
158
|
-
} catch {
|
|
167
|
+
} catch {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
159
170
|
}
|
|
160
171
|
function humanName(root) {
|
|
161
172
|
return projectPackageName(root).split(/[-_.]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
@@ -174,11 +185,12 @@ async function detectHostApp(root) {
|
|
|
174
185
|
}
|
|
175
186
|
async function createAppFlow(ui, api, root) {
|
|
176
187
|
const projects = await listProjects(api);
|
|
177
|
-
|
|
188
|
+
const [first] = projects;
|
|
189
|
+
if (first === void 0) {
|
|
178
190
|
ui.warn("Your account has no projects yet — create one in the dashboard first.");
|
|
179
191
|
return null;
|
|
180
192
|
}
|
|
181
|
-
let project =
|
|
193
|
+
let project = first;
|
|
182
194
|
if (projects.length > 1) {
|
|
183
195
|
const picked = await ui.select({
|
|
184
196
|
message: "Which project does the app belong to?",
|
|
@@ -221,7 +233,7 @@ async function createAppFlow(ui, api, root) {
|
|
|
221
233
|
async function connectApp(ui, interactive, root, target, detected, appId) {
|
|
222
234
|
const api = await requireApi(interactive);
|
|
223
235
|
if (appId !== void 0) {
|
|
224
|
-
const app$1 = (await
|
|
236
|
+
const app$1 = (await findApplication(api, appId))?.app;
|
|
225
237
|
if (app$1 === void 0) throw new Error(`No app with id \`${appId}\` in this account — run \`superwall apps\` to list them.`);
|
|
226
238
|
writeApp(target, requirePlatform(app$1), String(app$1.id));
|
|
227
239
|
ui.success(`Pushes go to \`${app$1.name ?? app$1.id}\` — saved in superwall.lock, so commit that file.`);
|
|
@@ -268,36 +280,53 @@ async function connectApp(ui, interactive, root, target, detected, appId) {
|
|
|
268
280
|
writeApp(target, requirePlatform(app), String(app.id));
|
|
269
281
|
ui.success(`Pushes go to \`${app.name ?? app.id}\` — saved in superwall.lock, so commit that file.`);
|
|
270
282
|
}
|
|
271
|
-
|
|
283
|
+
function uniqueSurfaceId(superwallDir, slug) {
|
|
272
284
|
let candidate = slug;
|
|
273
285
|
for (let n = 2; fs.existsSync(path.join(superwallDir, "paywalls", candidate)); n += 1) candidate = `${slug}-${n}`;
|
|
274
286
|
return candidate;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/core/paywalls/project/create.ts
|
|
291
|
+
const runtime = {
|
|
292
|
+
offerMigration,
|
|
293
|
+
askStudio,
|
|
294
|
+
startStudio
|
|
275
295
|
};
|
|
276
|
-
async function
|
|
277
|
-
const {
|
|
296
|
+
async function offerRebuild(ctx, options, migration, deps) {
|
|
297
|
+
const { interactive, ui } = ctx;
|
|
298
|
+
if (migration === void 0 || !interactive || options.yes) return { choice: "later" };
|
|
299
|
+
const choice = await deps.offerMigration(ui, interactive, migration);
|
|
300
|
+
if (choice !== "agent") return { choice };
|
|
301
|
+
return await deps.askStudio(ui, interactive, migration.surfaceId) ? {
|
|
302
|
+
choice,
|
|
303
|
+
studio: migration
|
|
304
|
+
} : { choice };
|
|
305
|
+
}
|
|
306
|
+
async function addSurface(ctx, options, superwallDir, deps) {
|
|
307
|
+
const { interactive, ui } = ctx;
|
|
278
308
|
const where = path.relative(process.cwd(), superwallDir) || ".";
|
|
279
|
-
if (
|
|
280
|
-
if (
|
|
281
|
-
const from =
|
|
309
|
+
if (options.example !== void 0) throw new Error(`\`${where}\` is already a superwall project — an example is a whole project, so start it in an empty directory.`);
|
|
310
|
+
if (options.app !== void 0) throw new Error(`\`${where}\` is already connected — its apps live in superwall.lock; drop \`--app\`.`);
|
|
311
|
+
const from = options.from;
|
|
282
312
|
if (from !== void 0) {
|
|
283
|
-
const
|
|
313
|
+
const rebuild = await offerRebuild(ctx, options, migrationFor(superwallDir, (await scaffoldFromPaywall(ui, await requireApi(interactive), {
|
|
284
314
|
root: process.cwd(),
|
|
285
315
|
target: superwallDir,
|
|
286
316
|
paywallId: from,
|
|
287
317
|
newProject: false
|
|
288
|
-
})).id);
|
|
289
|
-
const rebuilt = migration !== void 0 && interactive && argv.yes !== true ? await offerMigration(ui, interactive, migration) : "later";
|
|
290
|
-
const opening = rebuilt === "agent" && migration !== void 0 && await askStudio(ui, interactive, migration.surfaceId);
|
|
318
|
+
})).id), deps);
|
|
291
319
|
ui.step("Next steps");
|
|
292
|
-
ui.list({ items: migrationNextSteps(
|
|
293
|
-
if (
|
|
320
|
+
ui.list({ items: migrationNextSteps(rebuild.studio !== void 0, where, from, rebuild.choice).map((label) => ({ label })) });
|
|
321
|
+
if (rebuild.studio !== void 0) await deps.startStudio(superwallDir, rebuild.studio.surfaceId);
|
|
294
322
|
return;
|
|
295
323
|
}
|
|
296
|
-
|
|
324
|
+
let asked = "Pro";
|
|
325
|
+
if (interactive && !options.yes) asked = await ui.text({
|
|
297
326
|
message: "What is the paywall called?",
|
|
298
327
|
initialValue: "Pro",
|
|
299
328
|
validate: (value) => value.trim() === "" ? "Give the paywall a name." : void 0
|
|
300
|
-
})
|
|
329
|
+
});
|
|
301
330
|
if (asked === null) return;
|
|
302
331
|
const name = asked.trim();
|
|
303
332
|
const id = uniqueSurfaceId(superwallDir, slugOf(name));
|
|
@@ -312,127 +341,124 @@ async function addSurface(context, superwallDir) {
|
|
|
312
341
|
children: [{ label: "Open the studio and build the pages" }]
|
|
313
342
|
}] });
|
|
314
343
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
});
|
|
365
|
-
if (start === null) return;
|
|
366
|
-
if (start === "example") {
|
|
367
|
-
const spin = ui.spinner();
|
|
368
|
-
spin.start("Fetching the example list");
|
|
369
|
-
try {
|
|
370
|
-
const examples = await listExamples();
|
|
371
|
-
spin.stop(`${examples.length} examples`);
|
|
372
|
-
const picked = await ui.select({
|
|
373
|
-
message: "Which example?",
|
|
374
|
-
options: examples.map((name) => ({
|
|
375
|
-
value: name,
|
|
376
|
-
label: name
|
|
377
|
-
}))
|
|
378
|
-
});
|
|
379
|
-
if (picked === null) return;
|
|
380
|
-
example = picked;
|
|
381
|
-
} catch (error) {
|
|
382
|
-
spin.stop("Could not fetch the example list");
|
|
383
|
-
ui.warn(`${error instanceof ExampleError ? error.message : String(error)}\nStarting from minimal instead.`);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
if (from !== void 0) {} else if (example === void 0) {
|
|
388
|
-
writeTemplate(target, projectPackageName(root));
|
|
389
|
-
ui.step("Created superwall/ from the minimal template");
|
|
390
|
-
} else {
|
|
344
|
+
async function runCreate(ctx, options, deps = runtime) {
|
|
345
|
+
const { interactive, ui } = ctx;
|
|
346
|
+
ui.intro(`Superwall ${pc.dim("create")}`);
|
|
347
|
+
const root = path.resolve(options.dir ?? process.cwd());
|
|
348
|
+
const existing = projectDirOf(root);
|
|
349
|
+
if (existing !== void 0) {
|
|
350
|
+
await addSurface(ctx, options, existing, deps);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const problem = alreadyAProject(root);
|
|
354
|
+
if (problem !== void 0) throw new Error(problem);
|
|
355
|
+
const target = path.join(root, "superwall");
|
|
356
|
+
const appId = options.app;
|
|
357
|
+
if (appId !== void 0 && !options.connect) throw new Error("`--app` connects the project to that app — drop `--no-connect`.");
|
|
358
|
+
const detection = detectHostApp(root);
|
|
359
|
+
const from = options.from;
|
|
360
|
+
let example = options.example;
|
|
361
|
+
if (from !== void 0 && example !== void 0) throw new Error("`--from` rebuilds a dashboard paywall as the starter — drop `--example`.");
|
|
362
|
+
if (from !== void 0 && !options.connect) throw new Error("`--from` connects the project to the paywall's app — drop `--no-connect`.");
|
|
363
|
+
let originAppId;
|
|
364
|
+
let originBound = false;
|
|
365
|
+
let migration;
|
|
366
|
+
if (from !== void 0) {
|
|
367
|
+
const origin = await scaffoldFromPaywall(ui, await requireApi(interactive), {
|
|
368
|
+
root,
|
|
369
|
+
target,
|
|
370
|
+
paywallId: from,
|
|
371
|
+
newProject: true
|
|
372
|
+
});
|
|
373
|
+
if (origin.applicationId !== void 0 && origin.platform !== void 0) originBound = true;
|
|
374
|
+
else originAppId = origin.applicationId;
|
|
375
|
+
migration = migrationFor(target, origin.id);
|
|
376
|
+
}
|
|
377
|
+
if (from === void 0 && example === void 0 && interactive && !options.yes) {
|
|
378
|
+
const start = await ui.select({
|
|
379
|
+
message: "Start from",
|
|
380
|
+
options: [{
|
|
381
|
+
value: "minimal",
|
|
382
|
+
label: "Minimal",
|
|
383
|
+
hint: "one paywall, one product"
|
|
384
|
+
}, {
|
|
385
|
+
value: "example",
|
|
386
|
+
label: "An example",
|
|
387
|
+
hint: `github.com/${EXAMPLES_REPO}`
|
|
388
|
+
}],
|
|
389
|
+
initialValue: "minimal"
|
|
390
|
+
});
|
|
391
|
+
if (start === null) return;
|
|
392
|
+
if (start === "example") {
|
|
391
393
|
const spin = ui.spinner();
|
|
392
|
-
spin.start(
|
|
394
|
+
spin.start("Fetching the example list");
|
|
393
395
|
try {
|
|
394
|
-
await
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
396
|
+
const examples = await listExamples();
|
|
397
|
+
spin.stop(`${examples.length} examples`);
|
|
398
|
+
const picked = await ui.select({
|
|
399
|
+
message: "Which example?",
|
|
400
|
+
options: examples.map((name) => ({
|
|
401
|
+
value: name,
|
|
402
|
+
label: name
|
|
403
|
+
}))
|
|
400
404
|
});
|
|
401
|
-
|
|
405
|
+
if (picked === null) return;
|
|
406
|
+
example = picked;
|
|
407
|
+
} catch (error) {
|
|
408
|
+
spin.stop("Could not fetch the example list");
|
|
409
|
+
ui.warn(`${error instanceof ExampleError ? error.message : String(error)}\nStarting from minimal instead.`);
|
|
402
410
|
}
|
|
403
|
-
adoptExamplePackage(target, projectPackageName(root));
|
|
404
|
-
spin.stop(`Created superwall/ from the \`${example}\` example`);
|
|
405
411
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
412
|
+
}
|
|
413
|
+
if (from === void 0 && example === void 0) {
|
|
414
|
+
writeTemplate(target, projectPackageName(root));
|
|
415
|
+
ui.step("Created superwall/ from the minimal template");
|
|
416
|
+
} else if (from === void 0 && example !== void 0) {
|
|
417
|
+
const spin = ui.spinner();
|
|
418
|
+
spin.start(`Downloading \`${example}\``);
|
|
419
|
+
try {
|
|
420
|
+
await downloadExample(example, target);
|
|
413
421
|
} catch (error) {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
422
|
+
spin.stop("Download failed");
|
|
423
|
+
fs.rmSync(target, {
|
|
424
|
+
recursive: true,
|
|
425
|
+
force: true
|
|
426
|
+
});
|
|
427
|
+
throw error;
|
|
417
428
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
ui
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
429
|
+
adoptExamplePackage(target, projectPackageName(root));
|
|
430
|
+
spin.stop(`Created superwall/ from the \`${example}\` example`);
|
|
431
|
+
}
|
|
432
|
+
const detected = await detection;
|
|
433
|
+
if (detected?.existing.fullyIntegrated) ui.info(`The Superwall SDK is already set up in \`${detected.app.name}\`.`);
|
|
434
|
+
let connect = options.connect && !originBound;
|
|
435
|
+
if (connect && interactive && !options.yes && appId === void 0 && from === void 0) connect = await ui.confirm({
|
|
436
|
+
message: "Connect your Superwall account now? (Recommended)",
|
|
437
|
+
initial: true
|
|
438
|
+
}) === true;
|
|
439
|
+
if (connect) try {
|
|
440
|
+
await connectApp(ui, interactive, root, target, detected, appId ?? originAppId);
|
|
441
|
+
} catch (error) {
|
|
442
|
+
if (appId !== void 0) throw error;
|
|
443
|
+
if (error instanceof LoginRequiredError) ui.info("Not signed in — the first `superwall push` will connect you.");
|
|
444
|
+
else ui.warn(`${error instanceof Error ? error.message : String(error)}\nSkipping — the first \`superwall push\` connects you.`);
|
|
434
445
|
}
|
|
435
|
-
|
|
446
|
+
const manager = await detectPackageManager(root);
|
|
447
|
+
const installed = options.install && await installDependencies(ui, target, manager);
|
|
448
|
+
await initGit(ui, root);
|
|
449
|
+
const rebuild = await offerRebuild(ctx, options, migration, deps);
|
|
450
|
+
const integrate = detected?.existing.fullyIntegrated ? [] : [{
|
|
451
|
+
label: "superwall integrate",
|
|
452
|
+
children: [{ label: "Set up the SDK in your app" }]
|
|
453
|
+
}];
|
|
454
|
+
const dev = installed ? `cd superwall && ${devCommand(manager)}` : `cd superwall && ${manager} install && ${devCommand(manager)}`;
|
|
455
|
+
ui.step("Next steps");
|
|
456
|
+
ui.list({ items: from === void 0 ? [{
|
|
457
|
+
label: dev,
|
|
458
|
+
children: [{ label: "Open the studio" }]
|
|
459
|
+
}, ...integrate] : [...migrationNextSteps(rebuild.studio !== void 0, "superwall", from, rebuild.choice).map((label) => ({ label })), ...integrate] });
|
|
460
|
+
if (rebuild.studio !== void 0) await deps.startStudio(target, rebuild.studio.surfaceId);
|
|
461
|
+
}
|
|
436
462
|
|
|
437
463
|
//#endregion
|
|
438
|
-
export {
|
|
464
|
+
export { runCreate };
|