@superwall/cli 2.4.0 → 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 (109) hide show
  1. package/dist/{apple-Bx_fm5M-.js → apple-Dyr7OFBx.js} +16 -15
  2. package/dist/approve-Czs1-JO9.js +186 -0
  3. package/dist/{assets-W5yvyf0V.js → assets-BrB9jQPQ.js} +3 -3
  4. package/dist/auth.d.ts +1 -1
  5. package/dist/auth.js +3 -3
  6. package/dist/{billing-C4lXR0xG.js → billing-D5qqIlVb.js} +3 -3
  7. package/dist/{bind-82oTpHZ3.js → bind-B3eEcRyp.js} +4 -4
  8. package/dist/browser-Bp3yRKlU.js +36 -0
  9. package/dist/{build-7_8cBgBm.js → build-DD9pSwHX.js} +9 -7
  10. package/dist/{client-ltxxHuxn.js → client-AI9H4GGB.js} +3 -3
  11. package/dist/{create-Dk8U_B49.js → create-B4m-IKlr.js} +8 -8
  12. package/dist/create-CJljlkJK.js +20 -0
  13. package/dist/{create-DEyveHS6.js → create-ChfgWpiM.js} +39 -67
  14. package/dist/{doctor-Df2GwS4K.js → doctor-XtXW6tKE.js} +6 -6
  15. package/dist/download-2Zu2I_Og.js +58 -0
  16. package/dist/{drivers-CTyYdBL7.js → drivers-CMEL13gp.js} +3 -3
  17. package/dist/entry.js +25 -24
  18. package/dist/{environment-djS0ik60.js → environment-BWT2S4qC.js} +3 -2
  19. package/dist/{existing-Das3PHGG.js → existing-b0GxFcnc.js} +2 -2
  20. package/dist/{session-CV0P8BjK.js → git-D7AVdugb.js} +96 -334
  21. package/dist/held-CX7Zf8u-.js +17 -0
  22. package/dist/{held-B8EFWDEc.js → held-D3PUNky2.js} +7 -7
  23. package/dist/install-CVUXsx8c.js +103 -0
  24. package/dist/{integrate-Cz48dm_h.js → integrate-qvKd9pVW.js} +27 -25
  25. package/dist/{login-girc324T.js → login-COmGHrU5.js} +2 -1
  26. package/dist/login-ClnJi1Ea.js +17 -0
  27. package/dist/{login-CiK5T4w8.js → login-PMoXUGqq.js} +8 -41
  28. package/dist/{lookup-us5vu5od.js → lookup-gjcKIZvh.js} +3 -2
  29. package/dist/{migrate-DaVwhdov.js → migrate-SkkLLdmr.js} +30 -25
  30. package/dist/{migration-cS6UGeUj.js → migration-DS44-3Zr.js} +9 -9
  31. package/dist/{notification-url-Hg42tAbW.js → notification-url-BjQPLf4-.js} +4 -4
  32. package/dist/{open-BIuOZ9ka.js → open-DQpm2yVs.js} +2 -2
  33. package/dist/{org-BrR4HGvl.js → org-C04eAO-j.js} +3 -2
  34. package/dist/organization-BOECL3vZ.js +39 -0
  35. package/dist/orgs-D6Kk96mG.js +81 -0
  36. package/dist/{paths-CdwjySxK.js → paths-REb-GrbX.js} +1 -1
  37. package/dist/{playbook-BJ3opYIS.js → playbook-Du4Oydbf.js} +10 -10
  38. package/dist/{products-DH_fK9tY.js → products-Cqq59DBQ.js} +1 -1
  39. package/dist/project-CP6hiHra.js +47 -0
  40. package/dist/{promote-BQO-1ScY.js → promote-Dm2_b1WK.js} +23 -18
  41. package/dist/pull-DsdOoG-D.js +36 -0
  42. package/dist/{pull-BhRswq6x.js → pull-F6pvO4To.js} +9 -28
  43. package/dist/pull-zYAbqo9n.js +106 -0
  44. package/dist/{push-CR110qRh.js → push-BIFLhAiO.js} +8 -6
  45. package/dist/push-CJVfvFZq.js +29 -0
  46. package/dist/push-D_l9KJZN.js +290 -0
  47. package/dist/push-SVzv7fzE.js +22 -0
  48. package/dist/{registry-DZsWoWqH.js → registry-DIJB0mJa.js} +687 -64
  49. package/dist/resolve--GsHj0Q1.js +171 -0
  50. package/dist/{resources-BMspgZO1.js → resources-BaP3p_LY.js} +3 -80
  51. package/dist/{run-D4V6mq8_.js → run-C5OPwhvS.js} +2 -2
  52. package/dist/run-CgLmD2vR.js +1345 -0
  53. package/dist/{scan-CRexsHOE.js → scan-Bj5y0zTZ.js} +1 -1
  54. package/dist/scan-v_WTE722.js +4 -0
  55. package/dist/{scope-Ct0_HoNq.js → scope-Bp_zwJOo.js} +5 -4
  56. package/dist/scope-CCb_7UvN.js +89 -0
  57. package/dist/sdk-TvT0p_nO.js +71 -0
  58. package/dist/selection-BltBpyp5.js +179 -0
  59. package/dist/series-TAixFBWW.js +685 -0
  60. package/dist/{server-Dv1VwbNh.js → server-CdVIboQn.js} +10 -8
  61. package/dist/server-CvJVusw3.js +29 -0
  62. package/dist/session-B8JNXkwN.js +6 -0
  63. package/dist/session-D3fgXQBt.js +219 -0
  64. package/dist/{session-UiPlLFn6.js → session-Ywim-P8M.js} +1 -1
  65. package/dist/{setup-UWLhQG3M.js → setup-zzjtTy8k.js} +9 -8
  66. package/dist/skills/index.json +5 -0
  67. package/dist/skills/superwall/SKILL.md +48 -30
  68. package/dist/skills/superwall/references/api.md +3 -2
  69. package/dist/skills/superwall-editor/SKILL.md +7 -5
  70. package/dist/skills/superwall-framework/SKILL.md +7 -5
  71. package/dist/skills/superwall-workspaces/SKILL.md +313 -0
  72. package/dist/skills/superwall-workspaces/references/cli.md +174 -0
  73. package/dist/skills/superwall-workspaces/references/slots.md +103 -0
  74. package/dist/{skills-CiWxt6vS.js → skills-2qYaUXGE.js} +4 -4
  75. package/dist/{skills-DzOvse9L.js → skills-8um2fBPS.js} +8 -8
  76. package/dist/{source-push-CX_k_yZD.js → source-push-kAep4gPe.js} +6 -5
  77. package/dist/{spinner-1uuKKZMc.js → spinner-BANVLncC.js} +16 -4
  78. package/dist/starter-CiLrp1cN.js +190 -0
  79. package/dist/status-CoYMK7QL.js +139 -0
  80. package/dist/{storage-CrXGgIbS.js → storage-DzP22xKn.js} +1 -1
  81. package/dist/storekit-D5eopLM0.js +17 -0
  82. package/dist/{storekit-CptdG4RJ.js → storekit-n1x0bWkQ.js} +4 -4
  83. package/dist/{telemetry-BqaPbM0k.js → telemetry-CXN6f-ZX.js} +1 -1
  84. package/dist/{token-zjjlkNDF.js → token-FmeHywYt.js} +1 -1
  85. package/dist/tools-skills/superwall/SKILL.md +49 -31
  86. package/dist/tools-skills/superwall/references/api.md +3 -2
  87. package/dist/tools-skills/superwall-editor/SKILL.md +7 -5
  88. package/dist/tools.d.ts +1 -1
  89. package/dist/tools.js +452 -27
  90. package/dist/try-BWbzgelb.js +120 -0
  91. package/dist/{selection-CgZJJ3FD.js → types-JdxmnCko.js} +1 -178
  92. package/dist/{upgrade-BBnmcyY2.js → upgrade-Bk5boOgW.js} +2 -2
  93. package/dist/{upgrade-AdyF7wXk.js → upgrade-CoWCEnoi.js} +2 -2
  94. package/package.json +5 -3
  95. package/dist/create-CBCDWuyo.js +0 -19
  96. package/dist/held-BL4oizD6.js +0 -16
  97. package/dist/login-DdrOmi6m.js +0 -16
  98. package/dist/push-B3Onn_mL.js +0 -24
  99. package/dist/scan-DUQjxOZf.js +0 -4
  100. package/dist/server-Cv-Ug9JF.js +0 -24
  101. package/dist/session-BCQuMcQ0.js +0 -6
  102. package/dist/storekit-B675ZNiA.js +0 -16
  103. /package/dist/{client-BZ1UbpXz.js → client-BJQXl62Q.js} +0 -0
  104. /package/dist/{devtools-pBl_vt03.js → devtools-ByZ6XYnn.js} +0 -0
  105. /package/dist/{input-vi0bou04.js → input-MDd67UIp.js} +0 -0
  106. /package/dist/{reports-CwwKLUh0.js → reports-CuhB1_ub.js} +0 -0
  107. /package/dist/{screenshot-file-tVBfUEIi.js → screenshot-file-XAS0Xy0e.js} +0 -0
  108. /package/dist/{storage-gRyQetN9.d.ts → storage-BjQCiTuz.d.ts} +0 -0
  109. /package/dist/{timing-BVxPrYq3.js → timing-Ca0TXY-A.js} +0 -0
