@superwall/cli 2.5.0 → 2.5.2

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 +7 -0
  2. package/dist/{apple-Dyr7OFBx.js → apple-D2z3tALE.js} +14 -14
  3. package/dist/{approve-Czs1-JO9.js → approve-I-lvTanp.js} +35 -28
  4. package/dist/{assets-BrB9jQPQ.js → assets-oo93EFou.js} +3 -3
  5. package/dist/auth.d.ts +1 -1
  6. package/dist/auth.js +3 -3
  7. package/dist/{session-D3fgXQBt.js → base-Cft9NZfU.js} +35 -35
  8. package/dist/{billing-D5qqIlVb.js → billing-Bo1UEKqV.js} +3 -3
  9. package/dist/{bind-B3eEcRyp.js → bind-BvScWziR.js} +4 -4
  10. package/dist/{build-DD9pSwHX.js → build-Co487gha.js} +11 -9
  11. package/dist/{client-AI9H4GGB.js → client-Tp6iD66_.js} +55 -5
  12. package/dist/create-CHIPz5vb.js +20 -0
  13. package/dist/{create-ChfgWpiM.js → create-G3HuOHZ4.js} +31 -31
  14. package/dist/{create-B4m-IKlr.js → create-uA3nrMIa.js} +6 -6
  15. package/dist/design-lint-CiFc78aM.js +158 -0
  16. package/dist/{doctor-XtXW6tKE.js → doctor-CHF9aNFc.js} +6 -6
  17. package/dist/{drivers-CMEL13gp.js → drivers-YZEcBiSV.js} +3 -3
  18. package/dist/entry.js +20 -20
  19. package/dist/{environment-BWT2S4qC.js → environment-EU7Mrk7j.js} +3 -3
  20. package/dist/{existing-b0GxFcnc.js → existing-DV_6NLfW.js} +2 -2
  21. package/dist/{selection-BltBpyp5.js → framework-b-Yf8sP1.js} +50 -50
  22. package/dist/held-Dd19AduK.js +17 -0
  23. package/dist/{held-D3PUNky2.js → held-L0vz0_hA.js} +6 -6
  24. package/dist/install-CXfLcLhU.js +109 -0
  25. package/dist/{integrate-qvKd9pVW.js → integrate-DS2YGLsM.js} +23 -23
  26. package/dist/{types-JdxmnCko.js → lock-DgSx-p8Y.js} +79 -79
  27. package/dist/login-C0BjJmFy.js +17 -0
  28. package/dist/{login-PMoXUGqq.js → login-Ca6FhI6R.js} +6 -6
  29. package/dist/{login-COmGHrU5.js → login-DoMmU3Bq.js} +1 -1
  30. package/dist/{lookup-gjcKIZvh.js → lookup-DhMLZmdW.js} +3 -3
  31. package/dist/{migrate-SkkLLdmr.js → migrate-CoQWqzhJ.js} +29 -29
  32. package/dist/{migration-DS44-3Zr.js → migration-C22iQzAW.js} +29 -11
  33. package/dist/{notification-url-BjQPLf4-.js → notification-url-CqnXE9yB.js} +2 -2
  34. package/dist/{open-DQpm2yVs.js → open-DriuY3di.js} +2 -2
  35. package/dist/{org-C04eAO-j.js → org-D7LQrg3k.js} +3 -3
  36. package/dist/{organization-BOECL3vZ.js → organization-DDidaGRK.js} +8 -8
  37. package/dist/{orgs-D6Kk96mG.js → orgs-CYXjVdxM.js} +1 -1
  38. package/dist/{paths-REb-GrbX.js → paths-Bf3othB-.js} +1 -1
  39. package/dist/{playbook-Du4Oydbf.js → playbook-K7vmAUsu.js} +10 -10
  40. package/dist/{project-CP6hiHra.js → project-NoMtbMyl.js} +9 -9
  41. package/dist/{promote-Dm2_b1WK.js → promote-DXxxj4BU.js} +23 -22
  42. package/dist/pull-Bfa3_SBt.js +106 -0
  43. package/dist/pull-DGrlBSAG.js +36 -0
  44. package/dist/{pull-F6pvO4To.js → pull-DuFUkP7t.js} +8 -8
  45. package/dist/{push-D_l9KJZN.js → push-CrowxhpU.js} +54 -48
  46. package/dist/push-DPZdch2W.js +30 -0
  47. package/dist/push-DV-kJZdw.js +22 -0
  48. package/dist/{push-BIFLhAiO.js → push-Dk5x2xP3.js} +122 -22
  49. package/dist/{registry-DIJB0mJa.js → registry-HhZVRBqY.js} +178 -155
  50. package/dist/resolve-D3RBtfkI.js +242 -0
  51. package/dist/{resources-BaP3p_LY.js → resources-CkG6SCia.js} +2 -2
  52. package/dist/{run-C5OPwhvS.js → run-CL5ZnujW.js} +2 -2
  53. package/dist/{run-CgLmD2vR.js → run-Co8u_BkN.js} +93 -70
  54. package/dist/scan-BQmjhs3g.js +4 -0
  55. package/dist/{scan-Bj5y0zTZ.js → scan-DhmGH1rF.js} +1 -1
  56. package/dist/{scope-Bp_zwJOo.js → scope-D0XpYMn4.js} +5 -5
  57. package/dist/{scope-CCb_7UvN.js → scope-ehZ7L1nj.js} +25 -11
  58. package/dist/{sdk-TvT0p_nO.js → sdk-DEfQttek.js} +7 -7
  59. package/dist/{series-TAixFBWW.js → series-D2ZpZ8cx.js} +96 -63
  60. package/dist/server-4ZK_1Off.js +29 -0
  61. package/dist/{server-CdVIboQn.js → server-DamMN_ig.js} +9 -9
  62. package/dist/session-4F_YWSul.js +6 -0
  63. package/dist/{session-Ywim-P8M.js → session-G1uwJI8L.js} +1 -1
  64. package/dist/{setup-zzjtTy8k.js → setup-BFTSxEWU.js} +9 -9
  65. package/dist/skills/index.json +2 -2
  66. package/dist/skills/superwall/workflows/integrate/flutter.md +9 -7
  67. package/dist/skills/{superwall-workspaces → superwall-artifacts}/SKILL.md +47 -32
  68. package/dist/skills/{superwall-workspaces → superwall-artifacts}/references/cli.md +35 -29
  69. package/dist/skills/{superwall-workspaces → superwall-artifacts}/references/slots.md +9 -9
  70. package/dist/{skills-2qYaUXGE.js → skills-CE4c9eHX.js} +4 -4
  71. package/dist/{skills-8um2fBPS.js → skills-ClEVgXUB.js} +8 -8
  72. package/dist/{git-D7AVdugb.js → source-BccdO4aL.js} +111 -102
  73. package/dist/{source-push-kAep4gPe.js → source-push-EyF02ekO.js} +43 -26
  74. package/dist/{spinner-BANVLncC.js → spinner-mWZnJCkN.js} +3 -3
  75. package/dist/{starter-CiLrp1cN.js → starter-BtUUQWhd.js} +38 -28
  76. package/dist/{status-CoYMK7QL.js → status-SAZxltzW.js} +42 -39
  77. package/dist/{storage-DzP22xKn.js → storage-R5-qDvHq.js} +1 -1
  78. package/dist/{storekit-n1x0bWkQ.js → storekit-CQHVFTOC.js} +3 -3
  79. package/dist/storekit-DK3xXKoY.js +17 -0
  80. package/dist/{telemetry-CXN6f-ZX.js → telemetry-B-uKuu49.js} +1 -1
  81. package/dist/{token-FmeHywYt.js → token-C2kzntVM.js} +1 -1
  82. package/dist/tools.d.ts +6 -1
  83. package/dist/tools.js +208 -130
  84. package/dist/{try-BWbzgelb.js → try-BrJJyXgq.js} +32 -32
  85. package/dist/{upgrade-CoWCEnoi.js → upgrade-g_Bd9oJe.js} +2 -2
  86. package/dist/{upgrade-Bk5boOgW.js → upgrade-zOXTIaAZ.js} +2 -2
  87. package/package.json +2 -2
  88. package/dist/create-CJljlkJK.js +0 -20
  89. package/dist/held-CX7Zf8u-.js +0 -17
  90. package/dist/install-CVUXsx8c.js +0 -103
  91. package/dist/login-ClnJi1Ea.js +0 -17
  92. package/dist/pull-DsdOoG-D.js +0 -36
  93. package/dist/pull-zYAbqo9n.js +0 -106
  94. package/dist/push-CJVfvFZq.js +0 -29
  95. package/dist/push-SVzv7fzE.js +0 -22
  96. package/dist/resolve--GsHj0Q1.js +0 -171
  97. package/dist/scan-v_WTE722.js +0 -4
  98. package/dist/server-CvJVusw3.js +0 -29
  99. package/dist/session-B8JNXkwN.js +0 -6
  100. package/dist/storekit-D5eopLM0.js +0 -17
  101. /package/dist/{download-2Zu2I_Og.js → download-DhGd4hOB.js} +0 -0
  102. /package/dist/{reports-CuhB1_ub.js → reports-HYVp169R.js} +0 -0
  103. /package/dist/{storage-BjQCiTuz.d.ts → storage-Bdz5AmqS.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { n as ui } from "./ui-D_qf3Gvw.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";
2
+ import { i as formatSharedLock, v as TYPES_FILE } from "./lock-DgSx-p8Y.js";
3
+ import { a as classifyPath, c as isSurfaceRoot, i as LOCK_FILE$1, l as mergeLockText, o as derivedFilesOf, r as DERIVED_FILES, s as isOtherSurfaceDir } from "./scope-ehZ7L1nj.js";
4
4
  import { execFile } from "node:child_process";
5
5
  import * as fs from "node:fs";
6
6
  import * as os$1 from "node:os";
@@ -8,93 +8,25 @@ import * as path from "node:path";
8
8
  import { promisify } from "node:util";
9
9
  import fg from "fast-glob";
10
10
 
11
- //#region src/core/paywalls/source/source.ts
12
- const HARD_EXCLUDES = [
13
- ".superwall/**",
14
- "**/node_modules/**",
15
- ".git/**",
16
- "**/.env*",
17
- "**/.DS_Store",
18
- "**/.npmrc",
19
- "**/.netrc",
20
- "**/*.pem",
21
- "**/*.p8",
22
- "**/*.p12",
23
- "**/*.key",
24
- "**/*.keystore",
25
- "**/*.jks",
26
- "**/google-services.json",
27
- "**/GoogleService-Info.plist"
28
- ];
29
- const LOCK_FILE$1 = "superwall.lock";
30
- const SOURCE_LIMIT_BYTES = 250 * 1024 * 1024;
31
- const LARGEST_SHOWN = 3;
32
- const megabytes = (bytes) => `${(bytes / 1024 / 1024).toFixed(1)} MB`;
33
- function gitignoreExcludes(superwallDir) {
34
- let text;
35
- try {
36
- text = fs.readFileSync(path.join(superwallDir, ".gitignore"), "utf8");
37
- } catch {
38
- return [];
39
- }
40
- const excludes = [];
41
- for (const raw of text.split("\n")) {
42
- const line = raw.trim();
43
- if (line === "" || line.startsWith("#") || line.startsWith("!")) continue;
44
- const anchored = line.startsWith("/");
45
- const body = (anchored ? line.slice(1) : line).replace(/\/+$/, "");
46
- if (body === "") continue;
47
- const base = anchored || body.includes("/") ? body : `**/${body}`;
48
- excludes.push(base, `${base}/**`);
49
- }
50
- return excludes;
51
- }
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) {
54
- const entries = await fg("**/*", {
55
- cwd: superwallDir,
56
- dot: true,
57
- onlyFiles: true,
58
- followSymbolicLinks: false,
59
- ignore: [...HARD_EXCLUDES, ...gitignoreExcludes(superwallDir)]
60
- });
61
- if (entries.length === 0) return {
62
- ok: false,
63
- reason: `No source files found in ${superwallDir}.`
64
- };
65
- const sizes = entries.map((relative$1) => ({
66
- path: relative$1,
67
- bytes: fs.statSync(path.join(superwallDir, relative$1)).size
68
- }));
69
- const total = sizes.reduce((sum, entry) => sum + entry.bytes, 0);
70
- if (total > SOURCE_LIMIT_BYTES) {
71
- const largest = sizes.sort((a, b) => b.bytes - a.bytes).slice(0, LARGEST_SHOWN).map((entry) => `${entry.path} (${megabytes(entry.bytes)})`).join(", ");
72
- return {
73
- ok: false,
74
- reason: `The source in ${superwallDir} is ${megabytes(total)}, over the ${SOURCE_LIMIT_BYTES / 1024 / 1024} MB limit. Largest: ${largest}. Add what doesn't belong to .gitignore, then push again.`
75
- };
76
- }
77
- return {
78
- ok: true,
79
- files: entries.sort().map((relative$1) => ({
80
- path: relative$1,
81
- content: read(superwallDir, relative$1)
82
- }))
83
- };
84
- }
85
-
86
- //#endregion
87
11
  //#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}`);
