@superwall/cli 2.6.0-beta.2 → 2.6.1

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.
Files changed (152) hide show
  1. package/README.md +47 -16
  2. package/dist/{apple-Dc5pOPms.js → apple-BE1GBJFP.js} +17 -19
  3. package/dist/{approve-BSbdmOez.js → approve-yRZmvkCj.js} +9 -11
  4. package/dist/{assets-C_RjojkK.js → assets-DTAgbWw0.js} +3 -3
  5. package/dist/auth.d.ts +11 -4
  6. package/dist/auth.js +4 -5
  7. package/dist/base-zc1wl_9b.js +82 -0
  8. package/dist/{billing-B6HK-F_a.js → billing-C1LV4-BN.js} +3 -3
  9. package/dist/{build-DK88pTMW.js → build-CQd-pf7O.js} +35 -16
  10. package/dist/{client-x08fpvay.js → config-DCqRQTJ4.js} +162 -15
  11. package/dist/create-CSHGZDfB.js +18 -0
  12. package/dist/{create-kpqEhqkk.js → create-Costu6UT.js} +9 -9
  13. package/dist/{create-B6-Dr3GZ.js → create-wlCp83IH.js} +41 -41
  14. package/dist/{doctor-DYbm8IKQ.js → doctor-Bd9ffg51.js} +50 -10
  15. package/dist/entry.js +45 -40
  16. package/dist/{environment-BFNzLLPN.js → environment-Dn7irhZr.js} +1 -1
  17. package/dist/{drivers-Dyi-y9Jn.js → existing-BQMB_2AG.js} +305 -8
  18. package/dist/framework-DW5fqjh4.js +65 -0
  19. package/dist/{source-BccdO4aL.js → git-Hf9Wc7Hp.js} +34 -92
  20. package/dist/{held-sKq3xrsT.js → held-D5wSX2Mf.js} +9 -9
  21. package/dist/held-Dmf5SR3p.js +15 -0
  22. package/dist/{install-DsIsif39.js → install-CxyqfKFe.js} +15 -17
  23. package/dist/{integrate-B8eA676b.js → integrate-MkyDDzI5.js} +33 -38
  24. package/dist/{login-BlpfYapG.js → login-B7IqDafm.js} +3 -3
  25. package/dist/{login-Blhxi20A.js → login-BMHDhxAx.js} +8 -9
  26. package/dist/login-Cp0-BgDZ.js +13 -0
  27. package/dist/{lookup-Dg55W9S7.js → lookup-DkcT4E-5.js} +28 -4
  28. package/dist/{migrate-DoRb9jmA.js → migrate-CdFoZipj.js} +66 -45
  29. package/dist/{notification-url-D82msWF5.js → notification-url-D6KKeXnk.js} +4 -4
  30. package/dist/{open-BAqLpTSI.js → open-COJE6ryI.js} +2 -2
  31. package/dist/{org-C4G7WjTV.js → org-BV8wwxwc.js} +4 -4
  32. package/dist/{organization-CmuQwcKN.js → organization-9R_1PJKk.js} +4 -4
  33. package/dist/{orgs-1OzwUtpT.js → orgs-ltP8H0Nl.js} +1 -2
  34. package/dist/{paths-gBbqgkS7.js → paths-Cb1RfjaX.js} +1 -1
  35. package/dist/{playbook-BKqlv77S.js → playbook-CVGolez9.js} +10 -14
  36. package/dist/{products-Cqq59DBQ.js → products-CJq_iXv5.js} +1 -1
  37. package/dist/{promote-D0i8A0CO.js → promote-B_HnFEbX.js} +27 -28
  38. package/dist/{pull-DgQ_UmGv.js → pull-DF4KYVcP.js} +72 -26
  39. package/dist/pull-JxiMyRwY.js +30 -0
  40. package/dist/{pull-CiIrJ5ik.js → pull-lYRULo4v.js} +33 -39
  41. package/dist/push-B5py7h5y.js +29 -0
  42. package/dist/{push-7N4XIVtg.js → push-BZN1Qpkq.js} +23 -12
  43. package/dist/{push-BWsXO7FN.js → push-BnllH2Rd.js} +8 -7
  44. package/dist/push-DHlUMkbf.js +21 -0
  45. package/dist/registry-BGEYCWyD.js +22 -0
  46. package/dist/{registry-aAR_8VOw.js → registry-CqePfigB.js} +1287 -902
  47. package/dist/{resolve-CcOpO_5s.js → resolve-B4bd3Qjl.js} +4 -4
  48. package/dist/{resources-DNwvf8rg.js → resources-BaURbSpY.js} +15 -2
  49. package/dist/{run-tVYJ3V5j.js → run-Bme4Egyl.js} +15 -17
  50. package/dist/{scan-dv0rrY4C.js → scan-DugxddUU.js} +1 -1
  51. package/dist/scan-J2DILUNE.js +4 -0
  52. package/dist/{scope-ehZ7L1nj.js → scope-Cg1AdAfO.js} +33 -3
  53. package/dist/{scope-BXoQo30_.js → scope-DDYLQeZw.js} +24 -18
  54. package/dist/screenshot-file-Dix2Qynm.js +127 -0
  55. package/dist/{sdk-DEfQttek.js → sdk-BFunw4Hc.js} +1 -1
  56. package/dist/{framework-JFLjmD5Y.js → selection-C439nEhn.js} +4 -54
  57. package/dist/{series-D2ZpZ8cx.js → series-B8NJK4yS.js} +1 -1
  58. package/dist/{server-CcZGdYjE.js → server-C_aMxzvS.js} +40 -18
  59. package/dist/server-Cif9w5lM.js +33 -0
  60. package/dist/{session-dHBtgSN0.js → session-B7frlXXQ.js} +1 -1
  61. package/dist/{base-83ZTv6up.js → session-CfG3gzko.js} +8 -83
  62. package/dist/session-DvaPyOuH.js +5 -0
  63. package/dist/{migration-BUedsREQ.js → setup-DQEasPhx.js} +290 -28
  64. package/dist/skills/index.json +5 -0
  65. package/dist/skills/superwall/SKILL.md +37 -10
  66. package/dist/skills/superwall/references/api.md +66 -21
  67. package/dist/skills/superwall/references/asa.md +109 -64
  68. package/dist/skills/superwall/references/dashboard-links.md +65 -28
  69. package/dist/skills/superwall/references/data-analytics.md +1 -1
  70. package/dist/skills/superwall/workflows/dashboard/setup.md +15 -5
  71. package/dist/skills/superwall/workflows/integrate/flutter.md +9 -7
  72. package/dist/skills/superwall-framework/SKILL.md +248 -36
  73. package/dist/skills/superwall-framework/references/cli.md +98 -7
  74. package/dist/skills/superwall-framework/references/examples.md +2 -2
  75. package/dist/skills/superwall-framework/references/layout.md +30 -2
  76. package/dist/skills/superwall-framework/references/migrate-from-editor.md +5 -0
  77. package/dist/skills/superwall-framework/references/migrate-from-native.md +5 -0
  78. package/dist/skills/teleport/SKILL.md +154 -0
  79. package/dist/skills/teleport/references/experiments.md +328 -0
  80. package/dist/skills/teleport/references/setup.md +157 -0
  81. package/dist/{skills-Q7xB784d.js → skills-DnegE1A6.js} +139 -9
  82. package/dist/{skills-Bqz2l_bx.js → skills-MmF7IyTg.js} +8 -12
  83. package/dist/source-DQs6iLtC.js +82 -0
  84. package/dist/{source-push-CG948HrX.js → source-push-MbJjh4Ki.js} +38 -14
  85. package/dist/{spinner-IA6hV8nI.js → spinner-Dcr-Dqdi.js} +7 -5
  86. package/dist/{starter-BtUUQWhd.js → starter-BlJ_InZJ.js} +2 -2
  87. package/dist/{status-CB_MrFu5.js → status-DHRxg1ZA.js} +9 -11
  88. package/dist/{output-Ggzq5_-t.js → storage-DdIAHolY.js} +40 -1
  89. package/dist/storekit-De998QOt.js +203 -0
  90. package/dist/storekit-iBCWmeKn.js +15 -0
  91. package/dist/{bind-DcWIIPgk.js → theme-BrUrye-c.js} +29 -6
  92. package/dist/token-CKCBQ4I8.js +100 -0
  93. package/dist/tools-skills/animate-onboarding/SKILL.md +1 -1
  94. package/dist/tools-skills/mobile-design/SKILL.md +1 -1
  95. package/dist/tools-skills/onboarding-questions/SKILL.md +1 -1
  96. package/dist/tools-skills/superwall/SKILL.md +43 -17
  97. package/dist/tools-skills/superwall/references/api.md +74 -24
  98. package/dist/tools-skills/superwall/references/asa.md +109 -64
  99. package/dist/tools-skills/superwall/references/dashboard-links.md +65 -28
  100. package/dist/tools-skills/superwall/references/data-analytics.md +1 -1
  101. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +4 -3
  102. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +21 -8
  103. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +9 -7
  104. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +4 -3
  105. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +2 -2
  106. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +4 -3
  107. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +4 -3
  108. package/dist/tools-skills/superwall-editor/SKILL.md +2 -3
  109. package/dist/tools-skills/teleport/SKILL.md +154 -0
  110. package/dist/tools-skills/teleport/references/experiments.md +328 -0
  111. package/dist/tools-skills/teleport/references/setup.md +157 -0
  112. package/dist/tools.d.ts +1 -1
  113. package/dist/tools.js +1232 -746
  114. package/dist/{try-CS3jLyoP.js → try-C8QQbG0b.js} +17 -19
  115. package/dist/{lock-DgSx-p8Y.js → types-Dc9U_4kp.js} +86 -80
  116. package/dist/upgrade-CYFdpVpi.js +27 -0
  117. package/dist/upgrade-D0thxCA4.js +348 -0
  118. package/package.json +11 -3
  119. package/dist/config-CGcG7GOt.js +0 -113
  120. package/dist/create-Du8Fx7W5.js +0 -20
  121. package/dist/existing-WQ3pz94o.js +0 -97
  122. package/dist/held-DmOhszHR.js +0 -17
  123. package/dist/log-C0MDCfA2.js +0 -62
  124. package/dist/login-D9jfRO8w.js +0 -17
  125. package/dist/pull-CO5HlqBe.js +0 -36
  126. package/dist/push-BIhGDNpL.js +0 -30
  127. package/dist/push-BgqTddLA.js +0 -22
  128. package/dist/run-B-YoyB-a.js +0 -100
  129. package/dist/scan-BU41gcQY.js +0 -4
  130. package/dist/screenshot-file-XAS0Xy0e.js +0 -16
  131. package/dist/server-BemmM1FV.js +0 -29
  132. package/dist/session-4aITGsF1.js +0 -6
  133. package/dist/setup-m94dpT3t.js +0 -217
  134. package/dist/spawn-DmmmHIP-.js +0 -71
  135. package/dist/storage-pR0Wb0d9.js +0 -41
  136. package/dist/storekit-BMxyYAHj.js +0 -17
  137. package/dist/storekit-CQnwlpKV.js +0 -47
  138. package/dist/telemetry-DU56L7Cy.js +0 -56
  139. package/dist/theme-DUsCh-Vd.js +0 -25
  140. package/dist/token-BbUeExGJ.js +0 -70
  141. package/dist/upgrade-CKn88PZD.js +0 -206
  142. package/dist/upgrade-DfD3-ClG.js +0 -7
  143. /package/dist/{browser-Bp3yRKlU.js → browser-BVjaf98V.js} +0 -0
  144. /package/dist/{client-BJQXl62Q.js → client-BwYhzITp.js} +0 -0
  145. /package/dist/{design-lint-CiFc78aM.js → design-lint-mgO-2SGS.js} +0 -0
  146. /package/dist/{devtools-ByZ6XYnn.js → devtools-B6Vp6HMy.js} +0 -0
  147. /package/dist/{input-MDd67UIp.js → input-DOT_2Zvb.js} +0 -0
  148. /package/dist/{project-NoMtbMyl.js → project-BomArwSj.js} +0 -0
  149. /package/dist/{reports-HYVp169R.js → reports-hbxsd3Zo.js} +0 -0
  150. /package/dist/{storage-Bdz5AmqS.d.ts → storage-Bh3wT1Rn.d.ts} +0 -0
  151. /package/dist/{timing-Ca0TXY-A.js → timing-BKEEIBij.js} +0 -0
  152. /package/dist/{ui-D_qf3Gvw.js → ui-hFgji1e8.js} +0 -0
