@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
@@ -0,0 +1,81 @@
1
+ import { t as ApiError } from "./client-DHlsTaP1.js";
2
+ import { h as writeOpenedOrgs, s as readOpenedOrgs } from "./config-CGcG7GOt.js";
3
+
4
+ //#region src/core/api/orgs.ts
5
+ async function listOrganizations(api) {
6
+ const res = await api.get("/v2/me/organizations");
7
+ return [...new Map((res.data ?? []).map((org) => [String(org.id), org])).values()];
8
+ }
9
+ function orgProjects(api, orgId) {
10
+ return api.list(`/v2/projects?organization_id=${encodeURIComponent(orgId)}`).then((projects) => projects.map((project) => ({
11
+ organization_id: orgId,
12
+ ...project
13
+ })));
14
+ }
15
+ function orgIdOf(project) {
16
+ return project.organization_id === void 0 ? void 0 : String(project.organization_id);
17
+ }
18
+ function asksForOrg(error) {
19
+ return error instanceof ApiError && error.status === 400 && /organization_id/.test(error.message);
20
+ }
21
+ async function listReachableProjects(api) {
22
+ let members = await api.list("/v2/projects").catch(async (error) => {
23
+ if (!asksForOrg(error)) throw error;
24
+ const orgs = await listOrganizations(api);
25
+ return (await Promise.all(orgs.map((org) => orgProjects(api, String(org.id))))).flat();
26
+ });
27
+ members = unique(members);
28
+ const seen = new Set(members.map(orgIdOf).filter((id) => id !== void 0));
29
+ const opened = readOpenedOrgs().filter((id) => !seen.has(id));
30
+ if (opened.length === 0) return members;
31
+ const reached = await Promise.all(opened.map((id) => {
32
+ return orgProjects(api, id).catch((error) => {
33
+ if (error instanceof ApiError && [
34
+ 400,
35
+ 403,
36
+ 404
37
+ ].includes(error.status)) return [];
38
+ throw error;
39
+ });
40
+ }));
41
+ writeOpenedOrgs(opened.filter((_, index) => (reached[index]?.length ?? 0) > 0));
42
+ return [...members, ...reached.flat()];
43
+ }
44
+ function unique(projects) {
45
+ return [...new Map(projects.map((project) => [String(project.id), project])).values()];
46
+ }
47
+ function rememberOrg(project) {
48
+ const id = project && orgIdOf(project);
49
+ if (id) writeOpenedOrgs([...readOpenedOrgs(), id]);
50
+ }
51
+ async function listOrgGroups(api) {
52
+ const [projects, memberships] = await Promise.all([listReachableProjects(api), listOrganizations(api).catch(() => [])]);
53
+ const members = new Map(memberships.map((org) => [String(org.id), org]));
54
+ const groups = /* @__PURE__ */ new Map();
55
+ for (const project of projects) {
56
+ const id = orgIdOf(project) ?? "";
57
+ const name = members.get(id)?.name;
58
+ const group = groups.get(id) ?? {
59
+ id,
60
+ name: typeof name === "string" ? name : void 0,
61
+ member: members.has(id) || id === "",
62
+ projects: []
63
+ };
64
+ group.projects.push(project);
65
+ groups.set(id, group);
66
+ }
67
+ await Promise.all([...groups.values()].filter((group) => !group.member && !group.name).map(async (group) => {
68
+ const org = await api.get(`/v2/organizations/${encodeURIComponent(group.id)}`).catch(() => void 0);
69
+ if (typeof org?.name === "string") group.name = org.name;
70
+ }));
71
+ return [...groups.values()].sort((a, b) => Number(b.member) - Number(a.member));
72
+ }
73
+ async function organizationOf(api, projectId, known) {
74
+ const local = known?.find((project) => String(project.id) === projectId);
75
+ const id = (local && orgIdOf(local)) ?? orgIdOf(await api.get(`/v2/projects/${encodeURIComponent(projectId)}`));
76
+ if (!id) throw new Error(`Couldn't tell which account project ${projectId} belongs to.`);
77
+ return id;
78
+ }
79
+
80
+ //#endregion
81
+ export { orgProjects as a, orgIdOf as i, listOrganizations as n, organizationOf as o, listReachableProjects as r, rememberOrg as s, listOrgGroups as t };
@@ -1,4 +1,4 @@
1
- import { T as resolveEnv } from "./environment-djS0ik60.js";
1
+ import { E as resolveEnv } from "./environment-FR3bcq0D.js";
2
2
  import { existsSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { dirname, join } from "node:path";
@@ -1,17 +1,17 @@
1
- import "./token-zjjlkNDF.js";
1
+ import "./token-B2PduqrR.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import "./environment-djS0ik60.js";
4
- import "./storage-CrXGgIbS.js";
5
- import "./client-ltxxHuxn.js";
3
+ import "./environment-FR3bcq0D.js";
4
+ import "./storage-CUMgpcVH.js";
5
+ import "./client-DHlsTaP1.js";
6
6
  import "./config-CGcG7GOt.js";
7
- import { i as updateTelemetryTags, r as track } from "./telemetry-BqaPbM0k.js";
7
+ import { i as updateTelemetryTags, r as track } from "./telemetry-ekUQuhLJ.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import "./spinner-1uuKKZMc.js";
9
+ import "./spinner-025_eqCX.js";
10
10
  import "./ui-D_qf3Gvw.js";
11
- import { t as scanProject } from "./scan-CRexsHOE.js";
12
- import "./paths-CdwjySxK.js";
13
- import { d as readBundledSkill } from "./skills-CiWxt6vS.js";
14
- import { n as FRAMEWORK_REF, t as detectBilling } from "./billing-C4lXR0xG.js";
11
+ import { t as scanProject } from "./scan-BZS2FZeU.js";
12
+ import "./paths-BaeoxDze.js";
13
+ import { d as readBundledSkill } from "./skills-Cm1j2d1W.js";
14
+ import { n as FRAMEWORK_REF, t as detectBilling } from "./billing-BopwIhR3.js";
15
15
 
16
16
  //#region src/core/workflows/playbook.ts
17
17
  async function printPlaybook(installDir, playbook) {
@@ -1,4 +1,4 @@
1
- import { n as ascProxyGet } from "./client-BZ1UbpXz.js";
1
+ import { n as ascProxyGet } from "./client-BJQXl62Q.js";
2
2
 
3
3
  //#region src/core/app-store-connect/store/products.ts
4
4
  function attr(r, key) {
@@ -0,0 +1,47 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+
4
+ //#region src/core/workspaces/project.ts
5
+ var WorkspaceError = class extends Error {};
6
+ const MANIFEST_FILE = "superwall.json";
7
+ const VENDORED_SDK = path.join("vendor", "workspace-sdk");
8
+ function isManifest(value) {
9
+ if (typeof value !== "object" || value === null) return false;
10
+ const { name, scopes, entrypoints } = value;
11
+ return typeof name === "string" && Array.isArray(scopes) && Array.isArray(entrypoints);
12
+ }
13
+ function readManifest(root) {
14
+ const file = path.join(root, MANIFEST_FILE);
15
+ let text;
16
+ try {
17
+ text = fs.readFileSync(file, "utf8");
18
+ } catch {
19
+ throw new WorkspaceError(`No ${MANIFEST_FILE} in ${root}. Run this inside a workspace, or start one with \`superwall workspaces create\`.`);
20
+ }
21
+ let parsed;
22
+ try {
23
+ parsed = JSON.parse(text);
24
+ } catch (error) {
25
+ throw new WorkspaceError(`${MANIFEST_FILE} is not valid JSON: ${error.message}`);
26
+ }
27
+ if (!isManifest(parsed)) throw new WorkspaceError(`${MANIFEST_FILE} needs a name, scopes and entrypoints.`);
28
+ return parsed;
29
+ }
30
+ function readProject(dir) {
31
+ const root = path.resolve(dir ?? process.cwd());
32
+ return {
33
+ root,
34
+ manifest: readManifest(root)
35
+ };
36
+ }
37
+ function findEntrypoint(manifest, id) {
38
+ const entrypoint = manifest.entrypoints.find((candidate) => candidate.id === id);
39
+ if (entrypoint) return entrypoint;
40
+ throw new WorkspaceError(`No entrypoint named \`${id}\` in ${MANIFEST_FILE}. It has: ${manifest.entrypoints.map((candidate) => candidate.id).join(", ") || "none"}.`);
41
+ }
42
+ function bundleDir(root) {
43
+ return path.join(root, ".superwall", "workspace");
44
+ }
45
+
46
+ //#endregion
47
+ export { findEntrypoint as a, bundleDir as i, VENDORED_SDK as n, readManifest as o, WorkspaceError as r, readProject as s, MANIFEST_FILE as t };
@@ -1,25 +1,31 @@
1
- import "./token-zjjlkNDF.js";
1
+ import "./token-B2PduqrR.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import { b as VERSION } from "./environment-djS0ik60.js";
4
- import "./storage-CrXGgIbS.js";
5
- import { t as ApiError } from "./client-ltxxHuxn.js";
3
+ import { x as VERSION } from "./environment-FR3bcq0D.js";
4
+ import "./storage-CUMgpcVH.js";
5
+ import { t as ApiError } from "./client-DHlsTaP1.js";
6
6
  import "./config-CGcG7GOt.js";
7
- import "./telemetry-BqaPbM0k.js";
7
+ import "./telemetry-ekUQuhLJ.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import "./spinner-1uuKKZMc.js";
9
+ import "./spinner-025_eqCX.js";
10
10
  import { n as ui } from "./ui-D_qf3Gvw.js";
11
- import "./scan-CRexsHOE.js";
12
- import "./paths-CdwjySxK.js";
13
- import { _ as livePaywallVersion, x as promotePaywallVersion } from "./resources-BMspgZO1.js";
14
- import "./lookup-us5vu5od.js";
15
- import "./login-CiK5T4w8.js";
16
- import "./skills-CiWxt6vS.js";
17
- import "./assets-W5yvyf0V.js";
18
- import { a as resolveProjectDir, g as transition, k as readLock, s as selectSurfaces, y as collectProjectDeclarations, z as resolveFramework } from "./selection-CgZJJ3FD.js";
19
- import { f as parsePlatformFlags, h as wantedPlatforms, m as targetLabel, n as requireApi, p as planTargets, v as resolveApps } from "./session-CV0P8BjK.js";
20
- import { l as resolveBinding } from "./source-push-CX_k_yZD.js";
21
- import { a as pickApplicationOption, i as timed, o as pickAdoptOption, t as group } from "./push-CR110qRh.js";
22
- import "./login-girc324T.js";
11
+ import "./scan-BZS2FZeU.js";
12
+ import "./paths-BaeoxDze.js";
13
+ import "./orgs-BxlwcvTu.js";
14
+ import { _ as livePaywallVersion, x as promotePaywallVersion } from "./resources-COOEvqqW.js";
15
+ import "./lookup-D23dAOz6.js";
16
+ import "./login-C6FcBQZg.js";
17
+ import "./skills-Cm1j2d1W.js";
18
+ import "./browser-Bp3yRKlU.js";
19
+ import "./assets-CqpFg5mM.js";
20
+ import { a as resolveProjectDir, g as transition, s as selectSurfaces, y as resolveFramework } from "./selection-CWfI4a0O.js";
21
+ import "./design-lint-CvgcSzVg.js";
22
+ import { f as readLock, n as collectProjectDeclarations } from "./types-CB6O_wjy.js";
23
+ import { c as planTargets, d as wantedPlatforms, h as resolveApps, n as requireApi, s as parsePlatformFlags, u as targetLabel } from "./session-DYdxTNZf.js";
24
+ import { u as resolveBinding } from "./source-push-B3c-VLfe.js";
25
+ import { a as pickApplicationOption, i as timed, o as pickAdoptOption, t as group } from "./push-BlZoIwIj.js";
26
+ import "./git-DqDPnldI.js";
27
+ import "./scope-t_SqFN6W.js";
28
+ import "./login-dRPPnGr7.js";
23
29
  import pc from "picocolors";
24
30
 
25
31
  //#region src/core/paywalls/promote.ts
@@ -1,31 +1,12 @@
1
- import "./token-zjjlkNDF.js";
2
- import "./output-Ggzq5_-t.js";
3
- import { b as VERSION } from "./environment-djS0ik60.js";
4
- import "./storage-CrXGgIbS.js";
5
- import "./client-ltxxHuxn.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./telemetry-BqaPbM0k.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-1uuKKZMc.js";
1
+ import { x as VERSION } from "./environment-FR3bcq0D.js";
10
2
  import { n as ui } from "./ui-D_qf3Gvw.js";
11
- import "./theme-DUsCh-Vd.js";
12
- import "./log-C0MDCfA2.js";
13
- import "./scan-CRexsHOE.js";
14
- import "./existing-Das3PHGG.js";
15
- import "./paths-CdwjySxK.js";
16
- import { f as listAppPaywalls, v as mintSourceAccess } from "./resources-BMspgZO1.js";
17
- import "./org-BrR4HGvl.js";
18
- import { n as findApplication, t as appNotFound } from "./lookup-us5vu5od.js";
19
- import "./bind-82oTpHZ3.js";
20
- import "./login-CiK5T4w8.js";
21
- import "./skills-CiWxt6vS.js";
22
- import { D as parseLock, P as writeLock, a as resolveProjectDir, b as writeProjectTypes, i as requireProject, k as readLock, v as TYPES_FILE, x as NewerLockError, y as collectProjectDeclarations, z as resolveFramework } from "./selection-CgZJJ3FD.js";
23
- import { _ as requirePlatform, c as writeSourceBase, f as parsePlatformFlags, g as PLATFORMS, i as pullSourceTree, l as collectSourceFiles, n as requireApi, o as statIfPresent, s as readSourceBase } from "./session-CV0P8BjK.js";
24
- import "./login-girc324T.js";
25
- import "./run-D4V6mq8_.js";
26
- import "./drivers-CTyYdBL7.js";
27
- import "./migration-cS6UGeUj.js";
28
- import { a as devCommand, i as detectPackageManager } from "./setup-UWLhQG3M.js";
3
+ import { f as listAppPaywalls, v as mintSourceAccess } from "./resources-COOEvqqW.js";
4
+ import { n as findApplication, t as appNotFound } from "./lookup-D23dAOz6.js";
5
+ import { a as resolveProjectDir, i as requireProject, y as resolveFramework } from "./selection-CWfI4a0O.js";
6
+ import { _ as writeLock, f as readLock, i as NewerLockError, n as collectProjectDeclarations, r as writeProjectTypes, t as TYPES_FILE, u as parseLock } from "./types-CB6O_wjy.js";
7
+ import { f as PLATFORMS, i as writeSourceBase, m as requirePlatform, n as requireApi, r as readSourceBase, s as parsePlatformFlags } from "./session-DYdxTNZf.js";
8
+ import { a as collectSourceFiles, i as statIfPresent, n as pullSourceTree } from "./git-DqDPnldI.js";
9
+ import { a as devCommand, i as detectPackageManager } from "./setup-DW50luOZ.js";
29
10
  import * as fs from "node:fs";
30
11
  import * as path from "node:path";
31
12
  import pc from "picocolors";
@@ -300,4 +281,4 @@ async function runPull(ctx, { args, flags }) {
300
281
  }
301
282
 
302
283
  //#endregion
303
- export { PullPathError, applyPulledChanges, appsToPull, boundPaywall, cloneInto, cloneTarget, mergePulledLock, pullInto, runPull };
284
+ export { cloneInto as a, pullInto as c, boundPaywall as i, runPull as l, applyPulledChanges as n, cloneTarget as o, appsToPull as r, mergePulledLock as s, PullPathError as t };
@@ -0,0 +1,36 @@
1
+ import "./token-B2PduqrR.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-FR3bcq0D.js";
4
+ import "./storage-CUMgpcVH.js";
5
+ import "./client-DHlsTaP1.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./telemetry-ekUQuhLJ.js";
8
+ import "./spawn-DmmmHIP-.js";
9
+ import "./spinner-025_eqCX.js";
10
+ import "./ui-D_qf3Gvw.js";
11
+ import "./theme-DUsCh-Vd.js";
12
+ import "./log-C0MDCfA2.js";
13
+ import "./scan-BZS2FZeU.js";
14
+ import "./existing-C6TTT6c4.js";
15
+ import "./paths-BaeoxDze.js";
16
+ import "./orgs-BxlwcvTu.js";
17
+ import "./resources-COOEvqqW.js";
18
+ import "./org-DZ41muzA.js";
19
+ import "./lookup-D23dAOz6.js";
20
+ import "./bind-DOF3o3FR.js";
21
+ import "./login-C6FcBQZg.js";
22
+ import "./skills-Cm1j2d1W.js";
23
+ import "./browser-Bp3yRKlU.js";
24
+ import "./selection-CWfI4a0O.js";
25
+ import "./types-CB6O_wjy.js";
26
+ import "./session-DYdxTNZf.js";
27
+ import "./git-DqDPnldI.js";
28
+ import "./scope-t_SqFN6W.js";
29
+ import "./login-dRPPnGr7.js";
30
+ import "./run-DpYDOAw-.js";
31
+ import "./drivers-DkboeR1c.js";
32
+ import "./migration-r9plM7F6.js";
33
+ import "./setup-DW50luOZ.js";
34
+ import { a as cloneInto, c as pullInto, i as boundPaywall, l as runPull, n as applyPulledChanges, o as cloneTarget, r as appsToPull, s as mergePulledLock, t as PullPathError } from "./pull-CQcTZxW8.js";
35
+
36
+ export { PullPathError, applyPulledChanges, appsToPull, boundPaywall, cloneInto, cloneTarget, mergePulledLock, pullInto, runPull };
@@ -0,0 +1,106 @@
1
+ import "./token-B2PduqrR.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-FR3bcq0D.js";
4
+ import "./storage-CUMgpcVH.js";
5
+ import "./client-DHlsTaP1.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./telemetry-ekUQuhLJ.js";
8
+ import "./spawn-DmmmHIP-.js";
9
+ import "./spinner-025_eqCX.js";
10
+ import "./ui-D_qf3Gvw.js";
11
+ import "./theme-DUsCh-Vd.js";
12
+ import "./log-C0MDCfA2.js";
13
+ import "./scan-BZS2FZeU.js";
14
+ import "./existing-C6TTT6c4.js";
15
+ import "./paths-BaeoxDze.js";
16
+ import "./orgs-BxlwcvTu.js";
17
+ import "./resources-COOEvqqW.js";
18
+ import "./org-DZ41muzA.js";
19
+ import "./lookup-D23dAOz6.js";
20
+ import "./bind-DOF3o3FR.js";
21
+ import "./login-C6FcBQZg.js";
22
+ import "./skills-Cm1j2d1W.js";
23
+ import "./browser-Bp3yRKlU.js";
24
+ import "./selection-CWfI4a0O.js";
25
+ import "./types-CB6O_wjy.js";
26
+ import "./session-DYdxTNZf.js";
27
+ import { a as collectSourceFiles, n as pullSourceTree } from "./git-DqDPnldI.js";
28
+ import { r as WORKSPACE_DERIVED_FILES } from "./scope-t_SqFN6W.js";
29
+ import "./login-dRPPnGr7.js";
30
+ import "./run-DpYDOAw-.js";
31
+ import "./drivers-DkboeR1c.js";
32
+ import "./migration-r9plM7F6.js";
33
+ import "./download-F8OtTJze.js";
34
+ import "./setup-DW50luOZ.js";
35
+ import { n as applyPulledChanges } from "./pull-CQcTZxW8.js";
36
+ import { c as projectRoot, f as readBinding, l as resolveWorkspace, m as writeBinding, p as readSourceFile, w as mintSourceAccess } from "./resolve-DGePiHgL.js";
37
+ import { r as WorkspaceError } from "./project-DHU5wc3R.js";
38
+ import "./organization-DIODPOwO.js";
39
+ import "./sdk-CyttTnGf.js";
40
+ import { a as toSourceAccess } from "./push-DQE48h_M.js";
41
+ import * as fs from "node:fs";
42
+ import * as path from "node:path";
43
+
44
+ //#region src/core/workspaces/pull.ts
45
+ const NOT_PUSHED = "Its source repo is empty: nobody has pushed yet. Run `superwall workspaces push` first.";
46
+ function report(ctx, slug, head, written, skipped) {
47
+ if (ctx.json) {
48
+ ctx.output.data({
49
+ slug,
50
+ head,
51
+ written,
52
+ skipped
53
+ });
54
+ return;
55
+ }
56
+ ctx.ui.success(written.length === 0 ? "Already up to date." : `Pulled ${written.length} ${written.length === 1 ? "file" : "files"} of \`${slug}\`.`);
57
+ if (written.length > 0) ctx.ui.list({ items: written.map((label) => ({ label })) });
58
+ if (skipped.length > 0) ctx.ui.warn(`Not pulled, because a file of yours that git doesn't track is in the way: ${skipped.join(", ")}. Move it, then pull again.`);
59
+ }
60
+ function assertCloneTarget(root) {
61
+ if (!fs.existsSync(root)) return;
62
+ if (fs.readdirSync(root).length > 0) throw new WorkspaceError(`${root} already has files and isn't linked to this workspace. Pick an empty directory.`);
63
+ }
64
+ async function runWorkspacePull(ctx, input) {
65
+ const root = projectRoot(input.dir);
66
+ const linked = readBinding(root);
67
+ const workspace = await resolveWorkspace(ctx, input);
68
+ if (linked && linked.workspaceId !== String(workspace.id)) throw new WorkspaceError(`This project is linked to workspace ${linked.workspaceId}, not ${workspace.id}. Pull into an empty directory instead.`);
69
+ if (!linked) assertCloneTarget(root);
70
+ fs.mkdirSync(root, { recursive: true });
71
+ const collected = linked ? await collectSourceFiles(root, readSourceFile) : {
72
+ ok: true,
73
+ files: []
74
+ };
75
+ if (!collected.ok) throw new WorkspaceError(collected.reason);
76
+ const pulled = await pullSourceTree({
77
+ access: toSourceAccess(await mintSourceAccess(ctx.api, workspace.id)),
78
+ files: collected.files,
79
+ base: linked?.syncedCommit,
80
+ theirs: input.theirs,
81
+ derived: WORKSPACE_DERIVED_FILES
82
+ });
83
+ if (pulled.status === "empty") throw new WorkspaceError(NOT_PUSHED);
84
+ const { written, skipped } = applyPulledChanges(root, pulled.changes, new Set(collected.files.map((file) => file.path)));
85
+ writeBinding(root, {
86
+ workspaceId: String(workspace.id),
87
+ organizationId: String(workspace.organization_id),
88
+ slug: workspace.slug,
89
+ ...skipped.length > 0 ? {
90
+ syncedCommit: linked?.syncedCommit,
91
+ reviewedCommit: linked?.reviewedCommit
92
+ } : {
93
+ syncedCommit: pulled.head,
94
+ reviewedCommit: pulled.head
95
+ }
96
+ });
97
+ report(ctx, workspace.slug, pulled.head, written, skipped);
98
+ if (linked && written.length > 0 && !ctx.json) ctx.ui.info("Read what came in before you push: your own copy runs all of it with your reads.");
99
+ if (!linked && !ctx.json) {
100
+ const where = path.relative(process.cwd(), root) || ".";
101
+ ctx.ui.info(`Next: cd ${where} && npm install && superwall workspaces dev`);
102
+ }
103
+ }
104
+
105
+ //#endregion
106
+ export { runWorkspacePull };
@@ -1,10 +1,13 @@
1
- import { b as VERSION } from "./environment-djS0ik60.js";
1
+ import { x as VERSION } from "./environment-FR3bcq0D.js";
2
2
  import { n as ui } from "./ui-D_qf3Gvw.js";
3
- import { C as pushPaywallVersion, D as versionProducts, b as platformStore, g as livePaywall, w as pushedProducts, x as promotePaywallVersion, y as platformLabel } from "./resources-BMspgZO1.js";
4
- import { n as requireAssets, r as syncAssets, t as assetBaseUrl } from "./assets-W5yvyf0V.js";
5
- import { A as removeBinding, I as writeSnapshot, N as writeBindings, R as frameworkVersion, S as describeBindings, _ as weight, a as resolveProjectDir, b as writeProjectTypes, c as storesDiffer, d as kb, f as pendingPromoteWarning, g as transition, h as took, i as requireProject, k as readLock, l as BIND_VERB, m as resolveNote, p as pushedLine, r as requireClean, s as selectSurfaces, t as needsWork, y as collectProjectDeclarations, z as resolveFramework } from "./selection-CgZJJ3FD.js";
6
- import { d as writeProjectScaffold, f as parsePlatformFlags, h as wantedPlatforms, l as collectSourceFiles, m as targetLabel, n as requireApi, p as planTargets, v as resolveApps } from "./session-CV0P8BjK.js";
7
- import { a as listProjectCatalogue, c as requireProducts, l as resolveBinding, n as pushSource, r as warnNotPortable, s as projectForApplication, t as assertGit } from "./source-push-CX_k_yZD.js";
3
+ import { C as pushPaywallVersion, D as versionProducts, b as platformStore, g as livePaywall, w as pushedProducts, x as promotePaywallVersion, y as platformLabel } from "./resources-COOEvqqW.js";
4
+ import { n as requireAssets, r as syncAssets, t as assetBaseUrl } from "./assets-CqpFg5mM.js";
5
+ import { _ as weight, a as resolveProjectDir, c as storesDiffer, d as kb, f as pendingPromoteWarning, g as transition, h as took, i as requireProject, l as BIND_VERB, m as resolveNote, p as pushedLine, r as requireClean, s as selectSurfaces, t as needsWork, v as frameworkVersion, y as resolveFramework } from "./selection-CWfI4a0O.js";
6
+ import { n as lintDesignTokens, t as formatTokenFinding } from "./design-lint-CvgcSzVg.js";
7
+ import { a as describeBindings, f as readLock, g as writeBindings, n as collectProjectDeclarations, p as removeBinding, r as writeProjectTypes, y as writeSnapshot } from "./types-CB6O_wjy.js";
8
+ import { c as planTargets, d as wantedPlatforms, h as resolveApps, l as surfaceKey, n as requireApi, o as writeProjectScaffold, p as platformFor, s as parsePlatformFlags, u as targetLabel } from "./session-DYdxTNZf.js";
9
+ import { c as projectForApplication, i as warnNotPortable, l as requireProducts, n as pushProjectSource, o as listProjectCatalogue, r as pushSource, t as assertGit, u as resolveBinding } from "./source-push-B3c-VLfe.js";
10
+ import { a as collectSourceFiles } from "./git-DqDPnldI.js";
8
11
  import { cpus } from "node:os";
9
12
  import pc from "picocolors";
10
13
 
@@ -242,21 +245,74 @@ function summary(outcomes, skipped, promoted) {
242
245
  ui.outro(`${count} ${noun(count)} pushed${unchanged} · run \`superwall promote\` to publish ${count === 1 ? "it" : "them"}.`);
243
246
  }
244
247
  const BUILD_CONCURRENCY = Math.max(2, Math.min(8, cpus().length - 1));
248
+ const isBound = (lock, target) => {
249
+ return (target.surface.kind === "paywall" ? lock.paywalls : lock.funnels)[target.surface.id]?.[target.platform] !== void 0;
250
+ };
251
+ function boundScope(lock, surfaces, declared, only) {
252
+ const allowed = only.map((entry) => platformFor(lock.apps, entry) ?? entry);
253
+ const wanted = (platform) => only.length === 0 || allowed.includes(platform);
254
+ const apps = Object.fromEntries(Object.entries(lock.apps).filter(([platform]) => wanted(platform)));
255
+ const scoped = [];
256
+ const narrowed = { ...declared };
257
+ const unbound = [];
258
+ for (const surface of surfaces) {
259
+ const platforms = declared[surfaceKey(surface)];
260
+ if (platforms === void 0) {
261
+ if (Object.keys(lock.apps).length > 1) planTargets({
262
+ surfaces: [surface],
263
+ declared,
264
+ apps: lock.apps
265
+ });
266
+ if (Object.keys(apps).length > 0) scoped.push(surface);
267
+ continue;
268
+ }
269
+ const kept = [];
270
+ for (const platform of platforms) {
271
+ if (!wanted(platform)) continue;
272
+ if (isBound(lock, {
273
+ surface,
274
+ platform
275
+ })) kept.push(platform);
276
+ else unbound.push({
277
+ surface,
278
+ platform
279
+ });
280
+ }
281
+ narrowed[surfaceKey(surface)] = kept;
282
+ if (kept.length > 0) scoped.push(surface);
283
+ }
284
+ return {
285
+ surfaces: scoped,
286
+ declared: narrowed,
287
+ apps,
288
+ unbound
289
+ };
290
+ }
245
291
  async function prepare(context, input) {
246
- const { framework, project, surfaces, declared } = input;
247
- const apps = await resolveApps({
292
+ const { framework, project } = input;
293
+ const only = parsePlatformFlags(input.platforms);
294
+ const lock = readLock(project.superwallDir);
295
+ const scope = input.existing ? boundScope(lock, input.surfaces, input.declared, only) : {
296
+ surfaces: input.surfaces,
297
+ declared: input.declared,
298
+ apps: void 0,
299
+ unbound: []
300
+ };
301
+ const apps = scope.apps ?? await resolveApps({
248
302
  api: context.api,
249
303
  superwallDir: project.superwallDir,
250
- wanted: wantedPlatforms(surfaces, declared),
304
+ wanted: wantedPlatforms(scope.surfaces, scope.declared),
251
305
  pickApplication: context.interactive ? pickApplicationOption : void 0
252
306
  });
253
- const multi = Object.keys(apps).length > 1;
254
- const targets = planTargets({
255
- surfaces,
256
- declared,
307
+ const multi = Object.keys(input.existing ? lock.apps : apps).length > 1;
308
+ const planned = scope.surfaces.length === 0 ? [] : planTargets({
309
+ surfaces: scope.surfaces,
310
+ declared: scope.declared,
257
311
  apps,
258
- only: parsePlatformFlags(input.platforms)
312
+ only: input.existing ? [] : only
259
313
  });
314
+ const targets = input.existing ? planned.filter((target) => isBound(lock, target)) : planned;
315
+ const unbound = [...scope.unbound, ...planned.filter((target) => !targets.includes(target))];
260
316
  const spin = context.outputMode === "rich" ? ui.spinner() : void 0;
261
317
  const label = targets.length === 1 && targets[0] !== void 0 ? targetLabel(targets[0], multi) : `${targets.length} paywalls`;
262
318
  spin?.start(`Building ${label}`);
@@ -305,8 +361,8 @@ async function prepare(context, input) {
305
361
  if (!bind || !build) throw new Error(`Missing binding for ${target.surface.id}`);
306
362
  requireAssets(build);
307
363
  const live = await livePaywall(context.api, bind.paywallId);
308
- const lock = readLock(project.superwallDir);
309
- const recorded = (target.surface.kind === "paywall" ? lock.paywalls : lock.funnels)[target.surface.id]?.[target.platform];
364
+ const current = readLock(project.superwallDir);
365
+ const recorded = (target.surface.kind === "paywall" ? current.paywalls : current.funnels)[target.surface.id]?.[target.platform];
310
366
  const stores = catalogueOf(target)?.stores ?? {};
311
367
  const unsourced = recorded?.snapshot === build.snapshotId ? recorded.sourcePending : void 0;
312
368
  const stale = needsWork(build.snapshotId, recorded?.snapshot, live.snapshotId);
@@ -327,7 +383,8 @@ async function prepare(context, input) {
327
383
  spin?.stop(`${pc.bold(`Built ${label}`)} ${pc.dim(`${modified} modified · ${prepared.length - modified} unchanged`)} ${took(at)}`);
328
384
  return {
329
385
  prepared,
330
- multi
386
+ multi,
387
+ unbound
331
388
  };
332
389
  } catch (error) {
333
390
  spin?.stop(pc.red(`Building ${label} failed`));
@@ -397,13 +454,16 @@ async function runPushPipeline(context, options) {
397
454
  const source = await collectSourceFiles(project.superwallDir);
398
455
  const outcomes = [];
399
456
  const external = /* @__PURE__ */ new Set();
400
- const { prepared, multi } = await prepare(context, {
457
+ for (const finding of lintDesignTokens(project, surfaces)) ui.warn(formatTokenFinding(finding));
458
+ const { prepared, multi, unbound } = await prepare(context, {
401
459
  framework,
402
460
  project,
403
461
  surfaces,
404
462
  declared: declarations.platforms,
405
- platforms: options.platforms ?? []
463
+ platforms: options.platforms ?? [],
464
+ existing: options.existing === true
406
465
  });
466
+ for (const target of unbound) ui.step(`${targetLabel(target, multi)} skipped ${pc.dim("(not on Superwall yet; --existing never creates one)")}`);
407
467
  for (const entry of prepared) for (const source$1 of entry.build.externalSources ?? []) external.add(source$1);
408
468
  const changed = prepared.filter((entry) => entry.changed);
409
469
  const skipped = prepared.length - changed.length;
@@ -474,9 +534,49 @@ async function runPushPipeline(context, options) {
474
534
  live
475
535
  });
476
536
  }
537
+ if (options.source) await pushSourceAlone(context, {
538
+ project,
539
+ prepared,
540
+ synced: new Set(changed.map((entry) => entry.bind.applicationId)),
541
+ multi,
542
+ files: source,
543
+ framework: installed,
544
+ note: publishNote,
545
+ overwrite: options.overwriteSource
546
+ });
477
547
  warnNotPortable(external);
478
548
  summary(outcomes, skipped, options.promote);
479
549
  }
550
+ async function pushSourceAlone(context, input) {
551
+ if (input.prepared.length === 0) throw new Error("--source needs a paywall that is already on Superwall to push the source through.");
552
+ const through = /* @__PURE__ */ new Map();
553
+ for (const entry of input.prepared) {
554
+ const { applicationId } = entry.bind;
555
+ if (!input.synced.has(applicationId) && !through.has(applicationId)) through.set(applicationId, entry);
556
+ }
557
+ if (through.size === 0) return;
558
+ if (!input.files.ok) throw new Error(input.files.reason);
559
+ await assertGit();
560
+ const files = input.files.files;
561
+ for (const { bind, target } of through.values()) {
562
+ const label = input.multi ? `Project source · ${target.platform}` : "Project source";
563
+ await group(context.outputMode, label, async () => {
564
+ const pushed = await timed(() => pushProjectSource({
565
+ api: context.api,
566
+ superwallDir: input.project.superwallDir,
567
+ paywallId: bind.paywallId,
568
+ applicationId: bind.applicationId,
569
+ files,
570
+ framework: input.framework,
571
+ cli: VERSION,
572
+ note: input.note,
573
+ overwrite: input.overwrite
574
+ }));
575
+ const sha = pc.dim(pushed.value.commitSha.slice(0, 7));
576
+ return [`Source ${pushed.value.status === "unchanged" ? "unchanged" : "pushed"} ${sha} ${pushed.took}`];
577
+ });
578
+ }
579
+ }
480
580
  async function runPush(ctx, { args, flags }, promote) {
481
581
  await runPushPipeline({
482
582
  api: await requireApi(ctx.interactive),
@@ -489,7 +589,9 @@ async function runPush(ctx, { args, flags }, promote) {
489
589
  platforms: flags.platform,
490
590
  renames: flags.rename,
491
591
  message: flags.message,
492
- overwriteSource: flags.overwriteSource
592
+ overwriteSource: flags.overwriteSource,
593
+ existing: flags.existing,
594
+ source: flags.source
493
595
  });
494
596
  }
495
597
 
@@ -0,0 +1,30 @@
1
+ import "./token-B2PduqrR.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-FR3bcq0D.js";
4
+ import "./storage-CUMgpcVH.js";
5
+ import "./client-DHlsTaP1.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./telemetry-ekUQuhLJ.js";
8
+ import "./spawn-DmmmHIP-.js";
9
+ import "./spinner-025_eqCX.js";
10
+ import "./ui-D_qf3Gvw.js";
11
+ import "./scan-BZS2FZeU.js";
12
+ import "./paths-BaeoxDze.js";
13
+ import "./orgs-BxlwcvTu.js";
14
+ import "./resources-COOEvqqW.js";
15
+ import "./lookup-D23dAOz6.js";
16
+ import "./login-C6FcBQZg.js";
17
+ import "./skills-Cm1j2d1W.js";
18
+ import "./browser-Bp3yRKlU.js";
19
+ import "./assets-CqpFg5mM.js";
20
+ import "./selection-CWfI4a0O.js";
21
+ import "./design-lint-CvgcSzVg.js";
22
+ import "./types-CB6O_wjy.js";
23
+ import "./session-DYdxTNZf.js";
24
+ import "./source-push-B3c-VLfe.js";
25
+ import { i as timed, n as runPush, r as runPushPipeline, t as group } from "./push-BlZoIwIj.js";
26
+ import "./git-DqDPnldI.js";
27
+ import "./scope-t_SqFN6W.js";
28
+ import "./login-dRPPnGr7.js";
29
+
30
+ export { group, runPush, runPushPipeline, timed };