@@ -1,10 +1,6 @@
1
- import { d as ENV_API_KEY, t as API_HOST, x as apiKeyFromEnv } from "./environment-djS0ik60.js";
2
- import { n as readSession } from "./storage-CrXGgIbS.js";
3
- import { r as createSuperwallApi } from "./client-ltxxHuxn.js";
4
1
  import { n as ui } from "./ui-D_qf3Gvw.js";
5
- import { k as isRecord, p as listApplications, y as platformLabel } from "./resources-BMspgZO1.js";
6
- import { C as formatLock, D as parseLock, E as originKey, L as writeSources, O as parseSources, j as writeApp, k as readLock, v as TYPES_FILE, w as formatSharedLock, x as NewerLockError } from "./selection-CgZJJ3FD.js";
7
- import { n as performLoginWithUi } from "./login-girc324T.js";
2
+ import { s as formatSharedLock, t as TYPES_FILE } from "./types-JdxmnCko.js";
3
+ import { a as classifyPath, c as isSurfaceRoot, l as mergeLockText, n as LOCK_FILE, o as derivedFilesOf, s as isOtherSurfaceDir, t as DERIVED_FILES } from "./scope-CCb_7UvN.js";
8
4
  import { execFile } from "node:child_process";
9
5
  import * as fs from "node:fs";
10
6
  import * as os$1 from "node:os";
@@ -12,158 +8,6 @@ import * as path from "node:path";
12
8
  import { promisify } from "node:util";
13
9
  import fg from "fast-glob";
14
10
 