@@ -1,217 +0,0 @@
1
- import { i as readPackageJson, r as allDeps, t as scanProject } from "./scan-dv0rrY4C.js";
2
- import { t as detectExisting } from "./existing-WQ3pz94o.js";
3
- import { m as listProjects, p as listApplications, r as createApplication, y as platformLabel } from "./resources-DNwvf8rg.js";
4
- import { n as findApplication } from "./lookup-Dg55W9S7.js";
5
- import { r as resolveScopeFromKey } from "./bind-DcWIIPgk.js";
6
- import { d as writeApp } from "./lock-DgSx-p8Y.js";
7
- import { a as projectPackageName, i as requireApi, m as requirePlatform } from "./base-83ZTv6up.js";
8
- import { r as isSuperwallProject } from "./migration-BUedsREQ.js";
9
- import { n as gitAvailable } from "./source-BccdO4aL.js";
10
- import { execFile } from "node:child_process";
11
- import * as fs from "node:fs";
12
- import * as path from "node:path";
13
- import { promisify } from "node:util";
14
-
15
- //#region src/core/paywalls/project/setup.ts
16
- const run = promisify(execFile);
17
- const APP_PLATFORMS = [
18
- "ios",
19
- "android",
20
- "flutter",
21
- "react_native",
22
- "web"
23
- ];
24
- function alreadyAProject(root) {
25
- const target = path.join(root, "superwall");
26
- if (isSuperwallProject(target)) return `\`${target}\` is already a superwall project — run \`superwall dev\` to open it.`;
27
- 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.`;
28
- 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.`;
29
- const parsed = readPackageJson(root);
30
- if (parsed && "superwall" in allDeps(parsed)) return `\`${root}\` is already a superwall project — run \`superwall dev\` to open it.`;
31
- }
32
- const LOCKFILES = [
33
- ["bun.lock", "bun"],
34
- ["bun.lockb", "bun"],
35
- ["pnpm-lock.yaml", "pnpm"],
36
- ["yarn.lock", "yarn"],
37
- ["package-lock.json", "npm"]
38
- ];
39
- async function available(manager) {
40
- try {
41
- await run(manager, ["--version"], { shell: process.platform === "win32" });
42
- return true;
43
- } catch {
44
- return false;
45
- }
46
- }
47
- async function detectPackageManager(root) {
48
- const agent = process.env.npm_config_user_agent ?? "";
49
- const candidates = [
50
- ...LOCKFILES.filter(([file]) => fs.existsSync(path.join(root, file))).map(([, manager]) => manager),
51
- ...[
52
- "bun",
53
- "pnpm",
54
- "yarn",
55
- "npm"
56
- ].filter((manager) => agent.startsWith(manager)),
57
- "bun"
58
- ];
59
- for (const manager of candidates) if (await available(manager)) return manager;
60
- return "npm";
61
- }
62
- function devCommand(manager) {
63
- return manager === "npm" ? "npm run dev" : `${manager} dev`;
64
- }
65
- async function installDependencies(ui, target, manager) {
66
- const spin = ui.spinner();
67
- spin.start(`Installing dependencies with ${manager}`);
68
- try {
69
- await run(manager, ["install"], {
70
- cwd: target,
71
- shell: process.platform === "win32",
72
- timeout: 3e5
73
- });
74
- spin.stop("Dependencies installed");
75
- return true;
76
- } catch {
77
- spin.stop(`\`${manager} install\` failed — run it yourself in superwall/`);
78
- return false;
79
- }
80
- }
81
- async function initGit(ui, root) {
82
- if (!await gitAvailable()) return;
83
- if (await run("git", ["rev-parse", "--is-inside-work-tree"], { cwd: root }).then(() => true, () => false)) return;
84
- try {
85
- await run("git", ["init", "--quiet"], { cwd: root });
86
- await run("git", ["add", "-A"], { cwd: root });
87
- await run("git", [
88
- "commit",
89
- "--quiet",
90
- "-m",
91
- "New superwall project"
92
- ], { cwd: root });
93
- ui.step("Initialized a git repository");
94
- } catch {
95
- return;
96
- }
97
- }
98
- function humanName(root) {
99
- return projectPackageName(root).split(/[-_.]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
100
- }
101
- async function detectHostApp(root) {
102
- try {
103
- const app = (await scanProject(root)).apps[0];
104
- if (!app) return void 0;
105
- return {
106
- app,
107
- existing: detectExisting(app)
108
- };
109
- } catch {
110
- return;
111
- }
112
- }
113
- async function createAppFlow(ui, api, root) {
114
- const projects = await listProjects(api);
115
- const [first] = projects;
116
- if (first === void 0) {
117
- ui.warn("Your account has no projects yet — create one in the dashboard first.");
118
- return null;
119
- }
120
- let project = first;
121
- if (projects.length > 1) {
122
- const picked = await ui.select({
123
- message: "Which project does the app belong to?",
124
- options: projects.map((candidate) => ({
125
- value: String(candidate.id),
126
- label: candidate.name ?? String(candidate.id)
127
- }))
128
- });
129
- if (picked === null) return null;
130
- project = projects.find((candidate) => String(candidate.id) === picked) ?? project;
131
- }
132
- const name = await ui.text({
133
- message: "What is the app called?",
134
- initialValue: humanName(root),
135
- validate: (value) => value.trim() === "" ? "Give the app a name." : void 0
136
- });
137
- if (name === null) return null;
138
- const platform = await ui.select({
139
- message: "Which platform?",
140
- options: APP_PLATFORMS.map((value) => ({
141
- value,
142
- label: platformLabel(value)
143
- }))
144
- });
145
- if (platform === null) return null;
146
- const spin = ui.spinner();
147
- spin.start("Creating the app");
148
- const created = await createApplication(api, { projectId: String(project.id) }, {
149
- name: name.trim(),
150
- platform
151
- });
152
- spin.stop(`Created \`${name.trim()}\``);
153
- if (created.id === void 0) return null;
154
- return {
155
- id: created.id,
156
- name: name.trim(),
157
- platform
158
- };
159
- }
160
- async function connectApp(ui, interactive, root, target, detected, appId) {
161
- const api = await requireApi(interactive);
162
- if (appId !== void 0) {
163
- const app$1 = (await findApplication(api, appId))?.app;
164
- if (app$1 === void 0) throw new Error(`No app with id \`${appId}\` in this account — run \`superwall apps\` to list them.`);
165
- writeApp(target, requirePlatform(app$1), String(app$1.id));
166
- ui.success(`Pushes go to \`${app$1.name ?? app$1.id}\` — saved in superwall.lock, so commit that file.`);
167
- return;
168
- }
169
- if (detected?.existing.apiKey) {
170
- const scope = await resolveScopeFromKey(api, detected.existing.apiKey).catch(() => null);
171
- if (scope) {
172
- writeApp(target, requirePlatform((await listApplications(api).catch(() => [])).find((candidate) => String(candidate.id) === scope.applicationId) ?? { id: scope.applicationId }), scope.applicationId);
173
- ui.success(`\`${detected.app.name}\` is already on Superwall as \`${scope.appName ?? scope.applicationId}\` — pushes go there. Saved in superwall.lock; commit that file.`);
174
- return;
175
- }
176
- ui.info("Found a Superwall API key in the app, but no matching app in this account — pick one instead.");
177
- }
178
- const apps = await listApplications(api);
179
- let app = null;
180
- if (apps.length === 1 && apps[0] !== void 0) app = apps[0];
181
- else if (apps.length > 1) {
182
- if (!interactive) {
183
- ui.info("Several apps in your account — the first `superwall push` will ask which one.");
184
- return;
185
- }
186
- const picked = await ui.select({
187
- message: "Which app should these paywalls push to?",
188
- options: [...apps.map((candidate) => ({
189
- value: String(candidate.id),
190
- label: candidate.name ?? candidate.bundle_id ?? String(candidate.id),
191
- hint: platformLabel(candidate.platform)
192
- })), {
193
- value: "__new__",
194
- label: "Create a new app"
195
- }]
196
- });
197
- if (picked === null) return;
198
- app = picked === "__new__" ? await createAppFlow(ui, api, root) : apps.find((candidate) => String(candidate.id) === picked) ?? null;
199
- } else {
200
- if (!interactive) {
201
- ui.info("Your account has no apps yet — the first `superwall push` will set one up.");
202
- return;
203
- }
204
- app = await createAppFlow(ui, api, root);
205
- }
206
- if (app === null) return;
207
- writeApp(target, requirePlatform(app), String(app.id));
208
- ui.success(`Pushes go to \`${app.name ?? app.id}\` — saved in superwall.lock, so commit that file.`);
209
- }
210
- function uniqueSurfaceId(superwallDir, slug) {
211
- let candidate = slug;
212
- for (let n = 2; fs.existsSync(path.join(superwallDir, "paywalls", candidate)); n += 1) candidate = `${slug}-${n}`;
213
- return candidate;
214
- }
215
-
216
- //#endregion
217
- export { devCommand as a, uniqueSurfaceId as c, detectPackageManager as i, connectApp as n, initGit as o, detectHostApp as r, installDependencies as s, alreadyAProject as t };
@@ -1,71 +0,0 @@
1
- import { execFile, spawn } from "node:child_process";
2
- import { appendFileSync } from "node:fs";
3
- import { createInterface } from "node:readline";
4
- import { promisify } from "node:util";
5
-
6
- //#region src/core/workflows/agent/drivers/spawn.ts
7
- const execFileAsync = promisify(execFile);
8
- function writeTranscript(line) {
9
- const transcript = process.env.SW_BENCH_TRANSCRIPT;
10
- if (!transcript) return;
11
- try {
12
- appendFileSync(transcript, line + "\n");
13
- } catch {
14
- return;
15
- }
16
- }
17
- async function readVersion(bin) {
18
- try {
19
- const { stdout } = await execFileAsync(bin, ["--version"], { timeout: 5e3 });
20
- return stdout.trim().split("\n")[0];
21
- } catch {
22
- return;
23
- }
24
- }
25
- async function onPath(bin) {
26
- const probe = process.platform === "win32" ? "where" : "command";
27
- const args = process.platform === "win32" ? [bin] : ["-v", bin];
28
- try {
29
- await execFileAsync(probe, args, {
30
- timeout: 5e3,
31
- shell: process.platform !== "win32"
32
- });
33
- return true;
34
- } catch {
35
- return false;
36
- }
37
- }
38
- function spawnStream(opts) {
39
- return new Promise((resolve, reject) => {
40
- const child = spawn(opts.bin, opts.args, {
41
- cwd: opts.cwd,
42
- signal: opts.signal,
43
- stdio: [
44
- "ignore",
45
- "pipe",
46
- "pipe"
47
- ]
48
- });
49
- createInterface({ input: child.stdout }).on("line", (line) => {
50
- if (line.length) {
51
- writeTranscript(line);
52
- opts.onStdoutLine(line);
53
- }
54
- });
55
- const { onStderrLine } = opts;
56
- if (onStderrLine) createInterface({ input: child.stderr }).on("line", (line) => {
57
- if (line.length) onStderrLine(line);
58
- });
59
- child.on("error", (e) => {
60
- if (e.name === "AbortError") {
61
- resolve({ code: null });
62
- return;
63
- }
64
- reject(e);
65
- });
66
- child.on("close", (code) => resolve({ code }));
67
- });
68
- }
69
-
70
- //#endregion
71
- export { readVersion as n, spawnStream as r, onPath as t };
@@ -1,41 +0,0 @@
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-BFNzLLPN.js";
3
-
4
- //#region src/core/account/storage.ts
5
- const sessionOrgName = (session) => {
6
- return session?.authMethod === "api_key" ? session.orgName : void 0;
7
- };
8
- const FILE = "auth.json";
9
- const PENDING_FILE = "pending-login.json";
10
- function writePendingLogin(pending) {
11
- state().write(PENDING_FILE, `${formatJson(pending)}\n`);
12
- }
13
- function readPendingLogin() {
14
- return readJson(state(), PENDING_FILE) ?? null;
15
- }
16
- function removePendingLogin() {
17
- state().remove(PENDING_FILE);
18
- }
19
- function writeSession(session) {
20
- state().write(FILE, `${formatJson(session)}\n`);
21
- }
22
- function readSession() {
23
- return readJson(state(), FILE) ?? null;
24
- }
25
- function removeSession() {
26
- state().remove(FILE);
27
- }
28
- function resolveApiHost(session) {
29
- return API_HOST_OVERRIDE() ?? session.host ?? API_HOST();
30
- }
31
- function serializeSession(session) {
32
- return {
33
- authenticated: true,
34
- user: { email: session.userEmail ?? null },
35
- credential: { type: session.apiKey ? "api_key" : session.accessToken ? "oauth" : "unknown" },
36
- host: resolveApiHost(session)
37
- };
38
- }
39
-
40
- //#endregion
41
- export { resolveApiHost as a, writePendingLogin as c, removeSession as i, writeSession as l, readSession as n, serializeSession as o, removePendingLogin as r, sessionOrgName as s, readPendingLogin as t };
@@ -1,17 +0,0 @@
1
- import "./token-BbUeExGJ.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BFNzLLPN.js";
4
- import "./storage-pR0Wb0d9.js";
5
- import "./client-x08fpvay.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./spinner-IA6hV8nI.js";
8
- import "./ui-D_qf3Gvw.js";
9
- import "./orgs-1OzwUtpT.js";
10
- import "./resources-DNwvf8rg.js";
11
- import "./org-C4G7WjTV.js";
12
- import "./lookup-Dg55W9S7.js";
13
- import "./scope-BXoQo30_.js";
14
- import "./input-MDd67UIp.js";
15
- import { n as writeStoreKit, t as generateStoreKit } from "./storekit-CQnwlpKV.js";
16
-
17
- export { generateStoreKit, writeStoreKit };
@@ -1,47 +0,0 @@
1
- import { r as formatJson } from "./output-Ggzq5_-t.js";
2
- import { t as apiCall } from "./spinner-IA6hV8nI.js";
3
- import { h as listResource } from "./resources-DNwvf8rg.js";
4
- import { a as pickScope } from "./scope-BXoQo30_.js";
5
- import { r as textOf } from "./input-MDd67UIp.js";
6
- import { writeFileSync } from "node:fs";
7
-
8
- //#region src/core/main/storekit.ts
9
- async function writeStoreKit(context, api, out) {
10
- const scope = await pickScope(context, api, false);
11
- const products = await apiCall(context, "Loading products", () => listResource(api, "products", scope));
12
- const outFile = textOf(out) ?? "Superwall.storekit";
13
- writeFileSync(outFile, `${formatJson(generateStoreKit(products))}\n`);
14
- if (context.json) return context.output.data({
15
- path: outFile,
16
- products: products.length
17
- });
18
- context.ui.success(`Wrote \`${outFile}\` with ${products.length} product${products.length === 1 ? "" : "s"}`);
19
- }
20
- function generateStoreKit(products) {
21
- return {
22
- identifier: "SUPERWALL",
23
- nonRenewingSubscriptions: [],
24
- products: products.map((p) => String(p.identifier ?? p.product_identifier ?? p.name ?? "")).filter(Boolean).map((id, i) => ({
25
- displayPrice: "9.99",
26
- familyShareable: false,
27
- internalID: String(1e3 + i),
28
- localizations: [{
29
- description: id,
30
- displayName: id,
31
- locale: "en_US"
32
- }],
33
- productID: id,
34
- referenceName: id,
35
- type: "NonConsumable"
36
- })),
37
- settings: { _applicationInternalID: "SUPERWALL" },
38
- subscriptionGroups: [],
39
- version: {
40
- major: 3,
41
- minor: 0
42
- }
43
- };
44
- }
45
-
46
- //#endregion
47
- export { writeStoreKit as n, generateStoreKit as t };
@@ -1,56 +0,0 @@
1
- import { T as isNonInteractive, v as TELEMETRY_HOST, x as VERSION, y as TELEMETRY_KEY } from "./environment-BFNzLLPN.js";
2
- import { _ as writeTelemetryNoticeShown, t as readAnonymousId, u as telemetryNoticeShown } from "./config-CGcG7GOt.js";
3
-
4
- //#region src/core/support/telemetry.ts
5
- const tags = {};
6
- const pending = [];
7
- function updateTelemetryTags(next) {
8
- Object.assign(tags, next);
9
- }
10
- function isTelemetryEnabled(env, key) {
11
- return Boolean(key) && !env.DO_NOT_TRACK && !env.SUPERWALL_TELEMETRY_DISABLED && !env.NODE_TEST_CONTEXT;
12
- }
13
- function telemetryEnabled() {
14
- return isTelemetryEnabled(process.env, TELEMETRY_KEY());
15
- }
16
- function buildEvent(event, props, distinctId) {
17
- return {
18
- api_key: TELEMETRY_KEY(),
19
- event,
20
- distinct_id: distinctId,
21
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
22
- properties: {
23
- $process_person_profile: false,
24
- cli_version: VERSION,
25
- platform: process.platform,
26
- ci: process.env.CI === "true",
27
- interactive: !isNonInteractive(),
28
- ...tags,
29
- ...props
30
- }
31
- };
32
- }
33
- function track(event, props = {}) {
34
- if (!telemetryEnabled()) return;
35
- try {
36
- const payload = buildEvent(event, props, readAnonymousId());
37
- pending.push(fetch(`${TELEMETRY_HOST()}/capture/`, {
38
- method: "POST",
39
- headers: { "content-type": "application/json" },
40
- body: JSON.stringify(payload),
41
- signal: AbortSignal.timeout(1500)
42
- }).catch(() => {}));
43
- } catch {}
44
- }
45
- async function flushTelemetry(capMs = 2e3) {
46
- if (pending.length === 0) return;
47
- await Promise.race([Promise.allSettled(pending), new Promise((done) => setTimeout(done, capMs).unref())]);
48
- }
49
- function maybeShowTelemetryNotice(ui) {
50
- if (!telemetryEnabled() || telemetryNoticeShown()) return;
51
- writeTelemetryNoticeShown();
52
- ui.info("The CLI collects anonymous usage data - no personal data, ever (see the README). Opt out with `SUPERWALL_TELEMETRY_DISABLED=1`.");
53
- }
54
-
55
- //#endregion
56
- export { updateTelemetryTags as i, maybeShowTelemetryNotice as n, track as r, flushTelemetry as t };
@@ -1,25 +0,0 @@
1
- import pc from "picocolors";
2
-
3
- //#region src/ui/theme.ts
4
- const THEME = {
5
- primary: "#74FFF1",
6
- alert: "#E46671"
7
- };
8
- function hexToRgb(hex) {
9
- const h = hex.replace("#", "");
10
- const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
11
- const n = parseInt(full, 16);
12
- return [
13
- n >> 16 & 255,
14
- n >> 8 & 255,
15
- n & 255
16
- ];
17
- }
18
- function fg(hex, text) {
19
- if (!pc.isColorSupported) return text;
20
- const [r, g, b] = hexToRgb(hex);
21
- return `\x1b[38;2;${r};${g};${b}m${text}\x1b[39m`;
22
- }
23
-
24
- //#endregion
25
- export { fg as n, THEME as t };
@@ -1,70 +0,0 @@
1
- import { l as writeSession, n as readSession } from "./storage-pR0Wb0d9.js";
2
-
3
- //#region src/core/account/errors.ts
4
- var NotLoggedInError = class extends Error {
5
- constructor() {
6
- super("You aren't logged in. Run `superwall login` first.");
7
- this.name = "NotLoggedInError";
8
- }
9
- };
10
-
11
- //#endregion
12
- //#region src/core/account/token.ts
13
- const EXPIRY_SKEW_MS = 6e4;
14
- function accessTokenIsFresh(session) {
15
- return session.accessTokenExpiresAt !== void 0 && session.accessTokenExpiresAt - EXPIRY_SKEW_MS > Date.now();
16
- }
17
- async function refreshAccessToken(session) {
18
- if (!session.refreshToken || !session.tokenEndpoint || !session.oauthClientId) return null;
19
- try {
20
- const res = await fetch(session.tokenEndpoint, {
21
- method: "POST",
22
- headers: { "content-type": "application/x-www-form-urlencoded" },
23
- body: new URLSearchParams({
24
- grant_type: "refresh_token",
25
- refresh_token: session.refreshToken,
26
- client_id: session.oauthClientId
27
- })
28
- });
29
- if (!res.ok) return null;
30
- const d = await res.json();
31
- if (!d.access_token) return null;
32
- const updated = {
33
- ...session,
34
- accessToken: d.access_token,
35
- refreshToken: d.refresh_token ?? session.refreshToken,
36
- accessTokenExpiresAt: d.expires_in ? Date.now() + d.expires_in * 1e3 : void 0
37
- };
38
- writeSession(updated);
39
- return updated;
40
- } catch {
41
- return null;
42
- }
43
- }
44
- async function getOAuthAccessToken() {
45
- const session = readSession();
46
- if (!session?.accessToken || !session.refreshToken) return null;
47
- if (accessTokenIsFresh(session)) return session.accessToken;
48
- return (await refreshAccessToken(session))?.accessToken ?? null;
49
- }
50
- async function resolveAuthToken(session) {
51
- if (session.accessToken && session.refreshToken) {
52
- if (accessTokenIsFresh(session)) return {
53
- token: session.accessToken,
54
- session
55
- };
56
- const refreshed = await refreshAccessToken(session);
57
- if (refreshed) return {
58
- token: refreshed.accessToken,
59
- session: refreshed
60
- };
61
- }
62
- if (session.apiKey) return {
63
- token: session.apiKey,
64
- session
65
- };
66
- throw new NotLoggedInError();
67
- }
68
-
69
- //#endregion
70
- export { resolveAuthToken as n, NotLoggedInError as r, getOAuthAccessToken as t };