12
+ const noteBody = (note) => {
13
+ const text = note?.replace(/\r\n?/g, "\n").trim();
14
+ return text ? `\n${text}\n` : "";
15
+ };
16
+ const artifactCommitMessage = (input) => {
17
+ const surface = `artifact/${input.surface}`;
18
+ const trailers = [`Superwall-Artifact: ${input.artifactId}`, `Superwall-Surface: ${surface}`];
19
+ if (input.sdk) trailers.push(`Superwall-Artifact-Sdk: ${input.sdk}`);
92
20
  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`;
21
+ return `push ${surface}\n${noteBody(input.note)}\n${trailers.join("\n")}\n`;
95
22
  };
96
23
  const buildCommitMessage = (input) => {
97
- if (input.kind === "workspace") return workspaceCommitMessage(input);
24
+ if (input.kind === "artifact") return artifactCommitMessage(input);
25
+ if (input.kind === "project") {
26
+ const trailers$1 = [`Superwall-Application: ${input.applicationId}`, `Superwall-Framework: ${input.framework}`];
27
+ if (input.cli) trailers$1.push(`Superwall-Cli: ${input.cli}`);
28
+ return `publish project source\n${noteBody(input.note)}\n${trailers$1.join("\n")}\n`;
29
+ }
98
30
  const surface = `${input.kind}/${input.surface}`;
99
31
  const subject = `publish ${surface} v${input.version}`;
100
32
  const external = (input.external ?? []).filter((entry) => entry.trim() !== "");
@@ -109,8 +41,7 @@ const buildCommitMessage = (input) => {
109
41
  if (input.snapshotSha) trailers.push(`Superwall-Snapshot: ${input.snapshotSha}`);
110
42
  trailers.push(`Superwall-Framework: ${input.framework}`);
111
43
  if (input.cli) trailers.push(`Superwall-Cli: ${input.cli}`);
112
- const note = input.note?.replace(/\r\n?/g, "\n").trim();
113
- return `${subject}\n${note ? `\n${note}\n` : ""}\n${trailers.join("\n")}\n`;
44
+ return `${subject}\n${noteBody(input.note)}\n${trailers.join("\n")}\n`;
114
45
  };
115
46
  const tokenSecret = (token) => token.split("?")[0] ?? token;
116
47
  const redact = (text, ...secrets) => {
@@ -228,12 +159,12 @@ function materializeSourceTree(dir, files, scope, options = {}) {
228
159
  for (const file of files) {
229
160
  if (classifyPath(file.path, scope) === "other") continue;
230
161
  if (file.content.byteLength > LARGE_FILE_BYTES) large.push(file.path);
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 }));
162
+ if (file.path === LOCK_FILE$1 && scope.kind !== "artifact") write(file.path, mergeLockText(theirs.get(LOCK_FILE$1)?.toString("utf8"), file.content.toString("utf8"), scope, { replaceUnreadable: options.overwrite }));
232
163
  else write(file.path, file.content);
233
164
  theirs.delete(file.path);
234
165
  }
235
166
  for (const [derived, content] of theirs) write(derived, content);
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.`);
167
+ 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 === "artifact" ? "artifact's" : "app's"} source repo pays for it.`);
237
168
  }
238
169
  const SHOWN_FILES = 5;
239
170
  const listFiles = (files) => {
@@ -241,15 +172,16 @@ const listFiles = (files) => {
241
172
  const rest = files.length - SHOWN_FILES;
242
173
  return rest > 0 ? `${shown} and ${rest} more` : shown;
243
174
  };
175
+ const replaced = (kind) => kind === "project" ? "the project's shared files" : "this paywall's source";
244
176
  var SourceConflictError = class extends Error {
245
177
  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.`);