15
- //#region src/core/paywalls/binding/apps.ts
16
- const PLATFORMS = [
17
- "ios",
18
- "android",
19
- "web"
20
- ];
21
- var AppBindingError = class extends Error {};
22
- const platformOf = (app) => {
23
- const normalized = (app.platform ?? "").toLowerCase();
24
- return PLATFORMS.find((platform) => platform === normalized);
25
- };
26
- function requirePlatform(app) {
27
- const platform = platformOf(app);
28
- if (platform !== void 0) return platform;
29
- 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.`);
30
- }
31
- const platformFor = (apps, value) => {
32
- if (value in apps) return value;
33
- return Object.entries(apps).find(([, id]) => id === value)?.[0];
34
- };
35
- function describePlatforms(apps) {
36
- return Object.keys(apps).join(", ");
37
- }
38
- async function resolveApps(input) {
39
- const { api, superwallDir } = input;
40
- let cached;
41
- const known = () => cached ??= listApplications(api);
42
- const current = () => readLock(superwallDir).apps;
43
- for (const platform of new Set(input.wanted ?? [])) {
44
- if (!PLATFORMS.some((known$1) => known$1 === platform)) throw new AppBindingError(`"${platform}" is not a platform — use one of ${PLATFORMS.join(", ")}.`);
45
- if (platform in current()) continue;
46
- const bound = new Set(Object.values(current()));
47
- const candidates = (await known()).filter((app) => !bound.has(String(app.id)) && platformOf(app) === platform);
48
- const only = candidates.length === 1 ? candidates[0] : void 0;
49
- if (only) {
50
- writeApp(superwallDir, platform, String(only.id));
51
- continue;
52
- }
53
- const picked = candidates.length > 1 && input.pickApplication ? await input.pickApplication(candidates, platform) : null;
54
- if (picked) {
55
- writeApp(superwallDir, platform, String(picked.id));
56
- continue;
57
- }
58
- const label = platformLabel(platform);
59
- 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).`);
60
- }
61
- if (Object.keys(current()).length > 0) return current();
62
- const apps = await known();
63
- if (apps.length === 1 && apps[0] !== void 0) {
64
- writeApp(superwallDir, requirePlatform(apps[0]), String(apps[0].id));
65
- return current();
66
- }
67
- if (apps.length > 1 && input.pickApplication) {
68
- const picked = await input.pickApplication(apps);
69
- if (picked) {
70
- writeApp(superwallDir, requirePlatform(picked), String(picked.id));
71
- return current();
72
- }
73
- }
74
- 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.");
75
- }
76
-
77
- //#endregion
78
- //#region src/core/paywalls/binding/targets.ts
79
- var TargetError = class extends Error {};
80
- const surfaceKey = (surface) => `${surface.kind}/${surface.id}`;
81
- const targetLabel = (target, multi) => multi ? `${target.surface.id} · ${target.platform}` : target.surface.id;
82
- function wantedPlatforms(surfaces, declared) {
83
- const wanted = /* @__PURE__ */ new Set();
84
- for (const surface of surfaces) for (const platform of declared[surfaceKey(surface)] ?? []) wanted.add(platform);
85
- return [...wanted];
86
- }
87
- function parsePlatformFlags(value) {
88
- return (Array.isArray(value) ? value : value === void 0 ? [] : [value]).flatMap((entry) => typeof entry === "string" ? entry.split(",") : []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
89
- }
90
- function planTargets(input) {
91
- const { surfaces, declared, apps } = input;
92
- const known = Object.keys(apps);
93
- const only = (input.only ?? []).map((entry) => {
94
- const platform = platformFor(apps, entry);
95
- if (platform === void 0) throw new TargetError(`This project has no app for "${entry}" — its platforms are ${describePlatforms(apps) || "none"} (the keys under \`apps\` in superwall.lock). Declare it in a config.ts with \`platforms: [...]\` to bind one.`);
96
- return platform;
97
- });
98
- const targets = [];
99
- for (const surface of surfaces) {
100
- const wanted = declared[surfaceKey(surface)];
101
- let platforms;
102
- if (wanted !== void 0) {
103
- if (wanted.length === 0) throw new TargetError(`${surface.kind} \`${surface.id}\` declares \`platforms: []\` — list at least one, or remove the field.`);
104
- for (const platform of wanted) if (!(platform in apps)) throw new TargetError(`${surface.kind} \`${surface.id}\` targets \`${platform}\`, which superwall.lock does not bind to an app.`);
105
- platforms = [...new Set(wanted)];
106
- } else if (known.length === 1 && known[0] !== void 0) platforms = [known[0]];
107
- else if (known.length === 0) throw new TargetError("This project is not bound to an app yet — run `superwall push` to pick one.");
108
- else throw new TargetError(`${surface.kind} \`${surface.id}\` doesn't say which platforms it's for, and this project pushes to several (${describePlatforms(apps)}). Add \`platforms: [...]\` to ${surface.kind}s/${surface.id}/config.ts.`);
109
- for (const platform of platforms) {
110
- if (only.length > 0 && !only.includes(platform)) continue;
111
- const applicationId = apps[platform];
112
- if (applicationId === void 0) continue;
113
- targets.push({
114
- surface,
115
- platform,
116
- applicationId
117
- });
118
- }
119
- }
120
- if (targets.length === 0 && only.length > 0) throw new TargetError(`No paywall or funnel targets ${only.map((platform) => `\`${platform}\``).join(", ")}.`);
121
- return targets;
122
- }
123
-
124
- //#endregion
125
- //#region src/core/paywalls/project/scaffold.ts
126
- const REACT_VERSION = "19.1.0";
127
- function projectPackageName(root) {
128
- const name = path.basename(root).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
129
- return name === "" || name === "superwall" ? "superwall-project" : name;
130
- }
131
- function packageJson(name, frameworkVersion) {
132
- return `${JSON.stringify({
133
- name,
134
- private: true,
135
- type: "module",
136
- scripts: {
137
- dev: "superwall dev",
138
- push: "superwall push",
139
- promote: "superwall promote",
140
- ship: "superwall publish"
141
- },
142
- dependencies: {
143
- react: REACT_VERSION,
144
- "react-dom": REACT_VERSION,
145
- superwall: frameworkVersion === "unknown" ? "*" : `^${frameworkVersion}`
146
- }
147
- }, null, 2)}\n`;
148
- }
149
- const GITIGNORE = `node_modules/
150
- .superwall
151
- .env
152
- `;
153
- function writeIfAbsent(file, content) {
154
- if (fs.existsSync(file)) return;
155
- try {
156
- fs.writeFileSync(file, content, { flag: "wx" });
157
- } catch {
158
- return;
159
- }
160
- }
161
- function writeProjectScaffold(options) {
162
- writeIfAbsent(path.join(options.superwallDir, "package.json"), packageJson(projectPackageName(options.root), options.frameworkVersion));
163
- writeIfAbsent(path.join(options.superwallDir, ".gitignore"), GITIGNORE);
164
- }
165
-
166
- //#endregion
167
11
  //#region src/core/paywalls/source/source.ts
168
12
  const HARD_EXCLUDES = [
169
13
  ".superwall/**",
@@ -205,7 +49,8 @@ function gitignoreExcludes(superwallDir) {
205
49
  }
206
50
  return excludes;
207
51
  }
208
- async function collectSourceFiles(superwallDir) {
52
+ const readFramework = (superwallDir, relative$1) => relative$1 === LOCK_FILE$1 ? Buffer.from(formatSharedLock(superwallDir)) : fs.readFileSync(path.join(superwallDir, relative$1));
53
+ async function collectSourceFiles(superwallDir, read = readFramework) {
209
54
  const entries = await fg("**/*", {
210
55
  cwd: superwallDir,
211
56
  dot: true,
@@ -233,42 +78,23 @@ async function collectSourceFiles(superwallDir) {
233
78
  ok: true,
234
79
  files: entries.sort().map((relative$1) => ({
235
80
  path: relative$1,
236
- content: relative$1 === LOCK_FILE$1 ? Buffer.from(formatSharedLock(superwallDir)) : fs.readFileSync(path.join(superwallDir, relative$1))
81
+ content: read(superwallDir, relative$1)
237
82
  }))
238
83
  };
239
84
  }
240
85
 
241
- //#endregion
242
- //#region src/core/paywalls/source/base.ts
243
- const LEGACY_FILE = path.join(".superwall", "source.json");
244
- function readLegacyBases(superwallDir) {
245
- const file = path.join(superwallDir, LEGACY_FILE);
246
- if (!fs.existsSync(file)) return {};
247
- let parsed;
248
- try {
249
- parsed = JSON.parse(fs.readFileSync(file, "utf8"));
250
- } catch (error) {
251
- const reason = error instanceof Error ? error.message : String(error);
252
- throw new Error(`Can't read ${file} (${reason}) — fix or delete it, then push again.`);
253
- }
254
- if (!isRecord(parsed) || !isRecord(parsed.repos)) throw new Error(`${file} isn't a source sync record — fix or delete it, then push again.`);
255
- return parseSources(parsed.repos);
256
- }
257
- function readSourceBase(superwallDir, repo) {
258
- return readLock(superwallDir).sources?.[repo] ?? readLegacyBases(superwallDir)[repo];
259
- }
260
- function writeSourceBase(superwallDir, repo, commitSha) {
261
- writeSources(superwallDir, {
262
- ...readLegacyBases(superwallDir),
263
- ...readLock(superwallDir).sources,
264
- [repo]: commitSha
265
- });
266
- fs.rmSync(path.join(superwallDir, LEGACY_FILE), { force: true });
267
- }
268
-
269
86
  //#endregion
