@superwall/cli 2.6.0-beta.1 → 2.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.
Files changed (147) hide show
  1. package/README.md +47 -16
  2. package/dist/{apple-Bmt_iywx.js → apple-D-rfsuDA.js} +17 -19
  3. package/dist/{approve-D2UgqaRx.js → approve-aPc5RoXB.js} +14 -13
  4. package/dist/{assets-B_quADds.js → assets-PyuXe45Y.js} +3 -3
  5. package/dist/auth.d.ts +11 -4
  6. package/dist/auth.js +4 -5
  7. package/dist/base-CAU0hWoI.js +82 -0
  8. package/dist/{billing-ZIETn0j4.js → billing-Dt6L_l9R.js} +3 -3
  9. package/dist/{build-BWjXurjs.js → build-CY5FnMNY.js} +35 -16
  10. package/dist/config-DOp5oChe.js +377 -0
  11. package/dist/{create-C3uklw-U.js → create-BZL5VH4L.js} +41 -41
  12. package/dist/{create-BCIgjRHn.js → create-D6w3UL0m.js} +9 -9
  13. package/dist/create-DM5Y1Pyk.js +18 -0
  14. package/dist/{doctor-D2Q1EZe8.js → doctor-C9FR0qw3.js} +50 -10
  15. package/dist/entry.js +45 -40
  16. package/dist/{environment-BocmdvZ-.js → environment-sE2wZYdg.js} +1 -1
  17. package/dist/{drivers-BQkO5tHs.js → existing--peXpOZj.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-Bykbwy-m.js → held-CUBCOCGP.js} +8 -8
  21. package/dist/held-DVxvPMSG.js +15 -0
  22. package/dist/{install-dXZZ79Oe.js → install-C5d82gZF.js} +15 -17
  23. package/dist/{integrate-DiSjlOjC.js → integrate-D8J_X1bj.js} +33 -38
  24. package/dist/{login-5sWIKDI2.js → login-C6X7JrhM.js} +8 -9
  25. package/dist/{login-Jp6E6d2e.js → login-DXhm9L0F.js} +3 -3
  26. package/dist/login-et319ESO.js +13 -0
  27. package/dist/{lookup-CWzVfPpq.js → lookup-DqmIbUkv.js} +28 -4
  28. package/dist/{migrate-BKiOUsMY.js → migrate-BYF6hKZ2.js} +66 -45
  29. package/dist/{notification-url-BDBxbwZq.js → notification-url-Bo54nkXv.js} +4 -4
  30. package/dist/{open-DNd49kT-.js → open-xdgXUzaF.js} +2 -2
  31. package/dist/{org-Dud1rF9f.js → org-BD8U3D1_.js} +4 -4
  32. package/dist/{organization-7vJA3uy1.js → organization-D-ZlB3qU.js} +4 -4
  33. package/dist/{orgs-Z0H9WOs1.js → orgs-DQQJ3sw_.js} +1 -2
  34. package/dist/{paths-CzTJVpfi.js → paths-CIlyzF2I.js} +1 -1
  35. package/dist/{playbook-DJ__edOW.js → playbook-ecggWGFi.js} +10 -14
  36. package/dist/{products-Cqq59DBQ.js → products-CJq_iXv5.js} +1 -1
  37. package/dist/{promote-DLtPSvmL.js → promote-QVMLGYlU.js} +27 -28
  38. package/dist/{pull-AoUmaiMK.js → pull-CCXhb2a7.js} +72 -26
  39. package/dist/{pull-D-YuT3e0.js → pull-CrdsfsAl.js} +33 -39
  40. package/dist/pull-h71pL3r_.js +30 -0
  41. package/dist/push-BIq6R8Ro.js +29 -0
  42. package/dist/push-D6pJM_vv.js +21 -0
  43. package/dist/{push-BMblzg_6.js → push-DJMGG7zW.js} +23 -12
  44. package/dist/{push-BrzMFd4Z.js → push-DiMDwGfe.js} +15 -8
  45. package/dist/{registry-DDU10_Ix.js → registry-BSnQXft4.js} +1288 -901
  46. package/dist/registry-YwzTfCNc.js +22 -0
  47. package/dist/{resolve-DpOSDDdr.js → resolve-DO7bPota.js} +52 -6
  48. package/dist/{resources-CptT7HD6.js → resources-XwvXA20E.js} +15 -2
  49. package/dist/{run-r3foWfhV.js → run-B-YvxfRc.js} +15 -17
  50. package/dist/scan-B36wkZmI.js +4 -0
  51. package/dist/{scan-nVQO7JLx.js → scan-ViBhmrB7.js} +1 -1
  52. package/dist/{scope-l1qGLsgz.js → scope-BLLUxbrA.js} +24 -18
  53. package/dist/{scope-ehZ7L1nj.js → scope-Cg1AdAfO.js} +33 -3
  54. package/dist/screenshot-file-Dix2Qynm.js +127 -0
  55. package/dist/{sdk-DEfQttek.js → sdk-BFunw4Hc.js} +1 -1
  56. package/dist/{framework-CLmf4swr.js → selection-C07e_GGY.js} +4 -54
  57. package/dist/{series-D2ZpZ8cx.js → series-B8NJK4yS.js} +1 -1
  58. package/dist/{server-DLARhh1k.js → server-CBtHzl9y.js} +40 -18
  59. package/dist/server-CZwSfzKe.js +33 -0
  60. package/dist/{base-ChTi42M0.js → session-BfVx50iA.js} +8 -83
  61. package/dist/{session-Z0BeaJPf.js → session-BlrwAdGN.js} +1 -1
  62. package/dist/session-Cip4j99n.js +5 -0
  63. package/dist/{migration-Z69tLeHC.js → setup-a4B72xJ8.js} +290 -28
  64. package/dist/skills/superwall/SKILL.md +37 -10
  65. package/dist/skills/superwall/references/api.md +66 -21
  66. package/dist/skills/superwall/references/asa.md +109 -64
  67. package/dist/skills/superwall/references/dashboard-links.md +65 -28
  68. package/dist/skills/superwall/references/data-analytics.md +1 -1
  69. package/dist/skills/superwall/workflows/dashboard/setup.md +15 -5
  70. package/dist/skills/superwall/workflows/integrate/flutter.md +9 -7
  71. package/dist/skills/superwall-artifacts/SKILL.md +7 -2
  72. package/dist/skills/superwall-artifacts/references/cli.md +4 -1
  73. package/dist/skills/superwall-framework/SKILL.md +197 -14
  74. package/dist/skills/superwall-framework/references/cli.md +98 -7
  75. package/dist/skills/superwall-framework/references/examples.md +2 -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-421SFEyF.js → skills-BB1uIt8t.js} +139 -9
  79. package/dist/{skills-CdKwaTRS.js → skills-SnxFa2in.js} +8 -12
  80. package/dist/source-DQs6iLtC.js +82 -0
  81. package/dist/{source-push-B4s6r9bB.js → source-push-w7miTr6m.js} +38 -14
  82. package/dist/{spinner-DPdBlZe2.js → spinner-BQp7fQvK.js} +7 -5
  83. package/dist/{starter-0OdVPH4l.js → starter-BlJ_InZJ.js} +16 -6
  84. package/dist/{status-Dsc7d3z2.js → status-DxsIw9zq.js} +9 -11
  85. package/dist/{output-Ggzq5_-t.js → storage-BR6imSqm.js} +40 -1
  86. package/dist/storekit-BqyujKQ_.js +203 -0
  87. package/dist/storekit-ELVCMF0X.js +15 -0
  88. package/dist/{bind-ClFjTt0U.js → theme-Ed0gz6hr.js} +29 -6
  89. package/dist/token-CWQ6tdva.js +100 -0
  90. package/dist/tools-skills/animate-onboarding/SKILL.md +1 -1
  91. package/dist/tools-skills/mobile-design/SKILL.md +1 -1
  92. package/dist/tools-skills/onboarding-questions/SKILL.md +1 -1
  93. package/dist/tools-skills/superwall/SKILL.md +43 -17
  94. package/dist/tools-skills/superwall/references/api.md +74 -24
  95. package/dist/tools-skills/superwall/references/asa.md +109 -64
  96. package/dist/tools-skills/superwall/references/dashboard-links.md +65 -28
  97. package/dist/tools-skills/superwall/references/data-analytics.md +1 -1
  98. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +4 -3
  99. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +21 -8
  100. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +9 -7
  101. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +4 -3
  102. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +2 -2
  103. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +4 -3
  104. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +4 -3
  105. package/dist/tools-skills/superwall-editor/SKILL.md +2 -3
  106. package/dist/tools.d.ts +6 -1
  107. package/dist/tools.js +1290 -747
  108. package/dist/{try-B8FYkTvQ.js → try-C3HW3hPZ.js} +20 -22
  109. package/dist/{lock-DgSx-p8Y.js → types-Dc9U_4kp.js} +86 -80
  110. package/dist/upgrade-Cw9jVt-r.js +348 -0
  111. package/dist/upgrade-DVsonzDF.js +27 -0
  112. package/package.json +11 -3
  113. package/dist/client-CyrYJzBF.js +0 -180
  114. package/dist/config-CGcG7GOt.js +0 -113
  115. package/dist/create-7HDW3DCl.js +0 -20
  116. package/dist/existing-Cl5x6_5u.js +0 -97
  117. package/dist/held-Chw3BtBV.js +0 -17
  118. package/dist/log-C0MDCfA2.js +0 -62
  119. package/dist/login-DZ8Pipf6.js +0 -17
  120. package/dist/pull-C1xm2zqG.js +0 -36
  121. package/dist/push-B42D8fKf.js +0 -22
  122. package/dist/push-Co5jk6Kr.js +0 -30
  123. package/dist/run-c1O2_8pp.js +0 -100
  124. package/dist/scan-D86kLtM7.js +0 -4
  125. package/dist/screenshot-file-XAS0Xy0e.js +0 -16
  126. package/dist/server-BEcsQaPu.js +0 -29
  127. package/dist/session-Csuaw6RU.js +0 -6
  128. package/dist/setup-C6NFy14d.js +0 -217
  129. package/dist/spawn-DmmmHIP-.js +0 -71
  130. package/dist/storage-DT_wxwJ8.js +0 -41
  131. package/dist/storekit-B9M2raxe.js +0 -47
  132. package/dist/storekit-BWZf-fNE.js +0 -17
  133. package/dist/telemetry-ovPiseFm.js +0 -56
  134. package/dist/theme-DUsCh-Vd.js +0 -25
  135. package/dist/token-Bu3FaRkv.js +0 -70
  136. package/dist/upgrade-B7TmvEPP.js +0 -206
  137. package/dist/upgrade-CAHyrWUL.js +0 -7
  138. /package/dist/{browser-Bp3yRKlU.js → browser-BVjaf98V.js} +0 -0
  139. /package/dist/{client-BJQXl62Q.js → client-BwYhzITp.js} +0 -0
  140. /package/dist/{design-lint-CiFc78aM.js → design-lint-mgO-2SGS.js} +0 -0
  141. /package/dist/{devtools-ByZ6XYnn.js → devtools-B6Vp6HMy.js} +0 -0
  142. /package/dist/{input-MDd67UIp.js → input-DOT_2Zvb.js} +0 -0
  143. /package/dist/{project-NoMtbMyl.js → project-BomArwSj.js} +0 -0
  144. /package/dist/{reports-HYVp169R.js → reports-hbxsd3Zo.js} +0 -0
  145. /package/dist/{storage-Bdz5AmqS.d.ts → storage-Bh3wT1Rn.d.ts} +0 -0
  146. /package/dist/{timing-Ca0TXY-A.js → timing-BKEEIBij.js} +0 -0
  147. /package/dist/{ui-D_qf3Gvw.js → ui-hFgji1e8.js} +0 -0
