@superwall/cli 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +21 -5
  2. package/dist/{actions-EfP8phmb.js → actions-Dt35nIi8.js} +3 -2
  3. package/dist/{api-CEwXCCoC.js → api-BOR-uXZe.js} +9 -9
  4. package/dist/{app-D8mEVlQo.js → app-BU27SLPX.js} +9 -9
  5. package/dist/{asa-BFWehnTA.js → asa-2ykGnjaV.js} +11 -11
  6. package/dist/{asc-DJqQmtmR.js → asc-r3xmFT0L.js} +14 -14
  7. package/dist/{auth-CT2DWX8r.js → auth-BWZfguI8.js} +9 -9
  8. package/dist/auth.js +2 -2
  9. package/dist/{billing-BzEnVPD2.js → billing-BsQgXXYh.js} +1 -1
  10. package/dist/{bind-BZxVyt9P.js → bind-BSTAinn6.js} +5 -4
  11. package/dist/{command-DP96_gmP.js → command-DMoMn7uc.js} +39 -16
  12. package/dist/{create-Q8TqqjZt.js → create-CSo6XjSm.js} +118 -91
  13. package/dist/dev-B0MF6z3L.js +21 -0
  14. package/dist/{dev-DlCcwFu5.js → dev-CuXa3J4Z.js} +29 -24
  15. package/dist/{doctor-CJsjHpCZ.js → doctor-DXJaDqsx.js} +10 -10
  16. package/dist/{drivers-UT36AnOw.js → drivers-Cr252DOJ.js} +3 -3
  17. package/dist/entry.js +84 -50
  18. package/dist/{existing-Cak1WxWB.js → existing-Ckx_g7Be.js} +6 -3
  19. package/dist/{feedback-DDRzoqPx.js → feedback-Dt5yebMS.js} +6 -6
  20. package/dist/{hosted-CEH78QVn.js → hosted-Cjekn8oJ.js} +2 -2
  21. package/dist/{integrate-D8jyhDzk.js → integrate-DVqhvPVq.js} +25 -66
  22. package/dist/{login-kneYhhk0.js → login-Bjj8QvIN.js} +6 -6
  23. package/dist/migrate-qmvOtp3l.js +283 -0
  24. package/dist/open-studio-CpHqjovS.js +1299 -0
  25. package/dist/{org-Cg25bcsj.js → org-CV8c849b.js} +3 -3
  26. package/dist/{output-csAtR6kJ.js → output-CiELrN8w.js} +15 -2
  27. package/dist/{pipeline-DAeI9tHs.js → pipeline-DSCHL9KA.js} +482 -9
  28. package/dist/{print-skill-BHVPP9cX.js → print-skill-CaHRJ8xW.js} +7 -7
  29. package/dist/{promote-Boek5K2d.js → promote-UMTh8Q33.js} +17 -18
  30. package/dist/publish-DWX8S9yZ.js +34 -0
  31. package/dist/push-Dox4_5Dq.js +34 -0
  32. package/dist/{query-B8G6T8Ba.js → query-CnSsDZ7Q.js} +10 -10
  33. package/dist/reports-C0xHCLnt.js +27 -0
  34. package/dist/{resource-DjsWVka-.js → resource-5bgyyL9B.js} +15 -15
  35. package/dist/{resources-s64mBHaC.js → resources-Bf9O1JNM.js} +28 -2
  36. package/dist/{run-BtcQJCP8.js → run-BVeZWbXx.js} +39 -22
  37. package/dist/{scan-DJixvuHn.js → scan-CAObNRgc.js} +44 -4
  38. package/dist/skills/superwall/SKILL.md +146 -0
  39. package/dist/skills/superwall/references/api.md +275 -0
  40. package/dist/skills/superwall/references/asa.md +160 -0
  41. package/dist/skills/superwall/references/asc.md +96 -0
  42. package/dist/skills/superwall/references/dashboard-links.md +57 -0
  43. package/dist/skills/superwall/references/data-analytics.md +893 -0
  44. package/dist/skills/superwall/references/docs.md +51 -0
  45. package/dist/skills/superwall/references/sdk-integration.md +105 -0
  46. package/dist/skills/superwall/references/sdk-source.md +18 -0
  47. package/{skills/superwall-dashboard/SKILL.md → dist/skills/superwall/workflows/dashboard/playbook.md} +3 -9
  48. package/{skills/superwall-dashboard/references → dist/skills/superwall/workflows/dashboard}/setup.md +1 -3
  49. package/dist/skills/superwall/workflows/integrate/android.md +292 -0
  50. package/{skills/superwall-integrate/SKILL.md → dist/skills/superwall/workflows/integrate/playbook.md} +16 -11
  51. package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/adapty.md +4 -4
  52. package/{skills/superwall-migrate/SKILL.md → dist/skills/superwall/workflows/migrate/playbook.md} +4 -10
  53. package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/qonversion.md +4 -4
  54. package/{skills/superwall-migrate/references → dist/skills/superwall/workflows/migrate}/revenuecat.md +4 -4
  55. package/dist/skills/superwall/workflows/placements/android.md +175 -0
  56. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/expo.md +1 -1
  57. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/flutter.md +1 -1
  58. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/ios.md +1 -1
  59. package/{skills/superwall-placements/SKILL.md → dist/skills/superwall/workflows/placements/playbook.md} +6 -10
  60. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/react-native.md +2 -2
  61. package/{skills/superwall-placements/references → dist/skills/superwall/workflows/placements}/strategy.md +4 -3
  62. package/dist/skills/superwall/workflows/review/android.md +120 -0
  63. package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/expo.md +1 -1
  64. package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/flutter.md +1 -1
  65. package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/ios.md +1 -1
  66. package/{skills/superwall-review/SKILL.md → dist/skills/superwall/workflows/review/playbook.md} +2 -7
  67. package/{skills/superwall-review/references → dist/skills/superwall/workflows/review}/react-native.md +1 -1
  68. package/dist/skills/superwall-framework/SKILL.md +253 -0
  69. package/dist/skills/superwall-framework/references/cli.md +340 -0
  70. package/dist/skills/superwall-framework/references/examples.md +123 -0
  71. package/dist/skills/superwall-framework/references/layout.md +295 -0
  72. package/dist/skills/superwall-framework/references/migrate-from-editor.md +208 -0
  73. package/dist/skills/superwall-framework/references/migrate-from-native.md +193 -0
  74. package/dist/skills/superwall-framework/references/mobile-design.md +371 -0
  75. package/dist/skills/superwall-framework/references/native/android.md +83 -0
  76. package/dist/skills/superwall-framework/references/native/flutter.md +65 -0
  77. package/dist/skills/superwall-framework/references/native/ios.md +77 -0
  78. package/dist/skills/superwall-framework/references/native/react-native.md +67 -0
  79. package/dist/skills/superwall-framework/references/responsive.md +162 -0
  80. package/dist/{skills-CRG1xk0G.js → skills-Cu41i-Az.js} +12 -12
  81. package/dist/{skills-CODut1Hn.js → skills-grTDuHlc.js} +134 -36
  82. package/dist/{spinner-B9dT3DBY.js → spinner-DFctF_Jw.js} +1 -1
  83. package/dist/{telemetry-BtkMdT-5.js → telemetry-BuCbmoux.js} +3 -3
  84. package/dist/{token-hM7V1KMG.js → token-mju3Q-vc.js} +3 -3
  85. package/dist/{ui-Lqt_zFOr.js → ui-4gLyfrgl.js} +76 -46
  86. package/dist/{update-CeylIjx5.js → update-DnGfpCD7.js} +2 -2
  87. package/dist/{upgrade-DRqUfCBT.js → upgrade-PMoj3yqJ.js} +6 -6
  88. package/package.json +8 -7
  89. package/prompts/actions/paywall-migrate.xml +24 -0
  90. package/prompts/actions/screen-migrate.xml +26 -0
  91. package/dist/git-ZwA3Mx8m.js +0 -433
  92. package/dist/migrate-D_x1oyTk.js +0 -114
  93. package/dist/publish-C-zEUnO9.js +0 -35
  94. package/dist/push-DUDQG-EO.js +0 -35
  95. package/skills/README.md +0 -118
  96. /package/dist/{api-output-D9ggXQIr.js → api-output-CEhN-U_N.js} +0 -0
  97. /package/dist/{asc-products-C6MvSy8H.js → asc-products-1e1DoGeL.js} +0 -0
  98. /package/dist/{params-B1zeElGa.js → params-BxgTuCzr.js} +0 -0
  99. /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/expo.md +0 -0
  100. /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/flutter.md +0 -0
  101. /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/ios.md +0 -0
  102. /package/{skills/superwall-integrate/references → dist/skills/superwall/workflows/integrate}/react-native.md +0 -0
  103. /package/dist/{storekit-DPonXSwe.js → storekit-Dlpbq5Wv.js} +0 -0
