@superwall/cli 2.4.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +7 -0
  2. package/dist/{apple-Bx_fm5M-.js → apple-BSKxY7Gx.js} +16 -15
  3. package/dist/approve-DbwsYO4s.js +190 -0
  4. package/dist/{assets-W5yvyf0V.js → assets-CqpFg5mM.js} +3 -3
  5. package/dist/auth.d.ts +1 -1
  6. package/dist/auth.js +3 -3
  7. package/dist/{billing-C4lXR0xG.js → billing-BopwIhR3.js} +3 -3
  8. package/dist/{bind-82oTpHZ3.js → bind-DOF3o3FR.js} +4 -4
  9. package/dist/browser-Bp3yRKlU.js +36 -0
  10. package/dist/{build-7_8cBgBm.js → build-BF22vVdV.js} +11 -7
  11. package/dist/{client-ltxxHuxn.js → client-DHlsTaP1.js} +3 -3
  12. package/dist/{create-DEyveHS6.js → create-CboPfAlN.js} +39 -67
  13. package/dist/{create-Dk8U_B49.js → create-CiZzZrru.js} +8 -8
  14. package/dist/create-DAkNdEzt.js +20 -0
  15. package/dist/design-lint-CvgcSzVg.js +158 -0
  16. package/dist/{doctor-Df2GwS4K.js → doctor-BqZGaQE5.js} +6 -6
  17. package/dist/download-F8OtTJze.js +58 -0
  18. package/dist/{drivers-CTyYdBL7.js → drivers-DkboeR1c.js} +3 -3
  19. package/dist/entry.js +25 -24
  20. package/dist/{environment-djS0ik60.js → environment-FR3bcq0D.js} +5 -4
  21. package/dist/{existing-Das3PHGG.js → existing-C6TTT6c4.js} +2 -2
  22. package/dist/{session-CV0P8BjK.js → git-DqDPnldI.js} +109 -338
  23. package/dist/{held-B8EFWDEc.js → held-C2IjAyg6.js} +7 -7
  24. package/dist/held-KVcYIplR.js +17 -0
  25. package/dist/install-DoSYCwLL.js +109 -0
  26. package/dist/{integrate-Cz48dm_h.js → integrate-BSqd2wgI.js} +27 -25
  27. package/dist/login-BiwaQkXS.js +17 -0
  28. package/dist/{login-CiK5T4w8.js → login-C6FcBQZg.js} +8 -41
  29. package/dist/{login-girc324T.js → login-dRPPnGr7.js} +2 -1
  30. package/dist/{lookup-us5vu5od.js → lookup-D23dAOz6.js} +3 -2
  31. package/dist/{migrate-DaVwhdov.js → migrate-CDdUCTH3.js} +30 -25
  32. package/dist/{migration-cS6UGeUj.js → migration-r9plM7F6.js} +29 -11
  33. package/dist/{notification-url-Hg42tAbW.js → notification-url-rdnENCxt.js} +4 -4
  34. package/dist/{open-BIuOZ9ka.js → open-DVdE3HnK.js} +2 -2
  35. package/dist/{org-BrR4HGvl.js → org-DZ41muzA.js} +3 -2
  36. package/dist/organization-DIODPOwO.js +39 -0
  37. package/dist/orgs-BxlwcvTu.js +81 -0
  38. package/dist/{paths-CdwjySxK.js → paths-BaeoxDze.js} +1 -1
  39. package/dist/{playbook-BJ3opYIS.js → playbook-B-Pdonhg.js} +10 -10
  40. package/dist/{products-DH_fK9tY.js → products-Cqq59DBQ.js} +1 -1
  41. package/dist/project-DHU5wc3R.js +47 -0
  42. package/dist/{promote-BQO-1ScY.js → promote-Ca4URuHY.js} +24 -18
  43. package/dist/{pull-BhRswq6x.js → pull-CQcTZxW8.js} +9 -28
  44. package/dist/pull-DRMIxqR8.js +36 -0
  45. package/dist/pull-_qs90vGA.js +106 -0
  46. package/dist/{push-CR110qRh.js → push-BlZoIwIj.js} +122 -20
  47. package/dist/push-Cb4g_l1K.js +30 -0
  48. package/dist/push-DQE48h_M.js +290 -0
  49. package/dist/push-DZKsd6Dp.js +22 -0
  50. package/dist/{registry-DZsWoWqH.js → registry-FNG-uiIt.js} +712 -68
  51. package/dist/resolve-DGePiHgL.js +196 -0
  52. package/dist/{resources-BMspgZO1.js → resources-COOEvqqW.js} +3 -80
  53. package/dist/run-Czbb-sHR.js +1368 -0
  54. package/dist/{run-D4V6mq8_.js → run-DpYDOAw-.js} +2 -2
  55. package/dist/scan-2WqHGkjU.js +4 -0
  56. package/dist/{scan-CRexsHOE.js → scan-BZS2FZeU.js} +1 -1
  57. package/dist/{scope-Ct0_HoNq.js → scope-BJQ-KcQg.js} +5 -4
  58. package/dist/scope-t_SqFN6W.js +103 -0
  59. package/dist/sdk-CyttTnGf.js +71 -0
  60. package/dist/selection-CWfI4a0O.js +179 -0
  61. package/dist/series--Wp7TngJ.js +685 -0
  62. package/dist/{server-Dv1VwbNh.js → server-BmmOj7bh.js} +10 -8
  63. package/dist/server-BqLPwcy9.js +29 -0
  64. package/dist/session-BHBIGscL.js +6 -0
  65. package/dist/{session-UiPlLFn6.js → session-BpYpOgaY.js} +1 -1
  66. package/dist/session-DYdxTNZf.js +219 -0
  67. package/dist/{setup-UWLhQG3M.js → setup-DW50luOZ.js} +9 -8
  68. package/dist/skills/index.json +5 -0
  69. package/dist/skills/superwall/SKILL.md +48 -30
  70. package/dist/skills/superwall/references/api.md +3 -2
  71. package/dist/skills/superwall-editor/SKILL.md +7 -5
  72. package/dist/skills/superwall-framework/SKILL.md +7 -5
  73. package/dist/skills/superwall-workspaces/SKILL.md +314 -0
  74. package/dist/skills/superwall-workspaces/references/cli.md +174 -0
  75. package/dist/skills/superwall-workspaces/references/slots.md +103 -0
  76. package/dist/{skills-DzOvse9L.js → skills-Bbtq8V_D.js} +8 -8
  77. package/dist/{skills-CiWxt6vS.js → skills-Cm1j2d1W.js} +4 -4
  78. package/dist/{source-push-CX_k_yZD.js → source-push-B3c-VLfe.js} +43 -25
  79. package/dist/{spinner-1uuKKZMc.js → spinner-025_eqCX.js} +16 -4
  80. package/dist/starter-hcwocv_Z.js +190 -0
  81. package/dist/status-K1IGp6pe.js +142 -0
  82. package/dist/{storage-CrXGgIbS.js → storage-CUMgpcVH.js} +1 -1
  83. package/dist/{storekit-CptdG4RJ.js → storekit-Cb0TkToV.js} +4 -4
  84. package/dist/storekit-Dewj_5qg.js +17 -0
  85. package/dist/{telemetry-BqaPbM0k.js → telemetry-ekUQuhLJ.js} +1 -1
  86. package/dist/{token-zjjlkNDF.js → token-B2PduqrR.js} +1 -1
  87. package/dist/tools-skills/superwall/SKILL.md +49 -31
  88. package/dist/tools-skills/superwall/references/api.md +3 -2
  89. package/dist/tools-skills/superwall-editor/SKILL.md +7 -5
  90. package/dist/tools.d.ts +1 -1
  91. package/dist/tools.js +479 -34
  92. package/dist/try-BUnhITXS.js +120 -0
  93. package/dist/{selection-CgZJJ3FD.js → types-CB6O_wjy.js} +1 -178
  94. package/dist/{upgrade-BBnmcyY2.js → upgrade-CI7K1UZ-.js} +2 -2
  95. package/dist/{upgrade-AdyF7wXk.js → upgrade-DfZfDljd.js} +2 -2
  96. package/package.json +5 -3
  97. package/dist/create-CBCDWuyo.js +0 -19
  98. package/dist/held-BL4oizD6.js +0 -16
  99. package/dist/login-DdrOmi6m.js +0 -16
  100. package/dist/push-B3Onn_mL.js +0 -24
  101. package/dist/scan-DUQjxOZf.js +0 -4
  102. package/dist/server-Cv-Ug9JF.js +0 -24
  103. package/dist/session-BCQuMcQ0.js +0 -6
  104. package/dist/storekit-B675ZNiA.js +0 -16
  105. /package/dist/{client-BZ1UbpXz.js → client-BJQXl62Q.js} +0 -0
  106. /package/dist/{devtools-pBl_vt03.js → devtools-ByZ6XYnn.js} +0 -0
  107. /package/dist/{input-vi0bou04.js → input-MDd67UIp.js} +0 -0
  108. /package/dist/{reports-CwwKLUh0.js → reports-BZfxvenS.js} +0 -0
  109. /package/dist/{screenshot-file-tVBfUEIi.js → screenshot-file-XAS0Xy0e.js} +0 -0
  110. /package/dist/{storage-gRyQetN9.d.ts → storage-Bdz5AmqS.d.ts} +0 -0
  111. /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-CB6O_wjy.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-t_SqFN6W.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,31 @@ 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 noteBody = (note) => {
89
+ const text = note?.replace(/\r\n?/g, "\n").trim();
90
+ return text ? `\n${text}\n` : "";
91
+ };
92
+ const workspaceCommitMessage = (input) => {
93
+ const surface = `workspace/${input.surface}`;
94
+ const trailers = [`Superwall-Workspace: ${input.workspaceId}`, `Superwall-Surface: ${surface}`];
95
+ if (input.sdk) trailers.push(`Superwall-Workspace-Sdk: ${input.sdk}`);
96
+ if (input.cli) trailers.push(`Superwall-Cli: ${input.cli}`);
97
+ return `push ${surface}\n${noteBody(input.note)}\n${trailers.join("\n")}\n`;
98
+ };
271
99
  const buildCommitMessage = (input) => {
100
+ if (input.kind === "workspace") return workspaceCommitMessage(input);
101
+ if (input.kind === "project") {
102
+ const trailers$1 = [`Superwall-Application: ${input.applicationId}`, `Superwall-Framework: ${input.framework}`];
103
+ if (input.cli) trailers$1.push(`Superwall-Cli: ${input.cli}`);
104
+ return `publish project source\n${noteBody(input.note)}\n${trailers$1.join("\n")}\n`;
105
+ }
272
106
  const surface = `${input.kind}/${input.surface}`;
273
107
  const subject = `publish ${surface} v${input.version}`;
274
108
  const external = (input.external ?? []).filter((entry) => entry.trim() !== "");
@@ -283,8 +117,7 @@ const buildCommitMessage = (input) => {
283
117
  if (input.snapshotSha) trailers.push(`Superwall-Snapshot: ${input.snapshotSha}`);
284
118
  trailers.push(`Superwall-Framework: ${input.framework}`);
285
119
  if (input.cli) trailers.push(`Superwall-Cli: ${input.cli}`);
286
- const note = input.note?.replace(/\r\n?/g, "\n").trim();
287
- return `${subject}\n${note ? `\n${note}\n` : ""}\n${trailers.join("\n")}\n`;
120
+ return `${subject}\n${noteBody(input.note)}\n${trailers.join("\n")}\n`;
288
121
  };
289
122
  const tokenSecret = (token) => token.split("?")[0] ?? token;
290
123
  const redact = (text, ...secrets) => {
@@ -296,87 +129,6 @@ const redact = (text, ...secrets) => {
296
129
  return safe;
297
130
  };
298
131
 
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
132
  //#endregion
381
133
  //#region src/core/paywalls/source/git.ts
382
134
  const run = promisify(execFile);
@@ -442,7 +194,7 @@ async function gitAvailable() {
442
194
  const LARGE_FILE_BYTES = 50 * 1024 * 1024;
443
195
  function materializeSourceTree(dir, files, scope, options = {}) {
444
196
  const theirs = /* @__PURE__ */ new Map();
445
- for (const derived of DERIVED_FILES) {
197
+ for (const derived of derivedFilesOf(scope)) {
446
198
  const existing = path.join(dir, derived);
447
199
  if (fs.existsSync(existing)) theirs.set(derived, fs.readFileSync(existing));
448
200
  }
@@ -455,7 +207,7 @@ function materializeSourceTree(dir, files, scope, options = {}) {
455
207
  if (entry === ".git") continue;
456
208
  const top = path.join(dir, entry);
457
209
  const isDir = fs.lstatSync(top).isDirectory();
458
- if (keepShared && !(isDir && isSurfaceRoot(entry))) continue;
210
+ if (keepShared && !(isDir && isSurfaceRoot(entry, scope))) continue;
459
211
  if (!isDir) {
460
212
  remove(top);
461
213
  continue;
@@ -483,12 +235,12 @@ function materializeSourceTree(dir, files, scope, options = {}) {
483
235
  for (const file of files) {
484
236
  if (classifyPath(file.path, scope) === "other") continue;
485
237
  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 }));
238
+ 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
239
  else write(file.path, file.content);
488
240
  theirs.delete(file.path);
489
241
  }
490
242
  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.`);
243
+ 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
244
  }
493
245
  const SHOWN_FILES = 5;
494
246
  const listFiles = (files) => {
@@ -496,18 +248,31 @@ const listFiles = (files) => {
496
248
  const rest = files.length - SHOWN_FILES;
497
249
  return rest > 0 ? `${shown} and ${rest} more` : shown;
498
250
  };
251
+ const replaced = (kind) => kind === "project" ? "the project's shared files" : "this paywall's source";
499
252
  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.`);
253
+ constructor(files, kind = "paywall") {
254
+ 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 ${replaced(kind)} with yours.`);
502
255
  this.files = files;
503
256
  }
504
257
  };
505
258
  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.`);
259
+ constructor(files, kind = "paywall") {
260
+ 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 ${replaced(kind)} with yours.`);
508
261
  this.files = files;
509
262
  }
510
263
  };
264
+ const printable = (text) => text.replace(/[\p{Cc}\p{Cf}]/gu, "");
265
+ function parseCommits(output) {
266
+ const fields = output.split("\0");
267
+ const commits = [];
268
+ for (let index = 0; index + 3 < fields.length; index += 4) commits.push({
269
+ sha: (fields[index] ?? "").trim(),
270
+ author: printable(fields[index + 1] ?? ""),
271
+ email: printable(fields[index + 2] ?? ""),
272
+ subject: printable(fields[index + 3] ?? "")
273
+ });
274
+ return commits;
275
+ }
511
276
  const PUSH_ATTEMPTS = 3;
512
277
  async function pushSourceTree(input) {
513
278
  const { access } = input;
@@ -515,8 +280,8 @@ async function pushSourceTree(input) {
515
280
  const dir = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-source-"));
516
281
  const env = gitEnv(access.token);
517
282
  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,
283
+ GIT_AUTHOR_NAME: input.author?.name ?? (process.env.GIT_AUTHOR_NAME || AUTHOR.name),
284
+ GIT_AUTHOR_EMAIL: input.author?.email ?? (process.env.GIT_AUTHOR_EMAIL || AUTHOR.email),
520
285
  GIT_COMMITTER_NAME: AUTHOR.name,
521
286
  GIT_COMMITTER_EMAIL: AUTHOR.email
522
287
  });
@@ -531,12 +296,35 @@ async function pushSourceTree(input) {
531
296
  "--quiet",
532
297
  `${ref}^{commit}`
533
298
  ]).then((out) => out.trim(), () => void 0);
299
+ const incoming = [];
300
+ const finished = (result) => incoming.length > 0 ? {
301
+ ...result,
302
+ incoming
303
+ } : result;
304
+ const known = /* @__PURE__ */ new Set();
305
+ const confirmIncoming = async (from, to) => {
306
+ if (!input.confirmIncoming) return;
307
+ known.add(from);
308
+ const reviewed = input.reviewed ? await revParse(input.reviewed) : void 0;
309
+ if (reviewed) known.add(reviewed);
310
+ const commits = parseCommits(await run$1([
311
+ "log",
312
+ "-z",
313
+ "--format=%H%x00%an%x00%ae%x00%s",
314
+ to,
315
+ ...[...known].map((ref) => `^${ref}`)
316
+ ]));
317
+ known.add(to);
318
+ if (commits.length === 0) return;
319
+ await input.confirmIncoming(commits);
320
+ incoming.push(...commits);
321
+ };
534
322
  try {
535
323
  await cloneSource(access, dir, {
536
324
  env,
537
325
  secrets
538
326
  });
539
- const scope = {
327
+ const scope = input.message.kind === "project" ? { kind: "project" } : {
540
328
  kind: input.message.kind,
541
329
  id: input.message.surface
542
330
  };
@@ -552,17 +340,21 @@ async function pushSourceTree(input) {
552
340
  fs.writeFileSync(messageFile, buildCommitMessage(input.message));
553
341
  const onRemote = head !== void 0 && !base;
554
342
  const local = onRemote ? await snapshotLocal(run$1, dir, input.files, scope, head, committing) : void 0;
343
+ const unsynced = onRemote && scope.kind === "project";
555
344
  materializeSourceTree(dir, input.files, scope, {
556
- onRemote,
345
+ onRemote: onRemote && scope.kind !== "workspace",
557
346
  overwrite: input.overwrite
558
347
  });
559
348
  await run$1(["add", "-A"]);
560
349
  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
- };
350
+ if (dirty === "" && local === void 0) {
351
+ if (base && head && base !== head) await confirmIncoming(base, head);
352
+ return finished({
353
+ commitSha: head ?? "",
354
+ status: "unchanged",
355
+ syncedTo: unsynced ? void 0 : base ?? head
356
+ });
357
+ }
566
358
  if (onRemote && !input.overwrite) {
567
359
  const refused = overwrittenPaths(await run$1([
568
360
  "diff",
@@ -571,8 +363,8 @@ async function pushSourceTree(input) {
571
363
  "--no-renames",
572
364
  "-z",
573
365
  "HEAD"
574
- ]));
575
- if (refused.length > 0) throw new SourceDivergedError(refused);
366
+ ]), derivedFilesOf(scope));
367
+ if (refused.length > 0) throw new SourceDivergedError(refused, scope.kind);
576
368
  }
577
369
  if (local !== void 0 && head !== void 0) await run$1([
578
370
  "reset",
@@ -598,7 +390,7 @@ async function pushSourceTree(input) {
598
390
  ], { env: committing });
599
391
  const own = await revParse("HEAD");
600
392
  if (!own) throw new Error("The source commit was not created.");
601
- const syncedTo = local ?? own;
393
+ const syncedTo = unsynced ? void 0 : local ?? own;
602
394
  const status = dirty === "" ? "unchanged" : "committed";
603
395
  const isAncestor = (ancestor, of) => run$1([
604
396
  "merge-base",
@@ -610,11 +402,14 @@ async function pushSourceTree(input) {
610
402
  for (let attempt = 1;; attempt++) {
611
403
  const upstream = parent ? await revParse(`origin/${access.branch}`) : void 0;
612
404
  if (upstream && upstream !== parent) {
613
- if (await isAncestor(own, upstream)) return {
614
- commitSha: upstream,
615
- status: "unchanged",
616
- syncedTo
617
- };
405
+ if (await isAncestor(own, upstream)) {
406
+ await confirmIncoming(own, upstream);
407
+ return finished({
408
+ commitSha: upstream,
409
+ status: "unchanged",
410
+ syncedTo
411
+ });
412
+ }
618
413
  await run$1([
619
414
  "reset",
620
415
  "--quiet",
@@ -628,6 +423,7 @@ async function pushSourceTree(input) {
628
423
  own,
629
424
  scope
630
425
  });
426
+ await confirmIncoming(parent ?? own, upstream);
631
427
  }
632
428
  try {
633
429
  await run$1([
@@ -635,11 +431,11 @@ async function pushSourceTree(input) {
635
431
  "origin",
636
432
  `HEAD:${access.branch}`
637
433
  ]);
638
- return {
434
+ return finished({
639
435
  commitSha: await revParse("HEAD") ?? own,
640
436
  status,
641
437
  syncedTo
642
- };
438
+ });
643
439
  } catch (error) {
644
440
  if (!parent || attempt >= PUSH_ATTEMPTS || !isRejected(error)) throw error;
645
441
  await run$1([
@@ -703,13 +499,13 @@ async function snapshotLocal(run$1, dir, files, scope, head, committing) {
703
499
  "superwall: the project this push was made from"
704
500
  ], { env: committing })).trim();
705
501
  }
706
- function overwrittenPaths(nameStatus) {
502
+ function overwrittenPaths(nameStatus, derived) {
707
503
  const fields = nameStatus.split("\0").filter(Boolean);
708
504
  const paths = [];
709
505
  for (let index = 0; index + 1 < fields.length; index += 2) {
710
506
  const status = fields[index];
711
507
  const file = fields[index + 1];
712
- if (file === void 0 || status === "A" || DERIVED_FILES.has(file)) continue;
508
+ if (file === void 0 || status === "A" || derived.has(file)) continue;
713
509
  paths.push(file);
714
510
  }
715
511
  return paths;
@@ -764,7 +560,8 @@ async function mergeUpstream(upstream, messageFile, { run: run$1, committing, di
764
560
  "--diff-filter=U",
765
561
  "-z"
766
562
  ]).catch(() => "")).split("\0").filter(Boolean);
767
- const blocking = conflicted.filter((file) => !DERIVED_FILES.has(file));
563
+ const derived = derivedFilesOf(scope);
564
+ const blocking = conflicted.filter((file) => !derived.has(file));
768
565
  const merging = await run$1([
769
566
  "rev-parse",
770
567
  "--verify",
@@ -773,15 +570,17 @@ async function mergeUpstream(upstream, messageFile, { run: run$1, committing, di
773
570
  ]).then(() => true, () => false);
774
571
  if (blocking.length > 0 || failure !== void 0 && conflicted.length === 0) {
775
572
  await run$1(["merge", "--abort"]).catch(() => void 0);
776
- if (blocking.length > 0) throw new SourceConflictError(blocking);
573
+ if (blocking.length > 0) throw new SourceConflictError(blocking, scope.kind);
777
574
  throw failure;
778
575
  }
779
576
  if (!merging) return;
780
577
  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));
578
+ if (scope.kind !== "workspace") {
579
+ const theirsLock = await show(upstream, LOCK_FILE);
580
+ const mineLock = await show(own, LOCK_FILE);
581
+ await settle(run$1, dir, LOCK_FILE, mineLock === void 0 ? theirsLock : mergeLockText(theirsLock, mineLock, scope));
582
+ }
583
+ for (const file of derived) if (file !== LOCK_FILE) await settle(run$1, dir, file, await show(own, file));
785
584
  await run$1([
786
585
  "commit",
787
586
  "--quiet",
@@ -806,7 +605,7 @@ var PullConflictError = class extends Error {
806
605
  }
807
606
  };
808
607
  async function pullSourceTree(input) {
809
- const { access } = input;
608
+ const { access, derived = DERIVED_FILES } = input;
810
609
  const secrets = [access.token, tokenSecret(access.token)];
811
610
  const dir = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-pull-"));
812
611
  const env = gitEnv(access.token, {
@@ -876,7 +675,7 @@ async function pullSourceTree(input) {
876
675
  "-z"
877
676
  ]));
878
677
  if (failure !== void 0 && conflicted.length === 0) throw failure;
879
- const blocking = conflicted.filter((file) => !DERIVED_FILES.has(file));
678
+ const blocking = conflicted.filter((file) => !derived.has(file));
880
679
  if (blocking.length > 0 && !input.theirs) throw new PullConflictError(blocking);
881
680
  const present = new Set((await run$1([
882
681
  "ls-tree",
@@ -920,7 +719,7 @@ async function pullSourceTree(input) {
920
719
  for (let index = 0; index + 1 < staged.length; index += 2) {
921
720
  const status = staged[index];
922
721
  const file = staged[index + 1];
923
- if (file === void 0 || DERIVED_FILES.has(file)) continue;
722
+ if (file === void 0 || derived.has(file)) continue;
924
723
  if (status === "D") {
925
724
  removed.push({
926
725
  path: file,
@@ -967,32 +766,4 @@ function replaceTree(dir, files) {
967
766
  const isRejected = (error) => error instanceof GitError && /rejected|non-fast-forward|fetch first|stale info|failed to push some refs/i.test(error.message);
968
767
 
969
768
  //#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 };
769
+ export { collectSourceFiles as a, statIfPresent as i, pullSourceTree as n, pushSourceTree as r, gitAvailable as t };
@@ -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-DHlsTaP1.js";
3
+ import { d as readInput, t as apiCall } from "./spinner-025_eqCX.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-COOEvqqW.js";
5
+ import { n as orgForNewProject } from "./org-DZ41muzA.js";
6
+ import { n as findApplication } from "./lookup-D23dAOz6.js";
7
+ import { r as pickOrganization } from "./scope-BJQ-KcQg.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;