270
87
  //#region src/core/paywalls/source/commit.ts
88
+ const workspaceCommitMessage = (input) => {
89
+ const surface = `workspace/${input.surface}`;
90
+ const trailers = [`Superwall-Workspace: ${input.workspaceId}`, `Superwall-Surface: ${surface}`];
91
+ if (input.sdk) trailers.push(`Superwall-Workspace-Sdk: ${input.sdk}`);
92
+ if (input.cli) trailers.push(`Superwall-Cli: ${input.cli}`);
93
+ const note = input.note?.replace(/\r\n?/g, "\n").trim();
94
+ return `push ${surface}\n${note ? `\n${note}\n` : ""}\n${trailers.join("\n")}\n`;
95
+ };
271
96
  const buildCommitMessage = (input) => {
97
+ if (input.kind === "workspace") return workspaceCommitMessage(input);
272
98
  const surface = `${input.kind}/${input.surface}`;
273
99
  const subject = `publish ${surface} v${input.version}`;
274
100
  const external = (input.external ?? []).filter((entry) => entry.trim() !== "");
@@ -296,87 +122,6 @@ const redact = (text, ...secrets) => {
296
122
  return safe;
297
123
  };
298
124
 
299
- //#endregion
300
- //#region src/core/paywalls/source/scope.ts
301
- const LOCK_FILE = "superwall.lock";
302
- const DERIVED_FILES = new Set([LOCK_FILE, TYPES_FILE]);
303
- const SURFACE_DIRS = {
304
- paywalls: "paywall",
305
- funnels: "funnel"
306
- };
307
- function surfaceOf(relative$1) {
308
- const [top, id, ...rest] = relative$1.split("/");
309
- const kind = top === void 0 ? void 0 : SURFACE_DIRS[top];
310
- if (!kind || !id || rest.length === 0) return void 0;
311
- return {
312
- kind,
313
- id
314
- };
315
- }
316
- function classifyPath(relative$1, scope) {
317
- if (DERIVED_FILES.has(relative$1)) return "derived";
318
- const surface = surfaceOf(relative$1);
319
- if (!surface) return "shared";
320
- return surface.kind === scope.kind && surface.id === scope.id ? "own" : "other";
321
- }
322
- const isSurfaceRoot = (top) => SURFACE_DIRS[top] !== void 0;
323
- const isOtherSurfaceDir = (top, child, scope) => {
324
- const kind = SURFACE_DIRS[top];
325
- return kind !== void 0 && !(kind === scope.kind && child === scope.id);
326
- };
327
- var SourceLockUnreadableError = class extends Error {
328
- constructor(reason) {
329
- 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.`);
330
- }
331
- };
332
- const readable = (text) => {
333
- try {
334
- return { lock: parseLock(text, LOCK_FILE) };
335
- } catch (error) {
336
- if (error instanceof NewerLockError) throw error;
337
- return { reason: error instanceof Error ? error.message : String(error) };
338
- }
339
- };
340
- function mergeLockText(theirs, mine, scope, options = {}) {
341
- const own = readable(mine);
342
- if (!("lock" in own)) return mine;
343
- if (theirs === void 0) return formatLock(withoutSources(own.lock));
344
- const read = readable(theirs);
345
- if (!("lock" in read)) {
346
- if (!options.replaceUnreadable) throw new SourceLockUnreadableError(read.reason);
347
- return formatLock(withoutSources(own.lock));
348
- }
349
- return mergeLocks(read.lock, own.lock, scope);
350
- }
351
- function mergeLocks(other, own, scope) {
352
- const section = (lock) => scope.kind === "paywall" ? lock.paywalls : lock.funnels;
353
- const conflicting = new Set(Object.entries(own.apps).filter(([platform, app]) => other.apps[platform] !== void 0 && other.apps[platform] !== app).map(([platform]) => platform));
354
- const ownApps = Object.fromEntries(Object.entries(own.apps).filter(([platform]) => !conflicting.has(platform)));
355
- const merged = {
356
- version: 1,
357
- apps: {
358
- ...other.apps,
359
- ...ownApps
360
- },
361
- paywalls: { ...other.paywalls },
362
- funnels: { ...other.funnels }
363
- };
364
- const target = section(merged);
365
- const theirEntry = section(other)[scope.id] ?? {};
366
- const mineEntry = section(own)[scope.id] ?? {};
367
- const entry = Object.fromEntries([...Object.entries(theirEntry).filter(([platform]) => conflicting.has(platform)), ...Object.entries(mineEntry).filter(([platform]) => !conflicting.has(platform))]);
368
- if (Object.keys(entry).length > 0) target[scope.id] = entry;
369
- else delete target[scope.id];
370
- const key = originKey(scope.kind, scope.id);
371
- const origins = { ...other.origins };
372
- const mineOrigin = own.origins?.[key];
373
- if (mineOrigin) origins[key] = mineOrigin;
374
- else delete origins[key];
375
- if (Object.keys(origins).length > 0) merged.origins = origins;
376
- return formatLock(merged);
377
- }
378
- const withoutSources = ({ sources: _,...lock }) => lock;
379
-
380
125
  //#endregion
381
126
  //#region src/core/paywalls/source/git.ts
382
127
  const run = promisify(execFile);
@@ -442,7 +187,7 @@ async function gitAvailable() {
442
187
  const LARGE_FILE_BYTES = 50 * 1024 * 1024;
443
188
  function materializeSourceTree(dir, files, scope, options = {}) {
444
189
  const theirs = /* @__PURE__ */ new Map();
445
- for (const derived of DERIVED_FILES) {
190
+ for (const derived of derivedFilesOf(scope)) {
446
191
  const existing = path.join(dir, derived);
447
192
  if (fs.existsSync(existing)) theirs.set(derived, fs.readFileSync(existing));
448
193
  }
@@ -455,7 +200,7 @@ function materializeSourceTree(dir, files, scope, options = {}) {
455
200
  if (entry === ".git") continue;
456
201
  const top = path.join(dir, entry);
457
202
  const isDir = fs.lstatSync(top).isDirectory();
458
- if (keepShared && !(isDir && isSurfaceRoot(entry))) continue;
203
+ if (keepShared && !(isDir && isSurfaceRoot(entry, scope))) continue;
459
204
  if (!isDir) {
460
205
  remove(top);
461
206
  continue;
@@ -483,12 +228,12 @@ function materializeSourceTree(dir, files, scope, options = {}) {
483
228
  for (const file of files) {
484
229
  if (classifyPath(file.path, scope) === "other") continue;
485
230
  if (file.content.byteLength > LARGE_FILE_BYTES) large.push(file.path);
486
- if (file.path === LOCK_FILE) write(file.path, mergeLockText(theirs.get(LOCK_FILE)?.toString("utf8"), file.content.toString("utf8"), scope, { replaceUnreadable: options.overwrite }));
231
+ if (file.path === LOCK_FILE && scope.kind !== "workspace") write(file.path, mergeLockText(theirs.get(LOCK_FILE)?.toString("utf8"), file.content.toString("utf8"), scope, { replaceUnreadable: options.overwrite }));
487
232
  else write(file.path, file.content);
488
233
  theirs.delete(file.path);
489
234
  }
490
235
  for (const [derived, content] of theirs) write(derived, content);
491
- 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.`);
236
+ if (large.length > 0) ui.warn(`Committing ${large.length > 1 ? `${large.length} files` : large[0]} over 50 MB — every future clone of this ${scope.kind === "workspace" ? "workspace's" : "app's"} source repo pays for it.`);
492
237
  }
493
238
  const SHOWN_FILES = 5;
494
239
  const listFiles = (files) => {
@@ -497,17 +242,29 @@ const listFiles = (files) => {
497
242
  return rest > 0 ? `${shown} and ${rest} more` : shown;
498
243
  };
499
244
  var SourceConflictError = class extends Error {
500
- constructor(files) {
501
- super(`Someone else published changes to ${listFiles(files)} since this project last synced. Run \`superwall pull\` to bring their changes into this project, then publish again — or rerun with --overwrite-source to replace this paywall's source with yours.`);
245
+ constructor(files, kind = "paywall") {
246
+ super(kind === "workspace" ? `Someone else pushed changes to ${listFiles(files)} since this project last synced. Run \`superwall workspaces pull\` to bring their changes into this project, then push again, or rerun with --overwrite-source to replace this workspace's source with yours.` : `Someone else published changes to ${listFiles(files)} since this project last synced. Run \`superwall pull\` to bring their changes into this project, then publish again — or rerun with --overwrite-source to replace this paywall's source with yours.`);
502
247
  this.files = files;
503
248
  }
504
249
  };
505
250
  var SourceDivergedError = class extends Error {
506
- constructor(files) {
507
- super(`The source repo differs from this project in ${listFiles(files)}, and superwall.lock records no sync point to merge from. Run \`superwall pull\` to merge the source repo into this project, then publish again — or rerun with --overwrite-source to replace this paywall's source with yours.`);
251
+ constructor(files, kind = "paywall") {
252
+ super(kind === "workspace" ? `The source repo differs from this project in ${listFiles(files)}, and this project records no sync point to merge from. Run \`superwall workspaces pull\` to merge the source repo into this project, then push again, or rerun with --overwrite-source to replace this workspace's source with yours.` : `The source repo differs from this project in ${listFiles(files)}, and superwall.lock records no sync point to merge from. Run \`superwall pull\` to merge the source repo into this project, then publish again — or rerun with --overwrite-source to replace this paywall's source with yours.`);
508
253
  this.files = files;
509
254
  }
510
255
  };
256
+ const printable = (text) => text.replace(/[\p{Cc}\p{Cf}]/gu, "");
257
+ function parseCommits(output) {
258
+ const fields = output.split("\0");
259
+ const commits = [];
260
+ for (let index = 0; index + 3 < fields.length; index += 4) commits.push({
261
+ sha: (fields[index] ?? "").trim(),
262
+ author: printable(fields[index + 1] ?? ""),
263
+ email: printable(fields[index + 2] ?? ""),
264
+ subject: printable(fields[index + 3] ?? "")
265
+ });
266
+ return commits;
267
+ }
511
268
  const PUSH_ATTEMPTS = 3;
512
269
  async function pushSourceTree(input) {
513
270
  const { access } = input;
@@ -515,8 +272,8 @@ async function pushSourceTree(input) {
515
272
  const dir = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-source-"));
516
273
  const env = gitEnv(access.token);
517
274
  const committing = gitEnv(access.token, {
518
- GIT_AUTHOR_NAME: process.env.GIT_AUTHOR_NAME || AUTHOR.name,
519
- GIT_AUTHOR_EMAIL: process.env.GIT_AUTHOR_EMAIL || AUTHOR.email,
275
+ GIT_AUTHOR_NAME: input.author?.name ?? (process.env.GIT_AUTHOR_NAME || AUTHOR.name),
276
+ GIT_AUTHOR_EMAIL: input.author?.email ?? (process.env.GIT_AUTHOR_EMAIL || AUTHOR.email),
520
277
  GIT_COMMITTER_NAME: AUTHOR.name,
521
278
  GIT_COMMITTER_EMAIL: AUTHOR.email
522
279
  });
@@ -531,6 +288,29 @@ async function pushSourceTree(input) {
531
288
  "--quiet",
532
289
  `${ref}^{commit}`
533
290
  ]).then((out) => out.trim(), () => void 0);
291
+ const incoming = [];
292
+ const finished = (result) => incoming.length > 0 ? {
293
+ ...result,
294
+ incoming
295
+ } : result;
296
+ const known = /* @__PURE__ */ new Set();
297
+ const confirmIncoming = async (from, to) => {
298
+ if (!input.confirmIncoming) return;
299
+ known.add(from);
300
+ const reviewed = input.reviewed ? await revParse(input.reviewed) : void 0;
301
+ if (reviewed) known.add(reviewed);
302
+ const commits = parseCommits(await run$1([
303
+ "log",
304
+ "-z",
305
+ "--format=%H%x00%an%x00%ae%x00%s",
306
+ to,
307
+ ...[...known].map((ref) => `^${ref}`)
308
+ ]));
309
+ known.add(to);
310
+ if (commits.length === 0) return;
311
+ await input.confirmIncoming(commits);
312
+ incoming.push(...commits);
313
+ };
534
314
  try {
535
315
  await cloneSource(access, dir, {
536
316
  env,
@@ -553,16 +333,19 @@ async function pushSourceTree(input) {
553
333
  const onRemote = head !== void 0 && !base;
554
334
  const local = onRemote ? await snapshotLocal(run$1, dir, input.files, scope, head, committing) : void 0;
555
335
  materializeSourceTree(dir, input.files, scope, {
556
- onRemote,
336
+ onRemote: onRemote && scope.kind !== "workspace",
557
337
  overwrite: input.overwrite
558
338
  });
559
339
  await run$1(["add", "-A"]);
560
340
  const dirty = (await run$1(["status", "--porcelain"])).trim();
561
- if (dirty === "" && local === void 0) return {
562
- commitSha: head ?? "",
563
- status: "unchanged",
564
- syncedTo: base ?? head
565
- };
341
+ if (dirty === "" && local === void 0) {
342
+ if (base && head && base !== head) await confirmIncoming(base, head);
343
+ return finished({
344
+ commitSha: head ?? "",
345
+ status: "unchanged",
346
+ syncedTo: base ?? head
347
+ });
348
+ }
566
349
  if (onRemote && !input.overwrite) {
567
350
  const refused = overwrittenPaths(await run$1([
568
351
  "diff",
@@ -571,8 +354,8 @@ async function pushSourceTree(input) {
571
354
  "--no-renames",
572
355
  "-z",
573
356
  "HEAD"
574
- ]));
575
- if (refused.length > 0) throw new SourceDivergedError(refused);
357
+ ]), derivedFilesOf(scope));
358
+ if (refused.length > 0) throw new SourceDivergedError(refused, scope.kind);
576
359
  }
577
360
  if (local !== void 0 && head !== void 0) await run$1([
578
361
  "reset",
@@ -610,11 +393,14 @@ async function pushSourceTree(input) {
610
393
  for (let attempt = 1;; attempt++) {
611
394
  const upstream = parent ? await revParse(`origin/${access.branch}`) : void 0;
612
395
  if (upstream && upstream !== parent) {
613
- if (await isAncestor(own, upstream)) return {
614
- commitSha: upstream,
615
- status: "unchanged",
616
- syncedTo
617
- };
396
+ if (await isAncestor(own, upstream)) {
397
+ await confirmIncoming(own, upstream);
398
+ return finished({
399
+ commitSha: upstream,
400
+ status: "unchanged",
401
+ syncedTo
402
+ });
403
+ }
618
404
  await run$1([
619
405
  "reset",
620
406
  "--quiet",
@@ -628,6 +414,7 @@ async function pushSourceTree(input) {
628
414
  own,
629
415
  scope
630
416
  });
417
+ await confirmIncoming(parent ?? own, upstream);
631
418
  }
632
419
  try {
633
420
  await run$1([
@@ -635,11 +422,11 @@ async function pushSourceTree(input) {
635
422
  "origin",
636
423
  `HEAD:${access.branch}`
637
424
  ]);
638
- return {
425
+ return finished({
639
426
  commitSha: await revParse("HEAD") ?? own,
640
427
  status,
641
428
  syncedTo
642
- };
429
+ });
643
430
  } catch (error) {
644
431
  if (!parent || attempt >= PUSH_ATTEMPTS || !isRejected(error)) throw error;
645
432
  await run$1([
@@ -703,13 +490,13 @@ async function snapshotLocal(run$1, dir, files, scope, head, committing) {
703
490
  "superwall: the project this push was made from"
704
491
  ], { env: committing })).trim();
705
492
  }
706
- function overwrittenPaths(nameStatus) {
493
+ function overwrittenPaths(nameStatus, derived) {
707
494
  const fields = nameStatus.split("\0").filter(Boolean);
708
495
  const paths = [];
709
496
  for (let index = 0; index + 1 < fields.length; index += 2) {
710
497
  const status = fields[index];
711
498
  const file = fields[index + 1];
712
- if (file === void 0 || status === "A" || DERIVED_FILES.has(file)) continue;
499
+ if (file === void 0 || status === "A" || derived.has(file)) continue;
713
500
  paths.push(file);
714
501
  }
715
502
  return paths;
@@ -764,7 +551,8 @@ async function mergeUpstream(upstream, messageFile, { run: run$1, committing, di
764
551
  "--diff-filter=U",
765
552
  "-z"
766
553
  ]).catch(() => "")).split("\0").filter(Boolean);
767
- const blocking = conflicted.filter((file) => !DERIVED_FILES.has(file));
554
+ const derived = derivedFilesOf(scope);
555
+ const blocking = conflicted.filter((file) => !derived.has(file));
768
556
  const merging = await run$1([
769
557
  "rev-parse",
770
558
  "--verify",
@@ -773,15 +561,17 @@ async function mergeUpstream(upstream, messageFile, { run: run$1, committing, di
773
561
  ]).then(() => true, () => false);
774
562
  if (blocking.length > 0 || failure !== void 0 && conflicted.length === 0) {
775
563
  await run$1(["merge", "--abort"]).catch(() => void 0);
776
- if (blocking.length > 0) throw new SourceConflictError(blocking);
564
+ if (blocking.length > 0) throw new SourceConflictError(blocking, scope.kind);
777
565
  throw failure;
778
566
  }
779
567
  if (!merging) return;
780
568
  const show = (ref, file) => run$1(["show", `${ref}:${file}`]).then((text) => text, () => void 0);
781
- const theirsLock = await show(upstream, LOCK_FILE);
782
- const mineLock = await show(own, LOCK_FILE);
783
- await settle(run$1, dir, LOCK_FILE, mineLock === void 0 ? theirsLock : mergeLockText(theirsLock, mineLock, scope));
784
- for (const file of DERIVED_FILES) if (file !== LOCK_FILE) await settle(run$1, dir, file, await show(own, file));
569
+ if (scope.kind !== "workspace") {
570
+ const theirsLock = await show(upstream, LOCK_FILE);
571
+ const mineLock = await show(own, LOCK_FILE);
572
+ await settle(run$1, dir, LOCK_FILE, mineLock === void 0 ? theirsLock : mergeLockText(theirsLock, mineLock, scope));
573
+ }
574
+ for (const file of derived) if (file !== LOCK_FILE) await settle(run$1, dir, file, await show(own, file));
785
575
  await run$1([
786
576
  "commit",
787
577
  "--quiet",
@@ -806,7 +596,7 @@ var PullConflictError = class extends Error {
806
596
  }
807
597
  };
808
598
  async function pullSourceTree(input) {
809
- const { access } = input;
599
+ const { access, derived = DERIVED_FILES } = input;
810
600
  const secrets = [access.token, tokenSecret(access.token)];
811
601
  const dir = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-pull-"));
812
602
  const env = gitEnv(access.token, {
@@ -876,7 +666,7 @@ async function pullSourceTree(input) {
876
666
  "-z"
877
667
  ]));
878
668
  if (failure !== void 0 && conflicted.length === 0) throw failure;
879
- const blocking = conflicted.filter((file) => !DERIVED_FILES.has(file));
669
+ const blocking = conflicted.filter((file) => !derived.has(file));
880
670
  if (blocking.length > 0 && !input.theirs) throw new PullConflictError(blocking);
881
671
  const present = new Set((await run$1([
882
672
  "ls-tree",
@@ -920,7 +710,7 @@ async function pullSourceTree(input) {
920
710
  for (let index = 0; index + 1 < staged.length; index += 2) {
921
711
  const status = staged[index];
922
712
  const file = staged[index + 1];
923
- if (file === void 0 || DERIVED_FILES.has(file)) continue;
713
+ if (file === void 0 || derived.has(file)) continue;
924
714
  if (status === "D") {
925
715
  removed.push({
926
716
  path: file,
@@ -967,32 +757,4 @@ function replaceTree(dir, files) {
967
757
  const isRejected = (error) => error instanceof GitError && /rejected|non-fast-forward|fetch first|stale info|failed to push some refs/i.test(error.message);
968
758
 
969
759
  //#endregion
970
- //#region src/core/paywalls/project/session.ts
971
- var LoginRequiredError = class extends Error {
972
- constructor() {
973
- super(`Pushing paywalls needs a Superwall account.
974
- Interactively: run \`superwall login\`.
975
- In an agent: run \`superwall login\`, have the link it prints approved, then \`superwall login --poll\`.
976
- In CI: set ${ENV_API_KEY} to an org API key (sk_…).`);
977
- this.name = "LoginRequiredError";
978
- }
979
- };
980
- async function requireApi(interactive, login = performLoginWithUi) {
981
- const apiKey = apiKeyFromEnv();
982
- if (apiKey) return createSuperwallApi({
983
- authMethod: "api_key",
984
- apiKey,
985
- host: process.env.SUPERWALL_API_HOST ?? API_HOST(),
986
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
987
- });
988
- const session = readSession();
989
- if (session) return createSuperwallApi(session);
990
- if (!interactive) throw new LoginRequiredError();
991
- ui.info("You're not signed in to Superwall yet — let's fix that.");
992
- const signedIn = await login();
993
- if (!signedIn) throw new LoginRequiredError();
994
- return createSuperwallApi(signedIn);
995
- }
996
-
997
- //#endregion
998
- export { requirePlatform as _, pushSourceTree as a, writeSourceBase as c, writeProjectScaffold as d, parsePlatformFlags as f, PLATFORMS as g, wantedPlatforms as h, pullSourceTree as i, collectSourceFiles as l, targetLabel as m, requireApi as n, statIfPresent as o, planTargets as p, gitAvailable as r, readSourceBase as s, LoginRequiredError as t, projectPackageName as u, resolveApps as v };
760
+ export { collectSourceFiles as a, statIfPresent as i, pullSourceTree as n, pushSourceTree as r, gitAvailable as t };
@@ -0,0 +1,17 @@
1
+ import "./token-FmeHywYt.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-BWT2S4qC.js";
4
+ import "./storage-DzP22xKn.js";
5
+ import "./client-AI9H4GGB.js";
6
+ import { t as upsertHeldKey } from "./held-D3PUNky2.js";
7
+ import "./config-CGcG7GOt.js";
8
+ import "./spinner-BANVLncC.js";
9
+ import "./ui-D_qf3Gvw.js";
10
+ import "./orgs-D6Kk96mG.js";
11
+ import "./resources-BaP3p_LY.js";
12
+ import "./org-C04eAO-j.js";
13
+ import "./lookup-gjcKIZvh.js";
14
+ import "./scope-Bp_zwJOo.js";
15
+ import "./client-BJQXl62Q.js";
16
+
17
+ export { upsertHeldKey };
@@ -1,11 +1,11 @@
1
1
  import { l as readJson, o as cache } from "./output-Ggzq5_-t.js";
2
- import { t as ApiError } from "./client-ltxxHuxn.js";
3
- import { d as readInput, t as apiCall } from "./spinner-1uuKKZMc.js";
4
- import { A as listField, M as textField, O as field, c as createProject, k as isRecord, m as listProjects, r as createApplication } from "./resources-BMspgZO1.js";
5
- import { n as orgForNewProject } from "./org-BrR4HGvl.js";
6
- import { n as findApplication } from "./lookup-us5vu5od.js";
7
- import { r as pickOrganization } from "./scope-Ct0_HoNq.js";
8
- import { a as listAscConfigs, c as replaceAppPurchaseKey, l as replaceAscConfig, r as createAscConfig, s as replaceAppAscKey, t as ascProxy } from "./client-BZ1UbpXz.js";
2
+ import { t as ApiError } from "./client-AI9H4GGB.js";
3
+ import { d as readInput, t as apiCall } from "./spinner-BANVLncC.js";
4
+ import { A as listField, M as textField, O as field, c as createProject, k as isRecord, m as listProjects, r as createApplication } from "./resources-BaP3p_LY.js";
5
+ import { n as orgForNewProject } from "./org-C04eAO-j.js";
6
+ import { n as findApplication } from "./lookup-gjcKIZvh.js";
7
+ import { r as pickOrganization } from "./scope-Bp_zwJOo.js";
8
+ import { a as listAscConfigs, c as replaceAppPurchaseKey, l as replaceAscConfig, r as createAscConfig, s as replaceAppAscKey, t as ascProxy } from "./client-BJQXl62Q.js";
9
9
 
10
10
  //#region src/core/app-store-connect/api/spec.ts
11
11
  const REFRESH_TTL_MS = 10080 * 60 * 1e3;