@superwall/cli 2.3.1 → 2.5.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 (117) hide show
  1. package/README.md +10 -0
  2. package/dist/{apple-z2qjOzIZ.js → apple-Dyr7OFBx.js} +17 -16
  3. package/dist/approve-Czs1-JO9.js +186 -0
  4. package/dist/{assets-DXXegdDt.js → assets-BrB9jQPQ.js} +3 -3
  5. package/dist/auth.d.ts +1 -1
  6. package/dist/auth.js +3 -3
  7. package/dist/{billing-B8tOjsnY.js → billing-D5qqIlVb.js} +3 -3
  8. package/dist/{bind-Bx9K6LwP.js → bind-B3eEcRyp.js} +4 -4
  9. package/dist/browser-Bp3yRKlU.js +36 -0
  10. package/dist/{build-Bu2kkzRe.js → build-DD9pSwHX.js} +10 -8
  11. package/dist/{client-DOgk9gAS.js → client-AI9H4GGB.js} +3 -3
  12. package/dist/{config-BO1Y87kV.js → config-CGcG7GOt.js} +9 -1
  13. package/dist/{create-B03MAuPe.js → create-B4m-IKlr.js} +8 -8
  14. package/dist/create-CJljlkJK.js +20 -0
  15. package/dist/{create-DzC_89gq.js → create-ChfgWpiM.js} +41 -69
  16. package/dist/{doctor-BGZSKY_B.js → doctor-XtXW6tKE.js} +6 -6
  17. package/dist/download-2Zu2I_Og.js +58 -0
  18. package/dist/{drivers-DqLgQxkC.js → drivers-CMEL13gp.js} +4 -4
  19. package/dist/entry.js +69 -33
  20. package/dist/{environment-i8BhiBDB.js → environment-BWT2S4qC.js} +9 -2
  21. package/dist/{existing-BPOG5zLO.js → existing-b0GxFcnc.js} +2 -2
  22. package/dist/{session-BDLQUJyV.js → git-D7AVdugb.js} +97 -335
  23. package/dist/held-CX7Zf8u-.js +17 -0
  24. package/dist/{held-C56PYMRH.js → held-D3PUNky2.js} +7 -7
  25. package/dist/install-CVUXsx8c.js +103 -0
  26. package/dist/{integrate-DZ4Qvoch.js → integrate-qvKd9pVW.js} +29 -27
  27. package/dist/{log-NVhVe_oe.js → log-C0MDCfA2.js} +1 -1
  28. package/dist/{login-p9GVEKzD.js → login-COmGHrU5.js} +2 -1
  29. package/dist/login-ClnJi1Ea.js +17 -0
  30. package/dist/{login-ONZdK8vN.js → login-PMoXUGqq.js} +9 -42
  31. package/dist/{lookup-flTi0at0.js → lookup-gjcKIZvh.js} +4 -3
  32. package/dist/{migrate-DnXpbhL1.js → migrate-SkkLLdmr.js} +33 -28
  33. package/dist/{migration-DJ1uNKhk.js → migration-DS44-3Zr.js} +10 -10
  34. package/dist/{notification-url-CCDeS5S-.js → notification-url-BjQPLf4-.js} +4 -4
  35. package/dist/{open-QdsZ_N47.js → open-DQpm2yVs.js} +2 -2
  36. package/dist/{org-BiFPjoHD.js → org-C04eAO-j.js} +3 -2
  37. package/dist/organization-BOECL3vZ.js +39 -0
  38. package/dist/orgs-D6Kk96mG.js +81 -0
  39. package/dist/{paths-yRgm5Jpa.js → paths-REb-GrbX.js} +2 -2
  40. package/dist/{playbook-B-pRKNa4.js → playbook-Du4Oydbf.js} +11 -11
  41. package/dist/{products-DH_fK9tY.js → products-Cqq59DBQ.js} +1 -1
  42. package/dist/project-CP6hiHra.js +47 -0
  43. package/dist/{promote-Djzk4C81.js → promote-Dm2_b1WK.js} +24 -19
  44. package/dist/pull-DsdOoG-D.js +36 -0
  45. package/dist/{pull-BLA9XwHj.js → pull-F6pvO4To.js} +9 -28
  46. package/dist/pull-zYAbqo9n.js +106 -0
  47. package/dist/{push-gSBxGDik.js → push-BIFLhAiO.js} +9 -7
  48. package/dist/push-CJVfvFZq.js +29 -0
  49. package/dist/push-D_l9KJZN.js +290 -0
  50. package/dist/push-SVzv7fzE.js +22 -0
  51. package/dist/{registry-D3xmWk9p.js → registry-DIJB0mJa.js} +890 -158
  52. package/dist/resolve--GsHj0Q1.js +171 -0
  53. package/dist/{resources-BTnczJCA.js → resources-BaP3p_LY.js} +3 -80
  54. package/dist/{run-C1SoizcJ.js → run-C5OPwhvS.js} +2 -2
  55. package/dist/run-CgLmD2vR.js +1345 -0
  56. package/dist/{scan-Dwk_lT5q.js → scan-Bj5y0zTZ.js} +1 -1
  57. package/dist/scan-v_WTE722.js +4 -0
  58. package/dist/{scope-Db7blD-l.js → scope-Bp_zwJOo.js} +6 -5
  59. package/dist/scope-CCb_7UvN.js +89 -0
  60. package/dist/sdk-TvT0p_nO.js +71 -0
  61. package/dist/selection-BltBpyp5.js +179 -0
  62. package/dist/series-TAixFBWW.js +685 -0
  63. package/dist/{server-Cb2N75JL.js → server-CdVIboQn.js} +10 -8
  64. package/dist/server-CvJVusw3.js +29 -0
  65. package/dist/session-B8JNXkwN.js +6 -0
  66. package/dist/session-D3fgXQBt.js +219 -0
  67. package/dist/{session-CnDJp_HO.js → session-Ywim-P8M.js} +1 -1
  68. package/dist/{setup-BLahHpgy.js → setup-zzjtTy8k.js} +9 -8
  69. package/dist/skills/index.json +5 -0
  70. package/dist/skills/superwall/SKILL.md +48 -30
  71. package/dist/skills/superwall/references/api.md +3 -2
  72. package/dist/skills/superwall-editor/SKILL.md +7 -5
  73. package/dist/skills/superwall-framework/SKILL.md +11 -8
  74. package/dist/skills/superwall-framework/references/onboarding-state.md +21 -14
  75. package/dist/skills/superwall-workspaces/SKILL.md +313 -0
  76. package/dist/skills/superwall-workspaces/references/cli.md +174 -0
  77. package/dist/skills/superwall-workspaces/references/slots.md +103 -0
  78. package/dist/{skills-zebMTZyr.js → skills-2qYaUXGE.js} +15 -9
  79. package/dist/skills-8um2fBPS.js +14 -0
  80. package/dist/{source-push-DxuJuwEf.js → source-push-kAep4gPe.js} +6 -5
  81. package/dist/{spinner-BN3U1CVB.js → spinner-BANVLncC.js} +17 -5
  82. package/dist/starter-CiLrp1cN.js +190 -0
  83. package/dist/status-CoYMK7QL.js +139 -0
  84. package/dist/{storage-VagEaaJC.js → storage-DzP22xKn.js} +1 -1
  85. package/dist/storekit-D5eopLM0.js +17 -0
  86. package/dist/{storekit-CoOf4Rvh.js → storekit-n1x0bWkQ.js} +4 -4
  87. package/dist/{telemetry-CM0BDwCK.js → telemetry-CXN6f-ZX.js} +2 -2
  88. package/dist/{token-lUUOkTJA.js → token-FmeHywYt.js} +1 -1
  89. package/dist/tools-skills/superwall/SKILL.md +49 -31
  90. package/dist/tools-skills/superwall/references/api.md +3 -2
  91. package/dist/tools-skills/superwall-editor/SKILL.md +7 -5
  92. package/dist/tools.d.ts +1 -1
  93. package/dist/tools.js +575 -75
  94. package/dist/try-BWbzgelb.js +120 -0
  95. package/dist/{selection-u2KiKu_d.js → types-JdxmnCko.js} +1 -178
  96. package/dist/upgrade-Bk5boOgW.js +206 -0
  97. package/dist/upgrade-CoWCEnoi.js +7 -0
  98. package/package.json +5 -3
  99. package/prompts/commandments.xml +2 -0
  100. package/dist/create-BdZS_T68.js +0 -19
  101. package/dist/held-DSNUY-NZ.js +0 -16
  102. package/dist/login-Blrkm6oi.js +0 -16
  103. package/dist/push-BkMgOT6X.js +0 -24
  104. package/dist/scan-Kp-MAutK.js +0 -4
  105. package/dist/server-psYghr9K.js +0 -24
  106. package/dist/session-CehHJWZk.js +0 -6
  107. package/dist/skills-DDV4zcLR.js +0 -14
  108. package/dist/storekit-BcBb2jXB.js +0 -16
  109. package/dist/upgrade-CpTJv_M7.js +0 -7
  110. package/dist/upgrade-DZbKb67W.js +0 -117
  111. /package/dist/{client-BZ1UbpXz.js → client-BJQXl62Q.js} +0 -0
  112. /package/dist/{devtools-pBl_vt03.js → devtools-ByZ6XYnn.js} +0 -0
  113. /package/dist/{input-vi0bou04.js → input-MDd67UIp.js} +0 -0
  114. /package/dist/{reports-CwwKLUh0.js → reports-CuhB1_ub.js} +0 -0
  115. /package/dist/{screenshot-file-tVBfUEIi.js → screenshot-file-XAS0Xy0e.js} +0 -0
  116. /package/dist/{storage-gRyQetN9.d.ts → storage-BjQCiTuz.d.ts} +0 -0
  117. /package/dist/{timing-BVxPrYq3.js → timing-Ca0TXY-A.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { f as Integration } from "./environment-i8BhiBDB.js";
1
+ import { h as Integration } from "./environment-BWT2S4qC.js";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { basename, dirname, join, relative, sep } from "node:path";
4
4
  import fg from "fast-glob";
@@ -0,0 +1,4 @@
1
+ import "./environment-BWT2S4qC.js";
2
+ import { t as scanProject } from "./scan-Bj5y0zTZ.js";
3
+
4
+ export { scanProject };
@@ -1,8 +1,9 @@
1
- import { n as readDefaultApp, u as writeDefaultApp } from "./config-BO1Y87kV.js";
2
- import { t as apiCall, u as currentHost } from "./spinner-BN3U1CVB.js";
3
- import { F as orgIdOf, L as organizationOf, N as listOrgGroups, l as findPaywall, m as listProjects, y as platformLabel } from "./resources-BTnczJCA.js";
4
- import { t as chooseOrgOfApps } from "./org-BiFPjoHD.js";
5
- import { n as findApplication, r as findProject, t as appNotFound } from "./lookup-flTi0at0.js";
1
+ import { f as writeDefaultApp, r as readDefaultApp } from "./config-CGcG7GOt.js";
2
+ import { t as apiCall, u as currentHost } from "./spinner-BANVLncC.js";
3
+ import { i as orgIdOf, o as organizationOf, t as listOrgGroups } from "./orgs-D6Kk96mG.js";
4
+ import { l as findPaywall, m as listProjects, y as platformLabel } from "./resources-BaP3p_LY.js";
5
+ import { t as chooseOrgOfApps } from "./org-C04eAO-j.js";
6
+ import { n as findApplication, r as findProject, t as appNotFound } from "./lookup-gjcKIZvh.js";
6
7
 
7
8
  //#region src/core/account/scope.ts
8
9
  function moveFirst(items, match) {
@@ -0,0 +1,89 @@
1
+ import { i as NewerLockError, l as originKey, o as formatLock, t as TYPES_FILE, u as parseLock } from "./types-JdxmnCko.js";
2
+
3
+ //#region src/core/paywalls/source/scope.ts
4
+ const LOCK_FILE = "superwall.lock";
5
+ const WORKSPACE_FILE = "superwall.workspace.json";
6
+ const DERIVED_FILES = new Set([LOCK_FILE, TYPES_FILE]);
7
+ const WORKSPACE_DERIVED_FILES = new Set([WORKSPACE_FILE]);
8
+ const derivedFilesOf = (scope) => scope.kind === "workspace" ? WORKSPACE_DERIVED_FILES : DERIVED_FILES;
9
+ const SURFACE_DIRS = {
10
+ paywalls: "paywall",
11
+ funnels: "funnel"
12
+ };
13
+ function surfaceOf(relative) {
14
+ const [top, id, ...rest] = relative.split("/");
15
+ const kind = top === void 0 ? void 0 : SURFACE_DIRS[top];
16
+ if (!kind || !id || rest.length === 0) return void 0;
17
+ return {
18
+ kind,
19
+ id
20
+ };
21
+ }
22
+ function classifyPath(relative, scope) {
23
+ if (derivedFilesOf(scope).has(relative)) return "derived";
24
+ if (scope.kind === "workspace") return "own";
25
+ const surface = surfaceOf(relative);
26
+ if (!surface) return "shared";
27
+ return surface.kind === scope.kind && surface.id === scope.id ? "own" : "other";
28
+ }
29
+ const isSurfaceRoot = (top, scope) => scope?.kind !== "workspace" && SURFACE_DIRS[top] !== void 0;
30
+ const isOtherSurfaceDir = (top, child, scope) => {
31
+ if (scope.kind === "workspace") return false;
32
+ const kind = SURFACE_DIRS[top];
33
+ return kind !== void 0 && !(kind === scope.kind && child === scope.id);
34
+ };
35
+ var SourceLockUnreadableError = class extends Error {
36
+ constructor(reason) {
37
+ super(`The source repo's superwall.lock can't be read (${reason}), so its bindings for other paywalls can't be kept. Rerun with --overwrite-source to replace it with yours.`);
38
+ }
39
+ };
40
+ const readable = (text) => {
41
+ try {
42
+ return { lock: parseLock(text, LOCK_FILE) };
43
+ } catch (error) {
44
+ if (error instanceof NewerLockError) throw error;
45
+ return { reason: error instanceof Error ? error.message : String(error) };
46
+ }
47
+ };
48
+ function mergeLockText(theirs, mine, scope, options = {}) {
49
+ const own = readable(mine);
50
+ if (!("lock" in own)) return mine;
51
+ if (theirs === void 0) return formatLock(withoutSources(own.lock));
52
+ const read = readable(theirs);
53
+ if (!("lock" in read)) {
54
+ if (!options.replaceUnreadable) throw new SourceLockUnreadableError(read.reason);
55
+ return formatLock(withoutSources(own.lock));
56
+ }
57
+ return mergeLocks(read.lock, own.lock, scope);
58
+ }
59
+ function mergeLocks(other, own, scope) {
60
+ const section = (lock) => scope.kind === "paywall" ? lock.paywalls : lock.funnels;
61
+ const conflicting = new Set(Object.entries(own.apps).filter(([platform, app]) => other.apps[platform] !== void 0 && other.apps[platform] !== app).map(([platform]) => platform));
62
+ const ownApps = Object.fromEntries(Object.entries(own.apps).filter(([platform]) => !conflicting.has(platform)));
63
+ const merged = {
64
+ version: 1,
65
+ apps: {
66
+ ...other.apps,
67
+ ...ownApps
68
+ },
69
+ paywalls: { ...other.paywalls },
70
+ funnels: { ...other.funnels }
71
+ };
72
+ const target = section(merged);
73
+ const theirEntry = section(other)[scope.id] ?? {};
74
+ const mineEntry = section(own)[scope.id] ?? {};
75
+ const entry = Object.fromEntries([...Object.entries(theirEntry).filter(([platform]) => conflicting.has(platform)), ...Object.entries(mineEntry).filter(([platform]) => !conflicting.has(platform))]);
76
+ if (Object.keys(entry).length > 0) target[scope.id] = entry;
77
+ else delete target[scope.id];
78
+ const key = originKey(scope.kind, scope.id);
79
+ const origins = { ...other.origins };
80
+ const mineOrigin = own.origins?.[key];
81
+ if (mineOrigin) origins[key] = mineOrigin;
82
+ else delete origins[key];
83
+ if (Object.keys(origins).length > 0) merged.origins = origins;
84
+ return formatLock(merged);
85
+ }
86
+ const withoutSources = ({ sources: _,...lock }) => lock;
87
+
88
+ //#endregion
89
+ export { classifyPath as a, isSurfaceRoot as c, WORKSPACE_FILE as i, mergeLockText as l, LOCK_FILE as n, derivedFilesOf as o, WORKSPACE_DERIVED_FILES as r, isOtherSurfaceDir as s, DERIVED_FILES as t };
@@ -0,0 +1,71 @@
1
+ import { n as PUBLIC_REPO, t as PUBLIC_REF } from "./download-2Zu2I_Og.js";
2
+ import { n as VENDORED_SDK } from "./project-CP6hiHra.js";
3
+ import * as fs from "node:fs";
4
+ import * as path from "node:path";
5
+
6
+ //#region src/core/workspaces/sdk.ts
7
+ const STARTER_DIR = "workspaces/starter";
8
+ const LATEST_TIMEOUT_MS = 1500;
9
+ const LATEST_URL = () => `https://raw.githubusercontent.com/${PUBLIC_REPO}/${PUBLIC_REF}/${STARTER_DIR}/vendor/workspace-sdk/package.json`;
10
+ function versionOf(manifest) {
11
+ const version = manifest?.version;
12
+ return typeof version === "string" ? version : void 0;
13
+ }
14
+ function vendoredVersion(root) {
15
+ try {
16
+ return versionOf(JSON.parse(fs.readFileSync(path.join(root, VENDORED_SDK, "package.json"), "utf8")));
17
+ } catch {
18
+ return;
19
+ }
20
+ }
21
+ async function latestVersion(fetchImpl = fetch) {
22
+ try {
23
+ const response = await fetchImpl(LATEST_URL(), { signal: AbortSignal.timeout(LATEST_TIMEOUT_MS) });
24
+ return response.ok ? versionOf(await response.json()) : void 0;
25
+ } catch {
26
+ return;
27
+ }
28
+ }
29
+ function compareIdentifiers(a, b) {
30
+ const [x, y] = [Number(a), Number(b)];
31
+ const [xNumeric, yNumeric] = [/^\d+$/.test(a), /^\d+$/.test(b)];
32
+ if (xNumeric && yNumeric) return x - y;
33
+ if (xNumeric !== yNumeric) return xNumeric ? -1 : 1;
34
+ return a < b ? -1 : a > b ? 1 : 0;
35
+ }
36
+ function compareVersions(a, b) {
37
+ const parse = (version) => {
38
+ const [core = "", ...pre] = version.split("+")[0].split("-");
39
+ return {
40
+ core: core.split(".").map(Number),
41
+ pre: pre.join("-").split(".").filter(Boolean)
42
+ };
43
+ };
44
+ const [left, right] = [parse(a), parse(b)];
45
+ for (let index = 0; index < 3; index += 1) {
46
+ const difference = (left.core[index] ?? 0) - (right.core[index] ?? 0);
47
+ if (difference !== 0) return difference;
48
+ }
49
+ if (left.pre.length === 0 || right.pre.length === 0) return right.pre.length - left.pre.length;
50
+ for (let index = 0; index < Math.max(left.pre.length, right.pre.length); index += 1) {
51
+ const [x, y] = [left.pre[index], right.pre[index]];
52
+ if (x === void 0) return -1;
53
+ if (y === void 0) return 1;
54
+ const difference = compareIdentifiers(x, y);
55
+ if (difference !== 0) return difference;
56
+ }
57
+ return 0;
58
+ }
59
+ const isBehind = (current, latest) => compareVersions(current, latest) < 0;
60
+ async function warnIfSdkBehind(ui, root, fetchImpl) {
61
+ const current = vendoredVersion(root);
62
+ if (current === void 0) {
63
+ ui.warn("This workspace has no vendored SDK package. Run `superwall workspaces update` to add it.");
64
+ return;
65
+ }
66
+ const latest = await latestVersion(fetchImpl);
67
+ if (latest !== void 0 && isBehind(current, latest)) ui.warn(`Its workspace SDK is ${current}, and ${latest} is out. Run \`superwall workspaces update\` to get it.`);
68
+ }
69
+
70
+ //#endregion
71
+ export { warnIfSdkBehind as i, compareVersions as n, vendoredVersion as r, STARTER_DIR as t };
@@ -0,0 +1,179 @@
1
+ import { n as billingPlanOf } from "./resources-BaP3p_LY.js";
2
+ import { createRequire } from "node:module";
3
+ import { globSync, readFileSync, statSync } from "node:fs";
4
+ import { join, resolve } from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ import pc from "picocolors";
7
+
8
+ //#region src/core/paywalls/project/framework.ts
9
+ var FrameworkNotFoundError = class extends Error {
10
+ constructor(dir) {
11
+ super(`No superwall framework found from ${dir}.\nInstall it in the project (\`npm i superwall\` / \`bun add superwall\`) and make sure you run this inside a project with a superwall/ directory.`);
12
+ }
13
+ };
14
+ async function importSubpath(packageDir, subpath) {
15
+ return import(pathToFileURL(createRequire(join(packageDir, "package.json")).resolve(subpath)).href);
16
+ }
17
+ function fn(mod, name, subpath) {
18
+ const candidate = mod[name];
19
+ if (typeof candidate !== "function") throw new Error(`This project's superwall version does not export ${name} from ${subpath} — update the project's superwall dependency.`);
20
+ return candidate;
21
+ }
22
+ function resolveFrameworkDir(cwd) {
23
+ for (const anchor of [join(cwd, "superwall", "package.json"), join(cwd, "package.json")]) try {
24
+ return join(createRequire(anchor).resolve("superwall/package.json"), "..");
25
+ } catch {
26
+ continue;
27
+ }
28
+ throw new FrameworkNotFoundError(cwd);
29
+ }
30
+ function frameworkVersion(cwd) {
31
+ try {
32
+ const { version } = JSON.parse(readFileSync(join(resolveFrameworkDir(cwd), "package.json"), "utf8"));
33
+ if (typeof version === "string" && version !== "") return version;
34
+ } catch {
35
+ return "unknown";
36
+ }
37
+ return "unknown";
38
+ }
39
+ async function resolveFramework(cwd) {
40
+ const dir = resolveFrameworkDir(cwd);
41
+ const [discover, build, preview] = await Promise.all([
42
+ importSubpath(dir, "superwall/discover"),
43
+ importSubpath(dir, "superwall/build"),
44
+ importSubpath(dir, "superwall/preview")
45
+ ]);
46
+ const studioProject = typeof preview.buildStudioProject === "function" ? preview.buildStudioProject : void 0;
47
+ return {
48
+ discoverProject: fn(discover, "discoverProject", "superwall/discover"),
49
+ buildSnapshot: fn(build, "buildSnapshot", "superwall/build"),
50
+ startPreviewServer: fn(preview, "startPreviewServer", "superwall/preview"),
51
+ studioProject
52
+ };
53
+ }
54
+
55
+ //#endregion
56
+ //#region src/core/paywalls/pipeline/output.ts
57
+ const kb = (bytes) => `${(bytes / 1024).toFixed(1)} kB`;
58
+ const weight = (bytes) => bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : kb(bytes);
59
+ const SHORT_SHA = 7;
60
+ const shortSha = (sha) => typeof sha === "string" && sha.length >= SHORT_SHA ? sha.slice(0, SHORT_SHA) : void 0;
61
+ function pushedLine(input) {
62
+ const sha = shortSha(input.snapshotId);
63
+ const pushed = `Pushed ${input.promoting ? `version ${input.version}` : pc.yellow(`version ${input.version}`)}${sha ? ` ${pc.dim(`(${sha})`)}` : ""}`;
64
+ return input.promoting || input.live === void 0 ? pushed : `${pushed} · ${pc.dim(`live ${input.live}`)}`;
65
+ }
66
+ function transition(before, after) {
67
+ if (before === void 0) return `Promoted ${pc.green(`version ${after}`)}`;
68
+ if (before === after) return `Version ${pc.green(String(after))} already live`;
69
+ if (after < before) return `Rolled back ${pc.green(`version ${before} → ${after}`)}`;
70
+ return `Promoted ${pc.green(`version ${before} → ${after}`)}`;
71
+ }
72
+ const BIND_VERB = {
73
+ lock: "Linked to",
74
+ matched: "Linked to",
75
+ created: "Created",
76
+ renamed: "Rebound after rename to"
77
+ };
78
+ const LAYOUT_HINT = "expected superwall/{paywalls,funnels}/<id>/ with config.ts and app/index.tsx";
79
+ const NOTE_LIMIT = 2e3;
80
+ const PENDING_NAMES = 10;
81
+ function pendingPromoteWarning(pending, multi = false) {
82
+ if (pending.length === 0) return void 0;
83
+ const entries = pending.map((entry) => typeof entry === "string" ? { id: entry } : entry);
84
+ const ids = [...new Set(entries.map((entry) => entry.id))];
85
+ const platforms = new Set(entries.flatMap((entry) => entry.platform ? [entry.platform] : []));
86
+ const platformFlag = multi && platforms.size === 1 ? ` --platform ${[...platforms][0]}` : "";
87
+ const command = `superwall promote --id ${ids.join(",")}${platformFlag}`;
88
+ const labels = entries.map((entry) => multi && entry.platform ? `${entry.id} · ${entry.platform}` : entry.id);
89
+ if (labels.length === 1) return `${labels[0]} is pushed but not live — run \`${command}\` to publish it.`;
90
+ const shown = labels.slice(0, PENDING_NAMES).map((label) => ` ${label}`);
91
+ const rest = labels.length - shown.length;
92
+ return [
93
+ `These ${labels.length} paywalls are pushed but not live:`,
94
+ ...shown,
95
+ ...rest > 0 ? [` …and ${rest} more`] : [],
96
+ "",
97
+ ` ${command}`
98
+ ].join("\n");
99
+ }
100
+ function resolveNote(message) {
101
+ if (message === void 0) return void 0;
102
+ if (message.length > NOTE_LIMIT) throw new Error(`Publish note is ${message.length} characters (limit ${NOTE_LIMIT}).`);
103
+ return message;
104
+ }
105
+ const took = (since) => {
106
+ const seconds = (Date.now() - since) / 1e3;
107
+ return pc.dim(seconds < 10 ? `(${seconds.toFixed(1)}s)` : `(${Math.round(seconds)}s)`);
108
+ };
109
+
110
+ //#endregion
111
+ //#region src/core/paywalls/pipeline/selection.ts
112
+ function resolveProjectDir(dir) {
113
+ const [first] = resolveProjectDirs(dir === void 0 ? [] : [dir]);
114
+ return first ?? process.cwd();
115
+ }
116
+ function resolveProjectDirs(dirs) {
117
+ const list = dirs.filter((entry) => entry.length > 0);
118
+ if (list.length === 0) return [process.cwd()];
119
+ const expanded = list.flatMap((entry) => entry.includes("*") ? expandGlob(entry) : [entry]);
120
+ return [...new Set(expanded.map((entry) => resolve(entry)))];
121
+ }
122
+ function expandGlob(pattern) {
123
+ try {
124
+ return [...globSync(pattern)].filter((entry) => statSync(entry, { throwIfNoEntry: false })?.isDirectory() ?? false).sort();
125
+ } catch {
126
+ return [pattern];
127
+ }
128
+ }
129
+ function requireProject(project, dir) {
130
+ if (!project.marker) throw new Error(`Not a superwall project: ${dir}\nExpected a package.json here (or in superwall/) that depends on superwall.`);
131
+ if (project.packageName === "superwall") throw new Error(`${project.superwallDir}/package.json is named "superwall".\nNode resolves every bare \`import "superwall"\` inside a package to that package itself, so the framework can never load. Rename it to your project's name.`);
132
+ return project;
133
+ }
134
+ function parseIds(values) {
135
+ return values.flatMap((entry) => entry.split(",")).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
136
+ }
137
+ function selectSurfaces(project, ids) {
138
+ const wanted = parseIds(ids);
139
+ const known = project.surfaces.map((surface) => surface.id).join(", ");
140
+ if (wanted.length === 0) {
141
+ if (project.surfaces.length === 0) throw new Error(`No paywalls or funnels found — ${LAYOUT_HINT}.`);
142
+ return [...project.surfaces];
143
+ }
144
+ const selected = [];
145
+ for (const id of wanted) {
146
+ const matches = project.surfaces.filter((surface$1) => surface$1.id === id);
147
+ if (matches.length === 0) throw new Error(`No paywall or funnel named "${id}"` + (known ? ` — this project has: ${known}.` : ` — ${LAYOUT_HINT}.`));
148
+ if (matches.length > 1) {
149
+ const kinds = matches.map((surface$1) => `${surface$1.kind}/${surface$1.id}`).join(" and ");
150
+ throw new Error(`"${id}" is ambiguous — this project has ${kinds}.`);
151
+ }
152
+ const surface = matches[0];
153
+ if (surface && !selected.includes(surface)) selected.push(surface);
154
+ }
155
+ return selected;
156
+ }
157
+ function requireClean(surfaces) {
158
+ const problems = surfaces.flatMap((surface) => surface.diagnostics ?? []);
159
+ if (problems.length === 0) return;
160
+ throw new Error([
161
+ ...problems,
162
+ "",
163
+ "Publishing is immutable — fix these first, then push again."
164
+ ].join("\n"));
165
+ }
166
+ function storesDiffer(products, live, comparePlans = true) {
167
+ return products.some((product) => {
168
+ const pushed = live?.find((ref) => ref.reference === product.reference_name && ref.identifier === product.identifier);
169
+ if (pushed === void 0) return false;
170
+ if (pushed.store !== void 0 && pushed.store !== product.store) return true;
171
+ return comparePlans && pushed.billingPlan !== billingPlanOf(product.billing_plan_type);
172
+ });
173
+ }
174
+ function needsWork(built, pushed, live) {
175
+ return built !== pushed && built !== live;
176
+ }
177
+
178
+ //#endregion
179
+ export { weight as _, resolveProjectDir as a, storesDiffer as c, kb as d, pendingPromoteWarning as f, transition as g, took as h, requireProject as i, BIND_VERB as l, resolveNote as m, parseIds as n, resolveProjectDirs as o, pushedLine as p, requireClean as r, selectSurfaces as s, needsWork as t, LAYOUT_HINT as u, frameworkVersion as v, resolveFramework as y };