178
+ super(kind === "artifact" ? `Someone else pushed changes to ${listFiles(files)} since this project last synced. Run \`superwall artifacts pull\` to bring their changes into this project, then push again, or rerun with --overwrite-source to replace this artifact'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.`);
247
179
  this.files = files;
248
180
  }
249
181
  };
250
182
  var SourceDivergedError = class extends Error {
251
183
  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.`);
184
+ super(kind === "artifact" ? `The source repo differs from this project in ${listFiles(files)}, and this project records no sync point to merge from. Run \`superwall artifacts pull\` to merge the source repo into this project, then push again, or rerun with --overwrite-source to replace this artifact'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.`);
253
185
  this.files = files;
254
186
  }
255
187
  };
@@ -316,7 +248,7 @@ async function pushSourceTree(input) {
316
248
  env,
317
249
  secrets
318
250
  });
319
- const scope = {
251
+ const scope = input.message.kind === "project" ? { kind: "project" } : {
320
252
  kind: input.message.kind,
321
253
  id: input.message.surface
322
254
  };
@@ -332,8 +264,9 @@ async function pushSourceTree(input) {
332
264
  fs.writeFileSync(messageFile, buildCommitMessage(input.message));
333
265
  const onRemote = head !== void 0 && !base;
334
266
  const local = onRemote ? await snapshotLocal(run$1, dir, input.files, scope, head, committing) : void 0;
267
+ const unsynced = onRemote && scope.kind === "project";
335
268
  materializeSourceTree(dir, input.files, scope, {
336
- onRemote: onRemote && scope.kind !== "workspace",
269
+ onRemote: onRemote && scope.kind !== "artifact",
337
270
  overwrite: input.overwrite
338
271
  });
339
272
  await run$1(["add", "-A"]);
@@ -343,7 +276,7 @@ async function pushSourceTree(input) {
343
276
  return finished({
344
277
  commitSha: head ?? "",
345
278
  status: "unchanged",
346
- syncedTo: base ?? head
279
+ syncedTo: unsynced ? void 0 : base ?? head
347
280
  });
348
281
  }
349
282
  if (onRemote && !input.overwrite) {
@@ -381,7 +314,7 @@ async function pushSourceTree(input) {
381
314
  ], { env: committing });
382
315
  const own = await revParse("HEAD");
383
316
  if (!own) throw new Error("The source commit was not created.");
384
- const syncedTo = local ?? own;
317
+ const syncedTo = unsynced ? void 0 : local ?? own;
385
318
  const status = dirty === "" ? "unchanged" : "committed";
386
319
  const isAncestor = (ancestor, of) => run$1([
387
320
  "merge-base",
@@ -566,12 +499,12 @@ async function mergeUpstream(upstream, messageFile, { run: run$1, committing, di
566
499
  }
567
500
  if (!merging) return;
568
501
  const show = (ref, file) => run$1(["show", `${ref}:${file}`]).then((text) => text, () => void 0);
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));
502
+ if (scope.kind !== "artifact") {
503
+ const theirsLock = await show(upstream, LOCK_FILE$1);
504
+ const mineLock = await show(own, LOCK_FILE$1);
505
+ await settle(run$1, dir, LOCK_FILE$1, mineLock === void 0 ? theirsLock : mergeLockText(theirsLock, mineLock, scope));
573
506
  }
574
- for (const file of derived) if (file !== LOCK_FILE) await settle(run$1, dir, file, await show(own, file));
507
+ for (const file of derived) if (file !== LOCK_FILE$1) await settle(run$1, dir, file, await show(own, file));
575
508
  await run$1([
576
509
  "commit",
577
510
  "--quiet",
@@ -732,7 +665,7 @@ async function pullSourceTree(input) {
732
665
  status: "pulled",
733
666
  head,
734
667
  changes,
735
- lock: await shown(LOCK_FILE),
668
+ lock: await shown(LOCK_FILE$1),
736
669
  types: await shown(TYPES_FILE)
737
670
  };
738
671
  } finally {
@@ -757,4 +690,80 @@ function replaceTree(dir, files) {
757
690
  const isRejected = (error) => error instanceof GitError && /rejected|non-fast-forward|fetch first|stale info|failed to push some refs/i.test(error.message);
758
691
 
759
692
  //#endregion
760
- export { collectSourceFiles as a, statIfPresent as i, pullSourceTree as n, pushSourceTree as r, gitAvailable as t };
693
+ //#region src/core/paywalls/source/source.ts
694
+ const HARD_EXCLUDES = [
695
+ ".superwall/**",
696
+ "**/node_modules/**",
697
+ ".git/**",
698
+ "**/.env*",
699
+ "**/.DS_Store",
700
+ "**/.npmrc",
701
+ "**/.netrc",
702
+ "**/*.pem",
703
+ "**/*.p8",
704
+ "**/*.p12",
705
+ "**/*.key",
706
+ "**/*.keystore",
707
+ "**/*.jks",
708
+ "**/google-services.json",
709
+ "**/GoogleService-Info.plist"
710
+ ];
711
+ const LOCK_FILE = "superwall.lock";
712
+ const SOURCE_LIMIT_BYTES = 250 * 1024 * 1024;
713
+ const LARGEST_SHOWN = 3;
714
+ const megabytes = (bytes) => `${(bytes / 1024 / 1024).toFixed(1)} MB`;
715
+ function gitignoreExcludes(superwallDir) {
716
+ let text;
717
+ try {
718
+ text = fs.readFileSync(path.join(superwallDir, ".gitignore"), "utf8");
719
+ } catch {
720
+ return [];
721
+ }
722
+ const excludes = [];
723
+ for (const raw of text.split("\n")) {
724
+ const line = raw.trim();
725
+ if (line === "" || line.startsWith("#") || line.startsWith("!")) continue;
726
+ const anchored = line.startsWith("/");
727
+ const body = (anchored ? line.slice(1) : line).replace(/\/+$/, "");
728
+ if (body === "") continue;
729
+ const base = anchored || body.includes("/") ? body : `**/${body}`;
730
+ excludes.push(base, `${base}/**`);
731
+ }
732
+ return excludes;
733
+ }
734
+ const readFramework = (superwallDir, relative$1) => relative$1 === LOCK_FILE ? Buffer.from(formatSharedLock(superwallDir)) : fs.readFileSync(path.join(superwallDir, relative$1));
735
+ async function collectSourceFiles(superwallDir, read = readFramework) {
736
+ const entries = await fg("**/*", {
737
+ cwd: superwallDir,
738
+ dot: true,
739
+ onlyFiles: true,
740
+ followSymbolicLinks: false,
741
+ ignore: [...HARD_EXCLUDES, ...gitignoreExcludes(superwallDir)]
742
+ });
743
+ if (entries.length === 0) return {
744
+ ok: false,
745
+ reason: `No source files found in ${superwallDir}.`
746
+ };
747
+ const sizes = entries.map((relative$1) => ({
748
+ path: relative$1,
749
+ bytes: fs.statSync(path.join(superwallDir, relative$1)).size
750
+ }));
751
+ const total = sizes.reduce((sum, entry) => sum + entry.bytes, 0);
752
+ if (total > SOURCE_LIMIT_BYTES) {
753
+ const largest = sizes.sort((a, b) => b.bytes - a.bytes).slice(0, LARGEST_SHOWN).map((entry) => `${entry.path} (${megabytes(entry.bytes)})`).join(", ");
754
+ return {
755
+ ok: false,
756
+ reason: `The source in ${superwallDir} is ${megabytes(total)}, over the ${SOURCE_LIMIT_BYTES / 1024 / 1024} MB limit. Largest: ${largest}. Add what doesn't belong to .gitignore, then push again.`
757
+ };
758
+ }
759
+ return {
760
+ ok: true,
761
+ files: entries.sort().map((relative$1) => ({
762
+ path: relative$1,
763
+ content: read(superwallDir, relative$1)
764
+ }))
765
+ };
766
+ }
767
+
768
+ //#endregion
769
+ export { statIfPresent as a, pushSourceTree as i, gitAvailable as n, pullSourceTree as r, collectSourceFiles as t };
@@ -1,10 +1,10 @@
1
- import { n as ApiUnreachableError, t as ApiError } from "./client-AI9H4GGB.js";
1
+ import { n as ApiUnreachableError, t as ApiError } from "./client-Tp6iD66_.js";
2
2
  import { n as ui } from "./ui-D_qf3Gvw.js";
3
- import { d as linkSourceCommit, f as listAppPaywalls, o as createHeadlessPaywall, v as mintSourceAccess } from "./resources-BaP3p_LY.js";
4
- import { n as findApplication } from "./lookup-gjcKIZvh.js";
5
- import { f as readLock, h as writeBinding } from "./types-JdxmnCko.js";
6
- import { i as writeSourceBase, r as readSourceBase } from "./session-D3fgXQBt.js";
7
- import { r as pushSourceTree, t as gitAvailable } from "./git-D7AVdugb.js";
3
+ import { d as linkSourceCommit, f as listAppPaywalls, o as createHeadlessPaywall, v as mintSourceAccess } from "./resources-CkG6SCia.js";
4
+ import { n as findApplication } from "./lookup-DhMLZmdW.js";
5
+ import { f as writeBinding, l as readLock } from "./lock-DgSx-p8Y.js";
6
+ import { n as writeSourceBase, t as readSourceBase } from "./base-Cft9NZfU.js";
7
+ import { i as pushSourceTree, n as gitAvailable } from "./source-BccdO4aL.js";
8
8
  import { setTimeout } from "node:timers/promises";
9
9
  import { productVariables } from "@superwall/studio/products";
10
10
 
@@ -155,28 +155,35 @@ var GitRequiredError = class extends Error {
155
155
  async function assertGit(hasGit = gitAvailable) {
156
156
  if (!await hasGit()) throw new GitRequiredError();
157
157
  }
158
+ async function syncSource(input, message) {
159
+ const access = await mintSourceAccess(input.api, input.paywallId);
160
+ const pushed = await pushSourceTree({
161
+ access,
162
+ base: readSourceBase(input.superwallDir, access.repo),
163
+ overwrite: input.overwrite,
164
+ files: input.files,
165
+ message
166
+ });
167
+ if (pushed.syncedTo) writeSourceBase(input.superwallDir, access.repo, pushed.syncedTo);
168
+ return {
169
+ access,
170
+ pushed
171
+ };
172
+ }
158
173
  async function pushSource(input) {
159
174
  for (let attempt = 0;; attempt++) {
160
- const access = await mintSourceAccess(input.api, input.paywallId);
161
- const pushed = await pushSourceTree({
162
- access,
163
- base: readSourceBase(input.superwallDir, access.repo),
164
- overwrite: input.overwrite,
165
- files: input.files,
166
- message: {
167
- kind: input.kind,
168
- surface: input.surface,
169
- version: input.version,
170
- paywallId: input.paywallId,
171
- applicationId: input.applicationId,
172
- snapshotSha: input.snapshotId,
173
- framework: input.framework,
174
- cli: input.cli,
175
- note: input.note,
176
- external: input.external
177
- }
175
+ const { access, pushed } = await syncSource(input, {
176
+ kind: input.kind,
177
+ surface: input.surface,
178
+ version: input.version,
179
+ paywallId: input.paywallId,
180
+ applicationId: input.applicationId,
181
+ snapshotSha: input.snapshotId,
182
+ framework: input.framework,
183
+ cli: input.cli,
184
+ note: input.note,
185
+ external: input.external
178
186
  });
179
- if (pushed.syncedTo) writeSourceBase(input.superwallDir, access.repo, pushed.syncedTo);
180
187
  try {
181
188
  await linkCommit(input, access, pushed.commitSha);
182
189
  return pushed;
@@ -186,6 +193,16 @@ async function pushSource(input) {
186
193
  }
187
194
  }
188
195
  }
196
+ async function pushProjectSource(input) {
197
+ const { pushed } = await syncSource(input, {
198
+ kind: "project",
199
+ applicationId: input.applicationId,
200
+ framework: input.framework,
201
+ cli: input.cli,
202
+ note: input.note
203
+ });
204
+ return pushed;
205
+ }
189
206
  const LINK_ATTEMPTS = 2;
190
207
  const LINK_RETRY_DELAY_MS = 300;
191
208
  async function linkCommit(input, access, commitSha) {
@@ -203,4 +220,4 @@ async function linkCommit(input, access, commitSha) {
203
220
  const isTransient = (error) => error instanceof ApiUnreachableError || error instanceof ApiError && error.status >= 500;
204
221
 
205
222
  //#endregion
206
- export { listProjectCatalogue as a, requireProducts as c, listApplicationCatalogue as i, resolveBinding as l, pushSource as n, listProjectProducts as o, warnNotPortable as r, projectForApplication as s, assertGit as t };
223
+ export { listApplicationCatalogue as a, projectForApplication as c, warnNotPortable as i, requireProducts as l, pushProjectSource as n, listProjectCatalogue as o, pushSource as r, listProjectProducts as s, assertGit as t, resolveBinding as u };
@@ -1,7 +1,7 @@
1
- import { r as NotLoggedInError } from "./token-FmeHywYt.js";
1
+ import { r as NotLoggedInError } from "./token-C2kzntVM.js";
2
2
  import { i as writeJson, n as createCommandOutput } from "./output-Ggzq5_-t.js";
3
- import { s as CHANNEL } from "./environment-BWT2S4qC.js";
4
- import { t as ApiError } from "./client-AI9H4GGB.js";
3
+ import { s as CHANNEL } from "./environment-EU7Mrk7j.js";
4
+ import { t as ApiError } from "./client-Tp6iD66_.js";
5
5
  import { n as ui, r as useRenderer } from "./ui-D_qf3Gvw.js";
6
6
  import pc from "picocolors";
7
7
 
@@ -1,13 +1,13 @@
1
- import { i as downloadRepoDir, n as PUBLIC_REPO, r as RepoDownloadError } from "./download-2Zu2I_Og.js";
2
- import { n as VENDORED_SDK, o as readManifest, r as WorkspaceError, t as MANIFEST_FILE } from "./project-CP6hiHra.js";
3
- import { n as compareVersions, r as vendoredVersion, t as STARTER_DIR } from "./sdk-TvT0p_nO.js";
1
+ import { n as MANIFEST_FILE, o as readManifest, r as VENDORED_SDK, t as ArtifactError } from "./project-NoMtbMyl.js";
2
+ import { i as downloadRepoDir, n as PUBLIC_REPO, r as RepoDownloadError } from "./download-DhGd4hOB.js";
3
+ import { n as compareVersions, r as vendoredVersion, t as STARTER_DIR } from "./sdk-DEfQttek.js";
4
4
  import { execFile } from "node:child_process";
5
5
  import * as fs from "node:fs";
6
6
  import * as os$1 from "node:os";
7
7
  import * as path from "node:path";
8
8
  import { promisify } from "node:util";
9
9
 
10
- //#region src/core/workspaces/starter.ts
10
+ //#region src/core/artifacts/starter.ts
11
11
  const run = promisify(execFile);
12
12
  const npmInstall = async (root) => {
13
13
  await run("npm", [
@@ -20,7 +20,7 @@ const npmInstall = async (root) => {
20
20
  timeout: 3e5
21
21
  });
22
22
  };
23
- const packageNameOf = (dir) => path.basename(dir).toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "my-workspace";
23
+ const packageNameOf = (dir) => path.basename(dir).toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "my-artifact";
24
24
  const titleOf = (name) => {
25
25
  const words = name.split("-").join(" ");
26
26
  return words.charAt(0).toUpperCase() + words.slice(1);
@@ -43,14 +43,14 @@ function adoptStarter(target, name) {
43
43
  for (const entrypoint of value.entrypoints ?? []) if (entrypoint.slot === "org.page@1") entrypoint.title = titleOf(name);
44
44
  });
45
45
  const wrangler = path.join(target, "wrangler.jsonc");
46
- fs.writeFileSync(wrangler, fs.readFileSync(wrangler, "utf8").replace("superwall-workspace-starter", name));
46
+ fs.writeFileSync(wrangler, fs.readFileSync(wrangler, "utf8").replace("superwall-artifact-starter", name));
47
47
  }
48
- async function runWorkspaceCreate(ctx, input, runtime = {}) {
49
- const target = path.resolve(input.dir ?? "my-workspace");
48
+ async function runArtifactCreate(ctx, input, runtime = {}) {
49
+ const target = path.resolve(input.dir ?? "my-artifact");
50
50
  const existed = fs.existsSync(target);
51
- if (existed && !fs.statSync(target).isDirectory()) throw new WorkspaceError(`${target} is a file. Pick an empty directory.`);
52
- if (existed && fs.readdirSync(target).length > 0) throw new WorkspaceError(`${target} already has files in it. Pick an empty directory.`);
53
- ctx.ui.intro("New workspace");
51
+ if (existed && !fs.statSync(target).isDirectory()) throw new ArtifactError(`${target} is a file. Pick an empty directory.`);
52
+ if (existed && fs.readdirSync(target).length > 0) throw new ArtifactError(`${target} already has files in it. Pick an empty directory.`);
53
+ ctx.ui.intro("New artifact");
54
54
  const spin = ctx.ui.spinner();
55
55
  spin.start(`Downloading the starter from github.com/${PUBLIC_REPO}`);
56
56
  try {
@@ -84,14 +84,14 @@ async function runWorkspaceCreate(ctx, input, runtime = {}) {
84
84
  const next = [
85
85
  `cd ${path.relative(process.cwd(), target) || "."}`,
86
86
  ...installed ? [] : ["npm install"],
87
- "superwall workspaces dev"
87
+ "superwall artifacts dev"
88
88
  ];
89
89
  ctx.ui.note(next.join("\n"), "Next");
90
90
  }
91
91
  async function downloadSdk(fetchImpl) {
92
- const stage = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-workspace-sdk-"));
92
+ const stage = fs.mkdtempSync(path.join(os$1.tmpdir(), "superwall-artifact-sdk-"));
93
93
  try {
94
- await downloadRepoDir(`${STARTER_DIR}/vendor/workspace-sdk`, stage, `No workspace SDK at ${STARTER_DIR} in github.com/${PUBLIC_REPO}. Update the CLI with \`superwall upgrade\`.`, fetchImpl);
94
+ await downloadRepoDir(`${STARTER_DIR}/vendor/artifact-sdk`, stage, `No artifact SDK at ${STARTER_DIR} in github.com/${PUBLIC_REPO}. Update the CLI with \`superwall upgrade\`.`, fetchImpl);
95
95
  return {
96
96
  stage,
97
97
  version: readStageVersion(stage)
@@ -107,7 +107,7 @@ async function downloadSdk(fetchImpl) {
107
107
  function replaceDirectory(stage, target, rename = fs.renameSync) {
108
108
  const parent = path.dirname(target);
109
109
  fs.mkdirSync(parent, { recursive: true });
110
- const incoming = fs.mkdtempSync(path.join(parent, ".workspace-sdk-new-"));
110
+ const incoming = fs.mkdtempSync(path.join(parent, ".artifact-sdk-new-"));
111
111
  const outgoing = `${incoming}-old`;
112
112
  fs.cpSync(stage, incoming, { recursive: true });
113
113
  const hadTarget = fs.existsSync(target);
@@ -127,42 +127,46 @@ function replaceDirectory(stage, target, rename = fs.renameSync) {
127
127
  force: true
128
128
  });
129
129
  }
130
+ /** Returns whether package.json had to change. */
130
131
  function pointPackageAtSdk(file) {
131
132
  const text = fs.readFileSync(file, "utf8");
132
133
  const parsed = JSON.parse(text);
133
- if (parsed.dependencies?.["@superwall/workspace-sdk"] === "file:vendor/workspace-sdk") return;
134
+ if (parsed.dependencies?.["@superwall/artifact-sdk"] === "file:vendor/artifact-sdk") return false;
134
135
  parsed.dependencies = {
135
136
  ...parsed.dependencies,
136
- "@superwall/workspace-sdk": "file:vendor/workspace-sdk"
137
+ "@superwall/artifact-sdk": "file:vendor/artifact-sdk"
137
138
  };
138
139
  const indent = /^([ \t]+)"/m.exec(text)?.[1] ?? " ";
139
140
  fs.writeFileSync(file, `${JSON.stringify(parsed, null, indent)}${text.endsWith("\n") ? "\n" : ""}`);
141
+ return true;
140
142
  }
143
+ const readIfPresent = (file) => fs.existsSync(file) ? fs.readFileSync(file, "utf8") : void 0;
144
+ const commitList = (files) => files.length === 1 ? files[0] : `${files.slice(0, -1).join(", ")} and ${files.at(-1)}`;
141
145
  function readStageVersion(stage) {
142
146
  const { version } = JSON.parse(fs.readFileSync(path.join(stage, "package.json"), "utf8"));
143
- if (typeof version !== "string") throw new RepoDownloadError("The downloaded workspace SDK has no version.");
147
+ if (typeof version !== "string") throw new RepoDownloadError("The downloaded artifact SDK has no version.");
144
148
  return version;
145
149
  }
146
- async function runWorkspaceUpdate(ctx, input, runtime = {}) {
150
+ async function runArtifactUpdate(ctx, input, runtime = {}) {
147
151
  const root = path.resolve(input.dir ?? process.cwd());
148
152
  readManifest(root);
149
153
  const packageFile = path.join(root, "package.json");
150
- if (!fs.existsSync(packageFile)) throw new WorkspaceError(`No package.json in ${root}, so nothing was changed. A workspace needs one to depend on the SDK.`);
154
+ if (!fs.existsSync(packageFile)) throw new ArtifactError(`No package.json in ${root}, so nothing was changed. An artifact needs one to depend on the SDK.`);
151
155
  const before = vendoredVersion(root);
152
156
  const spin = ctx.ui.spinner();
153
- spin.start("Downloading the workspace SDK");
157
+ spin.start("Downloading the artifact SDK");
154
158
  let downloaded;
155
159
  try {
156
160
  downloaded = await downloadSdk(runtime.fetch ?? fetch);
157
161
  } catch (error) {
158
- spin.stop("The workspace SDK didn't download");
162
+ spin.stop("The artifact SDK didn't download");
159
163
  throw error;
160
164
  }
161
165
  const { stage, version } = downloaded;
162
166
  try {
163
167
  if (before !== void 0 && compareVersions(before, version) > 0 && !input.force) {
164
168
  spin.stop(`Yours is newer than the latest published one, ${version}`);
165
- ctx.ui.warn(`Left workspace SDK ${before} alone. Pass --force to replace it with ${version}.`);
169
+ ctx.ui.warn(`Left artifact SDK ${before} alone. Pass --force to replace it with ${version}.`);
166
170
  return;
167
171
  }
168
172
  replaceDirectory(stage, path.join(root, VENDORED_SDK), runtime.rename);
@@ -172,19 +176,25 @@ async function runWorkspaceUpdate(ctx, input, runtime = {}) {
172
176
  force: true
173
177
  });
174
178
  }
175
- spin.stop(before === version ? `Already on the latest workspace SDK, ${version}` : `Workspace SDK ${version}`);
176
- pointPackageAtSdk(packageFile);
179
+ spin.stop(before === version ? `Already on the latest artifact SDK, ${version}` : `Artifact SDK ${version}`);
180
+ const sdkChanged = before !== version;
181
+ const packageChanged = pointPackageAtSdk(packageFile);
182
+ const changed = [...sdkChanged ? ["vendor/artifact-sdk"] : [], ...packageChanged ? ["package.json"] : []];
177
183
  if (!input.install) {
178
- ctx.ui.info("Run `npm install` to update package-lock.json, then commit vendor/workspace-sdk and the lockfile.");
184
+ if (changed.length > 0) ctx.ui.info(`Run \`npm install\` to update package-lock.json, then commit ${commitList([...changed, "the lockfile"])}.`);
179
185
  return;
180
186
  }
187
+ const lockFile = path.join(root, "package-lock.json");
188
+ const lockBefore = readIfPresent(lockFile);
181
189
  try {
182
190
  await (runtime.install ?? npmInstall)(root);
183
- ctx.ui.success("Updated package-lock.json. Commit vendor/workspace-sdk and the lockfile.");
184
191
  } catch {
185
192
  ctx.ui.warn("`npm install` failed. Run it yourself to update package-lock.json.");
193
+ return;
186
194
  }
195
+ if (readIfPresent(lockFile) !== lockBefore) ctx.ui.success(`Updated package-lock.json. Commit ${commitList([...changed, "the lockfile"])}.`);
196
+ else if (changed.length > 0) ctx.ui.success(`Commit ${commitList(changed)}.`);
187
197
  }
188
198
 
189
199
  //#endregion
190
- export { runWorkspaceCreate, runWorkspaceUpdate };
200
+ export { runArtifactCreate, runArtifactUpdate };