@@ -1,6 +1,6 @@
1
- import { n as ui } from "./ui-Lqt_zFOr.js";
2
- import { t as withSpinner } from "./spinner-B9dT3DBY.js";
3
- import { C as rowName, p as listOrganizations, w as titleCase } from "./resources-s64mBHaC.js";
1
+ import { n as ui } from "./ui-4gLyfrgl.js";
2
+ import { t as withSpinner } from "./spinner-DFctF_Jw.js";
3
+ import { E as titleCase, T as rowName, m as listOrganizations } from "./resources-Bf9O1JNM.js";
4
4
 
5
5
  //#region src/core/account/org.ts
6
6
  /**
@@ -1,13 +1,25 @@
1
+ import { join } from "node:path";
2
+ import { homedir } from "node:os";
1
3
  import { stripVTControlCharacters } from "node:util";
2
4
 
3
5
  //#region package.json
4
- var version = "1.4.0";
6
+ var version = "1.6.0";
5
7
 
6
8
  //#endregion
7
9
  //#region src/environment.ts
8
10
  const VERSION = version;
9
11
  const DASHBOARD_URL = "https://superwall.com/dashboard";
10
12
  const ENV_API_KEY = "SUPERWALL_API_KEY";
13
+ const CHANNELS = {
14
+ latest: { skillsRef: "main" },
15
+ next: { skillsRef: "next" }
16
+ };
17
+ const isChannel = (value) => value !== void 0 && value in CHANNELS;
18
+ const CHANNEL = () => {
19
+ const value = process.env.SUPERWALL_CHANNEL?.trim();
20
+ return isChannel(value) ? value : "latest";
21
+ };
22
+ const AGENT_SKILLS_DIR = () => process.env.SUPERWALL_AGENT_SKILLS_DIR ?? join(homedir(), ".agents", "skills");
11
23
  const SUPERWALL_HOME = () => {
12
24
  const value = process.env.SUPERWALL_HOME;
13
25
  return value && value.trim() !== "" ? value.trim() : void 0;
@@ -25,6 +37,7 @@ const TELEMETRY_HOST = () => host("SUPERWALL_TELEMETRY_HOST", "https://us.i.post
25
37
  const TELEMETRY_KEY = () => host("SUPERWALL_TELEMETRY_KEY", "phc_obWpK8cuSfhNkZUKmDByATHp928RHPRD5DoMEDreAHS6");
26
38
  let Integration = /* @__PURE__ */ function(Integration$1) {
27
39
  Integration$1["swift"] = "swift";
40
+ Integration$1["android"] = "android";
28
41
  Integration$1["expo"] = "expo";
29
42
  Integration$1["reactNative"] = "react-native";
30
43
  Integration$1["flutter"] = "flutter";
@@ -120,4 +133,4 @@ function renderBlock(renderer, block) {
120
133
  }
121
134
 
122
135
  //#endregion
123
- export { apiKeyFromEnv as _, API_HOST as a, CLI_CLIENT_ID as c, Integration as d, OAUTH_SCOPE as f, VERSION as g, TELEMETRY_KEY as h, writeJson as i, DASHBOARD_URL as l, TELEMETRY_HOST as m, createCommandOutput as n, ASSET_HOST as o, SUPERWALL_HOME as p, formatJson as r, AUTH_HOST as s, blocks as t, ENV_API_KEY as u, isNonInteractive as v };
136
+ export { TELEMETRY_HOST as _, AGENT_SKILLS_DIR as a, apiKeyFromEnv as b, AUTH_HOST as c, CLI_CLIENT_ID as d, DASHBOARD_URL as f, SUPERWALL_HOME as g, OAUTH_SCOPE as h, writeJson as i, CHANNEL as l, Integration as m, createCommandOutput as n, API_HOST as o, ENV_API_KEY as p, formatJson as r, ASSET_HOST as s, blocks as t, CHANNELS as u, TELEMETRY_KEY as v, isNonInteractive as x, VERSION as y };
@@ -1,19 +1,310 @@
1
- import { g as VERSION, o as ASSET_HOST } from "./output-csAtR6kJ.js";
2
- import { n as ApiError } from "./command-DP96_gmP.js";
3
- import { n as ui } from "./ui-Lqt_zFOr.js";
4
- import { S as pushPaywallVersion, T as versionProducts, a as createHeadlessPaywall, b as promotePaywallVersion, d as listAppPaywalls, g as livePaywall, m as listProjects, u as linkSourceCommit, v as mintSourceAccess, x as pushPaywallAssets, y as platformLabel } from "./resources-s64mBHaC.js";
5
- import { _ as writeSnapshot, c as platformFor, d as describeBindings, f as readLock, g as writeBindings, h as writeBinding, n as pushSourceTree, o as writeProjectScaffold, p as removeBinding, s as describePlatforms, t as gitAvailable, u as resolveApps } from "./git-ZwA3Mx8m.js";
1
+ import { b as apiKeyFromEnv, o as API_HOST, p as ENV_API_KEY, s as ASSET_HOST, y as VERSION } from "./output-CiELrN8w.js";
2
+ import { i as loadSession } from "./token-mju3Q-vc.js";
3
+ import { i as createSuperwallApi, r as ApiError } from "./command-DMoMn7uc.js";
4
+ import { n as ui } from "./ui-4gLyfrgl.js";
5
+ import { C as pushPaywallAssets, D as versionProducts, S as promotePaywallVersion, _ as livePaywall, a as createHeadlessPaywall, b as platformLabel, d as linkSourceCommit, f as listAppPaywalls, h as listProjects, p as listApplications, w as pushPaywallVersion, y as mintSourceAccess } from "./resources-Bf9O1JNM.js";
6
+ import { r as performLoginWithUi } from "./app-BU27SLPX.js";
6
7
  import { createRequire } from "node:module";
7
8
  import pc from "picocolors";
8
- import * as fs from "node:fs";
9
- import { globSync, readFileSync, statSync } from "node:fs";
10
- import { cpus } from "node:os";
11
9
  import * as path from "node:path";
12
10
  import { join, resolve } from "node:path";
11
+ import * as os$1 from "node:os";
12
+ import { cpus } from "node:os";
13
+ import { promisify } from "node:util";
14
+ import * as fs from "node:fs";
15
+ import { globSync, readFileSync, statSync } from "node:fs";
13
16
  import { pathToFileURL } from "node:url";
17
+ import { execFile } from "node:child_process";
14
18
  import fg from "fast-glob";
15
19
  import { productVariables } from "@superwall/studio/products";
16
20
 
21
+ //#region src/core/paywalls/project/lock.ts
22
+ const isScreenOrigin = (origin) => "path" in origin;
23
+ const isFileName = (value) => typeof value === "string" && value !== "" && !/[\\/]/.test(value) && !value.startsWith(".");
24
+ const SCREEN_FRAMEWORKS = new Set([
25
+ "swiftui",
26
+ "uikit",
27
+ "compose",
28
+ "android-views",
29
+ "react-native",
30
+ "flutter"
31
+ ]);
32
+ const readOrigin = (candidate) => {
33
+ if (typeof candidate.paywallId === "string" && typeof candidate.url === "string") return {
34
+ paywallId: candidate.paywallId,
35
+ url: candidate.url
36
+ };
37
+ if (typeof candidate.path === "string" && typeof candidate.framework === "string" && SCREEN_FRAMEWORKS.has(candidate.framework)) {
38
+ const framework = candidate.framework;
39
+ return isFileName(candidate.screenshot) ? {
40
+ path: candidate.path,
41
+ framework,
42
+ screenshot: candidate.screenshot
43
+ } : {
44
+ path: candidate.path,
45
+ framework
46
+ };
47
+ }
48
+ };
49
+ const EXPLAINER = "Commit this file: it binds each paywall to its dashboard entry, per app, so every machine and CI push to the same place. Managed by the Superwall CLI.";
50
+ const emptyLock = () => ({
51
+ version: 1,
52
+ apps: {},
53
+ paywalls: {},
54
+ funnels: {}
55
+ });
56
+ const originKey = (kind, surfaceId) => `${kind}/${surfaceId}`;
57
+ const readOrigins = (value) => {
58
+ if (!isRecord(value)) return void 0;
59
+ const origins = {};
60
+ for (const [key, candidate] of Object.entries(value)) {
61
+ if (!isRecord(candidate)) continue;
62
+ const origin = readOrigin(candidate);
63
+ if (origin) origins[key] = origin;
64
+ }
65
+ return Object.keys(origins).length > 0 ? origins : void 0;
66
+ };
67
+ const lockPath = (superwallDir) => path.join(superwallDir, "superwall.lock");
68
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
69
+ const readBinding = (value) => {
70
+ if (!isRecord(value) || typeof value.paywallId !== "string") return void 0;
71
+ return typeof value.snapshot === "string" ? {
72
+ paywallId: value.paywallId,
73
+ snapshot: value.snapshot
74
+ } : { paywallId: value.paywallId };
75
+ };
76
+ const readSection = (value) => {
77
+ const section = {};
78
+ if (!isRecord(value)) return section;
79
+ for (const [surfaceId, entry] of Object.entries(value)) {
80
+ if (!isRecord(entry)) continue;
81
+ const bindings = {};
82
+ for (const [platform, candidate] of Object.entries(entry)) {
83
+ const binding = readBinding(candidate);
84
+ if (binding) bindings[platform] = binding;
85
+ }
86
+ if (Object.keys(bindings).length > 0) section[surfaceId] = bindings;
87
+ }
88
+ return section;
89
+ };
90
+ function readLock(superwallDir) {
91
+ const file = lockPath(superwallDir);
92
+ if (!fs.existsSync(file)) return emptyLock();
93
+ try {
94
+ const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
95
+ if (!isRecord(parsed) || parsed.version !== 1) return emptyLock();
96
+ const lock = emptyLock();
97
+ if (isRecord(parsed.apps)) {
98
+ for (const [platform, id] of Object.entries(parsed.apps)) if (typeof id === "string") lock.apps[platform] = id;
99
+ }
100
+ lock.paywalls = readSection(parsed.paywalls);
101
+ lock.funnels = readSection(parsed.funnels);
102
+ const origins = readOrigins(parsed.origins);
103
+ if (origins) lock.origins = origins;
104
+ return lock;
105
+ } catch {}
106
+ return emptyLock();
107
+ }
108
+ function writeLock(superwallDir, lock) {
109
+ const annotated = {
110
+ "//": EXPLAINER,
111
+ version: lock.version,
112
+ apps: lock.apps,
113
+ paywalls: lock.paywalls,
114
+ funnels: lock.funnels,
115
+ ...lock.origins && Object.keys(lock.origins).length > 0 ? { origins: lock.origins } : {}
116
+ };
117
+ fs.writeFileSync(lockPath(superwallDir), `${JSON.stringify(annotated, null, 2)}\n`);
118
+ }
119
+ function writeOrigin(superwallDir, kind, surfaceId, origin) {
120
+ const lock = readLock(superwallDir);
121
+ lock.origins = {
122
+ ...lock.origins,
123
+ [originKey(kind, surfaceId)]: origin
124
+ };
125
+ writeLock(superwallDir, lock);
126
+ }
127
+ const sectionOf = (lock, kind) => kind === "paywall" ? lock.paywalls : lock.funnels;
128
+ function writeApp(superwallDir, platform, applicationId) {
129
+ const lock = readLock(superwallDir);
130
+ lock.apps[platform] = applicationId;
131
+ writeLock(superwallDir, lock);
132
+ }
133
+ function writeBinding(superwallDir, kind, surfaceId, platform, binding) {
134
+ const lock = readLock(superwallDir);
135
+ const section = sectionOf(lock, kind);
136
+ section[surfaceId] = {
137
+ ...section[surfaceId],
138
+ [platform]: binding
139
+ };
140
+ writeLock(superwallDir, lock);
141
+ }
142
+ function writeBindings(superwallDir, kind, surfaceId, bindings) {
143
+ const lock = readLock(superwallDir);
144
+ sectionOf(lock, kind)[surfaceId] = { ...bindings };
145
+ writeLock(superwallDir, lock);
146
+ }
147
+ function writeSnapshot(superwallDir, kind, surfaceId, platform, snapshot) {
148
+ const lock = readLock(superwallDir);
149
+ const section = sectionOf(lock, kind);
150
+ const binding = section[surfaceId]?.[platform];
151
+ if (!binding || binding.snapshot === snapshot) return;
152
+ section[surfaceId] = {
153
+ ...section[surfaceId],
154
+ [platform]: {
155
+ ...binding,
156
+ snapshot
157
+ }
158
+ };
159
+ writeLock(superwallDir, lock);
160
+ }
161
+ function removeBinding(superwallDir, kind, surfaceId) {
162
+ const lock = readLock(superwallDir);
163
+ const section = sectionOf(lock, kind);
164
+ if (!(surfaceId in section)) return false;
165
+ delete section[surfaceId];
166
+ writeLock(superwallDir, lock);
167
+ return true;
168
+ }
169
+ const describeBindings = (bindings) => {
170
+ const entries = Object.entries(bindings);
171
+ if (entries.length === 1 && entries[0] !== void 0) return `paywall ${entries[0][1].paywallId}`;
172
+ return `paywalls ${entries.map(([platform, binding]) => `${binding.paywallId} (${platform})`).join(", ")}`;
173
+ };
174
+
175
+ //#endregion
176
+ //#region src/core/paywalls/binding/apps.ts
177
+ const PLATFORMS = [
178
+ "ios",
179
+ "android",
180
+ "web"
181
+ ];
182
+ var AppBindingError = class extends Error {};
183
+ const platformOf = (app) => {
184
+ const normalized = (app.platform ?? "").toLowerCase();
185
+ return PLATFORMS.find((platform) => platform === normalized);
186
+ };
187
+ function requirePlatform(app) {
188
+ const platform = platformOf(app);
189
+ if (platform !== void 0) return platform;
190
+ throw new AppBindingError(`\`${app.name ?? app.id}\` is a ${platformLabel(app.platform)} app on Superwall, and Superwall for Agents pushes to ${PLATFORMS.join(", ")} apps only.`);
191
+ }
192
+ const platformFor = (apps, value) => {
193
+ if (value in apps) return value;
194
+ return Object.entries(apps).find(([, id]) => id === value)?.[0];
195
+ };
196
+ function describePlatforms(apps) {
197
+ return Object.keys(apps).join(", ");
198
+ }
199
+ async function resolveApps(input) {
200
+ const { api, superwallDir } = input;
201
+ let cached;
202
+ const known = () => cached ??= listApplications(api);
203
+ const current = () => readLock(superwallDir).apps;
204
+ for (const platform of new Set(input.wanted ?? [])) {
205
+ if (!PLATFORMS.some((known$1) => known$1 === platform)) throw new AppBindingError(`"${platform}" is not a platform — use one of ${PLATFORMS.join(", ")}.`);
206
+ if (platform in current()) continue;
207
+ const bound = new Set(Object.values(current()));
208
+ const candidates = (await known()).filter((app) => !bound.has(String(app.id)) && platformOf(app) === platform);
209
+ const only = candidates.length === 1 ? candidates[0] : void 0;
210
+ if (only) {
211
+ writeApp(superwallDir, platform, String(only.id));
212
+ continue;
213
+ }
214
+ const picked = candidates.length > 1 && input.pickApplication ? await input.pickApplication(candidates, platform) : null;
215
+ if (picked) {
216
+ writeApp(superwallDir, platform, String(picked.id));
217
+ continue;
218
+ }
219
+ const label = platformLabel(platform);
220
+ throw new AppBindingError(candidates.length === 0 ? `Your account has no ${label} app to bind — create one with \`superwall apps create --platform ${platform}\` or in the dashboard, then push again.` : `Several ${label} apps in your account — run \`superwall push\` interactively once to pick one, or add "${platform}": "<app id>" under "apps" in superwall.lock (\`superwall apps list\` shows ids).`);
221
+ }
222
+ if (Object.keys(current()).length > 0) return current();
223
+ const apps = await known();
224
+ if (apps.length === 1 && apps[0] !== void 0) {
225
+ writeApp(superwallDir, requirePlatform(apps[0]), String(apps[0].id));
226
+ return current();
227
+ }
228
+ if (apps.length > 1 && input.pickApplication) {
229
+ const picked = await input.pickApplication(apps);
230
+ if (picked) {
231
+ writeApp(superwallDir, requirePlatform(picked), String(picked.id));
232
+ return current();
233
+ }
234
+ }
235
+ throw new AppBindingError(apps.length === 0 ? "Your account has no apps yet — create one with `superwall apps create` or in the dashboard." : "Several apps in your account — run `superwall push` interactively once to pick one; the choice is saved to superwall.lock.");
236
+ }
237
+
238
+ //#endregion
239
+ //#region src/core/paywalls/project/scaffold.ts
240
+ const REACT_VERSION = "19.1.0";
241
+ function projectPackageName(root) {
242
+ const name = path.basename(root).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
243
+ return name === "" || name === "superwall" ? "superwall-project" : name;
244
+ }
245
+ function packageJson(name, frameworkVersion$1) {
246
+ return `${JSON.stringify({
247
+ name,
248
+ private: true,
249
+ type: "module",
250
+ scripts: {
251
+ dev: "superwall dev",
252
+ push: "superwall push",
253
+ promote: "superwall promote",
254
+ ship: "superwall publish"
255
+ },
256
+ dependencies: {
257
+ react: REACT_VERSION,
258
+ "react-dom": REACT_VERSION,
259
+ superwall: frameworkVersion$1 === "unknown" ? "*" : `^${frameworkVersion$1}`
260
+ }
261
+ }, null, 2)}\n`;
262
+ }
263
+ const GITIGNORE = `node_modules/
264
+ .superwall
265
+ .env
266
+ `;
267
+ function writeIfAbsent(file, content) {
268
+ if (fs.existsSync(file)) return;
269
+ try {
270
+ fs.writeFileSync(file, content, { flag: "wx" });
271
+ } catch {
272
+ return;
273
+ }
274
+ }
275
+ function writeProjectScaffold(options) {
276
+ writeIfAbsent(path.join(options.superwallDir, "package.json"), packageJson(projectPackageName(options.root), options.frameworkVersion));
277
+ writeIfAbsent(path.join(options.superwallDir, ".gitignore"), GITIGNORE);
278
+ }
279
+
280
+ //#endregion
281
+ //#region src/core/paywalls/project/session.ts
282
+ var LoginRequiredError = class extends Error {
283
+ constructor() {
284
+ super(`Pushing paywalls needs a Superwall account.
285
+ Interactively: run \`superwall login\`.
286
+ In CI or an agent: set ${ENV_API_KEY} to an org API key (sk_…).`);
287
+ this.name = "LoginRequiredError";
288
+ }
289
+ };
290
+ async function requireApi(interactive) {
291
+ const apiKey = apiKeyFromEnv();
292
+ if (apiKey) return createSuperwallApi({
293
+ authMethod: "api_key",
294
+ apiKey,
295
+ host: process.env.SUPERWALL_API_HOST ?? API_HOST(),
296
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
297
+ });
298
+ const session = loadSession();
299
+ if (session) return createSuperwallApi(session);
300
+ if (!interactive) throw new LoginRequiredError();
301
+ ui.info("You're not signed in to Superwall yet — let's fix that.");
302
+ const signedIn = await performLoginWithUi();
303
+ if (!signedIn) throw new LoginRequiredError();
304
+ return createSuperwallApi(signedIn);
305
+ }
306
+
307
+ //#endregion
17
308
  //#region src/core/paywalls/project/types.ts
18
309
  const TYPES_FILE = "superwall.d.ts";
19
310
  const SUPERSEDED = ["superwall-env.d.ts", "superwall-routes.d.ts"];
@@ -416,6 +707,188 @@ async function collectSourceFiles(superwallDir) {
416
707
  };
417
708
  }