@@ -1,100 +0,0 @@
1
- import { d as DASHBOARD_URL } from "./environment-BocmdvZ-.js";
2
- import { i as packagedDir } from "./paths-CzTJVpfi.js";
3
- import { spawn } from "node:child_process";
4
- import { readFileSync } from "node:fs";
5
- import { join } from "node:path";
6
-
7
- //#region src/ui/clipboard.ts
8
- async function copyToClipboard(text) {
9
- const cmd = resolveClipboardCommand();
10
- return new Promise((resolve$1) => {
11
- try {
12
- const child = spawn(cmd.command, cmd.args, { stdio: [
13
- "pipe",
14
- "ignore",
15
- "ignore"
16
- ] });
17
- child.on("error", () => resolve$1(false));
18
- child.on("close", (code) => resolve$1(code === 0));
19
- child.stdin.on("error", () => resolve$1(false));
20
- child.stdin.write(text);
21
- child.stdin.end();
22
- } catch {
23
- resolve$1(false);
24
- }
25
- });
26
- }
27
- function resolveClipboardCommand() {
28
- switch (process.platform) {
29
- case "darwin": return {
30
- command: "pbcopy",
31
- args: []
32
- };
33
- case "win32": return {
34
- command: "clip",
35
- args: []
36
- };
37
- default: return {
38
- command: "xclip",
39
- args: ["-selection", "clipboard"]
40
- };
41
- }
42
- }
43
-
44
- //#endregion
45
- //#region src/core/workflows/agent/prompt.ts
46
- const cache = /* @__PURE__ */ new Map();
47
- function readPrompt(rel, vars = {}) {
48
- let raw = cache.get(rel);
49
- if (raw === void 0) {
50
- raw = readFileSync(join(packagedDir("prompts"), rel), "utf8");
51
- cache.set(rel, raw);
52
- }
53
- return raw.replace(/\{\{#(\w+)\}\}([\s\S]*?)\{\{\/\1\}\}/g, (_m, key, body) => vars[key] ? body : "").replace(/\{\{(\w+)\}\}/g, (_m, key) => {
54
- const value = vars[key];
55
- if (value === void 0) throw new Error(`Missing prompt variable "${key}" in ${rel}`);
56
- return value;
57
- }).replace(/\n{3,}/g, "\n\n").trim();
58
- }
59
- function readCommandments() {
60
- return readPrompt("commandments.xml");
61
- }
62
- function buildActionPrompt(action, ctx) {
63
- return `${readPrompt("context.xml", {
64
- platform: `${ctx.app.framework.name}${ctx.app.details ? ` (${ctx.app.details})` : ""}`,
65
- app_dir: ctx.app.path,
66
- api_key: ctx.apiKey || "(not provided)",
67
- sdk_installed: ctx.existing.sdkInstalled ? "yes" : "no",
68
- configure_present: ctx.existing.configureFound ? "yes" : "no",
69
- docs_url: ctx.app.framework.docsUrl,
70
- dashboard_url: DASHBOARD_URL
71
- })}\n\n${readPrompt(`actions/${action.id}.xml`, action.vars(ctx))}`;
72
- }
73
- function buildCopyPrompt(action, ctx) {
74
- return buildActionPrompt(action, ctx).split("\n").filter((line) => !line.includes("[STATUS]")).join("\n").trimEnd();
75
- }
76
-
77
- //#endregion
78
- //#region src/core/workflows/agent/run.ts
79
- async function runAction(opts) {
80
- return runWithDriverFallback([opts.driver, ...opts.fallbackDrivers ?? []], {
81
- prompt: buildActionPrompt(opts.action, opts.ctx),
82
- cwd: opts.ctx.app.path,
83
- systemAppend: readCommandments(),
84
- capabilities: opts.action.capabilities,
85
- onEvent: opts.onEvent,
86
- signal: opts.signal
87
- });
88
- }
89
- async function runWithDriverFallback(drivers, options) {
90
- if (drivers.length === 0) throw new Error("No agent driver available.");
91
- let result = { ok: false };
92
- for (const driver of drivers) {
93
- result = await driver.run(options);
94
- if (result.ok || result.failureReason !== "usage-limit") return result;
95
- }
96
- return result;
97
- }
98
-
99
- //#endregion
100
- export { copyToClipboard as a, readPrompt as i, runWithDriverFallback as n, buildCopyPrompt as r, runAction as t };
@@ -1,4 +0,0 @@
1
- import "./environment-BocmdvZ-.js";
2
- import { t as scanProject } from "./scan-nVQO7JLx.js";
3
-
4
- export { scanProject };
@@ -1,16 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { basename } from "node:path";
3
- import { createHash } from "node:crypto";
4
-
5
- //#region src/core/app-store-connect/resources/screenshot-file.ts
6
- function readScreenshotFile(path) {
7
- const bytes = new Uint8Array(readFileSync(path));
8
- return {
9
- name: basename(path),
10
- bytes,
11
- checksum: createHash("md5").update(bytes).digest("hex")
12
- };
13
- }
14
-
15
- //#endregion
16
- export { readScreenshotFile };
@@ -1,29 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./telemetry-ovPiseFm.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-DPdBlZe2.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./scan-nVQO7JLx.js";
12
- import "./paths-CzTJVpfi.js";
13
- import "./orgs-Z0H9WOs1.js";
14
- import "./resources-CptT7HD6.js";
15
- import "./lookup-CWzVfPpq.js";
16
- import "./login-5sWIKDI2.js";
17
- import "./skills-421SFEyF.js";
18
- import "./browser-Bp3yRKlU.js";
19
- import "./lock-DgSx-p8Y.js";
20
- import "./scope-ehZ7L1nj.js";
21
- import "./base-ChTi42M0.js";
22
- import "./framework-CLmf4swr.js";
23
- import "./login-Jp6E6d2e.js";
24
- import "./source-BccdO4aL.js";
25
- import "./assets-B_quADds.js";
26
- import "./source-push-B4s6r9bB.js";
27
- import { t as runStudio } from "./server-DLARhh1k.js";
28
-
29
- export { runStudio };
@@ -1,6 +0,0 @@
1
- import "./output-Ggzq5_-t.js";
2
- import "./environment-BocmdvZ-.js";
3
- import "./storage-DT_wxwJ8.js";
4
- import { n as runWhoami, t as runLogout } from "./session-Z0BeaJPf.js";
5
-
6
- export { runLogout, runWhoami };
@@ -1,217 +0,0 @@
1
- import { i as readPackageJson, r as allDeps, t as scanProject } from "./scan-nVQO7JLx.js";
2
- import { t as detectExisting } from "./existing-Cl5x6_5u.js";
3
- import { m as listProjects, p as listApplications, r as createApplication, y as platformLabel } from "./resources-CptT7HD6.js";
4
- import { n as findApplication } from "./lookup-CWzVfPpq.js";
5
- import { r as resolveScopeFromKey } from "./bind-ClFjTt0U.js";
6
- import { d as writeApp } from "./lock-DgSx-p8Y.js";
7
- import { a as projectPackageName, i as requireApi, m as requirePlatform } from "./base-ChTi42M0.js";
8
- import { r as isSuperwallProject } from "./migration-Z69tLeHC.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-BocmdvZ-.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,47 +0,0 @@
1
- import { r as formatJson } from "./output-Ggzq5_-t.js";
2
- import { t as apiCall } from "./spinner-DPdBlZe2.js";
3
- import { h as listResource } from "./resources-CptT7HD6.js";
4
- import { a as pickScope } from "./scope-l1qGLsgz.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,17 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./spinner-DPdBlZe2.js";
8
- import "./ui-D_qf3Gvw.js";
9
- import "./orgs-Z0H9WOs1.js";
10
- import "./resources-CptT7HD6.js";
11
- import "./org-Dud1rF9f.js";
12
- import "./lookup-CWzVfPpq.js";
13
- import "./scope-l1qGLsgz.js";
14
- import "./input-MDd67UIp.js";
15
- import { n as writeStoreKit, t as generateStoreKit } from "./storekit-B9M2raxe.js";
16
-
17
- export { generateStoreKit, writeStoreKit };
@@ -1,56 +0,0 @@
1
- import { T as isNonInteractive, v as TELEMETRY_HOST, x as VERSION, y as TELEMETRY_KEY } from "./environment-BocmdvZ-.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 };