418
709
 
710
+ //#endregion
711
+ //#region src/core/paywalls/source/commit.ts
712
+ const buildCommitMessage = (input) => {
713
+ const surface = `${input.kind}/${input.surface}`;
714
+ const subject = `publish ${surface} v${input.version}`;
715
+ const external = (input.external ?? []).filter((entry) => entry.trim() !== "");
716
+ const trailers = [
717
+ `Superwall-Paywall: ${input.paywallId}`,
718
+ `Superwall-Application: ${input.applicationId}`,
719
+ `Superwall-Version: ${input.version}`,
720
+ `Superwall-Surface: ${surface}`,
721
+ `Superwall-Portable: ${external.length === 0}`
722
+ ];
723
+ if (external.length > 0) trailers.push(`Superwall-External: ${external.join(", ")}`);
724
+ if (input.snapshotSha) trailers.push(`Superwall-Snapshot: ${input.snapshotSha}`);
725
+ trailers.push(`Superwall-Framework: ${input.framework}`);
726
+ if (input.cli) trailers.push(`Superwall-Cli: ${input.cli}`);
727
+ const note = input.note?.replace(/\r\n?/g, "\n").trim();
728
+ return `${subject}\n${note ? `\n${note}\n` : ""}\n${trailers.join("\n")}\n`;
729
+ };
730
+ const tokenSecret = (token) => token.split("?")[0] ?? token;
731
+ const redact = (text, ...secrets) => {
732
+ let safe = text;
733
+ for (const secret of secrets) {
734
+ if (secret.length < 8) continue;
735
+ safe = safe.split(secret).join("***");
736
+ }
737
+ return safe;
738
+ };
739
+
740
+ //#endregion
741
+ //#region src/core/paywalls/source/git.ts
742
+ const run = promisify(execFile);
743
+ const AUTHOR = {
744
+ name: "Superwall",
745
+ email: "publish@superwall.com"
746
+ };
747
+ var GitError = class extends Error {};
748
+ const gitEnv = (token, extra = {}) => ({
749
+ ...process.env,
750
+ GIT_CONFIG_COUNT: "1",
751
+ GIT_CONFIG_KEY_0: "http.extraHeader",
752
+ GIT_CONFIG_VALUE_0: `Authorization: Bearer ${tokenSecret(token)}`,
753
+ GIT_TERMINAL_PROMPT: "0",
754
+ ...extra
755
+ });
756
+ async function git(args, options = {}) {
757
+ try {
758
+ const { stdout } = await run("git", args, {
759
+ cwd: options.cwd,
760
+ env: options.env,
761
+ maxBuffer: 64 * 1024 * 1024
762
+ });
763
+ return stdout;
764
+ } catch (error) {
765
+ const detail = typeof error === "object" && error !== null ? String(Reflect.get(error, "stderr") ?? Reflect.get(error, "message") ?? error) : String(error);
766
+ throw new GitError(redact(`git ${args[0]} failed: ${gitReason(detail)}`, ...options.secrets ?? []));
767
+ }
768
+ }
769
+ function gitReason(stderr) {
770
+ const lines = stderr.split("\n").map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("Command failed:"));
771
+ return (lines.find((line) => /^(fatal|error):/.test(line)) ?? lines[lines.length - 1] ?? "").replace(/^(fatal|error):\s*/, "") || "git reported no reason.";
772
+ }
773
+ async function gitAvailable() {
774
+ try {
775
+ await run("git", ["--version"]);
776
+ return true;
777
+ } catch {
778
+ return false;
779
+ }
780
+ }
781
+ const LARGE_FILE_BYTES = 50 * 1024 * 1024;
782
+ function materializeSourceTree(dir, files) {
783
+ for (const entry of fs.readdirSync(dir)) {
784
+ if (entry === ".git") continue;
785
+ fs.rmSync(path.join(dir, entry), {
786
+ recursive: true,
787
+ force: true
788
+ });
789
+ }
790
+ const write = (relative$1, data) => {
791
+ const file = path.join(dir, relative$1);
792
+ fs.mkdirSync(path.dirname(file), { recursive: true });
793
+ fs.writeFileSync(file, data);
794
+ };
795
+ const large = [];
796
+ for (const file of files) {
797
+ if (file.content.byteLength > LARGE_FILE_BYTES) large.push(file.path);
798
+ write(file.path, file.content);
799
+ }
800
+ if (large.length > 0) ui.warn(`Committing ${large.length > 1 ? `${large.length} files` : large[0]} over 50 MB — every future clone of this app's source repo pays for it.`);
801
+ }
802
+ async function pushSourceTree(input) {
803
+ const { access } = input;
804
+ const secrets = [access.token, tokenSecret(access.token)];
805
+ const dir = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-source-"));
806
+ const env = gitEnv(access.token);
807
+ try {
808
+ await git([
809
+ "clone",
810
+ "--depth",
811
+ "1",
812
+ "--branch",
813
+ access.branch,
814
+ access.remote,
815
+ dir
816
+ ], {
817
+ env,
818
+ secrets
819
+ }).catch(async (error) => {
820
+ await git([
821
+ "clone",
822
+ "--depth",
823
+ "1",
824
+ access.remote,
825
+ dir
826
+ ], {
827
+ env,
828
+ secrets
829
+ }).catch(() => {
830
+ throw error;
831
+ });
832
+ });
833
+ materializeSourceTree(dir, input.files);
834
+ await git(["add", "-A"], {
835
+ cwd: dir,
836
+ env,
837
+ secrets
838
+ });
839
+ if ((await git(["status", "--porcelain"], {
840
+ cwd: dir,
841
+ env,
842
+ secrets
843
+ })).trim() === "") return {
844
+ commitSha: (await git(["rev-parse", "HEAD"], {
845
+ cwd: dir,
846
+ env,
847
+ secrets
848
+ })).trim(),
849
+ status: "unchanged"
850
+ };
851
+ const messageFile = path.join(dir, ".git", "SUPERWALL_COMMITMSG");
852
+ fs.writeFileSync(messageFile, buildCommitMessage(input.message));
853
+ await git([
854
+ "commit",
855
+ "-F",
856
+ messageFile
857
+ ], {
858
+ cwd: dir,
859
+ env: gitEnv(access.token, {
860
+ GIT_AUTHOR_NAME: AUTHOR.name,
861
+ GIT_AUTHOR_EMAIL: AUTHOR.email,
862
+ GIT_COMMITTER_NAME: AUTHOR.name,
863
+ GIT_COMMITTER_EMAIL: AUTHOR.email
864
+ }),
865
+ secrets
866
+ });
867
+ await git([
868
+ "push",
869
+ "origin",
870
+ `HEAD:${access.branch}`
871
+ ], {
872
+ cwd: dir,
873
+ env,
874
+ secrets
875
+ });
876
+ return {
877
+ commitSha: (await git(["rev-parse", "HEAD"], {
878
+ cwd: dir,
879
+ env,
880
+ secrets
881
+ })).trim(),
882
+ status: "committed"
883
+ };
884
+ } finally {
885
+ fs.rmSync(dir, {
886
+ recursive: true,
887
+ force: true
888
+ });
889
+ }
890
+ }
891
+
419
892
  //#endregion
420
893
  //#region src/core/paywalls/source/source-push.ts
421
894
  var GitRequiredError = class extends Error {
@@ -986,4 +1459,4 @@ async function runPushPipeline(context, options) {
986
1459
  }
987
1460
 
988
1461
  //#endregion
989
- export { syncAssets as C, writeProjectTypes as D, collectProjectDeclarations as E, requireAssets as S, loadFramework as T, planTargets as _, projectDir as a, resolveBinding as b, selectSurfaces as c, pushSource as d, collectSourceFiles as f, parsePlatformFlags as g, projectForApplication as h, pickApplicationOption as i, LAYOUT_HINT as l, fetchProducts as m, runPushPipeline as n, projectDirs as o, warnNotPortable as p, timed as r, requireProject as s, group as t, transition as u, targetLabel as v, frameworkVersion as w, assetBaseUrl as x, wantedPlatforms as y };
1462
+ export { requireApi as A, requireAssets as C, collectProjectDeclarations as D, loadFramework as E, isScreenOrigin as F, readLock as I, writeApp as L, writeProjectScaffold as M, requirePlatform as N, writeProjectTypes as O, resolveApps as P, writeOrigin as R, assetBaseUrl as S, frameworkVersion as T, parsePlatformFlags as _, projectDir as a, wantedPlatforms as b, selectSurfaces as c, pushSource as d, gitAvailable as f, projectForApplication as g, fetchProducts as h, pickApplicationOption as i, projectPackageName as j, LoginRequiredError as k, LAYOUT_HINT as l, warnNotPortable as m, runPushPipeline as n, projectDirs as o, collectSourceFiles as p, timed as r, requireProject as s, group as t, transition as u, planTargets as v, syncAssets as w, resolveBinding as x, targetLabel as y };
@@ -1,11 +1,11 @@
1
- import "./output-csAtR6kJ.js";
2
- import { i as track, r as setTelemetryTags } from "./telemetry-BtkMdT-5.js";
3
- import "./ui-Lqt_zFOr.js";
4
- import { i as loadBundledSkill } from "./skills-CODut1Hn.js";
1
+ import "./output-CiELrN8w.js";
2
+ import { i as track, r as setTelemetryTags } from "./telemetry-BuCbmoux.js";
3
+ import "./ui-4gLyfrgl.js";
4
+ import { i as loadBundledSkill } from "./skills-grTDuHlc.js";
5
5
  import "./spawn-DSoTXy_j.js";
6
- import { t as scanProject } from "./scan-DJixvuHn.js";
7
- import { n as FRAMEWORK_REF } from "./actions-EfP8phmb.js";
8
- import { t as detectBilling } from "./billing-BzEnVPD2.js";
6
+ import { t as scanProject } from "./scan-CAObNRgc.js";
7
+ import { n as FRAMEWORK_REF } from "./actions-Dt35nIi8.js";
8
+ import { t as detectBilling } from "./billing-BsQgXXYh.js";
9
9
  import { resolve } from "node:path";
10
10
 
11
11
  //#region src/commands/workflow/print-skill.ts
@@ -1,22 +1,21 @@
1
- import { g as VERSION } from "./output-csAtR6kJ.js";
2
- import "./telemetry-BtkMdT-5.js";
3
- import "./update-CeylIjx5.js";
4
- import "./token-hM7V1KMG.js";
5
- import { n as ApiError, t as defineCommand } from "./command-DP96_gmP.js";
6
- import { n as ui } from "./ui-Lqt_zFOr.js";
7
- import "./skills-CODut1Hn.js";
1
+ import { y as VERSION } from "./output-CiELrN8w.js";
2
+ import "./telemetry-BuCbmoux.js";
3
+ import "./update-DnGfpCD7.js";
4
+ import "./token-mju3Q-vc.js";
5
+ import { r as ApiError, t as defineCommand } from "./command-DMoMn7uc.js";
6
+ import { n as ui } from "./ui-4gLyfrgl.js";
7
+ import "./skills-grTDuHlc.js";
8
8
  import "./spawn-DSoTXy_j.js";
9
- import "./login-kneYhhk0.js";
10
- import "./scan-DJixvuHn.js";
11
- import "./hosted-CEH78QVn.js";
12
- import "./spinner-B9dT3DBY.js";
13
- import { _ as livePaywallVersion, b as promotePaywallVersion } from "./resources-s64mBHaC.js";
14
- import "./org-Cg25bcsj.js";
15
- import "./bind-BZxVyt9P.js";
16
- import { i as requireApi, u as resolveApps } from "./git-ZwA3Mx8m.js";
17
- import "./actions-EfP8phmb.js";
18
- import "./app-D8mEVlQo.js";
19
- import { E as collectProjectDeclarations, T as loadFramework, _ as planTargets, a as projectDir, b as resolveBinding, c as selectSurfaces, g as parsePlatformFlags, i as pickApplicationOption, r as timed, t as group, u as transition, v as targetLabel, y as wantedPlatforms } from "./pipeline-DAeI9tHs.js";
9
+ import "./login-Bjj8QvIN.js";
10
+ import "./scan-CAObNRgc.js";
11
+ import "./hosted-Cjekn8oJ.js";
12
+ import "./spinner-DFctF_Jw.js";
13
+ import { S as promotePaywallVersion, v as livePaywallVersion } from "./resources-Bf9O1JNM.js";
14
+ import "./org-CV8c849b.js";
15
+ import "./bind-BSTAinn6.js";
16
+ import { A as requireApi, D as collectProjectDeclarations, E as loadFramework, P as resolveApps, _ as parsePlatformFlags, a as projectDir, b as wantedPlatforms, c as selectSurfaces, i as pickApplicationOption, r as timed, t as group, u as transition, v as planTargets, x as resolveBinding, y as targetLabel } from "./pipeline-DSCHL9KA.js";
17
+ import "./actions-Dt35nIi8.js";
18
+ import "./app-BU27SLPX.js";
20
19
  import pc from "picocolors";
21
20
 
22
21
  //#region src/commands/paywalls/promote.ts
@@ -0,0 +1,34 @@
1
+ import "./output-CiELrN8w.js";
2
+ import "./telemetry-BuCbmoux.js";
3
+ import "./update-DnGfpCD7.js";
4
+ import "./token-mju3Q-vc.js";
5
+ import { t as defineCommand } from "./command-DMoMn7uc.js";
6
+ import "./ui-4gLyfrgl.js";
7
+ import "./skills-grTDuHlc.js";
8
+ import "./spawn-DSoTXy_j.js";
9
+ import "./login-Bjj8QvIN.js";
10
+ import "./scan-CAObNRgc.js";
11
+ import "./hosted-Cjekn8oJ.js";
12
+ import "./spinner-DFctF_Jw.js";
13
+ import "./resources-Bf9O1JNM.js";
14
+ import "./org-CV8c849b.js";
15
+ import "./bind-BSTAinn6.js";
16
+ import { A as requireApi, n as runPushPipeline } from "./pipeline-DSCHL9KA.js";
17
+ import "./actions-Dt35nIi8.js";
18
+ import "./app-BU27SLPX.js";
19
+
20
+ //#region src/commands/paywalls/publish.ts
21
+ const runPublish = defineCommand({
22
+ name: "publish",
23
+ output: "human",
24
+ async run(context) {
25
+ const api = await requireApi(context.interactive);
26
+ await runPushPipeline({
27
+ ...context,
28
+ api
29
+ }, { promote: true });
30
+ }
31
+ });
32
+
33
+ //#endregion
34
+ export { runPublish };